diff options
author | David S. Miller <davem@davemloft.net> | 2008-08-27 03:24:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-08-29 05:14:46 -0400 |
commit | 5dc2536bb8d8adb5fdfbe76cd6fdcdf9de3f40f8 (patch) | |
tree | 6b6c77764cd486adc7ec072f4712d35361e83b1e | |
parent | 05bb5e93f2ef3f14e0c5a7e9281d07e7a7e4233d (diff) |
qlogicpti: Convert to pure OF driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/scsi/qlogicpti.c | 108 | ||||
-rw-r--r-- | drivers/scsi/qlogicpti.h | 2 |
2 files changed, 56 insertions, 54 deletions
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index e16c56c515f1..b6ce82d3de3d 100644 --- a/drivers/scsi/qlogicpti.c +++ b/drivers/scsi/qlogicpti.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver. | 1 | /* qlogicpti.c: Performance Technologies QlogicISP sbus card driver. |
2 | * | 2 | * |
3 | * Copyright (C) 1996, 2006 David S. Miller (davem@davemloft.net) | 3 | * Copyright (C) 1996, 2006, 2008 David S. Miller (davem@davemloft.net) |
4 | * | 4 | * |
5 | * A lot of this driver was directly stolen from Erik H. Moe's PCI | 5 | * A lot of this driver was directly stolen from Erik H. Moe's PCI |
6 | * Qlogic ISP driver. Mucho kudos to him for this code. | 6 | * Qlogic ISP driver. Mucho kudos to him for this code. |
@@ -26,12 +26,13 @@ | |||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/jiffies.h> | 27 | #include <linux/jiffies.h> |
28 | #include <linux/dma-mapping.h> | 28 | #include <linux/dma-mapping.h> |
29 | #include <linux/of.h> | ||
30 | #include <linux/of_device.h> | ||
29 | 31 | ||
30 | #include <asm/byteorder.h> | 32 | #include <asm/byteorder.h> |
31 | 33 | ||
32 | #include "qlogicpti.h" | 34 | #include "qlogicpti.h" |
33 | 35 | ||
34 | #include <asm/sbus.h> | ||
35 | #include <asm/dma.h> | 36 | #include <asm/dma.h> |
36 | #include <asm/system.h> | 37 | #include <asm/system.h> |
37 | #include <asm/ptrace.h> | 38 | #include <asm/ptrace.h> |
@@ -685,19 +686,19 @@ static void __devexit qpti_chain_del(struct qlogicpti *qpti) | |||
685 | 686 | ||
686 | static int __devinit qpti_map_regs(struct qlogicpti *qpti) | 687 | static int __devinit qpti_map_regs(struct qlogicpti *qpti) |
687 | { | 688 | { |
688 | struct sbus_dev *sdev = qpti->sdev; | 689 | struct of_device *op = qpti->op; |
689 | 690 | ||
690 | qpti->qregs = sbus_ioremap(&sdev->resource[0], 0, | 691 | qpti->qregs = of_ioremap(&op->resource[0], 0, |
691 | sdev->reg_addrs[0].reg_size, | 692 | resource_size(&op->resource[0]), |
692 | "PTI Qlogic/ISP"); | 693 | "PTI Qlogic/ISP"); |
693 | if (!qpti->qregs) { | 694 | if (!qpti->qregs) { |
694 | printk("PTI: Qlogic/ISP registers are unmappable\n"); | 695 | printk("PTI: Qlogic/ISP registers are unmappable\n"); |
695 | return -1; | 696 | return -1; |
696 | } | 697 | } |
697 | if (qpti->is_pti) { | 698 | if (qpti->is_pti) { |
698 | qpti->sreg = sbus_ioremap(&sdev->resource[0], (16 * 4096), | 699 | qpti->sreg = of_ioremap(&op->resource[0], (16 * 4096), |
699 | sizeof(unsigned char), | 700 | sizeof(unsigned char), |
700 | "PTI Qlogic/ISP statreg"); | 701 | "PTI Qlogic/ISP statreg"); |
701 | if (!qpti->sreg) { | 702 | if (!qpti->sreg) { |
702 | printk("PTI: Qlogic/ISP status register is unmappable\n"); | 703 | printk("PTI: Qlogic/ISP status register is unmappable\n"); |
703 | return -1; | 704 | return -1; |
@@ -708,9 +709,9 @@ static int __devinit qpti_map_regs(struct qlogicpti *qpti) | |||
708 | 709 | ||
709 | static int __devinit qpti_register_irq(struct qlogicpti *qpti) | 710 | static int __devinit qpti_register_irq(struct qlogicpti *qpti) |
710 | { | 711 | { |
711 | struct sbus_dev *sdev = qpti->sdev; | 712 | struct of_device *op = qpti->op; |
712 | 713 | ||
713 | qpti->qhost->irq = qpti->irq = sdev->irqs[0]; | 714 | qpti->qhost->irq = qpti->irq = op->irqs[0]; |
714 | 715 | ||
715 | /* We used to try various overly-clever things to | 716 | /* We used to try various overly-clever things to |
716 | * reduce the interrupt processing overhead on | 717 | * reduce the interrupt processing overhead on |
@@ -733,17 +734,19 @@ fail: | |||
733 | 734 | ||
734 | static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) | 735 | static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) |
735 | { | 736 | { |
736 | qpti->scsi_id = prom_getintdefault(qpti->prom_node, | 737 | struct of_device *op = qpti->op; |
737 | "initiator-id", | 738 | struct device_node *dp; |
738 | -1); | 739 | |
740 | dp = op->node; | ||
741 | |||
742 | qpti->scsi_id = of_getintprop_default(dp, "initiator-id", -1); | ||
739 | if (qpti->scsi_id == -1) | 743 | if (qpti->scsi_id == -1) |
740 | qpti->scsi_id = prom_getintdefault(qpti->prom_node, | 744 | qpti->scsi_id = of_getintprop_default(dp, "scsi-initiator-id", |
741 | "scsi-initiator-id", | 745 | -1); |
742 | -1); | ||
743 | if (qpti->scsi_id == -1) | 746 | if (qpti->scsi_id == -1) |
744 | qpti->scsi_id = | 747 | qpti->scsi_id = |
745 | prom_getintdefault(qpti->sdev->bus->prom_node, | 748 | of_getintprop_default(dp->parent, |
746 | "scsi-initiator-id", 7); | 749 | "scsi-initiator-id", 7); |
747 | qpti->qhost->this_id = qpti->scsi_id; | 750 | qpti->qhost->this_id = qpti->scsi_id; |
748 | qpti->qhost->max_sectors = 64; | 751 | qpti->qhost->max_sectors = 64; |
749 | 752 | ||
@@ -752,12 +755,11 @@ static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) | |||
752 | 755 | ||
753 | static void qpti_get_bursts(struct qlogicpti *qpti) | 756 | static void qpti_get_bursts(struct qlogicpti *qpti) |
754 | { | 757 | { |
755 | struct sbus_dev *sdev = qpti->sdev; | 758 | struct of_device *op = qpti->op; |
756 | u8 bursts, bmask; | 759 | u8 bursts, bmask; |
757 | 760 | ||
758 | bursts = prom_getintdefault(qpti->prom_node, "burst-sizes", 0xff); | 761 | bursts = of_getintprop_default(op->node, "burst-sizes", 0xff); |
759 | bmask = prom_getintdefault(sdev->bus->prom_node, | 762 | bmask = of_getintprop_default(op->node->parent, "burst-sizes", 0xff); |
760 | "burst-sizes", 0xff); | ||
761 | if (bmask != 0xff) | 763 | if (bmask != 0xff) |
762 | bursts &= bmask; | 764 | bursts &= bmask; |
763 | if (bursts == 0xff || | 765 | if (bursts == 0xff || |
@@ -786,10 +788,10 @@ static void qpti_get_clock(struct qlogicpti *qpti) | |||
786 | */ | 788 | */ |
787 | static int __devinit qpti_map_queues(struct qlogicpti *qpti) | 789 | static int __devinit qpti_map_queues(struct qlogicpti *qpti) |
788 | { | 790 | { |
789 | struct sbus_dev *sdev = qpti->sdev; | 791 | struct of_device *op = qpti->op; |
790 | 792 | ||
791 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | 793 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
792 | qpti->res_cpu = dma_alloc_coherent(&sdev->ofdev.dev, | 794 | qpti->res_cpu = dma_alloc_coherent(&op->dev, |
793 | QSIZE(RES_QUEUE_LEN), | 795 | QSIZE(RES_QUEUE_LEN), |
794 | &qpti->res_dvma, GFP_ATOMIC); | 796 | &qpti->res_dvma, GFP_ATOMIC); |
795 | if (qpti->res_cpu == NULL || | 797 | if (qpti->res_cpu == NULL || |
@@ -798,12 +800,12 @@ static int __devinit qpti_map_queues(struct qlogicpti *qpti) | |||
798 | return -1; | 800 | return -1; |
799 | } | 801 | } |
800 | 802 | ||
801 | qpti->req_cpu = dma_alloc_coherent(&sdev->ofdev.dev, | 803 | qpti->req_cpu = dma_alloc_coherent(&op->dev, |
802 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | 804 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
803 | &qpti->req_dvma, GFP_ATOMIC); | 805 | &qpti->req_dvma, GFP_ATOMIC); |
804 | if (qpti->req_cpu == NULL || | 806 | if (qpti->req_cpu == NULL || |
805 | qpti->req_dvma == 0) { | 807 | qpti->req_dvma == 0) { |
806 | dma_free_coherent(&sdev->ofdev.dev, QSIZE(RES_QUEUE_LEN), | 808 | dma_free_coherent(&op->dev, QSIZE(RES_QUEUE_LEN), |
807 | qpti->res_cpu, qpti->res_dvma); | 809 | qpti->res_cpu, qpti->res_dvma); |
808 | printk("QPTI: Cannot map request queue.\n"); | 810 | printk("QPTI: Cannot map request queue.\n"); |
809 | return -1; | 811 | return -1; |
@@ -876,7 +878,7 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct Command_Entry *cmd, | |||
876 | int sg_count; | 878 | int sg_count; |
877 | 879 | ||
878 | sg = scsi_sglist(Cmnd); | 880 | sg = scsi_sglist(Cmnd); |
879 | sg_count = dma_map_sg(&qpti->sdev->ofdev.dev, sg, | 881 | sg_count = dma_map_sg(&qpti->op->dev, sg, |
880 | scsi_sg_count(Cmnd), | 882 | scsi_sg_count(Cmnd), |
881 | Cmnd->sc_data_direction); | 883 | Cmnd->sc_data_direction); |
882 | 884 | ||
@@ -1153,7 +1155,7 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct qlogicpti *qpti) | |||
1153 | Cmnd->result = DID_ERROR << 16; | 1155 | Cmnd->result = DID_ERROR << 16; |
1154 | 1156 | ||
1155 | if (scsi_bufflen(Cmnd)) | 1157 | if (scsi_bufflen(Cmnd)) |
1156 | dma_unmap_sg(&qpti->sdev->ofdev.dev, | 1158 | dma_unmap_sg(&qpti->op->dev, |
1157 | scsi_sglist(Cmnd), scsi_sg_count(Cmnd), | 1159 | scsi_sglist(Cmnd), scsi_sg_count(Cmnd), |
1158 | Cmnd->sc_data_direction); | 1160 | Cmnd->sc_data_direction); |
1159 | 1161 | ||
@@ -1269,34 +1271,32 @@ static struct scsi_host_template qpti_template = { | |||
1269 | .use_clustering = ENABLE_CLUSTERING, | 1271 | .use_clustering = ENABLE_CLUSTERING, |
1270 | }; | 1272 | }; |
1271 | 1273 | ||
1272 | static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_device_id *match) | 1274 | static int __devinit qpti_sbus_probe(struct of_device *op, const struct of_device_id *match) |
1273 | { | 1275 | { |
1274 | static int nqptis; | ||
1275 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | ||
1276 | struct device_node *dp = dev->node; | ||
1277 | struct scsi_host_template *tpnt = match->data; | 1276 | struct scsi_host_template *tpnt = match->data; |
1277 | struct device_node *dp = op->node; | ||
1278 | struct Scsi_Host *host; | 1278 | struct Scsi_Host *host; |
1279 | struct qlogicpti *qpti; | 1279 | struct qlogicpti *qpti; |
1280 | static int nqptis; | ||
1280 | const char *fcode; | 1281 | const char *fcode; |
1281 | 1282 | ||
1282 | /* Sometimes Antares cards come up not completely | 1283 | /* Sometimes Antares cards come up not completely |
1283 | * setup, and we get a report of a zero IRQ. | 1284 | * setup, and we get a report of a zero IRQ. |
1284 | */ | 1285 | */ |
1285 | if (sdev->irqs[0] == 0) | 1286 | if (op->irqs[0] == 0) |
1286 | return -ENODEV; | 1287 | return -ENODEV; |
1287 | 1288 | ||
1288 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); | 1289 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); |
1289 | if (!host) | 1290 | if (!host) |
1290 | return -ENOMEM; | 1291 | return -ENOMEM; |
1291 | 1292 | ||
1292 | qpti = (struct qlogicpti *) host->hostdata; | 1293 | qpti = shost_priv(host); |
1293 | 1294 | ||
1294 | host->max_id = MAX_TARGETS; | 1295 | host->max_id = MAX_TARGETS; |
1295 | qpti->qhost = host; | 1296 | qpti->qhost = host; |
1296 | qpti->sdev = sdev; | 1297 | qpti->op = op; |
1297 | qpti->qpti_id = nqptis; | 1298 | qpti->qpti_id = nqptis; |
1298 | qpti->prom_node = sdev->prom_node; | 1299 | strcpy(qpti->prom_name, op->node->name); |
1299 | strcpy(qpti->prom_name, sdev->ofdev.node->name); | ||
1300 | qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp"); | 1300 | qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp"); |
1301 | 1301 | ||
1302 | if (qpti_map_regs(qpti) < 0) | 1302 | if (qpti_map_regs(qpti) < 0) |
@@ -1342,12 +1342,12 @@ static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_devi | |||
1342 | (qpti->ultra ? "Ultra" : "Fast"), | 1342 | (qpti->ultra ? "Ultra" : "Fast"), |
1343 | (qpti->differential ? "differential" : "single ended")); | 1343 | (qpti->differential ? "differential" : "single ended")); |
1344 | 1344 | ||
1345 | if (scsi_add_host(host, &dev->dev)) { | 1345 | if (scsi_add_host(host, &op->dev)) { |
1346 | printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id); | 1346 | printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id); |
1347 | goto fail_unmap_queues; | 1347 | goto fail_unmap_queues; |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | dev_set_drvdata(&sdev->ofdev.dev, qpti); | 1350 | dev_set_drvdata(&op->dev, qpti); |
1351 | 1351 | ||
1352 | qpti_chain_add(qpti); | 1352 | qpti_chain_add(qpti); |
1353 | 1353 | ||
@@ -1358,19 +1358,20 @@ static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_devi | |||
1358 | 1358 | ||
1359 | fail_unmap_queues: | 1359 | fail_unmap_queues: |
1360 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | 1360 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
1361 | dma_free_coherent(&qpti->sdev->ofdev.dev, | 1361 | dma_free_coherent(&op->dev, |
1362 | QSIZE(RES_QUEUE_LEN), | 1362 | QSIZE(RES_QUEUE_LEN), |
1363 | qpti->res_cpu, qpti->res_dvma); | 1363 | qpti->res_cpu, qpti->res_dvma); |
1364 | dma_free_coherent(&qpti->sdev->ofdev.dev, | 1364 | dma_free_coherent(&op->dev, |
1365 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | 1365 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
1366 | qpti->req_cpu, qpti->req_dvma); | 1366 | qpti->req_cpu, qpti->req_dvma); |
1367 | #undef QSIZE | 1367 | #undef QSIZE |
1368 | 1368 | ||
1369 | fail_unmap_regs: | 1369 | fail_unmap_regs: |
1370 | sbus_iounmap(qpti->qregs, | 1370 | of_iounmap(&op->resource[0], qpti->qregs, |
1371 | qpti->sdev->reg_addrs[0].reg_size); | 1371 | resource_size(&op->resource[0])); |
1372 | if (qpti->is_pti) | 1372 | if (qpti->is_pti) |
1373 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | 1373 | of_iounmap(&op->resource[0], qpti->sreg, |
1374 | sizeof(unsigned char)); | ||
1374 | 1375 | ||
1375 | fail_free_irq: | 1376 | fail_free_irq: |
1376 | free_irq(qpti->irq, qpti); | 1377 | free_irq(qpti->irq, qpti); |
@@ -1381,9 +1382,9 @@ fail_unlink: | |||
1381 | return -ENODEV; | 1382 | return -ENODEV; |
1382 | } | 1383 | } |
1383 | 1384 | ||
1384 | static int __devexit qpti_sbus_remove(struct of_device *dev) | 1385 | static int __devexit qpti_sbus_remove(struct of_device *op) |
1385 | { | 1386 | { |
1386 | struct qlogicpti *qpti = dev_get_drvdata(&dev->dev); | 1387 | struct qlogicpti *qpti = dev_get_drvdata(&op->dev); |
1387 | 1388 | ||
1388 | qpti_chain_del(qpti); | 1389 | qpti_chain_del(qpti); |
1389 | 1390 | ||
@@ -1396,17 +1397,18 @@ static int __devexit qpti_sbus_remove(struct of_device *dev) | |||
1396 | free_irq(qpti->irq, qpti); | 1397 | free_irq(qpti->irq, qpti); |
1397 | 1398 | ||
1398 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | 1399 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
1399 | dma_free_coherent(&qpti->sdev->ofdev.dev, | 1400 | dma_free_coherent(&op->dev, |
1400 | QSIZE(RES_QUEUE_LEN), | 1401 | QSIZE(RES_QUEUE_LEN), |
1401 | qpti->res_cpu, qpti->res_dvma); | 1402 | qpti->res_cpu, qpti->res_dvma); |
1402 | dma_free_coherent(&qpti->sdev->ofdev.dev, | 1403 | dma_free_coherent(&op->dev, |
1403 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | 1404 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
1404 | qpti->req_cpu, qpti->req_dvma); | 1405 | qpti->req_cpu, qpti->req_dvma); |
1405 | #undef QSIZE | 1406 | #undef QSIZE |
1406 | 1407 | ||
1407 | sbus_iounmap(qpti->qregs, qpti->sdev->reg_addrs[0].reg_size); | 1408 | of_iounmap(&op->resource[0], qpti->qregs, |
1409 | resource_size(&op->resource[0])); | ||
1408 | if (qpti->is_pti) | 1410 | if (qpti->is_pti) |
1409 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | 1411 | of_iounmap(&op->resource[0], qpti->sreg, sizeof(unsigned char)); |
1410 | 1412 | ||
1411 | scsi_host_put(qpti->qhost); | 1413 | scsi_host_put(qpti->qhost); |
1412 | 1414 | ||
@@ -1443,7 +1445,7 @@ static struct of_platform_driver qpti_sbus_driver = { | |||
1443 | 1445 | ||
1444 | static int __init qpti_init(void) | 1446 | static int __init qpti_init(void) |
1445 | { | 1447 | { |
1446 | return of_register_driver(&qpti_sbus_driver, &sbus_bus_type); | 1448 | return of_register_driver(&qpti_sbus_driver, &of_bus_type); |
1447 | } | 1449 | } |
1448 | 1450 | ||
1449 | static void __exit qpti_exit(void) | 1451 | static void __exit qpti_exit(void) |
@@ -1454,7 +1456,7 @@ static void __exit qpti_exit(void) | |||
1454 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); | 1456 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); |
1455 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); | 1457 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); |
1456 | MODULE_LICENSE("GPL"); | 1458 | MODULE_LICENSE("GPL"); |
1457 | MODULE_VERSION("2.0"); | 1459 | MODULE_VERSION("2.1"); |
1458 | 1460 | ||
1459 | module_init(qpti_init); | 1461 | module_init(qpti_init); |
1460 | module_exit(qpti_exit); | 1462 | module_exit(qpti_exit); |
diff --git a/drivers/scsi/qlogicpti.h b/drivers/scsi/qlogicpti.h index ef6da2df584b..9c053bbaa877 100644 --- a/drivers/scsi/qlogicpti.h +++ b/drivers/scsi/qlogicpti.h | |||
@@ -342,7 +342,7 @@ struct qlogicpti { | |||
342 | u_int req_in_ptr; /* index of next request slot */ | 342 | u_int req_in_ptr; /* index of next request slot */ |
343 | u_int res_out_ptr; /* index of next result slot */ | 343 | u_int res_out_ptr; /* index of next result slot */ |
344 | long send_marker; /* must we send a marker? */ | 344 | long send_marker; /* must we send a marker? */ |
345 | struct sbus_dev *sdev; | 345 | struct of_device *op; |
346 | unsigned long __pad; | 346 | unsigned long __pad; |
347 | 347 | ||
348 | int cmd_count[MAX_TARGETS]; | 348 | int cmd_count[MAX_TARGETS]; |