diff options
| author | David Daney <david.daney@cavium.com> | 2011-11-22 09:47:04 -0500 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2011-12-07 17:03:29 -0500 |
| commit | 714c1f5c1aab1cc185018f02bcc854c41ff8e6c8 (patch) | |
| tree | 23e47a57ecfac9ad6b70efcb9bf59e6a94b5bc93 | |
| parent | 26afc5e399a4ab33a04216a37cd996ee224976a0 (diff) | |
MIPS: Octeon: Update DMA mapping operations for OCTEON II processors.
OCTEON II has a new dma to phys mapping method for PCIe. Define
OCTEON_DMA_BAR_TYPE_PCIE2 to denote this case, and handle it.
OCTEON II also needs a swiotlb if the OHCI USB driver is enabled, so
allocate this too.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2983/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
| -rw-r--r-- | arch/mips/cavium-octeon/dma-octeon.c | 23 | ||||
| -rw-r--r-- | arch/mips/include/asm/octeon/pci-octeon.h | 3 |
2 files changed, 23 insertions, 3 deletions
diff --git a/arch/mips/cavium-octeon/dma-octeon.c b/arch/mips/cavium-octeon/dma-octeon.c index ea4febaa4bb1..b6bb92c16a47 100644 --- a/arch/mips/cavium-octeon/dma-octeon.c +++ b/arch/mips/cavium-octeon/dma-octeon.c | |||
| @@ -61,6 +61,16 @@ static phys_addr_t octeon_gen1_dma_to_phys(struct device *dev, dma_addr_t daddr) | |||
| 61 | return daddr; | 61 | return daddr; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static dma_addr_t octeon_gen2_phys_to_dma(struct device *dev, phys_addr_t paddr) | ||
| 65 | { | ||
| 66 | return octeon_hole_phys_to_dma(paddr); | ||
| 67 | } | ||
| 68 | |||
| 69 | static phys_addr_t octeon_gen2_dma_to_phys(struct device *dev, dma_addr_t daddr) | ||
| 70 | { | ||
| 71 | return octeon_hole_dma_to_phys(daddr); | ||
| 72 | } | ||
| 73 | |||
| 64 | static dma_addr_t octeon_big_phys_to_dma(struct device *dev, phys_addr_t paddr) | 74 | static dma_addr_t octeon_big_phys_to_dma(struct device *dev, phys_addr_t paddr) |
| 65 | { | 75 | { |
| 66 | if (paddr >= 0x410000000ull && paddr < 0x420000000ull) | 76 | if (paddr >= 0x410000000ull && paddr < 0x420000000ull) |
| @@ -262,11 +272,11 @@ void __init plat_swiotlb_setup(void) | |||
| 262 | 272 | ||
| 263 | for (i = 0 ; i < boot_mem_map.nr_map; i++) { | 273 | for (i = 0 ; i < boot_mem_map.nr_map; i++) { |
| 264 | struct boot_mem_map_entry *e = &boot_mem_map.map[i]; | 274 | struct boot_mem_map_entry *e = &boot_mem_map.map[i]; |
| 265 | if (e->type != BOOT_MEM_RAM) | 275 | if (e->type != BOOT_MEM_RAM && e->type != BOOT_MEM_INIT_RAM) |
| 266 | continue; | 276 | continue; |
| 267 | 277 | ||
| 268 | /* These addresses map low for PCI. */ | 278 | /* These addresses map low for PCI. */ |
| 269 | if (e->addr > 0x410000000ull) | 279 | if (e->addr > 0x410000000ull && !OCTEON_IS_MODEL(OCTEON_CN6XXX)) |
| 270 | continue; | 280 | continue; |
| 271 | 281 | ||
| 272 | addr_size += e->size; | 282 | addr_size += e->size; |
| @@ -296,6 +306,11 @@ void __init plat_swiotlb_setup(void) | |||
| 296 | swiotlbsize = 64 * (1<<20); | 306 | swiotlbsize = 64 * (1<<20); |
| 297 | } | 307 | } |
| 298 | #endif | 308 | #endif |
| 309 | #ifdef CONFIG_USB_OCTEON_OHCI | ||
| 310 | /* OCTEON II ohci is only 32-bit. */ | ||
| 311 | if (OCTEON_IS_MODEL(OCTEON_CN6XXX) && max_addr >= 0x100000000ul) | ||
| 312 | swiotlbsize = 64 * (1<<20); | ||
| 313 | #endif | ||
| 299 | swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT; | 314 | swiotlb_nslabs = swiotlbsize >> IO_TLB_SHIFT; |
| 300 | swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE); | 315 | swiotlb_nslabs = ALIGN(swiotlb_nslabs, IO_TLB_SEGSIZE); |
| 301 | swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT; | 316 | swiotlbsize = swiotlb_nslabs << IO_TLB_SHIFT; |
| @@ -330,6 +345,10 @@ struct dma_map_ops *octeon_pci_dma_map_ops; | |||
| 330 | void __init octeon_pci_dma_init(void) | 345 | void __init octeon_pci_dma_init(void) |
| 331 | { | 346 | { |
| 332 | switch (octeon_dma_bar_type) { | 347 | switch (octeon_dma_bar_type) { |
| 348 | case OCTEON_DMA_BAR_TYPE_PCIE2: | ||
| 349 | _octeon_pci_dma_map_ops.phys_to_dma = octeon_gen2_phys_to_dma; | ||
| 350 | _octeon_pci_dma_map_ops.dma_to_phys = octeon_gen2_dma_to_phys; | ||
| 351 | break; | ||
| 333 | case OCTEON_DMA_BAR_TYPE_PCIE: | 352 | case OCTEON_DMA_BAR_TYPE_PCIE: |
| 334 | _octeon_pci_dma_map_ops.phys_to_dma = octeon_gen1_phys_to_dma; | 353 | _octeon_pci_dma_map_ops.phys_to_dma = octeon_gen1_phys_to_dma; |
| 335 | _octeon_pci_dma_map_ops.dma_to_phys = octeon_gen1_dma_to_phys; | 354 | _octeon_pci_dma_map_ops.dma_to_phys = octeon_gen1_dma_to_phys; |
diff --git a/arch/mips/include/asm/octeon/pci-octeon.h b/arch/mips/include/asm/octeon/pci-octeon.h index fba2ba200f58..c66734bd3382 100644 --- a/arch/mips/include/asm/octeon/pci-octeon.h +++ b/arch/mips/include/asm/octeon/pci-octeon.h | |||
| @@ -56,7 +56,8 @@ enum octeon_dma_bar_type { | |||
| 56 | OCTEON_DMA_BAR_TYPE_INVALID, | 56 | OCTEON_DMA_BAR_TYPE_INVALID, |
| 57 | OCTEON_DMA_BAR_TYPE_SMALL, | 57 | OCTEON_DMA_BAR_TYPE_SMALL, |
| 58 | OCTEON_DMA_BAR_TYPE_BIG, | 58 | OCTEON_DMA_BAR_TYPE_BIG, |
| 59 | OCTEON_DMA_BAR_TYPE_PCIE | 59 | OCTEON_DMA_BAR_TYPE_PCIE, |
| 60 | OCTEON_DMA_BAR_TYPE_PCIE2 | ||
| 60 | }; | 61 | }; |
| 61 | 62 | ||
| 62 | /* | 63 | /* |
