aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c197
1 files changed, 36 insertions, 161 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index c6d4f630e18a..97894abd9ebc 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -95,7 +95,7 @@ DEFINE_MUTEX(ide_cfg_mtx);
95 __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); 95 __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
96 96
97#ifdef CONFIG_IDEPCI_PCIBUS_ORDER 97#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
98static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */ 98int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */
99#endif 99#endif
100 100
101int noautodma = 0; 101int noautodma = 0;
@@ -116,7 +116,7 @@ EXPORT_SYMBOL(ide_hwifs);
116/* 116/*
117 * Do not even *think* about calling this! 117 * Do not even *think* about calling this!
118 */ 118 */
119static void init_hwif_data(ide_hwif_t *hwif, unsigned int index) 119void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
120{ 120{
121 unsigned int unit; 121 unsigned int unit;
122 122
@@ -159,6 +159,7 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
159 init_completion(&drive->gendev_rel_comp); 159 init_completion(&drive->gendev_rel_comp);
160 } 160 }
161} 161}
162EXPORT_SYMBOL_GPL(ide_init_port_data);
162 163
163static void init_hwif_default(ide_hwif_t *hwif, unsigned int index) 164static void init_hwif_default(ide_hwif_t *hwif, unsigned int index)
164{ 165{
@@ -177,8 +178,6 @@ static void init_hwif_default(ide_hwif_t *hwif, unsigned int index)
177#endif 178#endif
178} 179}
179 180
180extern void ide_arm_init(void);
181
182/* 181/*
183 * init_ide_data() sets reasonable default values into all fields 182 * init_ide_data() sets reasonable default values into all fields
184 * of all instances of the hwifs and drives, but only on the first call. 183 * of all instances of the hwifs and drives, but only on the first call.
@@ -210,16 +209,13 @@ static void __init init_ide_data (void)
210 /* Initialise all interface structures */ 209 /* Initialise all interface structures */
211 for (index = 0; index < MAX_HWIFS; ++index) { 210 for (index = 0; index < MAX_HWIFS; ++index) {
212 hwif = &ide_hwifs[index]; 211 hwif = &ide_hwifs[index];
213 init_hwif_data(hwif, index); 212 ide_init_port_data(hwif, index);
214 init_hwif_default(hwif, index); 213 init_hwif_default(hwif, index);
215#if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI) 214#if !defined(CONFIG_PPC32) || !defined(CONFIG_PCI)
216 hwif->irq = 215 hwif->irq =
217 ide_init_default_irq(hwif->io_ports[IDE_DATA_OFFSET]); 216 ide_init_default_irq(hwif->io_ports[IDE_DATA_OFFSET]);
218#endif 217#endif
219 } 218 }
220#ifdef CONFIG_IDE_ARM
221 ide_arm_init();
222#endif
223} 219}
224 220
225/** 221/**
@@ -414,8 +410,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
414 hwif->cds = tmp_hwif->cds; 410 hwif->cds = tmp_hwif->cds;
415#endif 411#endif
416 412
417 hwif->fixup = tmp_hwif->fixup;
418
419 hwif->set_pio_mode = tmp_hwif->set_pio_mode; 413 hwif->set_pio_mode = tmp_hwif->set_pio_mode;
420 hwif->set_dma_mode = tmp_hwif->set_dma_mode; 414 hwif->set_dma_mode = tmp_hwif->set_dma_mode;
421 hwif->mdma_filter = tmp_hwif->mdma_filter; 415 hwif->mdma_filter = tmp_hwif->mdma_filter;
@@ -433,16 +427,13 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
433 hwif->atapi_input_bytes = tmp_hwif->atapi_input_bytes; 427 hwif->atapi_input_bytes = tmp_hwif->atapi_input_bytes;
434 hwif->atapi_output_bytes = tmp_hwif->atapi_output_bytes; 428 hwif->atapi_output_bytes = tmp_hwif->atapi_output_bytes;
435 429
430 hwif->dma_host_set = tmp_hwif->dma_host_set;
436 hwif->dma_setup = tmp_hwif->dma_setup; 431 hwif->dma_setup = tmp_hwif->dma_setup;
437 hwif->dma_exec_cmd = tmp_hwif->dma_exec_cmd; 432 hwif->dma_exec_cmd = tmp_hwif->dma_exec_cmd;
438 hwif->dma_start = tmp_hwif->dma_start; 433 hwif->dma_start = tmp_hwif->dma_start;
439 hwif->ide_dma_end = tmp_hwif->ide_dma_end; 434 hwif->ide_dma_end = tmp_hwif->ide_dma_end;
440 hwif->ide_dma_on = tmp_hwif->ide_dma_on;
441 hwif->dma_off_quietly = tmp_hwif->dma_off_quietly;
442 hwif->ide_dma_test_irq = tmp_hwif->ide_dma_test_irq; 435 hwif->ide_dma_test_irq = tmp_hwif->ide_dma_test_irq;
443 hwif->ide_dma_clear_irq = tmp_hwif->ide_dma_clear_irq; 436 hwif->ide_dma_clear_irq = tmp_hwif->ide_dma_clear_irq;
444 hwif->dma_host_on = tmp_hwif->dma_host_on;
445 hwif->dma_host_off = tmp_hwif->dma_host_off;
446 hwif->dma_lost_irq = tmp_hwif->dma_lost_irq; 437 hwif->dma_lost_irq = tmp_hwif->dma_lost_irq;
447 hwif->dma_timeout = tmp_hwif->dma_timeout; 438 hwif->dma_timeout = tmp_hwif->dma_timeout;
448 439
@@ -614,7 +605,7 @@ void ide_unregister(unsigned int index)
614 tmp_hwif = *hwif; 605 tmp_hwif = *hwif;
615 606
616 /* restore hwif data to pristine status */ 607 /* restore hwif data to pristine status */
617 init_hwif_data(hwif, index); 608 ide_init_port_data(hwif, index);
618 init_hwif_default(hwif, index); 609 init_hwif_default(hwif, index);
619 610
620 ide_hwif_restore(hwif, &tmp_hwif); 611 ide_hwif_restore(hwif, &tmp_hwif);
@@ -680,24 +671,34 @@ void ide_setup_ports ( hw_regs_t *hw,
680 */ 671 */
681} 672}
682 673
674void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
675{
676 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
677 hwif->irq = hw->irq;
678 hwif->noprobe = 0;
679 hwif->chipset = hw->chipset;
680 hwif->gendev.parent = hw->dev;
681 hwif->ack_intr = hw->ack_intr;
682}
683EXPORT_SYMBOL_GPL(ide_init_port_hw);
684
683/** 685/**
684 * ide_register_hw - register IDE interface 686 * ide_register_hw - register IDE interface
685 * @hw: hardware registers 687 * @hw: hardware registers
686 * @fixup: fixup function 688 * @quirkproc: quirkproc function
687 * @initializing: set while initializing built-in drivers
688 * @hwifp: pointer to returned hwif 689 * @hwifp: pointer to returned hwif
689 * 690 *
690 * Register an IDE interface, specifying exactly the registers etc. 691 * Register an IDE interface, specifying exactly the registers etc.
691 * Set init=1 iff calling before probes have taken place.
692 * 692 *
693 * Returns -1 on error. 693 * Returns -1 on error.
694 */ 694 */
695 695
696int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *), 696int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
697 int initializing, ide_hwif_t **hwifp) 697 ide_hwif_t **hwifp)
698{ 698{
699 int index, retry = 1; 699 int index, retry = 1;
700 ide_hwif_t *hwif; 700 ide_hwif_t *hwif;
701 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
701 702
702 do { 703 do {
703 for (index = 0; index < MAX_HWIFS; ++index) { 704 for (index = 0; index < MAX_HWIFS; ++index) {
@@ -709,8 +710,7 @@ int ide_register_hw(hw_regs_t *hw, void (*fixup)(ide_hwif_t *),
709 hwif = &ide_hwifs[index]; 710 hwif = &ide_hwifs[index];
710 if (hwif->hold) 711 if (hwif->hold)
711 continue; 712 continue;
712 if ((!hwif->present && !hwif->mate && !initializing) || 713 if (!hwif->present && hwif->mate == NULL)
713 (!hwif->io_ports[IDE_DATA_OFFSET] && initializing))
714 goto found; 714 goto found;
715 } 715 }
716 for (index = 0; index < MAX_HWIFS; index++) 716 for (index = 0; index < MAX_HWIFS; index++)
@@ -721,29 +721,23 @@ found:
721 if (hwif->present) 721 if (hwif->present)
722 ide_unregister(index); 722 ide_unregister(index);
723 else if (!hwif->hold) { 723 else if (!hwif->hold) {
724 init_hwif_data(hwif, index); 724 ide_init_port_data(hwif, index);
725 init_hwif_default(hwif, index); 725 init_hwif_default(hwif, index);
726 } 726 }
727 if (hwif->present) 727 if (hwif->present)
728 return -1; 728 return -1;
729 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
730 hwif->irq = hw->irq;
731 hwif->noprobe = 0;
732 hwif->fixup = fixup;
733 hwif->chipset = hw->chipset;
734 hwif->gendev.parent = hw->dev;
735 hwif->ack_intr = hw->ack_intr;
736 729
737 if (initializing == 0) { 730 ide_init_port_hw(hwif, hw);
738 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 731 hwif->quirkproc = quirkproc;
739 732
740 ide_device_add(idx); 733 idx[0] = index;
741 } 734
735 ide_device_add(idx);
742 736
743 if (hwifp) 737 if (hwifp)
744 *hwifp = hwif; 738 *hwifp = hwif;
745 739
746 return (initializing || hwif->present) ? index : -1; 740 return hwif->present ? index : -1;
747} 741}
748 742
749EXPORT_SYMBOL(ide_register_hw); 743EXPORT_SYMBOL(ide_register_hw);
@@ -836,7 +830,7 @@ int set_using_dma(ide_drive_t *drive, int arg)
836 if (!drive->id || !(drive->id->capability & 1)) 830 if (!drive->id || !(drive->id->capability & 1))
837 goto out; 831 goto out;
838 832
839 if (hwif->ide_dma_on == NULL) 833 if (hwif->dma_host_set == NULL)
840 goto out; 834 goto out;
841 835
842 err = -EBUSY; 836 err = -EBUSY;
@@ -884,7 +878,10 @@ int set_pio_mode(ide_drive_t *drive, int arg)
884 878
885 if (drive->special.b.set_tune) 879 if (drive->special.b.set_tune)
886 return -EBUSY; 880 return -EBUSY;
881
887 ide_init_drive_cmd(&rq); 882 ide_init_drive_cmd(&rq);
883 rq.cmd_type = REQ_TYPE_ATA_TASKFILE;
884
888 drive->tune_req = (u8) arg; 885 drive->tune_req = (u8) arg;
889 drive->special.b.set_tune = 1; 886 drive->special.b.set_tune = 1;
890 (void) ide_do_drive_cmd(drive, &rq, ide_wait); 887 (void) ide_do_drive_cmd(drive, &rq, ide_wait);
@@ -1066,7 +1063,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
1066 ide_init_hwif_ports(&hw, (unsigned long) args[0], 1063 ide_init_hwif_ports(&hw, (unsigned long) args[0],
1067 (unsigned long) args[1], NULL); 1064 (unsigned long) args[1], NULL);
1068 hw.irq = args[2]; 1065 hw.irq = args[2];
1069 if (ide_register_hw(&hw, NULL, 0, NULL) == -1) 1066 if (ide_register_hw(&hw, NULL, NULL) == -1)
1070 return -EIO; 1067 return -EIO;
1071 return 0; 1068 return 0;
1072 } 1069 }
@@ -1227,26 +1224,12 @@ static int __init match_parm (char *s, const char *keywords[], int vals[], int m
1227 return 0; /* zero = nothing matched */ 1224 return 0; /* zero = nothing matched */
1228} 1225}
1229 1226
1230#ifdef CONFIG_BLK_DEV_ALI14XX
1231extern int probe_ali14xx; 1227extern int probe_ali14xx;
1232extern int ali14xx_init(void);
1233#endif
1234#ifdef CONFIG_BLK_DEV_UMC8672
1235extern int probe_umc8672; 1228extern int probe_umc8672;
1236extern int umc8672_init(void);
1237#endif
1238#ifdef CONFIG_BLK_DEV_DTC2278
1239extern int probe_dtc2278; 1229extern int probe_dtc2278;
1240extern int dtc2278_init(void);
1241#endif
1242#ifdef CONFIG_BLK_DEV_HT6560B
1243extern int probe_ht6560b; 1230extern int probe_ht6560b;
1244extern int ht6560b_init(void);
1245#endif
1246#ifdef CONFIG_BLK_DEV_QD65XX
1247extern int probe_qd65xx; 1231extern int probe_qd65xx;
1248extern int qd65xx_init(void); 1232extern int cmd640_vlb;
1249#endif
1250 1233
1251static int __initdata is_chipset_set[MAX_HWIFS]; 1234static int __initdata is_chipset_set[MAX_HWIFS];
1252 1235
@@ -1323,7 +1306,7 @@ static int __init ide_setup(char *s)
1323 if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) { 1306 if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) {
1324 const char *hd_words[] = { 1307 const char *hd_words[] = {
1325 "none", "noprobe", "nowerr", "cdrom", "nodma", 1308 "none", "noprobe", "nowerr", "cdrom", "nodma",
1326 "autotune", "noautotune", "minus8", "swapdata", "bswap", 1309 "autotune", "noautotune", "-8", "-9", "-10",
1327 "noflush", "remap", "remap63", "scsi", NULL }; 1310 "noflush", "remap", "remap63", "scsi", NULL };
1328 unit = s[2] - 'a'; 1311 unit = s[2] - 'a';
1329 hw = unit / MAX_DRIVES; 1312 hw = unit / MAX_DRIVES;
@@ -1359,10 +1342,6 @@ static int __init ide_setup(char *s)
1359 case -7: /* "noautotune" */ 1342 case -7: /* "noautotune" */
1360 drive->autotune = IDE_TUNE_NOAUTO; 1343 drive->autotune = IDE_TUNE_NOAUTO;
1361 goto obsolete_option; 1344 goto obsolete_option;
1362 case -9: /* "swapdata" */
1363 case -10: /* "bswap" */
1364 drive->bswap = 1;
1365 goto done;
1366 case -11: /* noflush */ 1345 case -11: /* noflush */
1367 drive->noflush = 1; 1346 drive->noflush = 1;
1368 goto done; 1347 goto done;
@@ -1462,11 +1441,8 @@ static int __init ide_setup(char *s)
1462#endif 1441#endif
1463#ifdef CONFIG_BLK_DEV_CMD640 1442#ifdef CONFIG_BLK_DEV_CMD640
1464 case -14: /* "cmd640_vlb" */ 1443 case -14: /* "cmd640_vlb" */
1465 {
1466 extern int cmd640_vlb; /* flag for cmd640.c */
1467 cmd640_vlb = 1; 1444 cmd640_vlb = 1;
1468 goto done; 1445 goto done;
1469 }
1470#endif 1446#endif
1471#ifdef CONFIG_BLK_DEV_HT6560B 1447#ifdef CONFIG_BLK_DEV_HT6560B
1472 case -13: /* "ht6560b" */ 1448 case -13: /* "ht6560b" */
@@ -1556,79 +1532,6 @@ done:
1556 return 1; 1532 return 1;
1557} 1533}
1558 1534
1559extern void __init pnpide_init(void);
1560extern void __exit pnpide_exit(void);
1561extern void __init h8300_ide_init(void);
1562
1563/*
1564 * probe_for_hwifs() finds/initializes "known" IDE interfaces
1565 */
1566static void __init probe_for_hwifs (void)
1567{
1568#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
1569 ide_scan_pcibus(ide_scan_direction);
1570#endif
1571
1572#ifdef CONFIG_ETRAX_IDE
1573 {
1574 extern void init_e100_ide(void);
1575 init_e100_ide();
1576 }
1577#endif /* CONFIG_ETRAX_IDE */
1578#ifdef CONFIG_BLK_DEV_CMD640
1579 {
1580 extern void ide_probe_for_cmd640x(void);
1581 ide_probe_for_cmd640x();
1582 }
1583#endif /* CONFIG_BLK_DEV_CMD640 */
1584#ifdef CONFIG_BLK_DEV_IDE_PMAC
1585 {
1586 extern int pmac_ide_probe(void);
1587 (void)pmac_ide_probe();
1588 }
1589#endif /* CONFIG_BLK_DEV_IDE_PMAC */
1590#ifdef CONFIG_BLK_DEV_GAYLE
1591 {
1592 extern void gayle_init(void);
1593 gayle_init();
1594 }
1595#endif /* CONFIG_BLK_DEV_GAYLE */
1596#ifdef CONFIG_BLK_DEV_FALCON_IDE
1597 {
1598 extern void falconide_init(void);
1599 falconide_init();
1600 }
1601#endif /* CONFIG_BLK_DEV_FALCON_IDE */
1602#ifdef CONFIG_BLK_DEV_MAC_IDE
1603 {
1604 extern void macide_init(void);
1605 macide_init();
1606 }
1607#endif /* CONFIG_BLK_DEV_MAC_IDE */
1608#ifdef CONFIG_BLK_DEV_Q40IDE
1609 {
1610 extern void q40ide_init(void);
1611 q40ide_init();
1612 }
1613#endif /* CONFIG_BLK_DEV_Q40IDE */
1614#ifdef CONFIG_BLK_DEV_BUDDHA
1615 {
1616 extern void buddha_init(void);
1617 buddha_init();
1618 }
1619#endif /* CONFIG_BLK_DEV_BUDDHA */
1620#ifdef CONFIG_BLK_DEV_IDEPNP
1621 pnpide_init();
1622#endif
1623#ifdef CONFIG_H8300
1624 h8300_ide_init();
1625#endif
1626}
1627
1628/*
1629 * Probe module
1630 */
1631
1632EXPORT_SYMBOL(ide_lock); 1535EXPORT_SYMBOL(ide_lock);
1633 1536
1634static int ide_bus_match(struct device *dev, struct device_driver *drv) 1537static int ide_bus_match(struct device *dev, struct device_driver *drv)
@@ -1775,30 +1678,6 @@ static int __init ide_init(void)
1775 1678
1776 proc_ide_create(); 1679 proc_ide_create();
1777 1680
1778#ifdef CONFIG_BLK_DEV_ALI14XX
1779 if (probe_ali14xx)
1780 (void)ali14xx_init();
1781#endif
1782#ifdef CONFIG_BLK_DEV_UMC8672
1783 if (probe_umc8672)
1784 (void)umc8672_init();
1785#endif
1786#ifdef CONFIG_BLK_DEV_DTC2278
1787 if (probe_dtc2278)
1788 (void)dtc2278_init();
1789#endif
1790#ifdef CONFIG_BLK_DEV_HT6560B
1791 if (probe_ht6560b)
1792 (void)ht6560b_init();
1793#endif
1794#ifdef CONFIG_BLK_DEV_QD65XX
1795 if (probe_qd65xx)
1796 (void)qd65xx_init();
1797#endif
1798
1799 /* Probe for special PCI and other "known" interface chipsets. */
1800 probe_for_hwifs();
1801
1802 return 0; 1681 return 0;
1803} 1682}
1804 1683
@@ -1834,10 +1713,6 @@ void __exit cleanup_module (void)
1834 for (index = 0; index < MAX_HWIFS; ++index) 1713 for (index = 0; index < MAX_HWIFS; ++index)
1835 ide_unregister(index); 1714 ide_unregister(index);
1836 1715
1837#ifdef CONFIG_BLK_DEV_IDEPNP
1838 pnpide_exit();
1839#endif
1840
1841 proc_ide_destroy(); 1716 proc_ide_destroy();
1842 1717
1843 bus_unregister(&ide_bus_type); 1718 bus_unregister(&ide_bus_type);