aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ioctl/hdio.txt7
-rw-r--r--drivers/block/Kconfig12
-rw-r--r--drivers/block/Makefile1
-rw-r--r--drivers/block/hd.c (renamed from drivers/ide/legacy/hd.c)3
-rw-r--r--drivers/ide/Kconfig88
-rw-r--r--drivers/ide/Makefile10
-rw-r--r--drivers/ide/arm/Makefile1
-rw-r--r--drivers/ide/arm/bast-ide.c90
-rw-r--r--drivers/ide/arm/icside.c105
-rw-r--r--drivers/ide/arm/palm_bk3710.c3
-rw-r--r--drivers/ide/arm/rapide.c33
-rw-r--r--drivers/ide/h8300/ide-h8300.c19
-rw-r--r--drivers/ide/ide-cd.c160
-rw-r--r--drivers/ide/ide-disk.c1
-rw-r--r--drivers/ide/ide-floppy.c32
-rw-r--r--drivers/ide/ide-io.c72
-rw-r--r--drivers/ide/ide-iops.c24
-rw-r--r--drivers/ide/ide-lib.c151
-rw-r--r--drivers/ide/ide-pio-blacklist.c94
-rw-r--r--drivers/ide/ide-pnp.c4
-rw-r--r--drivers/ide/ide-probe.c21
-rw-r--r--drivers/ide/ide-tape.c1
-rw-r--r--drivers/ide/ide-taskfile.c33
-rw-r--r--drivers/ide/ide-timings.c (renamed from drivers/ide/ide-timing.h)204
-rw-r--r--drivers/ide/ide.c76
-rw-r--r--drivers/ide/legacy/ali14xx.c3
-rw-r--r--drivers/ide/legacy/buddha.c1
-rw-r--r--drivers/ide/legacy/falconide.c1
-rw-r--r--drivers/ide/legacy/gayle.c1
-rw-r--r--drivers/ide/legacy/ht6560b.c15
-rw-r--r--drivers/ide/legacy/ide-4drives.c25
-rw-r--r--drivers/ide/legacy/ide-cs.c9
-rw-r--r--drivers/ide/legacy/ide_platform.c9
-rw-r--r--drivers/ide/legacy/macide.c1
-rw-r--r--drivers/ide/legacy/q40ide.c1
-rw-r--r--drivers/ide/legacy/qd65xx.c19
-rw-r--r--drivers/ide/mips/au1xxx-ide.c13
-rw-r--r--drivers/ide/mips/swarm.c28
-rw-r--r--drivers/ide/pci/alim15x3.c6
-rw-r--r--drivers/ide/pci/amd74xx.c2
-rw-r--r--drivers/ide/pci/cmd640.c131
-rw-r--r--drivers/ide/pci/cmd64x.c6
-rw-r--r--drivers/ide/pci/cs5535.c6
-rw-r--r--drivers/ide/pci/cy82c693.c9
-rw-r--r--drivers/ide/pci/delkin_cb.c1
-rw-r--r--drivers/ide/pci/it821x.c6
-rw-r--r--drivers/ide/pci/scc_pata.c8
-rw-r--r--drivers/ide/pci/sgiioc4.c23
-rw-r--r--drivers/ide/pci/siimage.c3
-rw-r--r--drivers/ide/pci/sis5513.c3
-rw-r--r--drivers/ide/pci/sl82c105.c3
-rw-r--r--drivers/ide/pci/via82cxxx.c2
-rw-r--r--drivers/ide/ppc/Makefile1
-rw-r--r--drivers/ide/ppc/mpc8xx.c851
-rw-r--r--drivers/ide/ppc/pmac.c21
-rw-r--r--drivers/ide/setup-pci.c25
-rw-r--r--drivers/scsi/ide-scsi.c14
-rw-r--r--include/linux/ide.h74
58 files changed, 695 insertions, 1871 deletions
diff --git a/Documentation/ioctl/hdio.txt b/Documentation/ioctl/hdio.txt
index c19efdeace2c..91a6ecbae0bb 100644
--- a/Documentation/ioctl/hdio.txt
+++ b/Documentation/ioctl/hdio.txt
@@ -508,12 +508,13 @@ HDIO_DRIVE_RESET execute a device reset
508 508
509 error returns: 509 error returns:
510 EACCES Access denied: requires CAP_SYS_ADMIN 510 EACCES Access denied: requires CAP_SYS_ADMIN
511 ENXIO No such device: phy dead or ctl_addr == 0
512 EIO I/O error: reset timed out or hardware error
511 513
512 notes: 514 notes:
513 515
514 Abort any current command, prevent anything else from being 516 Execute a reset on the device as soon as the current IO
515 queued, execute a reset on the device, and issue BLKRRPART 517 operation has completed.
516 ioctl on the block device.
517 518
518 Executes an ATAPI soft reset if applicable, otherwise 519 Executes an ATAPI soft reset if applicable, otherwise
519 executes an ATA soft reset on the controller. 520 executes an ATA soft reset on the controller.
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 0d1d2133d9bc..61ad8d639ba3 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -433,4 +433,16 @@ config VIRTIO_BLK
433 This is the virtual block driver for virtio. It can be used with 433 This is the virtual block driver for virtio. It can be used with
434 lguest or QEMU based VMMs (like KVM or Xen). Say Y or M. 434 lguest or QEMU based VMMs (like KVM or Xen). Say Y or M.
435 435
436config BLK_DEV_HD
437 bool "Very old hard disk (MFM/RLL/IDE) driver"
438 depends on HAVE_IDE
439 depends on !ARM || ARCH_RPC || ARCH_SHARK || BROKEN
440 help
441 This is a very old hard disk driver that lacks the enhanced
442 functionality of the newer ones.
443
444 It is required for systems with ancient MFM/RLL/ESDI drives.
445
446 If unsure, say N.
447
436endif # BLK_DEV 448endif # BLK_DEV
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 5e584306be99..204332b29578 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -29,5 +29,6 @@ obj-$(CONFIG_VIRTIO_BLK) += virtio_blk.o
29obj-$(CONFIG_VIODASD) += viodasd.o 29obj-$(CONFIG_VIODASD) += viodasd.o
30obj-$(CONFIG_BLK_DEV_SX8) += sx8.o 30obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
31obj-$(CONFIG_BLK_DEV_UB) += ub.o 31obj-$(CONFIG_BLK_DEV_UB) += ub.o
32obj-$(CONFIG_BLK_DEV_HD) += hd.o
32 33
33obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o 34obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
diff --git a/drivers/ide/legacy/hd.c b/drivers/block/hd.c
index abdedf56643e..682243bf2e46 100644
--- a/drivers/ide/legacy/hd.c
+++ b/drivers/block/hd.c
@@ -37,7 +37,6 @@
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/string.h> 38#include <linux/string.h>
39#include <linux/ioport.h> 39#include <linux/ioport.h>
40#include <linux/mc146818rtc.h> /* CMOS defines */
41#include <linux/init.h> 40#include <linux/init.h>
42#include <linux/blkpg.h> 41#include <linux/blkpg.h>
43#include <linux/hdreg.h> 42#include <linux/hdreg.h>
@@ -812,4 +811,4 @@ static int __init parse_hd_setup(char *line)
812} 811}
813__setup("hd=", parse_hd_setup); 812__setup("hd=", parse_hd_setup);
814 813
815module_init(hd_init); 814late_initcall(hd_init);
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index cf707c8f08d4..15b09b89588a 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -98,6 +98,9 @@ if BLK_DEV_IDE
98 98
99comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" 99comment "Please see Documentation/ide/ide.txt for help/info on IDE drives"
100 100
101config IDE_TIMINGS
102 bool
103
101config IDE_ATAPI 104config IDE_ATAPI
102 bool 105 bool
103 106
@@ -326,6 +329,7 @@ config BLK_DEV_PLATFORM
326config BLK_DEV_CMD640 329config BLK_DEV_CMD640
327 tristate "CMD640 chipset bugfix/support" 330 tristate "CMD640 chipset bugfix/support"
328 depends on X86 331 depends on X86
332 select IDE_TIMINGS
329 ---help--- 333 ---help---
330 The CMD-Technologies CMD640 IDE chip is used on many common 486 and 334 The CMD-Technologies CMD640 IDE chip is used on many common 486 and
331 Pentium motherboards, usually in combination with a "Neptune" or 335 Pentium motherboards, usually in combination with a "Neptune" or
@@ -455,6 +459,7 @@ config BLK_DEV_AEC62XX
455 459
456config BLK_DEV_ALI15X3 460config BLK_DEV_ALI15X3
457 tristate "ALI M15x3 chipset support" 461 tristate "ALI M15x3 chipset support"
462 select IDE_TIMINGS
458 select BLK_DEV_IDEDMA_PCI 463 select BLK_DEV_IDEDMA_PCI
459 help 464 help
460 This driver ensures (U)DMA support for ALI 1533, 1543 and 1543C 465 This driver ensures (U)DMA support for ALI 1533, 1543 and 1543C
@@ -469,6 +474,7 @@ config BLK_DEV_ALI15X3
469config BLK_DEV_AMD74XX 474config BLK_DEV_AMD74XX
470 tristate "AMD and nVidia IDE support" 475 tristate "AMD and nVidia IDE support"
471 depends on !ARM 476 depends on !ARM
477 select IDE_TIMINGS
472 select BLK_DEV_IDEDMA_PCI 478 select BLK_DEV_IDEDMA_PCI
473 help 479 help
474 This driver adds explicit support for AMD-7xx and AMD-8111 chips 480 This driver adds explicit support for AMD-7xx and AMD-8111 chips
@@ -489,6 +495,7 @@ config BLK_DEV_ATIIXP
489 495
490config BLK_DEV_CMD64X 496config BLK_DEV_CMD64X
491 tristate "CMD64{3|6|8|9} chipset support" 497 tristate "CMD64{3|6|8|9} chipset support"
498 select IDE_TIMINGS
492 select BLK_DEV_IDEDMA_PCI 499 select BLK_DEV_IDEDMA_PCI
493 help 500 help
494 Say Y here if you have an IDE controller which uses any of these 501 Say Y here if you have an IDE controller which uses any of these
@@ -503,6 +510,7 @@ config BLK_DEV_TRIFLEX
503 510
504config BLK_DEV_CY82C693 511config BLK_DEV_CY82C693
505 tristate "CY82C693 chipset support" 512 tristate "CY82C693 chipset support"
513 select IDE_TIMINGS
506 select BLK_DEV_IDEDMA_PCI 514 select BLK_DEV_IDEDMA_PCI
507 help 515 help
508 This driver adds detection and support for the CY82C693 chipset 516 This driver adds detection and support for the CY82C693 chipset
@@ -695,6 +703,7 @@ config BLK_DEV_SIS5513
695config BLK_DEV_SL82C105 703config BLK_DEV_SL82C105
696 tristate "Winbond SL82c105 support" 704 tristate "Winbond SL82c105 support"
697 depends on (PPC || ARM) 705 depends on (PPC || ARM)
706 select IDE_TIMINGS
698 select BLK_DEV_IDEDMA_PCI 707 select BLK_DEV_IDEDMA_PCI
699 help 708 help
700 If you have a Winbond SL82c105 IDE controller, say Y here to enable 709 If you have a Winbond SL82c105 IDE controller, say Y here to enable
@@ -725,6 +734,7 @@ config BLK_DEV_TRM290
725 734
726config BLK_DEV_VIA82CXXX 735config BLK_DEV_VIA82CXXX
727 tristate "VIA82CXXX chipset support" 736 tristate "VIA82CXXX chipset support"
737 select IDE_TIMINGS
728 select BLK_DEV_IDEDMA_PCI 738 select BLK_DEV_IDEDMA_PCI
729 help 739 help
730 This driver adds explicit support for VIA BusMastering IDE chips. 740 This driver adds explicit support for VIA BusMastering IDE chips.
@@ -751,6 +761,7 @@ endif
751config BLK_DEV_IDE_PMAC 761config BLK_DEV_IDE_PMAC
752 tristate "PowerMac on-board IDE support" 762 tristate "PowerMac on-board IDE support"
753 depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y 763 depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y
764 select IDE_TIMINGS
754 help 765 help
755 This driver provides support for the on-board IDE controller on 766 This driver provides support for the on-board IDE controller on
756 most of the recent Apple Power Macintoshes and PowerBooks. 767 most of the recent Apple Power Macintoshes and PowerBooks.
@@ -829,13 +840,6 @@ config BLK_DEV_IDE_RAPIDE
829 Say Y here if you want to support the Yellowstone RapIDE controller 840 Say Y here if you want to support the Yellowstone RapIDE controller
830 manufactured for use with Acorn computers. 841 manufactured for use with Acorn computers.
831 842
832config BLK_DEV_IDE_BAST
833 tristate "Simtec BAST / Thorcom VR1000 IDE support"
834 depends on ARM && (ARCH_BAST || MACH_VR1000)
835 help
836 Say Y here if you want to support the onboard IDE channels on the
837 Simtec BAST or the Thorcom VR1000
838
839config IDE_H8300 843config IDE_H8300
840 tristate "H8300 IDE support" 844 tristate "H8300 IDE support"
841 depends on H8300 845 depends on H8300
@@ -919,51 +923,12 @@ config BLK_DEV_Q40IDE
919config BLK_DEV_PALMCHIP_BK3710 923config BLK_DEV_PALMCHIP_BK3710
920 tristate "Palmchip bk3710 IDE controller support" 924 tristate "Palmchip bk3710 IDE controller support"
921 depends on ARCH_DAVINCI 925 depends on ARCH_DAVINCI
926 select IDE_TIMINGS
922 select BLK_DEV_IDEDMA_SFF 927 select BLK_DEV_IDEDMA_SFF
923 help 928 help
924 Say Y here if you want to support the onchip IDE controller on the 929 Say Y here if you want to support the onchip IDE controller on the
925 TI DaVinci SoC 930 TI DaVinci SoC
926 931
927
928config BLK_DEV_MPC8xx_IDE
929 tristate "MPC8xx IDE support"
930 depends on 8xx && (LWMON || IVMS8 || IVML24 || TQM8xxL) && IDE=y && BLK_DEV_IDE=y && !PPC_MERGE
931 help
932 This option provides support for IDE on Motorola MPC8xx Systems.
933 Please see 'Type of MPC8xx IDE interface' for details.
934
935 If unsure, say N.
936
937choice
938 prompt "Type of MPC8xx IDE interface"
939 depends on BLK_DEV_MPC8xx_IDE
940 default IDE_8xx_PCCARD
941
942config IDE_8xx_PCCARD
943 bool "8xx_PCCARD"
944 ---help---
945 Select how the IDE devices are connected to the MPC8xx system:
946
947 8xx_PCCARD uses the 8xx internal PCMCIA interface in combination
948 with a PC Card (e.g. ARGOSY portable Hard Disk Adapter),
949 ATA PC Card HDDs or ATA PC Flash Cards (example: TQM8xxL
950 systems)
951
952 8xx_DIRECT is used for directly connected IDE devices using the 8xx
953 internal PCMCIA interface (example: IVMS8 systems)
954
955 EXT_DIRECT is used for IDE devices directly connected to the 8xx
956 bus using some glue logic, but _not_ the 8xx internal
957 PCMCIA interface (example: IDIF860 systems)
958
959config IDE_8xx_DIRECT
960 bool "8xx_DIRECT"
961
962config IDE_EXT_DIRECT
963 bool "EXT_DIRECT"
964
965endchoice
966
967# no isa -> no vlb 932# no isa -> no vlb
968if ISA && (ALPHA || X86 || MIPS) 933if ISA && (ALPHA || X86 || MIPS)
969 934
@@ -981,6 +946,7 @@ config BLK_DEV_4DRIVES
981 946
982config BLK_DEV_ALI14XX 947config BLK_DEV_ALI14XX
983 tristate "ALI M14xx support" 948 tristate "ALI M14xx support"
949 select IDE_TIMINGS
984 help 950 help
985 This driver is enabled at runtime using the "ali14xx.probe" kernel 951 This driver is enabled at runtime using the "ali14xx.probe" kernel
986 boot parameter. It enables support for the secondary IDE interface 952 boot parameter. It enables support for the secondary IDE interface
@@ -1000,6 +966,7 @@ config BLK_DEV_DTC2278
1000 966
1001config BLK_DEV_HT6560B 967config BLK_DEV_HT6560B
1002 tristate "Holtek HT6560B support" 968 tristate "Holtek HT6560B support"
969 select IDE_TIMINGS
1003 help 970 help
1004 This driver is enabled at runtime using the "ht6560b.probe" kernel 971 This driver is enabled at runtime using the "ht6560b.probe" kernel
1005 boot parameter. It enables support for the secondary IDE interface 972 boot parameter. It enables support for the secondary IDE interface
@@ -1009,6 +976,7 @@ config BLK_DEV_HT6560B
1009 976
1010config BLK_DEV_QD65XX 977config BLK_DEV_QD65XX
1011 tristate "QDI QD65xx support" 978 tristate "QDI QD65xx support"
979 select IDE_TIMINGS
1012 help 980 help
1013 This driver is enabled at runtime using the "qd65xx.probe" kernel 981 This driver is enabled at runtime using the "qd65xx.probe" kernel
1014 boot parameter. It permits faster I/O speeds to be set. See the 982 boot parameter. It permits faster I/O speeds to be set. See the
@@ -1032,30 +1000,4 @@ config BLK_DEV_IDEDMA
1032 1000
1033endif 1001endif
1034 1002
1035config BLK_DEV_HD_ONLY
1036 bool "Old hard disk (MFM/RLL/IDE) driver"
1037 depends on !ARM || ARCH_RPC || ARCH_SHARK || BROKEN
1038 help
1039 There are two drivers for MFM/RLL/IDE hard disks. Most people use
1040 the newer enhanced driver, but this old one is still around for two
1041 reasons. Some older systems have strange timing problems and seem to
1042 work only with the old driver (which itself does not work with some
1043 newer systems). The other reason is that the old driver is smaller,
1044 since it lacks the enhanced functionality of the new one. This makes
1045 it a good choice for systems with very tight memory restrictions, or
1046 for systems with only older MFM/RLL/ESDI drives. Choosing the old
1047 driver can save 13 KB or so of kernel memory.
1048
1049 If you want to use this driver together with the new one you have
1050 to use "hda=noprobe hdb=noprobe" kernel parameters to prevent the new
1051 driver from probing the primary interface.
1052
1053 If you are unsure, then just choose the Enhanced IDE/MFM/RLL driver
1054 instead of this one. For more detailed information, read the
1055 Disk-HOWTO, available from
1056 <http://www.tldp.org/docs.html#howto>.
1057
1058config BLK_DEV_HD
1059 def_bool BLK_DEV_HD_ONLY
1060
1061endif # IDE 1003endif # IDE
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index a2b3f84d710d..5d414e301a5a 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -11,9 +11,11 @@
11 11
12EXTRA_CFLAGS += -Idrivers/ide 12EXTRA_CFLAGS += -Idrivers/ide
13 13
14ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o 14ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o \
15 ide-pio-blacklist.o
15 16
16# core IDE code 17# core IDE code
18ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o
17ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o 19ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o
18ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o 20ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
19ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o 21ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o
@@ -59,9 +61,3 @@ ifeq ($(CONFIG_BLK_DEV_PLATFORM), y)
59endif 61endif
60 62
61obj-$(CONFIG_BLK_DEV_IDE) += arm/ mips/ 63obj-$(CONFIG_BLK_DEV_IDE) += arm/ mips/
62
63# old hd driver must be last
64ifeq ($(CONFIG_BLK_DEV_HD), y)
65 hd-core-y += legacy/hd.o
66 obj-y += hd-core.o
67endif
diff --git a/drivers/ide/arm/Makefile b/drivers/ide/arm/Makefile
index 936e7b0237f5..5bc26053afa6 100644
--- a/drivers/ide/arm/Makefile
+++ b/drivers/ide/arm/Makefile
@@ -1,7 +1,6 @@
1 1
2obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o 2obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o
3obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o 3obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o
4obj-$(CONFIG_BLK_DEV_IDE_BAST) += bast-ide.o
5obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o 4obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o
6 5
7ifeq ($(CONFIG_IDE_ARM), m) 6ifeq ($(CONFIG_IDE_ARM), m)
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c
deleted file mode 100644
index 8e8c28104b45..000000000000
--- a/drivers/ide/arm/bast-ide.c
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * Copyright (c) 2003-2004 Simtec Electronics
3 * Ben Dooks <ben@simtec.co.uk>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9*/
10
11#include <linux/module.h>
12#include <linux/errno.h>
13#include <linux/ide.h>
14#include <linux/init.h>
15
16#include <asm/mach-types.h>
17
18#include <asm/io.h>
19#include <asm/irq.h>
20#include <asm/arch/map.h>
21#include <asm/arch/bast-map.h>
22#include <asm/arch/bast-irq.h>
23
24#define DRV_NAME "bast-ide"
25
26static int __init bastide_register(unsigned int base, unsigned int aux, int irq)
27{
28 ide_hwif_t *hwif;
29 hw_regs_t hw;
30 int i;
31 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
32
33 memset(&hw, 0, sizeof(hw));
34
35 base += BAST_IDE_CS;
36 aux += BAST_IDE_CS;
37
38 for (i = 0; i <= 7; i++) {
39 hw.io_ports_array[i] = (unsigned long)base;
40 base += 0x20;
41 }
42
43 hw.io_ports.ctl_addr = aux + (6 * 0x20);
44 hw.irq = irq;
45 hw.chipset = ide_generic;
46
47 hwif = ide_find_port();
48 if (hwif == NULL)
49 goto out;
50
51 i = hwif->index;
52
53 ide_init_port_data(hwif, i);
54 ide_init_port_hw(hwif, &hw);
55 hwif->port_ops = NULL;
56
57 idx[0] = i;
58
59 ide_device_add(idx, NULL);
60out:
61 return 0;
62}
63
64static int __init bastide_init(void)
65{
66 unsigned long base = BAST_VA_IDEPRI + BAST_IDE_CS;
67
68 /* we can treat the VR1000 and the BAST the same */
69
70 if (!(machine_is_bast() || machine_is_vr1000()))
71 return 0;
72
73 printk("BAST: IDE driver, (c) 2003-2004 Simtec Electronics\n");
74
75 if (!request_mem_region(base, 0x400000, DRV_NAME)) {
76 printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
77 return -EBUSY;
78 }
79
80 bastide_register(BAST_VA_IDEPRI, BAST_VA_IDEPRIAUX, IRQ_IDE0);
81 bastide_register(BAST_VA_IDESEC, BAST_VA_IDESECAUX, IRQ_IDE1);
82
83 return 0;
84}
85
86module_init(bastide_init);
87
88MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
89MODULE_LICENSE("GPL");
90MODULE_DESCRIPTION("Simtec BAST / Thorcom VR1000 IDE driver");
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index 061456914ca3..52f58c885783 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -21,6 +21,8 @@
21#include <asm/dma.h> 21#include <asm/dma.h>
22#include <asm/ecard.h> 22#include <asm/ecard.h>
23 23
24#define DRV_NAME "icside"
25
24#define ICS_IDENT_OFFSET 0x2280 26#define ICS_IDENT_OFFSET 0x2280
25 27
26#define ICS_ARCIN_V5_INTRSTAT 0x0000 28#define ICS_ARCIN_V5_INTRSTAT 0x0000
@@ -68,6 +70,7 @@ struct icside_state {
68 unsigned int enabled; 70 unsigned int enabled;
69 void __iomem *irq_port; 71 void __iomem *irq_port;
70 void __iomem *ioc_base; 72 void __iomem *ioc_base;
73 unsigned int sel;
71 unsigned int type; 74 unsigned int type;
72 ide_hwif_t *hwif[2]; 75 ide_hwif_t *hwif[2];
73}; 76};
@@ -165,7 +168,8 @@ static const expansioncard_ops_t icside_ops_arcin_v6 = {
165static void icside_maskproc(ide_drive_t *drive, int mask) 168static void icside_maskproc(ide_drive_t *drive, int mask)
166{ 169{
167 ide_hwif_t *hwif = HWIF(drive); 170 ide_hwif_t *hwif = HWIF(drive);
168 struct icside_state *state = hwif->hwif_data; 171 struct expansion_card *ec = ECARD_DEV(hwif->dev);
172 struct icside_state *state = ecard_get_drvdata(ec);
169 unsigned long flags; 173 unsigned long flags;
170 174
171 local_irq_save(flags); 175 local_irq_save(flags);
@@ -308,6 +312,7 @@ static int icside_dma_setup(ide_drive_t *drive)
308{ 312{
309 ide_hwif_t *hwif = HWIF(drive); 313 ide_hwif_t *hwif = HWIF(drive);
310 struct expansion_card *ec = ECARD_DEV(hwif->dev); 314 struct expansion_card *ec = ECARD_DEV(hwif->dev);
315 struct icside_state *state = ecard_get_drvdata(ec);
311 struct request *rq = hwif->hwgroup->rq; 316 struct request *rq = hwif->hwgroup->rq;
312 unsigned int dma_mode; 317 unsigned int dma_mode;
313 318
@@ -331,7 +336,7 @@ static int icside_dma_setup(ide_drive_t *drive)
331 /* 336 /*
332 * Route the DMA signals to the correct interface. 337 * Route the DMA signals to the correct interface.
333 */ 338 */
334 writeb(hwif->select_data, hwif->config_data); 339 writeb(state->sel | hwif->channel, state->ioc_base);
335 340
336 /* 341 /*
337 * Select the correct timing for this drive. 342 * Select the correct timing for this drive.
@@ -359,7 +364,8 @@ static void icside_dma_exec_cmd(ide_drive_t *drive, u8 cmd)
359static int icside_dma_test_irq(ide_drive_t *drive) 364static int icside_dma_test_irq(ide_drive_t *drive)
360{ 365{
361 ide_hwif_t *hwif = HWIF(drive); 366 ide_hwif_t *hwif = HWIF(drive);
362 struct icside_state *state = hwif->hwif_data; 367 struct expansion_card *ec = ECARD_DEV(hwif->dev);
368 struct icside_state *state = ecard_get_drvdata(ec);
363 369
364 return readb(state->irq_port + 370 return readb(state->irq_port +
365 (hwif->channel ? 371 (hwif->channel ?
@@ -411,36 +417,24 @@ static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d)
411 return -EOPNOTSUPP; 417 return -EOPNOTSUPP;
412} 418}
413 419
414static ide_hwif_t * 420static void icside_setup_ports(hw_regs_t *hw, void __iomem *base,
415icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) 421 struct cardinfo *info, struct expansion_card *ec)
416{ 422{
417 unsigned long port = (unsigned long)base + info->dataoffset; 423 unsigned long port = (unsigned long)base + info->dataoffset;
418 ide_hwif_t *hwif;
419 424
420 hwif = ide_find_port(); 425 hw->io_ports.data_addr = port;
421 if (hwif) { 426 hw->io_ports.error_addr = port + (1 << info->stepping);
422 /* 427 hw->io_ports.nsect_addr = port + (2 << info->stepping);
423 * Ensure we're using MMIO 428 hw->io_ports.lbal_addr = port + (3 << info->stepping);
424 */ 429 hw->io_ports.lbam_addr = port + (4 << info->stepping);
425 default_hwif_mmiops(hwif); 430 hw->io_ports.lbah_addr = port + (5 << info->stepping);
426 431 hw->io_ports.device_addr = port + (6 << info->stepping);
427 hwif->io_ports.data_addr = port; 432 hw->io_ports.status_addr = port + (7 << info->stepping);
428 hwif->io_ports.error_addr = port + (1 << info->stepping); 433 hw->io_ports.ctl_addr = (unsigned long)base + info->ctrloffset;
429 hwif->io_ports.nsect_addr = port + (2 << info->stepping); 434
430 hwif->io_ports.lbal_addr = port + (3 << info->stepping); 435 hw->irq = ec->irq;
431 hwif->io_ports.lbam_addr = port + (4 << info->stepping); 436 hw->dev = &ec->dev;
432 hwif->io_ports.lbah_addr = port + (5 << info->stepping); 437 hw->chipset = ide_acorn;
433 hwif->io_ports.device_addr = port + (6 << info->stepping);
434 hwif->io_ports.status_addr = port + (7 << info->stepping);
435 hwif->io_ports.ctl_addr =
436 (unsigned long)base + info->ctrloffset;
437 hwif->irq = ec->irq;
438 hwif->chipset = ide_acorn;
439 hwif->gendev.parent = &ec->dev;
440 hwif->dev = &ec->dev;
441 }
442
443 return hwif;
444} 438}
445 439
446static int __init 440static int __init
@@ -449,6 +443,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
449 ide_hwif_t *hwif; 443 ide_hwif_t *hwif;
450 void __iomem *base; 444 void __iomem *base;
451 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 445 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
446 hw_regs_t hw;
452 447
453 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0); 448 base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
454 if (!base) 449 if (!base)
@@ -466,12 +461,19 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
466 */ 461 */
467 icside_irqdisable_arcin_v5(ec, 0); 462 icside_irqdisable_arcin_v5(ec, 0);
468 463
469 hwif = icside_setup(base, &icside_cardinfo_v5, ec); 464 icside_setup_ports(&hw, base, &icside_cardinfo_v5, ec);
465
466 hwif = ide_find_port();
470 if (!hwif) 467 if (!hwif)
471 return -ENODEV; 468 return -ENODEV;
472 469
470 ide_init_port_hw(hwif, &hw);
471 default_hwif_mmiops(hwif);
472
473 state->hwif[0] = hwif; 473 state->hwif[0] = hwif;
474 474
475 ecard_set_drvdata(ec, state);
476
475 idx[0] = hwif->index; 477 idx[0] = hwif->index;
476 478
477 ide_device_add(idx, NULL); 479 ide_device_add(idx, NULL);
@@ -497,6 +499,7 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
497 int ret; 499 int ret;
498 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 500 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
499 struct ide_port_info d = icside_v6_port_info; 501 struct ide_port_info d = icside_v6_port_info;
502 hw_regs_t hw[2];
500 503
501 ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0); 504 ioc_base = ecardm_iomap(ec, ECARD_RES_IOCFAST, 0, 0);
502 if (!ioc_base) { 505 if (!ioc_base) {
@@ -525,43 +528,47 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
525 528
526 state->irq_port = easi_base; 529 state->irq_port = easi_base;
527 state->ioc_base = ioc_base; 530 state->ioc_base = ioc_base;
531 state->sel = sel;
528 532
529 /* 533 /*
530 * Be on the safe side - disable interrupts 534 * Be on the safe side - disable interrupts
531 */ 535 */
532 icside_irqdisable_arcin_v6(ec, 0); 536 icside_irqdisable_arcin_v6(ec, 0);
533 537
538 icside_setup_ports(&hw[0], easi_base, &icside_cardinfo_v6_1, ec);
539 icside_setup_ports(&hw[1], easi_base, &icside_cardinfo_v6_2, ec);
540
534 /* 541 /*
535 * Find and register the interfaces. 542 * Find and register the interfaces.
536 */ 543 */
537 hwif = icside_setup(easi_base, &icside_cardinfo_v6_1, ec); 544 hwif = ide_find_port();
538 mate = icside_setup(easi_base, &icside_cardinfo_v6_2, ec); 545 if (hwif == NULL)
546 return -ENODEV;
539 547
540 if (!hwif || !mate) { 548 ide_init_port_hw(hwif, &hw[0]);
541 ret = -ENODEV; 549 default_hwif_mmiops(hwif);
542 goto out; 550
551 idx[0] = hwif->index;
552
553 mate = ide_find_port();
554 if (mate) {
555 ide_init_port_hw(mate, &hw[1]);
556 default_hwif_mmiops(mate);
557
558 idx[1] = mate->index;
543 } 559 }
544 560
545 state->hwif[0] = hwif; 561 state->hwif[0] = hwif;
546 state->hwif[1] = mate; 562 state->hwif[1] = mate;
547 563
548 hwif->hwif_data = state; 564 ecard_set_drvdata(ec, state);
549 hwif->config_data = (unsigned long)ioc_base;
550 hwif->select_data = sel;
551
552 mate->hwif_data = state;
553 mate->config_data = (unsigned long)ioc_base;
554 mate->select_data = sel | 1;
555 565
556 if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { 566 if (ec->dma != NO_DMA && !request_dma(ec->dma, DRV_NAME)) {
557 d.init_dma = icside_dma_init; 567 d.init_dma = icside_dma_init;
558 d.port_ops = &icside_v6_port_ops; 568 d.port_ops = &icside_v6_port_ops;
559 d.dma_ops = NULL; 569 d.dma_ops = NULL;
560 } 570 }
561 571
562 idx[0] = hwif->index;
563 idx[1] = mate->index;
564
565 ide_device_add(idx, &d); 572 ide_device_add(idx, &d);
566 573
567 return 0; 574 return 0;
@@ -627,10 +634,8 @@ icside_probe(struct expansion_card *ec, const struct ecard_id *id)
627 break; 634 break;
628 } 635 }
629 636
630 if (ret == 0) { 637 if (ret == 0)
631 ecard_set_drvdata(ec, state);
632 goto out; 638 goto out;
633 }
634 639
635 kfree(state); 640 kfree(state);
636 release: 641 release:
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c
index 3839f5722985..c79b85b6e4a3 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/arm/palm_bk3710.c
@@ -74,8 +74,6 @@ struct palm_bk3710_udmatiming {
74#define BK3710_IORDYTMP 0x78 74#define BK3710_IORDYTMP 0x78
75#define BK3710_IORDYTMS 0x7C 75#define BK3710_IORDYTMS 0x7C
76 76
77#include "../ide-timing.h"
78
79static unsigned ideclk_period; /* in nanoseconds */ 77static unsigned ideclk_period; /* in nanoseconds */
80 78
81static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { 79static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
@@ -402,7 +400,6 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
402 400
403 i = hwif->index; 401 i = hwif->index;
404 402
405 ide_init_port_data(hwif, i);
406 ide_init_port_hw(hwif, &hw); 403 ide_init_port_hw(hwif, &hw);
407 404
408 default_hwif_mmiops(hwif); 405 default_hwif_mmiops(hwif);
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c
index 1747b2358775..43057e0303c8 100644
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -11,6 +11,10 @@
11 11
12#include <asm/ecard.h> 12#include <asm/ecard.h>
13 13
14static struct const ide_port_info rapide_port_info = {
15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
16};
17
14static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, 18static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base,
15 void __iomem *ctrl, unsigned int sz, int irq) 19 void __iomem *ctrl, unsigned int sz, int irq)
16{ 20{
@@ -44,25 +48,26 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
44 goto release; 48 goto release;
45 } 49 }
46 50
47 hwif = ide_find_port(); 51 memset(&hw, 0, sizeof(hw));
48 if (hwif) { 52 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
49 memset(&hw, 0, sizeof(hw)); 53 hw.chipset = ide_generic;
50 rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq); 54 hw.dev = &ec->dev;
51 hw.chipset = ide_generic;
52 hw.dev = &ec->dev;
53 55
54 ide_init_port_hw(hwif, &hw); 56 hwif = ide_find_port();
57 if (hwif == NULL) {
58 ret = -ENOENT;
59 goto release;
60 }
55 61
56 hwif->host_flags = IDE_HFLAG_MMIO; 62 ide_init_port_hw(hwif, &hw);
57 default_hwif_mmiops(hwif); 63 default_hwif_mmiops(hwif);
58 64
59 idx[0] = hwif->index; 65 idx[0] = hwif->index;
60 66
61 ide_device_add(idx, NULL); 67 ide_device_add(idx, &rapide_port_info);
62 68
63 ecard_set_drvdata(ec, hwif); 69 ecard_set_drvdata(ec, hwif);
64 goto out; 70 goto out;
65 }
66 71
67 release: 72 release:
68 ecard_release_resources(ec); 73 ecard_release_resources(ec);
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c
index ae37ee58bae2..20fad6d542cc 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -8,6 +8,8 @@
8#include <asm/io.h> 8#include <asm/io.h>
9#include <asm/irq.h> 9#include <asm/irq.h>
10 10
11#define DRV_NAME "ide-h8300"
12
11#define bswap(d) \ 13#define bswap(d) \
12({ \ 14({ \
13 u16 r; \ 15 u16 r; \
@@ -176,6 +178,10 @@ static inline void hwif_setup(ide_hwif_t *hwif)
176 hwif->output_data = h8300_output_data; 178 hwif->output_data = h8300_output_data;
177} 179}
178 180
181static const struct ide_port_info h8300_port_info = {
182 .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA,
183};
184
179static int __init h8300_ide_init(void) 185static int __init h8300_ide_init(void)
180{ 186{
181 hw_regs_t hw; 187 hw_regs_t hw;
@@ -183,6 +189,8 @@ static int __init h8300_ide_init(void)
183 int index; 189 int index;
184 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 190 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
185 191
192 printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n");
193
186 if (!request_region(CONFIG_H8300_IDE_BASE, H8300_IDE_GAP*8, "ide-h8300")) 194 if (!request_region(CONFIG_H8300_IDE_BASE, H8300_IDE_GAP*8, "ide-h8300"))
187 goto out_busy; 195 goto out_busy;
188 if (!request_region(CONFIG_H8300_IDE_ALT, H8300_IDE_GAP, "ide-h8300")) { 196 if (!request_region(CONFIG_H8300_IDE_ALT, H8300_IDE_GAP, "ide-h8300")) {
@@ -192,22 +200,17 @@ static int __init h8300_ide_init(void)
192 200
193 hw_setup(&hw); 201 hw_setup(&hw);
194 202
195 hwif = ide_find_port(); 203 hwif = ide_find_port_slot(&h8300_port_info);
196 if (hwif == NULL) { 204 if (hwif == NULL)
197 printk(KERN_ERR "ide-h8300: IDE I/F register failed\n");
198 return -ENOENT; 205 return -ENOENT;
199 }
200 206
201 index = hwif->index; 207 index = hwif->index;
202 ide_init_port_data(hwif, index);
203 ide_init_port_hw(hwif, &hw); 208 ide_init_port_hw(hwif, &hw);
204 hwif_setup(hwif); 209 hwif_setup(hwif);
205 hwif->host_flags = IDE_HFLAG_NO_IO_32BIT;
206 printk(KERN_INFO "ide%d: H8/300 generic IDE interface\n", index);
207 210
208 idx[0] = index; 211 idx[0] = index;
209 212
210 ide_device_add(idx, NULL); 213 ide_device_add(idx, &h8300_port_info);
211 214
212 return 0; 215 return 0;
213 216
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index d99847157186..6e29dd532090 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -517,14 +517,9 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
517 int xferlen, 517 int xferlen,
518 ide_handler_t *handler) 518 ide_handler_t *handler)
519{ 519{
520 ide_startstop_t startstop;
521 struct cdrom_info *info = drive->driver_data; 520 struct cdrom_info *info = drive->driver_data;
522 ide_hwif_t *hwif = drive->hwif; 521 ide_hwif_t *hwif = drive->hwif;
523 522
524 /* wait for the controller to be idle */
525 if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY))
526 return startstop;
527
528 /* FIXME: for Virtual DMA we must check harder */ 523 /* FIXME: for Virtual DMA we must check harder */
529 if (info->dma) 524 if (info->dma)
530 info->dma = !hwif->dma_ops->dma_setup(drive); 525 info->dma = !hwif->dma_ops->dma_setup(drive);
@@ -604,28 +599,6 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
604} 599}
605 600
606/* 601/*
607 * Block read functions.
608 */
609static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len)
610{
611 while (len > 0) {
612 int dum = 0;
613 xf(drive, NULL, &dum, sizeof(dum));
614 len -= sizeof(dum);
615 }
616}
617
618static void ide_cd_drain_data(ide_drive_t *drive, int nsects)
619{
620 while (nsects > 0) {
621 static char dum[SECTOR_SIZE];
622
623 drive->hwif->input_data(drive, NULL, dum, sizeof(dum));
624 nsects--;
625 }
626}
627
628/*
629 * Check the contents of the interrupt reason register from the cdrom 602 * Check the contents of the interrupt reason register from the cdrom
630 * and attempt to recover if there are problems. Returns 0 if everything's 603 * and attempt to recover if there are problems. Returns 0 if everything's
631 * ok; nonzero if the request has been terminated. 604 * ok; nonzero if the request has been terminated.
@@ -640,15 +613,12 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
640 if (ireason == (!rw << 1)) 613 if (ireason == (!rw << 1))
641 return 0; 614 return 0;
642 else if (ireason == (rw << 1)) { 615 else if (ireason == (rw << 1)) {
643 ide_hwif_t *hwif = drive->hwif;
644 xfer_func_t *xf;
645 616
646 /* whoops... */ 617 /* whoops... */
647 printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 618 printk(KERN_ERR "%s: %s: wrong transfer direction!\n",
648 drive->name, __func__); 619 drive->name, __func__);
649 620
650 xf = rw ? hwif->output_data : hwif->input_data; 621 ide_pad_transfer(drive, rw, len);
651 ide_cd_pad_transfer(drive, xf, len);
652 } else if (rw == 0 && ireason == 1) { 622 } else if (rw == 0 && ireason == 1) {
653 /* 623 /*
654 * Some drives (ASUS) seem to tell us that status info is 624 * Some drives (ASUS) seem to tell us that status info is
@@ -696,16 +666,9 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
696 666
697static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); 667static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
698 668
699/* 669static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
700 * Routine to send a read/write packet command to the drive. This is usually 670 struct request *rq)
701 * called directly from cdrom_start_{read,write}(). However, for drq_interrupt
702 * devices, it is called from an interrupt when the drive is ready to accept
703 * the command.
704 */
705static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
706{ 671{
707 struct request *rq = HWGROUP(drive)->rq;
708
709 if (rq_data_dir(rq) == READ) { 672 if (rq_data_dir(rq) == READ) {
710 unsigned short sectors_per_frame = 673 unsigned short sectors_per_frame =
711 queue_hardsect_size(drive->queue) >> SECTOR_BITS; 674 queue_hardsect_size(drive->queue) >> SECTOR_BITS;
@@ -742,6 +705,19 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
742 /* set up the command */ 705 /* set up the command */
743 rq->timeout = ATAPI_WAIT_PC; 706 rq->timeout = ATAPI_WAIT_PC;
744 707
708 return ide_started;
709}
710
711/*
712 * Routine to send a read/write packet command to the drive. This is usually
713 * called directly from cdrom_start_{read,write}(). However, for drq_interrupt
714 * devices, it is called from an interrupt when the drive is ready to accept
715 * the command.
716 */
717static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
718{
719 struct request *rq = drive->hwif->hwgroup->rq;
720
745 /* send the command to the drive and return */ 721 /* send the command to the drive and return */
746 return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); 722 return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
747} 723}
@@ -768,9 +744,8 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
768 return ide_stopped; 744 return ide_stopped;
769} 745}
770 746
771static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive) 747static void ide_cd_prepare_seek_request(ide_drive_t *drive, struct request *rq)
772{ 748{
773 struct request *rq = HWGROUP(drive)->rq;
774 sector_t frame = rq->sector; 749 sector_t frame = rq->sector;
775 750
776 sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS); 751 sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS);
@@ -780,17 +755,13 @@ static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
780 put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]); 755 put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]);
781 756
782 rq->timeout = ATAPI_WAIT_PC; 757 rq->timeout = ATAPI_WAIT_PC;
783 return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
784} 758}
785 759
786static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) 760static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
787{ 761{
788 struct cdrom_info *info = drive->driver_data; 762 struct request *rq = drive->hwif->hwgroup->rq;
789 763
790 info->dma = 0; 764 return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
791 info->start_seek = jiffies;
792 return cdrom_start_packet_command(drive, 0,
793 cdrom_start_seek_continuation);
794} 765}
795 766
796/* 767/*
@@ -1011,7 +982,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1011 - bio_cur_sectors(rq->bio), 982 - bio_cur_sectors(rq->bio),
1012 thislen >> 9); 983 thislen >> 9);
1013 if (nskip > 0) { 984 if (nskip > 0) {
1014 ide_cd_drain_data(drive, nskip); 985 ide_pad_transfer(drive, write, nskip << 9);
1015 rq->current_nr_sectors -= nskip; 986 rq->current_nr_sectors -= nskip;
1016 thislen -= (nskip << 9); 987 thislen -= (nskip << 9);
1017 } 988 }
@@ -1048,7 +1019,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1048 * If the buffers are full, pipe the rest into 1019 * If the buffers are full, pipe the rest into
1049 * oblivion. 1020 * oblivion.
1050 */ 1021 */
1051 ide_cd_drain_data(drive, thislen >> 9); 1022 ide_pad_transfer(drive, 0, thislen);
1052 else { 1023 else {
1053 printk(KERN_ERR "%s: confused, missing data\n", 1024 printk(KERN_ERR "%s: confused, missing data\n",
1054 drive->name); 1025 drive->name);
@@ -1096,7 +1067,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1096 1067
1097 /* pad, if necessary */ 1068 /* pad, if necessary */
1098 if (!blk_fs_request(rq) && len > 0) 1069 if (!blk_fs_request(rq) && len > 0)
1099 ide_cd_pad_transfer(drive, xferfunc, len); 1070 ide_pad_transfer(drive, write, len);
1100 1071
1101 if (blk_pc_request(rq)) { 1072 if (blk_pc_request(rq)) {
1102 timeout = rq->timeout; 1073 timeout = rq->timeout;
@@ -1165,21 +1136,17 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
1165 if (write) 1136 if (write)
1166 cd->devinfo.media_written = 1; 1137 cd->devinfo.media_written = 1;
1167 1138
1168 /* start sending the read/write request to the drive */ 1139 return ide_started;
1169 return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont);
1170} 1140}
1171 1141
1172static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) 1142static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive)
1173{ 1143{
1174 struct request *rq = HWGROUP(drive)->rq; 1144 struct request *rq = HWGROUP(drive)->rq;
1175 1145
1176 if (!rq->timeout)
1177 rq->timeout = ATAPI_WAIT_PC;
1178
1179 return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); 1146 return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr);
1180} 1147}
1181 1148
1182static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) 1149static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1183{ 1150{
1184 struct cdrom_info *info = drive->driver_data; 1151 struct cdrom_info *info = drive->driver_data;
1185 1152
@@ -1191,10 +1158,16 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1191 info->dma = 0; 1158 info->dma = 0;
1192 1159
1193 /* sg request */ 1160 /* sg request */
1194 if (rq->bio) { 1161 if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) {
1195 int mask = drive->queue->dma_alignment; 1162 struct request_queue *q = drive->queue;
1196 unsigned long addr = 1163 unsigned int alignment;
1197 (unsigned long)page_address(bio_page(rq->bio)); 1164 unsigned long addr;
1165 unsigned long stack_mask = ~(THREAD_SIZE - 1);
1166
1167 if (rq->bio)
1168 addr = (unsigned long)bio_data(rq->bio);
1169 else
1170 addr = (unsigned long)rq->data;
1198 1171
1199 info->dma = drive->using_dma; 1172 info->dma = drive->using_dma;
1200 1173
@@ -1204,23 +1177,25 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1204 * NOTE! The "len" and "addr" checks should possibly have 1177 * NOTE! The "len" and "addr" checks should possibly have
1205 * separate masks. 1178 * separate masks.
1206 */ 1179 */
1207 if ((rq->data_len & 15) || (addr & mask)) 1180 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
1181 if (addr & alignment || rq->data_len & alignment)
1208 info->dma = 0; 1182 info->dma = 0;
1209 }
1210 1183
1211 /* start sending the command to the drive */ 1184 if (!((addr & stack_mask) ^
1212 return cdrom_start_packet_command(drive, rq->data_len, 1185 ((unsigned long)current->stack & stack_mask)))
1213 cdrom_do_newpc_cont); 1186 info->dma = 0;
1187 }
1214} 1188}
1215 1189
1216/* 1190/*
1217 * cdrom driver request routine. 1191 * cdrom driver request routine.
1218 */ 1192 */
1219static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, 1193static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1220 sector_t block) 1194 sector_t block)
1221{ 1195{
1222 ide_startstop_t action;
1223 struct cdrom_info *info = drive->driver_data; 1196 struct cdrom_info *info = drive->driver_data;
1197 ide_handler_t *fn;
1198 int xferlen;
1224 1199
1225 if (blk_fs_request(rq)) { 1200 if (blk_fs_request(rq)) {
1226 if (info->cd_flags & IDE_CD_FLAG_SEEKING) { 1201 if (info->cd_flags & IDE_CD_FLAG_SEEKING) {
@@ -1240,29 +1215,48 @@ static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq,
1240 } 1215 }
1241 if (rq_data_dir(rq) == READ && 1216 if (rq_data_dir(rq) == READ &&
1242 IDE_LARGE_SEEK(info->last_block, block, 1217 IDE_LARGE_SEEK(info->last_block, block,
1243 IDECD_SEEK_THRESHOLD) && 1218 IDECD_SEEK_THRESHOLD) &&
1244 drive->dsc_overlap) 1219 drive->dsc_overlap) {
1245 action = cdrom_start_seek(drive, block); 1220 xferlen = 0;
1246 else 1221 fn = cdrom_start_seek_continuation;
1247 action = cdrom_start_rw(drive, rq); 1222
1223 info->dma = 0;
1224 info->start_seek = jiffies;
1225
1226 ide_cd_prepare_seek_request(drive, rq);
1227 } else {
1228 xferlen = 32768;
1229 fn = cdrom_start_rw_cont;
1230
1231 if (cdrom_start_rw(drive, rq) == ide_stopped)
1232 return ide_stopped;
1233
1234 if (ide_cd_prepare_rw_request(drive, rq) == ide_stopped)
1235 return ide_stopped;
1236 }
1248 info->last_block = block; 1237 info->last_block = block;
1249 return action;
1250 } else if (blk_sense_request(rq) || blk_pc_request(rq) || 1238 } else if (blk_sense_request(rq) || blk_pc_request(rq) ||
1251 rq->cmd_type == REQ_TYPE_ATA_PC) { 1239 rq->cmd_type == REQ_TYPE_ATA_PC) {
1252 return cdrom_do_block_pc(drive, rq); 1240 xferlen = rq->data_len;
1241 fn = cdrom_do_newpc_cont;
1242
1243 if (!rq->timeout)
1244 rq->timeout = ATAPI_WAIT_PC;
1245
1246 cdrom_do_block_pc(drive, rq);
1253 } else if (blk_special_request(rq)) { 1247 } else if (blk_special_request(rq)) {
1254 /* right now this can only be a reset... */ 1248 /* right now this can only be a reset... */
1255 cdrom_end_request(drive, 1); 1249 cdrom_end_request(drive, 1);
1256 return ide_stopped; 1250 return ide_stopped;
1251 } else {
1252 blk_dump_rq_flags(rq, "ide-cd bad flags");
1253 cdrom_end_request(drive, 0);
1254 return ide_stopped;
1257 } 1255 }
1258 1256
1259 blk_dump_rq_flags(rq, "ide-cd bad flags"); 1257 return cdrom_start_packet_command(drive, xferlen, fn);
1260 cdrom_end_request(drive, 0);
1261 return ide_stopped;
1262} 1258}
1263 1259
1264
1265
1266/* 1260/*
1267 * Ioctl handling. 1261 * Ioctl handling.
1268 * 1262 *
@@ -1872,6 +1866,7 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1872 1866
1873 blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); 1867 blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn);
1874 blk_queue_dma_alignment(drive->queue, 31); 1868 blk_queue_dma_alignment(drive->queue, 31);
1869 blk_queue_update_dma_pad(drive->queue, 15);
1875 drive->queue->unplug_delay = (1 * HZ) / 1000; 1870 drive->queue->unplug_delay = (1 * HZ) / 1000;
1876 if (!drive->queue->unplug_delay) 1871 if (!drive->queue->unplug_delay)
1877 drive->queue->unplug_delay = 1; 1872 drive->queue->unplug_delay = 1;
@@ -1954,10 +1949,9 @@ static ide_driver_t ide_cdrom_driver = {
1954 .version = IDECD_VERSION, 1949 .version = IDECD_VERSION,
1955 .media = ide_cdrom, 1950 .media = ide_cdrom,
1956 .supports_dsc_overlap = 1, 1951 .supports_dsc_overlap = 1,
1957 .do_request = ide_do_rw_cdrom, 1952 .do_request = ide_cd_do_request,
1958 .end_request = ide_end_request, 1953 .end_request = ide_end_request,
1959 .error = __ide_error, 1954 .error = __ide_error,
1960 .abort = __ide_abort,
1961#ifdef CONFIG_IDE_PROC_FS 1955#ifdef CONFIG_IDE_PROC_FS
1962 .proc = idecd_proc, 1956 .proc = idecd_proc,
1963#endif 1957#endif
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 5f49a4ae9dd8..3a2e80237c10 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -985,7 +985,6 @@ static ide_driver_t idedisk_driver = {
985 .do_request = ide_do_rw_disk, 985 .do_request = ide_do_rw_disk,
986 .end_request = ide_end_request, 986 .end_request = ide_end_request,
987 .error = __ide_error, 987 .error = __ide_error,
988 .abort = __ide_abort,
989#ifdef CONFIG_IDE_PROC_FS 988#ifdef CONFIG_IDE_PROC_FS
990 .proc = idedisk_proc, 989 .proc = idedisk_proc,
991#endif 990#endif
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index b3689437269f..011d72011cc4 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -351,10 +351,7 @@ static void ide_floppy_callback(ide_drive_t *drive)
351 351
352static void idefloppy_init_pc(struct ide_atapi_pc *pc) 352static void idefloppy_init_pc(struct ide_atapi_pc *pc)
353{ 353{
354 memset(pc->c, 0, 12); 354 memset(pc, 0, sizeof(*pc));
355 pc->retries = 0;
356 pc->flags = 0;
357 pc->req_xfer = 0;
358 pc->buf = pc->pc_buf; 355 pc->buf = pc->pc_buf;
359 pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; 356 pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
360 pc->callback = ide_floppy_callback; 357 pc->callback = ide_floppy_callback;
@@ -561,12 +558,6 @@ static void idefloppy_create_start_stop_cmd(struct ide_atapi_pc *pc, int start)
561 pc->c[4] = start; 558 pc->c[4] = start;
562} 559}
563 560
564static void idefloppy_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
565{
566 idefloppy_init_pc(pc);
567 pc->c[0] = GPCMD_TEST_UNIT_READY;
568}
569
570static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, 561static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
571 struct ide_atapi_pc *pc, struct request *rq, 562 struct ide_atapi_pc *pc, struct request *rq,
572 unsigned long sector) 563 unsigned long sector)
@@ -711,10 +702,10 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
711 set_disk_ro(floppy->disk, floppy->wp); 702 set_disk_ro(floppy->disk, floppy->wp);
712 page = &pc.buf[8]; 703 page = &pc.buf[8];
713 704
714 transfer_rate = be16_to_cpu(*(u16 *)&pc.buf[8 + 2]); 705 transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]);
715 sector_size = be16_to_cpu(*(u16 *)&pc.buf[8 + 6]); 706 sector_size = be16_to_cpup((__be16 *)&pc.buf[8 + 6]);
716 cyls = be16_to_cpu(*(u16 *)&pc.buf[8 + 8]); 707 cyls = be16_to_cpup((__be16 *)&pc.buf[8 + 8]);
717 rpm = be16_to_cpu(*(u16 *)&pc.buf[8 + 28]); 708 rpm = be16_to_cpup((__be16 *)&pc.buf[8 + 28]);
718 heads = pc.buf[8 + 4]; 709 heads = pc.buf[8 + 4];
719 sectors = pc.buf[8 + 5]; 710 sectors = pc.buf[8 + 5];
720 711
@@ -789,8 +780,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
789 for (i = 0; i < desc_cnt; i++) { 780 for (i = 0; i < desc_cnt; i++) {
790 unsigned int desc_start = 4 + i*8; 781 unsigned int desc_start = 4 + i*8;
791 782
792 blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]); 783 blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]);
793 length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]); 784 length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]);
794 785
795 debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", 786 debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n",
796 i, blocks * length / 1024, blocks, length); 787 i, blocks * length / 1024, blocks, length);
@@ -911,8 +902,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
911 if (u_index >= u_array_size) 902 if (u_index >= u_array_size)
912 break; /* User-supplied buffer too small */ 903 break; /* User-supplied buffer too small */
913 904
914 blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]); 905 blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]);
915 length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]); 906 length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]);
916 907
917 if (put_user(blocks, argp)) 908 if (put_user(blocks, argp))
918 return(-EFAULT); 909 return(-EFAULT);
@@ -1138,7 +1129,6 @@ static ide_driver_t idefloppy_driver = {
1138 .do_request = idefloppy_do_request, 1129 .do_request = idefloppy_do_request,
1139 .end_request = idefloppy_end_request, 1130 .end_request = idefloppy_end_request,
1140 .error = __ide_error, 1131 .error = __ide_error,
1141 .abort = __ide_abort,
1142#ifdef CONFIG_IDE_PROC_FS 1132#ifdef CONFIG_IDE_PROC_FS
1143 .proc = idefloppy_proc, 1133 .proc = idefloppy_proc,
1144#endif 1134#endif
@@ -1166,7 +1156,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
1166 floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; 1156 floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS;
1167 /* Just in case */ 1157 /* Just in case */
1168 1158
1169 idefloppy_create_test_unit_ready_cmd(&pc); 1159 idefloppy_init_pc(&pc);
1160 pc.c[0] = GPCMD_TEST_UNIT_READY;
1161
1170 if (idefloppy_queue_pc_tail(drive, &pc)) { 1162 if (idefloppy_queue_pc_tail(drive, &pc)) {
1171 idefloppy_create_start_stop_cmd(&pc, 1); 1163 idefloppy_create_start_stop_cmd(&pc, 1);
1172 (void) idefloppy_queue_pc_tail(drive, &pc); 1164 (void) idefloppy_queue_pc_tail(drive, &pc);
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 28057747c1f8..661b75a89d4d 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -504,55 +504,6 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat)
504 504
505EXPORT_SYMBOL_GPL(ide_error); 505EXPORT_SYMBOL_GPL(ide_error);
506 506
507ide_startstop_t __ide_abort(ide_drive_t *drive, struct request *rq)
508{
509 if (drive->media != ide_disk)
510 rq->errors |= ERROR_RESET;
511
512 ide_kill_rq(drive, rq);
513
514 return ide_stopped;
515}
516
517EXPORT_SYMBOL_GPL(__ide_abort);
518
519/**
520 * ide_abort - abort pending IDE operations
521 * @drive: drive the error occurred on
522 * @msg: message to report
523 *
524 * ide_abort kills and cleans up when we are about to do a
525 * host initiated reset on active commands. Longer term we
526 * want handlers to have sensible abort handling themselves
527 *
528 * This differs fundamentally from ide_error because in
529 * this case the command is doing just fine when we
530 * blow it away.
531 */
532
533ide_startstop_t ide_abort(ide_drive_t *drive, const char *msg)
534{
535 struct request *rq;
536
537 if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL)
538 return ide_stopped;
539
540 /* retry only "normal" I/O: */
541 if (!blk_fs_request(rq)) {
542 rq->errors = 1;
543 ide_end_drive_cmd(drive, BUSY_STAT, 0);
544 return ide_stopped;
545 }
546
547 if (rq->rq_disk) {
548 ide_driver_t *drv;
549
550 drv = *(ide_driver_t **)rq->rq_disk->private_data;
551 return drv->abort(drive, rq);
552 } else
553 return __ide_abort(drive, rq);
554}
555
556static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) 507static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
557{ 508{
558 tf->nsect = drive->sect; 509 tf->nsect = drive->sect;
@@ -766,6 +717,18 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
766 return ide_stopped; 717 return ide_stopped;
767} 718}
768 719
720static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq)
721{
722 switch (rq->cmd[0]) {
723 case REQ_DRIVE_RESET:
724 return ide_do_reset(drive);
725 default:
726 blk_dump_rq_flags(rq, "ide_special_rq - bad request");
727 ide_end_request(drive, 0, 0);
728 return ide_stopped;
729 }
730}
731
769static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) 732static void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
770{ 733{
771 struct request_pm_state *pm = rq->data; 734 struct request_pm_state *pm = rq->data;
@@ -869,7 +832,16 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
869 pm->pm_step == ide_pm_state_completed) 832 pm->pm_step == ide_pm_state_completed)
870 ide_complete_pm_request(drive, rq); 833 ide_complete_pm_request(drive, rq);
871 return startstop; 834 return startstop;
872 } 835 } else if (!rq->rq_disk && blk_special_request(rq))
836 /*
837 * TODO: Once all ULDs have been modified to
838 * check for specific op codes rather than
839 * blindly accepting any special request, the
840 * check for ->rq_disk above may be replaced
841 * by a more suitable mechanism or even
842 * dropped entirely.
843 */
844 return ide_special_rq(drive, rq);
873 845
874 drv = *(ide_driver_t **)rq->rq_disk->private_data; 846 drv = *(ide_driver_t **)rq->rq_disk->private_data;
875 return drv->do_request(drive, rq, block); 847 return drv->do_request(drive, rq, block);
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 80ad4f234f3f..44aaec256a30 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -905,6 +905,14 @@ void ide_execute_pkt_cmd(ide_drive_t *drive)
905} 905}
906EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); 906EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd);
907 907
908static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
909{
910 struct request *rq = drive->hwif->hwgroup->rq;
911
912 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET)
913 ide_end_request(drive, err ? err : 1, 0);
914}
915
908/* needed below */ 916/* needed below */
909static ide_startstop_t do_reset1 (ide_drive_t *, int); 917static ide_startstop_t do_reset1 (ide_drive_t *, int);
910 918
@@ -940,7 +948,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive)
940 } 948 }
941 /* done polling */ 949 /* done polling */
942 hwgroup->polling = 0; 950 hwgroup->polling = 0;
943 hwgroup->resetting = 0; 951 ide_complete_drive_reset(drive, 0);
944 return ide_stopped; 952 return ide_stopped;
945} 953}
946 954
@@ -956,12 +964,14 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
956 ide_hwif_t *hwif = HWIF(drive); 964 ide_hwif_t *hwif = HWIF(drive);
957 const struct ide_port_ops *port_ops = hwif->port_ops; 965 const struct ide_port_ops *port_ops = hwif->port_ops;
958 u8 tmp; 966 u8 tmp;
967 int err = 0;
959 968
960 if (port_ops && port_ops->reset_poll) { 969 if (port_ops && port_ops->reset_poll) {
961 if (port_ops->reset_poll(drive)) { 970 err = port_ops->reset_poll(drive);
971 if (err) {
962 printk(KERN_ERR "%s: host reset_poll failure for %s.\n", 972 printk(KERN_ERR "%s: host reset_poll failure for %s.\n",
963 hwif->name, drive->name); 973 hwif->name, drive->name);
964 return ide_stopped; 974 goto out;
965 } 975 }
966 } 976 }
967 977
@@ -975,6 +985,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
975 } 985 }
976 printk("%s: reset timed-out, status=0x%02x\n", hwif->name, tmp); 986 printk("%s: reset timed-out, status=0x%02x\n", hwif->name, tmp);
977 drive->failures++; 987 drive->failures++;
988 err = -EIO;
978 } else { 989 } else {
979 printk("%s: reset: ", hwif->name); 990 printk("%s: reset: ", hwif->name);
980 tmp = ide_read_error(drive); 991 tmp = ide_read_error(drive);
@@ -1001,10 +1012,12 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive)
1001 if (tmp & 0x80) 1012 if (tmp & 0x80)
1002 printk("; slave: failed"); 1013 printk("; slave: failed");
1003 printk("\n"); 1014 printk("\n");
1015 err = -EIO;
1004 } 1016 }
1005 } 1017 }
1018out:
1006 hwgroup->polling = 0; /* done polling */ 1019 hwgroup->polling = 0; /* done polling */
1007 hwgroup->resetting = 0; /* done reset attempt */ 1020 ide_complete_drive_reset(drive, err);
1008 return ide_stopped; 1021 return ide_stopped;
1009} 1022}
1010 1023
@@ -1090,7 +1103,6 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1090 1103
1091 /* For an ATAPI device, first try an ATAPI SRST. */ 1104 /* For an ATAPI device, first try an ATAPI SRST. */
1092 if (drive->media != ide_disk && !do_not_try_atapi) { 1105 if (drive->media != ide_disk && !do_not_try_atapi) {
1093 hwgroup->resetting = 1;
1094 pre_reset(drive); 1106 pre_reset(drive);
1095 SELECT_DRIVE(drive); 1107 SELECT_DRIVE(drive);
1096 udelay (20); 1108 udelay (20);
@@ -1112,10 +1124,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1112 1124
1113 if (io_ports->ctl_addr == 0) { 1125 if (io_ports->ctl_addr == 0) {
1114 spin_unlock_irqrestore(&ide_lock, flags); 1126 spin_unlock_irqrestore(&ide_lock, flags);
1127 ide_complete_drive_reset(drive, -ENXIO);
1115 return ide_stopped; 1128 return ide_stopped;
1116 } 1129 }
1117 1130
1118 hwgroup->resetting = 1;
1119 /* 1131 /*
1120 * Note that we also set nIEN while resetting the device, 1132 * Note that we also set nIEN while resetting the device,
1121 * to mask unwanted interrupts from the interface during the reset. 1133 * to mask unwanted interrupts from the interface during the reset.
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 47af80df6872..13af72f09ec4 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -1,26 +1,11 @@
1#include <linux/module.h>
2#include <linux/types.h> 1#include <linux/types.h>
3#include <linux/string.h> 2#include <linux/string.h>
4#include <linux/kernel.h> 3#include <linux/kernel.h>
5#include <linux/timer.h>
6#include <linux/mm.h>
7#include <linux/interrupt.h> 4#include <linux/interrupt.h>
8#include <linux/major.h>
9#include <linux/errno.h>
10#include <linux/genhd.h>
11#include <linux/blkpg.h>
12#include <linux/slab.h>
13#include <linux/pci.h>
14#include <linux/delay.h>
15#include <linux/hdreg.h> 5#include <linux/hdreg.h>
16#include <linux/ide.h> 6#include <linux/ide.h>
17#include <linux/bitops.h> 7#include <linux/bitops.h>
18 8
19#include <asm/byteorder.h>
20#include <asm/irq.h>
21#include <asm/uaccess.h>
22#include <asm/io.h>
23
24static const char *udma_str[] = 9static const char *udma_str[] =
25 { "UDMA/16", "UDMA/25", "UDMA/33", "UDMA/44", 10 { "UDMA/16", "UDMA/25", "UDMA/33", "UDMA/44",
26 "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" }; 11 "UDMA/66", "UDMA/100", "UDMA/133", "UDMA7" };
@@ -90,142 +75,6 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
90 return min(speed, mode); 75 return min(speed, mode);
91} 76}
92 77
93/*
94 * Standard (generic) timings for PIO modes, from ATA2 specification.
95 * These timings are for access to the IDE data port register *only*.
96 * Some drives may specify a mode, while also specifying a different
97 * value for cycle_time (from drive identification data).
98 */
99const ide_pio_timings_t ide_pio_timings[6] = {
100 { 70, 165, 600 }, /* PIO Mode 0 */
101 { 50, 125, 383 }, /* PIO Mode 1 */
102 { 30, 100, 240 }, /* PIO Mode 2 */
103 { 30, 80, 180 }, /* PIO Mode 3 with IORDY */
104 { 25, 70, 120 }, /* PIO Mode 4 with IORDY */
105 { 20, 50, 100 } /* PIO Mode 5 with IORDY (nonstandard) */
106};
107
108EXPORT_SYMBOL_GPL(ide_pio_timings);
109
110/*
111 * Shared data/functions for determining best PIO mode for an IDE drive.
112 * Most of this stuff originally lived in cmd640.c, and changes to the
113 * ide_pio_blacklist[] table should be made with EXTREME CAUTION to avoid
114 * breaking the fragile cmd640.c support.
115 */
116
117/*
118 * Black list. Some drives incorrectly report their maximal PIO mode,
119 * at least in respect to CMD640. Here we keep info on some known drives.
120 */
121static struct ide_pio_info {
122 const char *name;
123 int pio;
124} ide_pio_blacklist [] = {
125 { "Conner Peripherals 540MB - CFS540A", 3 },
126
127 { "WDC AC2700", 3 },
128 { "WDC AC2540", 3 },
129 { "WDC AC2420", 3 },
130 { "WDC AC2340", 3 },
131 { "WDC AC2250", 0 },
132 { "WDC AC2200", 0 },
133 { "WDC AC21200", 4 },
134 { "WDC AC2120", 0 },
135 { "WDC AC2850", 3 },
136 { "WDC AC1270", 3 },
137 { "WDC AC1170", 1 },
138 { "WDC AC1210", 1 },
139 { "WDC AC280", 0 },
140 { "WDC AC31000", 3 },
141 { "WDC AC31200", 3 },
142
143 { "Maxtor 7131 AT", 1 },
144 { "Maxtor 7171 AT", 1 },
145 { "Maxtor 7213 AT", 1 },
146 { "Maxtor 7245 AT", 1 },
147 { "Maxtor 7345 AT", 1 },
148 { "Maxtor 7546 AT", 3 },
149 { "Maxtor 7540 AV", 3 },
150
151 { "SAMSUNG SHD-3121A", 1 },
152 { "SAMSUNG SHD-3122A", 1 },
153 { "SAMSUNG SHD-3172A", 1 },
154
155 { "ST5660A", 3 },
156 { "ST3660A", 3 },
157 { "ST3630A", 3 },
158 { "ST3655A", 3 },
159 { "ST3391A", 3 },
160 { "ST3390A", 1 },
161 { "ST3600A", 1 },
162 { "ST3290A", 0 },
163 { "ST3144A", 0 },
164 { "ST3491A", 1 }, /* reports 3, should be 1 or 2 (depending on */
165 /* drive) according to Seagates FIND-ATA program */
166
167 { "QUANTUM ELS127A", 0 },
168 { "QUANTUM ELS170A", 0 },
169 { "QUANTUM LPS240A", 0 },
170 { "QUANTUM LPS210A", 3 },
171 { "QUANTUM LPS270A", 3 },
172 { "QUANTUM LPS365A", 3 },
173 { "QUANTUM LPS540A", 3 },
174 { "QUANTUM LIGHTNING 540A", 3 },
175 { "QUANTUM LIGHTNING 730A", 3 },
176
177 { "QUANTUM FIREBALL_540", 3 }, /* Older Quantum Fireballs don't work */
178 { "QUANTUM FIREBALL_640", 3 },
179 { "QUANTUM FIREBALL_1080", 3 },
180 { "QUANTUM FIREBALL_1280", 3 },
181 { NULL, 0 }
182};
183
184/**
185 * ide_scan_pio_blacklist - check for a blacklisted drive
186 * @model: Drive model string
187 *
188 * This routine searches the ide_pio_blacklist for an entry
189 * matching the start/whole of the supplied model name.
190 *
191 * Returns -1 if no match found.
192 * Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
193 */
194
195static int ide_scan_pio_blacklist (char *model)
196{
197 struct ide_pio_info *p;
198
199 for (p = ide_pio_blacklist; p->name != NULL; p++) {
200 if (strncmp(p->name, model, strlen(p->name)) == 0)
201 return p->pio;
202 }
203 return -1;
204}
205
206unsigned int ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
207{
208 struct hd_driveid *id = drive->id;
209 int cycle_time = 0;
210
211 if (id->field_valid & 2) {
212 if (id->capability & 8)
213 cycle_time = id->eide_pio_iordy;
214 else
215 cycle_time = id->eide_pio;
216 }
217
218 /* conservative "downgrade" for all pre-ATA2 drives */
219 if (pio < 3) {
220 if (cycle_time && cycle_time < ide_pio_timings[pio].cycle_time)
221 cycle_time = 0; /* use standard timing */
222 }
223
224 return cycle_time ? cycle_time : ide_pio_timings[pio].cycle_time;
225}
226
227EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
228
229/** 78/**
230 * ide_get_best_pio_mode - get PIO mode from drive 79 * ide_get_best_pio_mode - get PIO mode from drive
231 * @drive: drive to consider 80 * @drive: drive to consider
diff --git a/drivers/ide/ide-pio-blacklist.c b/drivers/ide/ide-pio-blacklist.c
new file mode 100644
index 000000000000..a8c2c8f8660a
--- /dev/null
+++ b/drivers/ide/ide-pio-blacklist.c
@@ -0,0 +1,94 @@
1/*
2 * PIO blacklist. Some drives incorrectly report their maximal PIO mode,
3 * at least in respect to CMD640. Here we keep info on some known drives.
4 *
5 * Changes to the ide_pio_blacklist[] should be made with EXTREME CAUTION
6 * to avoid breaking the fragile cmd640.c support.
7 */
8
9#include <linux/string.h>
10
11static struct ide_pio_info {
12 const char *name;
13 int pio;
14} ide_pio_blacklist [] = {
15 { "Conner Peripherals 540MB - CFS540A", 3 },
16
17 { "WDC AC2700", 3 },
18 { "WDC AC2540", 3 },
19 { "WDC AC2420", 3 },
20 { "WDC AC2340", 3 },
21 { "WDC AC2250", 0 },
22 { "WDC AC2200", 0 },
23 { "WDC AC21200", 4 },
24 { "WDC AC2120", 0 },
25 { "WDC AC2850", 3 },
26 { "WDC AC1270", 3 },
27 { "WDC AC1170", 1 },
28 { "WDC AC1210", 1 },
29 { "WDC AC280", 0 },
30 { "WDC AC31000", 3 },
31 { "WDC AC31200", 3 },
32
33 { "Maxtor 7131 AT", 1 },
34 { "Maxtor 7171 AT", 1 },
35 { "Maxtor 7213 AT", 1 },
36 { "Maxtor 7245 AT", 1 },
37 { "Maxtor 7345 AT", 1 },
38 { "Maxtor 7546 AT", 3 },
39 { "Maxtor 7540 AV", 3 },
40
41 { "SAMSUNG SHD-3121A", 1 },
42 { "SAMSUNG SHD-3122A", 1 },
43 { "SAMSUNG SHD-3172A", 1 },
44
45 { "ST5660A", 3 },
46 { "ST3660A", 3 },
47 { "ST3630A", 3 },
48 { "ST3655A", 3 },
49 { "ST3391A", 3 },
50 { "ST3390A", 1 },
51 { "ST3600A", 1 },
52 { "ST3290A", 0 },
53 { "ST3144A", 0 },
54 { "ST3491A", 1 }, /* reports 3, should be 1 or 2 (depending on drive)
55 according to Seagate's FIND-ATA program */
56
57 { "QUANTUM ELS127A", 0 },
58 { "QUANTUM ELS170A", 0 },
59 { "QUANTUM LPS240A", 0 },
60 { "QUANTUM LPS210A", 3 },
61 { "QUANTUM LPS270A", 3 },
62 { "QUANTUM LPS365A", 3 },
63 { "QUANTUM LPS540A", 3 },
64 { "QUANTUM LIGHTNING 540A", 3 },
65 { "QUANTUM LIGHTNING 730A", 3 },
66
67 { "QUANTUM FIREBALL_540", 3 }, /* Older Quantum Fireballs don't work */
68 { "QUANTUM FIREBALL_640", 3 },
69 { "QUANTUM FIREBALL_1080", 3 },
70 { "QUANTUM FIREBALL_1280", 3 },
71 { NULL, 0 }
72};
73
74/**
75 * ide_scan_pio_blacklist - check for a blacklisted drive
76 * @model: Drive model string
77 *
78 * This routine searches the ide_pio_blacklist for an entry
79 * matching the start/whole of the supplied model name.
80 *
81 * Returns -1 if no match found.
82 * Otherwise returns the recommended PIO mode from ide_pio_blacklist[].
83 */
84
85int ide_scan_pio_blacklist(char *model)
86{
87 struct ide_pio_info *p;
88
89 for (p = ide_pio_blacklist; p->name != NULL; p++) {
90 if (strncmp(p->name, model, strlen(p->name)) == 0)
91 return p->pio;
92 }
93 return -1;
94}
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index adbd01784162..03f2ef5470a3 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -33,6 +33,8 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
33 ide_hwif_t *hwif; 33 ide_hwif_t *hwif;
34 unsigned long base, ctl; 34 unsigned long base, ctl;
35 35
36 printk(KERN_INFO DRV_NAME ": generic PnP IDE interface\n");
37
36 if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) 38 if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0)))
37 return -1; 39 return -1;
38 40
@@ -62,10 +64,8 @@ static int idepnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
62 u8 index = hwif->index; 64 u8 index = hwif->index;
63 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 65 u8 idx[4] = { index, 0xff, 0xff, 0xff };
64 66
65 ide_init_port_data(hwif, index);
66 ide_init_port_hw(hwif, &hw); 67 ide_init_port_hw(hwif, &hw);
67 68
68 printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index);
69 pnp_set_drvdata(dev, hwif); 69 pnp_set_drvdata(dev, hwif);
70 70
71 ide_device_add(idx, NULL); 71 ide_device_add(idx, NULL);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index d21e51a02c3e..235ebdb29b28 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -39,6 +39,8 @@
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42static ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */
43
42/** 44/**
43 * generic_id - add a generic drive id 45 * generic_id - add a generic drive id
44 * @drive: drive to make an ID block for 46 * @drive: drive to make an ID block for
@@ -1318,10 +1320,10 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
1318 drive->unmask = 1; 1320 drive->unmask = 1;
1319 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) 1321 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS)
1320 drive->no_unmask = 1; 1322 drive->no_unmask = 1;
1321 }
1322 1323
1323 if (port_ops && port_ops->port_init_devs) 1324 if (port_ops && port_ops->init_dev)
1324 port_ops->port_init_devs(hwif); 1325 port_ops->init_dev(drive);
1326 }
1325} 1327}
1326 1328
1327static void ide_init_port(ide_hwif_t *hwif, unsigned int port, 1329static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
@@ -1473,22 +1475,29 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d)
1473 for (; i < MAX_HWIFS; i++) { 1475 for (; i < MAX_HWIFS; i++) {
1474 hwif = &ide_hwifs[i]; 1476 hwif = &ide_hwifs[i];
1475 if (hwif->chipset == ide_unknown) 1477 if (hwif->chipset == ide_unknown)
1476 return hwif; 1478 goto out_found;
1477 } 1479 }
1478 } else { 1480 } else {
1479 for (i = 2; i < MAX_HWIFS; i++) { 1481 for (i = 2; i < MAX_HWIFS; i++) {
1480 hwif = &ide_hwifs[i]; 1482 hwif = &ide_hwifs[i];
1481 if (hwif->chipset == ide_unknown) 1483 if (hwif->chipset == ide_unknown)
1482 return hwif; 1484 goto out_found;
1483 } 1485 }
1484 for (i = 0; i < 2 && i < MAX_HWIFS; i++) { 1486 for (i = 0; i < 2 && i < MAX_HWIFS; i++) {
1485 hwif = &ide_hwifs[i]; 1487 hwif = &ide_hwifs[i];
1486 if (hwif->chipset == ide_unknown) 1488 if (hwif->chipset == ide_unknown)
1487 return hwif; 1489 goto out_found;
1488 } 1490 }
1489 } 1491 }
1490 1492
1493 printk(KERN_ERR "%s: no free slot for interface\n",
1494 d ? d->name : "ide");
1495
1491 return NULL; 1496 return NULL;
1497
1498out_found:
1499 ide_init_port_data(hwif, i);
1500 return hwif;
1492} 1501}
1493EXPORT_SYMBOL_GPL(ide_find_port_slot); 1502EXPORT_SYMBOL_GPL(ide_find_port_slot);
1494 1503
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index f9cf1670e4e1..b711ab96e287 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2591,7 +2591,6 @@ static ide_driver_t idetape_driver = {
2591 .do_request = idetape_do_request, 2591 .do_request = idetape_do_request,
2592 .end_request = idetape_end_request, 2592 .end_request = idetape_end_request,
2593 .error = __ide_error, 2593 .error = __ide_error,
2594 .abort = __ide_abort,
2595#ifdef CONFIG_IDE_PROC_FS 2594#ifdef CONFIG_IDE_PROC_FS
2596 .proc = idetape_proc, 2595 .proc = idetape_proc,
2597#endif 2596#endif
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index cf55a48a7dd2..1fbdb746dc88 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -8,28 +8,18 @@
8 * The big the bad and the ugly. 8 * The big the bad and the ugly.
9 */ 9 */
10 10
11#include <linux/module.h>
12#include <linux/types.h> 11#include <linux/types.h>
13#include <linux/string.h> 12#include <linux/string.h>
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/timer.h>
16#include <linux/mm.h>
17#include <linux/sched.h> 14#include <linux/sched.h>
18#include <linux/interrupt.h> 15#include <linux/interrupt.h>
19#include <linux/major.h>
20#include <linux/errno.h> 16#include <linux/errno.h>
21#include <linux/genhd.h>
22#include <linux/blkpg.h>
23#include <linux/slab.h> 17#include <linux/slab.h>
24#include <linux/pci.h>
25#include <linux/delay.h> 18#include <linux/delay.h>
26#include <linux/hdreg.h> 19#include <linux/hdreg.h>
27#include <linux/ide.h> 20#include <linux/ide.h>
28#include <linux/bitops.h>
29#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
30 22
31#include <asm/byteorder.h>
32#include <asm/irq.h>
33#include <asm/uaccess.h> 23#include <asm/uaccess.h>
34#include <asm/io.h> 24#include <asm/io.h>
35 25
@@ -62,25 +52,6 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
62 return ide_raw_taskfile(drive, &args, buf, 1); 52 return ide_raw_taskfile(drive, &args, buf, 1);
63} 53}
64 54
65static int inline task_dma_ok(ide_task_t *task)
66{
67 if (blk_fs_request(task->rq) || (task->tf_flags & IDE_TFLAG_FLAGGED))
68 return 1;
69
70 switch (task->tf.command) {
71 case WIN_WRITEDMA_ONCE:
72 case WIN_WRITEDMA:
73 case WIN_WRITEDMA_EXT:
74 case WIN_READDMA_ONCE:
75 case WIN_READDMA:
76 case WIN_READDMA_EXT:
77 case WIN_IDENTIFY_DMA:
78 return 1;
79 }
80
81 return 0;
82}
83
84static ide_startstop_t task_no_data_intr(ide_drive_t *); 55static ide_startstop_t task_no_data_intr(ide_drive_t *);
85static ide_startstop_t set_geometry_intr(ide_drive_t *); 56static ide_startstop_t set_geometry_intr(ide_drive_t *);
86static ide_startstop_t recal_intr(ide_drive_t *); 57static ide_startstop_t recal_intr(ide_drive_t *);
@@ -139,8 +110,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
139 WAIT_WORSTCASE, NULL); 110 WAIT_WORSTCASE, NULL);
140 return ide_started; 111 return ide_started;
141 default: 112 default:
142 if (task_dma_ok(task) == 0 || drive->using_dma == 0 || 113 if (drive->using_dma == 0 || dma_ops->dma_setup(drive))
143 dma_ops->dma_setup(drive))
144 return ide_stopped; 114 return ide_stopped;
145 dma_ops->dma_exec_cmd(drive, tf->command); 115 dma_ops->dma_exec_cmd(drive, tf->command);
146 dma_ops->dma_start(drive); 116 dma_ops->dma_start(drive);
@@ -183,7 +153,6 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
183 if (stat & (ERR_STAT|DRQ_STAT)) 153 if (stat & (ERR_STAT|DRQ_STAT))
184 return ide_error(drive, "set_geometry_intr", stat); 154 return ide_error(drive, "set_geometry_intr", stat);
185 155
186 BUG_ON(HWGROUP(drive)->handler != NULL);
187 ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL); 156 ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL);
188 return ide_started; 157 return ide_started;
189} 158}
diff --git a/drivers/ide/ide-timing.h b/drivers/ide/ide-timings.c
index 2e91c5870b4c..8c2f8327f487 100644
--- a/drivers/ide/ide-timing.h
+++ b/drivers/ide/ide-timings.c
@@ -1,11 +1,7 @@
1#ifndef _IDE_TIMING_H
2#define _IDE_TIMING_H
3
4/* 1/*
5 * Copyright (c) 1999-2001 Vojtech Pavlik 2 * Copyright (c) 1999-2001 Vojtech Pavlik
6 */ 3 * Copyright (c) 2007-2008 Bartlomiej Zolnierkiewicz
7 4 *
8/*
9 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
@@ -27,27 +23,14 @@
27 23
28#include <linux/kernel.h> 24#include <linux/kernel.h>
29#include <linux/hdreg.h> 25#include <linux/hdreg.h>
30 26#include <linux/ide.h>
31#define XFER_PIO_5 0x0d 27#include <linux/module.h>
32#define XFER_UDMA_SLOW 0x4f
33
34struct ide_timing {
35 short mode;
36 short setup; /* t1 */
37 short act8b; /* t2 for 8-bit io */
38 short rec8b; /* t2i for 8-bit io */
39 short cyc8b; /* t0 for 8-bit io */
40 short active; /* t2 or tD */
41 short recover; /* t2i or tK */
42 short cycle; /* t0 */
43 short udma; /* t2CYCTYP/2 */
44};
45 28
46/* 29/*
47 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds). 30 * PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
48 * These were taken from ATA/ATAPI-6 standard, rev 0a, except 31 * These were taken from ATA/ATAPI-6 standard, rev 0a, except
49 * for PIO 5, which is a nonstandard extension and UDMA6, which 32 * for PIO 5, which is a nonstandard extension and UDMA6, which
50 * is currently supported only by Maxtor drives. 33 * is currently supported only by Maxtor drives.
51 */ 34 */
52 35
53static struct ide_timing ide_timing[] = { 36static struct ide_timing ide_timing[] = {
@@ -61,12 +44,10 @@ static struct ide_timing ide_timing[] = {
61 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 }, 44 { XFER_UDMA_1, 0, 0, 0, 0, 0, 0, 0, 80 },
62 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 }, 45 { XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
63 46
64 { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 },
65
66 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 }, 47 { XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 },
67 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 }, 48 { XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 },
68 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 }, 49 { XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
69 50
70 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 }, 51 { XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 },
71 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 }, 52 { XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
72 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 }, 53 { XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
@@ -81,29 +62,46 @@ static struct ide_timing ide_timing[] = {
81 62
82 { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 }, 63 { XFER_PIO_SLOW, 120, 290, 240, 960, 290, 240, 960, 0 },
83 64
84 { -1 } 65 { 0xff }
85}; 66};
86 67
87#define IDE_TIMING_SETUP 0x01 68struct ide_timing *ide_timing_find_mode(u8 speed)
88#define IDE_TIMING_ACT8B 0x02 69{
89#define IDE_TIMING_REC8B 0x04 70 struct ide_timing *t;
90#define IDE_TIMING_CYC8B 0x08 71
91#define IDE_TIMING_8BIT 0x0e 72 for (t = ide_timing; t->mode != speed; t++)
92#define IDE_TIMING_ACTIVE 0x10 73 if (t->mode == 0xff)
93#define IDE_TIMING_RECOVER 0x20 74 return NULL;
94#define IDE_TIMING_CYCLE 0x40 75 return t;
95#define IDE_TIMING_UDMA 0x80 76}
96#define IDE_TIMING_ALL 0xff 77EXPORT_SYMBOL_GPL(ide_timing_find_mode);
97 78
98#define ENOUGH(v,unit) (((v)-1)/(unit)+1) 79u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio)
99#define EZ(v,unit) ((v)?ENOUGH(v,unit):0) 80{
100 81 struct hd_driveid *id = drive->id;
101#define XFER_MODE 0xf0 82 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
102#define XFER_MWDMA 0x20 83 u16 cycle = 0;
103#define XFER_EPIO 0x01 84
104#define XFER_PIO 0x00 85 if (id->field_valid & 2) {
105 86 if (id->capability & 8)
106static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT) 87 cycle = id->eide_pio_iordy;
88 else
89 cycle = id->eide_pio;
90
91 /* conservative "downgrade" for all pre-ATA2 drives */
92 if (pio < 3 && cycle < t->cycle)
93 cycle = 0; /* use standard timing */
94 }
95
96 return cycle ? cycle : t->cycle;
97}
98EXPORT_SYMBOL_GPL(ide_pio_cycle_time);
99
100#define ENOUGH(v, unit) (((v) - 1) / (unit) + 1)
101#define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0)
102
103static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q,
104 int T, int UT)
107{ 105{
108 q->setup = EZ(t->setup * 1000, T); 106 q->setup = EZ(t->setup * 1000, T);
109 q->act8b = EZ(t->act8b * 1000, T); 107 q->act8b = EZ(t->act8b * 1000, T);
@@ -115,92 +113,83 @@ static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int
115 q->udma = EZ(t->udma * 1000, UT); 113 q->udma = EZ(t->udma * 1000, UT);
116} 114}
117 115
118static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, struct ide_timing *m, unsigned int what) 116void ide_timing_merge(struct ide_timing *a, struct ide_timing *b,
119{ 117 struct ide_timing *m, unsigned int what)
120 if (what & IDE_TIMING_SETUP ) m->setup = max(a->setup, b->setup);
121 if (what & IDE_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b);
122 if (what & IDE_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b);
123 if (what & IDE_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b);
124 if (what & IDE_TIMING_ACTIVE ) m->active = max(a->active, b->active);
125 if (what & IDE_TIMING_RECOVER) m->recover = max(a->recover, b->recover);
126 if (what & IDE_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle);
127 if (what & IDE_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
128}
129
130static struct ide_timing* ide_timing_find_mode(short speed)
131{ 118{
132 struct ide_timing *t; 119 if (what & IDE_TIMING_SETUP)
133 120 m->setup = max(a->setup, b->setup);
134 for (t = ide_timing; t->mode != speed; t++) 121 if (what & IDE_TIMING_ACT8B)
135 if (t->mode < 0) 122 m->act8b = max(a->act8b, b->act8b);
136 return NULL; 123 if (what & IDE_TIMING_REC8B)
137 return t; 124 m->rec8b = max(a->rec8b, b->rec8b);
125 if (what & IDE_TIMING_CYC8B)
126 m->cyc8b = max(a->cyc8b, b->cyc8b);
127 if (what & IDE_TIMING_ACTIVE)
128 m->active = max(a->active, b->active);
129 if (what & IDE_TIMING_RECOVER)
130 m->recover = max(a->recover, b->recover);
131 if (what & IDE_TIMING_CYCLE)
132 m->cycle = max(a->cycle, b->cycle);
133 if (what & IDE_TIMING_UDMA)
134 m->udma = max(a->udma, b->udma);
138} 135}
136EXPORT_SYMBOL_GPL(ide_timing_merge);
139 137
140static int ide_timing_compute(ide_drive_t *drive, short speed, struct ide_timing *t, int T, int UT) 138int ide_timing_compute(ide_drive_t *drive, u8 speed,
139 struct ide_timing *t, int T, int UT)
141{ 140{
142 struct hd_driveid *id = drive->id; 141 struct hd_driveid *id = drive->id;
143 struct ide_timing *s, p; 142 struct ide_timing *s, p;
144 143
145/* 144 /*
146 * Find the mode. 145 * Find the mode.
147 */ 146 */
148 147 s = ide_timing_find_mode(speed);
149 if (!(s = ide_timing_find_mode(speed))) 148 if (s == NULL)
150 return -EINVAL; 149 return -EINVAL;
151 150
152/* 151 /*
153 * Copy the timing from the table. 152 * Copy the timing from the table.
154 */ 153 */
155
156 *t = *s; 154 *t = *s;
157 155
158/* 156 /*
159 * If the drive is an EIDE drive, it can tell us it needs extended 157 * If the drive is an EIDE drive, it can tell us it needs extended
160 * PIO/MWDMA cycle timing. 158 * PIO/MWDMA cycle timing.
161 */ 159 */
162
163 if (id && id->field_valid & 2) { /* EIDE drive */ 160 if (id && id->field_valid & 2) { /* EIDE drive */
164 161
165 memset(&p, 0, sizeof(p)); 162 memset(&p, 0, sizeof(p));
166 163
167 switch (speed & XFER_MODE) { 164 if (speed <= XFER_PIO_2)
168 165 p.cycle = p.cyc8b = id->eide_pio;
169 case XFER_PIO: 166 else if (speed <= XFER_PIO_5)
170 if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = id->eide_pio; 167 p.cycle = p.cyc8b = id->eide_pio_iordy;
171 else p.cycle = p.cyc8b = id->eide_pio_iordy; 168 else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2)
172 break; 169 p.cycle = id->eide_dma_min;
173
174 case XFER_MWDMA:
175 p.cycle = id->eide_dma_min;
176 break;
177 }
178 170
179 ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B); 171 ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B);
180 } 172 }
181 173
182/* 174 /*
183 * Convert the timing to bus clock counts. 175 * Convert the timing to bus clock counts.
184 */ 176 */
185
186 ide_timing_quantize(t, t, T, UT); 177 ide_timing_quantize(t, t, T, UT);
187 178
188/* 179 /*
189 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T 180 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY,
190 * and some other commands. We have to ensure that the DMA cycle timing is 181 * S.M.A.R.T and some other commands. We have to ensure that the
191 * slower/equal than the fastest PIO timing. 182 * DMA cycle timing is slower/equal than the fastest PIO timing.
192 */ 183 */
193 184 if (speed >= XFER_SW_DMA_0) {
194 if ((speed & XFER_MODE) != XFER_PIO) {
195 u8 pio = ide_get_best_pio_mode(drive, 255, 5); 185 u8 pio = ide_get_best_pio_mode(drive, 255, 5);
196 ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT); 186 ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT);
197 ide_timing_merge(&p, t, t, IDE_TIMING_ALL); 187 ide_timing_merge(&p, t, t, IDE_TIMING_ALL);
198 } 188 }
199 189
200/* 190 /*
201 * Lengthen active & recovery time so that cycle time is correct. 191 * Lengthen active & recovery time so that cycle time is correct.
202 */ 192 */
203
204 if (t->act8b + t->rec8b < t->cyc8b) { 193 if (t->act8b + t->rec8b < t->cyc8b) {
205 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2; 194 t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2;
206 t->rec8b = t->cyc8b - t->act8b; 195 t->rec8b = t->cyc8b - t->act8b;
@@ -213,5 +202,4 @@ static int ide_timing_compute(ide_drive_t *drive, short speed, struct ide_timing
213 202
214 return 0; 203 return 0;
215} 204}
216 205EXPORT_SYMBOL_GPL(ide_timing_compute);
217#endif
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 2b8453510e09..d4a6b102a772 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -50,29 +50,16 @@
50#include <linux/types.h> 50#include <linux/types.h>
51#include <linux/string.h> 51#include <linux/string.h>
52#include <linux/kernel.h> 52#include <linux/kernel.h>
53#include <linux/timer.h>
54#include <linux/mm.h>
55#include <linux/interrupt.h> 53#include <linux/interrupt.h>
56#include <linux/major.h> 54#include <linux/major.h>
57#include <linux/errno.h> 55#include <linux/errno.h>
58#include <linux/genhd.h> 56#include <linux/genhd.h>
59#include <linux/blkpg.h>
60#include <linux/slab.h> 57#include <linux/slab.h>
61#include <linux/init.h> 58#include <linux/init.h>
62#include <linux/pci.h> 59#include <linux/pci.h>
63#include <linux/delay.h>
64#include <linux/ide.h> 60#include <linux/ide.h>
65#include <linux/completion.h> 61#include <linux/completion.h>
66#include <linux/reboot.h>
67#include <linux/cdrom.h>
68#include <linux/seq_file.h>
69#include <linux/device.h> 62#include <linux/device.h>
70#include <linux/bitops.h>
71
72#include <asm/byteorder.h>
73#include <asm/irq.h>
74#include <asm/uaccess.h>
75#include <asm/io.h>
76 63
77 64
78/* default maximum number of failures */ 65/* default maximum number of failures */
@@ -91,8 +78,6 @@ DEFINE_MUTEX(ide_cfg_mtx);
91__cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); 78__cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
92EXPORT_SYMBOL(ide_lock); 79EXPORT_SYMBOL(ide_lock);
93 80
94ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */
95
96static void ide_port_init_devices_data(ide_hwif_t *); 81static void ide_port_init_devices_data(ide_hwif_t *);
97 82
98/* 83/*
@@ -121,7 +106,6 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
121 106
122 ide_port_init_devices_data(hwif); 107 ide_port_init_devices_data(hwif);
123} 108}
124EXPORT_SYMBOL_GPL(ide_init_port_data);
125 109
126static void ide_port_init_devices_data(ide_hwif_t *hwif) 110static void ide_port_init_devices_data(ide_hwif_t *hwif)
127{ 111{
@@ -150,18 +134,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
150 } 134 }
151} 135}
152 136
153static void __init init_ide_data (void)
154{
155 unsigned int index;
156
157 /* Initialise all interface structures */
158 for (index = 0; index < MAX_HWIFS; ++index) {
159 ide_hwif_t *hwif = &ide_hwifs[index];
160
161 ide_init_port_data(hwif, index);
162 }
163}
164
165void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) 137void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
166{ 138{
167 ide_hwgroup_t *hwgroup = hwif->hwgroup; 139 ide_hwgroup_t *hwgroup = hwif->hwgroup;
@@ -312,7 +284,8 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw)
312 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); 284 memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports));
313 hwif->irq = hw->irq; 285 hwif->irq = hw->irq;
314 hwif->chipset = hw->chipset; 286 hwif->chipset = hw->chipset;
315 hwif->gendev.parent = hw->dev; 287 hwif->dev = hw->dev;
288 hwif->gendev.parent = hw->parent ? hw->parent : hw->dev;
316 hwif->ack_intr = hw->ack_intr; 289 hwif->ack_intr = hw->ack_intr;
317} 290}
318EXPORT_SYMBOL_GPL(ide_init_port_hw); 291EXPORT_SYMBOL_GPL(ide_init_port_hw);
@@ -556,6 +529,22 @@ static int generic_ide_resume(struct device *dev)
556 return err; 529 return err;
557} 530}
558 531
532static int generic_drive_reset(ide_drive_t *drive)
533{
534 struct request *rq;
535 int ret = 0;
536
537 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
538 rq->cmd_type = REQ_TYPE_SPECIAL;
539 rq->cmd_len = 1;
540 rq->cmd[0] = REQ_DRIVE_RESET;
541 rq->cmd_flags |= REQ_SOFTBARRIER;
542 if (blk_execute_rq(drive->queue, NULL, rq, 1))
543 ret = rq->errors;
544 blk_put_request(rq);
545 return ret;
546}
547
559int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, 548int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
560 unsigned int cmd, unsigned long arg) 549 unsigned int cmd, unsigned long arg)
561{ 550{
@@ -630,33 +619,8 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
630 if (!capable(CAP_SYS_ADMIN)) 619 if (!capable(CAP_SYS_ADMIN))
631 return -EACCES; 620 return -EACCES;
632 621
633 /* 622 return generic_drive_reset(drive);
634 * Abort the current command on the
635 * group if there is one, taking
636 * care not to allow anything else
637 * to be queued and to die on the
638 * spot if we miss one somehow
639 */
640
641 spin_lock_irqsave(&ide_lock, flags);
642
643 if (HWGROUP(drive)->resetting) {
644 spin_unlock_irqrestore(&ide_lock, flags);
645 return -EBUSY;
646 }
647 623
648 ide_abort(drive, "drive reset");
649
650 BUG_ON(HWGROUP(drive)->handler);
651
652 /* Ensure nothing gets queued after we
653 drop the lock. Reset will clear the busy */
654
655 HWGROUP(drive)->busy = 1;
656 spin_unlock_irqrestore(&ide_lock, flags);
657 (void) ide_do_reset(drive);
658
659 return 0;
660 case HDIO_GET_BUSSTATE: 624 case HDIO_GET_BUSSTATE:
661 if (!capable(CAP_SYS_ADMIN)) 625 if (!capable(CAP_SYS_ADMIN))
662 return -EACCES; 626 return -EACCES;
@@ -1021,8 +985,6 @@ static int __init ide_init(void)
1021 goto out_port_class; 985 goto out_port_class;
1022 } 986 }
1023 987
1024 init_ide_data();
1025
1026 proc_ide_create(); 988 proc_ide_create();
1027 989
1028 return 0; 990 return 0;
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index 052125fafcfa..4ec19737f3c5 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -117,10 +117,11 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
117 u8 param1, param2, param3, param4; 117 u8 param1, param2, param3, param4;
118 unsigned long flags; 118 unsigned long flags;
119 int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; 119 int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
120 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
120 121
121 /* calculate timing, according to PIO mode */ 122 /* calculate timing, according to PIO mode */
122 time1 = ide_pio_cycle_time(drive, pio); 123 time1 = ide_pio_cycle_time(drive, pio);
123 time2 = ide_pio_timings[pio].active_time; 124 time2 = t->active;
124 param3 = param1 = (time2 * bus_speed + 999) / 1000; 125 param3 = param1 = (time2 * bus_speed + 999) / 1000;
125 param4 = param2 = (time1 * bus_speed + 999) / 1000 - param1; 126 param4 = param2 = (time1 * bus_speed + 999) / 1000 - param1;
126 if (pio < 3) { 127 if (pio < 3) {
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c
index 9a1d27ef3f8a..0497e7f85b09 100644
--- a/drivers/ide/legacy/buddha.c
+++ b/drivers/ide/legacy/buddha.c
@@ -227,7 +227,6 @@ fail_base2:
227 if (hwif) { 227 if (hwif) {
228 u8 index = hwif->index; 228 u8 index = hwif->index;
229 229
230 ide_init_port_data(hwif, index);
231 ide_init_port_hw(hwif, &hw); 230 ide_init_port_hw(hwif, &hw);
232 231
233 idx[i] = index; 232 idx[i] = index;
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index af11028b4794..129a812bb57f 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -111,7 +111,6 @@ static int __init falconide_init(void)
111 u8 index = hwif->index; 111 u8 index = hwif->index;
112 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 112 u8 idx[4] = { index, 0xff, 0xff, 0xff };
113 113
114 ide_init_port_data(hwif, index);
115 ide_init_port_hw(hwif, &hw); 114 ide_init_port_hw(hwif, &hw);
116 115
117 /* Atari has a byte-swapped IDE interface */ 116 /* Atari has a byte-swapped IDE interface */
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index b78941680c32..7e74b20202df 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -185,7 +185,6 @@ found:
185 if (hwif) { 185 if (hwif) {
186 u8 index = hwif->index; 186 u8 index = hwif->index;
187 187
188 ide_init_port_data(hwif, index);
189 ide_init_port_hw(hwif, &hw); 188 ide_init_port_hw(hwif, &hw);
190 189
191 idx[i] = index; 190 idx[i] = index;
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index dd6dfb32e853..7bc8fd59ea9e 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -216,6 +216,7 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio)
216 216
217 if (pio) { 217 if (pio) {
218 unsigned int cycle_time; 218 unsigned int cycle_time;
219 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
219 220
220 cycle_time = ide_pio_cycle_time(drive, pio); 221 cycle_time = ide_pio_cycle_time(drive, pio);
221 222
@@ -224,10 +225,8 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio)
224 * actual cycle time for recovery and activity 225 * actual cycle time for recovery and activity
225 * according system bus speed. 226 * according system bus speed.
226 */ 227 */
227 active_time = ide_pio_timings[pio].active_time; 228 active_time = t->active;
228 recovery_time = cycle_time 229 recovery_time = cycle_time - active_time - t->setup;
229 - active_time
230 - ide_pio_timings[pio].setup_time;
231 /* 230 /*
232 * Cycle times should be Vesa bus cycles 231 * Cycle times should be Vesa bus cycles
233 */ 232 */
@@ -311,16 +310,16 @@ static void ht6560b_set_pio_mode(ide_drive_t *drive, const u8 pio)
311#endif 310#endif
312} 311}
313 312
314static void __init ht6560b_port_init_devs(ide_hwif_t *hwif) 313static void __init ht6560b_init_dev(ide_drive_t *drive)
315{ 314{
315 ide_hwif_t *hwif = drive->hwif;
316 /* Setting default configurations for drives. */ 316 /* Setting default configurations for drives. */
317 int t = (HT_CONFIG_DEFAULT << 8) | HT_TIMING_DEFAULT; 317 int t = (HT_CONFIG_DEFAULT << 8) | HT_TIMING_DEFAULT;
318 318
319 if (hwif->channel) 319 if (hwif->channel)
320 t |= (HT_SECONDARY_IF << 8); 320 t |= (HT_SECONDARY_IF << 8);
321 321
322 hwif->drives[0].drive_data = t; 322 drive->drive_data = t;
323 hwif->drives[1].drive_data = t;
324} 323}
325 324
326static int probe_ht6560b; 325static int probe_ht6560b;
@@ -329,7 +328,7 @@ module_param_named(probe, probe_ht6560b, bool, 0);
329MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); 328MODULE_PARM_DESC(probe, "probe for HT6560B chipset");
330 329
331static const struct ide_port_ops ht6560b_port_ops = { 330static const struct ide_port_ops ht6560b_port_ops = {
332 .port_init_devs = ht6560b_port_init_devs, 331 .init_dev = ht6560b_init_dev,
333 .set_pio_mode = ht6560b_set_pio_mode, 332 .set_pio_mode = ht6560b_set_pio_mode,
334 .selectproc = ht6560b_selectproc, 333 .selectproc = ht6560b_selectproc,
335}; 334};
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/legacy/ide-4drives.c
index ecae916a3385..89c8ff0a4d08 100644
--- a/drivers/ide/legacy/ide-4drives.c
+++ b/drivers/ide/legacy/ide-4drives.c
@@ -11,6 +11,21 @@ static int probe_4drives;
11module_param_named(probe, probe_4drives, bool, 0); 11module_param_named(probe, probe_4drives, bool, 0);
12MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); 12MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
13 13
14static void ide_4drives_init_dev(ide_drive_t *drive)
15{
16 if (drive->hwif->channel)
17 drive->select.all ^= 0x20;
18}
19
20static const struct ide_port_ops ide_4drives_port_ops = {
21 .init_dev = ide_4drives_init_dev,
22};
23
24static const struct ide_port_info ide_4drives_port_info = {
25 .port_ops = &ide_4drives_port_ops,
26 .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA,
27};
28
14static int __init ide_4drives_init(void) 29static int __init ide_4drives_init(void)
15{ 30{
16 ide_hwif_t *hwif, *mate; 31 ide_hwif_t *hwif, *mate;
@@ -49,18 +64,10 @@ static int __init ide_4drives_init(void)
49 mate = ide_find_port(); 64 mate = ide_find_port();
50 if (mate) { 65 if (mate) {
51 ide_init_port_hw(mate, &hw); 66 ide_init_port_hw(mate, &hw);
52 mate->drives[0].select.all ^= 0x20;
53 mate->drives[1].select.all ^= 0x20;
54 idx[1] = mate->index; 67 idx[1] = mate->index;
55
56 if (hwif) {
57 hwif->mate = mate;
58 mate->mate = hwif;
59 hwif->serialized = mate->serialized = 1;
60 }
61 } 68 }
62 69
63 ide_device_add(idx, NULL); 70 ide_device_add(idx, &ide_4drives_port_info);
64 71
65 return 0; 72 return 0;
66} 73}
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 8dbf4d9b6447..fc53dcfbfe38 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -154,6 +154,11 @@ static const struct ide_port_ops idecs_port_ops = {
154 .quirkproc = ide_undecoded_slave, 154 .quirkproc = ide_undecoded_slave,
155}; 155};
156 156
157static const struct ide_port_info idecs_port_info = {
158 .port_ops = &idecs_port_ops,
159 .host_flags = IDE_HFLAG_NO_DMA,
160};
161
157static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, 162static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl,
158 unsigned long irq, struct pcmcia_device *handle) 163 unsigned long irq, struct pcmcia_device *handle)
159{ 164{
@@ -187,13 +192,11 @@ static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl,
187 192
188 i = hwif->index; 193 i = hwif->index;
189 194
190 ide_init_port_data(hwif, i);
191 ide_init_port_hw(hwif, &hw); 195 ide_init_port_hw(hwif, &hw);
192 hwif->port_ops = &idecs_port_ops;
193 196
194 idx[0] = i; 197 idx[0] = i;
195 198
196 ide_device_add(idx, NULL); 199 ide_device_add(idx, &idecs_port_info);
197 200
198 if (hwif->present) 201 if (hwif->present)
199 return hwif; 202 return hwif;
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/legacy/ide_platform.c
index d3bc3f24e05d..a249562b34b5 100644
--- a/drivers/ide/legacy/ide_platform.c
+++ b/drivers/ide/legacy/ide_platform.c
@@ -44,6 +44,10 @@ static void __devinit plat_ide_setup_ports(hw_regs_t *hw,
44 hw->chipset = ide_generic; 44 hw->chipset = ide_generic;
45} 45}
46 46
47static const struct ide_port_info platform_ide_port_info = {
48 .host_flags = IDE_HFLAG_NO_DMA,
49};
50
47static int __devinit plat_ide_probe(struct platform_device *pdev) 51static int __devinit plat_ide_probe(struct platform_device *pdev)
48{ 52{
49 struct resource *res_base, *res_alt, *res_irq; 53 struct resource *res_base, *res_alt, *res_irq;
@@ -54,6 +58,7 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
54 int ret = 0; 58 int ret = 0;
55 int mmio = 0; 59 int mmio = 0;
56 hw_regs_t hw; 60 hw_regs_t hw;
61 struct ide_port_info d = platform_ide_port_info;
57 62
58 pdata = pdev->dev.platform_data; 63 pdata = pdev->dev.platform_data;
59 64
@@ -102,13 +107,13 @@ static int __devinit plat_ide_probe(struct platform_device *pdev)
102 ide_init_port_hw(hwif, &hw); 107 ide_init_port_hw(hwif, &hw);
103 108
104 if (mmio) { 109 if (mmio) {
105 hwif->host_flags = IDE_HFLAG_MMIO; 110 d.host_flags |= IDE_HFLAG_MMIO;
106 default_hwif_mmiops(hwif); 111 default_hwif_mmiops(hwif);
107 } 112 }
108 113
109 idx[0] = hwif->index; 114 idx[0] = hwif->index;
110 115
111 ide_device_add(idx, NULL); 116 ide_device_add(idx, &d);
112 117
113 platform_set_drvdata(pdev, hwif); 118 platform_set_drvdata(pdev, hwif);
114 119
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
index 2e84290d0bcc..0a6195bcfeda 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/legacy/macide.c
@@ -130,7 +130,6 @@ static int __init macide_init(void)
130 u8 index = hwif->index; 130 u8 index = hwif->index;
131 u8 idx[4] = { index, 0xff, 0xff, 0xff }; 131 u8 idx[4] = { index, 0xff, 0xff, 0xff };
132 132
133 ide_init_port_data(hwif, index);
134 ide_init_port_hw(hwif, &hw); 133 ide_init_port_hw(hwif, &hw);
135 134
136 ide_device_add(idx, NULL); 135 ide_device_add(idx, NULL);
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index 8ff6e2d20834..9c2b9d078f69 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -142,7 +142,6 @@ static int __init q40ide_init(void)
142 142
143 hwif = ide_find_port(); 143 hwif = ide_find_port();
144 if (hwif) { 144 if (hwif) {
145 ide_init_port_data(hwif, hwif->index);
146 ide_init_port_hw(hwif, &hw); 145 ide_init_port_hw(hwif, &hw);
147 146
148 /* Q40 has a byte-swapped IDE interface */ 147 /* Q40 has a byte-swapped IDE interface */
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index 51dba82f8812..2338f344ea24 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -207,6 +207,7 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio)
207static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) 207static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio)
208{ 208{
209 ide_hwif_t *hwif = drive->hwif; 209 ide_hwif_t *hwif = drive->hwif;
210 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
210 unsigned int cycle_time; 211 unsigned int cycle_time;
211 int active_time = 175; 212 int active_time = 175;
212 int recovery_time = 415; /* worst case values from the dos driver */ 213 int recovery_time = 415; /* worst case values from the dos driver */
@@ -236,7 +237,7 @@ static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio)
236 active_time = 110; 237 active_time = 110;
237 recovery_time = cycle_time - 120; 238 recovery_time = cycle_time - 120;
238 } else { 239 } else {
239 active_time = ide_pio_timings[pio].active_time; 240 active_time = t->active;
240 recovery_time = cycle_time - active_time; 241 recovery_time = cycle_time - active_time;
241 } 242 }
242 } 243 }
@@ -281,17 +282,18 @@ static int __init qd_testreg(int port)
281 return (readreg != QD_TESTVAL); 282 return (readreg != QD_TESTVAL);
282} 283}
283 284
284static void __init qd6500_port_init_devs(ide_hwif_t *hwif) 285static void __init qd6500_init_dev(ide_drive_t *drive)
285{ 286{
287 ide_hwif_t *hwif = drive->hwif;
286 u8 base = (hwif->config_data & 0xff00) >> 8; 288 u8 base = (hwif->config_data & 0xff00) >> 8;
287 u8 config = QD_CONFIG(hwif); 289 u8 config = QD_CONFIG(hwif);
288 290
289 hwif->drives[0].drive_data = QD6500_DEF_DATA; 291 drive->drive_data = QD6500_DEF_DATA;
290 hwif->drives[1].drive_data = QD6500_DEF_DATA;
291} 292}
292 293
293static void __init qd6580_port_init_devs(ide_hwif_t *hwif) 294static void __init qd6580_init_dev(ide_drive_t *drive)
294{ 295{
296 ide_hwif_t *hwif = drive->hwif;
295 u16 t1, t2; 297 u16 t1, t2;
296 u8 base = (hwif->config_data & 0xff00) >> 8; 298 u8 base = (hwif->config_data & 0xff00) >> 8;
297 u8 config = QD_CONFIG(hwif); 299 u8 config = QD_CONFIG(hwif);
@@ -302,18 +304,17 @@ static void __init qd6580_port_init_devs(ide_hwif_t *hwif)
302 } else 304 } else
303 t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA; 305 t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA;
304 306
305 hwif->drives[0].drive_data = t1; 307 drive->drive_data = drive->select.b.unit ? t2 : t1;
306 hwif->drives[1].drive_data = t2;
307} 308}
308 309
309static const struct ide_port_ops qd6500_port_ops = { 310static const struct ide_port_ops qd6500_port_ops = {
310 .port_init_devs = qd6500_port_init_devs, 311 .init_dev = qd6500_init_dev,
311 .set_pio_mode = qd6500_set_pio_mode, 312 .set_pio_mode = qd6500_set_pio_mode,
312 .selectproc = qd65xx_select, 313 .selectproc = qd65xx_select,
313}; 314};
314 315
315static const struct ide_port_ops qd6580_port_ops = { 316static const struct ide_port_ops qd6580_port_ops = {
316 .port_init_devs = qd6580_port_init_devs, 317 .init_dev = qd6580_init_dev,
317 .set_pio_mode = qd6580_set_pio_mode, 318 .set_pio_mode = qd6580_set_pio_mode,
318 .selectproc = qd65xx_select, 319 .selectproc = qd65xx_select,
319}; 320};
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index 1a6c27b32498..48d57cae63c6 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -213,10 +213,8 @@ static int auide_build_dmatable(ide_drive_t *drive)
213{ 213{
214 int i, iswrite, count = 0; 214 int i, iswrite, count = 0;
215 ide_hwif_t *hwif = HWIF(drive); 215 ide_hwif_t *hwif = HWIF(drive);
216
217 struct request *rq = HWGROUP(drive)->rq; 216 struct request *rq = HWGROUP(drive)->rq;
218 217 _auide_hwif *ahwif = &auide_hwif;
219 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
220 struct scatterlist *sg; 218 struct scatterlist *sg;
221 219
222 iswrite = (rq_data_dir(rq) == WRITE); 220 iswrite = (rq_data_dir(rq) == WRITE);
@@ -402,7 +400,7 @@ static const struct ide_dma_ops au1xxx_dma_ops = {
402 400
403static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) 401static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
404{ 402{
405 _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; 403 _auide_hwif *auide = &auide_hwif;
406 dbdev_tab_t source_dev_tab, target_dev_tab; 404 dbdev_tab_t source_dev_tab, target_dev_tab;
407 u32 dev_id, tsize, devwidth, flags; 405 u32 dev_id, tsize, devwidth, flags;
408 406
@@ -463,7 +461,7 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
463#else 461#else
464static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) 462static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
465{ 463{
466 _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; 464 _auide_hwif *auide = &auide_hwif;
467 dbdev_tab_t source_dev_tab; 465 dbdev_tab_t source_dev_tab;
468 int flags; 466 int flags;
469 467
@@ -600,8 +598,6 @@ static int au_ide_probe(struct device *dev)
600 598
601 ide_init_port_hw(hwif, &hw); 599 ide_init_port_hw(hwif, &hw);
602 600
603 hwif->dev = dev;
604
605 /* If the user has selected DDMA assisted copies, 601 /* If the user has selected DDMA assisted copies,
606 then set up a few local I/O function entry points 602 then set up a few local I/O function entry points
607 */ 603 */
@@ -610,11 +606,8 @@ static int au_ide_probe(struct device *dev)
610 hwif->input_data = au1xxx_input_data; 606 hwif->input_data = au1xxx_input_data;
611 hwif->output_data = au1xxx_output_data; 607 hwif->output_data = au1xxx_output_data;
612#endif 608#endif
613 hwif->select_data = 0; /* no chipset-specific code */
614 hwif->config_data = 0; /* no chipset-specific code */
615 609
616 auide_hwif.hwif = hwif; 610 auide_hwif.hwif = hwif;
617 hwif->hwif_data = &auide_hwif;
618 611
619 idx[0] = hwif->index; 612 idx[0] = hwif->index;
620 613
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
index 52fee3d2771a..9f1212cc4aed 100644
--- a/drivers/ide/mips/swarm.c
+++ b/drivers/ide/mips/swarm.c
@@ -61,6 +61,11 @@ static struct resource swarm_ide_resource = {
61 61
62static struct platform_device *swarm_ide_dev; 62static struct platform_device *swarm_ide_dev;
63 63
64static const struct ide_port_info swarm_port_info = {
65 .name = DRV_NAME,
66 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
67};
68
64/* 69/*
65 * swarm_ide_probe - if the board header indicates the existence of 70 * swarm_ide_probe - if the board header indicates the existence of
66 * Generic Bus IDE, allocate a HWIF for it. 71 * Generic Bus IDE, allocate a HWIF for it.
@@ -77,12 +82,6 @@ static int __devinit swarm_ide_probe(struct device *dev)
77 if (!SIBYTE_HAVE_IDE) 82 if (!SIBYTE_HAVE_IDE)
78 return -ENODEV; 83 return -ENODEV;
79 84
80 hwif = ide_find_port();
81 if (hwif == NULL) {
82 printk(KERN_ERR DRV_NAME ": no free slot for interface\n");
83 return -ENOMEM;
84 }
85
86 base = ioremap(A_IO_EXT_BASE, 0x800); 85 base = ioremap(A_IO_EXT_BASE, 0x800);
87 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS)); 86 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
88 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS)); 87 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
@@ -109,10 +108,6 @@ static int __devinit swarm_ide_probe(struct device *dev)
109 108
110 base = ioremap(offset, size); 109 base = ioremap(offset, size);
111 110
112 /* Setup MMIO ops. */
113 hwif->host_flags = IDE_HFLAG_MMIO;
114 default_hwif_mmiops(hwif);
115
116 for (i = 0; i <= 7; i++) 111 for (i = 0; i <= 7; i++)
117 hw.io_ports_array[i] = 112 hw.io_ports_array[i] =
118 (unsigned long)(base + ((0x1f0 + i) << 5)); 113 (unsigned long)(base + ((0x1f0 + i) << 5));
@@ -121,15 +116,26 @@ static int __devinit swarm_ide_probe(struct device *dev)
121 hw.irq = K_INT_GB_IDE; 116 hw.irq = K_INT_GB_IDE;
122 hw.chipset = ide_generic; 117 hw.chipset = ide_generic;
123 118
119 hwif = ide_find_port_slot(&swarm_port_info);
120 if (hwif == NULL)
121 goto err;
122
124 ide_init_port_hw(hwif, &hw); 123 ide_init_port_hw(hwif, &hw);
125 124
125 /* Setup MMIO ops. */
126 default_hwif_mmiops(hwif);
127
126 idx[0] = hwif->index; 128 idx[0] = hwif->index;
127 129
128 ide_device_add(idx, NULL); 130 ide_device_add(idx, &swarm_port_info);
129 131
130 dev_set_drvdata(dev, hwif); 132 dev_set_drvdata(dev, hwif);
131 133
132 return 0; 134 return 0;
135err:
136 release_resource(&swarm_ide_resource);
137 iounmap(base);
138 return -ENOMEM;
133} 139}
134 140
135static struct device_driver swarm_ide_driver = { 141static struct device_driver swarm_ide_driver = {
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index f2de00adf147..80d19c0eb780 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -69,7 +69,8 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
69{ 69{
70 ide_hwif_t *hwif = HWIF(drive); 70 ide_hwif_t *hwif = HWIF(drive);
71 struct pci_dev *dev = to_pci_dev(hwif->dev); 71 struct pci_dev *dev = to_pci_dev(hwif->dev);
72 int s_time, a_time, c_time; 72 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
73 int s_time = t->setup, a_time = t->active, c_time = t->cycle;
73 u8 s_clc, a_clc, r_clc; 74 u8 s_clc, a_clc, r_clc;
74 unsigned long flags; 75 unsigned long flags;
75 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 76 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
@@ -78,13 +79,10 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
78 u8 cd_dma_fifo = 0; 79 u8 cd_dma_fifo = 0;
79 int unit = drive->select.b.unit & 1; 80 int unit = drive->select.b.unit & 1;
80 81
81 s_time = ide_pio_timings[pio].setup_time;
82 a_time = ide_pio_timings[pio].active_time;
83 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8) 82 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
84 s_clc = 0; 83 s_clc = 0;
85 if ((a_clc = (a_time * bus_speed + 999) / 1000) >= 8) 84 if ((a_clc = (a_time * bus_speed + 999) / 1000) >= 8)
86 a_clc = 0; 85 a_clc = 0;
87 c_time = ide_pio_timings[pio].cycle_time;
88 86
89 if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) { 87 if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) {
90 r_clc = 1; 88 r_clc = 1;
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index ad222206a429..0bfcdd0e77b3 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -21,8 +21,6 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/ide.h> 22#include <linux/ide.h>
23 23
24#include "ide-timing.h"
25
26enum { 24enum {
27 AMD_IDE_CONFIG = 0x41, 25 AMD_IDE_CONFIG = 0x41,
28 AMD_CABLE_DETECT = 0x42, 26 AMD_CABLE_DETECT = 0x42,
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index cd1ba14984ab..1ad1e23e3105 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -521,6 +521,7 @@ static void program_drive_counts(ide_drive_t *drive, unsigned int index)
521static void cmd640_set_mode(ide_drive_t *drive, unsigned int index, 521static void cmd640_set_mode(ide_drive_t *drive, unsigned int index,
522 u8 pio_mode, unsigned int cycle_time) 522 u8 pio_mode, unsigned int cycle_time)
523{ 523{
524 struct ide_timing *t;
524 int setup_time, active_time, recovery_time, clock_time; 525 int setup_time, active_time, recovery_time, clock_time;
525 u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count; 526 u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count;
526 int bus_speed; 527 int bus_speed;
@@ -532,8 +533,11 @@ static void cmd640_set_mode(ide_drive_t *drive, unsigned int index,
532 533
533 if (pio_mode > 5) 534 if (pio_mode > 5)
534 pio_mode = 5; 535 pio_mode = 5;
535 setup_time = ide_pio_timings[pio_mode].setup_time; 536
536 active_time = ide_pio_timings[pio_mode].active_time; 537 t = ide_timing_find_mode(XFER_PIO_0 + pio_mode);
538 setup_time = t->setup;
539 active_time = t->active;
540
537 recovery_time = cycle_time - (setup_time + active_time); 541 recovery_time = cycle_time - (setup_time + active_time);
538 clock_time = 1000 / bus_speed; 542 clock_time = 1000 / bus_speed;
539 cycle_count = DIV_ROUND_UP(cycle_time, clock_time); 543 cycle_count = DIV_ROUND_UP(cycle_time, clock_time);
@@ -607,11 +611,40 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
607 611
608 display_clocks(index); 612 display_clocks(index);
609} 613}
614#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
615
616static void cmd640_init_dev(ide_drive_t *drive)
617{
618 unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit;
619
620#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
621 /*
622 * Reset timing to the slowest speed and turn off prefetch.
623 * This way, the drive identify code has a better chance.
624 */
625 setup_counts[i] = 4; /* max possible */
626 active_counts[i] = 16; /* max possible */
627 recovery_counts[i] = 16; /* max possible */
628 program_drive_counts(drive, i);
629 set_prefetch_mode(drive, i, 0);
630 printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch cleared\n", i);
631#else
632 /*
633 * Set the drive unmask flags to match the prefetch setting.
634 */
635 check_prefetch(drive, i);
636 printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch(%s) preserved\n",
637 i, drive->no_io_32bit ? "off" : "on");
638#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
639}
640
610 641
611static const struct ide_port_ops cmd640_port_ops = { 642static const struct ide_port_ops cmd640_port_ops = {
643 .init_dev = cmd640_init_dev,
644#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
612 .set_pio_mode = cmd640_set_pio_mode, 645 .set_pio_mode = cmd640_set_pio_mode,
646#endif
613}; 647};
614#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
615 648
616static int pci_conf1(void) 649static int pci_conf1(void)
617{ 650{
@@ -654,10 +687,8 @@ static const struct ide_port_info cmd640_port_info __initdata = {
654 IDE_HFLAG_NO_DMA | 687 IDE_HFLAG_NO_DMA |
655 IDE_HFLAG_ABUSE_PREFETCH | 688 IDE_HFLAG_ABUSE_PREFETCH |
656 IDE_HFLAG_ABUSE_FAST_DEVSEL, 689 IDE_HFLAG_ABUSE_FAST_DEVSEL,
657#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
658 .port_ops = &cmd640_port_ops, 690 .port_ops = &cmd640_port_ops,
659 .pio_mask = ATA_PIO5, 691 .pio_mask = ATA_PIO5,
660#endif
661}; 692};
662 693
663static int cmd640x_init_one(unsigned long base, unsigned long ctl) 694static int cmd640x_init_one(unsigned long base, unsigned long ctl)
@@ -683,12 +714,8 @@ static int cmd640x_init_one(unsigned long base, unsigned long ctl)
683 */ 714 */
684static int __init cmd640x_init(void) 715static int __init cmd640x_init(void)
685{ 716{
686#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
687 int second_port_toggled = 0;
688#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
689 int second_port_cmd640 = 0, rc; 717 int second_port_cmd640 = 0, rc;
690 const char *bus_type, *port2; 718 const char *bus_type, *port2;
691 unsigned int index;
692 u8 b, cfr; 719 u8 b, cfr;
693 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 720 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
694 hw_regs_t hw[2]; 721 hw_regs_t hw[2];
@@ -774,88 +801,44 @@ static int __init cmd640x_init(void)
774 put_cmd640_reg(CMDTIM, 0); 801 put_cmd640_reg(CMDTIM, 0);
775 put_cmd640_reg(BRST, 0x40); 802 put_cmd640_reg(BRST, 0x40);
776 803
777 cmd_hwif1 = ide_find_port(); 804 b = get_cmd640_reg(CNTRL);
778 805
779 /* 806 /*
780 * Try to enable the secondary interface, if not already enabled 807 * Try to enable the secondary interface, if not already enabled
781 */ 808 */
782 if (cmd_hwif1 && 809 if (secondary_port_responding()) {
783 cmd_hwif1->drives[0].noprobe && cmd_hwif1->drives[1].noprobe) { 810 if ((b & CNTRL_ENA_2ND)) {
784 port2 = "not probed"; 811 second_port_cmd640 = 1;
812 port2 = "okay";
813 } else if (cmd640_vlb) {
814 second_port_cmd640 = 1;
815 port2 = "alive";
816 } else
817 port2 = "not cmd640";
785 } else { 818 } else {
786 b = get_cmd640_reg(CNTRL); 819 put_cmd640_reg(CNTRL, b ^ CNTRL_ENA_2ND); /* toggle the bit */
787 if (secondary_port_responding()) { 820 if (secondary_port_responding()) {
788 if ((b & CNTRL_ENA_2ND)) { 821 second_port_cmd640 = 1;
789 second_port_cmd640 = 1; 822 port2 = "enabled";
790 port2 = "okay";
791 } else if (cmd640_vlb) {
792 second_port_cmd640 = 1;
793 port2 = "alive";
794 } else
795 port2 = "not cmd640";
796 } else { 823 } else {
797 put_cmd640_reg(CNTRL, b ^ CNTRL_ENA_2ND); /* toggle the bit */ 824 put_cmd640_reg(CNTRL, b); /* restore original setting */
798 if (secondary_port_responding()) { 825 port2 = "not responding";
799 second_port_cmd640 = 1;
800#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
801 second_port_toggled = 1;
802#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
803 port2 = "enabled";
804 } else {
805 put_cmd640_reg(CNTRL, b); /* restore original setting */
806 port2 = "not responding";
807 }
808 } 826 }
809 } 827 }
810 828
811 /* 829 /*
812 * Initialize data for secondary cmd640 port, if enabled 830 * Initialize data for secondary cmd640 port, if enabled
813 */ 831 */
814 if (second_port_cmd640 && cmd_hwif1) { 832 if (second_port_cmd640) {
815 ide_init_port_hw(cmd_hwif1, &hw[1]); 833 cmd_hwif1 = ide_find_port();
816 idx[1] = cmd_hwif1->index; 834 if (cmd_hwif1) {
835 ide_init_port_hw(cmd_hwif1, &hw[1]);
836 idx[1] = cmd_hwif1->index;
837 }
817 } 838 }
818 printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", 839 printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n",
819 second_port_cmd640 ? "" : "not ", port2); 840 second_port_cmd640 ? "" : "not ", port2);
820 841
821 /*
822 * Establish initial timings/prefetch for all drives.
823 * Do not unnecessarily disturb any prior BIOS setup of these.
824 */
825 for (index = 0; index < (2 + (second_port_cmd640 << 1)); index++) {
826 ide_drive_t *drive;
827
828 if (index > 1) {
829 if (cmd_hwif1 == NULL)
830 continue;
831 drive = &cmd_hwif1->drives[index & 1];
832 } else {
833 if (cmd_hwif0 == NULL)
834 continue;
835 drive = &cmd_hwif0->drives[index & 1];
836 }
837
838#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
839 /*
840 * Reset timing to the slowest speed and turn off prefetch.
841 * This way, the drive identify code has a better chance.
842 */
843 setup_counts [index] = 4; /* max possible */
844 active_counts [index] = 16; /* max possible */
845 recovery_counts [index] = 16; /* max possible */
846 program_drive_counts(drive, index);
847 set_prefetch_mode(drive, index, 0);
848 printk("cmd640: drive%d timings/prefetch cleared\n", index);
849#else
850 /*
851 * Set the drive unmask flags to match the prefetch setting
852 */
853 check_prefetch(drive, index);
854 printk("cmd640: drive%d timings/prefetch(%s) preserved\n",
855 index, drive->no_io_32bit ? "off" : "on");
856#endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */
857 }
858
859#ifdef CMD640_DUMP_REGS 842#ifdef CMD640_DUMP_REGS
860 cmd640_dump_regs(); 843 cmd640_dump_regs();
861#endif 844#endif
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index ca4774aa27ee..cfa784bacf48 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -116,6 +116,7 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio)
116{ 116{
117 ide_hwif_t *hwif = HWIF(drive); 117 ide_hwif_t *hwif = HWIF(drive);
118 struct pci_dev *dev = to_pci_dev(hwif->dev); 118 struct pci_dev *dev = to_pci_dev(hwif->dev);
119 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
119 unsigned int cycle_time; 120 unsigned int cycle_time;
120 u8 setup_count, arttim = 0; 121 u8 setup_count, arttim = 0;
121 122
@@ -124,10 +125,9 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio)
124 125
125 cycle_time = ide_pio_cycle_time(drive, pio); 126 cycle_time = ide_pio_cycle_time(drive, pio);
126 127
127 program_cycle_times(drive, cycle_time, 128 program_cycle_times(drive, cycle_time, t->active);
128 ide_pio_timings[pio].active_time);
129 129
130 setup_count = quantize_timing(ide_pio_timings[pio].setup_time, 130 setup_count = quantize_timing(t->setup,
131 1000 / (ide_pci_clk ? ide_pci_clk : 33)); 131 1000 / (ide_pci_clk ? ide_pci_clk : 33));
132 132
133 /* 133 /*
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 99fe91a191b8..dc97c48623f3 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -26,8 +26,6 @@
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/ide.h> 27#include <linux/ide.h>
28 28
29#include "ide-timing.h"
30
31#define MSR_ATAC_BASE 0x51300000 29#define MSR_ATAC_BASE 0x51300000
32#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0) 30#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0)
33#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01) 31#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01)
@@ -75,13 +73,11 @@ static unsigned int cs5535_udma_timings[5] =
75 */ 73 */
76static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) 74static void cs5535_set_speed(ide_drive_t *drive, const u8 speed)
77{ 75{
78
79 u32 reg = 0, dummy; 76 u32 reg = 0, dummy;
80 int unit = drive->select.b.unit; 77 int unit = drive->select.b.unit;
81 78
82
83 /* Set the PIO timings */ 79 /* Set the PIO timings */
84 if ((speed & XFER_MODE) == XFER_PIO) { 80 if (speed < XFER_SW_DMA_0) {
85 ide_drive_t *pair = ide_get_paired_drive(drive); 81 ide_drive_t *pair = ide_get_paired_drive(drive);
86 u8 cmd, pioa; 82 u8 cmd, pioa;
87 83
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 8c534afcb6c8..e14ad5530fa4 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -133,6 +133,7 @@ static int calc_clk(int time, int bus_speed)
133 */ 133 */
134static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) 134static void compute_clocks(u8 pio, pio_clocks_t *p_pclk)
135{ 135{
136 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
136 int clk1, clk2; 137 int clk1, clk2;
137 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 138 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
138 139
@@ -141,15 +142,13 @@ static void compute_clocks(u8 pio, pio_clocks_t *p_pclk)
141 */ 142 */
142 143
143 /* let's calc the address setup time clocks */ 144 /* let's calc the address setup time clocks */
144 p_pclk->address_time = (u8)calc_clk(ide_pio_timings[pio].setup_time, bus_speed); 145 p_pclk->address_time = (u8)calc_clk(t->setup, bus_speed);
145 146
146 /* let's calc the active and recovery time clocks */ 147 /* let's calc the active and recovery time clocks */
147 clk1 = calc_clk(ide_pio_timings[pio].active_time, bus_speed); 148 clk1 = calc_clk(t->active, bus_speed);
148 149
149 /* calc recovery timing */ 150 /* calc recovery timing */
150 clk2 = ide_pio_timings[pio].cycle_time - 151 clk2 = t->cycle - t->active - t->setup;
151 ide_pio_timings[pio].active_time -
152 ide_pio_timings[pio].setup_time;
153 152
154 clk2 = calc_clk(clk2, bus_speed); 153 clk2 = calc_clk(clk2, bus_speed);
155 154
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index af0f30051d5a..0106e2a2df77 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -93,7 +93,6 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
93 93
94 i = hwif->index; 94 i = hwif->index;
95 95
96 ide_init_port_data(hwif, i);
97 ide_init_port_hw(hwif, &hw); 96 ide_init_port_hw(hwif, &hw);
98 97
99 idx[0] = i; 98 idx[0] = i;
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 6ab04115286b..cbf647202994 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -512,8 +512,14 @@ static void __devinit it821x_quirkproc(ide_drive_t *drive)
512} 512}
513 513
514static struct ide_dma_ops it821x_pass_through_dma_ops = { 514static struct ide_dma_ops it821x_pass_through_dma_ops = {
515 .dma_host_set = ide_dma_host_set,
516 .dma_setup = ide_dma_setup,
517 .dma_exec_cmd = ide_dma_exec_cmd,
515 .dma_start = it821x_dma_start, 518 .dma_start = it821x_dma_start,
516 .dma_end = it821x_dma_end, 519 .dma_end = it821x_dma_end,
520 .dma_test_irq = ide_dma_test_irq,
521 .dma_timeout = ide_dma_timeout,
522 .dma_lost_irq = ide_dma_lost_irq,
517}; 523};
518 524
519/** 525/**
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 1584ebb6a185..789c66dfbde5 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -558,12 +558,9 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
558 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 558 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
559 int i; 559 int i;
560 560
561 hwif = ide_find_port(); 561 hwif = ide_find_port_slot(d);
562 if (hwif == NULL) { 562 if (hwif == NULL)
563 printk(KERN_ERR "%s: too many IDE interfaces, "
564 "no room in table\n", SCC_PATA_NAME);
565 return -ENOMEM; 563 return -ENOMEM;
566 }
567 564
568 memset(&hw, 0, sizeof(hw)); 565 memset(&hw, 0, sizeof(hw));
569 for (i = 0; i <= 8; i++) 566 for (i = 0; i <= 8; i++)
@@ -572,7 +569,6 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev,
572 hw.dev = &dev->dev; 569 hw.dev = &dev->dev;
573 hw.chipset = ide_pci; 570 hw.chipset = ide_pci;
574 ide_init_port_hw(hwif, &hw); 571 ide_init_port_hw(hwif, &hw);
575 hwif->dev = &dev->dev;
576 572
577 idx[0] = hwif->index; 573 idx[0] = hwif->index;
578 574
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 24513e3dcd6b..c79ff5b41088 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -568,6 +568,7 @@ static const struct ide_dma_ops sgiioc4_dma_ops = {
568}; 568};
569 569
570static const struct ide_port_info sgiioc4_port_info __devinitdata = { 570static const struct ide_port_info sgiioc4_port_info __devinitdata = {
571 .name = DRV_NAME,
571 .chipset = ide_pci, 572 .chipset = ide_pci,
572 .init_dma = ide_dma_sgiioc4, 573 .init_dma = ide_dma_sgiioc4,
573 .port_ops = &sgiioc4_port_ops, 574 .port_ops = &sgiioc4_port_ops,
@@ -587,13 +588,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
587 hw_regs_t hw; 588 hw_regs_t hw;
588 struct ide_port_info d = sgiioc4_port_info; 589 struct ide_port_info d = sgiioc4_port_info;
589 590
590 hwif = ide_find_port();
591 if (hwif == NULL) {
592 printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n",
593 DRV_NAME);
594 return -ENOMEM;
595 }
596
597 /* Get the CmdBlk and CtrlBlk Base Registers */ 591 /* Get the CmdBlk and CtrlBlk Base Registers */
598 bar0 = pci_resource_start(dev, 0); 592 bar0 = pci_resource_start(dev, 0);
599 virt_base = ioremap(bar0, pci_resource_len(dev, 0)); 593 virt_base = ioremap(bar0, pci_resource_len(dev, 0));
@@ -608,11 +602,11 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
608 602
609 cmd_phys_base = bar0 + IOC4_CMD_OFFSET; 603 cmd_phys_base = bar0 + IOC4_CMD_OFFSET;
610 if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, 604 if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE,
611 hwif->name)) { 605 DRV_NAME)) {
612 printk(KERN_ERR 606 printk(KERN_ERR
613 "%s : %s -- ERROR, Addresses " 607 "%s : %s -- ERROR, Addresses "
614 "0x%p to 0x%p ALREADY in use\n", 608 "0x%p to 0x%p ALREADY in use\n",
615 __func__, hwif->name, (void *) cmd_phys_base, 609 __func__, DRV_NAME, (void *) cmd_phys_base,
616 (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); 610 (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
617 return -ENOMEM; 611 return -ENOMEM;
618 } 612 }
@@ -623,9 +617,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
623 hw.irq = dev->irq; 617 hw.irq = dev->irq;
624 hw.chipset = ide_pci; 618 hw.chipset = ide_pci;
625 hw.dev = &dev->dev; 619 hw.dev = &dev->dev;
626 ide_init_port_hw(hwif, &hw);
627 620
628 hwif->dev = &dev->dev; 621 hwif = ide_find_port_slot(&d);
622 if (hwif == NULL)
623 goto err;
624
625 ide_init_port_hw(hwif, &hw);
629 626
630 /* The IOC4 uses MMIO rather than Port IO. */ 627 /* The IOC4 uses MMIO rather than Port IO. */
631 default_hwif_mmiops(hwif); 628 default_hwif_mmiops(hwif);
@@ -641,6 +638,10 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
641 return -EIO; 638 return -EIO;
642 639
643 return 0; 640 return 0;
641err:
642 release_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE);
643 iounmap(virt_base);
644 return -ENOMEM;
644} 645}
645 646
646static unsigned int __devinit 647static unsigned int __devinit
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index b75e9bb390a7..6e9d7655d89c 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -421,8 +421,7 @@ static int sil_sata_reset_poll(ide_drive_t *drive)
421 if ((sata_stat & 0x03) != 0x03) { 421 if ((sata_stat & 0x03) != 0x03) {
422 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", 422 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
423 hwif->name, sata_stat); 423 hwif->name, sata_stat);
424 HWGROUP(drive)->polling = 0; 424 return -ENXIO;
425 return ide_started;
426 } 425 }
427 } 426 }
428 427
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index e127eb25ab63..2389945ca95d 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -52,8 +52,6 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/ide.h> 53#include <linux/ide.h>
54 54
55#include "ide-timing.h"
56
57/* registers layout and init values are chipset family dependant */ 55/* registers layout and init values are chipset family dependant */
58 56
59#define ATA_16 0x01 57#define ATA_16 0x01
@@ -616,7 +614,6 @@ MODULE_LICENSE("GPL");
616/* 614/*
617 * TODO: 615 * TODO:
618 * - CLEANUP 616 * - CLEANUP
619 * - Use drivers/ide/ide-timing.h !
620 * - More checks in the config registers (force values instead of 617 * - More checks in the config registers (force values instead of
621 * relying on the BIOS setting them correctly). 618 * relying on the BIOS setting them correctly).
622 * - Further optimisations ? 619 * - Further optimisations ?
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index ce84fa045d39..6efbde297174 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -47,10 +47,11 @@
47 */ 47 */
48static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) 48static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio)
49{ 49{
50 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
50 unsigned int cmd_on, cmd_off; 51 unsigned int cmd_on, cmd_off;
51 u8 iordy = 0; 52 u8 iordy = 0;
52 53
53 cmd_on = (ide_pio_timings[pio].active_time + 29) / 30; 54 cmd_on = (t->active + 29) / 30;
54 cmd_off = (ide_pio_cycle_time(drive, pio) - 30 * cmd_on + 29) / 30; 55 cmd_off = (ide_pio_cycle_time(drive, pio) - 30 * cmd_on + 29) / 30;
55 56
56 if (cmd_on == 0) 57 if (cmd_on == 0)
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 3ed9728abd24..e47384c70c40 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -35,8 +35,6 @@
35#include <asm/processor.h> 35#include <asm/processor.h>
36#endif 36#endif
37 37
38#include "ide-timing.h"
39
40#define VIA_IDE_ENABLE 0x40 38#define VIA_IDE_ENABLE 0x40
41#define VIA_IDE_CONFIG 0x41 39#define VIA_IDE_CONFIG 0x41
42#define VIA_FIFO_CONFIG 0x43 40#define VIA_FIFO_CONFIG 0x43
diff --git a/drivers/ide/ppc/Makefile b/drivers/ide/ppc/Makefile
index 65af5848b28c..74e52adcdf4b 100644
--- a/drivers/ide/ppc/Makefile
+++ b/drivers/ide/ppc/Makefile
@@ -1,3 +1,2 @@
1 1
2obj-$(CONFIG_BLK_DEV_IDE_PMAC) += pmac.o 2obj-$(CONFIG_BLK_DEV_IDE_PMAC) += pmac.o
3obj-$(CONFIG_BLK_DEV_MPC8xx_IDE) += mpc8xx.o
diff --git a/drivers/ide/ppc/mpc8xx.c b/drivers/ide/ppc/mpc8xx.c
deleted file mode 100644
index 236f9c38e519..000000000000
--- a/drivers/ide/ppc/mpc8xx.c
+++ /dev/null
@@ -1,851 +0,0 @@
1/*
2 * Copyright (C) 2000, 2001 Wolfgang Denk, wd@denx.de
3 * Modified for direct IDE interface
4 * by Thomas Lange, thomas@corelatus.com
5 * Modified for direct IDE interface on 8xx without using the PCMCIA
6 * controller
7 * by Steven.Scholz@imc-berlin.de
8 * Moved out of arch/ppc/kernel/m8xx_setup.c, other minor cleanups
9 * by Mathew Locke <mattl@mvista.com>
10 */
11
12#include <linux/errno.h>
13#include <linux/kernel.h>
14#include <linux/mm.h>
15#include <linux/stddef.h>
16#include <linux/unistd.h>
17#include <linux/ptrace.h>
18#include <linux/slab.h>
19#include <linux/user.h>
20#include <linux/tty.h>
21#include <linux/major.h>
22#include <linux/interrupt.h>
23#include <linux/reboot.h>
24#include <linux/init.h>
25#include <linux/ioport.h>
26#include <linux/ide.h>
27#include <linux/bootmem.h>
28
29#include <asm/mpc8xx.h>
30#include <asm/mmu.h>
31#include <asm/processor.h>
32#include <asm/io.h>
33#include <asm/pgtable.h>
34#include <asm/ide.h>
35#include <asm/8xx_immap.h>
36#include <asm/machdep.h>
37#include <asm/irq.h>
38
39#define DRV_NAME "ide-mpc8xx"
40
41static int identify (volatile u8 *p);
42static void print_fixed (volatile u8 *p);
43static void print_funcid (int func);
44static int check_ide_device (unsigned long base);
45
46static void ide_interrupt_ack (void *dev);
47static void m8xx_ide_set_pio_mode(ide_drive_t *drive, const u8 pio);
48
49typedef struct ide_ioport_desc {
50 unsigned long base_off; /* Offset to PCMCIA memory */
51 unsigned long reg_off[IDE_NR_PORTS]; /* controller register offsets */
52 int irq; /* IRQ */
53} ide_ioport_desc_t;
54
55ide_ioport_desc_t ioport_dsc[MAX_HWIFS] = {
56#ifdef IDE0_BASE_OFFSET
57 { IDE0_BASE_OFFSET,
58 {
59 IDE0_DATA_REG_OFFSET,
60 IDE0_ERROR_REG_OFFSET,
61 IDE0_NSECTOR_REG_OFFSET,
62 IDE0_SECTOR_REG_OFFSET,
63 IDE0_LCYL_REG_OFFSET,
64 IDE0_HCYL_REG_OFFSET,
65 IDE0_SELECT_REG_OFFSET,
66 IDE0_STATUS_REG_OFFSET,
67 IDE0_CONTROL_REG_OFFSET,
68 IDE0_IRQ_REG_OFFSET,
69 },
70 IDE0_INTERRUPT,
71 },
72#ifdef IDE1_BASE_OFFSET
73 { IDE1_BASE_OFFSET,
74 {
75 IDE1_DATA_REG_OFFSET,
76 IDE1_ERROR_REG_OFFSET,
77 IDE1_NSECTOR_REG_OFFSET,
78 IDE1_SECTOR_REG_OFFSET,
79 IDE1_LCYL_REG_OFFSET,
80 IDE1_HCYL_REG_OFFSET,
81 IDE1_SELECT_REG_OFFSET,
82 IDE1_STATUS_REG_OFFSET,
83 IDE1_CONTROL_REG_OFFSET,
84 IDE1_IRQ_REG_OFFSET,
85 },
86 IDE1_INTERRUPT,
87 },
88#endif /* IDE1_BASE_OFFSET */
89#endif /* IDE0_BASE_OFFSET */
90};
91
92ide_pio_timings_t ide_pio_clocks[6];
93int hold_time[6] = {30, 20, 15, 10, 10, 10 }; /* PIO Mode 5 with IORDY (nonstandard) */
94
95/*
96 * Warning: only 1 (ONE) PCMCIA slot supported here,
97 * which must be correctly initialized by the firmware (PPCBoot).
98 */
99static int _slot_ = -1; /* will be read from PCMCIA registers */
100
101/* Make clock cycles and always round up */
102#define PCMCIA_MK_CLKS( t, T ) (( (t) * ((T)/1000000) + 999U ) / 1000U )
103
104#define M8XX_PCMCIA_CD2(slot) (0x10000000 >> (slot << 4))
105#define M8XX_PCMCIA_CD1(slot) (0x08000000 >> (slot << 4))
106
107/*
108 * The TQM850L hardware has two pins swapped! Grrrrgh!
109 */
110#ifdef CONFIG_TQM850L
111#define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXOE
112#define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXRESET
113#else
114#define __MY_PCMCIA_GCRX_CXRESET PCMCIA_GCRX_CXRESET
115#define __MY_PCMCIA_GCRX_CXOE PCMCIA_GCRX_CXOE
116#endif
117
118#if defined(CONFIG_BLK_DEV_MPC8xx_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
119#define PCMCIA_SCHLVL IDE0_INTERRUPT /* Status Change Interrupt Level */
120static int pcmcia_schlvl = PCMCIA_SCHLVL;
121#endif
122
123/*
124 * See include/linux/ide.h for definition of hw_regs_t (p, base)
125 */
126
127/*
128 * m8xx_ide_init_ports() for a direct IDE interface _using_
129 * MPC8xx's internal PCMCIA interface
130 */
131#if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
132static int __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
133{
134 unsigned long *p = hw->io_ports_array;
135 int i;
136
137 typedef struct {
138 ulong br;
139 ulong or;
140 } pcmcia_win_t;
141 volatile pcmcia_win_t *win;
142 volatile pcmconf8xx_t *pcmp;
143
144 uint *pgcrx;
145 u32 pcmcia_phy_base;
146 u32 pcmcia_phy_end;
147 static unsigned long pcmcia_base = 0;
148 unsigned long base;
149
150 *p = 0;
151
152 pcmp = (pcmconf8xx_t *)(&(((immap_t *)IMAP_ADDR)->im_pcmcia));
153
154 if (!pcmcia_base) {
155 /*
156 * Read out PCMCIA registers. Since the reset values
157 * are undefined, we sure hope that they have been
158 * set up by firmware
159 */
160
161 /* Scan all registers for valid settings */
162 pcmcia_phy_base = 0xFFFFFFFF;
163 pcmcia_phy_end = 0;
164 /* br0 is start of brX and orX regs */
165 win = (pcmcia_win_t *) \
166 (&(((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pbr0));
167 for (i = 0; i < 8; i++) {
168 if (win->or & 1) { /* This bank is marked as valid */
169 if (win->br < pcmcia_phy_base) {
170 pcmcia_phy_base = win->br;
171 }
172 if ((win->br + PCMCIA_MEM_SIZE) > pcmcia_phy_end) {
173 pcmcia_phy_end = win->br + PCMCIA_MEM_SIZE;
174 }
175 /* Check which slot that has been defined */
176 _slot_ = (win->or >> 2) & 1;
177
178 } /* Valid bank */
179 win++;
180 } /* for */
181
182 printk ("PCMCIA slot %c: phys mem %08x...%08x (size %08x)\n",
183 'A' + _slot_,
184 pcmcia_phy_base, pcmcia_phy_end,
185 pcmcia_phy_end - pcmcia_phy_base);
186
187 if (!request_mem_region(pcmcia_phy_base,
188 pcmcia_phy_end - pcmcia_phy_base,
189 DRV_NAME)) {
190 printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
191 return -EBUSY;
192 }
193
194 pcmcia_base=(unsigned long)ioremap(pcmcia_phy_base,
195 pcmcia_phy_end-pcmcia_phy_base);
196
197#ifdef DEBUG
198 printk ("PCMCIA virt base: %08lx\n", pcmcia_base);
199#endif
200 /* Compute clock cycles for PIO timings */
201 for (i=0; i<6; ++i) {
202 bd_t *binfo = (bd_t *)__res;
203
204 hold_time[i] =
205 PCMCIA_MK_CLKS (hold_time[i],
206 binfo->bi_busfreq);
207 ide_pio_clocks[i].setup_time =
208 PCMCIA_MK_CLKS (ide_pio_timings[i].setup_time,
209 binfo->bi_busfreq);
210 ide_pio_clocks[i].active_time =
211 PCMCIA_MK_CLKS (ide_pio_timings[i].active_time,
212 binfo->bi_busfreq);
213 ide_pio_clocks[i].cycle_time =
214 PCMCIA_MK_CLKS (ide_pio_timings[i].cycle_time,
215 binfo->bi_busfreq);
216#if 0
217 printk ("PIO mode %d timings: %d/%d/%d => %d/%d/%d\n",
218 i,
219 ide_pio_clocks[i].setup_time,
220 ide_pio_clocks[i].active_time,
221 ide_pio_clocks[i].hold_time,
222 ide_pio_clocks[i].cycle_time,
223 ide_pio_timings[i].setup_time,
224 ide_pio_timings[i].active_time,
225 ide_pio_timings[i].hold_time,
226 ide_pio_timings[i].cycle_time);
227#endif
228 }
229 }
230
231 if (_slot_ == -1) {
232 printk ("PCMCIA slot has not been defined! Using A as default\n");
233 _slot_ = 0;
234 }
235
236#ifdef CONFIG_IDE_8xx_PCCARD
237
238#ifdef DEBUG
239 printk ("PIPR = 0x%08X slot %c ==> mask = 0x%X\n",
240 pcmp->pcmc_pipr,
241 'A' + _slot_,
242 M8XX_PCMCIA_CD1(_slot_) | M8XX_PCMCIA_CD2(_slot_) );
243#endif /* DEBUG */
244
245 if (pcmp->pcmc_pipr & (M8XX_PCMCIA_CD1(_slot_)|M8XX_PCMCIA_CD2(_slot_))) {
246 printk ("No card in slot %c: PIPR=%08x\n",
247 'A' + _slot_, (u32) pcmp->pcmc_pipr);
248 return -ENODEV; /* No card in slot */
249 }
250
251 check_ide_device (pcmcia_base);
252
253#endif /* CONFIG_IDE_8xx_PCCARD */
254
255 base = pcmcia_base + ioport_dsc[data_port].base_off;
256#ifdef DEBUG
257 printk ("base: %08x + %08x = %08x\n",
258 pcmcia_base, ioport_dsc[data_port].base_off, base);
259#endif
260
261 for (i = 0; i < IDE_NR_PORTS; ++i) {
262#ifdef DEBUG
263 printk ("port[%d]: %08x + %08x = %08x\n",
264 i,
265 base,
266 ioport_dsc[data_port].reg_off[i],
267 i, base + ioport_dsc[data_port].reg_off[i]);
268#endif
269 *p++ = base + ioport_dsc[data_port].reg_off[i];
270 }
271
272 hw->irq = ioport_dsc[data_port].irq;
273 hw->ack_intr = (ide_ack_intr_t *)ide_interrupt_ack;
274
275#ifdef CONFIG_IDE_8xx_PCCARD
276 {
277 unsigned int reg;
278
279 if (_slot_)
280 pgcrx = &((immap_t *) IMAP_ADDR)->im_pcmcia.pcmc_pgcrb;
281 else
282 pgcrx = &((immap_t *) IMAP_ADDR)->im_pcmcia.pcmc_pgcra;
283
284 reg = *pgcrx;
285 reg |= mk_int_int_mask (pcmcia_schlvl) << 24;
286 reg |= mk_int_int_mask (pcmcia_schlvl) << 16;
287 *pgcrx = reg;
288 }
289#endif /* CONFIG_IDE_8xx_PCCARD */
290
291 /* Enable Harddisk Interrupt,
292 * and make it edge sensitive
293 */
294 /* (11-18) Set edge detect for irq, no wakeup from low power mode */
295 ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel |=
296 (0x80000000 >> ioport_dsc[data_port].irq);
297
298#ifdef CONFIG_IDE_8xx_PCCARD
299 /* Make sure we don't get garbage irq */
300 ((immap_t *) IMAP_ADDR)->im_pcmcia.pcmc_pscr = 0xFFFF;
301
302 /* Enable falling edge irq */
303 pcmp->pcmc_per = 0x100000 >> (16 * _slot_);
304#endif /* CONFIG_IDE_8xx_PCCARD */
305
306 hw->chipset = ide_generic;
307
308 return 0;
309}
310#endif /* CONFIG_IDE_8xx_PCCARD || CONFIG_IDE_8xx_DIRECT */
311
312/*
313 * m8xx_ide_init_ports() for a direct IDE interface _not_ using
314 * MPC8xx's internal PCMCIA interface
315 */
316#if defined(CONFIG_IDE_EXT_DIRECT)
317static int __init m8xx_ide_init_ports(hw_regs_t *hw, unsigned long data_port)
318{
319 unsigned long *p = hw->io_ports_array;
320 int i;
321
322 u32 ide_phy_base;
323 u32 ide_phy_end;
324 static unsigned long ide_base = 0;
325 unsigned long base;
326
327 *p = 0;
328
329 if (!ide_base) {
330
331 /* TODO:
332 * - add code to read ORx, BRx
333 */
334 ide_phy_base = CFG_ATA_BASE_ADDR;
335 ide_phy_end = CFG_ATA_BASE_ADDR + 0x200;
336
337 printk ("IDE phys mem : %08x...%08x (size %08x)\n",
338 ide_phy_base, ide_phy_end,
339 ide_phy_end - ide_phy_base);
340
341 if (!request_mem_region(ide_phy_base, 0x200, DRV_NAME)) {
342 printk(KERN_ERR "%s: resources busy\n", DRV_NAME);
343 return -EBUSY;
344 }
345
346 ide_base=(unsigned long)ioremap(ide_phy_base,
347 ide_phy_end-ide_phy_base);
348
349#ifdef DEBUG
350 printk ("IDE virt base: %08lx\n", ide_base);
351#endif
352 }
353
354 base = ide_base + ioport_dsc[data_port].base_off;
355#ifdef DEBUG
356 printk ("base: %08x + %08x = %08x\n",
357 ide_base, ioport_dsc[data_port].base_off, base);
358#endif
359
360 for (i = 0; i < IDE_NR_PORTS; ++i) {
361#ifdef DEBUG
362 printk ("port[%d]: %08x + %08x = %08x\n",
363 i,
364 base,
365 ioport_dsc[data_port].reg_off[i],
366 i, base + ioport_dsc[data_port].reg_off[i]);
367#endif
368 *p++ = base + ioport_dsc[data_port].reg_off[i];
369 }
370
371 /* direct connected IDE drive, i.e. external IRQ */
372 hw->irq = ioport_dsc[data_port].irq;
373 hw->ack_intr = (ide_ack_intr_t *)ide_interrupt_ack;
374
375 /* Enable Harddisk Interrupt,
376 * and make it edge sensitive
377 */
378 /* (11-18) Set edge detect for irq, no wakeup from low power mode */
379 ((immap_t *) IMAP_ADDR)->im_siu_conf.sc_siel |=
380 (0x80000000 >> ioport_dsc[data_port].irq);
381
382 hw->chipset = ide_generic;
383
384 return 0;
385}
386#endif /* CONFIG_IDE_8xx_DIRECT */
387
388
389/* -------------------------------------------------------------------- */
390
391
392/* PCMCIA Timing */
393#ifndef PCMCIA_SHT
394#define PCMCIA_SHT(t) ((t & 0x0F)<<16) /* Strobe Hold Time */
395#define PCMCIA_SST(t) ((t & 0x0F)<<12) /* Strobe Setup Time */
396#define PCMCIA_SL(t) ((t==32) ? 0 : ((t & 0x1F)<<7)) /* Strobe Length */
397#endif
398
399/* Calculate PIO timings */
400static void m8xx_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
401{
402#if defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_DIRECT)
403 volatile pcmconf8xx_t *pcmp;
404 ulong timing, mask, reg;
405
406 pcmp = (pcmconf8xx_t *)(&(((immap_t *)IMAP_ADDR)->im_pcmcia));
407
408 mask = ~(PCMCIA_SHT(0xFF) | PCMCIA_SST(0xFF) | PCMCIA_SL(0xFF));
409
410 timing = PCMCIA_SHT(hold_time[pio] )
411 | PCMCIA_SST(ide_pio_clocks[pio].setup_time )
412 | PCMCIA_SL (ide_pio_clocks[pio].active_time)
413 ;
414
415#if 1
416 printk ("Setting timing bits 0x%08lx in PCMCIA controller\n", timing);
417#endif
418 if ((reg = pcmp->pcmc_por0 & mask) != 0)
419 pcmp->pcmc_por0 = reg | timing;
420
421 if ((reg = pcmp->pcmc_por1 & mask) != 0)
422 pcmp->pcmc_por1 = reg | timing;
423
424 if ((reg = pcmp->pcmc_por2 & mask) != 0)
425 pcmp->pcmc_por2 = reg | timing;
426
427 if ((reg = pcmp->pcmc_por3 & mask) != 0)
428 pcmp->pcmc_por3 = reg | timing;
429
430 if ((reg = pcmp->pcmc_por4 & mask) != 0)
431 pcmp->pcmc_por4 = reg | timing;
432
433 if ((reg = pcmp->pcmc_por5 & mask) != 0)
434 pcmp->pcmc_por5 = reg | timing;
435
436 if ((reg = pcmp->pcmc_por6 & mask) != 0)
437 pcmp->pcmc_por6 = reg | timing;
438
439 if ((reg = pcmp->pcmc_por7 & mask) != 0)
440 pcmp->pcmc_por7 = reg | timing;
441
442#elif defined(CONFIG_IDE_EXT_DIRECT)
443
444 printk("%s[%d] %s: not implemented yet!\n",
445 __FILE__, __LINE__, __func__);
446#endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */
447}
448
449static const struct ide_port_ops m8xx_port_ops = {
450 .set_pio_mode = m8xx_ide_set_pio_mode,
451};
452
453static void
454ide_interrupt_ack (void *dev)
455{
456#ifdef CONFIG_IDE_8xx_PCCARD
457 u_int pscr, pipr;
458
459#if (PCMCIA_SOCKETS_NO == 2)
460 u_int _slot_;
461#endif
462
463 /* get interrupt sources */
464
465 pscr = ((volatile immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pscr;
466 pipr = ((volatile immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pipr;
467
468 /*
469 * report only if both card detect signals are the same
470 * not too nice done,
471 * we depend on that CD2 is the bit to the left of CD1...
472 */
473
474 if(_slot_==-1){
475 printk("PCMCIA slot has not been defined! Using A as default\n");
476 _slot_=0;
477 }
478
479 if(((pipr & M8XX_PCMCIA_CD2(_slot_)) >> 1) ^
480 (pipr & M8XX_PCMCIA_CD1(_slot_)) ) {
481 printk ("card detect interrupt\n");
482 }
483 /* clear the interrupt sources */
484 ((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pscr = pscr;
485
486#else /* ! CONFIG_IDE_8xx_PCCARD */
487 /*
488 * Only CONFIG_IDE_8xx_PCCARD is using the interrupt of the
489 * MPC8xx's PCMCIA controller, so there is nothing to be done here
490 * for CONFIG_IDE_8xx_DIRECT and CONFIG_IDE_EXT_DIRECT.
491 * The interrupt is handled somewhere else. -- Steven
492 */
493#endif /* CONFIG_IDE_8xx_PCCARD */
494}
495
496
497
498/*
499 * CIS Tupel codes
500 */
501#define CISTPL_NULL 0x00
502#define CISTPL_DEVICE 0x01
503#define CISTPL_LONGLINK_CB 0x02
504#define CISTPL_INDIRECT 0x03
505#define CISTPL_CONFIG_CB 0x04
506#define CISTPL_CFTABLE_ENTRY_CB 0x05
507#define CISTPL_LONGLINK_MFC 0x06
508#define CISTPL_BAR 0x07
509#define CISTPL_PWR_MGMNT 0x08
510#define CISTPL_EXTDEVICE 0x09
511#define CISTPL_CHECKSUM 0x10
512#define CISTPL_LONGLINK_A 0x11
513#define CISTPL_LONGLINK_C 0x12
514#define CISTPL_LINKTARGET 0x13
515#define CISTPL_NO_LINK 0x14
516#define CISTPL_VERS_1 0x15
517#define CISTPL_ALTSTR 0x16
518#define CISTPL_DEVICE_A 0x17
519#define CISTPL_JEDEC_C 0x18
520#define CISTPL_JEDEC_A 0x19
521#define CISTPL_CONFIG 0x1a
522#define CISTPL_CFTABLE_ENTRY 0x1b
523#define CISTPL_DEVICE_OC 0x1c
524#define CISTPL_DEVICE_OA 0x1d
525#define CISTPL_DEVICE_GEO 0x1e
526#define CISTPL_DEVICE_GEO_A 0x1f
527#define CISTPL_MANFID 0x20
528#define CISTPL_FUNCID 0x21
529#define CISTPL_FUNCE 0x22
530#define CISTPL_SWIL 0x23
531#define CISTPL_END 0xff
532
533/*
534 * CIS Function ID codes
535 */
536#define CISTPL_FUNCID_MULTI 0x00
537#define CISTPL_FUNCID_MEMORY 0x01
538#define CISTPL_FUNCID_SERIAL 0x02
539#define CISTPL_FUNCID_PARALLEL 0x03
540#define CISTPL_FUNCID_FIXED 0x04
541#define CISTPL_FUNCID_VIDEO 0x05
542#define CISTPL_FUNCID_NETWORK 0x06
543#define CISTPL_FUNCID_AIMS 0x07
544#define CISTPL_FUNCID_SCSI 0x08
545
546/*
547 * Fixed Disk FUNCE codes
548 */
549#define CISTPL_IDE_INTERFACE 0x01
550
551#define CISTPL_FUNCE_IDE_IFACE 0x01
552#define CISTPL_FUNCE_IDE_MASTER 0x02
553#define CISTPL_FUNCE_IDE_SLAVE 0x03
554
555/* First feature byte */
556#define CISTPL_IDE_SILICON 0x04
557#define CISTPL_IDE_UNIQUE 0x08
558#define CISTPL_IDE_DUAL 0x10
559
560/* Second feature byte */
561#define CISTPL_IDE_HAS_SLEEP 0x01
562#define CISTPL_IDE_HAS_STANDBY 0x02
563#define CISTPL_IDE_HAS_IDLE 0x04
564#define CISTPL_IDE_LOW_POWER 0x08
565#define CISTPL_IDE_REG_INHIBIT 0x10
566#define CISTPL_IDE_HAS_INDEX 0x20
567#define CISTPL_IDE_IOIS16 0x40
568
569
570/* -------------------------------------------------------------------- */
571
572
573#define MAX_TUPEL_SZ 512
574#define MAX_FEATURES 4
575
576static int check_ide_device (unsigned long base)
577{
578 volatile u8 *ident = NULL;
579 volatile u8 *feature_p[MAX_FEATURES];
580 volatile u8 *p, *start;
581 int n_features = 0;
582 u8 func_id = ~0;
583 u8 code, len;
584 unsigned short config_base = 0;
585 int found = 0;
586 int i;
587
588#ifdef DEBUG
589 printk ("PCMCIA MEM: %08lX\n", base);
590#endif
591 start = p = (volatile u8 *) base;
592
593 while ((p - start) < MAX_TUPEL_SZ) {
594
595 code = *p; p += 2;
596
597 if (code == 0xFF) { /* End of chain */
598 break;
599 }
600
601 len = *p; p += 2;
602#ifdef DEBUG_PCMCIA
603 { volatile u8 *q = p;
604 printk ("\nTuple code %02x length %d\n\tData:",
605 code, len);
606
607 for (i = 0; i < len; ++i) {
608 printk (" %02x", *q);
609 q+= 2;
610 }
611 }
612#endif /* DEBUG_PCMCIA */
613 switch (code) {
614 case CISTPL_VERS_1:
615 ident = p + 4;
616 break;
617 case CISTPL_FUNCID:
618 func_id = *p;
619 break;
620 case CISTPL_FUNCE:
621 if (n_features < MAX_FEATURES)
622 feature_p[n_features++] = p;
623 break;
624 case CISTPL_CONFIG:
625 config_base = (*(p+6) << 8) + (*(p+4));
626 default:
627 break;
628 }
629 p += 2 * len;
630 }
631
632 found = identify (ident);
633
634 if (func_id != ((u8)~0)) {
635 print_funcid (func_id);
636
637 if (func_id == CISTPL_FUNCID_FIXED)
638 found = 1;
639 else
640 return (1); /* no disk drive */
641 }
642
643 for (i=0; i<n_features; ++i) {
644 print_fixed (feature_p[i]);
645 }
646
647 if (!found) {
648 printk ("unknown card type\n");
649 return (1);
650 }
651
652 /* set level mode irq and I/O mapped device in config reg*/
653 *((u8 *)(base + config_base)) = 0x41;
654
655 return (0);
656}
657
658/* ------------------------------------------------------------------------- */
659
660static void print_funcid (int func)
661{
662 switch (func) {
663 case CISTPL_FUNCID_MULTI:
664 printk (" Multi-Function");
665 break;
666 case CISTPL_FUNCID_MEMORY:
667 printk (" Memory");
668 break;
669 case CISTPL_FUNCID_SERIAL:
670 printk (" Serial Port");
671 break;
672 case CISTPL_FUNCID_PARALLEL:
673 printk (" Parallel Port");
674 break;
675 case CISTPL_FUNCID_FIXED:
676 printk (" Fixed Disk");
677 break;
678 case CISTPL_FUNCID_VIDEO:
679 printk (" Video Adapter");
680 break;
681 case CISTPL_FUNCID_NETWORK:
682 printk (" Network Adapter");
683 break;
684 case CISTPL_FUNCID_AIMS:
685 printk (" AIMS Card");
686 break;
687 case CISTPL_FUNCID_SCSI:
688 printk (" SCSI Adapter");
689 break;
690 default:
691 printk (" Unknown");
692 break;
693 }
694 printk (" Card\n");
695}
696
697/* ------------------------------------------------------------------------- */
698
699static void print_fixed (volatile u8 *p)
700{
701 if (p == NULL)
702 return;
703
704 switch (*p) {
705 case CISTPL_FUNCE_IDE_IFACE:
706 { u8 iface = *(p+2);
707
708 printk ((iface == CISTPL_IDE_INTERFACE) ? " IDE" : " unknown");
709 printk (" interface ");
710 break;
711 }
712 case CISTPL_FUNCE_IDE_MASTER:
713 case CISTPL_FUNCE_IDE_SLAVE:
714 { u8 f1 = *(p+2);
715 u8 f2 = *(p+4);
716
717 printk ((f1 & CISTPL_IDE_SILICON) ? " [silicon]" : " [rotating]");
718
719 if (f1 & CISTPL_IDE_UNIQUE)
720 printk (" [unique]");
721
722 printk ((f1 & CISTPL_IDE_DUAL) ? " [dual]" : " [single]");
723
724 if (f2 & CISTPL_IDE_HAS_SLEEP)
725 printk (" [sleep]");
726
727 if (f2 & CISTPL_IDE_HAS_STANDBY)
728 printk (" [standby]");
729
730 if (f2 & CISTPL_IDE_HAS_IDLE)
731 printk (" [idle]");
732
733 if (f2 & CISTPL_IDE_LOW_POWER)
734 printk (" [low power]");
735
736 if (f2 & CISTPL_IDE_REG_INHIBIT)
737 printk (" [reg inhibit]");
738
739 if (f2 & CISTPL_IDE_HAS_INDEX)
740 printk (" [index]");
741
742 if (f2 & CISTPL_IDE_IOIS16)
743 printk (" [IOis16]");
744
745 break;
746 }
747 }
748 printk ("\n");
749}
750
751/* ------------------------------------------------------------------------- */
752
753
754#define MAX_IDENT_CHARS 64
755#define MAX_IDENT_FIELDS 4
756
757static u8 *known_cards[] = {
758 "ARGOSY PnPIDE D5",
759 NULL
760};
761
762static int identify (volatile u8 *p)
763{
764 u8 id_str[MAX_IDENT_CHARS];
765 u8 data;
766 u8 *t;
767 u8 **card;
768 int i, done;
769
770 if (p == NULL)
771 return (0); /* Don't know */
772
773 t = id_str;
774 done =0;
775
776 for (i=0; i<=4 && !done; ++i, p+=2) {
777 while ((data = *p) != '\0') {
778 if (data == 0xFF) {
779 done = 1;
780 break;
781 }
782 *t++ = data;
783 if (t == &id_str[MAX_IDENT_CHARS-1]) {
784 done = 1;
785 break;
786 }
787 p += 2;
788 }
789 if (!done)
790 *t++ = ' ';
791 }
792 *t = '\0';
793 while (--t > id_str) {
794 if (*t == ' ')
795 *t = '\0';
796 else
797 break;
798 }
799 printk ("Card ID: %s\n", id_str);
800
801 for (card=known_cards; *card; ++card) {
802 if (strcmp(*card, id_str) == 0) { /* found! */
803 return (1);
804 }
805 }
806
807 return (0); /* don't know */
808}
809
810static int __init mpc8xx_ide_probe(void)
811{
812 hw_regs_t hw;
813 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff };
814
815#ifdef IDE0_BASE_OFFSET
816 memset(&hw, 0, sizeof(hw));
817 if (!m8xx_ide_init_ports(&hw, 0)) {
818 ide_hwif_t *hwif = ide_find_port();
819
820 if (hwif) {
821 ide_init_port_hw(hwif, &hw);
822 hwif->pio_mask = ATA_PIO4;
823 hwif->port_ops = &m8xx_port_ops;
824
825 idx[0] = hwif->index;
826 }
827 }
828#ifdef IDE1_BASE_OFFSET
829 memset(&hw, 0, sizeof(hw));
830 if (!m8xx_ide_init_ports(&hw, 1)) {
831 ide_hwif_t *mate = ide_find_port();
832
833 if (mate) {
834 ide_init_port_hw(mate, &hw);
835 mate->pio_mask = ATA_PIO4;
836 mate->port_ops = &m8xx_port_ops;
837
838 idx[1] = mate->index;
839 }
840 }
841#endif
842#endif
843
844 ide_device_add(idx, NULL);
845
846 return 0;
847}
848
849module_init(mpc8xx_ide_probe);
850
851MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index dcb2c466bb97..93fb9067c043 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -5,7 +5,7 @@
5 * for doing DMA. 5 * for doing DMA.
6 * 6 *
7 * Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt 7 * Copyright (C) 1998-2003 Paul Mackerras & Ben. Herrenschmidt
8 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 8 * Copyright (C) 2007-2008 Bartlomiej Zolnierkiewicz
9 * 9 *
10 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License 11 * modify it under the terms of the GNU General Public License
@@ -48,8 +48,6 @@
48#include <asm/mediabay.h> 48#include <asm/mediabay.h>
49#endif 49#endif
50 50
51#include "../ide-timing.h"
52
53#undef IDE_PMAC_DEBUG 51#undef IDE_PMAC_DEBUG
54 52
55#define DMA_WAIT_TIMEOUT 50 53#define DMA_WAIT_TIMEOUT 50
@@ -495,6 +493,7 @@ static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port)
495static void 493static void
496pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) 494pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
497{ 495{
496 struct ide_timing *tim = ide_timing_find_mode(XFER_PIO_0 + pio);
498 u32 *timings, t; 497 u32 *timings, t;
499 unsigned accessTicks, recTicks; 498 unsigned accessTicks, recTicks;
500 unsigned accessTime, recTime; 499 unsigned accessTime, recTime;
@@ -526,10 +525,9 @@ pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
526 } 525 }
527 case controller_kl_ata4: 526 case controller_kl_ata4:
528 /* 66Mhz cell */ 527 /* 66Mhz cell */
529 recTime = cycle_time - ide_pio_timings[pio].active_time 528 recTime = cycle_time - tim->active - tim->setup;
530 - ide_pio_timings[pio].setup_time;
531 recTime = max(recTime, 150U); 529 recTime = max(recTime, 150U);
532 accessTime = ide_pio_timings[pio].active_time; 530 accessTime = tim->active;
533 accessTime = max(accessTime, 150U); 531 accessTime = max(accessTime, 150U);
534 accessTicks = SYSCLK_TICKS_66(accessTime); 532 accessTicks = SYSCLK_TICKS_66(accessTime);
535 accessTicks = min(accessTicks, 0x1fU); 533 accessTicks = min(accessTicks, 0x1fU);
@@ -542,10 +540,9 @@ pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
542 default: { 540 default: {
543 /* 33Mhz cell */ 541 /* 33Mhz cell */
544 int ebit = 0; 542 int ebit = 0;
545 recTime = cycle_time - ide_pio_timings[pio].active_time 543 recTime = cycle_time - tim->active - tim->setup;
546 - ide_pio_timings[pio].setup_time;
547 recTime = max(recTime, 150U); 544 recTime = max(recTime, 150U);
548 accessTime = ide_pio_timings[pio].active_time; 545 accessTime = tim->active;
549 accessTime = max(accessTime, 150U); 546 accessTime = max(accessTime, 150U);
550 accessTicks = SYSCLK_TICKS(accessTime); 547 accessTicks = SYSCLK_TICKS(accessTime);
551 accessTicks = min(accessTicks, 0x1fU); 548 accessTicks = min(accessTicks, 0x1fU);
@@ -1151,8 +1148,6 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1151 base = ioremap(macio_resource_start(mdev, 0), 0x400); 1148 base = ioremap(macio_resource_start(mdev, 0), 0x400);
1152 regbase = (unsigned long) base; 1149 regbase = (unsigned long) base;
1153 1150
1154 hwif->dev = &mdev->bus->pdev->dev;
1155
1156 pmif->mdev = mdev; 1151 pmif->mdev = mdev;
1157 pmif->node = mdev->ofdev.node; 1152 pmif->node = mdev->ofdev.node;
1158 pmif->regbase = regbase; 1153 pmif->regbase = regbase;
@@ -1174,7 +1169,8 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1174 memset(&hw, 0, sizeof(hw)); 1169 memset(&hw, 0, sizeof(hw));
1175 pmac_ide_init_ports(&hw, pmif->regbase); 1170 pmac_ide_init_ports(&hw, pmif->regbase);
1176 hw.irq = irq; 1171 hw.irq = irq;
1177 hw.dev = &mdev->ofdev.dev; 1172 hw.dev = &mdev->bus->pdev->dev;
1173 hw.parent = &mdev->ofdev.dev;
1178 1174
1179 rc = pmac_ide_setup_device(pmif, hwif, &hw); 1175 rc = pmac_ide_setup_device(pmif, hwif, &hw);
1180 if (rc != 0) { 1176 if (rc != 0) {
@@ -1274,7 +1270,6 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1274 goto out_free_pmif; 1270 goto out_free_pmif;
1275 } 1271 }
1276 1272
1277 hwif->dev = &pdev->dev;
1278 pmif->mdev = NULL; 1273 pmif->mdev = NULL;
1279 pmif->node = np; 1274 pmif->node = np;
1280 1275
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index abcfb1739d4d..65fc08b6b6d0 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -6,19 +6,15 @@
6 * May be copied or modified under the terms of the GNU General Public License 6 * May be copied or modified under the terms of the GNU General Public License
7 */ 7 */
8 8
9#include <linux/module.h>
10#include <linux/types.h> 9#include <linux/types.h>
11#include <linux/kernel.h> 10#include <linux/kernel.h>
12#include <linux/pci.h> 11#include <linux/pci.h>
13#include <linux/init.h> 12#include <linux/init.h>
14#include <linux/timer.h>
15#include <linux/mm.h>
16#include <linux/interrupt.h> 13#include <linux/interrupt.h>
17#include <linux/ide.h> 14#include <linux/ide.h>
18#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
19 16
20#include <asm/io.h> 17#include <asm/io.h>
21#include <asm/irq.h>
22 18
23/** 19/**
24 * ide_setup_pci_baseregs - place a PCI IDE controller native 20 * ide_setup_pci_baseregs - place a PCI IDE controller native
@@ -319,25 +315,22 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
319 315
320 ctl = pci_resource_start(dev, 2*port+1); 316 ctl = pci_resource_start(dev, 2*port+1);
321 base = pci_resource_start(dev, 2*port); 317 base = pci_resource_start(dev, 2*port);
322 if ((ctl && !base) || (base && !ctl)) { 318 } else {
323 printk(KERN_ERR "%s: inconsistent baseregs (BIOS) "
324 "for port %d, skipping\n", d->name, port);
325 return NULL;
326 }
327 }
328 if (!ctl) {
329 /* Use default values */ 319 /* Use default values */
330 ctl = port ? 0x374 : 0x3f4; 320 ctl = port ? 0x374 : 0x3f4;
331 base = port ? 0x170 : 0x1f0; 321 base = port ? 0x170 : 0x1f0;
332 } 322 }
333 323
334 hwif = ide_find_port_slot(d); 324 if (!base || !ctl) {
335 if (hwif == NULL) { 325 printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n",
336 printk(KERN_ERR "%s: too many IDE interfaces, no room in " 326 d->name, port);
337 "table\n", d->name);
338 return NULL; 327 return NULL;
339 } 328 }
340 329
330 hwif = ide_find_port_slot(d);
331 if (hwif == NULL)
332 return NULL;
333
341 memset(&hw, 0, sizeof(hw)); 334 memset(&hw, 0, sizeof(hw));
342 hw.irq = irq; 335 hw.irq = irq;
343 hw.dev = &dev->dev; 336 hw.dev = &dev->dev;
@@ -346,8 +339,6 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
346 339
347 ide_init_port_hw(hwif, &hw); 340 ide_init_port_hw(hwif, &hw);
348 341
349 hwif->dev = &dev->dev;
350
351 return hwif; 342 return hwif;
352} 343}
353 344
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 683bce375c74..f843c1383a4b 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -258,19 +258,6 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
258 return ide_stopped; 258 return ide_stopped;
259} 259}
260 260
261static ide_startstop_t
262idescsi_atapi_abort(ide_drive_t *drive, struct request *rq)
263{
264 debug_log("%s called for %lu\n", __func__,
265 ((struct ide_atapi_pc *) rq->special)->scsi_cmd->serial_number);
266
267 rq->errors |= ERROR_MAX;
268
269 idescsi_end_request(drive, 0, 0);
270
271 return ide_stopped;
272}
273
274static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) 261static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
275{ 262{
276 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 263 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
@@ -524,7 +511,6 @@ static ide_driver_t idescsi_driver = {
524 .do_request = idescsi_do_request, 511 .do_request = idescsi_do_request,
525 .end_request = idescsi_end_request, 512 .end_request = idescsi_end_request,
526 .error = idescsi_atapi_error, 513 .error = idescsi_atapi_error,
527 .abort = idescsi_atapi_abort,
528#ifdef CONFIG_IDE_PROC_FS 514#ifdef CONFIG_IDE_PROC_FS
529 .proc = idescsi_proc, 515 .proc = idescsi_proc,
530#endif 516#endif
diff --git a/include/linux/ide.h b/include/linux/ide.h
index ac4eeb2932ef..4726126f5a59 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -139,6 +139,12 @@ struct ide_io_ports {
139#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */ 139#define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */
140 140
141/* 141/*
142 * Op codes for special requests to be handled by ide_special_rq().
143 * Values should be in the range of 0x20 to 0x3f.
144 */
145#define REQ_DRIVE_RESET 0x20
146
147/*
142 * Check for an interrupt and acknowledge the interrupt status 148 * Check for an interrupt and acknowledge the interrupt status
143 */ 149 */
144struct hwif_s; 150struct hwif_s;
@@ -171,7 +177,7 @@ typedef struct hw_regs_s {
171 int irq; /* our irq number */ 177 int irq; /* our irq number */
172 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */ 178 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
173 hwif_chipset_t chipset; 179 hwif_chipset_t chipset;
174 struct device *dev; 180 struct device *dev, *parent;
175} hw_regs_t; 181} hw_regs_t;
176 182
177void ide_init_port_data(struct hwif_s *, unsigned int); 183void ide_init_port_data(struct hwif_s *, unsigned int);
@@ -405,8 +411,8 @@ typedef struct ide_drive_s {
405struct ide_port_info; 411struct ide_port_info;
406 412
407struct ide_port_ops { 413struct ide_port_ops {
408 /* host specific initialization of devices on a port */ 414 /* host specific initialization of a device */
409 void (*port_init_devs)(struct hwif_s *); 415 void (*init_dev)(ide_drive_t *);
410 /* routine to program host for PIO mode */ 416 /* routine to program host for PIO mode */
411 void (*set_pio_mode)(ide_drive_t *, const u8); 417 void (*set_pio_mode)(ide_drive_t *, const u8);
412 /* routine to program host for DMA mode */ 418 /* routine to program host for DMA mode */
@@ -565,8 +571,6 @@ typedef struct hwgroup_s {
565 unsigned int sleeping : 1; 571 unsigned int sleeping : 1;
566 /* BOOL: polling active & poll_timeout field valid */ 572 /* BOOL: polling active & poll_timeout field valid */
567 unsigned int polling : 1; 573 unsigned int polling : 1;
568 /* BOOL: in a polling reset situation. Must not trigger another reset yet */
569 unsigned int resetting : 1;
570 574
571 /* current drive */ 575 /* current drive */
572 ide_drive_t *drive; 576 ide_drive_t *drive;
@@ -786,7 +790,6 @@ struct ide_driver_s {
786 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 790 ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t);
787 int (*end_request)(ide_drive_t *, int, int); 791 int (*end_request)(ide_drive_t *, int, int);
788 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 792 ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
789 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
790 struct device_driver gen_driver; 793 struct device_driver gen_driver;
791 int (*probe)(ide_drive_t *); 794 int (*probe)(ide_drive_t *);
792 void (*remove)(ide_drive_t *); 795 void (*remove)(ide_drive_t *);
@@ -801,18 +804,6 @@ struct ide_driver_s {
801 804
802int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 805int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
803 806
804/*
805 * ide_hwifs[] is the master data structure used to keep track
806 * of just about everything in ide.c. Whenever possible, routines
807 * should be using pointers to a drive (ide_drive_t *) or
808 * pointers to a hwif (ide_hwif_t *), rather than indexing this
809 * structure directly (the allocation/layout may change!).
810 *
811 */
812#ifndef _IDE_C
813extern ide_hwif_t ide_hwifs[]; /* master data repository */
814#endif
815
816extern int ide_vlb_clk; 807extern int ide_vlb_clk;
817extern int ide_pci_clk; 808extern int ide_pci_clk;
818 809
@@ -840,10 +831,6 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
840 831
841ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 832ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
842 833
843ide_startstop_t __ide_abort(ide_drive_t *, struct request *);
844
845extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
846
847extern void ide_fix_driveid(struct hd_driveid *); 834extern void ide_fix_driveid(struct hd_driveid *);
848 835
849extern void ide_fixstring(u8 *, const int, const int); 836extern void ide_fixstring(u8 *, const int, const int);
@@ -1271,16 +1258,43 @@ static inline int ide_dev_is_sata(struct hd_driveid *id)
1271u64 ide_get_lba_addr(struct ide_taskfile *, int); 1258u64 ide_get_lba_addr(struct ide_taskfile *, int);
1272u8 ide_dump_status(ide_drive_t *, const char *, u8); 1259u8 ide_dump_status(ide_drive_t *, const char *, u8);
1273 1260
1274typedef struct ide_pio_timings_s { 1261struct ide_timing {
1275 int setup_time; /* Address setup (ns) minimum */ 1262 u8 mode;
1276 int active_time; /* Active pulse (ns) minimum */ 1263 u8 setup; /* t1 */
1277 int cycle_time; /* Cycle time (ns) minimum = */ 1264 u16 act8b; /* t2 for 8-bit io */
1278 /* active + recovery (+ setup for some chips) */ 1265 u16 rec8b; /* t2i for 8-bit io */
1279} ide_pio_timings_t; 1266 u16 cyc8b; /* t0 for 8-bit io */
1267 u16 active; /* t2 or tD */
1268 u16 recover; /* t2i or tK */
1269 u16 cycle; /* t0 */
1270 u16 udma; /* t2CYCTYP/2 */
1271};
1272
1273enum {
1274 IDE_TIMING_SETUP = (1 << 0),
1275 IDE_TIMING_ACT8B = (1 << 1),
1276 IDE_TIMING_REC8B = (1 << 2),
1277 IDE_TIMING_CYC8B = (1 << 3),
1278 IDE_TIMING_8BIT = IDE_TIMING_ACT8B | IDE_TIMING_REC8B |
1279 IDE_TIMING_CYC8B,
1280 IDE_TIMING_ACTIVE = (1 << 4),
1281 IDE_TIMING_RECOVER = (1 << 5),
1282 IDE_TIMING_CYCLE = (1 << 6),
1283 IDE_TIMING_UDMA = (1 << 7),
1284 IDE_TIMING_ALL = IDE_TIMING_SETUP | IDE_TIMING_8BIT |
1285 IDE_TIMING_ACTIVE | IDE_TIMING_RECOVER |
1286 IDE_TIMING_CYCLE | IDE_TIMING_UDMA,
1287};
1288
1289struct ide_timing *ide_timing_find_mode(u8);
1290u16 ide_pio_cycle_time(ide_drive_t *, u8);
1291void ide_timing_merge(struct ide_timing *, struct ide_timing *,
1292 struct ide_timing *, unsigned int);
1293int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
1294
1295int ide_scan_pio_blacklist(char *);
1280 1296
1281unsigned int ide_pio_cycle_time(ide_drive_t *, u8);
1282u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8); 1297u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
1283extern const ide_pio_timings_t ide_pio_timings[6];
1284 1298
1285int ide_set_pio_mode(ide_drive_t *, u8); 1299int ide_set_pio_mode(ide_drive_t *, u8);
1286int ide_set_dma_mode(ide_drive_t *, u8); 1300int ide_set_dma_mode(ide_drive_t *, u8);