diff options
Diffstat (limited to 'drivers/parisc/ccio-dma.c')
-rw-r--r-- | drivers/parisc/ccio-dma.c | 136 |
1 files changed, 78 insertions, 58 deletions
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c index 80d0927dc8a4..f1c442ab9102 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c | |||
@@ -100,9 +100,9 @@ | |||
100 | #define DBG_RUN_SG(x...) | 100 | #define DBG_RUN_SG(x...) |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | #define CCIO_INLINE /* inline */ | 103 | #define CCIO_INLINE inline |
104 | #define WRITE_U32(value, addr) gsc_writel(value, (u32 *)(addr)) | 104 | #define WRITE_U32(value, addr) __raw_writel(value, addr) |
105 | #define READ_U32(addr) gsc_readl((u32 *)(addr)) | 105 | #define READ_U32(addr) __raw_readl(addr) |
106 | 106 | ||
107 | #define U2_IOA_RUNWAY 0x580 | 107 | #define U2_IOA_RUNWAY 0x580 |
108 | #define U2_BC_GSC 0x501 | 108 | #define U2_BC_GSC 0x501 |
@@ -115,28 +115,28 @@ | |||
115 | 115 | ||
116 | struct ioa_registers { | 116 | struct ioa_registers { |
117 | /* Runway Supervisory Set */ | 117 | /* Runway Supervisory Set */ |
118 | volatile int32_t unused1[12]; | 118 | int32_t unused1[12]; |
119 | volatile uint32_t io_command; /* Offset 12 */ | 119 | uint32_t io_command; /* Offset 12 */ |
120 | volatile uint32_t io_status; /* Offset 13 */ | 120 | uint32_t io_status; /* Offset 13 */ |
121 | volatile uint32_t io_control; /* Offset 14 */ | 121 | uint32_t io_control; /* Offset 14 */ |
122 | volatile int32_t unused2[1]; | 122 | int32_t unused2[1]; |
123 | 123 | ||
124 | /* Runway Auxiliary Register Set */ | 124 | /* Runway Auxiliary Register Set */ |
125 | volatile uint32_t io_err_resp; /* Offset 0 */ | 125 | uint32_t io_err_resp; /* Offset 0 */ |
126 | volatile uint32_t io_err_info; /* Offset 1 */ | 126 | uint32_t io_err_info; /* Offset 1 */ |
127 | volatile uint32_t io_err_req; /* Offset 2 */ | 127 | uint32_t io_err_req; /* Offset 2 */ |
128 | volatile uint32_t io_err_resp_hi; /* Offset 3 */ | 128 | uint32_t io_err_resp_hi; /* Offset 3 */ |
129 | volatile uint32_t io_tlb_entry_m; /* Offset 4 */ | 129 | uint32_t io_tlb_entry_m; /* Offset 4 */ |
130 | volatile uint32_t io_tlb_entry_l; /* Offset 5 */ | 130 | uint32_t io_tlb_entry_l; /* Offset 5 */ |
131 | volatile uint32_t unused3[1]; | 131 | uint32_t unused3[1]; |
132 | volatile uint32_t io_pdir_base; /* Offset 7 */ | 132 | uint32_t io_pdir_base; /* Offset 7 */ |
133 | volatile uint32_t io_io_low_hv; /* Offset 8 */ | 133 | uint32_t io_io_low_hv; /* Offset 8 */ |
134 | volatile uint32_t io_io_high_hv; /* Offset 9 */ | 134 | uint32_t io_io_high_hv; /* Offset 9 */ |
135 | volatile uint32_t unused4[1]; | 135 | uint32_t unused4[1]; |
136 | volatile uint32_t io_chain_id_mask; /* Offset 11 */ | 136 | uint32_t io_chain_id_mask; /* Offset 11 */ |
137 | volatile uint32_t unused5[2]; | 137 | uint32_t unused5[2]; |
138 | volatile uint32_t io_io_low; /* Offset 14 */ | 138 | uint32_t io_io_low; /* Offset 14 */ |
139 | volatile uint32_t io_io_high; /* Offset 15 */ | 139 | uint32_t io_io_high; /* Offset 15 */ |
140 | }; | 140 | }; |
141 | 141 | ||
142 | /* | 142 | /* |
@@ -226,7 +226,7 @@ struct ioa_registers { | |||
226 | */ | 226 | */ |
227 | 227 | ||
228 | struct ioc { | 228 | struct ioc { |
229 | struct ioa_registers *ioc_hpa; /* I/O MMU base address */ | 229 | struct ioa_registers __iomem *ioc_regs; /* I/O MMU base address */ |
230 | u8 *res_map; /* resource map, bit == pdir entry */ | 230 | u8 *res_map; /* resource map, bit == pdir entry */ |
231 | u64 *pdir_base; /* physical base address */ | 231 | u64 *pdir_base; /* physical base address */ |
232 | u32 pdir_size; /* bytes, function of IOV Space size */ | 232 | u32 pdir_size; /* bytes, function of IOV Space size */ |
@@ -595,7 +595,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, | |||
595 | ** Grab virtual index [0:11] | 595 | ** Grab virtual index [0:11] |
596 | ** Deposit virt_idx bits into I/O PDIR word | 596 | ** Deposit virt_idx bits into I/O PDIR word |
597 | */ | 597 | */ |
598 | asm volatile ("lci 0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba)); | 598 | asm volatile ("lci %%r0(%%sr1, %1), %0" : "=r" (ci) : "r" (vba)); |
599 | asm volatile ("extru %1,19,12,%0" : "+r" (ci) : "r" (ci)); | 599 | asm volatile ("extru %1,19,12,%0" : "+r" (ci) : "r" (ci)); |
600 | asm volatile ("depw %1,15,12,%0" : "+r" (pa) : "r" (ci)); | 600 | asm volatile ("depw %1,15,12,%0" : "+r" (pa) : "r" (ci)); |
601 | 601 | ||
@@ -613,7 +613,7 @@ ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba, | |||
613 | ** the real mode coherence index generation of U2, the PDIR entry | 613 | ** the real mode coherence index generation of U2, the PDIR entry |
614 | ** must be flushed to memory to retain coherence." | 614 | ** must be flushed to memory to retain coherence." |
615 | */ | 615 | */ |
616 | asm volatile("fdc 0(%0)" : : "r" (pdir_ptr)); | 616 | asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr)); |
617 | asm volatile("sync"); | 617 | asm volatile("sync"); |
618 | } | 618 | } |
619 | 619 | ||
@@ -636,7 +636,7 @@ ccio_clear_io_tlb(struct ioc *ioc, dma_addr_t iovp, size_t byte_cnt) | |||
636 | byte_cnt += chain_size; | 636 | byte_cnt += chain_size; |
637 | 637 | ||
638 | while(byte_cnt > chain_size) { | 638 | while(byte_cnt > chain_size) { |
639 | WRITE_U32(CMD_TLB_PURGE | iovp, &ioc->ioc_hpa->io_command); | 639 | WRITE_U32(CMD_TLB_PURGE | iovp, &ioc->ioc_regs->io_command); |
640 | iovp += chain_size; | 640 | iovp += chain_size; |
641 | byte_cnt -= chain_size; | 641 | byte_cnt -= chain_size; |
642 | } | 642 | } |
@@ -684,7 +684,7 @@ ccio_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt) | |||
684 | ** Hopefully someone figures out how to patch (NOP) the | 684 | ** Hopefully someone figures out how to patch (NOP) the |
685 | ** FDC/SYNC out at boot time. | 685 | ** FDC/SYNC out at boot time. |
686 | */ | 686 | */ |
687 | asm volatile("fdc 0(%0)" : : "r" (pdir_ptr[7])); | 687 | asm volatile("fdc %%r0(%0)" : : "r" (pdir_ptr[7])); |
688 | 688 | ||
689 | iovp += IOVP_SIZE; | 689 | iovp += IOVP_SIZE; |
690 | byte_cnt -= IOVP_SIZE; | 690 | byte_cnt -= IOVP_SIZE; |
@@ -1314,14 +1314,13 @@ ccio_ioc_init(struct ioc *ioc) | |||
1314 | 1314 | ||
1315 | ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); | 1315 | ioc->pdir_size = (iova_space_size / IOVP_SIZE) * sizeof(u64); |
1316 | 1316 | ||
1317 | BUG_ON(ioc->pdir_size >= 4 * 1024 * 1024); /* max pdir size < 4MB */ | 1317 | BUG_ON(ioc->pdir_size > 8 * 1024 * 1024); /* max pdir size <= 8MB */ |
1318 | 1318 | ||
1319 | /* Verify it's a power of two */ | 1319 | /* Verify it's a power of two */ |
1320 | BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT)); | 1320 | BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT)); |
1321 | 1321 | ||
1322 | DBG_INIT("%s() hpa 0x%lx mem %luMB IOV %dMB (%d bits)\n", | 1322 | DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n", |
1323 | __FUNCTION__, | 1323 | __FUNCTION__, ioc->ioc_regs, |
1324 | ioc->ioc_hpa, | ||
1325 | (unsigned long) num_physpages >> (20 - PAGE_SHIFT), | 1324 | (unsigned long) num_physpages >> (20 - PAGE_SHIFT), |
1326 | iova_space_size>>20, | 1325 | iova_space_size>>20, |
1327 | iov_order + PAGE_SHIFT); | 1326 | iov_order + PAGE_SHIFT); |
@@ -1329,13 +1328,12 @@ ccio_ioc_init(struct ioc *ioc) | |||
1329 | ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, | 1328 | ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, |
1330 | get_order(ioc->pdir_size)); | 1329 | get_order(ioc->pdir_size)); |
1331 | if(NULL == ioc->pdir_base) { | 1330 | if(NULL == ioc->pdir_base) { |
1332 | panic("%s:%s() could not allocate I/O Page Table\n", __FILE__, | 1331 | panic("%s() could not allocate I/O Page Table\n", __FUNCTION__); |
1333 | __FUNCTION__); | ||
1334 | } | 1332 | } |
1335 | memset(ioc->pdir_base, 0, ioc->pdir_size); | 1333 | memset(ioc->pdir_base, 0, ioc->pdir_size); |
1336 | 1334 | ||
1337 | BUG_ON((((unsigned long)ioc->pdir_base) & PAGE_MASK) != (unsigned long)ioc->pdir_base); | 1335 | BUG_ON((((unsigned long)ioc->pdir_base) & PAGE_MASK) != (unsigned long)ioc->pdir_base); |
1338 | DBG_INIT(" base %p", ioc->pdir_base); | 1336 | DBG_INIT(" base %p\n", ioc->pdir_base); |
1339 | 1337 | ||
1340 | /* resource map size dictated by pdir_size */ | 1338 | /* resource map size dictated by pdir_size */ |
1341 | ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3; | 1339 | ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3; |
@@ -1344,8 +1342,7 @@ ccio_ioc_init(struct ioc *ioc) | |||
1344 | ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, | 1342 | ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, |
1345 | get_order(ioc->res_size)); | 1343 | get_order(ioc->res_size)); |
1346 | if(NULL == ioc->res_map) { | 1344 | if(NULL == ioc->res_map) { |
1347 | panic("%s:%s() could not allocate resource map\n", __FILE__, | 1345 | panic("%s() could not allocate resource map\n", __FUNCTION__); |
1348 | __FUNCTION__); | ||
1349 | } | 1346 | } |
1350 | memset(ioc->res_map, 0, ioc->res_size); | 1347 | memset(ioc->res_map, 0, ioc->res_size); |
1351 | 1348 | ||
@@ -1366,44 +1363,58 @@ ccio_ioc_init(struct ioc *ioc) | |||
1366 | ** Initialize IOA hardware | 1363 | ** Initialize IOA hardware |
1367 | */ | 1364 | */ |
1368 | WRITE_U32(CCIO_CHAINID_MASK << ioc->chainid_shift, | 1365 | WRITE_U32(CCIO_CHAINID_MASK << ioc->chainid_shift, |
1369 | &ioc->ioc_hpa->io_chain_id_mask); | 1366 | &ioc->ioc_regs->io_chain_id_mask); |
1370 | 1367 | ||
1371 | WRITE_U32(virt_to_phys(ioc->pdir_base), | 1368 | WRITE_U32(virt_to_phys(ioc->pdir_base), |
1372 | &ioc->ioc_hpa->io_pdir_base); | 1369 | &ioc->ioc_regs->io_pdir_base); |
1373 | 1370 | ||
1374 | /* | 1371 | /* |
1375 | ** Go to "Virtual Mode" | 1372 | ** Go to "Virtual Mode" |
1376 | */ | 1373 | */ |
1377 | WRITE_U32(IOA_NORMAL_MODE, &ioc->ioc_hpa->io_control); | 1374 | WRITE_U32(IOA_NORMAL_MODE, &ioc->ioc_regs->io_control); |
1378 | 1375 | ||
1379 | /* | 1376 | /* |
1380 | ** Initialize all I/O TLB entries to 0 (Valid bit off). | 1377 | ** Initialize all I/O TLB entries to 0 (Valid bit off). |
1381 | */ | 1378 | */ |
1382 | WRITE_U32(0, &ioc->ioc_hpa->io_tlb_entry_m); | 1379 | WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_m); |
1383 | WRITE_U32(0, &ioc->ioc_hpa->io_tlb_entry_l); | 1380 | WRITE_U32(0, &ioc->ioc_regs->io_tlb_entry_l); |
1384 | 1381 | ||
1385 | for(i = 1 << CCIO_CHAINID_SHIFT; i ; i--) { | 1382 | for(i = 1 << CCIO_CHAINID_SHIFT; i ; i--) { |
1386 | WRITE_U32((CMD_TLB_DIRECT_WRITE | (i << ioc->chainid_shift)), | 1383 | WRITE_U32((CMD_TLB_DIRECT_WRITE | (i << ioc->chainid_shift)), |
1387 | &ioc->ioc_hpa->io_command); | 1384 | &ioc->ioc_regs->io_command); |
1388 | } | 1385 | } |
1389 | } | 1386 | } |
1390 | 1387 | ||
1391 | static void | 1388 | static void |
1392 | ccio_init_resource(struct resource *res, char *name, unsigned long ioaddr) | 1389 | ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr) |
1393 | { | 1390 | { |
1394 | int result; | 1391 | int result; |
1395 | 1392 | ||
1396 | res->parent = NULL; | 1393 | res->parent = NULL; |
1397 | res->flags = IORESOURCE_MEM; | 1394 | res->flags = IORESOURCE_MEM; |
1398 | res->start = (unsigned long)(signed) __raw_readl(ioaddr) << 16; | 1395 | /* |
1399 | res->end = (unsigned long)(signed) (__raw_readl(ioaddr + 4) << 16) - 1; | 1396 | * bracing ((signed) ...) are required for 64bit kernel because |
1397 | * we only want to sign extend the lower 16 bits of the register. | ||
1398 | * The upper 16-bits of range registers are hardcoded to 0xffff. | ||
1399 | */ | ||
1400 | res->start = (unsigned long)((signed) READ_U32(ioaddr) << 16); | ||
1401 | res->end = (unsigned long)((signed) (READ_U32(ioaddr + 4) << 16) - 1); | ||
1400 | res->name = name; | 1402 | res->name = name; |
1403 | /* | ||
1404 | * Check if this MMIO range is disable | ||
1405 | */ | ||
1401 | if (res->end + 1 == res->start) | 1406 | if (res->end + 1 == res->start) |
1402 | return; | 1407 | return; |
1403 | result = request_resource(&iomem_resource, res); | 1408 | |
1409 | /* On some platforms (e.g. K-Class), we have already registered | ||
1410 | * resources for devices reported by firmware. Some are children | ||
1411 | * of ccio. | ||
1412 | * "insert" ccio ranges in the mmio hierarchy (/proc/iomem). | ||
1413 | */ | ||
1414 | result = insert_resource(&iomem_resource, res); | ||
1404 | if (result < 0) { | 1415 | if (result < 0) { |
1405 | printk(KERN_ERR "%s: failed to claim CCIO bus address space (%08lx,%08lx)\n", | 1416 | printk(KERN_ERR "%s() failed to claim CCIO bus address space (%08lx,%08lx)\n", |
1406 | __FILE__, res->start, res->end); | 1417 | __FUNCTION__, res->start, res->end); |
1407 | } | 1418 | } |
1408 | } | 1419 | } |
1409 | 1420 | ||
@@ -1414,9 +1425,8 @@ static void __init ccio_init_resources(struct ioc *ioc) | |||
1414 | 1425 | ||
1415 | sprintf(name, "GSC Bus [%d/]", ioc->hw_path); | 1426 | sprintf(name, "GSC Bus [%d/]", ioc->hw_path); |
1416 | 1427 | ||
1417 | ccio_init_resource(res, name, (unsigned long)&ioc->ioc_hpa->io_io_low); | 1428 | ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low); |
1418 | ccio_init_resource(res + 1, name, | 1429 | ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv); |
1419 | (unsigned long)&ioc->ioc_hpa->io_io_low_hv); | ||
1420 | } | 1430 | } |
1421 | 1431 | ||
1422 | static int new_ioc_area(struct resource *res, unsigned long size, | 1432 | static int new_ioc_area(struct resource *res, unsigned long size, |
@@ -1427,7 +1437,12 @@ static int new_ioc_area(struct resource *res, unsigned long size, | |||
1427 | 1437 | ||
1428 | res->start = (max - size + 1) &~ (align - 1); | 1438 | res->start = (max - size + 1) &~ (align - 1); |
1429 | res->end = res->start + size; | 1439 | res->end = res->start + size; |
1430 | if (!request_resource(&iomem_resource, res)) | 1440 | |
1441 | /* We might be trying to expand the MMIO range to include | ||
1442 | * a child device that has already registered it's MMIO space. | ||
1443 | * Use "insert" instead of request_resource(). | ||
1444 | */ | ||
1445 | if (!insert_resource(&iomem_resource, res)) | ||
1431 | return 0; | 1446 | return 0; |
1432 | 1447 | ||
1433 | return new_ioc_area(res, size, min, max - size, align); | 1448 | return new_ioc_area(res, size, min, max - size, align); |
@@ -1486,15 +1501,15 @@ int ccio_allocate_resource(const struct parisc_device *dev, | |||
1486 | 1501 | ||
1487 | if (!expand_ioc_area(parent, size, min, max, align)) { | 1502 | if (!expand_ioc_area(parent, size, min, max, align)) { |
1488 | __raw_writel(((parent->start)>>16) | 0xffff0000, | 1503 | __raw_writel(((parent->start)>>16) | 0xffff0000, |
1489 | (unsigned long)&(ioc->ioc_hpa->io_io_low)); | 1504 | &ioc->ioc_regs->io_io_low); |
1490 | __raw_writel(((parent->end)>>16) | 0xffff0000, | 1505 | __raw_writel(((parent->end)>>16) | 0xffff0000, |
1491 | (unsigned long)&(ioc->ioc_hpa->io_io_high)); | 1506 | &ioc->ioc_regs->io_io_high); |
1492 | } else if (!expand_ioc_area(parent + 1, size, min, max, align)) { | 1507 | } else if (!expand_ioc_area(parent + 1, size, min, max, align)) { |
1493 | parent++; | 1508 | parent++; |
1494 | __raw_writel(((parent->start)>>16) | 0xffff0000, | 1509 | __raw_writel(((parent->start)>>16) | 0xffff0000, |
1495 | (unsigned long)&(ioc->ioc_hpa->io_io_low_hv)); | 1510 | &ioc->ioc_regs->io_io_low_hv); |
1496 | __raw_writel(((parent->end)>>16) | 0xffff0000, | 1511 | __raw_writel(((parent->end)>>16) | 0xffff0000, |
1497 | (unsigned long)&(ioc->ioc_hpa->io_io_high_hv)); | 1512 | &ioc->ioc_regs->io_io_high_hv); |
1498 | } else { | 1513 | } else { |
1499 | return -EBUSY; | 1514 | return -EBUSY; |
1500 | } | 1515 | } |
@@ -1521,7 +1536,12 @@ int ccio_request_resource(const struct parisc_device *dev, | |||
1521 | return -EBUSY; | 1536 | return -EBUSY; |
1522 | } | 1537 | } |
1523 | 1538 | ||
1524 | return request_resource(parent, res); | 1539 | /* "transparent" bus bridges need to register MMIO resources |
1540 | * firmware assigned them. e.g. children of hppb.c (e.g. K-class) | ||
1541 | * registered their resources in the PDC "bus walk" (See | ||
1542 | * arch/parisc/kernel/inventory.c). | ||
1543 | */ | ||
1544 | return insert_resource(parent, res); | ||
1525 | } | 1545 | } |
1526 | 1546 | ||
1527 | /** | 1547 | /** |