aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/Kconfig16
-rw-r--r--drivers/ide/Makefile2
-rw-r--r--drivers/ide/ide-cd.c13
-rw-r--r--drivers/ide/ide-cd.h1
-rw-r--r--drivers/ide/ide-disk.c8
-rw-r--r--drivers/ide/ide-dma.c15
-rw-r--r--drivers/ide/ide-floppy.c7
-rw-r--r--drivers/ide/ide-io.c6
-rw-r--r--drivers/ide/ide-lib.c8
-rw-r--r--drivers/ide/ide-tape.c7
-rw-r--r--drivers/ide/ide-taskfile.c27
-rw-r--r--drivers/ide/mips/Makefile4
-rw-r--r--drivers/ide/mips/au1xxx-ide.c1498
-rw-r--r--drivers/ide/mips/swarm.c201
-rw-r--r--drivers/ide/pci/aec62xx.c47
-rw-r--r--drivers/ide/pci/alim15x3.c9
-rw-r--r--drivers/ide/pci/cs5520.c5
-rw-r--r--drivers/ide/pci/sgiioc4.c8
-rw-r--r--drivers/ide/pci/siimage.c8
-rw-r--r--drivers/ide/pci/sis5513.c1
-rw-r--r--drivers/ide/pci/sl82c105.c83
-rw-r--r--drivers/ide/pci/via82cxxx.c408
-rw-r--r--drivers/ide/ppc/pmac.c25
-rw-r--r--drivers/ide/setup-pci.c12
24 files changed, 982 insertions, 1437 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 42e5b8175cbf..1c81174595b3 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -625,7 +625,7 @@ config BLK_DEV_NS87415
625 tristate "NS87415 chipset support" 625 tristate "NS87415 chipset support"
626 help 626 help
627 This driver adds detection and support for the NS87415 chip 627 This driver adds detection and support for the NS87415 chip
628 (used in SPARC64, among others). 628 (used mainly on SPARC64 and PA-RISC machines).
629 629
630 Please read the comments at the top of <file:drivers/ide/pci/ns87415.c>. 630 Please read the comments at the top of <file:drivers/ide/pci/ns87415.c>.
631 631
@@ -787,6 +787,10 @@ config BLK_DEV_IDE_PMAC_BLINK
787 This option enables the use of the sleep LED as a hard drive 787 This option enables the use of the sleep LED as a hard drive
788 activity LED. 788 activity LED.
789 789
790config BLK_DEV_IDE_SWARM
791 tristate "IDE for Sibyte evaluation boards"
792 depends on SIBYTE_SB1xxx_SOC
793
790config BLK_DEV_IDE_AU1XXX 794config BLK_DEV_IDE_AU1XXX
791 bool "IDE for AMD Alchemy Au1200" 795 bool "IDE for AMD Alchemy Au1200"
792 depends on SOC_AU1200 796 depends on SOC_AU1200
@@ -803,14 +807,6 @@ config BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
803 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX 807 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX
804endchoice 808endchoice
805 809
806config BLK_DEV_IDE_AU1XXX_BURSTABLE_ON
807 bool "Enable burstable Mode on DbDMA"
808 default false
809 depends BLK_DEV_IDE_AU1XXX
810 help
811 This option enable the burstable Flag on DbDMA controller
812 (cf. "AMD Alchemy 'Au1200' Processor Data Book - PRELIMINARY").
813
814config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ 810config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
815 int "Maximum transfer size (KB) per request (up to 128)" 811 int "Maximum transfer size (KB) per request (up to 128)"
816 default "128" 812 default "128"
@@ -936,7 +932,7 @@ config BLK_DEV_Q40IDE
936 932
937config BLK_DEV_MPC8xx_IDE 933config BLK_DEV_MPC8xx_IDE
938 bool "MPC8xx IDE support" 934 bool "MPC8xx IDE support"
939 depends on 8xx 935 depends on 8xx && IDE=y && BLK_DEV_IDE=y
940 help 936 help
941 This option provides support for IDE on Motorola MPC8xx Systems. 937 This option provides support for IDE on Motorola MPC8xx Systems.
942 Please see 'Type of MPC8xx IDE interface' for details. 938 Please see 'Type of MPC8xx IDE interface' for details.
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index cca9c075966d..569fae717503 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -48,6 +48,6 @@ obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o
48obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o 48obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o
49obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o 49obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o
50 50
51obj-$(CONFIG_BLK_DEV_IDE) += legacy/ arm/ 51obj-$(CONFIG_BLK_DEV_IDE) += legacy/ arm/ mips/
52obj-$(CONFIG_BLK_DEV_HD) += legacy/ 52obj-$(CONFIG_BLK_DEV_HD) += legacy/
53obj-$(CONFIG_ETRAX_IDE) += cris/ 53obj-$(CONFIG_ETRAX_IDE) += cris/
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index c2f47923d174..b4d7a3efb90f 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1292,7 +1292,6 @@ static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
1292 struct cdrom_info *info = drive->driver_data; 1292 struct cdrom_info *info = drive->driver_data;
1293 1293
1294 info->dma = 0; 1294 info->dma = 0;
1295 info->cmd = 0;
1296 info->start_seek = jiffies; 1295 info->start_seek = jiffies;
1297 return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); 1296 return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
1298} 1297}
@@ -1344,8 +1343,6 @@ static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block)
1344 (rq->nr_sectors & (sectors_per_frame - 1))) 1343 (rq->nr_sectors & (sectors_per_frame - 1)))
1345 info->dma = 0; 1344 info->dma = 0;
1346 1345
1347 info->cmd = READ;
1348
1349 /* Start sending the read request to the drive. */ 1346 /* Start sending the read request to the drive. */
1350 return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation); 1347 return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation);
1351} 1348}
@@ -1484,7 +1481,6 @@ static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
1484 struct cdrom_info *info = drive->driver_data; 1481 struct cdrom_info *info = drive->driver_data;
1485 1482
1486 info->dma = 0; 1483 info->dma = 0;
1487 info->cmd = 0;
1488 rq->flags &= ~REQ_FAILED; 1484 rq->flags &= ~REQ_FAILED;
1489 len = rq->data_len; 1485 len = rq->data_len;
1490 1486
@@ -1891,7 +1887,6 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
1891 /* use dma, if possible. we don't need to check more, since we 1887 /* use dma, if possible. we don't need to check more, since we
1892 * know that the transfer is always (at least!) frame aligned */ 1888 * know that the transfer is always (at least!) frame aligned */
1893 info->dma = drive->using_dma ? 1 : 0; 1889 info->dma = drive->using_dma ? 1 : 0;
1894 info->cmd = WRITE;
1895 1890
1896 info->devinfo.media_written = 1; 1891 info->devinfo.media_written = 1;
1897 1892
@@ -1916,7 +1911,6 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1916 rq->flags |= REQ_QUIET; 1911 rq->flags |= REQ_QUIET;
1917 1912
1918 info->dma = 0; 1913 info->dma = 0;
1919 info->cmd = 0;
1920 1914
1921 /* 1915 /*
1922 * sg request 1916 * sg request
@@ -1925,7 +1919,6 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1925 int mask = drive->queue->dma_alignment; 1919 int mask = drive->queue->dma_alignment;
1926 unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); 1920 unsigned long addr = (unsigned long) page_address(bio_page(rq->bio));
1927 1921
1928 info->cmd = rq_data_dir(rq);
1929 info->dma = drive->using_dma; 1922 info->dma = drive->using_dma;
1930 1923
1931 /* 1924 /*
@@ -3328,8 +3321,8 @@ static ide_proc_entry_t idecd_proc[] = {
3328#endif 3321#endif
3329 3322
3330static ide_driver_t ide_cdrom_driver = { 3323static ide_driver_t ide_cdrom_driver = {
3331 .owner = THIS_MODULE,
3332 .gen_driver = { 3324 .gen_driver = {
3325 .owner = THIS_MODULE,
3333 .name = "ide-cdrom", 3326 .name = "ide-cdrom",
3334 .bus = &ide_bus_type, 3327 .bus = &ide_bus_type,
3335 .probe = ide_cd_probe, 3328 .probe = ide_cd_probe,
@@ -3510,8 +3503,8 @@ static void __exit ide_cdrom_exit(void)
3510{ 3503{
3511 driver_unregister(&ide_cdrom_driver.gen_driver); 3504 driver_unregister(&ide_cdrom_driver.gen_driver);
3512} 3505}
3513 3506
3514static int ide_cdrom_init(void) 3507static int __init ide_cdrom_init(void)
3515{ 3508{
3516 return driver_register(&ide_cdrom_driver.gen_driver); 3509 return driver_register(&ide_cdrom_driver.gen_driver);
3517} 3510}
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index 7ca3e5afc665..ad1f2ed14a37 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -480,7 +480,6 @@ struct cdrom_info {
480 480
481 struct request request_sense_request; 481 struct request request_sense_request;
482 int dma; 482 int dma;
483 int cmd;
484 unsigned long last_block; 483 unsigned long last_block;
485 unsigned long start_seek; 484 unsigned long start_seek;
486 /* Buffer to hold mechanism status and changer slot table. */ 485 /* Buffer to hold mechanism status and changer slot table. */
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index e827b39e4b3c..449522f0540c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1034,12 +1034,12 @@ static int ide_disk_remove(struct device *dev)
1034 struct ide_disk_obj *idkp = drive->driver_data; 1034 struct ide_disk_obj *idkp = drive->driver_data;
1035 struct gendisk *g = idkp->disk; 1035 struct gendisk *g = idkp->disk;
1036 1036
1037 ide_cacheflush_p(drive);
1038
1039 ide_unregister_subdriver(drive, idkp->driver); 1037 ide_unregister_subdriver(drive, idkp->driver);
1040 1038
1041 del_gendisk(g); 1039 del_gendisk(g);
1042 1040
1041 ide_cacheflush_p(drive);
1042
1043 ide_disk_put(idkp); 1043 ide_disk_put(idkp);
1044 1044
1045 return 0; 1045 return 0;
@@ -1089,8 +1089,8 @@ static void ide_device_shutdown(struct device *dev)
1089} 1089}
1090 1090
1091static ide_driver_t idedisk_driver = { 1091static ide_driver_t idedisk_driver = {
1092 .owner = THIS_MODULE,
1093 .gen_driver = { 1092 .gen_driver = {
1093 .owner = THIS_MODULE,
1094 .name = "ide-disk", 1094 .name = "ide-disk",
1095 .bus = &ide_bus_type, 1095 .bus = &ide_bus_type,
1096 .probe = ide_disk_probe, 1096 .probe = ide_disk_probe,
@@ -1266,7 +1266,7 @@ static void __exit idedisk_exit (void)
1266 driver_unregister(&idedisk_driver.gen_driver); 1266 driver_unregister(&idedisk_driver.gen_driver);
1267} 1267}
1268 1268
1269static int idedisk_init (void) 1269static int __init idedisk_init(void)
1270{ 1270{
1271 return driver_register(&idedisk_driver.gen_driver); 1271 return driver_register(&idedisk_driver.gen_driver);
1272} 1272}
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 1e1531334c25..0523da77425a 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -90,11 +90,6 @@
90#include <asm/io.h> 90#include <asm/io.h>
91#include <asm/irq.h> 91#include <asm/irq.h>
92 92
93struct drive_list_entry {
94 const char *id_model;
95 const char *id_firmware;
96};
97
98static const struct drive_list_entry drive_whitelist [] = { 93static const struct drive_list_entry drive_whitelist [] = {
99 94
100 { "Micropolis 2112A" , "ALL" }, 95 { "Micropolis 2112A" , "ALL" },
@@ -139,7 +134,7 @@ static const struct drive_list_entry drive_blacklist [] = {
139}; 134};
140 135
141/** 136/**
142 * in_drive_list - look for drive in black/white list 137 * ide_in_drive_list - look for drive in black/white list
143 * @id: drive identifier 138 * @id: drive identifier
144 * @drive_table: list to inspect 139 * @drive_table: list to inspect
145 * 140 *
@@ -147,7 +142,7 @@ static const struct drive_list_entry drive_blacklist [] = {
147 * Returns 1 if the drive is found in the table. 142 * Returns 1 if the drive is found in the table.
148 */ 143 */
149 144
150static int in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table) 145int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
151{ 146{
152 for ( ; drive_table->id_model ; drive_table++) 147 for ( ; drive_table->id_model ; drive_table++)
153 if ((!strcmp(drive_table->id_model, id->model)) && 148 if ((!strcmp(drive_table->id_model, id->model)) &&
@@ -157,6 +152,8 @@ static int in_drive_list(struct hd_driveid *id, const struct drive_list_entry *d
157 return 0; 152 return 0;
158} 153}
159 154
155EXPORT_SYMBOL_GPL(ide_in_drive_list);
156
160/** 157/**
161 * ide_dma_intr - IDE DMA interrupt handler 158 * ide_dma_intr - IDE DMA interrupt handler
162 * @drive: the drive the interrupt is for 159 * @drive: the drive the interrupt is for
@@ -663,7 +660,7 @@ int __ide_dma_bad_drive (ide_drive_t *drive)
663{ 660{
664 struct hd_driveid *id = drive->id; 661 struct hd_driveid *id = drive->id;
665 662
666 int blacklist = in_drive_list(id, drive_blacklist); 663 int blacklist = ide_in_drive_list(id, drive_blacklist);
667 if (blacklist) { 664 if (blacklist) {
668 printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n", 665 printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n",
669 drive->name, id->model); 666 drive->name, id->model);
@@ -677,7 +674,7 @@ EXPORT_SYMBOL(__ide_dma_bad_drive);
677int __ide_dma_good_drive (ide_drive_t *drive) 674int __ide_dma_good_drive (ide_drive_t *drive)
678{ 675{
679 struct hd_driveid *id = drive->id; 676 struct hd_driveid *id = drive->id;
680 return in_drive_list(id, drive_whitelist); 677 return ide_in_drive_list(id, drive_whitelist);
681} 678}
682 679
683EXPORT_SYMBOL(__ide_dma_good_drive); 680EXPORT_SYMBOL(__ide_dma_good_drive);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index f615ab759962..9e293c8063dc 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1925,8 +1925,8 @@ static ide_proc_entry_t idefloppy_proc[] = {
1925static int ide_floppy_probe(struct device *); 1925static int ide_floppy_probe(struct device *);
1926 1926
1927static ide_driver_t idefloppy_driver = { 1927static ide_driver_t idefloppy_driver = {
1928 .owner = THIS_MODULE,
1929 .gen_driver = { 1928 .gen_driver = {
1929 .owner = THIS_MODULE,
1930 .name = "ide-floppy", 1930 .name = "ide-floppy",
1931 .bus = &ide_bus_type, 1931 .bus = &ide_bus_type,
1932 .probe = ide_floppy_probe, 1932 .probe = ide_floppy_probe,
@@ -2191,10 +2191,7 @@ static void __exit idefloppy_exit (void)
2191 driver_unregister(&idefloppy_driver.gen_driver); 2191 driver_unregister(&idefloppy_driver.gen_driver);
2192} 2192}
2193 2193
2194/* 2194static int __init idefloppy_init(void)
2195 * idefloppy_init will register the driver for each floppy.
2196 */
2197static int idefloppy_init (void)
2198{ 2195{
2199 printk("ide-floppy driver " IDEFLOPPY_VERSION "\n"); 2196 printk("ide-floppy driver " IDEFLOPPY_VERSION "\n");
2200 return driver_register(&idefloppy_driver.gen_driver); 2197 return driver_register(&idefloppy_driver.gen_driver);
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 5275cbb1afe9..ecfafcdafea4 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -1629,12 +1629,6 @@ EXPORT_SYMBOL(ide_init_drive_cmd);
1629 * for the new rq to be completed. This is VERY DANGEROUS, and is 1629 * for the new rq to be completed. This is VERY DANGEROUS, and is
1630 * intended for careful use by the ATAPI tape/cdrom driver code. 1630 * intended for careful use by the ATAPI tape/cdrom driver code.
1631 * 1631 *
1632 * If action is ide_next, then the rq is queued immediately after
1633 * the currently-being-processed-request (if any), and the function
1634 * returns without waiting for the new rq to be completed. As above,
1635 * This is VERY DANGEROUS, and is intended for careful use by the
1636 * ATAPI tape/cdrom driver code.
1637 *
1638 * If action is ide_end, then the rq is queued at the end of the 1632 * If action is ide_end, then the rq is queued at the end of the
1639 * request queue, and the function returns immediately without waiting 1633 * request queue, and the function returns immediately without waiting
1640 * for the new rq to be completed. This is again intended for careful 1634 * for the new rq to be completed. This is again intended for careful
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index b09a6537c7a8..41d46dbe6c24 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -410,10 +410,10 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
410{ 410{
411 u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */ 411 u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */
412 412
413 if (on && drive->media == ide_disk) { 413 if (!PCI_DMA_BUS_IS_PHYS) {
414 if (!PCI_DMA_BUS_IS_PHYS) 414 addr = BLK_BOUNCE_ANY;
415 addr = BLK_BOUNCE_ANY; 415 } else if (on && drive->media == ide_disk) {
416 else if (HWIF(drive)->pci_dev) 416 if (HWIF(drive)->pci_dev)
417 addr = HWIF(drive)->pci_dev->dma_mask; 417 addr = HWIF(drive)->pci_dev->dma_mask;
418 } 418 }
419 419
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0ac7eb8f40d5..7d7944ed4158 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4748,8 +4748,8 @@ static ide_proc_entry_t idetape_proc[] = {
4748static int ide_tape_probe(struct device *); 4748static int ide_tape_probe(struct device *);
4749 4749
4750static ide_driver_t idetape_driver = { 4750static ide_driver_t idetape_driver = {
4751 .owner = THIS_MODULE,
4752 .gen_driver = { 4751 .gen_driver = {
4752 .owner = THIS_MODULE,
4753 .name = "ide-tape", 4753 .name = "ide-tape",
4754 .bus = &ide_bus_type, 4754 .bus = &ide_bus_type,
4755 .probe = ide_tape_probe, 4755 .probe = ide_tape_probe,
@@ -4916,10 +4916,7 @@ static void __exit idetape_exit (void)
4916 unregister_chrdev(IDETAPE_MAJOR, "ht"); 4916 unregister_chrdev(IDETAPE_MAJOR, "ht");
4917} 4917}
4918 4918
4919/* 4919static int __init idetape_init(void)
4920 * idetape_init will register the driver for each tape.
4921 */
4922static int idetape_init (void)
4923{ 4920{
4924 int error = 1; 4921 int error = 1;
4925 idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape"); 4922 idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape");
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 54f9639c2a8c..62ebefd6394a 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -51,8 +51,6 @@
51#include <asm/uaccess.h> 51#include <asm/uaccess.h>
52#include <asm/io.h> 52#include <asm/io.h>
53 53
54#define DEBUG_TASKFILE 0 /* unset when fixed */
55
56static void ata_bswap_data (void *buffer, int wcount) 54static void ata_bswap_data (void *buffer, int wcount)
57{ 55{
58 u16 *p = buffer; 56 u16 *p = buffer;
@@ -765,9 +763,6 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
765 ide_hwif_t *hwif = HWIF(drive); 763 ide_hwif_t *hwif = HWIF(drive);
766 task_struct_t *taskfile = (task_struct_t *) task->tfRegister; 764 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
767 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister; 765 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
768#if DEBUG_TASKFILE
769 u8 status;
770#endif
771 766
772 if (task->data_phase == TASKFILE_MULTI_IN || 767 if (task->data_phase == TASKFILE_MULTI_IN ||
773 task->data_phase == TASKFILE_MULTI_OUT) { 768 task->data_phase == TASKFILE_MULTI_OUT) {
@@ -778,19 +773,13 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
778 } 773 }
779 774
780 /* 775 /*
781 * (ks) Check taskfile in/out flags. 776 * (ks) Check taskfile in flags.
782 * If set, then execute as it is defined. 777 * If set, then execute as it is defined.
783 * If not set, then define default settings. 778 * If not set, then define default settings.
784 * The default values are: 779 * The default values are:
785 * write and read all taskfile registers (except data) 780 * read all taskfile registers (except data)
786 * write and read the hob registers (sector,nsector,lcyl,hcyl) 781 * read the hob registers (sector, nsector, lcyl, hcyl)
787 */ 782 */
788 if (task->tf_out_flags.all == 0) {
789 task->tf_out_flags.all = IDE_TASKFILE_STD_OUT_FLAGS;
790 if (drive->addressing == 1)
791 task->tf_out_flags.all |= (IDE_HOB_STD_OUT_FLAGS << 8);
792 }
793
794 if (task->tf_in_flags.all == 0) { 783 if (task->tf_in_flags.all == 0) {
795 task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS; 784 task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS;
796 if (drive->addressing == 1) 785 if (drive->addressing == 1)
@@ -803,16 +792,6 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
803 hwif->OUTB(drive->ctl, IDE_CONTROL_REG); 792 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
804 SELECT_MASK(drive, 0); 793 SELECT_MASK(drive, 0);
805 794
806#if DEBUG_TASKFILE
807 status = hwif->INB(IDE_STATUS_REG);
808 if (status & 0x80) {
809 printk("flagged_taskfile -> Bad status. Status = %02x. wait 100 usec ...\n", status);
810 udelay(100);
811 status = hwif->INB(IDE_STATUS_REG);
812 printk("flagged_taskfile -> Status = %02x\n", status);
813 }
814#endif
815
816 if (task->tf_out_flags.b.data) { 795 if (task->tf_out_flags.b.data) {
817 u16 data = taskfile->data + (hobfile->data << 8); 796 u16 data = taskfile->data + (hobfile->data << 8);
818 hwif->OUTW(data, IDE_DATA_REG); 797 hwif->OUTW(data, IDE_DATA_REG);
diff --git a/drivers/ide/mips/Makefile b/drivers/ide/mips/Makefile
new file mode 100644
index 000000000000..677c7b2bac92
--- /dev/null
+++ b/drivers/ide/mips/Makefile
@@ -0,0 +1,4 @@
1obj-$(CONFIG_BLK_DEV_IDE_SWARM) += swarm.o
2obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o
3
4EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index 2b6327c576b9..32431dcf5d8e 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -31,865 +31,638 @@
31 */ 31 */
32#undef REALLY_SLOW_IO /* most systems can safely undef this */ 32#undef REALLY_SLOW_IO /* most systems can safely undef this */
33 33
34#include <linux/config.h> /* for CONFIG_BLK_DEV_IDEPCI */
35#include <linux/types.h> 34#include <linux/types.h>
36#include <linux/module.h> 35#include <linux/module.h>
37#include <linux/kernel.h> 36#include <linux/kernel.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/timer.h> 38#include <linux/platform_device.h>
40#include <linux/mm.h> 39
41#include <linux/ioport.h>
42#include <linux/hdreg.h>
43#include <linux/init.h> 40#include <linux/init.h>
44#include <linux/ide.h> 41#include <linux/ide.h>
45#include <linux/sysdev.h> 42#include <linux/sysdev.h>
46 43
47#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
48 45
46#include "ide-timing.h"
47
49#include <asm/io.h> 48#include <asm/io.h>
50#include <asm/mach-au1x00/au1xxx.h> 49#include <asm/mach-au1x00/au1xxx.h>
51#include <asm/mach-au1x00/au1xxx_dbdma.h> 50#include <asm/mach-au1x00/au1xxx_dbdma.h>
52 51
53#if CONFIG_PM
54#include <asm/mach-au1x00/au1xxx_pm.h>
55#endif
56
57#include <asm/mach-au1x00/au1xxx_ide.h> 52#include <asm/mach-au1x00/au1xxx_ide.h>
58 53
59#define DRV_NAME "au1200-ide" 54#define DRV_NAME "au1200-ide"
60#define DRV_VERSION "1.0" 55#define DRV_VERSION "1.0"
61#define DRV_AUTHOR "AMD PCS / Pete Popov <ppopov@embeddedalley.com>" 56#define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>"
62#define DRV_DESC "Au1200 IDE"
63
64static _auide_hwif auide_hwif;
65static spinlock_t ide_tune_drive_spin_lock = SPIN_LOCK_UNLOCKED;
66static spinlock_t ide_tune_chipset_spin_lock = SPIN_LOCK_UNLOCKED;
67static int dbdma_init_done = 0;
68
69/*
70 * local I/O functions
71 */
72u8 auide_inb(unsigned long port)
73{
74 return (au_readb(port));
75}
76 57
77u16 auide_inw(unsigned long port) 58/* enable the burstmode in the dbdma */
78{ 59#define IDE_AU1XXX_BURSTMODE 1
79 return (au_readw(port));
80}
81 60
82u32 auide_inl(unsigned long port) 61static _auide_hwif auide_hwif;
83{ 62static int dbdma_init_done;
84 return (au_readl(port));
85}
86 63
87void auide_insw(unsigned long port, void *addr, u32 count)
88{
89#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA) 64#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
90 65
91 _auide_hwif *ahwif = &auide_hwif; 66void auide_insw(unsigned long port, void *addr, u32 count)
92 chan_tab_t *ctp;
93 au1x_ddma_desc_t *dp;
94
95 if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1,
96 DDMA_FLAGS_NOIE)) {
97 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
98 return;
99 }
100 ctp = *((chan_tab_t **)ahwif->rx_chan);
101 dp = ctp->cur_ptr;
102 while (dp->dscr_cmd0 & DSCR_CMD0_V)
103 ;
104 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
105#else
106 while (count--)
107 {
108 *(u16 *)addr = au_readw(port);
109 addr +=2 ;
110 }
111#endif
112}
113
114void auide_insl(unsigned long port, void *addr, u32 count)
115{
116 while (count--)
117 {
118 *(u32 *)addr = au_readl(port);
119 /* NOTE: For IDE interfaces over PCMCIA,
120 * 32-bit access does not work
121 */
122 addr += 4;
123 }
124}
125
126void auide_outb(u8 addr, unsigned long port)
127{ 67{
128 return (au_writeb(addr, port)); 68 _auide_hwif *ahwif = &auide_hwif;
129} 69 chan_tab_t *ctp;
70 au1x_ddma_desc_t *dp;
130 71
131void auide_outbsync(ide_drive_t *drive, u8 addr, unsigned long port) 72 if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1,
132{ 73 DDMA_FLAGS_NOIE)) {
133 return (au_writeb(addr, port)); 74 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
75 return;
76 }
77 ctp = *((chan_tab_t **)ahwif->rx_chan);
78 dp = ctp->cur_ptr;
79 while (dp->dscr_cmd0 & DSCR_CMD0_V)
80 ;
81 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
134} 82}
135 83
136void auide_outw(u16 addr, unsigned long port) 84void auide_outsw(unsigned long port, void *addr, u32 count)
137{ 85{
138 return (au_writew(addr, port)); 86 _auide_hwif *ahwif = &auide_hwif;
139} 87 chan_tab_t *ctp;
88 au1x_ddma_desc_t *dp;
140 89
141void auide_outl(u32 addr, unsigned long port) 90 if(!put_source_flags(ahwif->tx_chan, (void*)addr,
142{ 91 count << 1, DDMA_FLAGS_NOIE)) {
143 return (au_writel(addr, port)); 92 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
93 return;
94 }
95 ctp = *((chan_tab_t **)ahwif->tx_chan);
96 dp = ctp->cur_ptr;
97 while (dp->dscr_cmd0 & DSCR_CMD0_V)
98 ;
99 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
144} 100}
145 101
146void auide_outsw(unsigned long port, void *addr, u32 count)
147{
148#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
149 _auide_hwif *ahwif = &auide_hwif;
150 chan_tab_t *ctp;
151 au1x_ddma_desc_t *dp;
152
153 if(!put_source_flags(ahwif->tx_chan, (void*)addr,
154 count << 1, DDMA_FLAGS_NOIE)) {
155 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
156 return;
157 }
158 ctp = *((chan_tab_t **)ahwif->tx_chan);
159 dp = ctp->cur_ptr;
160 while (dp->dscr_cmd0 & DSCR_CMD0_V)
161 ;
162 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
163#else
164 while (count--)
165 {
166 au_writew(*(u16 *)addr, port);
167 addr += 2;
168 }
169#endif 102#endif
170}
171
172void auide_outsl(unsigned long port, void *addr, u32 count)
173{
174 while (count--)
175 {
176 au_writel(*(u32 *)addr, port);
177 /* NOTE: For IDE interfaces over PCMCIA,
178 * 32-bit access does not work
179 */
180 addr += 4;
181 }
182}
183 103
184static void auide_tune_drive(ide_drive_t *drive, byte pio) 104static void auide_tune_drive(ide_drive_t *drive, byte pio)
185{ 105{
186 int mem_sttime; 106 int mem_sttime;
187 int mem_stcfg; 107 int mem_stcfg;
188 unsigned long flags; 108 u8 speed;
189 u8 speed; 109
190 110 /* get the best pio mode for the drive */
191 /* get the best pio mode for the drive */ 111 pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
192 pio = ide_get_best_pio_mode(drive, pio, 4, NULL); 112
193 113 printk(KERN_INFO "%s: setting Au1XXX IDE to PIO mode%d\n",
194 printk("%s: setting Au1XXX IDE to PIO mode%d\n", 114 drive->name, pio);
195 drive->name, pio); 115
196 116 mem_sttime = 0;
197 spin_lock_irqsave(&ide_tune_drive_spin_lock, flags); 117 mem_stcfg = au_readl(MEM_STCFG2);
198 118
199 mem_sttime = 0; 119 /* set pio mode! */
200 mem_stcfg = au_readl(MEM_STCFG2); 120 switch(pio) {
201 121 case 0:
202 /* set pio mode! */ 122 mem_sttime = SBC_IDE_TIMING(PIO0);
203 switch(pio) { 123
204 case 0: 124 /* set configuration for RCS2# */
205 /* set timing parameters for RCS2# */ 125 mem_stcfg |= TS_MASK;
206 mem_sttime = SBC_IDE_PIO0_TWCS 126 mem_stcfg &= ~TCSOE_MASK;
207 | SBC_IDE_PIO0_TCSH 127 mem_stcfg &= ~TOECS_MASK;
208 | SBC_IDE_PIO0_TCSOFF 128 mem_stcfg |= SBC_IDE_PIO0_TCSOE | SBC_IDE_PIO0_TOECS;
209 | SBC_IDE_PIO0_TWP 129 break;
210 | SBC_IDE_PIO0_TCSW 130
211 | SBC_IDE_PIO0_TPM 131 case 1:
212 | SBC_IDE_PIO0_TA; 132 mem_sttime = SBC_IDE_TIMING(PIO1);
213 /* set configuration for RCS2# */ 133
214 mem_stcfg |= TS_MASK; 134 /* set configuration for RCS2# */
215 mem_stcfg &= ~TCSOE_MASK; 135 mem_stcfg |= TS_MASK;
216 mem_stcfg &= ~TOECS_MASK; 136 mem_stcfg &= ~TCSOE_MASK;
217 mem_stcfg |= SBC_IDE_PIO0_TCSOE | SBC_IDE_PIO0_TOECS; 137 mem_stcfg &= ~TOECS_MASK;
218 138 mem_stcfg |= SBC_IDE_PIO1_TCSOE | SBC_IDE_PIO1_TOECS;
219 au_writel(mem_sttime,MEM_STTIME2); 139 break;
220 au_writel(mem_stcfg,MEM_STCFG2); 140
221 break; 141 case 2:
222 142 mem_sttime = SBC_IDE_TIMING(PIO2);
223 case 1: 143
224 /* set timing parameters for RCS2# */ 144 /* set configuration for RCS2# */
225 mem_sttime = SBC_IDE_PIO1_TWCS 145 mem_stcfg &= ~TS_MASK;
226 | SBC_IDE_PIO1_TCSH 146 mem_stcfg &= ~TCSOE_MASK;
227 | SBC_IDE_PIO1_TCSOFF 147 mem_stcfg &= ~TOECS_MASK;
228 | SBC_IDE_PIO1_TWP 148 mem_stcfg |= SBC_IDE_PIO2_TCSOE | SBC_IDE_PIO2_TOECS;
229 | SBC_IDE_PIO1_TCSW 149 break;
230 | SBC_IDE_PIO1_TPM 150
231 | SBC_IDE_PIO1_TA; 151 case 3:
232 /* set configuration for RCS2# */ 152 mem_sttime = SBC_IDE_TIMING(PIO3);
233 mem_stcfg |= TS_MASK; 153
234 mem_stcfg &= ~TCSOE_MASK; 154 /* set configuration for RCS2# */
235 mem_stcfg &= ~TOECS_MASK; 155 mem_stcfg &= ~TS_MASK;
236 mem_stcfg |= SBC_IDE_PIO1_TCSOE | SBC_IDE_PIO1_TOECS; 156 mem_stcfg &= ~TCSOE_MASK;
237 break; 157 mem_stcfg &= ~TOECS_MASK;
238 158 mem_stcfg |= SBC_IDE_PIO3_TCSOE | SBC_IDE_PIO3_TOECS;
239 case 2: 159
240 /* set timing parameters for RCS2# */ 160 break;
241 mem_sttime = SBC_IDE_PIO2_TWCS 161
242 | SBC_IDE_PIO2_TCSH 162 case 4:
243 | SBC_IDE_PIO2_TCSOFF 163 mem_sttime = SBC_IDE_TIMING(PIO4);
244 | SBC_IDE_PIO2_TWP 164
245 | SBC_IDE_PIO2_TCSW 165 /* set configuration for RCS2# */
246 | SBC_IDE_PIO2_TPM 166 mem_stcfg &= ~TS_MASK;
247 | SBC_IDE_PIO2_TA; 167 mem_stcfg &= ~TCSOE_MASK;
248 /* set configuration for RCS2# */ 168 mem_stcfg &= ~TOECS_MASK;
249 mem_stcfg &= ~TS_MASK; 169 mem_stcfg |= SBC_IDE_PIO4_TCSOE | SBC_IDE_PIO4_TOECS;
250 mem_stcfg &= ~TCSOE_MASK; 170 break;
251 mem_stcfg &= ~TOECS_MASK; 171 }
252 mem_stcfg |= SBC_IDE_PIO2_TCSOE | SBC_IDE_PIO2_TOECS; 172
253 break; 173 au_writel(mem_sttime,MEM_STTIME2);
254 174 au_writel(mem_stcfg,MEM_STCFG2);
255 case 3: 175
256 /* set timing parameters for RCS2# */ 176 speed = pio + XFER_PIO_0;
257 mem_sttime = SBC_IDE_PIO3_TWCS 177 ide_config_drive_speed(drive, speed);
258 | SBC_IDE_PIO3_TCSH
259 | SBC_IDE_PIO3_TCSOFF
260 | SBC_IDE_PIO3_TWP
261 | SBC_IDE_PIO3_TCSW
262 | SBC_IDE_PIO3_TPM
263 | SBC_IDE_PIO3_TA;
264 /* set configuration for RCS2# */
265 mem_stcfg |= TS_MASK;
266 mem_stcfg &= ~TS_MASK;
267 mem_stcfg &= ~TCSOE_MASK;
268 mem_stcfg &= ~TOECS_MASK;
269 mem_stcfg |= SBC_IDE_PIO3_TCSOE | SBC_IDE_PIO3_TOECS;
270
271 break;
272
273 case 4:
274 /* set timing parameters for RCS2# */
275 mem_sttime = SBC_IDE_PIO4_TWCS
276 | SBC_IDE_PIO4_TCSH
277 | SBC_IDE_PIO4_TCSOFF
278 | SBC_IDE_PIO4_TWP
279 | SBC_IDE_PIO4_TCSW
280 | SBC_IDE_PIO4_TPM
281 | SBC_IDE_PIO4_TA;
282 /* set configuration for RCS2# */
283 mem_stcfg &= ~TS_MASK;
284 mem_stcfg &= ~TCSOE_MASK;
285 mem_stcfg &= ~TOECS_MASK;
286 mem_stcfg |= SBC_IDE_PIO4_TCSOE | SBC_IDE_PIO4_TOECS;
287 break;
288 }
289
290 au_writel(mem_sttime,MEM_STTIME2);
291 au_writel(mem_stcfg,MEM_STCFG2);
292
293 spin_unlock_irqrestore(&ide_tune_drive_spin_lock, flags);
294
295 speed = pio + XFER_PIO_0;
296 ide_config_drive_speed(drive, speed);
297} 178}
298 179
299static int auide_tune_chipset (ide_drive_t *drive, u8 speed) 180static int auide_tune_chipset (ide_drive_t *drive, u8 speed)
300{ 181{
301 u8 mode = 0; 182 int mem_sttime;
302 int mem_sttime; 183 int mem_stcfg;
303 int mem_stcfg; 184 unsigned long mode;
304 unsigned long flags; 185
305#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 186#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
306 struct hd_driveid *id = drive->id; 187 if (ide_use_dma(drive))
307 188 mode = ide_dma_speed(drive, 0);
308 /*
309 * Now see what the current drive is capable of,
310 * selecting UDMA only if the mate said it was ok.
311 */
312 if (id && (id->capability & 1) && drive->autodma &&
313 !__ide_dma_bad_drive(drive)) {
314 if (!mode && (id->field_valid & 2) && (id->dma_mword & 7)) {
315 if (id->dma_mword & 4)
316 mode = XFER_MW_DMA_2;
317 else if (id->dma_mword & 2)
318 mode = XFER_MW_DMA_1;
319 else if (id->dma_mword & 1)
320 mode = XFER_MW_DMA_0;
321 }
322 }
323#endif 189#endif
324 190
325 spin_lock_irqsave(&ide_tune_chipset_spin_lock, flags); 191 mem_sttime = 0;
192 mem_stcfg = au_readl(MEM_STCFG2);
326 193
327 mem_sttime = 0; 194 if (speed >= XFER_PIO_0 && speed <= XFER_PIO_4) {
328 mem_stcfg = au_readl(MEM_STCFG2); 195 auide_tune_drive(drive, speed - XFER_PIO_0);
329 196 return 0;
330 switch(speed) { 197 }
331 case XFER_PIO_4: 198
332 case XFER_PIO_3: 199 switch(speed) {
333 case XFER_PIO_2:
334 case XFER_PIO_1:
335 case XFER_PIO_0:
336 auide_tune_drive(drive, (speed - XFER_PIO_0));
337 break;
338#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 200#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
339 case XFER_MW_DMA_2: 201 case XFER_MW_DMA_2:
340 /* set timing parameters for RCS2# */ 202 mem_sttime = SBC_IDE_TIMING(MDMA2);
341 mem_sttime = SBC_IDE_MDMA2_TWCS 203
342 | SBC_IDE_MDMA2_TCSH 204 /* set configuration for RCS2# */
343 | SBC_IDE_MDMA2_TCSOFF 205 mem_stcfg &= ~TS_MASK;
344 | SBC_IDE_MDMA2_TWP 206 mem_stcfg &= ~TCSOE_MASK;
345 | SBC_IDE_MDMA2_TCSW 207 mem_stcfg &= ~TOECS_MASK;
346 | SBC_IDE_MDMA2_TPM 208 mem_stcfg |= SBC_IDE_MDMA2_TCSOE | SBC_IDE_MDMA2_TOECS;
347 | SBC_IDE_MDMA2_TA; 209
348 /* set configuration for RCS2# */ 210 mode = XFER_MW_DMA_2;
349 mem_stcfg &= ~TS_MASK; 211 break;
350 mem_stcfg &= ~TCSOE_MASK; 212 case XFER_MW_DMA_1:
351 mem_stcfg &= ~TOECS_MASK; 213 mem_sttime = SBC_IDE_TIMING(MDMA1);
352 mem_stcfg |= SBC_IDE_MDMA2_TCSOE | SBC_IDE_MDMA2_TOECS; 214
353 215 /* set configuration for RCS2# */
354 mode = XFER_MW_DMA_2; 216 mem_stcfg &= ~TS_MASK;
355 break; 217 mem_stcfg &= ~TCSOE_MASK;
356 case XFER_MW_DMA_1: 218 mem_stcfg &= ~TOECS_MASK;
357 /* set timing parameters for RCS2# */ 219 mem_stcfg |= SBC_IDE_MDMA1_TCSOE | SBC_IDE_MDMA1_TOECS;
358 mem_sttime = SBC_IDE_MDMA1_TWCS 220
359 | SBC_IDE_MDMA1_TCSH 221 mode = XFER_MW_DMA_1;
360 | SBC_IDE_MDMA1_TCSOFF 222 break;
361 | SBC_IDE_MDMA1_TWP 223 case XFER_MW_DMA_0:
362 | SBC_IDE_MDMA1_TCSW 224 mem_sttime = SBC_IDE_TIMING(MDMA0);
363 | SBC_IDE_MDMA1_TPM 225
364 | SBC_IDE_MDMA1_TA; 226 /* set configuration for RCS2# */
365 /* set configuration for RCS2# */ 227 mem_stcfg |= TS_MASK;
366 mem_stcfg &= ~TS_MASK; 228 mem_stcfg &= ~TCSOE_MASK;
367 mem_stcfg &= ~TCSOE_MASK; 229 mem_stcfg &= ~TOECS_MASK;
368 mem_stcfg &= ~TOECS_MASK; 230 mem_stcfg |= SBC_IDE_MDMA0_TCSOE | SBC_IDE_MDMA0_TOECS;
369 mem_stcfg |= SBC_IDE_MDMA1_TCSOE | SBC_IDE_MDMA1_TOECS; 231
370 232 mode = XFER_MW_DMA_0;
371 mode = XFER_MW_DMA_1; 233 break;
372 break;
373 case XFER_MW_DMA_0:
374 /* set timing parameters for RCS2# */
375 mem_sttime = SBC_IDE_MDMA0_TWCS
376 | SBC_IDE_MDMA0_TCSH
377 | SBC_IDE_MDMA0_TCSOFF
378 | SBC_IDE_MDMA0_TWP
379 | SBC_IDE_MDMA0_TCSW
380 | SBC_IDE_MDMA0_TPM
381 | SBC_IDE_MDMA0_TA;
382 /* set configuration for RCS2# */
383 mem_stcfg |= TS_MASK;
384 mem_stcfg &= ~TCSOE_MASK;
385 mem_stcfg &= ~TOECS_MASK;
386 mem_stcfg |= SBC_IDE_MDMA0_TCSOE | SBC_IDE_MDMA0_TOECS;
387
388 mode = XFER_MW_DMA_0;
389 break;
390#endif 234#endif
391 default: 235 default:
392 return 1; 236 return 1;
393 } 237 }
394 238
395 /* 239 if (ide_config_drive_speed(drive, mode))
396 * Tell the drive to switch to the new mode; abort on failure. 240 return 1;
397 */
398 if (!mode || ide_config_drive_speed(drive, mode))
399 {
400 return 1; /* failure */
401 }
402
403
404 au_writel(mem_sttime,MEM_STTIME2);
405 au_writel(mem_stcfg,MEM_STCFG2);
406 241
407 spin_unlock_irqrestore(&ide_tune_chipset_spin_lock, flags); 242 au_writel(mem_sttime,MEM_STTIME2);
243 au_writel(mem_stcfg,MEM_STCFG2);
408 244
409 return 0; 245 return 0;
410} 246}
411 247
412/* 248/*
413 * Multi-Word DMA + DbDMA functions 249 * Multi-Word DMA + DbDMA functions
414 */ 250 */
415#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
416 251
417static int in_drive_list(struct hd_driveid *id, 252#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
418 const struct drive_list_entry *drive_table)
419{
420 for ( ; drive_table->id_model ; drive_table++){
421 if ((!strcmp(drive_table->id_model, id->model)) &&
422 ((strstr(drive_table->id_firmware, id->fw_rev)) ||
423 (!strcmp(drive_table->id_firmware, "ALL")))
424 )
425 return 1;
426 }
427 return 0;
428}
429 253
430static int auide_build_sglist(ide_drive_t *drive, struct request *rq) 254static int auide_build_sglist(ide_drive_t *drive, struct request *rq)
431{ 255{
432 ide_hwif_t *hwif = drive->hwif; 256 ide_hwif_t *hwif = drive->hwif;
433 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 257 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
434 struct scatterlist *sg = hwif->sg_table; 258 struct scatterlist *sg = hwif->sg_table;
435 259
436 ide_map_sg(drive, rq); 260 ide_map_sg(drive, rq);
437 261
438 if (rq_data_dir(rq) == READ) 262 if (rq_data_dir(rq) == READ)
439 hwif->sg_dma_direction = DMA_FROM_DEVICE; 263 hwif->sg_dma_direction = DMA_FROM_DEVICE;
440 else 264 else
441 hwif->sg_dma_direction = DMA_TO_DEVICE; 265 hwif->sg_dma_direction = DMA_TO_DEVICE;
442 266
443 return dma_map_sg(ahwif->dev, sg, hwif->sg_nents, 267 return dma_map_sg(ahwif->dev, sg, hwif->sg_nents,
444 hwif->sg_dma_direction); 268 hwif->sg_dma_direction);
445} 269}
446 270
447static int auide_build_dmatable(ide_drive_t *drive) 271static int auide_build_dmatable(ide_drive_t *drive)
448{ 272{
449 int i, iswrite, count = 0; 273 int i, iswrite, count = 0;
450 ide_hwif_t *hwif = HWIF(drive); 274 ide_hwif_t *hwif = HWIF(drive);
451 275
452 struct request *rq = HWGROUP(drive)->rq; 276 struct request *rq = HWGROUP(drive)->rq;
453 277
454 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 278 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
455 struct scatterlist *sg; 279 struct scatterlist *sg;
456 280
457 iswrite = (rq_data_dir(rq) == WRITE); 281 iswrite = (rq_data_dir(rq) == WRITE);
458 /* Save for interrupt context */ 282 /* Save for interrupt context */
459 ahwif->drive = drive; 283 ahwif->drive = drive;
460 284
461 /* Build sglist */ 285 /* Build sglist */
462 hwif->sg_nents = i = auide_build_sglist(drive, rq); 286 hwif->sg_nents = i = auide_build_sglist(drive, rq);
463 287
464 if (!i) 288 if (!i)
465 return 0; 289 return 0;
466 290
467 /* fill the descriptors */ 291 /* fill the descriptors */
468 sg = hwif->sg_table; 292 sg = hwif->sg_table;
469 while (i && sg_dma_len(sg)) { 293 while (i && sg_dma_len(sg)) {
470 u32 cur_addr; 294 u32 cur_addr;
471 u32 cur_len; 295 u32 cur_len;
472 296
473 cur_addr = sg_dma_address(sg); 297 cur_addr = sg_dma_address(sg);
474 cur_len = sg_dma_len(sg); 298 cur_len = sg_dma_len(sg);
475 299
476 while (cur_len) { 300 while (cur_len) {
477 u32 flags = DDMA_FLAGS_NOIE; 301 u32 flags = DDMA_FLAGS_NOIE;
478 unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00; 302 unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
479 303
480 if (++count >= PRD_ENTRIES) { 304 if (++count >= PRD_ENTRIES) {
481 printk(KERN_WARNING "%s: DMA table too small\n", 305 printk(KERN_WARNING "%s: DMA table too small\n",
482 drive->name); 306 drive->name);
483 goto use_pio_instead; 307 goto use_pio_instead;
484 } 308 }
485 309
486 /* Lets enable intr for the last descriptor only */ 310 /* Lets enable intr for the last descriptor only */
487 if (1==i) 311 if (1==i)
488 flags = DDMA_FLAGS_IE; 312 flags = DDMA_FLAGS_IE;
489 else 313 else
490 flags = DDMA_FLAGS_NOIE; 314 flags = DDMA_FLAGS_NOIE;
491 315
492 if (iswrite) { 316 if (iswrite) {
493 if(!put_source_flags(ahwif->tx_chan, 317 if(!put_source_flags(ahwif->tx_chan,
494 (void*)(page_address(sg->page) 318 (void*)(page_address(sg->page)
495 + sg->offset), 319 + sg->offset),
496 tc, flags)) { 320 tc, flags)) {
497 printk(KERN_ERR "%s failed %d\n", 321 printk(KERN_ERR "%s failed %d\n",
498 __FUNCTION__, __LINE__); 322 __FUNCTION__, __LINE__);
499 } 323 }
500 } else 324 } else
501 { 325 {
502 if(!put_dest_flags(ahwif->rx_chan, 326 if(!put_dest_flags(ahwif->rx_chan,
503 (void*)(page_address(sg->page) 327 (void*)(page_address(sg->page)
504 + sg->offset), 328 + sg->offset),
505 tc, flags)) { 329 tc, flags)) {
506 printk(KERN_ERR "%s failed %d\n", 330 printk(KERN_ERR "%s failed %d\n",
507 __FUNCTION__, __LINE__); 331 __FUNCTION__, __LINE__);
508 } 332 }
509 } 333 }
510 334
511 cur_addr += tc; 335 cur_addr += tc;
512 cur_len -= tc; 336 cur_len -= tc;
513 } 337 }
514 sg++; 338 sg++;
515 i--; 339 i--;
516 } 340 }
517 341
518 if (count) 342 if (count)
519 return 1; 343 return 1;
520 344
521use_pio_instead: 345 use_pio_instead:
522 dma_unmap_sg(ahwif->dev, 346 dma_unmap_sg(ahwif->dev,
523 hwif->sg_table, 347 hwif->sg_table,
524 hwif->sg_nents, 348 hwif->sg_nents,
525 hwif->sg_dma_direction); 349 hwif->sg_dma_direction);
526 350
527 return 0; /* revert to PIO for this request */ 351 return 0; /* revert to PIO for this request */
528} 352}
529 353
530static int auide_dma_end(ide_drive_t *drive) 354static int auide_dma_end(ide_drive_t *drive)
531{ 355{
532 ide_hwif_t *hwif = HWIF(drive); 356 ide_hwif_t *hwif = HWIF(drive);
533 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 357 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
534 358
535 if (hwif->sg_nents) { 359 if (hwif->sg_nents) {
536 dma_unmap_sg(ahwif->dev, hwif->sg_table, hwif->sg_nents, 360 dma_unmap_sg(ahwif->dev, hwif->sg_table, hwif->sg_nents,
537 hwif->sg_dma_direction); 361 hwif->sg_dma_direction);
538 hwif->sg_nents = 0; 362 hwif->sg_nents = 0;
539 } 363 }
540 364
541 return 0; 365 return 0;
542} 366}
543 367
544static void auide_dma_start(ide_drive_t *drive ) 368static void auide_dma_start(ide_drive_t *drive )
545{ 369{
546// printk("%s\n", __FUNCTION__);
547} 370}
548 371
549ide_startstop_t auide_dma_intr(ide_drive_t *drive)
550{
551 //printk("%s\n", __FUNCTION__);
552
553 u8 stat = 0, dma_stat = 0;
554
555 dma_stat = HWIF(drive)->ide_dma_end(drive);
556 stat = HWIF(drive)->INB(IDE_STATUS_REG); /* get drive status */
557 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
558 if (!dma_stat) {
559 struct request *rq = HWGROUP(drive)->rq;
560
561 ide_end_request(drive, 1, rq->nr_sectors);
562 return ide_stopped;
563 }
564 printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n",
565 drive->name, dma_stat);
566 }
567 return ide_error(drive, "dma_intr", stat);
568}
569 372
570static void auide_dma_exec_cmd(ide_drive_t *drive, u8 command) 373static void auide_dma_exec_cmd(ide_drive_t *drive, u8 command)
571{ 374{
572 //printk("%s\n", __FUNCTION__); 375 /* issue cmd to drive */
573 376 ide_execute_command(drive, command, &ide_dma_intr,
574 /* issue cmd to drive */ 377 (2*WAIT_CMD), NULL);
575 ide_execute_command(drive, command, &auide_dma_intr,
576 (2*WAIT_CMD), NULL);
577} 378}
578 379
579static int auide_dma_setup(ide_drive_t *drive) 380static int auide_dma_setup(ide_drive_t *drive)
580{ 381{
581// printk("%s\n", __FUNCTION__); 382 struct request *rq = HWGROUP(drive)->rq;
582
583 if (drive->media != ide_disk)
584 return 1;
585
586 if (!auide_build_dmatable(drive))
587 /* try PIO instead of DMA */
588 return 1;
589 383
590 drive->waiting_for_dma = 1; 384 if (!auide_build_dmatable(drive)) {
385 ide_map_sg(drive, rq);
386 return 1;
387 }
591 388
592 return 0; 389 drive->waiting_for_dma = 1;
390 return 0;
593} 391}
594 392
595static int auide_dma_check(ide_drive_t *drive) 393static int auide_dma_check(ide_drive_t *drive)
596{ 394{
597// printk("%s\n", __FUNCTION__); 395 u8 speed;
598 396
599#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 397#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
600 if( !dbdma_init_done ){ 398
601 auide_hwif.white_list = in_drive_list(drive->id, 399 if( dbdma_init_done == 0 ){
602 dma_white_list); 400 auide_hwif.white_list = ide_in_drive_list(drive->id,
603 auide_hwif.black_list = in_drive_list(drive->id, 401 dma_white_list);
604 dma_black_list); 402 auide_hwif.black_list = ide_in_drive_list(drive->id,
605 auide_hwif.drive = drive; 403 dma_black_list);
606 auide_ddma_init(&auide_hwif); 404 auide_hwif.drive = drive;
607 dbdma_init_done = 1; 405 auide_ddma_init(&auide_hwif);
608 } 406 dbdma_init_done = 1;
407 }
609#endif 408#endif
610 409
611 /* Is the drive in our DMA black list? */ 410 /* Is the drive in our DMA black list? */
612 if ( auide_hwif.black_list ) { 411
613 drive->using_dma = 0; 412 if ( auide_hwif.black_list ) {
614 printk("%s found in dma_blacklist[]! Disabling DMA.\n", 413 drive->using_dma = 0;
615 drive->id->model); 414
616 } 415 /* Borrowed the warning message from ide-dma.c */
617 else
618 drive->using_dma = 1;
619 416
620 return HWIF(drive)->ide_dma_host_on(drive); 417 printk(KERN_WARNING "%s: Disabling DMA for %s (blacklisted)\n",
418 drive->name, drive->id->model);
419 }
420 else
421 drive->using_dma = 1;
422
423 speed = ide_find_best_mode(drive, XFER_PIO | XFER_MWDMA);
424
425 if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
426 return HWIF(drive)->ide_dma_on(drive);
427
428 return HWIF(drive)->ide_dma_off_quietly(drive);
621} 429}
622 430
623static int auide_dma_test_irq(ide_drive_t *drive) 431static int auide_dma_test_irq(ide_drive_t *drive)
624{ 432{
625// printk("%s\n", __FUNCTION__); 433 if (drive->waiting_for_dma == 0)
626 434 printk(KERN_WARNING "%s: ide_dma_test_irq \
627 if (!drive->waiting_for_dma)
628 printk(KERN_WARNING "%s: ide_dma_test_irq \
629 called while not waiting\n", drive->name); 435 called while not waiting\n", drive->name);
630 436
631 /* If dbdma didn't execute the STOP command yet, the 437 /* If dbdma didn't execute the STOP command yet, the
632 * active bit is still set 438 * active bit is still set
633 */ 439 */
634 drive->waiting_for_dma++; 440 drive->waiting_for_dma++;
635 if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) { 441 if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) {
636 printk(KERN_WARNING "%s: timeout waiting for ddma to \ 442 printk(KERN_WARNING "%s: timeout waiting for ddma to \
637 complete\n", drive->name); 443 complete\n", drive->name);
638 return 1; 444 return 1;
639 } 445 }
640 udelay(10); 446 udelay(10);
641 return 0; 447 return 0;
642} 448}
643 449
644static int auide_dma_host_on(ide_drive_t *drive) 450static int auide_dma_host_on(ide_drive_t *drive)
645{ 451{
646// printk("%s\n", __FUNCTION__); 452 return 0;
647 return 0;
648} 453}
649 454
650static int auide_dma_on(ide_drive_t *drive) 455static int auide_dma_on(ide_drive_t *drive)
651{ 456{
652// printk("%s\n", __FUNCTION__); 457 drive->using_dma = 1;
653 drive->using_dma = 1; 458 return auide_dma_host_on(drive);
654 return auide_dma_host_on(drive);
655} 459}
656 460
657 461
658static int auide_dma_host_off(ide_drive_t *drive) 462static int auide_dma_host_off(ide_drive_t *drive)
659{ 463{
660// printk("%s\n", __FUNCTION__); 464 return 0;
661 return 0;
662} 465}
663 466
664static int auide_dma_off_quietly(ide_drive_t *drive) 467static int auide_dma_off_quietly(ide_drive_t *drive)
665{ 468{
666// printk("%s\n", __FUNCTION__); 469 drive->using_dma = 0;
667 drive->using_dma = 0; 470 return auide_dma_host_off(drive);
668 return auide_dma_host_off(drive);
669} 471}
670 472
671static int auide_dma_lostirq(ide_drive_t *drive) 473static int auide_dma_lostirq(ide_drive_t *drive)
672{ 474{
673// printk("%s\n", __FUNCTION__); 475 printk(KERN_ERR "%s: IRQ lost\n", drive->name);
674 476 return 0;
675 printk(KERN_ERR "%s: IRQ lost\n", drive->name);
676 return 0;
677} 477}
678 478
679static void auide_ddma_tx_callback(int irq, void *param, struct pt_regs *regs) 479static void auide_ddma_tx_callback(int irq, void *param, struct pt_regs *regs)
680{ 480{
681// printk("%s\n", __FUNCTION__); 481 _auide_hwif *ahwif = (_auide_hwif*)param;
682 482 ahwif->drive->waiting_for_dma = 0;
683 _auide_hwif *ahwif = (_auide_hwif*)param;
684 ahwif->drive->waiting_for_dma = 0;
685 return;
686} 483}
687 484
688static void auide_ddma_rx_callback(int irq, void *param, struct pt_regs *regs) 485static void auide_ddma_rx_callback(int irq, void *param, struct pt_regs *regs)
689{ 486{
690// printk("%s\n", __FUNCTION__); 487 _auide_hwif *ahwif = (_auide_hwif*)param;
488 ahwif->drive->waiting_for_dma = 0;
489}
490
491#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
691 492
692 _auide_hwif *ahwif = (_auide_hwif*)param; 493static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize, u32 devwidth, u32 flags)
693 ahwif->drive->waiting_for_dma = 0; 494{
694 return; 495 dev->dev_id = dev_id;
496 dev->dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
497 dev->dev_intlevel = 0;
498 dev->dev_intpolarity = 0;
499 dev->dev_tsize = tsize;
500 dev->dev_devwidth = devwidth;
501 dev->dev_flags = flags;
695} 502}
503
504#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
696 505
697static int auide_dma_timeout(ide_drive_t *drive) 506static int auide_dma_timeout(ide_drive_t *drive)
698{ 507{
699// printk("%s\n", __FUNCTION__); 508// printk("%s\n", __FUNCTION__);
700 509
701 printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); 510 printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name);
702 511
703 if (HWIF(drive)->ide_dma_test_irq(drive)) 512 if (HWIF(drive)->ide_dma_test_irq(drive))
704 return 0; 513 return 0;
705 514
706 return HWIF(drive)->ide_dma_end(drive); 515 return HWIF(drive)->ide_dma_end(drive);
707} 516}
708#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */ 517
709 518
519static int auide_ddma_init(_auide_hwif *auide) {
520
521 dbdev_tab_t source_dev_tab, target_dev_tab;
522 u32 dev_id, tsize, devwidth, flags;
523 ide_hwif_t *hwif = auide->hwif;
710 524
711static int auide_ddma_init( _auide_hwif *auide ) 525 dev_id = AU1XXX_ATA_DDMA_REQ;
712{
713// printk("%s\n", __FUNCTION__);
714 526
715 dbdev_tab_t source_dev_tab; 527 if (auide->white_list || auide->black_list) {
716#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 528 tsize = 8;
717 dbdev_tab_t target_dev_tab; 529 devwidth = 32;
718 ide_hwif_t *hwif = auide->hwif; 530 }
719 char warning_output [2][80]; 531 else {
720 int i; 532 tsize = 1;
721#endif 533 devwidth = 16;
534
535 printk(KERN_ERR "au1xxx-ide: %s is not on ide driver whitelist.\n",auide_hwif.drive->id->model);
536 printk(KERN_ERR " please read 'Documentation/mips/AU1xxx_IDE.README'");
537 }
722 538
723 /* Add our custom device to DDMA device table */ 539#ifdef IDE_AU1XXX_BURSTMODE
724 /* Create our new device entries in the table */ 540 flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
725#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
726 source_dev_tab.dev_id = AU1XXX_ATA_DDMA_REQ;
727
728 if( auide->white_list || auide->black_list ){
729 source_dev_tab.dev_tsize = 8;
730 source_dev_tab.dev_devwidth = 32;
731 source_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
732 source_dev_tab.dev_intlevel = 0;
733 source_dev_tab.dev_intpolarity = 0;
734
735 /* init device table for target - static bus controller - */
736 target_dev_tab.dev_id = DSCR_CMD0_ALWAYS;
737 target_dev_tab.dev_tsize = 8;
738 target_dev_tab.dev_devwidth = 32;
739 target_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
740 target_dev_tab.dev_intlevel = 0;
741 target_dev_tab.dev_intpolarity = 0;
742 target_dev_tab.dev_flags = DEV_FLAGS_ANYUSE;
743 }
744 else{
745 source_dev_tab.dev_tsize = 1;
746 source_dev_tab.dev_devwidth = 16;
747 source_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
748 source_dev_tab.dev_intlevel = 0;
749 source_dev_tab.dev_intpolarity = 0;
750
751 /* init device table for target - static bus controller - */
752 target_dev_tab.dev_id = DSCR_CMD0_ALWAYS;
753 target_dev_tab.dev_tsize = 1;
754 target_dev_tab.dev_devwidth = 16;
755 target_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
756 target_dev_tab.dev_intlevel = 0;
757 target_dev_tab.dev_intpolarity = 0;
758 target_dev_tab.dev_flags = DEV_FLAGS_ANYUSE;
759
760 sprintf(&warning_output[0][0],
761 "%s is not on ide driver white list.",
762 auide_hwif.drive->id->model);
763 for ( i=strlen(&warning_output[0][0]) ; i<76; i++ ){
764 sprintf(&warning_output[0][i]," ");
765 }
766
767 sprintf(&warning_output[1][0],
768 "To add %s please read 'Documentation/mips/AU1xxx_IDE.README'.",
769 auide_hwif.drive->id->model);
770 for ( i=strlen(&warning_output[1][0]) ; i<76; i++ ){
771 sprintf(&warning_output[1][i]," ");
772 }
773
774 printk("\n****************************************");
775 printk("****************************************\n");
776 printk("* %s *\n",&warning_output[0][0]);
777 printk("* Switch to safe MWDMA Mode! ");
778 printk(" *\n");
779 printk("* %s *\n",&warning_output[1][0]);
780 printk("****************************************");
781 printk("****************************************\n\n");
782 }
783#else 541#else
784 source_dev_tab.dev_id = DSCR_CMD0_ALWAYS; 542 flags = DEV_FLAGS_SYNC;
785 source_dev_tab.dev_tsize = 8;
786 source_dev_tab.dev_devwidth = 32;
787 source_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
788 source_dev_tab.dev_intlevel = 0;
789 source_dev_tab.dev_intpolarity = 0;
790#endif 543#endif
791 544
792#if CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON 545 /* setup dev_tab for tx channel */
793 /* set flags for tx channel */ 546 auide_init_dbdma_dev( &source_dev_tab,
794 source_dev_tab.dev_flags = DEV_FLAGS_OUT 547 dev_id,
795 | DEV_FLAGS_SYNC 548 tsize, devwidth, DEV_FLAGS_OUT | flags);
796 | DEV_FLAGS_BURSTABLE; 549 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
797 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab ); 550
798 /* set flags for rx channel */ 551 auide_init_dbdma_dev( &source_dev_tab,
799 source_dev_tab.dev_flags = DEV_FLAGS_IN 552 dev_id,
800 | DEV_FLAGS_SYNC 553 tsize, devwidth, DEV_FLAGS_IN | flags);
801 | DEV_FLAGS_BURSTABLE; 554 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
802 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab ); 555
556 /* We also need to add a target device for the DMA */
557 auide_init_dbdma_dev( &target_dev_tab,
558 (u32)DSCR_CMD0_ALWAYS,
559 tsize, devwidth, DEV_FLAGS_ANYUSE);
560 auide->target_dev_id = au1xxx_ddma_add_device(&target_dev_tab);
561
562 /* Get a channel for TX */
563 auide->tx_chan = au1xxx_dbdma_chan_alloc(auide->target_dev_id,
564 auide->tx_dev_id,
565 auide_ddma_tx_callback,
566 (void*)auide);
567
568 /* Get a channel for RX */
569 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
570 auide->target_dev_id,
571 auide_ddma_rx_callback,
572 (void*)auide);
573
574 auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
575 NUM_DESCRIPTORS);
576 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
577 NUM_DESCRIPTORS);
578
579 hwif->dmatable_cpu = dma_alloc_coherent(auide->dev,
580 PRD_ENTRIES * PRD_BYTES, /* 1 Page */
581 &hwif->dmatable_dma, GFP_KERNEL);
582
583 au1xxx_dbdma_start( auide->tx_chan );
584 au1xxx_dbdma_start( auide->rx_chan );
585
586 return 0;
587}
803#else 588#else
804 /* set flags for tx channel */ 589
805 source_dev_tab.dev_flags = DEV_FLAGS_OUT | DEV_FLAGS_SYNC; 590static int auide_ddma_init( _auide_hwif *auide )
806 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab ); 591{
807 /* set flags for rx channel */ 592 dbdev_tab_t source_dev_tab;
808 source_dev_tab.dev_flags = DEV_FLAGS_IN | DEV_FLAGS_SYNC; 593 int flags;
809 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
810#endif
811 594
812#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 595#ifdef IDE_AU1XXX_BURSTMODE
813 596 flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
814 auide->target_dev_id = au1xxx_ddma_add_device(&target_dev_tab); 597#else
815 598 flags = DEV_FLAGS_SYNC;
816 /* Get a channel for TX */
817 auide->tx_chan = au1xxx_dbdma_chan_alloc(auide->target_dev_id,
818 auide->tx_dev_id,
819 auide_ddma_tx_callback,
820 (void*)auide);
821 /* Get a channel for RX */
822 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
823 auide->target_dev_id,
824 auide_ddma_rx_callback,
825 (void*)auide);
826#else /* CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA */
827 /*
828 * Note: if call back is not enabled, update ctp->cur_ptr manually
829 */
830 auide->tx_chan = au1xxx_dbdma_chan_alloc(DSCR_CMD0_ALWAYS,
831 auide->tx_dev_id,
832 NULL,
833 (void*)auide);
834 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
835 DSCR_CMD0_ALWAYS,
836 NULL,
837 (void*)auide);
838#endif 599#endif
839 auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
840 NUM_DESCRIPTORS);
841 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
842 NUM_DESCRIPTORS);
843 600
844#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 601 /* setup dev_tab for tx channel */
845 hwif->dmatable_cpu = dma_alloc_coherent(auide->dev, 602 auide_init_dbdma_dev( &source_dev_tab,
846 PRD_ENTRIES * PRD_BYTES, /* 1 Page */ 603 (u32)DSCR_CMD0_ALWAYS,
847 &hwif->dmatable_dma, GFP_KERNEL); 604 8, 32, DEV_FLAGS_OUT | flags);
848 605 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
849 auide->sg_table = kmalloc(sizeof(struct scatterlist) * PRD_ENTRIES, 606
850 GFP_KERNEL|GFP_DMA); 607 auide_init_dbdma_dev( &source_dev_tab,
851 if (auide->sg_table == NULL) { 608 (u32)DSCR_CMD0_ALWAYS,
852 return -ENOMEM; 609 8, 32, DEV_FLAGS_IN | flags);
853 } 610 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
854#endif 611
855 au1xxx_dbdma_start( auide->tx_chan ); 612 /* Get a channel for TX */
856 au1xxx_dbdma_start( auide->rx_chan ); 613 auide->tx_chan = au1xxx_dbdma_chan_alloc(DSCR_CMD0_ALWAYS,
857 return 0; 614 auide->tx_dev_id,
615 NULL,
616 (void*)auide);
617
618 /* Get a channel for RX */
619 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
620 DSCR_CMD0_ALWAYS,
621 NULL,
622 (void*)auide);
623
624 auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
625 NUM_DESCRIPTORS);
626 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
627 NUM_DESCRIPTORS);
628
629 au1xxx_dbdma_start( auide->tx_chan );
630 au1xxx_dbdma_start( auide->rx_chan );
631
632 return 0;
858} 633}
634#endif
859 635
860static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) 636static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
861{ 637{
862 int i; 638 int i;
863#define ide_ioreg_t unsigned long 639 unsigned long *ata_regs = hw->io_ports;
864 ide_ioreg_t *ata_regs = hw->io_ports; 640
865 641 /* FIXME? */
866 /* fixme */ 642 for (i = 0; i < IDE_CONTROL_OFFSET; i++) {
867 for (i = 0; i < IDE_CONTROL_OFFSET; i++) { 643 *ata_regs++ = ahwif->regbase + (i << AU1XXX_ATA_REG_OFFSET);
868 *ata_regs++ = (ide_ioreg_t) ahwif->regbase 644 }
869 + (ide_ioreg_t)(i << AU1XXX_ATA_REG_OFFSET); 645
870 } 646 /* set the Alternative Status register */
871 647 *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET);
872 /* set the Alternative Status register */
873 *ata_regs = (ide_ioreg_t) ahwif->regbase
874 + (ide_ioreg_t)(14 << AU1XXX_ATA_REG_OFFSET);
875} 648}
876 649
877static int au_ide_probe(struct device *dev) 650static int au_ide_probe(struct device *dev)
878{ 651{
879 struct platform_device *pdev = to_platform_device(dev); 652 struct platform_device *pdev = to_platform_device(dev);
880 _auide_hwif *ahwif = &auide_hwif; 653 _auide_hwif *ahwif = &auide_hwif;
881 ide_hwif_t *hwif; 654 ide_hwif_t *hwif;
882 struct resource *res; 655 struct resource *res;
883 int ret = 0; 656 int ret = 0;
884 657
885#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 658#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
886 char *mode = "MWDMA2"; 659 char *mode = "MWDMA2";
887#elif defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA) 660#elif defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
888 char *mode = "PIO+DDMA(offload)"; 661 char *mode = "PIO+DDMA(offload)";
889#endif 662#endif
890 663
891 memset(&auide_hwif, 0, sizeof(_auide_hwif)); 664 memset(&auide_hwif, 0, sizeof(_auide_hwif));
892 auide_hwif.dev = 0; 665 auide_hwif.dev = 0;
893 666
894 ahwif->dev = dev; 667 ahwif->dev = dev;
895 ahwif->irq = platform_get_irq(pdev, 0); 668 ahwif->irq = platform_get_irq(pdev, 0);
@@ -902,11 +675,11 @@ static int au_ide_probe(struct device *dev)
902 goto out; 675 goto out;
903 } 676 }
904 677
905 if (!request_mem_region (res->start, res->end-res->start, pdev->name)) { 678 if (!request_mem_region (res->start, res->end-res->start, pdev->name)) {
906 pr_debug("%s: request_mem_region failed\n", DRV_NAME); 679 pr_debug("%s: request_mem_region failed\n", DRV_NAME);
907 ret = -EBUSY; 680 ret = -EBUSY;
908 goto out; 681 goto out;
909 } 682 }
910 683
911 ahwif->regbase = (u32)ioremap(res->start, res->end-res->start); 684 ahwif->regbase = (u32)ioremap(res->start, res->end-res->start);
912 if (ahwif->regbase == 0) { 685 if (ahwif->regbase == 0) {
@@ -914,130 +687,92 @@ static int au_ide_probe(struct device *dev)
914 goto out; 687 goto out;
915 } 688 }
916 689
917 hwif = &ide_hwifs[pdev->id]; 690 /* FIXME: This might possibly break PCMCIA IDE devices */
691
692 hwif = &ide_hwifs[pdev->id];
918 hw_regs_t *hw = &hwif->hw; 693 hw_regs_t *hw = &hwif->hw;
919 hwif->irq = hw->irq = ahwif->irq; 694 hwif->irq = hw->irq = ahwif->irq;
920 hwif->chipset = ide_au1xxx; 695 hwif->chipset = ide_au1xxx;
921 696
922 auide_setup_ports(hw, ahwif); 697 auide_setup_ports(hw, ahwif);
923 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); 698 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
924 699
925#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ 700 hwif->ultra_mask = 0x0; /* Disable Ultra DMA */
926 hwif->rqsize = CONFIG_BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ;
927 hwif->rqsize = ((hwif->rqsize > AU1XXX_ATA_RQSIZE)
928 || (hwif->rqsize < 32)) ? AU1XXX_ATA_RQSIZE : hwif->rqsize;
929#else /* if kernel config is not set */
930 hwif->rqsize = AU1XXX_ATA_RQSIZE;
931#endif
932
933 hwif->ultra_mask = 0x0; /* Disable Ultra DMA */
934#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 701#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
935 hwif->mwdma_mask = 0x07; /* Multimode-2 DMA */ 702 hwif->mwdma_mask = 0x07; /* Multimode-2 DMA */
936 hwif->swdma_mask = 0x07; 703 hwif->swdma_mask = 0x00;
937#else 704#else
938 hwif->mwdma_mask = 0x0; 705 hwif->mwdma_mask = 0x0;
939 hwif->swdma_mask = 0x0; 706 hwif->swdma_mask = 0x0;
707#endif
708
709 hwif->noprobe = 0;
710 hwif->drives[0].unmask = 1;
711 hwif->drives[1].unmask = 1;
712
713 /* hold should be on in all cases */
714 hwif->hold = 1;
715 hwif->mmio = 2;
716
717 /* If the user has selected DDMA assisted copies,
718 then set up a few local I/O function entry points
719 */
720
721#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
722 hwif->INSW = auide_insw;
723 hwif->OUTSW = auide_outsw;
940#endif 724#endif
941 //hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; 725
942 hwif->noprobe = 0; 726 hwif->tuneproc = &auide_tune_drive;
943 hwif->drives[0].unmask = 1; 727 hwif->speedproc = &auide_tune_chipset;
944 hwif->drives[1].unmask = 1;
945
946 /* hold should be on in all cases */
947 hwif->hold = 1;
948 hwif->mmio = 2;
949
950 /* set up local I/O function entry points */
951 hwif->INB = auide_inb;
952 hwif->INW = auide_inw;
953 hwif->INL = auide_inl;
954 hwif->INSW = auide_insw;
955 hwif->INSL = auide_insl;
956 hwif->OUTB = auide_outb;
957 hwif->OUTBSYNC = auide_outbsync;
958 hwif->OUTW = auide_outw;
959 hwif->OUTL = auide_outl;
960 hwif->OUTSW = auide_outsw;
961 hwif->OUTSL = auide_outsl;
962
963 hwif->tuneproc = &auide_tune_drive;
964 hwif->speedproc = &auide_tune_chipset;
965 728
966#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 729#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
967 hwif->ide_dma_off_quietly = &auide_dma_off_quietly; 730 hwif->ide_dma_off_quietly = &auide_dma_off_quietly;
968 hwif->ide_dma_timeout = &auide_dma_timeout; 731 hwif->ide_dma_timeout = &auide_dma_timeout;
969 732
970 hwif->ide_dma_check = &auide_dma_check; 733 hwif->ide_dma_check = &auide_dma_check;
971 hwif->dma_exec_cmd = &auide_dma_exec_cmd; 734 hwif->dma_exec_cmd = &auide_dma_exec_cmd;
972 hwif->dma_start = &auide_dma_start; 735 hwif->dma_start = &auide_dma_start;
973 hwif->ide_dma_end = &auide_dma_end; 736 hwif->ide_dma_end = &auide_dma_end;
974 hwif->dma_setup = &auide_dma_setup; 737 hwif->dma_setup = &auide_dma_setup;
975 hwif->ide_dma_test_irq = &auide_dma_test_irq; 738 hwif->ide_dma_test_irq = &auide_dma_test_irq;
976 hwif->ide_dma_host_off = &auide_dma_host_off; 739 hwif->ide_dma_host_off = &auide_dma_host_off;
977 hwif->ide_dma_host_on = &auide_dma_host_on; 740 hwif->ide_dma_host_on = &auide_dma_host_on;
978 hwif->ide_dma_lostirq = &auide_dma_lostirq; 741 hwif->ide_dma_lostirq = &auide_dma_lostirq;
979 hwif->ide_dma_on = &auide_dma_on; 742 hwif->ide_dma_on = &auide_dma_on;
980 743
981 hwif->autodma = 1; 744 hwif->autodma = 1;
982 hwif->drives[0].autodma = hwif->autodma; 745 hwif->drives[0].autodma = hwif->autodma;
983 hwif->drives[1].autodma = hwif->autodma; 746 hwif->drives[1].autodma = hwif->autodma;
984 hwif->atapi_dma = 1; 747 hwif->atapi_dma = 1;
985 hwif->drives[0].using_dma = 1; 748
986 hwif->drives[1].using_dma = 1;
987#else /* !CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */ 749#else /* !CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
988 hwif->autodma = 0; 750 hwif->autodma = 0;
989 hwif->channel = 0; 751 hwif->channel = 0;
990 hwif->hold = 1; 752 hwif->hold = 1;
991 hwif->select_data = 0; /* no chipset-specific code */ 753 hwif->select_data = 0; /* no chipset-specific code */
992 hwif->config_data = 0; /* no chipset-specific code */ 754 hwif->config_data = 0; /* no chipset-specific code */
993 755
994 hwif->drives[0].autodma = 0; 756 hwif->drives[0].autodma = 0;
995 hwif->drives[0].drive_data = 0; /* no drive data */ 757 hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */
996 hwif->drives[0].using_dma = 0;
997 hwif->drives[0].waiting_for_dma = 0;
998 hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */
999 /* secondary hdd not supported */
1000 hwif->drives[1].autodma = 0;
1001
1002 hwif->drives[1].drive_data = 0;
1003 hwif->drives[1].using_dma = 0;
1004 hwif->drives[1].waiting_for_dma = 0;
1005 hwif->drives[1].autotune = 2; /* 1=autotune, 2=noautotune, 0=default */
1006#endif
1007 hwif->drives[0].io_32bit = 0; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
1008 hwif->drives[1].io_32bit = 0; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
1009
1010 /*Register Driver with PM Framework*/
1011#ifdef CONFIG_PM
1012 auide_hwif.pm.lock = SPIN_LOCK_UNLOCKED;
1013 auide_hwif.pm.stopped = 0;
1014
1015 auide_hwif.pm.dev = new_au1xxx_power_device( "ide",
1016 &au1200ide_pm_callback,
1017 NULL);
1018 if ( auide_hwif.pm.dev == NULL )
1019 printk(KERN_INFO "Unable to create a power management \
1020 device entry for the au1200-IDE.\n");
1021 else
1022 printk(KERN_INFO "Power management device entry for the \
1023 au1200-IDE loaded.\n");
1024#endif 758#endif
759 hwif->drives[0].no_io_32bit = 1;
1025 760
1026 auide_hwif.hwif = hwif; 761 auide_hwif.hwif = hwif;
1027 hwif->hwif_data = &auide_hwif; 762 hwif->hwif_data = &auide_hwif;
1028 763
1029#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA 764#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
1030 auide_ddma_init(&auide_hwif); 765 auide_ddma_init(&auide_hwif);
1031 dbdma_init_done = 1; 766 dbdma_init_done = 1;
1032#endif 767#endif
1033 768
1034 probe_hwif_init(hwif); 769 probe_hwif_init(hwif);
1035 dev_set_drvdata(dev, hwif); 770 dev_set_drvdata(dev, hwif);
1036 771
1037 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); 772 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
1038 773
1039out: 774 out:
1040 return ret; 775 return ret;
1041} 776}
1042 777
1043static int au_ide_remove(struct device *dev) 778static int au_ide_remove(struct device *dev)
@@ -1045,7 +780,7 @@ static int au_ide_remove(struct device *dev)
1045 struct platform_device *pdev = to_platform_device(dev); 780 struct platform_device *pdev = to_platform_device(dev);
1046 struct resource *res; 781 struct resource *res;
1047 ide_hwif_t *hwif = dev_get_drvdata(dev); 782 ide_hwif_t *hwif = dev_get_drvdata(dev);
1048 _auide_hwif *ahwif = &auide_hwif; 783 _auide_hwif *ahwif = &auide_hwif;
1049 784
1050 ide_unregister(hwif - ide_hwifs); 785 ide_unregister(hwif - ide_hwifs);
1051 786
@@ -1069,180 +804,11 @@ static int __init au_ide_init(void)
1069 return driver_register(&au1200_ide_driver); 804 return driver_register(&au1200_ide_driver);
1070} 805}
1071 806
1072static void __init au_ide_exit(void) 807static void __exit au_ide_exit(void)
1073{ 808{
1074 driver_unregister(&au1200_ide_driver); 809 driver_unregister(&au1200_ide_driver);
1075} 810}
1076 811
1077#ifdef CONFIG_PM
1078int au1200ide_pm_callback( au1xxx_power_dev_t *dev,\
1079 au1xxx_request_t request, void *data) {
1080
1081 unsigned int d, err = 0;
1082 unsigned long flags;
1083
1084 spin_lock_irqsave(auide_hwif.pm.lock, flags);
1085
1086 switch (request){
1087 case AU1XXX_PM_SLEEP:
1088 err = au1xxxide_pm_sleep(dev);
1089 break;
1090 case AU1XXX_PM_WAKEUP:
1091 d = *((unsigned int*)data);
1092 if ( d > 0 && d <= 99) {
1093 err = au1xxxide_pm_standby(dev);
1094 }
1095 else {
1096 err = au1xxxide_pm_resume(dev);
1097 }
1098 break;
1099 case AU1XXX_PM_GETSTATUS:
1100 err = au1xxxide_pm_getstatus(dev);
1101 break;
1102 case AU1XXX_PM_ACCESS:
1103 err = au1xxxide_pm_access(dev);
1104 break;
1105 case AU1XXX_PM_IDLE:
1106 err = au1xxxide_pm_idle(dev);
1107 break;
1108 case AU1XXX_PM_CLEANUP:
1109 err = au1xxxide_pm_cleanup(dev);
1110 break;
1111 default:
1112 err = -1;
1113 break;
1114 }
1115
1116 spin_unlock_irqrestore(auide_hwif.pm.lock, flags);
1117
1118 return err;
1119}
1120
1121static int au1xxxide_pm_standby( au1xxx_power_dev_t *dev ) {
1122 return 0;
1123}
1124
1125static int au1xxxide_pm_sleep( au1xxx_power_dev_t *dev ) {
1126
1127 int retval;
1128 ide_hwif_t *hwif = auide_hwif.hwif;
1129 struct request rq;
1130 struct request_pm_state rqpm;
1131 ide_task_t args;
1132
1133 if(auide_hwif.pm.stopped)
1134 return -1;
1135
1136 /*
1137 * wait until hard disc is ready
1138 */
1139 if ( wait_for_ready(&hwif->drives[0], 35000) ) {
1140 printk("Wait for drive sleep timeout!\n");
1141 retval = -1;
1142 }
1143
1144 /*
1145 * sequenz to tell the high level ide driver that pm is resuming
1146 */
1147 memset(&rq, 0, sizeof(rq));
1148 memset(&rqpm, 0, sizeof(rqpm));
1149 memset(&args, 0, sizeof(args));
1150 rq.flags = REQ_PM_SUSPEND;
1151 rq.special = &args;
1152 rq.pm = &rqpm;
1153 rqpm.pm_step = ide_pm_state_start_suspend;
1154 rqpm.pm_state = PMSG_SUSPEND;
1155
1156 retval = ide_do_drive_cmd(&hwif->drives[0], &rq, ide_wait);
1157
1158 if (wait_for_ready (&hwif->drives[0], 35000)) {
1159 printk("Wait for drive sleep timeout!\n");
1160 retval = -1;
1161 }
1162
1163 /*
1164 * stop dbdma channels
1165 */
1166 au1xxx_dbdma_reset(auide_hwif.tx_chan);
1167 au1xxx_dbdma_reset(auide_hwif.rx_chan);
1168
1169 auide_hwif.pm.stopped = 1;
1170
1171 return retval;
1172}
1173
1174static int au1xxxide_pm_resume( au1xxx_power_dev_t *dev ) {
1175
1176 int retval;
1177 ide_hwif_t *hwif = auide_hwif.hwif;
1178 struct request rq;
1179 struct request_pm_state rqpm;
1180 ide_task_t args;
1181
1182 if(!auide_hwif.pm.stopped)
1183 return -1;
1184
1185 /*
1186 * start dbdma channels
1187 */
1188 au1xxx_dbdma_start(auide_hwif.tx_chan);
1189 au1xxx_dbdma_start(auide_hwif.rx_chan);
1190
1191 /*
1192 * wait until hard disc is ready
1193 */
1194 if (wait_for_ready ( &hwif->drives[0], 35000)) {
1195 printk("Wait for drive wake up timeout!\n");
1196 retval = -1;
1197 }
1198
1199 /*
1200 * sequenz to tell the high level ide driver that pm is resuming
1201 */
1202 memset(&rq, 0, sizeof(rq));
1203 memset(&rqpm, 0, sizeof(rqpm));
1204 memset(&args, 0, sizeof(args));
1205 rq.flags = REQ_PM_RESUME;
1206 rq.special = &args;
1207 rq.pm = &rqpm;
1208 rqpm.pm_step = ide_pm_state_start_resume;
1209 rqpm.pm_state = PMSG_ON;
1210
1211 retval = ide_do_drive_cmd(&hwif->drives[0], &rq, ide_head_wait);
1212
1213 /*
1214 * wait for hard disc
1215 */
1216 if ( wait_for_ready(&hwif->drives[0], 35000) ) {
1217 printk("Wait for drive wake up timeout!\n");
1218 retval = -1;
1219 }
1220
1221 auide_hwif.pm.stopped = 0;
1222
1223 return retval;
1224}
1225
1226static int au1xxxide_pm_getstatus( au1xxx_power_dev_t *dev ) {
1227 return dev->cur_state;
1228}
1229
1230static int au1xxxide_pm_access( au1xxx_power_dev_t *dev ) {
1231 if (dev->cur_state != AWAKE_STATE)
1232 return 0;
1233 else
1234 return -1;
1235}
1236
1237static int au1xxxide_pm_idle( au1xxx_power_dev_t *dev ) {
1238 return 0;
1239}
1240
1241static int au1xxxide_pm_cleanup( au1xxx_power_dev_t *dev ) {
1242 return 0;
1243}
1244#endif /* CONFIG_PM */
1245
1246MODULE_LICENSE("GPL"); 812MODULE_LICENSE("GPL");
1247MODULE_DESCRIPTION("AU1200 IDE driver"); 813MODULE_DESCRIPTION("AU1200 IDE driver");
1248 814
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
new file mode 100644
index 000000000000..66f6064f4640
--- /dev/null
+++ b/drivers/ide/mips/swarm.c
@@ -0,0 +1,201 @@
1/*
2 * Copyright (C) 2001, 2002, 2003 Broadcom Corporation
3 * Copyright (C) 2004 MontaVista Software Inc.
4 * Author: Manish Lachwani, mlachwani@mvista.com
5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved.
6 * Author: Maciej W. Rozycki <macro@mips.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23/*
24 * Derived loosely from ide-pmac.c, so:
25 * Copyright (C) 1998 Paul Mackerras.
26 * Copyright (C) 1995-1998 Mark Lord
27 */
28
29/*
30 * Boards with SiByte processors so far have supported IDE devices via
31 * the Generic Bus, PCI bus, and built-in PCMCIA interface. In all
32 * cases, byte-swapping must be avoided for these devices (whereas
33 * other PCI devices, for example, will require swapping). Any
34 * SiByte-targetted kernel including IDE support will include this
35 * file. Probing of a Generic Bus for an IDE device is controlled by
36 * the definition of "SIBYTE_HAVE_IDE", which is provided by
37 * <asm/sibyte/board.h> for Broadcom boards.
38 */
39
40#include <linux/ide.h>
41#include <linux/ioport.h>
42#include <linux/kernel.h>
43#include <linux/types.h>
44#include <linux/platform_device.h>
45
46#include <asm/io.h>
47
48#include <asm/sibyte/board.h>
49#include <asm/sibyte/sb1250_genbus.h>
50#include <asm/sibyte/sb1250_regs.h>
51
52#define DRV_NAME "ide-swarm"
53
54static char swarm_ide_string[] = DRV_NAME;
55
56static struct resource swarm_ide_resource = {
57 .name = "SWARM GenBus IDE",
58 .flags = IORESOURCE_MEM,
59};
60
61static struct platform_device *swarm_ide_dev;
62
63/*
64 * swarm_ide_probe - if the board header indicates the existence of
65 * Generic Bus IDE, allocate a HWIF for it.
66 */
67static int __devinit swarm_ide_probe(struct device *dev)
68{
69 ide_hwif_t *hwif;
70 u8 __iomem *base;
71 phys_t offset, size;
72 int i;
73
74 if (!SIBYTE_HAVE_IDE)
75 return -ENODEV;
76
77 /* Find an empty slot. */
78 for (i = 0; i < MAX_HWIFS; i++)
79 if (!ide_hwifs[i].io_ports[IDE_DATA_OFFSET])
80 break;
81 if (i >= MAX_HWIFS) {
82 printk(KERN_ERR DRV_NAME ": no free slot for interface\n");
83 return -ENOMEM;
84 }
85
86 hwif = ide_hwifs + i;
87
88 base = ioremap(A_IO_EXT_BASE, 0x800);
89 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
90 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
91 iounmap(base);
92
93 offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
94 size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
95 if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
96 printk(KERN_INFO DRV_NAME
97 ": IDE interface at GenBus disabled\n");
98 return -EBUSY;
99 }
100
101 printk(KERN_INFO DRV_NAME ": IDE interface at GenBus slot %i\n",
102 IDE_CS);
103
104 swarm_ide_resource.start = offset;
105 swarm_ide_resource.end = offset + size - 1;
106 if (request_resource(&iomem_resource, &swarm_ide_resource)) {
107 printk(KERN_ERR DRV_NAME
108 ": can't request I/O memory resource\n");
109 return -EBUSY;
110 }
111
112 base = ioremap(offset, size);
113
114 /* Setup MMIO ops. */
115 default_hwif_mmiops(hwif);
116 /* Prevent resource map manipulation. */
117 hwif->mmio = 2;
118 hwif->noprobe = 0;
119
120 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
121 hwif->hw.io_ports[i] =
122 (unsigned long)(base + ((0x1f0 + i) << 5));
123 hwif->hw.io_ports[IDE_CONTROL_OFFSET] =
124 (unsigned long)(base + (0x3f6 << 5));
125 hwif->hw.irq = K_INT_GB_IDE;
126
127 memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
128 hwif->irq = hwif->hw.irq;
129
130 dev_set_drvdata(dev, hwif);
131
132 return 0;
133}
134
135static struct device_driver swarm_ide_driver = {
136 .name = swarm_ide_string,
137 .bus = &platform_bus_type,
138 .probe = swarm_ide_probe,
139};
140
141static void swarm_ide_platform_release(struct device *device)
142{
143 struct platform_device *pldev;
144
145 /* free device */
146 pldev = to_platform_device(device);
147 kfree(pldev);
148}
149
150static int __devinit swarm_ide_init_module(void)
151{
152 struct platform_device *pldev;
153 int err;
154
155 printk(KERN_INFO "SWARM IDE driver\n");
156
157 if (driver_register(&swarm_ide_driver)) {
158 printk(KERN_ERR "Driver registration failed\n");
159 err = -ENODEV;
160 goto out;
161 }
162
163 if (!(pldev = kmalloc(sizeof (*pldev), GFP_KERNEL))) {
164 err = -ENOMEM;
165 goto out_unregister_driver;
166 }
167
168 memset (pldev, 0, sizeof (*pldev));
169 pldev->name = swarm_ide_string;
170 pldev->id = 0;
171 pldev->dev.release = swarm_ide_platform_release;
172
173 if (platform_device_register(pldev)) {
174 err = -ENODEV;
175 goto out_free_pldev;
176 }
177
178 if (!pldev->dev.driver) {
179 /*
180 * The driver was not bound to this device, there was
181 * no hardware at this address. Unregister it, as the
182 * release fuction will take care of freeing the
183 * allocated structure
184 */
185 platform_device_unregister (pldev);
186 }
187
188 swarm_ide_dev = pldev;
189
190 return 0;
191
192out_free_pldev:
193 kfree(pldev);
194
195out_unregister_driver:
196 driver_unregister(&swarm_ide_driver);
197out:
198 return err;
199}
200
201module_init(swarm_ide_init_module);
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 52cadc005d72..a21b1e11eef4 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -65,23 +65,6 @@ static struct chipset_bus_clock_list_entry aec6xxx_34_base [] = {
65#define BUSCLOCK(D) \ 65#define BUSCLOCK(D) \
66 ((struct chipset_bus_clock_list_entry *) pci_get_drvdata((D))) 66 ((struct chipset_bus_clock_list_entry *) pci_get_drvdata((D)))
67 67
68#if 0
69 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
70 (void) pci_read_config_byte(dev, 0x54, &art);
71 p += sprintf(p, "DMA Mode: %s(%s)",
72 (c0&0x20)?((art&0x03)?"UDMA":" DMA"):" PIO",
73 (art&0x02)?"2":(art&0x01)?"1":"0");
74 p += sprintf(p, " %s(%s)",
75 (c0&0x40)?((art&0x0c)?"UDMA":" DMA"):" PIO",
76 (art&0x08)?"2":(art&0x04)?"1":"0");
77 p += sprintf(p, " %s(%s)",
78 (c1&0x20)?((art&0x30)?"UDMA":" DMA"):" PIO",
79 (art&0x20)?"2":(art&0x10)?"1":"0");
80 p += sprintf(p, " %s(%s)\n",
81 (c1&0x40)?((art&0xc0)?"UDMA":" DMA"):" PIO",
82 (art&0x80)?"2":(art&0x40)?"1":"0");
83 } else {
84#endif
85 68
86/* 69/*
87 * TO DO: active tuning and correction of cards without a bios. 70 * TO DO: active tuning and correction of cards without a bios.
@@ -112,13 +95,9 @@ static u8 aec62xx_ratemask (ide_drive_t *drive)
112 switch(hwif->pci_dev->device) { 95 switch(hwif->pci_dev->device) {
113 case PCI_DEVICE_ID_ARTOP_ATP865: 96 case PCI_DEVICE_ID_ARTOP_ATP865:
114 case PCI_DEVICE_ID_ARTOP_ATP865R: 97 case PCI_DEVICE_ID_ARTOP_ATP865R:
115#if 0
116 mode = (hwif->INB(hwif->dma_master) & 0x10) ? 4 : 3;
117#else
118 mode = (hwif->INB(((hwif->channel) ? 98 mode = (hwif->INB(((hwif->channel) ?
119 hwif->mate->dma_status : 99 hwif->mate->dma_status :
120 hwif->dma_status)) & 0x10) ? 4 : 3; 100 hwif->dma_status)) & 0x10) ? 4 : 3;
121#endif
122 break; 101 break;
123 case PCI_DEVICE_ID_ARTOP_ATP860: 102 case PCI_DEVICE_ID_ARTOP_ATP860:
124 case PCI_DEVICE_ID_ARTOP_ATP860R: 103 case PCI_DEVICE_ID_ARTOP_ATP860R:
@@ -263,35 +242,9 @@ static int aec62xx_irq_timeout (ide_drive_t *drive)
263 case PCI_DEVICE_ID_ARTOP_ATP865: 242 case PCI_DEVICE_ID_ARTOP_ATP865:
264 case PCI_DEVICE_ID_ARTOP_ATP865R: 243 case PCI_DEVICE_ID_ARTOP_ATP865R:
265 printk(" AEC62XX time out "); 244 printk(" AEC62XX time out ");
266#if 0
267 {
268 int i = 0;
269 u8 reg49h = 0;
270 pci_read_config_byte(HWIF(drive)->pci_dev, 0x49, &reg49h);
271 for (i=0;i<256;i++)
272 pci_write_config_byte(HWIF(drive)->pci_dev, 0x49, reg49h|0x10);
273 pci_write_config_byte(HWIF(drive)->pci_dev, 0x49, reg49h & ~0x10);
274 }
275 return 0;
276#endif
277 default: 245 default:
278 break; 246 break;
279 } 247 }
280#if 0
281 {
282 ide_hwif_t *hwif = HWIF(drive);
283 struct pci_dev *dev = hwif->pci_dev;
284 u8 tmp1 = 0, tmp2 = 0, mode6 = 0;
285
286 pci_read_config_byte(dev, 0x44, &tmp1);
287 pci_read_config_byte(dev, 0x45, &tmp2);
288 printk(" AEC6280 r44=%x r45=%x ",tmp1,tmp2);
289 mode6 = HWIF(drive)->INB(((hwif->channel) ?
290 hwif->mate->dma_status :
291 hwif->dma_status));
292 printk(" AEC6280 133=%x ", (mode6 & 0x10));
293 }
294#endif
295 return 0; 248 return 0;
296} 249}
297 250
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 6cf49394a80f..cf84350efc55 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -876,10 +876,15 @@ static ide_pci_device_t ali15x3_chipset __devinitdata = {
876 876
877static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) 877static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
878{ 878{
879 static struct pci_device_id ati_rs100[] = {
880 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100) },
881 { },
882 };
883
879 ide_pci_device_t *d = &ali15x3_chipset; 884 ide_pci_device_t *d = &ali15x3_chipset;
880 885
881 if(pci_find_device(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100, NULL)) 886 if (pci_dev_present(ati_rs100))
882 printk(KERN_ERR "Warning: ATI Radeon IGP Northbridge is not yet fully tested.\n"); 887 printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n");
883 888
884#if defined(CONFIG_SPARC64) 889#if defined(CONFIG_SPARC64)
885 d->init_hwif = init_hwif_common_ali15x3; 890 d->init_hwif = init_hwif_common_ali15x3;
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index 7dc24682d197..ea3c52cc8ac1 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -222,10 +222,9 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
222 222
223 /* We must not grab the entire device, it has 'ISA' space in its 223 /* We must not grab the entire device, it has 'ISA' space in its
224 BARS too and we will freak out other bits of the kernel */ 224 BARS too and we will freak out other bits of the kernel */
225 if(pci_enable_device_bars(dev, 1<<2)) 225 if (pci_enable_device_bars(dev, 1<<2)) {
226 {
227 printk(KERN_WARNING "%s: Unable to enable 55x0.\n", d->name); 226 printk(KERN_WARNING "%s: Unable to enable 55x0.\n", d->name);
228 return 1; 227 return -ENODEV;
229 } 228 }
230 pci_set_master(dev); 229 pci_set_master(dev);
231 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { 230 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index af526b671c4e..4ee597d08797 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -622,12 +622,18 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
622 ide_hwif_t *hwif; 622 ide_hwif_t *hwif;
623 int h; 623 int h;
624 624
625 /*
626 * Find an empty HWIF; if none available, return -ENOMEM.
627 */
625 for (h = 0; h < MAX_HWIFS; ++h) { 628 for (h = 0; h < MAX_HWIFS; ++h) {
626 hwif = &ide_hwifs[h]; 629 hwif = &ide_hwifs[h];
627 /* Find an empty HWIF */
628 if (hwif->chipset == ide_unknown) 630 if (hwif->chipset == ide_unknown)
629 break; 631 break;
630 } 632 }
633 if (h == MAX_HWIFS) {
634 printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", d->name);
635 return -ENOMEM;
636 }
631 637
632 /* Get the CmdBlk and CtrlBlk Base Registers */ 638 /* Get the CmdBlk and CtrlBlk Base Registers */
633 base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET; 639 base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET;
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 022d244f2eb0..f1ca154dd52c 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -6,7 +6,13 @@
6 * 6 *
7 * May be copied or modified under the terms of the GNU General Public License 7 * May be copied or modified under the terms of the GNU General Public License
8 * 8 *
9 * Documentation available under NDA only 9 * Documentation for CMD680:
10 * http://gkernel.sourceforge.net/specs/sii/sii-0680a-v1.31.pdf.bz2
11 *
12 * Documentation for SiI 3112:
13 * http://gkernel.sourceforge.net/specs/sii/3112A_SiI-DS-0095-B2.pdf.bz2
14 *
15 * Errata and other documentation only available under NDA.
10 * 16 *
11 * 17 *
12 * FAQ Items: 18 * FAQ Items:
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 16b3e2d8bfb1..75a2253a3e68 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -87,6 +87,7 @@ static const struct {
87 u8 chipset_family; 87 u8 chipset_family;
88 u8 flags; 88 u8 flags;
89} SiSHostChipInfo[] = { 89} SiSHostChipInfo[] = {
90 { "SiS965", PCI_DEVICE_ID_SI_965, ATA_133 },
90 { "SiS745", PCI_DEVICE_ID_SI_745, ATA_100 }, 91 { "SiS745", PCI_DEVICE_ID_SI_745, ATA_100 },
91 { "SiS735", PCI_DEVICE_ID_SI_735, ATA_100 }, 92 { "SiS735", PCI_DEVICE_ID_SI_735, ATA_100 },
92 { "SiS733", PCI_DEVICE_ID_SI_733, ATA_100 }, 93 { "SiS733", PCI_DEVICE_ID_SI_733, ATA_100 },
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index ea0806c82be0..8a5c7b286b2b 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -399,34 +399,6 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c
399 return dev->irq; 399 return dev->irq;
400} 400}
401 401
402static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
403{
404 unsigned int rev;
405 u8 dma_state;
406
407 DBG(("init_dma_sl82c105(hwif: ide%d, dma_base: 0x%08x)\n", hwif->index, dma_base));
408
409 hwif->autodma = 0;
410
411 if (!dma_base)
412 return;
413
414 dma_state = hwif->INB(dma_base + 2);
415 rev = sl82c105_bridge_revision(hwif->pci_dev);
416 if (rev <= 5) {
417 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
418 hwif->name, rev);
419 dma_state &= ~0x60;
420 } else {
421 dma_state |= 0x60;
422 if (!noautodma)
423 hwif->autodma = 1;
424 }
425 hwif->OUTB(dma_state, dma_base + 2);
426
427 ide_setup_dma(hwif, dma_base, 8);
428}
429
430/* 402/*
431 * Initialise the chip 403 * Initialise the chip
432 */ 404 */
@@ -434,6 +406,8 @@ static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base
434static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) 406static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
435{ 407{
436 struct pci_dev *dev = hwif->pci_dev; 408 struct pci_dev *dev = hwif->pci_dev;
409 unsigned int rev;
410 u8 dma_state;
437 u32 val; 411 u32 val;
438 412
439 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); 413 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
@@ -455,33 +429,54 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
455 pci_read_config_dword(dev, 0x40, &val); 429 pci_read_config_dword(dev, 0x40, &val);
456 *((u32 *)&hwif->hwif_data) = val; 430 *((u32 *)&hwif->hwif_data) = val;
457 431
432 hwif->atapi_dma = 0;
433 hwif->mwdma_mask = 0;
434 hwif->swdma_mask = 0;
435 hwif->autodma = 0;
436
458 if (!hwif->dma_base) 437 if (!hwif->dma_base)
459 return; 438 return;
460 439
461 hwif->atapi_dma = 1; 440 dma_state = hwif->INB(hwif->dma_base + 2) & ~0x60;
462 hwif->mwdma_mask = 0x07; 441 rev = sl82c105_bridge_revision(hwif->pci_dev);
463 hwif->swdma_mask = 0x07; 442 if (rev <= 5) {
464 443 /*
444 * Never ever EVER under any circumstances enable
445 * DMA when the bridge is this old.
446 */
447 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
448 hwif->name, rev);
449 } else {
465#ifdef CONFIG_BLK_DEV_IDEDMA 450#ifdef CONFIG_BLK_DEV_IDEDMA
466 hwif->ide_dma_check = &sl82c105_check_drive; 451 dma_state |= 0x60;
467 hwif->ide_dma_on = &sl82c105_ide_dma_on; 452
468 hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly; 453 hwif->atapi_dma = 1;
469 hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq; 454 hwif->mwdma_mask = 0x07;
470 hwif->dma_start = &sl82c105_ide_dma_start; 455 hwif->swdma_mask = 0x07;
471 hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout; 456
472 457 hwif->ide_dma_check = &sl82c105_check_drive;
473 if (!noautodma) 458 hwif->ide_dma_on = &sl82c105_ide_dma_on;
474 hwif->autodma = 1; 459 hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly;
475 hwif->drives[0].autodma = hwif->autodma; 460 hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq;
476 hwif->drives[1].autodma = hwif->autodma; 461 hwif->dma_start = &sl82c105_ide_dma_start;
462 hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout;
463
464 if (!noautodma)
465 hwif->autodma = 1;
466 hwif->drives[0].autodma = hwif->autodma;
467 hwif->drives[1].autodma = hwif->autodma;
468
469 if (hwif->mate)
470 hwif->serialized = hwif->mate->serialized = 1;
477#endif /* CONFIG_BLK_DEV_IDEDMA */ 471#endif /* CONFIG_BLK_DEV_IDEDMA */
472 }
473 hwif->OUTB(dma_state, hwif->dma_base + 2);
478} 474}
479 475
480static ide_pci_device_t sl82c105_chipset __devinitdata = { 476static ide_pci_device_t sl82c105_chipset __devinitdata = {
481 .name = "W82C105", 477 .name = "W82C105",
482 .init_chipset = init_chipset_sl82c105, 478 .init_chipset = init_chipset_sl82c105,
483 .init_hwif = init_hwif_sl82c105, 479 .init_hwif = init_hwif_sl82c105,
484 .init_dma = init_dma_sl82c105,
485 .channels = 2, 480 .channels = 2,
486 .autodma = NOAUTODMA, 481 .autodma = NOAUTODMA,
487 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, 482 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index a4d099c937ff..86fb1e0286d3 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -79,6 +79,8 @@ static struct via_isa_bridge {
79 u8 rev_max; 79 u8 rev_max;
80 u16 flags; 80 u16 flags;
81} via_isa_bridges[] = { 81} via_isa_bridges[] = {
82 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
83 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
82 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 84 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
83 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 85 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
84 { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 86 { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
@@ -100,185 +102,14 @@ static struct via_isa_bridge {
100 { NULL } 102 { NULL }
101}; 103};
102 104
103static struct via_isa_bridge *via_config;
104static unsigned int via_80w;
105static unsigned int via_clock; 105static unsigned int via_clock;
106static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; 106static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" };
107 107
108/* 108struct via82cxxx_dev
109 * VIA /proc entry.
110 */
111
112#if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS)
113
114#include <linux/stat.h>
115#include <linux/proc_fs.h>
116
117static u8 via_proc = 0;
118static unsigned long via_base;
119static struct pci_dev *bmide_dev, *isa_dev;
120
121static char *via_control3[] = { "No limit", "64", "128", "192" };
122
123#define via_print(format, arg...) p += sprintf(p, format "\n" , ## arg)
124#define via_print_drive(name, format, arg...)\
125 p += sprintf(p, name); for (i = 0; i < 4; i++) p += sprintf(p, format, ## arg); p += sprintf(p, "\n");
126
127
128/**
129 * via_get_info - generate via /proc file
130 * @buffer: buffer for data
131 * @addr: set to start of data to use
132 * @offset: current file offset
133 * @count: size of read
134 *
135 * Fills in buffer with the debugging/configuration information for
136 * the VIA chipset tuning and attached drives
137 */
138
139static int via_get_info(char *buffer, char **addr, off_t offset, int count)
140{ 109{
141 int speed[4], cycle[4], setup[4], active[4], recover[4], den[4], 110 struct via_isa_bridge *via_config;
142 uen[4], udma[4], umul[4], active8b[4], recover8b[4]; 111 unsigned int via_80w;
143 struct pci_dev *dev = bmide_dev; 112};
144 unsigned int v, u, i;
145 int len;
146 u16 c, w;
147 u8 t, x;
148 char *p = buffer;
149
150 via_print("----------VIA BusMastering IDE Configuration"
151 "----------------");
152
153 via_print("Driver Version: 3.38");
154 via_print("South Bridge: VIA %s",
155 via_config->name);
156
157 pci_read_config_byte(isa_dev, PCI_REVISION_ID, &t);
158 pci_read_config_byte(dev, PCI_REVISION_ID, &x);
159 via_print("Revision: ISA %#x IDE %#x", t, x);
160 via_print("Highest DMA rate: %s",
161 via_dma[via_config->flags & VIA_UDMA]);
162
163 via_print("BM-DMA base: %#lx", via_base);
164 via_print("PCI clock: %d.%dMHz",
165 via_clock / 1000, via_clock / 100 % 10);
166
167 pci_read_config_byte(dev, VIA_MISC_1, &t);
168 via_print("Master Read Cycle IRDY: %dws",
169 (t & 64) >> 6);
170 via_print("Master Write Cycle IRDY: %dws",
171 (t & 32) >> 5);
172 via_print("BM IDE Status Register Read Retry: %s",
173 (t & 8) ? "yes" : "no");
174
175 pci_read_config_byte(dev, VIA_MISC_3, &t);
176 via_print("Max DRDY Pulse Width: %s%s",
177 via_control3[(t & 0x03)], (t & 0x03) ? " PCI clocks" : "");
178
179 via_print("-----------------------Primary IDE"
180 "-------Secondary IDE------");
181 via_print("Read DMA FIFO flush: %10s%20s",
182 (t & 0x80) ? "yes" : "no", (t & 0x40) ? "yes" : "no");
183 via_print("End Sector FIFO flush: %10s%20s",
184 (t & 0x20) ? "yes" : "no", (t & 0x10) ? "yes" : "no");
185
186 pci_read_config_byte(dev, VIA_IDE_CONFIG, &t);
187 via_print("Prefetch Buffer: %10s%20s",
188 (t & 0x80) ? "yes" : "no", (t & 0x20) ? "yes" : "no");
189 via_print("Post Write Buffer: %10s%20s",
190 (t & 0x40) ? "yes" : "no", (t & 0x10) ? "yes" : "no");
191
192 pci_read_config_byte(dev, VIA_IDE_ENABLE, &t);
193 via_print("Enabled: %10s%20s",
194 (t & 0x02) ? "yes" : "no", (t & 0x01) ? "yes" : "no");
195
196 c = inb(via_base + 0x02) | (inb(via_base + 0x0a) << 8);
197 via_print("Simplex only: %10s%20s",
198 (c & 0x80) ? "yes" : "no", (c & 0x8000) ? "yes" : "no");
199
200 via_print("Cable Type: %10s%20s",
201 (via_80w & 1) ? "80w" : "40w", (via_80w & 2) ? "80w" : "40w");
202
203 via_print("-------------------drive0----drive1"
204 "----drive2----drive3-----");
205
206 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t);
207 pci_read_config_dword(dev, VIA_DRIVE_TIMING, &v);
208 pci_read_config_word(dev, VIA_8BIT_TIMING, &w);
209
210 if (via_config->flags & VIA_UDMA)
211 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
212 else u = 0;
213
214 for (i = 0; i < 4; i++) {
215
216 setup[i] = ((t >> ((3 - i) << 1)) & 0x3) + 1;
217 recover8b[i] = ((w >> ((1 - (i >> 1)) << 3)) & 0xf) + 1;
218 active8b[i] = ((w >> (((1 - (i >> 1)) << 3) + 4)) & 0xf) + 1;
219 active[i] = ((v >> (((3 - i) << 3) + 4)) & 0xf) + 1;
220 recover[i] = ((v >> ((3 - i) << 3)) & 0xf) + 1;
221 udma[i] = ((u >> ((3 - i) << 3)) & 0x7) + 2;
222 umul[i] = ((u >> (((3 - i) & 2) << 3)) & 0x8) ? 1 : 2;
223 uen[i] = ((u >> ((3 - i) << 3)) & 0x20);
224 den[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2));
225
226 speed[i] = 2 * via_clock / (active[i] + recover[i]);
227 cycle[i] = 1000000 * (active[i] + recover[i]) / via_clock;
228
229 if (!uen[i] || !den[i])
230 continue;
231
232 switch (via_config->flags & VIA_UDMA) {
233
234 case VIA_UDMA_33:
235 speed[i] = 2 * via_clock / udma[i];
236 cycle[i] = 1000000 * udma[i] / via_clock;
237 break;
238
239 case VIA_UDMA_66:
240 speed[i] = 4 * via_clock / (udma[i] * umul[i]);
241 cycle[i] = 500000 * (udma[i] * umul[i]) / via_clock;
242 break;
243
244 case VIA_UDMA_100:
245 speed[i] = 6 * via_clock / udma[i];
246 cycle[i] = 333333 * udma[i] / via_clock;
247 break;
248
249 case VIA_UDMA_133:
250 speed[i] = 8 * via_clock / udma[i];
251 cycle[i] = 250000 * udma[i] / via_clock;
252 break;
253 }
254 }
255
256 via_print_drive("Transfer Mode: ", "%10s",
257 den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO");
258
259 via_print_drive("Address Setup: ", "%8dns",
260 1000000 * setup[i] / via_clock);
261 via_print_drive("Cmd Active: ", "%8dns",
262 1000000 * active8b[i] / via_clock);
263 via_print_drive("Cmd Recovery: ", "%8dns",
264 1000000 * recover8b[i] / via_clock);
265 via_print_drive("Data Active: ", "%8dns",
266 1000000 * active[i] / via_clock);
267 via_print_drive("Data Recovery: ", "%8dns",
268 1000000 * recover[i] / via_clock);
269 via_print_drive("Cycle Time: ", "%8dns",
270 cycle[i]);
271 via_print_drive("Transfer Rate: ", "%4d.%dMB/s",
272 speed[i] / 1000, speed[i] / 100 % 10);
273
274 /* hoping it is less than 4K... */
275 len = (p - buffer) - offset;
276 *addr = buffer + offset;
277
278 return len > count ? count : len;
279}
280
281#endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */
282 113
283/** 114/**
284 * via_set_speed - write timing registers 115 * via_set_speed - write timing registers
@@ -289,11 +120,13 @@ static int via_get_info(char *buffer, char **addr, off_t offset, int count)
289 * via_set_speed writes timing values to the chipset registers 120 * via_set_speed writes timing values to the chipset registers
290 */ 121 */
291 122
292static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing) 123static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing)
293{ 124{
125 struct pci_dev *dev = hwif->pci_dev;
126 struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif);
294 u8 t; 127 u8 t;
295 128
296 if (~via_config->flags & VIA_BAD_AST) { 129 if (~vdev->via_config->flags & VIA_BAD_AST) {
297 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); 130 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t);
298 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); 131 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1));
299 pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); 132 pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t);
@@ -305,7 +138,7 @@ static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing)
305 pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), 138 pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn),
306 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); 139 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1));
307 140
308 switch (via_config->flags & VIA_UDMA) { 141 switch (vdev->via_config->flags & VIA_UDMA) {
309 case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; 142 case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break;
310 case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; 143 case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break;
311 case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; 144 case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break;
@@ -329,6 +162,7 @@ static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing)
329static int via_set_drive(ide_drive_t *drive, u8 speed) 162static int via_set_drive(ide_drive_t *drive, u8 speed)
330{ 163{
331 ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); 164 ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1);
165 struct via82cxxx_dev *vdev = ide_get_hwifdata(drive->hwif);
332 struct ide_timing t, p; 166 struct ide_timing t, p;
333 unsigned int T, UT; 167 unsigned int T, UT;
334 168
@@ -337,7 +171,7 @@ static int via_set_drive(ide_drive_t *drive, u8 speed)
337 171
338 T = 1000000000 / via_clock; 172 T = 1000000000 / via_clock;
339 173
340 switch (via_config->flags & VIA_UDMA) { 174 switch (vdev->via_config->flags & VIA_UDMA) {
341 case VIA_UDMA_33: UT = T; break; 175 case VIA_UDMA_33: UT = T; break;
342 case VIA_UDMA_66: UT = T/2; break; 176 case VIA_UDMA_66: UT = T/2; break;
343 case VIA_UDMA_100: UT = T/3; break; 177 case VIA_UDMA_100: UT = T/3; break;
@@ -352,7 +186,7 @@ static int via_set_drive(ide_drive_t *drive, u8 speed)
352 ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); 186 ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT);
353 } 187 }
354 188
355 via_set_speed(HWIF(drive)->pci_dev, drive->dn, &t); 189 via_set_speed(HWIF(drive), drive->dn, &t);
356 190
357 if (!drive->init_speed) 191 if (!drive->init_speed)
358 drive->init_speed = speed; 192 drive->init_speed = speed;
@@ -390,20 +224,41 @@ static void via82cxxx_tune_drive(ide_drive_t *drive, u8 pio)
390 224
391static int via82cxxx_ide_dma_check (ide_drive_t *drive) 225static int via82cxxx_ide_dma_check (ide_drive_t *drive)
392{ 226{
393 u16 w80 = HWIF(drive)->udma_four; 227 ide_hwif_t *hwif = HWIF(drive);
228 struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif);
229 u16 w80 = hwif->udma_four;
394 230
395 u16 speed = ide_find_best_mode(drive, 231 u16 speed = ide_find_best_mode(drive,
396 XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | 232 XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA |
397 (via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | 233 (vdev->via_config->flags & VIA_UDMA ? XFER_UDMA : 0) |
398 (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | 234 (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) |
399 (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | 235 (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) |
400 (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); 236 (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0));
401 237
402 via_set_drive(drive, speed); 238 via_set_drive(drive, speed);
403 239
404 if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) 240 if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
405 return HWIF(drive)->ide_dma_on(drive); 241 return hwif->ide_dma_on(drive);
406 return HWIF(drive)->ide_dma_off_quietly(drive); 242 return hwif->ide_dma_off_quietly(drive);
243}
244
245static struct via_isa_bridge *via_config_find(struct pci_dev **isa)
246{
247 struct via_isa_bridge *via_config;
248 u8 t;
249
250 for (via_config = via_isa_bridges; via_config->id; via_config++)
251 if ((*isa = pci_find_device(PCI_VENDOR_ID_VIA +
252 !!(via_config->flags & VIA_BAD_ID),
253 via_config->id, NULL))) {
254
255 pci_read_config_byte(*isa, PCI_REVISION_ID, &t);
256 if (t >= via_config->rev_min &&
257 t <= via_config->rev_max)
258 break;
259 }
260
261 return via_config;
407} 262}
408 263
409/** 264/**
@@ -418,82 +273,28 @@ static int via82cxxx_ide_dma_check (ide_drive_t *drive)
418static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name) 273static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name)
419{ 274{
420 struct pci_dev *isa = NULL; 275 struct pci_dev *isa = NULL;
276 struct via_isa_bridge *via_config;
421 u8 t, v; 277 u8 t, v;
422 unsigned int u; 278 unsigned int u;
423 int i;
424 279
425 /* 280 /*
426 * Find the ISA bridge to see how good the IDE is. 281 * Find the ISA bridge to see how good the IDE is.
427 */ 282 */
428 283 via_config = via_config_find(&isa);
429 for (via_config = via_isa_bridges; via_config->id; via_config++)
430 if ((isa = pci_find_device(PCI_VENDOR_ID_VIA +
431 !!(via_config->flags & VIA_BAD_ID),
432 via_config->id, NULL))) {
433
434 pci_read_config_byte(isa, PCI_REVISION_ID, &t);
435 if (t >= via_config->rev_min &&
436 t <= via_config->rev_max)
437 break;
438 }
439
440 if (!via_config->id) { 284 if (!via_config->id) {
441 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 285 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
442 return -ENODEV; 286 return -ENODEV;
443 } 287 }
444 288
445 /* 289 /*
446 * Check 80-wire cable presence and setup Clk66. 290 * Setup or disable Clk66 if appropriate
447 */ 291 */
448 292
449 switch (via_config->flags & VIA_UDMA) { 293 if ((via_config->flags & VIA_UDMA) == VIA_UDMA_66) {
450 294 /* Enable Clk66 */
451 case VIA_UDMA_66: 295 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
452 /* Enable Clk66 */ 296 pci_write_config_dword(dev, VIA_UDMA_TIMING, u|0x80008);
453 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); 297 } else if (via_config->flags & VIA_BAD_CLK66) {
454 pci_write_config_dword(dev, VIA_UDMA_TIMING, u|0x80008);
455 for (i = 24; i >= 0; i -= 8)
456 if (((u >> (i & 16)) & 8) &&
457 ((u >> i) & 0x20) &&
458 (((u >> i) & 7) < 2)) {
459 /*
460 * 2x PCI clock and
461 * UDMA w/ < 3T/cycle
462 */
463 via_80w |= (1 << (1 - (i >> 4)));
464 }
465 break;
466
467 case VIA_UDMA_100:
468 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
469 for (i = 24; i >= 0; i -= 8)
470 if (((u >> i) & 0x10) ||
471 (((u >> i) & 0x20) &&
472 (((u >> i) & 7) < 4))) {
473 /* BIOS 80-wire bit or
474 * UDMA w/ < 60ns/cycle
475 */
476 via_80w |= (1 << (1 - (i >> 4)));
477 }
478 break;
479
480 case VIA_UDMA_133:
481 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
482 for (i = 24; i >= 0; i -= 8)
483 if (((u >> i) & 0x10) ||
484 (((u >> i) & 0x20) &&
485 (((u >> i) & 7) < 6))) {
486 /* BIOS 80-wire bit or
487 * UDMA w/ < 60ns/cycle
488 */
489 via_80w |= (1 << (1 - (i >> 4)));
490 }
491 break;
492
493 }
494
495 /* Disable Clk66 */
496 if (via_config->flags & VIA_BAD_CLK66) {
497 /* Would cause trouble on 596a and 686 */ 298 /* Would cause trouble on 596a and 686 */
498 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); 299 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
499 pci_write_config_dword(dev, VIA_UDMA_TIMING, u & ~0x80008); 300 pci_write_config_dword(dev, VIA_UDMA_TIMING, u & ~0x80008);
@@ -560,26 +361,78 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
560 via_dma[via_config->flags & VIA_UDMA], 361 via_dma[via_config->flags & VIA_UDMA],
561 pci_name(dev)); 362 pci_name(dev));
562 363
563 /* 364 return 0;
564 * Setup /proc/ide/via entry. 365}
565 */ 366
367/*
368 * Check and handle 80-wire cable presence
369 */
370static void __devinit via_cable_detect(struct pci_dev *dev, struct via82cxxx_dev *vdev)
371{
372 unsigned int u;
373 int i;
374 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
375
376 switch (vdev->via_config->flags & VIA_UDMA) {
377
378 case VIA_UDMA_66:
379 for (i = 24; i >= 0; i -= 8)
380 if (((u >> (i & 16)) & 8) &&
381 ((u >> i) & 0x20) &&
382 (((u >> i) & 7) < 2)) {
383 /*
384 * 2x PCI clock and
385 * UDMA w/ < 3T/cycle
386 */
387 vdev->via_80w |= (1 << (1 - (i >> 4)));
388 }
389 break;
390
391 case VIA_UDMA_100:
392 for (i = 24; i >= 0; i -= 8)
393 if (((u >> i) & 0x10) ||
394 (((u >> i) & 0x20) &&
395 (((u >> i) & 7) < 4))) {
396 /* BIOS 80-wire bit or
397 * UDMA w/ < 60ns/cycle
398 */
399 vdev->via_80w |= (1 << (1 - (i >> 4)));
400 }
401 break;
402
403 case VIA_UDMA_133:
404 for (i = 24; i >= 0; i -= 8)
405 if (((u >> i) & 0x10) ||
406 (((u >> i) & 0x20) &&
407 (((u >> i) & 7) < 6))) {
408 /* BIOS 80-wire bit or
409 * UDMA w/ < 60ns/cycle
410 */
411 vdev->via_80w |= (1 << (1 - (i >> 4)));
412 }
413 break;
566 414
567#if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS)
568 if (!via_proc) {
569 via_base = pci_resource_start(dev, 4);
570 bmide_dev = dev;
571 isa_dev = isa;
572 ide_pci_create_host_proc("via", via_get_info);
573 via_proc = 1;
574 } 415 }
575#endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */
576 return 0;
577} 416}
578 417
579static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) 418static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
580{ 419{
420 struct via82cxxx_dev *vdev = kmalloc(sizeof(struct via82cxxx_dev),
421 GFP_KERNEL);
422 struct pci_dev *isa = NULL;
581 int i; 423 int i;
582 424
425 if (vdev == NULL) {
426 printk(KERN_ERR "VP_IDE: out of memory :(\n");
427 return;
428 }
429
430 memset(vdev, 0, sizeof(struct via82cxxx_dev));
431 ide_set_hwifdata(hwif, vdev);
432
433 vdev->via_config = via_config_find(&isa);
434 via_cable_detect(hwif->pci_dev, vdev);
435
583 hwif->autodma = 0; 436 hwif->autodma = 0;
584 437
585 hwif->tuneproc = &via82cxxx_tune_drive; 438 hwif->tuneproc = &via82cxxx_tune_drive;
@@ -594,7 +447,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
594 447
595 for (i = 0; i < 2; i++) { 448 for (i = 0; i < 2; i++) {
596 hwif->drives[i].io_32bit = 1; 449 hwif->drives[i].io_32bit = 1;
597 hwif->drives[i].unmask = (via_config->flags & VIA_NO_UNMASK) ? 0 : 1; 450 hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1;
598 hwif->drives[i].autotune = 1; 451 hwif->drives[i].autotune = 1;
599 hwif->drives[i].dn = hwif->channel * 2 + i; 452 hwif->drives[i].dn = hwif->channel * 2 + i;
600 } 453 }
@@ -608,7 +461,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
608 hwif->swdma_mask = 0x07; 461 hwif->swdma_mask = 0x07;
609 462
610 if (!hwif->udma_four) 463 if (!hwif->udma_four)
611 hwif->udma_four = (via_80w >> hwif->channel) & 1; 464 hwif->udma_four = (vdev->via_80w >> hwif->channel) & 1;
612 hwif->ide_dma_check = &via82cxxx_ide_dma_check; 465 hwif->ide_dma_check = &via82cxxx_ide_dma_check;
613 if (!noautodma) 466 if (!noautodma)
614 hwif->autodma = 1; 467 hwif->autodma = 1;
@@ -616,24 +469,35 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
616 hwif->drives[1].autodma = hwif->autodma; 469 hwif->drives[1].autodma = hwif->autodma;
617} 470}
618 471
619static ide_pci_device_t via82cxxx_chipset __devinitdata = { 472static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
620 .name = "VP_IDE", 473 { /* 0 */
621 .init_chipset = init_chipset_via82cxxx, 474 .name = "VP_IDE",
622 .init_hwif = init_hwif_via82cxxx, 475 .init_chipset = init_chipset_via82cxxx,
623 .channels = 2, 476 .init_hwif = init_hwif_via82cxxx,
624 .autodma = NOAUTODMA, 477 .channels = 2,
625 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, 478 .autodma = NOAUTODMA,
626 .bootable = ON_BOARD, 479 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
480 .bootable = ON_BOARD
481 },{ /* 1 */
482 .name = "VP_IDE",
483 .init_chipset = init_chipset_via82cxxx,
484 .init_hwif = init_hwif_via82cxxx,
485 .channels = 2,
486 .autodma = AUTODMA,
487 .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
488 .bootable = ON_BOARD,
489 }
627}; 490};
628 491
629static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) 492static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
630{ 493{
631 return ide_setup_pci_device(dev, &via82cxxx_chipset); 494 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
632} 495}
633 496
634static struct pci_device_id via_pci_tbl[] = { 497static struct pci_device_id via_pci_tbl[] = {
635 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 498 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
636 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 499 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
500 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_6410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
637 { 0, }, 501 { 0, },
638}; 502};
639MODULE_DEVICE_TABLE(pci, via_pci_tbl); 503MODULE_DEVICE_TABLE(pci, via_pci_tbl);
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index b3e65a65d202..16b28357885b 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1401,20 +1401,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1401 /* We probe the hwif now */ 1401 /* We probe the hwif now */
1402 probe_hwif_init(hwif); 1402 probe_hwif_init(hwif);
1403 1403
1404 /* The code IDE code will have set hwif->present if we have devices attached,
1405 * if we don't, the discard the interface except if we are on a media bay slot
1406 */
1407 if (!hwif->present && !pmif->mediabay) {
1408 printk(KERN_INFO "ide%d: Bus empty, interface released.\n",
1409 hwif->index);
1410 default_hwif_iops(hwif);
1411 for (i = IDE_DATA_OFFSET; i <= IDE_CONTROL_OFFSET; ++i)
1412 hwif->io_ports[i] = 0;
1413 hwif->chipset = ide_unknown;
1414 hwif->noprobe = 1;
1415 return -ENODEV;
1416 }
1417
1418 return 0; 1404 return 0;
1419} 1405}
1420 1406
@@ -1667,11 +1653,16 @@ static struct macio_driver pmac_ide_macio_driver =
1667}; 1653};
1668 1654
1669static struct pci_device_id pmac_ide_pci_match[] = { 1655static struct pci_device_id pmac_ide_pci_match[] = {
1670 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1656 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA,
1671 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1657 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1672 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1658 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100,
1659 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1660 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100,
1661 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1673 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_ATA, 1662 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_ATA,
1674 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1663 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1664 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_ATA,
1665 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1675}; 1666};
1676 1667
1677static struct pci_driver pmac_ide_pci_driver = { 1668static struct pci_driver pmac_ide_pci_driver = {
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 18ed7765417c..7ebf992e8c2f 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -787,8 +787,9 @@ static int pre_init = 1; /* Before first ordered IDE scan */
787static LIST_HEAD(ide_pci_drivers); 787static LIST_HEAD(ide_pci_drivers);
788 788
789/* 789/*
790 * ide_register_pci_driver - attach IDE driver 790 * __ide_pci_register_driver - attach IDE driver
791 * @driver: pci driver 791 * @driver: pci driver
792 * @module: owner module of the driver
792 * 793 *
793 * Registers a driver with the IDE layer. The IDE layer arranges that 794 * Registers a driver with the IDE layer. The IDE layer arranges that
794 * boot time setup is done in the expected device order and then 795 * boot time setup is done in the expected device order and then
@@ -801,15 +802,16 @@ static LIST_HEAD(ide_pci_drivers);
801 * Returns are the same as for pci_register_driver 802 * Returns are the same as for pci_register_driver
802 */ 803 */
803 804
804int ide_pci_register_driver(struct pci_driver *driver) 805int __ide_pci_register_driver(struct pci_driver *driver, struct module *module)
805{ 806{
806 if(!pre_init) 807 if(!pre_init)
807 return pci_module_init(driver); 808 return __pci_register_driver(driver, module);
809 driver->driver.owner = module;
808 list_add_tail(&driver->node, &ide_pci_drivers); 810 list_add_tail(&driver->node, &ide_pci_drivers);
809 return 0; 811 return 0;
810} 812}
811 813
812EXPORT_SYMBOL_GPL(ide_pci_register_driver); 814EXPORT_SYMBOL_GPL(__ide_pci_register_driver);
813 815
814/** 816/**
815 * ide_unregister_pci_driver - unregister an IDE driver 817 * ide_unregister_pci_driver - unregister an IDE driver
@@ -897,6 +899,6 @@ void __init ide_scan_pcibus (int scan_direction)
897 { 899 {
898 list_del(l); 900 list_del(l);
899 d = list_entry(l, struct pci_driver, node); 901 d = list_entry(l, struct pci_driver, node);
900 pci_register_driver(d); 902 __pci_register_driver(d, d->driver.owner);
901 } 903 }
902} 904}