pci.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License as published by the
  4. * Free Software Foundation; either version 2 of the License, or (at your
  5. * option) any later version.
  6. *
  7. * Copyright (C) 2003, 04, 11 Ralf Baechle (ralf@linux-mips.org)
  8. * Copyright (C) 2011 Wind River Systems,
  9. * written by Ralf Baechle (ralf@linux-mips.org)
  10. */
  11. #include <linux/bug.h>
  12. #include <linux/kernel.h>
  13. #include <linux/mm.h>
  14. #include <linux/bootmem.h>
  15. #include <linux/export.h>
  16. #include <linux/init.h>
  17. #include <linux/types.h>
  18. #include <linux/pci.h>
  19. #include <linux/of_address.h>
  20. #include <asm/cpu-info.h>
  21. unsigned long PCIBIOS_MIN_IO;
  22. EXPORT_SYMBOL(PCIBIOS_MIN_IO);
  23. unsigned long PCIBIOS_MIN_MEM;
  24. EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
  25. static int __init pcibios_set_cache_line_size(void)
  26. {
  27. struct cpuinfo_mips *c = &current_cpu_data;
  28. unsigned int lsize;
  29. /*
  30. * Set PCI cacheline size to that of the highest level in the
  31. * cache hierarchy.
  32. */
  33. lsize = c->dcache.linesz;
  34. lsize = c->scache.linesz ? : lsize;
  35. lsize = c->tcache.linesz ? : lsize;
  36. BUG_ON(!lsize);
  37. pci_dfl_cache_line_size = lsize >> 2;
  38. pr_debug("PCI: pci_cache_line_size set to %d bytes\n", lsize);
  39. return 0;
  40. }
  41. arch_initcall(pcibios_set_cache_line_size);
  42. void pci_resource_to_user(const struct pci_dev *dev, int bar,
  43. const struct resource *rsrc, resource_size_t *start,
  44. resource_size_t *end)
  45. {
  46. phys_addr_t size = resource_size(rsrc);
  47. *start = fixup_bigphys_addr(rsrc->start, size);
  48. *end = rsrc->start + size - 1;
  49. }
  50. int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
  51. enum pci_mmap_state mmap_state, int write_combine)
  52. {
  53. unsigned long prot;
  54. /*
  55. * I/O space can be accessed via normal processor loads and stores on
  56. * this platform but for now we elect not to do this and portable
  57. * drivers should not do this anyway.
  58. */
  59. if (mmap_state == pci_mmap_io)
  60. return -EINVAL;
  61. /*
  62. * Ignore write-combine; for now only return uncached mappings.
  63. */
  64. prot = pgprot_val(vma->vm_page_prot);
  65. prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED;
  66. vma->vm_page_prot = __pgprot(prot);
  67. return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
  68. vma->vm_end - vma->vm_start, vma->vm_page_prot);
  69. }