aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/arm/rapide.c34
-rw-r--r--drivers/ide/ide.c19
-rw-r--r--drivers/ide/legacy/ide_platform.c55
-rw-r--r--drivers/ide/pci/sgiioc4.c9
-rw-r--r--drivers/ide/ppc/pmac.c29
-rw-r--r--include/linux/ide.h1
6 files changed, 81 insertions, 66 deletions
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c
index c709d37ec095..0267467d1796 100644
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -13,26 +13,18 @@
13 13
14#include <asm/ecard.h> 14#include <asm/ecard.h>
15 15
16static ide_hwif_t * 16static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
17rapide_locate_hwif(void __iomem *base, void __iomem *ctrl, unsigned int sz, int irq) 17 void __iomem *ctrl, unsigned int sz, int irq)
18{ 18{
19 unsigned long port = (unsigned long)base; 19 unsigned long port = (unsigned long)base;
20 ide_hwif_t *hwif = ide_find_port(port);
21 int i; 20 int i;
22 21
23 if (hwif == NULL)
24 goto out;
25
26 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { 22 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
27 hwif->io_ports[i] = port; 23 hw->io_ports[i] = port;
28 port += sz; 24 port += sz;
29 } 25 }
30 hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl; 26 hw->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
31 hwif->irq = irq; 27 hw->irq = irq;
32 hwif->mmio = 1;
33 default_hwif_mmiops(hwif);
34out:
35 return hwif;
36} 28}
37 29
38static int __devinit 30static int __devinit
@@ -42,6 +34,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
42 void __iomem *base; 34 void __iomem *base;
43 int ret; 35 int ret;
44 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 36 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
37 hw_regs_t hw;
45 38
46 ret = ecard_request_resources(ec); 39 ret = ecard_request_resources(ec);
47 if (ret) 40 if (ret)
@@ -53,12 +46,19 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
53 goto release; 46 goto release;
54 } 47 }
55 48
56 hwif = rapide_locate_hwif(base, base + 0x818, 1 << 6, ec->irq); 49 hwif = ide_find_port((unsigned long)base);
57 if (hwif) { 50 if (hwif) {
58 hwif->chipset = ide_generic; 51 memset(&hw, 0, sizeof(hw));
52 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
53 hw.chipset = ide_generic;
54 hw.dev = &ec->dev;
55
56 ide_init_port_hw(hwif, &hw);
57
58 hwif->mmio = 1;
59 default_hwif_mmiops(hwif);
60
59 hwif->hwif_data = base; 61 hwif->hwif_data = base;
60 hwif->gendev.parent = &ec->dev;
61 hwif->noprobe = 0;
62 62
63 idx[0] = hwif->index; 63 idx[0] = hwif->index;
64 64
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 8ef521f66f87..98bd45e8c175 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -675,6 +675,17 @@ void ide_setup_ports ( hw_regs_t *hw,
675 */ 675 */
676} 676}
677 677
678void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
679{
680 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
681 hwif->irq = hw->irq;
682 hwif->noprobe = 0;
683 hwif->chipset = hw->chipset;
684 hwif->gendev.parent = hw->dev;
685 hwif->ack_intr = hw->ack_intr;
686}
687EXPORT_SYMBOL_GPL(ide_init_port_hw);
688
678/** 689/**
679 * ide_register_hw - register IDE interface 690 * ide_register_hw - register IDE interface
680 * @hw: hardware registers 691 * @hw: hardware registers
@@ -729,13 +740,9 @@ found:
729 } 740 }
730 if (hwif->present) 741 if (hwif->present)
731 return -1; 742 return -1;
732 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); 743
733 hwif->irq = hw->irq; 744 ide_init_port_hw(hwif, hw);
734 hwif->noprobe = 0;
735 hwif->quirkproc = quirkproc; 745 hwif->quirkproc = quirkproc;
736 hwif->chipset = hw->chipset;
737 hwif->gendev.parent = hw->dev;
738 hwif->ack_intr = hw->ack_intr;
739 746
740 if (initializing == 0) { 747 if (initializing == 0) {
741 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 748 u8 idx[4] = { index, 0xff, 0xff, 0xff };
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c
index 7bb79f53dac8..69a0fb0e564f 100644
--- a/drivers/ide/legacy/ide_platform.c
+++ b/drivers/ide/legacy/ide_platform.c
@@ -28,39 +28,27 @@ static struct {
28 int index; 28 int index;
29} hwif_prop; 29} hwif_prop;
30 30
31static ide_hwif_t *__devinit plat_ide_locate_hwif(void __iomem *base, 31static void __devinit plat_ide_setup_ports(hw_regs_t *hw,
32 void __iomem *ctrl, struct pata_platform_info *pdata, int irq, 32 void __iomem *base,
33 int mmio) 33 void __iomem *ctrl,
34 struct pata_platform_info *pdata,
35 int irq)
34{ 36{
35 unsigned long port = (unsigned long)base; 37 unsigned long port = (unsigned long)base;
36 ide_hwif_t *hwif = ide_find_port(port);
37 int i; 38 int i;
38 39
39 if (hwif == NULL) 40 hw->io_ports[IDE_DATA_OFFSET] = port;
40 goto out;
41
42 hwif->io_ports[IDE_DATA_OFFSET] = port;
43 41
44 port += (1 << pdata->ioport_shift); 42 port += (1 << pdata->ioport_shift);
45 for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET; 43 for (i = IDE_ERROR_OFFSET; i <= IDE_STATUS_OFFSET;
46 i++, port += (1 << pdata->ioport_shift)) 44 i++, port += (1 << pdata->ioport_shift))
47 hwif->io_ports[i] = port; 45 hw->io_ports[i] = port;
48
49 hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
50 46
51 hwif->irq = irq; 47 hw->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)ctrl;
52 48
53 hwif->chipset = ide_generic; 49 hw->irq = irq;
54 50
55 if (mmio) { 51 hw->chipset = ide_generic;
56 hwif->mmio = 1;
57 default_hwif_mmiops(hwif);
58 }
59
60 hwif_prop.hwif = hwif;
61 hwif_prop.index = hwif->index;
62out:
63 return hwif;
64} 52}
65 53
66static int __devinit plat_ide_probe(struct platform_device *pdev) 54static int __devinit plat_ide_probe(struct platform_device *pdev)
@@ -71,6 +59,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
71 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 59 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
72 int ret = 0; 60 int ret = 0;
73 int mmio = 0; 61 int mmio = 0;
62 hw_regs_t hw;
74 63
75 pdata = pdev->dev.platform_data; 64 pdata = pdev->dev.platform_data;
76 65
@@ -106,15 +95,27 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
106 res_alt->start, res_alt->end - res_alt->start + 1); 95 res_alt->start, res_alt->end - res_alt->start + 1);
107 } 96 }
108 97
109 hwif = plat_ide_locate_hwif(hwif_prop.plat_ide_mapbase, 98 hwif = ide_find_port((unsigned long)hwif_prop.plat_ide_mapbase);
110 hwif_prop.plat_ide_alt_mapbase, pdata, res_irq->start, mmio);
111
112 if (!hwif) { 99 if (!hwif) {
113 ret = -ENODEV; 100 ret = -ENODEV;
114 goto out; 101 goto out;
115 } 102 }
116 hwif->gendev.parent = &pdev->dev; 103
117 hwif->noprobe = 0; 104 memset(&hw, 0, sizeof(hw));
105 plat_ide_setup_ports(&hw, hwif_prop.plat_ide_mapbase,
106 hwif_prop.plat_ide_alt_mapbase,
107 pdata, res_irq->start);
108 hw.dev = &pdev->dev;
109
110 ide_init_port_hw(hwif, &hw);
111
112 if (mmio) {
113 hwif->mmio = 1;
114 default_hwif_mmiops(hwif);
115 }
116
117 hwif_prop.hwif = hwif;
118 hwif_prop.index = hwif->index;
118 119
119 idx[0] = hwif->index; 120 idx[0] = hwif->index;
120 121
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index b188efcd3551..9e0be7d54980 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -636,14 +636,13 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
636 /* Initialize the IO registers */ 636 /* Initialize the IO registers */
637 memset(&hw, 0, sizeof(hw)); 637 memset(&hw, 0, sizeof(hw));
638 sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport); 638 sgiioc4_init_hwif_ports(&hw, cmd_base, ctl, irqport);
639 memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); 639 hw.irq = dev->irq;
640 hwif->noprobe = 0; 640 hw.chipset = ide_pci;
641 hw.dev = &dev->dev;
642 ide_init_port_hw(hwif, &hw);
641 643
642 hwif->irq = dev->irq;
643 hwif->chipset = ide_pci;
644 hwif->pci_dev = dev; 644 hwif->pci_dev = dev;
645 hwif->channel = 0; /* Single Channel chip */ 645 hwif->channel = 0; /* Single Channel chip */
646 hwif->gendev.parent = &dev->dev;/* setup proper ancestral information */
647 646
648 /* The IOC4 uses MMIO rather than Port IO. */ 647 /* The IOC4 uses MMIO rather than Port IO. */
649 default_hwif_mmiops(hwif); 648 default_hwif_mmiops(hwif);
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 6a4b0d479897..36e4b9570746 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1012,12 +1012,11 @@ pmac_ide_do_resume(ide_hwif_t *hwif)
1012 * rare machines unfortunately, but it's better this way. 1012 * rare machines unfortunately, but it's better this way.
1013 */ 1013 */
1014static int 1014static int
1015pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) 1015pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1016{ 1016{
1017 struct device_node *np = pmif->node; 1017 struct device_node *np = pmif->node;
1018 const int *bidp; 1018 const int *bidp;
1019 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 1019 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
1020 hw_regs_t hw;
1021 1020
1022 pmif->cable_80 = 0; 1021 pmif->cable_80 = 0;
1023 pmif->broken_dma = pmif->broken_dma_warn = 0; 1022 pmif->broken_dma = pmif->broken_dma_warn = 0;
@@ -1103,11 +1102,9 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1103 /* Tell common code _not_ to mess with resources */ 1102 /* Tell common code _not_ to mess with resources */
1104 hwif->mmio = 1; 1103 hwif->mmio = 1;
1105 hwif->hwif_data = pmif; 1104 hwif->hwif_data = pmif;
1106 memset(&hw, 0, sizeof(hw)); 1105 hw->chipset = ide_pmac;
1107 pmac_ide_init_hwif_ports(&hw, pmif->regbase, 0, &hwif->irq); 1106 ide_init_port_hw(hwif, hw);
1108 memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports)); 1107 hwif->noprobe = pmif->mediabay;
1109 hwif->chipset = ide_pmac;
1110 hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay;
1111 hwif->hold = pmif->mediabay; 1108 hwif->hold = pmif->mediabay;
1112 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 1109 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
1113 hwif->drives[0].unmask = 1; 1110 hwif->drives[0].unmask = 1;
@@ -1163,6 +1160,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1163 ide_hwif_t *hwif; 1160 ide_hwif_t *hwif;
1164 pmac_ide_hwif_t *pmif; 1161 pmac_ide_hwif_t *pmif;
1165 int i, rc; 1162 int i, rc;
1163 hw_regs_t hw;
1166 1164
1167 i = 0; 1165 i = 0;
1168 while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0 1166 while (i < MAX_HWIFS && (ide_hwifs[i].io_ports[IDE_DATA_OFFSET] != 0
@@ -1205,7 +1203,6 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1205 regbase = (unsigned long) base; 1203 regbase = (unsigned long) base;
1206 1204
1207 hwif->pci_dev = mdev->bus->pdev; 1205 hwif->pci_dev = mdev->bus->pdev;
1208 hwif->gendev.parent = &mdev->ofdev.dev;
1209 1206
1210 pmif->mdev = mdev; 1207 pmif->mdev = mdev;
1211 pmif->node = mdev->ofdev.node; 1208 pmif->node = mdev->ofdev.node;
@@ -1223,7 +1220,12 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1223#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 1220#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
1224 dev_set_drvdata(&mdev->ofdev.dev, hwif); 1221 dev_set_drvdata(&mdev->ofdev.dev, hwif);
1225 1222
1226 rc = pmac_ide_setup_device(pmif, hwif); 1223 memset(&hw, 0, sizeof(hw));
1224 pmac_ide_init_hwif_ports(&hw, pmif->regbase, 0, NULL);
1225 hw.irq = irq;
1226 hw.dev = &mdev->ofdev.dev;
1227
1228 rc = pmac_ide_setup_device(pmif, hwif, &hw);
1227 if (rc != 0) { 1229 if (rc != 0) {
1228 /* The inteface is released to the common IDE layer */ 1230 /* The inteface is released to the common IDE layer */
1229 dev_set_drvdata(&mdev->ofdev.dev, NULL); 1231 dev_set_drvdata(&mdev->ofdev.dev, NULL);
@@ -1282,6 +1284,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1282 void __iomem *base; 1284 void __iomem *base;
1283 unsigned long rbase, rlen; 1285 unsigned long rbase, rlen;
1284 int i, rc; 1286 int i, rc;
1287 hw_regs_t hw;
1285 1288
1286 np = pci_device_to_OF_node(pdev); 1289 np = pci_device_to_OF_node(pdev);
1287 if (np == NULL) { 1290 if (np == NULL) {
@@ -1315,7 +1318,6 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1315 } 1318 }
1316 1319
1317 hwif->pci_dev = pdev; 1320 hwif->pci_dev = pdev;
1318 hwif->gendev.parent = &pdev->dev;
1319 pmif->mdev = NULL; 1321 pmif->mdev = NULL;
1320 pmif->node = np; 1322 pmif->node = np;
1321 1323
@@ -1332,7 +1334,12 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1332 1334
1333 pci_set_drvdata(pdev, hwif); 1335 pci_set_drvdata(pdev, hwif);
1334 1336
1335 rc = pmac_ide_setup_device(pmif, hwif); 1337 memset(&hw, 0, sizeof(hw));
1338 pmac_ide_init_hwif_ports(&hw, pmif->regbase, 0, NULL);
1339 hw.irq = pdev->irq;
1340 hw.dev = &pdev->dev;
1341
1342 rc = pmac_ide_setup_device(pmif, hwif, &hw);
1336 if (rc != 0) { 1343 if (rc != 0) {
1337 /* The inteface is released to the common IDE layer */ 1344 /* The inteface is released to the common IDE layer */
1338 pci_set_drvdata(pdev, NULL); 1345 pci_set_drvdata(pdev, NULL);
diff --git a/include/linux/ide.h b/include/linux/ide.h
index ce9b16f38c08..de94a526ef9e 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -198,6 +198,7 @@ typedef struct hw_regs_s {
198} hw_regs_t; 198} hw_regs_t;
199 199
200struct hwif_s * ide_find_port(unsigned long); 200struct hwif_s * ide_find_port(unsigned long);
201void ide_init_port_hw(struct hwif_s *, hw_regs_t *);
201 202
202struct ide_drive_s; 203struct ide_drive_s;
203int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *), int, 204int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *), int,