diff options
Diffstat (limited to 'drivers/scsi/qlogicpti.c')
-rw-r--r-- | drivers/scsi/qlogicpti.c | 146 |
1 files changed, 75 insertions, 71 deletions
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c index 905350896725..69d6ad862b60 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. |
@@ -25,12 +25,14 @@ | |||
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
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> | ||
29 | #include <linux/of.h> | ||
30 | #include <linux/of_device.h> | ||
28 | 31 | ||
29 | #include <asm/byteorder.h> | 32 | #include <asm/byteorder.h> |
30 | 33 | ||
31 | #include "qlogicpti.h" | 34 | #include "qlogicpti.h" |
32 | 35 | ||
33 | #include <asm/sbus.h> | ||
34 | #include <asm/dma.h> | 36 | #include <asm/dma.h> |
35 | #include <asm/system.h> | 37 | #include <asm/system.h> |
36 | #include <asm/ptrace.h> | 38 | #include <asm/ptrace.h> |
@@ -157,7 +159,7 @@ static inline void set_sbus_cfg1(struct qlogicpti *qpti) | |||
157 | * is a nop and the chip ends up using the smallest burst | 159 | * is a nop and the chip ends up using the smallest burst |
158 | * size. -DaveM | 160 | * size. -DaveM |
159 | */ | 161 | */ |
160 | if (sbus_can_burst64(qpti->sdev) && (bursts & DMA_BURST64)) { | 162 | if (sbus_can_burst64() && (bursts & DMA_BURST64)) { |
161 | val = (SBUS_CFG1_BENAB | SBUS_CFG1_B64); | 163 | val = (SBUS_CFG1_BENAB | SBUS_CFG1_B64); |
162 | } else | 164 | } else |
163 | #endif | 165 | #endif |
@@ -684,19 +686,19 @@ static void __devexit qpti_chain_del(struct qlogicpti *qpti) | |||
684 | 686 | ||
685 | static int __devinit qpti_map_regs(struct qlogicpti *qpti) | 687 | static int __devinit qpti_map_regs(struct qlogicpti *qpti) |
686 | { | 688 | { |
687 | struct sbus_dev *sdev = qpti->sdev; | 689 | struct of_device *op = qpti->op; |
688 | 690 | ||
689 | qpti->qregs = sbus_ioremap(&sdev->resource[0], 0, | 691 | qpti->qregs = of_ioremap(&op->resource[0], 0, |
690 | sdev->reg_addrs[0].reg_size, | 692 | resource_size(&op->resource[0]), |
691 | "PTI Qlogic/ISP"); | 693 | "PTI Qlogic/ISP"); |
692 | if (!qpti->qregs) { | 694 | if (!qpti->qregs) { |
693 | printk("PTI: Qlogic/ISP registers are unmappable\n"); | 695 | printk("PTI: Qlogic/ISP registers are unmappable\n"); |
694 | return -1; | 696 | return -1; |
695 | } | 697 | } |
696 | if (qpti->is_pti) { | 698 | if (qpti->is_pti) { |
697 | qpti->sreg = sbus_ioremap(&sdev->resource[0], (16 * 4096), | 699 | qpti->sreg = of_ioremap(&op->resource[0], (16 * 4096), |
698 | sizeof(unsigned char), | 700 | sizeof(unsigned char), |
699 | "PTI Qlogic/ISP statreg"); | 701 | "PTI Qlogic/ISP statreg"); |
700 | if (!qpti->sreg) { | 702 | if (!qpti->sreg) { |
701 | printk("PTI: Qlogic/ISP status register is unmappable\n"); | 703 | printk("PTI: Qlogic/ISP status register is unmappable\n"); |
702 | return -1; | 704 | return -1; |
@@ -707,9 +709,9 @@ static int __devinit qpti_map_regs(struct qlogicpti *qpti) | |||
707 | 709 | ||
708 | static int __devinit qpti_register_irq(struct qlogicpti *qpti) | 710 | static int __devinit qpti_register_irq(struct qlogicpti *qpti) |
709 | { | 711 | { |
710 | struct sbus_dev *sdev = qpti->sdev; | 712 | struct of_device *op = qpti->op; |
711 | 713 | ||
712 | qpti->qhost->irq = qpti->irq = sdev->irqs[0]; | 714 | qpti->qhost->irq = qpti->irq = op->irqs[0]; |
713 | 715 | ||
714 | /* We used to try various overly-clever things to | 716 | /* We used to try various overly-clever things to |
715 | * reduce the interrupt processing overhead on | 717 | * reduce the interrupt processing overhead on |
@@ -732,17 +734,19 @@ fail: | |||
732 | 734 | ||
733 | static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) | 735 | static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) |
734 | { | 736 | { |
735 | qpti->scsi_id = prom_getintdefault(qpti->prom_node, | 737 | struct of_device *op = qpti->op; |
736 | "initiator-id", | 738 | struct device_node *dp; |
737 | -1); | 739 | |
740 | dp = op->node; | ||
741 | |||
742 | qpti->scsi_id = of_getintprop_default(dp, "initiator-id", -1); | ||
738 | if (qpti->scsi_id == -1) | 743 | if (qpti->scsi_id == -1) |
739 | qpti->scsi_id = prom_getintdefault(qpti->prom_node, | 744 | qpti->scsi_id = of_getintprop_default(dp, "scsi-initiator-id", |
740 | "scsi-initiator-id", | 745 | -1); |
741 | -1); | ||
742 | if (qpti->scsi_id == -1) | 746 | if (qpti->scsi_id == -1) |
743 | qpti->scsi_id = | 747 | qpti->scsi_id = |
744 | prom_getintdefault(qpti->sdev->bus->prom_node, | 748 | of_getintprop_default(dp->parent, |
745 | "scsi-initiator-id", 7); | 749 | "scsi-initiator-id", 7); |
746 | qpti->qhost->this_id = qpti->scsi_id; | 750 | qpti->qhost->this_id = qpti->scsi_id; |
747 | qpti->qhost->max_sectors = 64; | 751 | qpti->qhost->max_sectors = 64; |
748 | 752 | ||
@@ -751,12 +755,11 @@ static void __devinit qpti_get_scsi_id(struct qlogicpti *qpti) | |||
751 | 755 | ||
752 | static void qpti_get_bursts(struct qlogicpti *qpti) | 756 | static void qpti_get_bursts(struct qlogicpti *qpti) |
753 | { | 757 | { |
754 | struct sbus_dev *sdev = qpti->sdev; | 758 | struct of_device *op = qpti->op; |
755 | u8 bursts, bmask; | 759 | u8 bursts, bmask; |
756 | 760 | ||
757 | bursts = prom_getintdefault(qpti->prom_node, "burst-sizes", 0xff); | 761 | bursts = of_getintprop_default(op->node, "burst-sizes", 0xff); |
758 | bmask = prom_getintdefault(sdev->bus->prom_node, | 762 | bmask = of_getintprop_default(op->node->parent, "burst-sizes", 0xff); |
759 | "burst-sizes", 0xff); | ||
760 | if (bmask != 0xff) | 763 | if (bmask != 0xff) |
761 | bursts &= bmask; | 764 | bursts &= bmask; |
762 | if (bursts == 0xff || | 765 | if (bursts == 0xff || |
@@ -785,25 +788,25 @@ static void qpti_get_clock(struct qlogicpti *qpti) | |||
785 | */ | 788 | */ |
786 | static int __devinit qpti_map_queues(struct qlogicpti *qpti) | 789 | static int __devinit qpti_map_queues(struct qlogicpti *qpti) |
787 | { | 790 | { |
788 | struct sbus_dev *sdev = qpti->sdev; | 791 | struct of_device *op = qpti->op; |
789 | 792 | ||
790 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | 793 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
791 | qpti->res_cpu = sbus_alloc_consistent(sdev, | 794 | qpti->res_cpu = dma_alloc_coherent(&op->dev, |
792 | QSIZE(RES_QUEUE_LEN), | 795 | QSIZE(RES_QUEUE_LEN), |
793 | &qpti->res_dvma); | 796 | &qpti->res_dvma, GFP_ATOMIC); |
794 | if (qpti->res_cpu == NULL || | 797 | if (qpti->res_cpu == NULL || |
795 | qpti->res_dvma == 0) { | 798 | qpti->res_dvma == 0) { |
796 | printk("QPTI: Cannot map response queue.\n"); | 799 | printk("QPTI: Cannot map response queue.\n"); |
797 | return -1; | 800 | return -1; |
798 | } | 801 | } |
799 | 802 | ||
800 | qpti->req_cpu = sbus_alloc_consistent(sdev, | 803 | qpti->req_cpu = dma_alloc_coherent(&op->dev, |
801 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | 804 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
802 | &qpti->req_dvma); | 805 | &qpti->req_dvma, GFP_ATOMIC); |
803 | if (qpti->req_cpu == NULL || | 806 | if (qpti->req_cpu == NULL || |
804 | qpti->req_dvma == 0) { | 807 | qpti->req_dvma == 0) { |
805 | sbus_free_consistent(sdev, QSIZE(RES_QUEUE_LEN), | 808 | dma_free_coherent(&op->dev, QSIZE(RES_QUEUE_LEN), |
806 | qpti->res_cpu, qpti->res_dvma); | 809 | qpti->res_cpu, qpti->res_dvma); |
807 | printk("QPTI: Cannot map request queue.\n"); | 810 | printk("QPTI: Cannot map request queue.\n"); |
808 | return -1; | 811 | return -1; |
809 | } | 812 | } |
@@ -875,8 +878,9 @@ static inline int load_cmd(struct scsi_cmnd *Cmnd, struct Command_Entry *cmd, | |||
875 | int sg_count; | 878 | int sg_count; |
876 | 879 | ||
877 | sg = scsi_sglist(Cmnd); | 880 | sg = scsi_sglist(Cmnd); |
878 | sg_count = sbus_map_sg(qpti->sdev, sg, scsi_sg_count(Cmnd), | 881 | sg_count = dma_map_sg(&qpti->op->dev, sg, |
879 | Cmnd->sc_data_direction); | 882 | scsi_sg_count(Cmnd), |
883 | Cmnd->sc_data_direction); | ||
880 | 884 | ||
881 | ds = cmd->dataseg; | 885 | ds = cmd->dataseg; |
882 | cmd->segment_cnt = sg_count; | 886 | cmd->segment_cnt = sg_count; |
@@ -1152,9 +1156,9 @@ static struct scsi_cmnd *qlogicpti_intr_handler(struct qlogicpti *qpti) | |||
1152 | Cmnd->result = DID_ERROR << 16; | 1156 | Cmnd->result = DID_ERROR << 16; |
1153 | 1157 | ||
1154 | if (scsi_bufflen(Cmnd)) | 1158 | if (scsi_bufflen(Cmnd)) |
1155 | sbus_unmap_sg(qpti->sdev, | 1159 | dma_unmap_sg(&qpti->op->dev, |
1156 | scsi_sglist(Cmnd), scsi_sg_count(Cmnd), | 1160 | scsi_sglist(Cmnd), scsi_sg_count(Cmnd), |
1157 | Cmnd->sc_data_direction); | 1161 | Cmnd->sc_data_direction); |
1158 | 1162 | ||
1159 | qpti->cmd_count[Cmnd->device->id]--; | 1163 | qpti->cmd_count[Cmnd->device->id]--; |
1160 | sbus_writew(out_ptr, qpti->qregs + MBOX5); | 1164 | sbus_writew(out_ptr, qpti->qregs + MBOX5); |
@@ -1268,34 +1272,32 @@ static struct scsi_host_template qpti_template = { | |||
1268 | .use_clustering = ENABLE_CLUSTERING, | 1272 | .use_clustering = ENABLE_CLUSTERING, |
1269 | }; | 1273 | }; |
1270 | 1274 | ||
1271 | static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_device_id *match) | 1275 | static int __devinit qpti_sbus_probe(struct of_device *op, const struct of_device_id *match) |
1272 | { | 1276 | { |
1273 | static int nqptis; | ||
1274 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | ||
1275 | struct device_node *dp = dev->node; | ||
1276 | struct scsi_host_template *tpnt = match->data; | 1277 | struct scsi_host_template *tpnt = match->data; |
1278 | struct device_node *dp = op->node; | ||
1277 | struct Scsi_Host *host; | 1279 | struct Scsi_Host *host; |
1278 | struct qlogicpti *qpti; | 1280 | struct qlogicpti *qpti; |
1281 | static int nqptis; | ||
1279 | const char *fcode; | 1282 | const char *fcode; |
1280 | 1283 | ||
1281 | /* Sometimes Antares cards come up not completely | 1284 | /* Sometimes Antares cards come up not completely |
1282 | * setup, and we get a report of a zero IRQ. | 1285 | * setup, and we get a report of a zero IRQ. |
1283 | */ | 1286 | */ |
1284 | if (sdev->irqs[0] == 0) | 1287 | if (op->irqs[0] == 0) |
1285 | return -ENODEV; | 1288 | return -ENODEV; |
1286 | 1289 | ||
1287 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); | 1290 | host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); |
1288 | if (!host) | 1291 | if (!host) |
1289 | return -ENOMEM; | 1292 | return -ENOMEM; |
1290 | 1293 | ||
1291 | qpti = (struct qlogicpti *) host->hostdata; | 1294 | qpti = shost_priv(host); |
1292 | 1295 | ||
1293 | host->max_id = MAX_TARGETS; | 1296 | host->max_id = MAX_TARGETS; |
1294 | qpti->qhost = host; | 1297 | qpti->qhost = host; |
1295 | qpti->sdev = sdev; | 1298 | qpti->op = op; |
1296 | qpti->qpti_id = nqptis; | 1299 | qpti->qpti_id = nqptis; |
1297 | qpti->prom_node = sdev->prom_node; | 1300 | strcpy(qpti->prom_name, op->node->name); |
1298 | strcpy(qpti->prom_name, sdev->ofdev.node->name); | ||
1299 | qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp"); | 1301 | qpti->is_pti = strcmp(qpti->prom_name, "QLGC,isp"); |
1300 | 1302 | ||
1301 | if (qpti_map_regs(qpti) < 0) | 1303 | if (qpti_map_regs(qpti) < 0) |
@@ -1341,12 +1343,12 @@ static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_devi | |||
1341 | (qpti->ultra ? "Ultra" : "Fast"), | 1343 | (qpti->ultra ? "Ultra" : "Fast"), |
1342 | (qpti->differential ? "differential" : "single ended")); | 1344 | (qpti->differential ? "differential" : "single ended")); |
1343 | 1345 | ||
1344 | if (scsi_add_host(host, &dev->dev)) { | 1346 | if (scsi_add_host(host, &op->dev)) { |
1345 | printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id); | 1347 | printk("qlogicpti%d: Failed scsi_add_host\n", qpti->qpti_id); |
1346 | goto fail_unmap_queues; | 1348 | goto fail_unmap_queues; |
1347 | } | 1349 | } |
1348 | 1350 | ||
1349 | dev_set_drvdata(&sdev->ofdev.dev, qpti); | 1351 | dev_set_drvdata(&op->dev, qpti); |
1350 | 1352 | ||
1351 | qpti_chain_add(qpti); | 1353 | qpti_chain_add(qpti); |
1352 | 1354 | ||
@@ -1357,19 +1359,20 @@ static int __devinit qpti_sbus_probe(struct of_device *dev, const struct of_devi | |||
1357 | 1359 | ||
1358 | fail_unmap_queues: | 1360 | fail_unmap_queues: |
1359 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | 1361 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
1360 | sbus_free_consistent(qpti->sdev, | 1362 | dma_free_coherent(&op->dev, |
1361 | QSIZE(RES_QUEUE_LEN), | 1363 | QSIZE(RES_QUEUE_LEN), |
1362 | qpti->res_cpu, qpti->res_dvma); | 1364 | qpti->res_cpu, qpti->res_dvma); |
1363 | sbus_free_consistent(qpti->sdev, | 1365 | dma_free_coherent(&op->dev, |
1364 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | 1366 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
1365 | qpti->req_cpu, qpti->req_dvma); | 1367 | qpti->req_cpu, qpti->req_dvma); |
1366 | #undef QSIZE | 1368 | #undef QSIZE |
1367 | 1369 | ||
1368 | fail_unmap_regs: | 1370 | fail_unmap_regs: |
1369 | sbus_iounmap(qpti->qregs, | 1371 | of_iounmap(&op->resource[0], qpti->qregs, |
1370 | qpti->sdev->reg_addrs[0].reg_size); | 1372 | resource_size(&op->resource[0])); |
1371 | if (qpti->is_pti) | 1373 | if (qpti->is_pti) |
1372 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | 1374 | of_iounmap(&op->resource[0], qpti->sreg, |
1375 | sizeof(unsigned char)); | ||
1373 | 1376 | ||
1374 | fail_free_irq: | 1377 | fail_free_irq: |
1375 | free_irq(qpti->irq, qpti); | 1378 | free_irq(qpti->irq, qpti); |
@@ -1380,9 +1383,9 @@ fail_unlink: | |||
1380 | return -ENODEV; | 1383 | return -ENODEV; |
1381 | } | 1384 | } |
1382 | 1385 | ||
1383 | static int __devexit qpti_sbus_remove(struct of_device *dev) | 1386 | static int __devexit qpti_sbus_remove(struct of_device *op) |
1384 | { | 1387 | { |
1385 | struct qlogicpti *qpti = dev_get_drvdata(&dev->dev); | 1388 | struct qlogicpti *qpti = dev_get_drvdata(&op->dev); |
1386 | 1389 | ||
1387 | qpti_chain_del(qpti); | 1390 | qpti_chain_del(qpti); |
1388 | 1391 | ||
@@ -1395,24 +1398,25 @@ static int __devexit qpti_sbus_remove(struct of_device *dev) | |||
1395 | free_irq(qpti->irq, qpti); | 1398 | free_irq(qpti->irq, qpti); |
1396 | 1399 | ||
1397 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) | 1400 | #define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN) |
1398 | sbus_free_consistent(qpti->sdev, | 1401 | dma_free_coherent(&op->dev, |
1399 | QSIZE(RES_QUEUE_LEN), | 1402 | QSIZE(RES_QUEUE_LEN), |
1400 | qpti->res_cpu, qpti->res_dvma); | 1403 | qpti->res_cpu, qpti->res_dvma); |
1401 | sbus_free_consistent(qpti->sdev, | 1404 | dma_free_coherent(&op->dev, |
1402 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), | 1405 | QSIZE(QLOGICPTI_REQ_QUEUE_LEN), |
1403 | qpti->req_cpu, qpti->req_dvma); | 1406 | qpti->req_cpu, qpti->req_dvma); |
1404 | #undef QSIZE | 1407 | #undef QSIZE |
1405 | 1408 | ||
1406 | sbus_iounmap(qpti->qregs, qpti->sdev->reg_addrs[0].reg_size); | 1409 | of_iounmap(&op->resource[0], qpti->qregs, |
1410 | resource_size(&op->resource[0])); | ||
1407 | if (qpti->is_pti) | 1411 | if (qpti->is_pti) |
1408 | sbus_iounmap(qpti->sreg, sizeof(unsigned char)); | 1412 | of_iounmap(&op->resource[0], qpti->sreg, sizeof(unsigned char)); |
1409 | 1413 | ||
1410 | scsi_host_put(qpti->qhost); | 1414 | scsi_host_put(qpti->qhost); |
1411 | 1415 | ||
1412 | return 0; | 1416 | return 0; |
1413 | } | 1417 | } |
1414 | 1418 | ||
1415 | static struct of_device_id qpti_match[] = { | 1419 | static const struct of_device_id qpti_match[] = { |
1416 | { | 1420 | { |
1417 | .name = "ptisp", | 1421 | .name = "ptisp", |
1418 | .data = &qpti_template, | 1422 | .data = &qpti_template, |
@@ -1442,7 +1446,7 @@ static struct of_platform_driver qpti_sbus_driver = { | |||
1442 | 1446 | ||
1443 | static int __init qpti_init(void) | 1447 | static int __init qpti_init(void) |
1444 | { | 1448 | { |
1445 | return of_register_driver(&qpti_sbus_driver, &sbus_bus_type); | 1449 | return of_register_driver(&qpti_sbus_driver, &of_bus_type); |
1446 | } | 1450 | } |
1447 | 1451 | ||
1448 | static void __exit qpti_exit(void) | 1452 | static void __exit qpti_exit(void) |
@@ -1453,7 +1457,7 @@ static void __exit qpti_exit(void) | |||
1453 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); | 1457 | MODULE_DESCRIPTION("QlogicISP SBUS driver"); |
1454 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); | 1458 | MODULE_AUTHOR("David S. Miller (davem@davemloft.net)"); |
1455 | MODULE_LICENSE("GPL"); | 1459 | MODULE_LICENSE("GPL"); |
1456 | MODULE_VERSION("2.0"); | 1460 | MODULE_VERSION("2.1"); |
1457 | 1461 | ||
1458 | module_init(qpti_init); | 1462 | module_init(qpti_init); |
1459 | module_exit(qpti_exit); | 1463 | module_exit(qpti_exit); |