aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ppc/pmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ppc/pmac.c')
-rw-r--r--drivers/ide/ppc/pmac.c104
1 files changed, 15 insertions, 89 deletions
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index d9ca52e6cdab..88619b50d9ef 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -80,7 +80,6 @@ typedef struct pmac_ide_hwif {
80} pmac_ide_hwif_t; 80} pmac_ide_hwif_t;
81 81
82static pmac_ide_hwif_t pmac_ide[MAX_HWIFS]; 82static pmac_ide_hwif_t pmac_ide[MAX_HWIFS];
83static int pmac_ide_count;
84 83
85enum { 84enum {
86 controller_ohare, /* OHare based */ 85 controller_ohare, /* OHare based */
@@ -419,38 +418,8 @@ static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
419 418
420#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 419#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
421 420
422/* 421#define PMAC_IDE_REG(x) \
423 * N.B. this can't be an initfunc, because the media-bay task can 422 ((void __iomem *)((drive)->hwif->io_ports[IDE_DATA_OFFSET] + (x)))
424 * call ide_[un]register at any time.
425 */
426void
427pmac_ide_init_hwif_ports(hw_regs_t *hw,
428 unsigned long data_port, unsigned long ctrl_port,
429 int *irq)
430{
431 int i, ix;
432
433 if (data_port == 0)
434 return;
435
436 for (ix = 0; ix < MAX_HWIFS; ++ix)
437 if (data_port == pmac_ide[ix].regbase)
438 break;
439
440 if (ix >= MAX_HWIFS)
441 return; /* not an IDE PMAC interface */
442
443 for (i = 0; i < 8; ++i)
444 hw->io_ports[i] = data_port + i * 0x10;
445 hw->io_ports[8] = data_port + 0x160;
446
447 if (irq != NULL)
448 *irq = pmac_ide[ix].irq;
449
450 hw->dev = &pmac_ide[ix].mdev->ofdev.dev;
451}
452
453#define PMAC_IDE_REG(x) ((void __iomem *)(IDE_DATA_REG+(x)))
454 423
455/* 424/*
456 * Apply the timings of the proper unit (master/slave) to the shared 425 * Apply the timings of the proper unit (master/slave) to the shared
@@ -886,58 +855,6 @@ sanitize_timings(pmac_ide_hwif_t *pmif)
886 pmif->timings[2] = pmif->timings[3] = value2; 855 pmif->timings[2] = pmif->timings[3] = value2;
887} 856}
888 857
889unsigned long
890pmac_ide_get_base(int index)
891{
892 return pmac_ide[index].regbase;
893}
894
895int
896pmac_ide_check_base(unsigned long base)
897{
898 int ix;
899
900 for (ix = 0; ix < MAX_HWIFS; ++ix)
901 if (base == pmac_ide[ix].regbase)
902 return ix;
903 return -1;
904}
905
906int
907pmac_ide_get_irq(unsigned long base)
908{
909 int ix;
910
911 for (ix = 0; ix < MAX_HWIFS; ++ix)
912 if (base == pmac_ide[ix].regbase)
913 return pmac_ide[ix].irq;
914 return 0;
915}
916
917static int ide_majors[] = { 3, 22, 33, 34, 56, 57 };
918
919dev_t __init
920pmac_find_ide_boot(char *bootdevice, int n)
921{
922 int i;
923
924 /*
925 * Look through the list of IDE interfaces for this one.
926 */
927 for (i = 0; i < pmac_ide_count; ++i) {
928 char *name;
929 if (!pmac_ide[i].node || !pmac_ide[i].node->full_name)
930 continue;
931 name = pmac_ide[i].node->full_name;
932 if (memcmp(name, bootdevice, n) == 0 && name[n] == 0) {
933 /* XXX should cope with the 2nd drive as well... */
934 return MKDEV(ide_majors[i], 0);
935 }
936 }
937
938 return 0;
939}
940
941/* Suspend call back, should be called after the child devices 858/* Suspend call back, should be called after the child devices
942 * have actually been suspended 859 * have actually been suspended
943 */ 860 */
@@ -1088,7 +1005,8 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1088 if (np->parent && np->parent->name 1005 if (np->parent && np->parent->name
1089 && strcasecmp(np->parent->name, "media-bay") == 0) { 1006 && strcasecmp(np->parent->name, "media-bay") == 0) {
1090#ifdef CONFIG_PMAC_MEDIABAY 1007#ifdef CONFIG_PMAC_MEDIABAY
1091 media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq, hwif->index); 1008 media_bay_set_ide_infos(np->parent, pmif->regbase, pmif->irq,
1009 hwif);
1092#endif /* CONFIG_PMAC_MEDIABAY */ 1010#endif /* CONFIG_PMAC_MEDIABAY */
1093 pmif->mediabay = 1; 1011 pmif->mediabay = 1;
1094 if (!bidp) 1012 if (!bidp)
@@ -1119,7 +1037,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1119 hwif->hwif_data = pmif; 1037 hwif->hwif_data = pmif;
1120 ide_init_port_hw(hwif, hw); 1038 ide_init_port_hw(hwif, hw);
1121 hwif->noprobe = pmif->mediabay; 1039 hwif->noprobe = pmif->mediabay;
1122 hwif->hold = pmif->mediabay;
1123 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 1040 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
1124 hwif->set_pio_mode = pmac_ide_set_pio_mode; 1041 hwif->set_pio_mode = pmac_ide_set_pio_mode;
1125 if (pmif->kind == controller_un_ata6 1042 if (pmif->kind == controller_un_ata6
@@ -1154,6 +1071,15 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif, hw_regs_t *hw)
1154 return 0; 1071 return 0;
1155} 1072}
1156 1073
1074static void __devinit pmac_ide_init_ports(hw_regs_t *hw, unsigned long base)
1075{
1076 int i;
1077
1078 for (i = 0; i < 8; ++i)
1079 hw->io_ports[i] = base + i * 0x10;
1080 hw->io_ports[8] = base + 0x160;
1081}
1082
1157/* 1083/*
1158 * Attach to a macio probed interface 1084 * Attach to a macio probed interface
1159 */ 1085 */
@@ -1227,7 +1153,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1227 dev_set_drvdata(&mdev->ofdev.dev, hwif); 1153 dev_set_drvdata(&mdev->ofdev.dev, hwif);
1228 1154
1229 memset(&hw, 0, sizeof(hw)); 1155 memset(&hw, 0, sizeof(hw));
1230 pmac_ide_init_hwif_ports(&hw, pmif->regbase, 0, NULL); 1156 pmac_ide_init_ports(&hw, pmif->regbase);
1231 hw.irq = irq; 1157 hw.irq = irq;
1232 hw.dev = &mdev->ofdev.dev; 1158 hw.dev = &mdev->ofdev.dev;
1233 1159
@@ -1341,7 +1267,7 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1341 pci_set_drvdata(pdev, hwif); 1267 pci_set_drvdata(pdev, hwif);
1342 1268
1343 memset(&hw, 0, sizeof(hw)); 1269 memset(&hw, 0, sizeof(hw));
1344 pmac_ide_init_hwif_ports(&hw, pmif->regbase, 0, NULL); 1270 pmac_ide_init_ports(&hw, pmif->regbase);
1345 hw.irq = pdev->irq; 1271 hw.irq = pdev->irq;
1346 hw.dev = &pdev->dev; 1272 hw.dev = &pdev->dev;
1347 1273