diff options
author | David S. Miller <davem@davemloft.net> | 2008-07-18 05:39:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-18 05:39:39 -0400 |
commit | 49997d75152b3d23c53b0fa730599f2f74c92c65 (patch) | |
tree | 46e93126170d02cfec9505172e545732c1b69656 /drivers/ide | |
parent | a0c80b80e0fb48129e4e9d6a9ede914f9ff1850d (diff) | |
parent | 5b664cb235e97afbf34db9c4d77f08ebd725335e (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
Documentation/powerpc/booting-without-of.txt
drivers/atm/Makefile
drivers/net/fs_enet/fs_enet-main.c
drivers/pci/pci-acpi.c
net/8021q/vlan.c
net/iucv/iucv.c
Diffstat (limited to 'drivers/ide')
62 files changed, 1479 insertions, 4063 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 1607536ff5fb..15b09b89588a 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
@@ -98,6 +98,12 @@ if BLK_DEV_IDE | |||
98 | 98 | ||
99 | comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" | 99 | comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" |
100 | 100 | ||
101 | config IDE_TIMINGS | ||
102 | bool | ||
103 | |||
104 | config IDE_ATAPI | ||
105 | bool | ||
106 | |||
101 | config BLK_DEV_IDE_SATA | 107 | config BLK_DEV_IDE_SATA |
102 | bool "Support for SATA (deprecated; conflicts with libata SATA driver)" | 108 | bool "Support for SATA (deprecated; conflicts with libata SATA driver)" |
103 | default n | 109 | default n |
@@ -201,6 +207,7 @@ config BLK_DEV_IDECD_VERBOSE_ERRORS | |||
201 | 207 | ||
202 | config BLK_DEV_IDETAPE | 208 | config BLK_DEV_IDETAPE |
203 | tristate "Include IDE/ATAPI TAPE support" | 209 | tristate "Include IDE/ATAPI TAPE support" |
210 | select IDE_ATAPI | ||
204 | help | 211 | help |
205 | If you have an IDE tape drive using the ATAPI protocol, say Y. | 212 | If you have an IDE tape drive using the ATAPI protocol, say Y. |
206 | ATAPI is a newer protocol used by IDE tape and CD-ROM drives, | 213 | ATAPI is a newer protocol used by IDE tape and CD-ROM drives, |
@@ -223,6 +230,7 @@ config BLK_DEV_IDETAPE | |||
223 | 230 | ||
224 | config BLK_DEV_IDEFLOPPY | 231 | config BLK_DEV_IDEFLOPPY |
225 | tristate "Include IDE/ATAPI FLOPPY support" | 232 | tristate "Include IDE/ATAPI FLOPPY support" |
233 | select IDE_ATAPI | ||
226 | ---help--- | 234 | ---help--- |
227 | If you have an IDE floppy drive which uses the ATAPI protocol, | 235 | If you have an IDE floppy drive which uses the ATAPI protocol, |
228 | answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy | 236 | answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy |
@@ -246,6 +254,7 @@ config BLK_DEV_IDEFLOPPY | |||
246 | config BLK_DEV_IDESCSI | 254 | config BLK_DEV_IDESCSI |
247 | tristate "SCSI emulation support" | 255 | tristate "SCSI emulation support" |
248 | depends on SCSI | 256 | depends on SCSI |
257 | select IDE_ATAPI | ||
249 | ---help--- | 258 | ---help--- |
250 | WARNING: ide-scsi is no longer needed for cd writing applications! | 259 | WARNING: ide-scsi is no longer needed for cd writing applications! |
251 | The 2.6 kernel supports direct writing to ide-cd, which eliminates | 260 | The 2.6 kernel supports direct writing to ide-cd, which eliminates |
@@ -320,6 +329,7 @@ config BLK_DEV_PLATFORM | |||
320 | config BLK_DEV_CMD640 | 329 | config BLK_DEV_CMD640 |
321 | tristate "CMD640 chipset bugfix/support" | 330 | tristate "CMD640 chipset bugfix/support" |
322 | depends on X86 | 331 | depends on X86 |
332 | select IDE_TIMINGS | ||
323 | ---help--- | 333 | ---help--- |
324 | 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 |
325 | Pentium motherboards, usually in combination with a "Neptune" or | 335 | Pentium motherboards, usually in combination with a "Neptune" or |
@@ -449,6 +459,7 @@ config BLK_DEV_AEC62XX | |||
449 | 459 | ||
450 | config BLK_DEV_ALI15X3 | 460 | config BLK_DEV_ALI15X3 |
451 | tristate "ALI M15x3 chipset support" | 461 | tristate "ALI M15x3 chipset support" |
462 | select IDE_TIMINGS | ||
452 | select BLK_DEV_IDEDMA_PCI | 463 | select BLK_DEV_IDEDMA_PCI |
453 | help | 464 | help |
454 | 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 |
@@ -463,6 +474,7 @@ config BLK_DEV_ALI15X3 | |||
463 | config BLK_DEV_AMD74XX | 474 | config BLK_DEV_AMD74XX |
464 | tristate "AMD and nVidia IDE support" | 475 | tristate "AMD and nVidia IDE support" |
465 | depends on !ARM | 476 | depends on !ARM |
477 | select IDE_TIMINGS | ||
466 | select BLK_DEV_IDEDMA_PCI | 478 | select BLK_DEV_IDEDMA_PCI |
467 | help | 479 | help |
468 | 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 |
@@ -483,6 +495,7 @@ config BLK_DEV_ATIIXP | |||
483 | 495 | ||
484 | config BLK_DEV_CMD64X | 496 | config BLK_DEV_CMD64X |
485 | tristate "CMD64{3|6|8|9} chipset support" | 497 | tristate "CMD64{3|6|8|9} chipset support" |
498 | select IDE_TIMINGS | ||
486 | select BLK_DEV_IDEDMA_PCI | 499 | select BLK_DEV_IDEDMA_PCI |
487 | help | 500 | help |
488 | 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 |
@@ -497,6 +510,7 @@ config BLK_DEV_TRIFLEX | |||
497 | 510 | ||
498 | config BLK_DEV_CY82C693 | 511 | config BLK_DEV_CY82C693 |
499 | tristate "CY82C693 chipset support" | 512 | tristate "CY82C693 chipset support" |
513 | select IDE_TIMINGS | ||
500 | select BLK_DEV_IDEDMA_PCI | 514 | select BLK_DEV_IDEDMA_PCI |
501 | help | 515 | help |
502 | This driver adds detection and support for the CY82C693 chipset | 516 | This driver adds detection and support for the CY82C693 chipset |
@@ -689,6 +703,7 @@ config BLK_DEV_SIS5513 | |||
689 | config BLK_DEV_SL82C105 | 703 | config BLK_DEV_SL82C105 |
690 | tristate "Winbond SL82c105 support" | 704 | tristate "Winbond SL82c105 support" |
691 | depends on (PPC || ARM) | 705 | depends on (PPC || ARM) |
706 | select IDE_TIMINGS | ||
692 | select BLK_DEV_IDEDMA_PCI | 707 | select BLK_DEV_IDEDMA_PCI |
693 | help | 708 | help |
694 | 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 |
@@ -719,6 +734,7 @@ config BLK_DEV_TRM290 | |||
719 | 734 | ||
720 | config BLK_DEV_VIA82CXXX | 735 | config BLK_DEV_VIA82CXXX |
721 | tristate "VIA82CXXX chipset support" | 736 | tristate "VIA82CXXX chipset support" |
737 | select IDE_TIMINGS | ||
722 | select BLK_DEV_IDEDMA_PCI | 738 | select BLK_DEV_IDEDMA_PCI |
723 | help | 739 | help |
724 | This driver adds explicit support for VIA BusMastering IDE chips. | 740 | This driver adds explicit support for VIA BusMastering IDE chips. |
@@ -745,6 +761,7 @@ endif | |||
745 | config BLK_DEV_IDE_PMAC | 761 | config BLK_DEV_IDE_PMAC |
746 | tristate "PowerMac on-board IDE support" | 762 | tristate "PowerMac on-board IDE support" |
747 | 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 | ||
748 | help | 765 | help |
749 | This driver provides support for the on-board IDE controller on | 766 | This driver provides support for the on-board IDE controller on |
750 | most of the recent Apple Power Macintoshes and PowerBooks. | 767 | most of the recent Apple Power Macintoshes and PowerBooks. |
@@ -823,13 +840,6 @@ config BLK_DEV_IDE_RAPIDE | |||
823 | 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 |
824 | manufactured for use with Acorn computers. | 841 | manufactured for use with Acorn computers. |
825 | 842 | ||
826 | config BLK_DEV_IDE_BAST | ||
827 | tristate "Simtec BAST / Thorcom VR1000 IDE support" | ||
828 | depends on ARM && (ARCH_BAST || MACH_VR1000) | ||
829 | help | ||
830 | Say Y here if you want to support the onboard IDE channels on the | ||
831 | Simtec BAST or the Thorcom VR1000 | ||
832 | |||
833 | config IDE_H8300 | 843 | config IDE_H8300 |
834 | tristate "H8300 IDE support" | 844 | tristate "H8300 IDE support" |
835 | depends on H8300 | 845 | depends on H8300 |
@@ -913,51 +923,12 @@ config BLK_DEV_Q40IDE | |||
913 | config BLK_DEV_PALMCHIP_BK3710 | 923 | config BLK_DEV_PALMCHIP_BK3710 |
914 | tristate "Palmchip bk3710 IDE controller support" | 924 | tristate "Palmchip bk3710 IDE controller support" |
915 | depends on ARCH_DAVINCI | 925 | depends on ARCH_DAVINCI |
926 | select IDE_TIMINGS | ||
916 | select BLK_DEV_IDEDMA_SFF | 927 | select BLK_DEV_IDEDMA_SFF |
917 | help | 928 | help |
918 | 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 |
919 | TI DaVinci SoC | 930 | TI DaVinci SoC |
920 | 931 | ||
921 | |||
922 | config BLK_DEV_MPC8xx_IDE | ||
923 | tristate "MPC8xx IDE support" | ||
924 | depends on 8xx && (LWMON || IVMS8 || IVML24 || TQM8xxL) && IDE=y && BLK_DEV_IDE=y && !PPC_MERGE | ||
925 | help | ||
926 | This option provides support for IDE on Motorola MPC8xx Systems. | ||
927 | Please see 'Type of MPC8xx IDE interface' for details. | ||
928 | |||
929 | If unsure, say N. | ||
930 | |||
931 | choice | ||
932 | prompt "Type of MPC8xx IDE interface" | ||
933 | depends on BLK_DEV_MPC8xx_IDE | ||
934 | default IDE_8xx_PCCARD | ||
935 | |||
936 | config IDE_8xx_PCCARD | ||
937 | bool "8xx_PCCARD" | ||
938 | ---help--- | ||
939 | Select how the IDE devices are connected to the MPC8xx system: | ||
940 | |||
941 | 8xx_PCCARD uses the 8xx internal PCMCIA interface in combination | ||
942 | with a PC Card (e.g. ARGOSY portable Hard Disk Adapter), | ||
943 | ATA PC Card HDDs or ATA PC Flash Cards (example: TQM8xxL | ||
944 | systems) | ||
945 | |||
946 | 8xx_DIRECT is used for directly connected IDE devices using the 8xx | ||
947 | internal PCMCIA interface (example: IVMS8 systems) | ||
948 | |||
949 | EXT_DIRECT is used for IDE devices directly connected to the 8xx | ||
950 | bus using some glue logic, but _not_ the 8xx internal | ||
951 | PCMCIA interface (example: IDIF860 systems) | ||
952 | |||
953 | config IDE_8xx_DIRECT | ||
954 | bool "8xx_DIRECT" | ||
955 | |||
956 | config IDE_EXT_DIRECT | ||
957 | bool "EXT_DIRECT" | ||
958 | |||
959 | endchoice | ||
960 | |||
961 | # no isa -> no vlb | 932 | # no isa -> no vlb |
962 | if ISA && (ALPHA || X86 || MIPS) | 933 | if ISA && (ALPHA || X86 || MIPS) |
963 | 934 | ||
@@ -975,6 +946,7 @@ config BLK_DEV_4DRIVES | |||
975 | 946 | ||
976 | config BLK_DEV_ALI14XX | 947 | config BLK_DEV_ALI14XX |
977 | tristate "ALI M14xx support" | 948 | tristate "ALI M14xx support" |
949 | select IDE_TIMINGS | ||
978 | help | 950 | help |
979 | This driver is enabled at runtime using the "ali14xx.probe" kernel | 951 | This driver is enabled at runtime using the "ali14xx.probe" kernel |
980 | boot parameter. It enables support for the secondary IDE interface | 952 | boot parameter. It enables support for the secondary IDE interface |
@@ -994,6 +966,7 @@ config BLK_DEV_DTC2278 | |||
994 | 966 | ||
995 | config BLK_DEV_HT6560B | 967 | config BLK_DEV_HT6560B |
996 | tristate "Holtek HT6560B support" | 968 | tristate "Holtek HT6560B support" |
969 | select IDE_TIMINGS | ||
997 | help | 970 | help |
998 | This driver is enabled at runtime using the "ht6560b.probe" kernel | 971 | This driver is enabled at runtime using the "ht6560b.probe" kernel |
999 | boot parameter. It enables support for the secondary IDE interface | 972 | boot parameter. It enables support for the secondary IDE interface |
@@ -1003,6 +976,7 @@ config BLK_DEV_HT6560B | |||
1003 | 976 | ||
1004 | config BLK_DEV_QD65XX | 977 | config BLK_DEV_QD65XX |
1005 | tristate "QDI QD65xx support" | 978 | tristate "QDI QD65xx support" |
979 | select IDE_TIMINGS | ||
1006 | help | 980 | help |
1007 | This driver is enabled at runtime using the "qd65xx.probe" kernel | 981 | This driver is enabled at runtime using the "qd65xx.probe" kernel |
1008 | 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 |
@@ -1026,30 +1000,4 @@ config BLK_DEV_IDEDMA | |||
1026 | 1000 | ||
1027 | endif | 1001 | endif |
1028 | 1002 | ||
1029 | config BLK_DEV_HD_ONLY | ||
1030 | bool "Old hard disk (MFM/RLL/IDE) driver" | ||
1031 | depends on !ARM || ARCH_RPC || ARCH_SHARK || BROKEN | ||
1032 | help | ||
1033 | There are two drivers for MFM/RLL/IDE hard disks. Most people use | ||
1034 | the newer enhanced driver, but this old one is still around for two | ||
1035 | reasons. Some older systems have strange timing problems and seem to | ||
1036 | work only with the old driver (which itself does not work with some | ||
1037 | newer systems). The other reason is that the old driver is smaller, | ||
1038 | since it lacks the enhanced functionality of the new one. This makes | ||
1039 | it a good choice for systems with very tight memory restrictions, or | ||
1040 | for systems with only older MFM/RLL/ESDI drives. Choosing the old | ||
1041 | driver can save 13 KB or so of kernel memory. | ||
1042 | |||
1043 | If you want to use this driver together with the new one you have | ||
1044 | to use "hda=noprobe hdb=noprobe" kernel parameters to prevent the new | ||
1045 | driver from probing the primary interface. | ||
1046 | |||
1047 | If you are unsure, then just choose the Enhanced IDE/MFM/RLL driver | ||
1048 | instead of this one. For more detailed information, read the | ||
1049 | Disk-HOWTO, available from | ||
1050 | <http://www.tldp.org/docs.html#howto>. | ||
1051 | |||
1052 | config BLK_DEV_HD | ||
1053 | def_bool BLK_DEV_HD_ONLY | ||
1054 | |||
1055 | endif # IDE | 1003 | endif # IDE |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index f94b679b611e..5d414e301a5a 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -11,9 +11,12 @@ | |||
11 | 11 | ||
12 | EXTRA_CFLAGS += -Idrivers/ide | 12 | EXTRA_CFLAGS += -Idrivers/ide |
13 | 13 | ||
14 | ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o | 14 | ide-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 |
18 | ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o | ||
19 | ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o | ||
17 | ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o | 20 | ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o |
18 | ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o | 21 | ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o |
19 | ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o | 22 | ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o |
@@ -58,9 +61,3 @@ ifeq ($(CONFIG_BLK_DEV_PLATFORM), y) | |||
58 | endif | 61 | endif |
59 | 62 | ||
60 | obj-$(CONFIG_BLK_DEV_IDE) += arm/ mips/ | 63 | obj-$(CONFIG_BLK_DEV_IDE) += arm/ mips/ |
61 | |||
62 | # old hd driver must be last | ||
63 | ifeq ($(CONFIG_BLK_DEV_HD), y) | ||
64 | hd-core-y += legacy/hd.o | ||
65 | obj-y += hd-core.o | ||
66 | endif | ||
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 | ||
2 | obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o | 2 | obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o |
3 | obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o | 3 | obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o |
4 | obj-$(CONFIG_BLK_DEV_IDE_BAST) += bast-ide.o | ||
5 | obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o | 4 | obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o |
6 | 5 | ||
7 | ifeq ($(CONFIG_IDE_ARM), m) | 6 | ifeq ($(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 | |||
26 | static 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); | ||
60 | out: | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static 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 | |||
86 | module_init(bastide_init); | ||
87 | |||
88 | MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>"); | ||
89 | MODULE_LICENSE("GPL"); | ||
90 | MODULE_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 = { | |||
165 | static void icside_maskproc(ide_drive_t *drive, int mask) | 168 | static 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) | |||
359 | static int icside_dma_test_irq(ide_drive_t *drive) | 364 | static 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 | ||
414 | static ide_hwif_t * | 420 | static void icside_setup_ports(hw_regs_t *hw, void __iomem *base, |
415 | icside_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 | ||
446 | static int __init | 440 | static 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 cc24803fadff..c79b85b6e4a3 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
@@ -74,20 +74,16 @@ 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" | 77 | static unsigned ideclk_period; /* in nanoseconds */ |
78 | |||
79 | static long ide_palm_clk; | ||
80 | 78 | ||
81 | static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { | 79 | static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = { |
82 | {160, 240}, /* UDMA Mode 0 */ | 80 | {160, 240}, /* UDMA Mode 0 */ |
83 | {125, 160}, /* UDMA Mode 1 */ | 81 | {125, 160}, /* UDMA Mode 1 */ |
84 | {100, 120}, /* UDMA Mode 2 */ | 82 | {100, 120}, /* UDMA Mode 2 */ |
85 | {100, 90}, /* UDMA Mode 3 */ | 83 | {100, 90}, /* UDMA Mode 3 */ |
86 | {85, 60}, /* UDMA Mode 4 */ | 84 | {100, 60}, /* UDMA Mode 4 */ |
87 | }; | 85 | }; |
88 | 86 | ||
89 | static struct clk *ideclkp; | ||
90 | |||
91 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | 87 | static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, |
92 | unsigned int mode) | 88 | unsigned int mode) |
93 | { | 89 | { |
@@ -97,10 +93,10 @@ static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, | |||
97 | 93 | ||
98 | /* DMA Data Setup */ | 94 | /* DMA Data Setup */ |
99 | t0 = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].cycletime, | 95 | t0 = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].cycletime, |
100 | ide_palm_clk) - 1; | 96 | ideclk_period) - 1; |
101 | tenv = DIV_ROUND_UP(20, ide_palm_clk) - 1; | 97 | tenv = DIV_ROUND_UP(20, ideclk_period) - 1; |
102 | trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, | 98 | trp = DIV_ROUND_UP(palm_bk3710_udmatimings[mode].rptime, |
103 | ide_palm_clk) - 1; | 99 | ideclk_period) - 1; |
104 | 100 | ||
105 | /* udmatim Register */ | 101 | /* udmatim Register */ |
106 | val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); | 102 | val16 = readw(base + BK3710_UDMATIM) & (dev ? 0xFF0F : 0xFFF0); |
@@ -141,8 +137,8 @@ static void palm_bk3710_setdmamode(void __iomem *base, unsigned int dev, | |||
141 | cycletime = max_t(int, t->cycle, min_cycle); | 137 | cycletime = max_t(int, t->cycle, min_cycle); |
142 | 138 | ||
143 | /* DMA Data Setup */ | 139 | /* DMA Data Setup */ |
144 | t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); | 140 | t0 = DIV_ROUND_UP(cycletime, ideclk_period); |
145 | td = DIV_ROUND_UP(t->active, ide_palm_clk); | 141 | td = DIV_ROUND_UP(t->active, ideclk_period); |
146 | tkw = t0 - td - 1; | 142 | tkw = t0 - td - 1; |
147 | td -= 1; | 143 | td -= 1; |
148 | 144 | ||
@@ -168,9 +164,9 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
168 | struct ide_timing *t; | 164 | struct ide_timing *t; |
169 | 165 | ||
170 | /* PIO Data Setup */ | 166 | /* PIO Data Setup */ |
171 | t0 = DIV_ROUND_UP(cycletime, ide_palm_clk); | 167 | t0 = DIV_ROUND_UP(cycletime, ideclk_period); |
172 | t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active, | 168 | t2 = DIV_ROUND_UP(ide_timing_find_mode(XFER_PIO_0 + mode)->active, |
173 | ide_palm_clk); | 169 | ideclk_period); |
174 | 170 | ||
175 | t2i = t0 - t2 - 1; | 171 | t2i = t0 - t2 - 1; |
176 | t2 -= 1; | 172 | t2 -= 1; |
@@ -192,8 +188,8 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
192 | 188 | ||
193 | /* TASKFILE Setup */ | 189 | /* TASKFILE Setup */ |
194 | t = ide_timing_find_mode(XFER_PIO_0 + mode); | 190 | t = ide_timing_find_mode(XFER_PIO_0 + mode); |
195 | t0 = DIV_ROUND_UP(t->cyc8b, ide_palm_clk); | 191 | t0 = DIV_ROUND_UP(t->cyc8b, ideclk_period); |
196 | t2 = DIV_ROUND_UP(t->act8b, ide_palm_clk); | 192 | t2 = DIV_ROUND_UP(t->act8b, ideclk_period); |
197 | 193 | ||
198 | t2i = t0 - t2 - 1; | 194 | t2i = t0 - t2 - 1; |
199 | t2 -= 1; | 195 | t2 -= 1; |
@@ -350,22 +346,22 @@ static const struct ide_port_info __devinitdata palm_bk3710_port_info = { | |||
350 | 346 | ||
351 | static int __devinit palm_bk3710_probe(struct platform_device *pdev) | 347 | static int __devinit palm_bk3710_probe(struct platform_device *pdev) |
352 | { | 348 | { |
353 | struct clk *clkp; | 349 | struct clk *clk; |
354 | struct resource *mem, *irq; | 350 | struct resource *mem, *irq; |
355 | ide_hwif_t *hwif; | 351 | ide_hwif_t *hwif; |
356 | unsigned long base; | 352 | unsigned long base, rate; |
357 | int i; | 353 | int i; |
358 | hw_regs_t hw; | 354 | hw_regs_t hw; |
359 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 355 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
360 | 356 | ||
361 | clkp = clk_get(NULL, "IDECLK"); | 357 | clk = clk_get(NULL, "IDECLK"); |
362 | if (IS_ERR(clkp)) | 358 | if (IS_ERR(clk)) |
363 | return -ENODEV; | 359 | return -ENODEV; |
364 | 360 | ||
365 | ideclkp = clkp; | 361 | clk_enable(clk); |
366 | clk_enable(ideclkp); | 362 | rate = clk_get_rate(clk); |
367 | ide_palm_clk = clk_get_rate(ideclkp)/100000; | 363 | ideclk_period = 1000000000UL / rate; |
368 | ide_palm_clk = (10000/ide_palm_clk) + 1; | 364 | |
369 | /* Register the IDE interface with Linux ATA Interface */ | 365 | /* Register the IDE interface with Linux ATA Interface */ |
370 | memset(&hw, 0, sizeof(hw)); | 366 | memset(&hw, 0, sizeof(hw)); |
371 | 367 | ||
@@ -404,10 +400,8 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev) | |||
404 | 400 | ||
405 | i = hwif->index; | 401 | i = hwif->index; |
406 | 402 | ||
407 | ide_init_port_data(hwif, i); | ||
408 | ide_init_port_hw(hwif, &hw); | 403 | ide_init_port_hw(hwif, &hw); |
409 | 404 | ||
410 | hwif->mmio = 1; | ||
411 | default_hwif_mmiops(hwif); | 405 | default_hwif_mmiops(hwif); |
412 | 406 | ||
413 | idx[0] = i; | 407 | idx[0] = i; |
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 | ||
14 | static struct const ide_port_info rapide_port_info = { | ||
15 | .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, | ||
16 | }; | ||
17 | |||
14 | static void rapide_setup_ports(hw_regs_t *hw, void __iomem *base, | 18 | static 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 ecf53bb0d2aa..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; \ |
@@ -52,8 +54,6 @@ static void h8300_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
52 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | 54 | if (task->tf_flags & IDE_TFLAG_FLAGGED) |
53 | HIHI = 0xFF; | 55 | HIHI = 0xFF; |
54 | 56 | ||
55 | ide_set_irq(drive, 1); | ||
56 | |||
57 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) | 57 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) |
58 | mm_outw((tf->hob_data << 8) | tf->data, io_ports->data_addr); | 58 | mm_outw((tf->hob_data << 8) | tf->data, io_ports->data_addr); |
59 | 59 | ||
@@ -98,7 +98,7 @@ static void h8300_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
98 | } | 98 | } |
99 | 99 | ||
100 | /* be sure we're looking at the low order bits */ | 100 | /* be sure we're looking at the low order bits */ |
101 | outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 101 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
102 | 102 | ||
103 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 103 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
104 | tf->nsect = inb(io_ports->nsect_addr); | 104 | tf->nsect = inb(io_ports->nsect_addr); |
@@ -112,7 +112,7 @@ static void h8300_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
112 | tf->device = inb(io_ports->device_addr); | 112 | tf->device = inb(io_ports->device_addr); |
113 | 113 | ||
114 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 114 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
115 | outb(drive->ctl | 0x80, io_ports->ctl_addr); | 115 | outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
116 | 116 | ||
117 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 117 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
118 | tf->hob_feature = inb(io_ports->feature_addr); | 118 | tf->hob_feature = inb(io_ports->feature_addr); |
@@ -178,6 +178,10 @@ static inline void hwif_setup(ide_hwif_t *hwif) | |||
178 | hwif->output_data = h8300_output_data; | 178 | hwif->output_data = h8300_output_data; |
179 | } | 179 | } |
180 | 180 | ||
181 | static const struct ide_port_info h8300_port_info = { | ||
182 | .host_flags = IDE_HFLAG_NO_IO_32BIT | IDE_HFLAG_NO_DMA, | ||
183 | }; | ||
184 | |||
181 | static int __init h8300_ide_init(void) | 185 | static int __init h8300_ide_init(void) |
182 | { | 186 | { |
183 | hw_regs_t hw; | 187 | hw_regs_t hw; |
@@ -185,6 +189,8 @@ static int __init h8300_ide_init(void) | |||
185 | int index; | 189 | int index; |
186 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 190 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
187 | 191 | ||
192 | printk(KERN_INFO DRV_NAME ": H8/300 generic IDE interface\n"); | ||
193 | |||
188 | 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")) |
189 | goto out_busy; | 195 | goto out_busy; |
190 | 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")) { |
@@ -194,22 +200,17 @@ static int __init h8300_ide_init(void) | |||
194 | 200 | ||
195 | hw_setup(&hw); | 201 | hw_setup(&hw); |
196 | 202 | ||
197 | hwif = ide_find_port(); | 203 | hwif = ide_find_port_slot(&h8300_port_info); |
198 | if (hwif == NULL) { | 204 | if (hwif == NULL) |
199 | printk(KERN_ERR "ide-h8300: IDE I/F register failed\n"); | ||
200 | return -ENOENT; | 205 | return -ENOENT; |
201 | } | ||
202 | 206 | ||
203 | index = hwif->index; | 207 | index = hwif->index; |
204 | ide_init_port_data(hwif, index); | ||
205 | ide_init_port_hw(hwif, &hw); | 208 | ide_init_port_hw(hwif, &hw); |
206 | hwif_setup(hwif); | 209 | hwif_setup(hwif); |
207 | hwif->host_flags = IDE_HFLAG_NO_IO_32BIT; | ||
208 | printk(KERN_INFO "ide%d: H8/300 generic IDE interface\n", index); | ||
209 | 210 | ||
210 | idx[0] = index; | 211 | idx[0] = index; |
211 | 212 | ||
212 | ide_device_add(idx, NULL); | 213 | ide_device_add(idx, &h8300_port_info); |
213 | 214 | ||
214 | return 0; | 215 | return 0; |
215 | 216 | ||
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 9d3601fa5680..6f704628c27d 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
@@ -60,15 +60,15 @@ struct ide_acpi_hwif_link { | |||
60 | #define DEBPRINT(fmt, args...) do {} while (0) | 60 | #define DEBPRINT(fmt, args...) do {} while (0) |
61 | #endif /* DEBUGGING */ | 61 | #endif /* DEBUGGING */ |
62 | 62 | ||
63 | int ide_noacpi; | 63 | static int ide_noacpi; |
64 | module_param_named(noacpi, ide_noacpi, bool, 0); | 64 | module_param_named(noacpi, ide_noacpi, bool, 0); |
65 | MODULE_PARM_DESC(noacpi, "disable IDE ACPI support"); | 65 | MODULE_PARM_DESC(noacpi, "disable IDE ACPI support"); |
66 | 66 | ||
67 | int ide_acpigtf; | 67 | static int ide_acpigtf; |
68 | module_param_named(acpigtf, ide_acpigtf, bool, 0); | 68 | module_param_named(acpigtf, ide_acpigtf, bool, 0); |
69 | MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support"); | 69 | MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support"); |
70 | 70 | ||
71 | int ide_acpionboot; | 71 | static int ide_acpionboot; |
72 | module_param_named(acpionboot, ide_acpionboot, bool, 0); | 72 | module_param_named(acpionboot, ide_acpionboot, bool, 0); |
73 | MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot"); | 73 | MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot"); |
74 | 74 | ||
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c new file mode 100644 index 000000000000..2802031de670 --- /dev/null +++ b/drivers/ide/ide-atapi.c | |||
@@ -0,0 +1,296 @@ | |||
1 | /* | ||
2 | * ATAPI support. | ||
3 | */ | ||
4 | |||
5 | #include <linux/kernel.h> | ||
6 | #include <linux/delay.h> | ||
7 | #include <linux/ide.h> | ||
8 | #include <scsi/scsi.h> | ||
9 | |||
10 | #ifdef DEBUG | ||
11 | #define debug_log(fmt, args...) \ | ||
12 | printk(KERN_INFO "ide: " fmt, ## args) | ||
13 | #else | ||
14 | #define debug_log(fmt, args...) do {} while (0) | ||
15 | #endif | ||
16 | |||
17 | /* TODO: unify the code thus making some arguments go away */ | ||
18 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
19 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | ||
20 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | ||
21 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | ||
22 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) | ||
23 | { | ||
24 | ide_hwif_t *hwif = drive->hwif; | ||
25 | xfer_func_t *xferfunc; | ||
26 | unsigned int temp; | ||
27 | u16 bcount; | ||
28 | u8 stat, ireason, scsi = drive->scsi; | ||
29 | |||
30 | debug_log("Enter %s - interrupt handler\n", __func__); | ||
31 | |||
32 | if (pc->flags & PC_FLAG_TIMEDOUT) { | ||
33 | pc->callback(drive); | ||
34 | return ide_stopped; | ||
35 | } | ||
36 | |||
37 | /* Clear the interrupt */ | ||
38 | stat = ide_read_status(drive); | ||
39 | |||
40 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
41 | if (hwif->dma_ops->dma_end(drive) || | ||
42 | (drive->media == ide_tape && !scsi && (stat & ERR_STAT))) { | ||
43 | if (drive->media == ide_floppy && !scsi) | ||
44 | printk(KERN_ERR "%s: DMA %s error\n", | ||
45 | drive->name, rq_data_dir(pc->rq) | ||
46 | ? "write" : "read"); | ||
47 | pc->flags |= PC_FLAG_DMA_ERROR; | ||
48 | } else { | ||
49 | pc->xferred = pc->req_xfer; | ||
50 | if (update_buffers) | ||
51 | update_buffers(drive, pc); | ||
52 | } | ||
53 | debug_log("%s: DMA finished\n", drive->name); | ||
54 | } | ||
55 | |||
56 | /* No more interrupts */ | ||
57 | if ((stat & DRQ_STAT) == 0) { | ||
58 | debug_log("Packet command completed, %d bytes transferred\n", | ||
59 | pc->xferred); | ||
60 | |||
61 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
62 | |||
63 | local_irq_enable_in_hardirq(); | ||
64 | |||
65 | if (drive->media == ide_tape && !scsi && | ||
66 | (stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) | ||
67 | stat &= ~ERR_STAT; | ||
68 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | ||
69 | /* Error detected */ | ||
70 | debug_log("%s: I/O error\n", drive->name); | ||
71 | |||
72 | if (drive->media != ide_tape || scsi) { | ||
73 | pc->rq->errors++; | ||
74 | if (scsi) | ||
75 | goto cmd_finished; | ||
76 | } | ||
77 | |||
78 | if (pc->c[0] == REQUEST_SENSE) { | ||
79 | printk(KERN_ERR "%s: I/O error in request sense" | ||
80 | " command\n", drive->name); | ||
81 | return ide_do_reset(drive); | ||
82 | } | ||
83 | |||
84 | debug_log("[cmd %x]: check condition\n", pc->c[0]); | ||
85 | |||
86 | /* Retry operation */ | ||
87 | retry_pc(drive); | ||
88 | /* queued, but not started */ | ||
89 | return ide_stopped; | ||
90 | } | ||
91 | cmd_finished: | ||
92 | pc->error = 0; | ||
93 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && | ||
94 | (stat & SEEK_STAT) == 0) { | ||
95 | dsc_handle(drive); | ||
96 | return ide_stopped; | ||
97 | } | ||
98 | /* Command finished - Call the callback function */ | ||
99 | pc->callback(drive); | ||
100 | return ide_stopped; | ||
101 | } | ||
102 | |||
103 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
104 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
105 | printk(KERN_ERR "%s: The device wants to issue more interrupts " | ||
106 | "in DMA mode\n", drive->name); | ||
107 | ide_dma_off(drive); | ||
108 | return ide_do_reset(drive); | ||
109 | } | ||
110 | /* Get the number of bytes to transfer on this interrupt. */ | ||
111 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
112 | hwif->INB(hwif->io_ports.lbam_addr); | ||
113 | |||
114 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
115 | |||
116 | if (ireason & CD) { | ||
117 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); | ||
118 | return ide_do_reset(drive); | ||
119 | } | ||
120 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | ||
121 | /* Hopefully, we will never get here */ | ||
122 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " | ||
123 | "to %s!\n", drive->name, | ||
124 | (ireason & IO) ? "Write" : "Read", | ||
125 | (ireason & IO) ? "Read" : "Write"); | ||
126 | return ide_do_reset(drive); | ||
127 | } | ||
128 | if (!(pc->flags & PC_FLAG_WRITING)) { | ||
129 | /* Reading - Check that we have enough space */ | ||
130 | temp = pc->xferred + bcount; | ||
131 | if (temp > pc->req_xfer) { | ||
132 | if (temp > pc->buf_size) { | ||
133 | printk(KERN_ERR "%s: The device wants to send " | ||
134 | "us more data than expected - " | ||
135 | "discarding data\n", | ||
136 | drive->name); | ||
137 | if (scsi) | ||
138 | temp = pc->buf_size - pc->xferred; | ||
139 | else | ||
140 | temp = 0; | ||
141 | if (temp) { | ||
142 | if (pc->sg) | ||
143 | io_buffers(drive, pc, temp, 0); | ||
144 | else | ||
145 | hwif->input_data(drive, NULL, | ||
146 | pc->cur_pos, temp); | ||
147 | printk(KERN_ERR "%s: transferred %d of " | ||
148 | "%d bytes\n", | ||
149 | drive->name, | ||
150 | temp, bcount); | ||
151 | } | ||
152 | pc->xferred += temp; | ||
153 | pc->cur_pos += temp; | ||
154 | ide_pad_transfer(drive, 0, bcount - temp); | ||
155 | ide_set_handler(drive, handler, timeout, | ||
156 | expiry); | ||
157 | return ide_started; | ||
158 | } | ||
159 | debug_log("The device wants to send us more data than " | ||
160 | "expected - allowing transfer\n"); | ||
161 | } | ||
162 | xferfunc = hwif->input_data; | ||
163 | } else | ||
164 | xferfunc = hwif->output_data; | ||
165 | |||
166 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || | ||
167 | (drive->media == ide_tape && !scsi && pc->bh) || | ||
168 | (scsi && pc->sg)) | ||
169 | io_buffers(drive, pc, bcount, !!(pc->flags & PC_FLAG_WRITING)); | ||
170 | else | ||
171 | xferfunc(drive, NULL, pc->cur_pos, bcount); | ||
172 | |||
173 | /* Update the current position */ | ||
174 | pc->xferred += bcount; | ||
175 | pc->cur_pos += bcount; | ||
176 | |||
177 | debug_log("[cmd %x] transferred %d bytes on that intr.\n", | ||
178 | pc->c[0], bcount); | ||
179 | |||
180 | /* And set the interrupt handler again */ | ||
181 | ide_set_handler(drive, handler, timeout, expiry); | ||
182 | return ide_started; | ||
183 | } | ||
184 | EXPORT_SYMBOL_GPL(ide_pc_intr); | ||
185 | |||
186 | static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) | ||
187 | { | ||
188 | ide_hwif_t *hwif = drive->hwif; | ||
189 | int retries = 100; | ||
190 | |||
191 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | ||
192 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | ||
193 | "a packet command, retrying\n", drive->name); | ||
194 | udelay(100); | ||
195 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
196 | if (retries == 0) { | ||
197 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | ||
198 | "a packet command, ignoring\n", | ||
199 | drive->name); | ||
200 | ireason |= CD; | ||
201 | ireason &= ~IO; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | return ireason; | ||
206 | } | ||
207 | |||
208 | ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
209 | ide_handler_t *handler, unsigned int timeout, | ||
210 | ide_expiry_t *expiry) | ||
211 | { | ||
212 | ide_hwif_t *hwif = drive->hwif; | ||
213 | ide_startstop_t startstop; | ||
214 | u8 ireason; | ||
215 | |||
216 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
217 | printk(KERN_ERR "%s: Strange, packet command initiated yet " | ||
218 | "DRQ isn't asserted\n", drive->name); | ||
219 | return startstop; | ||
220 | } | ||
221 | |||
222 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
223 | if (drive->media == ide_tape && !drive->scsi) | ||
224 | ireason = ide_wait_ireason(drive, ireason); | ||
225 | |||
226 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
227 | printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " | ||
228 | "a packet command\n", drive->name); | ||
229 | return ide_do_reset(drive); | ||
230 | } | ||
231 | |||
232 | /* Set the interrupt routine */ | ||
233 | ide_set_handler(drive, handler, timeout, expiry); | ||
234 | |||
235 | /* Begin DMA, if necessary */ | ||
236 | if (pc->flags & PC_FLAG_DMA_OK) { | ||
237 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
238 | hwif->dma_ops->dma_start(drive); | ||
239 | } | ||
240 | |||
241 | /* Send the actual packet */ | ||
242 | if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0) | ||
243 | hwif->output_data(drive, NULL, pc->c, 12); | ||
244 | |||
245 | return ide_started; | ||
246 | } | ||
247 | EXPORT_SYMBOL_GPL(ide_transfer_pc); | ||
248 | |||
249 | ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
250 | ide_handler_t *handler, unsigned int timeout, | ||
251 | ide_expiry_t *expiry) | ||
252 | { | ||
253 | ide_hwif_t *hwif = drive->hwif; | ||
254 | u16 bcount; | ||
255 | u8 dma = 0; | ||
256 | |||
257 | /* We haven't transferred any data yet */ | ||
258 | pc->xferred = 0; | ||
259 | pc->cur_pos = pc->buf; | ||
260 | |||
261 | /* Request to transfer the entire buffer at once */ | ||
262 | if (drive->media == ide_tape && !drive->scsi) | ||
263 | bcount = pc->req_xfer; | ||
264 | else | ||
265 | bcount = min(pc->req_xfer, 63 * 1024); | ||
266 | |||
267 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
268 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
269 | ide_dma_off(drive); | ||
270 | } | ||
271 | |||
272 | if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) { | ||
273 | if (drive->scsi) | ||
274 | hwif->sg_mapped = 1; | ||
275 | dma = !hwif->dma_ops->dma_setup(drive); | ||
276 | if (drive->scsi) | ||
277 | hwif->sg_mapped = 0; | ||
278 | } | ||
279 | |||
280 | if (!dma) | ||
281 | pc->flags &= ~PC_FLAG_DMA_OK; | ||
282 | |||
283 | ide_pktcmd_tf_load(drive, drive->scsi ? 0 : IDE_TFLAG_OUT_DEVICE, | ||
284 | bcount, dma); | ||
285 | |||
286 | /* Issue the packet command */ | ||
287 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | ||
288 | ide_execute_command(drive, WIN_PACKETCMD, handler, | ||
289 | timeout, NULL); | ||
290 | return ide_started; | ||
291 | } else { | ||
292 | ide_execute_pkt_cmd(drive); | ||
293 | return (*handler)(drive); | ||
294 | } | ||
295 | } | ||
296 | EXPORT_SYMBOL_GPL(ide_issue_pc); | ||
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 68e7f19dc036..6e29dd532090 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -188,16 +188,6 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
188 | ide_cd_log_error(drive->name, failed_command, sense); | 188 | ide_cd_log_error(drive->name, failed_command, sense); |
189 | } | 189 | } |
190 | 190 | ||
191 | /* Initialize a ide-cd packet command request */ | ||
192 | void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) | ||
193 | { | ||
194 | struct cdrom_info *cd = drive->driver_data; | ||
195 | |||
196 | ide_init_drive_cmd(rq); | ||
197 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
198 | rq->rq_disk = cd->disk; | ||
199 | } | ||
200 | |||
201 | static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | 191 | static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, |
202 | struct request *failed_command) | 192 | struct request *failed_command) |
203 | { | 193 | { |
@@ -208,7 +198,9 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
208 | sense = &info->sense_data; | 198 | sense = &info->sense_data; |
209 | 199 | ||
210 | /* stuff the sense request in front of our current request */ | 200 | /* stuff the sense request in front of our current request */ |
211 | ide_cd_init_rq(drive, rq); | 201 | blk_rq_init(NULL, rq); |
202 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
203 | rq->rq_disk = info->disk; | ||
212 | 204 | ||
213 | rq->data = sense; | 205 | rq->data = sense; |
214 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | 206 | rq->cmd[0] = GPCMD_REQUEST_SENSE; |
@@ -216,11 +208,12 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
216 | rq->data_len = 18; | 208 | rq->data_len = 18; |
217 | 209 | ||
218 | rq->cmd_type = REQ_TYPE_SENSE; | 210 | rq->cmd_type = REQ_TYPE_SENSE; |
211 | rq->cmd_flags |= REQ_PREEMPT; | ||
219 | 212 | ||
220 | /* NOTE! Save the failed command in "rq->buffer" */ | 213 | /* NOTE! Save the failed command in "rq->buffer" */ |
221 | rq->buffer = (void *) failed_command; | 214 | rq->buffer = (void *) failed_command; |
222 | 215 | ||
223 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 216 | ide_do_drive_cmd(drive, rq); |
224 | } | 217 | } |
225 | 218 | ||
226 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) | 219 | static void cdrom_end_request(ide_drive_t *drive, int uptodate) |
@@ -524,21 +517,16 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
524 | int xferlen, | 517 | int xferlen, |
525 | ide_handler_t *handler) | 518 | ide_handler_t *handler) |
526 | { | 519 | { |
527 | ide_startstop_t startstop; | ||
528 | struct cdrom_info *info = drive->driver_data; | 520 | struct cdrom_info *info = drive->driver_data; |
529 | ide_hwif_t *hwif = drive->hwif; | 521 | ide_hwif_t *hwif = drive->hwif; |
530 | 522 | ||
531 | /* wait for the controller to be idle */ | ||
532 | if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) | ||
533 | return startstop; | ||
534 | |||
535 | /* FIXME: for Virtual DMA we must check harder */ | 523 | /* FIXME: for Virtual DMA we must check harder */ |
536 | if (info->dma) | 524 | if (info->dma) |
537 | info->dma = !hwif->dma_ops->dma_setup(drive); | 525 | info->dma = !hwif->dma_ops->dma_setup(drive); |
538 | 526 | ||
539 | /* set up the controller registers */ | 527 | /* set up the controller registers */ |
540 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | | 528 | ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL, |
541 | IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); | 529 | xferlen, info->dma); |
542 | 530 | ||
543 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { | 531 | if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { |
544 | /* waiting for CDB interrupt, not DMA yet. */ | 532 | /* waiting for CDB interrupt, not DMA yet. */ |
@@ -611,28 +599,6 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
611 | } | 599 | } |
612 | 600 | ||
613 | /* | 601 | /* |
614 | * Block read functions. | ||
615 | */ | ||
616 | static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) | ||
617 | { | ||
618 | while (len > 0) { | ||
619 | int dum = 0; | ||
620 | xf(drive, NULL, &dum, sizeof(dum)); | ||
621 | len -= sizeof(dum); | ||
622 | } | ||
623 | } | ||
624 | |||
625 | static void ide_cd_drain_data(ide_drive_t *drive, int nsects) | ||
626 | { | ||
627 | while (nsects > 0) { | ||
628 | static char dum[SECTOR_SIZE]; | ||
629 | |||
630 | drive->hwif->input_data(drive, NULL, dum, sizeof(dum)); | ||
631 | nsects--; | ||
632 | } | ||
633 | } | ||
634 | |||
635 | /* | ||
636 | * Check the contents of the interrupt reason register from the cdrom | 602 | * Check the contents of the interrupt reason register from the cdrom |
637 | * 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 |
638 | * ok; nonzero if the request has been terminated. | 604 | * ok; nonzero if the request has been terminated. |
@@ -647,15 +613,12 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | |||
647 | if (ireason == (!rw << 1)) | 613 | if (ireason == (!rw << 1)) |
648 | return 0; | 614 | return 0; |
649 | else if (ireason == (rw << 1)) { | 615 | else if (ireason == (rw << 1)) { |
650 | ide_hwif_t *hwif = drive->hwif; | ||
651 | xfer_func_t *xf; | ||
652 | 616 | ||
653 | /* whoops... */ | 617 | /* whoops... */ |
654 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", | 618 | printk(KERN_ERR "%s: %s: wrong transfer direction!\n", |
655 | drive->name, __func__); | 619 | drive->name, __func__); |
656 | 620 | ||
657 | xf = rw ? hwif->output_data : hwif->input_data; | 621 | ide_pad_transfer(drive, rw, len); |
658 | ide_cd_pad_transfer(drive, xf, len); | ||
659 | } else if (rw == 0 && ireason == 1) { | 622 | } else if (rw == 0 && ireason == 1) { |
660 | /* | 623 | /* |
661 | * Some drives (ASUS) seem to tell us that status info is | 624 | * Some drives (ASUS) seem to tell us that status info is |
@@ -703,16 +666,9 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) | |||
703 | 666 | ||
704 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); | 667 | static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); |
705 | 668 | ||
706 | /* | 669 | static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, |
707 | * Routine to send a read/write packet command to the drive. This is usually | 670 | struct request *rq) |
708 | * called directly from cdrom_start_{read,write}(). However, for drq_interrupt | ||
709 | * devices, it is called from an interrupt when the drive is ready to accept | ||
710 | * the command. | ||
711 | */ | ||
712 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | ||
713 | { | 671 | { |
714 | struct request *rq = HWGROUP(drive)->rq; | ||
715 | |||
716 | if (rq_data_dir(rq) == READ) { | 672 | if (rq_data_dir(rq) == READ) { |
717 | unsigned short sectors_per_frame = | 673 | unsigned short sectors_per_frame = |
718 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; | 674 | queue_hardsect_size(drive->queue) >> SECTOR_BITS; |
@@ -749,6 +705,19 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | |||
749 | /* set up the command */ | 705 | /* set up the command */ |
750 | rq->timeout = ATAPI_WAIT_PC; | 706 | rq->timeout = ATAPI_WAIT_PC; |
751 | 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 | */ | ||
717 | static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) | ||
718 | { | ||
719 | struct request *rq = drive->hwif->hwgroup->rq; | ||
720 | |||
752 | /* send the command to the drive and return */ | 721 | /* send the command to the drive and return */ |
753 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); | 722 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); |
754 | } | 723 | } |
@@ -775,9 +744,8 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive) | |||
775 | return ide_stopped; | 744 | return ide_stopped; |
776 | } | 745 | } |
777 | 746 | ||
778 | static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive) | 747 | static void ide_cd_prepare_seek_request(ide_drive_t *drive, struct request *rq) |
779 | { | 748 | { |
780 | struct request *rq = HWGROUP(drive)->rq; | ||
781 | sector_t frame = rq->sector; | 749 | sector_t frame = rq->sector; |
782 | 750 | ||
783 | sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS); | 751 | sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS); |
@@ -787,17 +755,13 @@ static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive) | |||
787 | put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]); | 755 | put_unaligned(cpu_to_be32(frame), (unsigned int *) &rq->cmd[2]); |
788 | 756 | ||
789 | rq->timeout = ATAPI_WAIT_PC; | 757 | rq->timeout = ATAPI_WAIT_PC; |
790 | return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr); | ||
791 | } | 758 | } |
792 | 759 | ||
793 | static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) | 760 | static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive) |
794 | { | 761 | { |
795 | struct cdrom_info *info = drive->driver_data; | 762 | struct request *rq = drive->hwif->hwgroup->rq; |
796 | 763 | ||
797 | info->dma = 0; | 764 | return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr); |
798 | info->start_seek = jiffies; | ||
799 | return cdrom_start_packet_command(drive, 0, | ||
800 | cdrom_start_seek_continuation); | ||
801 | } | 765 | } |
802 | 766 | ||
803 | /* | 767 | /* |
@@ -838,34 +802,54 @@ static void ide_cd_request_sense_fixup(struct request *rq) | |||
838 | } | 802 | } |
839 | } | 803 | } |
840 | 804 | ||
841 | int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | 805 | int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd, |
806 | int write, void *buffer, unsigned *bufflen, | ||
807 | struct request_sense *sense, int timeout, | ||
808 | unsigned int cmd_flags) | ||
842 | { | 809 | { |
843 | struct request_sense sense; | 810 | struct cdrom_info *info = drive->driver_data; |
811 | struct request_sense local_sense; | ||
844 | int retries = 10; | 812 | int retries = 10; |
845 | unsigned int flags = rq->cmd_flags; | 813 | unsigned int flags = 0; |
846 | 814 | ||
847 | if (rq->sense == NULL) | 815 | if (!sense) |
848 | rq->sense = &sense; | 816 | sense = &local_sense; |
849 | 817 | ||
850 | /* start of retry loop */ | 818 | /* start of retry loop */ |
851 | do { | 819 | do { |
820 | struct request *rq; | ||
852 | int error; | 821 | int error; |
853 | unsigned long time = jiffies; | ||
854 | rq->cmd_flags = flags; | ||
855 | 822 | ||
856 | error = ide_do_drive_cmd(drive, rq, ide_wait); | 823 | rq = blk_get_request(drive->queue, write, __GFP_WAIT); |
857 | time = jiffies - time; | 824 | |
825 | memcpy(rq->cmd, cmd, BLK_MAX_CDB); | ||
826 | rq->cmd_type = REQ_TYPE_ATA_PC; | ||
827 | rq->sense = sense; | ||
828 | rq->cmd_flags |= cmd_flags; | ||
829 | rq->timeout = timeout; | ||
830 | if (buffer) { | ||
831 | rq->data = buffer; | ||
832 | rq->data_len = *bufflen; | ||
833 | } | ||
834 | |||
835 | error = blk_execute_rq(drive->queue, info->disk, rq, 0); | ||
836 | |||
837 | if (buffer) | ||
838 | *bufflen = rq->data_len; | ||
839 | |||
840 | flags = rq->cmd_flags; | ||
841 | blk_put_request(rq); | ||
858 | 842 | ||
859 | /* | 843 | /* |
860 | * FIXME: we should probably abort/retry or something in case of | 844 | * FIXME: we should probably abort/retry or something in case of |
861 | * failure. | 845 | * failure. |
862 | */ | 846 | */ |
863 | if (rq->cmd_flags & REQ_FAILED) { | 847 | if (flags & REQ_FAILED) { |
864 | /* | 848 | /* |
865 | * The request failed. Retry if it was due to a unit | 849 | * The request failed. Retry if it was due to a unit |
866 | * attention status (usually means media was changed). | 850 | * attention status (usually means media was changed). |
867 | */ | 851 | */ |
868 | struct request_sense *reqbuf = rq->sense; | 852 | struct request_sense *reqbuf = sense; |
869 | 853 | ||
870 | if (reqbuf->sense_key == UNIT_ATTENTION) | 854 | if (reqbuf->sense_key == UNIT_ATTENTION) |
871 | cdrom_saw_media_change(drive); | 855 | cdrom_saw_media_change(drive); |
@@ -885,10 +869,10 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) | |||
885 | } | 869 | } |
886 | 870 | ||
887 | /* end of retry loop */ | 871 | /* end of retry loop */ |
888 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); | 872 | } while ((flags & REQ_FAILED) && retries >= 0); |
889 | 873 | ||
890 | /* return an error if the command failed */ | 874 | /* return an error if the command failed */ |
891 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; | 875 | return (flags & REQ_FAILED) ? -EIO : 0; |
892 | } | 876 | } |
893 | 877 | ||
894 | /* | 878 | /* |
@@ -998,7 +982,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
998 | - bio_cur_sectors(rq->bio), | 982 | - bio_cur_sectors(rq->bio), |
999 | thislen >> 9); | 983 | thislen >> 9); |
1000 | if (nskip > 0) { | 984 | if (nskip > 0) { |
1001 | ide_cd_drain_data(drive, nskip); | 985 | ide_pad_transfer(drive, write, nskip << 9); |
1002 | rq->current_nr_sectors -= nskip; | 986 | rq->current_nr_sectors -= nskip; |
1003 | thislen -= (nskip << 9); | 987 | thislen -= (nskip << 9); |
1004 | } | 988 | } |
@@ -1035,7 +1019,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1035 | * If the buffers are full, pipe the rest into | 1019 | * If the buffers are full, pipe the rest into |
1036 | * oblivion. | 1020 | * oblivion. |
1037 | */ | 1021 | */ |
1038 | ide_cd_drain_data(drive, thislen >> 9); | 1022 | ide_pad_transfer(drive, 0, thislen); |
1039 | else { | 1023 | else { |
1040 | printk(KERN_ERR "%s: confused, missing data\n", | 1024 | printk(KERN_ERR "%s: confused, missing data\n", |
1041 | drive->name); | 1025 | drive->name); |
@@ -1083,7 +1067,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
1083 | 1067 | ||
1084 | /* pad, if necessary */ | 1068 | /* pad, if necessary */ |
1085 | if (!blk_fs_request(rq) && len > 0) | 1069 | if (!blk_fs_request(rq) && len > 0) |
1086 | ide_cd_pad_transfer(drive, xferfunc, len); | 1070 | ide_pad_transfer(drive, write, len); |
1087 | 1071 | ||
1088 | if (blk_pc_request(rq)) { | 1072 | if (blk_pc_request(rq)) { |
1089 | timeout = rq->timeout; | 1073 | timeout = rq->timeout; |
@@ -1152,21 +1136,17 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1152 | if (write) | 1136 | if (write) |
1153 | cd->devinfo.media_written = 1; | 1137 | cd->devinfo.media_written = 1; |
1154 | 1138 | ||
1155 | /* start sending the read/write request to the drive */ | 1139 | return ide_started; |
1156 | return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); | ||
1157 | } | 1140 | } |
1158 | 1141 | ||
1159 | static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) | 1142 | static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive) |
1160 | { | 1143 | { |
1161 | struct request *rq = HWGROUP(drive)->rq; | 1144 | struct request *rq = HWGROUP(drive)->rq; |
1162 | 1145 | ||
1163 | if (!rq->timeout) | ||
1164 | rq->timeout = ATAPI_WAIT_PC; | ||
1165 | |||
1166 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); | 1146 | return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); |
1167 | } | 1147 | } |
1168 | 1148 | ||
1169 | static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | 1149 | static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) |
1170 | { | 1150 | { |
1171 | struct cdrom_info *info = drive->driver_data; | 1151 | struct cdrom_info *info = drive->driver_data; |
1172 | 1152 | ||
@@ -1178,10 +1158,16 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1178 | info->dma = 0; | 1158 | info->dma = 0; |
1179 | 1159 | ||
1180 | /* sg request */ | 1160 | /* sg request */ |
1181 | if (rq->bio) { | 1161 | if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) { |
1182 | int mask = drive->queue->dma_alignment; | 1162 | struct request_queue *q = drive->queue; |
1183 | unsigned long addr = | 1163 | unsigned int alignment; |
1184 | (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; | ||
1185 | 1171 | ||
1186 | info->dma = drive->using_dma; | 1172 | info->dma = drive->using_dma; |
1187 | 1173 | ||
@@ -1191,23 +1177,25 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1191 | * NOTE! The "len" and "addr" checks should possibly have | 1177 | * NOTE! The "len" and "addr" checks should possibly have |
1192 | * separate masks. | 1178 | * separate masks. |
1193 | */ | 1179 | */ |
1194 | 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) | ||
1195 | info->dma = 0; | 1182 | info->dma = 0; |
1196 | } | ||
1197 | 1183 | ||
1198 | /* start sending the command to the drive */ | 1184 | if (!((addr & stack_mask) ^ |
1199 | return cdrom_start_packet_command(drive, rq->data_len, | 1185 | ((unsigned long)current->stack & stack_mask))) |
1200 | cdrom_do_newpc_cont); | 1186 | info->dma = 0; |
1187 | } | ||
1201 | } | 1188 | } |
1202 | 1189 | ||
1203 | /* | 1190 | /* |
1204 | * cdrom driver request routine. | 1191 | * cdrom driver request routine. |
1205 | */ | 1192 | */ |
1206 | static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, | 1193 | static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, |
1207 | sector_t block) | 1194 | sector_t block) |
1208 | { | 1195 | { |
1209 | ide_startstop_t action; | ||
1210 | struct cdrom_info *info = drive->driver_data; | 1196 | struct cdrom_info *info = drive->driver_data; |
1197 | ide_handler_t *fn; | ||
1198 | int xferlen; | ||
1211 | 1199 | ||
1212 | if (blk_fs_request(rq)) { | 1200 | if (blk_fs_request(rq)) { |
1213 | if (info->cd_flags & IDE_CD_FLAG_SEEKING) { | 1201 | if (info->cd_flags & IDE_CD_FLAG_SEEKING) { |
@@ -1227,29 +1215,48 @@ static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, | |||
1227 | } | 1215 | } |
1228 | if (rq_data_dir(rq) == READ && | 1216 | if (rq_data_dir(rq) == READ && |
1229 | IDE_LARGE_SEEK(info->last_block, block, | 1217 | IDE_LARGE_SEEK(info->last_block, block, |
1230 | IDECD_SEEK_THRESHOLD) && | 1218 | IDECD_SEEK_THRESHOLD) && |
1231 | drive->dsc_overlap) | 1219 | drive->dsc_overlap) { |
1232 | action = cdrom_start_seek(drive, block); | 1220 | xferlen = 0; |
1233 | else | 1221 | fn = cdrom_start_seek_continuation; |
1234 | 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 | } | ||
1235 | info->last_block = block; | 1237 | info->last_block = block; |
1236 | return action; | ||
1237 | } else if (blk_sense_request(rq) || blk_pc_request(rq) || | 1238 | } else if (blk_sense_request(rq) || blk_pc_request(rq) || |
1238 | rq->cmd_type == REQ_TYPE_ATA_PC) { | 1239 | rq->cmd_type == REQ_TYPE_ATA_PC) { |
1239 | 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); | ||
1240 | } else if (blk_special_request(rq)) { | 1247 | } else if (blk_special_request(rq)) { |
1241 | /* right now this can only be a reset... */ | 1248 | /* right now this can only be a reset... */ |
1242 | cdrom_end_request(drive, 1); | 1249 | cdrom_end_request(drive, 1); |
1243 | 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; | ||
1244 | } | 1255 | } |
1245 | 1256 | ||
1246 | blk_dump_rq_flags(rq, "ide-cd bad flags"); | 1257 | return cdrom_start_packet_command(drive, xferlen, fn); |
1247 | cdrom_end_request(drive, 0); | ||
1248 | return ide_stopped; | ||
1249 | } | 1258 | } |
1250 | 1259 | ||
1251 | |||
1252 | |||
1253 | /* | 1260 | /* |
1254 | * Ioctl handling. | 1261 | * Ioctl handling. |
1255 | * | 1262 | * |
@@ -1268,23 +1275,20 @@ static void msf_from_bcd(struct atapi_msf *msf) | |||
1268 | 1275 | ||
1269 | int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | 1276 | int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) |
1270 | { | 1277 | { |
1271 | struct request req; | ||
1272 | struct cdrom_info *info = drive->driver_data; | 1278 | struct cdrom_info *info = drive->driver_data; |
1273 | struct cdrom_device_info *cdi = &info->devinfo; | 1279 | struct cdrom_device_info *cdi = &info->devinfo; |
1280 | unsigned char cmd[BLK_MAX_CDB]; | ||
1274 | 1281 | ||
1275 | ide_cd_init_rq(drive, &req); | 1282 | memset(cmd, 0, BLK_MAX_CDB); |
1276 | 1283 | cmd[0] = GPCMD_TEST_UNIT_READY; | |
1277 | req.sense = sense; | ||
1278 | req.cmd[0] = GPCMD_TEST_UNIT_READY; | ||
1279 | req.cmd_flags |= REQ_QUIET; | ||
1280 | 1284 | ||
1281 | /* | 1285 | /* |
1282 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs | 1286 | * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs |
1283 | * instead of supporting the LOAD_UNLOAD opcode. | 1287 | * instead of supporting the LOAD_UNLOAD opcode. |
1284 | */ | 1288 | */ |
1285 | req.cmd[7] = cdi->sanyo_slot % 3; | 1289 | cmd[7] = cdi->sanyo_slot % 3; |
1286 | 1290 | ||
1287 | return ide_cd_queue_pc(drive, &req); | 1291 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, REQ_QUIET); |
1288 | } | 1292 | } |
1289 | 1293 | ||
1290 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | 1294 | static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, |
@@ -1297,17 +1301,14 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
1297 | } capbuf; | 1301 | } capbuf; |
1298 | 1302 | ||
1299 | int stat; | 1303 | int stat; |
1300 | struct request req; | 1304 | unsigned char cmd[BLK_MAX_CDB]; |
1301 | 1305 | unsigned len = sizeof(capbuf); | |
1302 | ide_cd_init_rq(drive, &req); | ||
1303 | 1306 | ||
1304 | req.sense = sense; | 1307 | memset(cmd, 0, BLK_MAX_CDB); |
1305 | req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; | 1308 | cmd[0] = GPCMD_READ_CDVD_CAPACITY; |
1306 | req.data = (char *)&capbuf; | ||
1307 | req.data_len = sizeof(capbuf); | ||
1308 | req.cmd_flags |= REQ_QUIET; | ||
1309 | 1309 | ||
1310 | stat = ide_cd_queue_pc(drive, &req); | 1310 | stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0, |
1311 | REQ_QUIET); | ||
1311 | if (stat == 0) { | 1312 | if (stat == 0) { |
1312 | *capacity = 1 + be32_to_cpu(capbuf.lba); | 1313 | *capacity = 1 + be32_to_cpu(capbuf.lba); |
1313 | *sectors_per_frame = | 1314 | *sectors_per_frame = |
@@ -1321,24 +1322,20 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, | |||
1321 | int format, char *buf, int buflen, | 1322 | int format, char *buf, int buflen, |
1322 | struct request_sense *sense) | 1323 | struct request_sense *sense) |
1323 | { | 1324 | { |
1324 | struct request req; | 1325 | unsigned char cmd[BLK_MAX_CDB]; |
1325 | 1326 | ||
1326 | ide_cd_init_rq(drive, &req); | 1327 | memset(cmd, 0, BLK_MAX_CDB); |
1327 | 1328 | ||
1328 | req.sense = sense; | 1329 | cmd[0] = GPCMD_READ_TOC_PMA_ATIP; |
1329 | req.data = buf; | 1330 | cmd[6] = trackno; |
1330 | req.data_len = buflen; | 1331 | cmd[7] = (buflen >> 8); |
1331 | req.cmd_flags |= REQ_QUIET; | 1332 | cmd[8] = (buflen & 0xff); |
1332 | req.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; | 1333 | cmd[9] = (format << 6); |
1333 | req.cmd[6] = trackno; | ||
1334 | req.cmd[7] = (buflen >> 8); | ||
1335 | req.cmd[8] = (buflen & 0xff); | ||
1336 | req.cmd[9] = (format << 6); | ||
1337 | 1334 | ||
1338 | if (msf_flag) | 1335 | if (msf_flag) |
1339 | req.cmd[1] = 2; | 1336 | cmd[1] = 2; |
1340 | 1337 | ||
1341 | return ide_cd_queue_pc(drive, &req); | 1338 | return ide_cd_queue_pc(drive, cmd, 0, buf, &buflen, sense, 0, REQ_QUIET); |
1342 | } | 1339 | } |
1343 | 1340 | ||
1344 | /* Try to read the entire TOC for the disk into our internal buffer. */ | 1341 | /* Try to read the entire TOC for the disk into our internal buffer. */ |
@@ -1869,6 +1866,7 @@ static int ide_cdrom_setup(ide_drive_t *drive) | |||
1869 | 1866 | ||
1870 | blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); | 1867 | blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); |
1871 | blk_queue_dma_alignment(drive->queue, 31); | 1868 | blk_queue_dma_alignment(drive->queue, 31); |
1869 | blk_queue_update_dma_pad(drive->queue, 15); | ||
1872 | drive->queue->unplug_delay = (1 * HZ) / 1000; | 1870 | drive->queue->unplug_delay = (1 * HZ) / 1000; |
1873 | if (!drive->queue->unplug_delay) | 1871 | if (!drive->queue->unplug_delay) |
1874 | drive->queue->unplug_delay = 1; | 1872 | drive->queue->unplug_delay = 1; |
@@ -1951,10 +1949,9 @@ static ide_driver_t ide_cdrom_driver = { | |||
1951 | .version = IDECD_VERSION, | 1949 | .version = IDECD_VERSION, |
1952 | .media = ide_cdrom, | 1950 | .media = ide_cdrom, |
1953 | .supports_dsc_overlap = 1, | 1951 | .supports_dsc_overlap = 1, |
1954 | .do_request = ide_do_rw_cdrom, | 1952 | .do_request = ide_cd_do_request, |
1955 | .end_request = ide_end_request, | 1953 | .end_request = ide_end_request, |
1956 | .error = __ide_error, | 1954 | .error = __ide_error, |
1957 | .abort = __ide_abort, | ||
1958 | #ifdef CONFIG_IDE_PROC_FS | 1955 | #ifdef CONFIG_IDE_PROC_FS |
1959 | .proc = idecd_proc, | 1956 | .proc = idecd_proc, |
1960 | #endif | 1957 | #endif |
@@ -2103,11 +2100,6 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2103 | goto failed; | 2100 | goto failed; |
2104 | } | 2101 | } |
2105 | } | 2102 | } |
2106 | if (drive->scsi) { | ||
2107 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " | ||
2108 | "emulation.\n", drive->name); | ||
2109 | goto failed; | ||
2110 | } | ||
2111 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); | 2103 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); |
2112 | if (info == NULL) { | 2104 | if (info == NULL) { |
2113 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", | 2105 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", |
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h index a58801c4484d..fe0ea36e4124 100644 --- a/drivers/ide/ide-cd.h +++ b/drivers/ide/ide-cd.h | |||
@@ -143,8 +143,8 @@ struct cdrom_info { | |||
143 | void ide_cd_log_error(const char *, struct request *, struct request_sense *); | 143 | void ide_cd_log_error(const char *, struct request *, struct request_sense *); |
144 | 144 | ||
145 | /* ide-cd.c functions used by ide-cd_ioctl.c */ | 145 | /* ide-cd.c functions used by ide-cd_ioctl.c */ |
146 | void ide_cd_init_rq(ide_drive_t *, struct request *); | 146 | int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *, |
147 | int ide_cd_queue_pc(ide_drive_t *, struct request *); | 147 | unsigned *, struct request_sense *, int, unsigned int); |
148 | int ide_cd_read_toc(ide_drive_t *, struct request_sense *); | 148 | int ide_cd_read_toc(ide_drive_t *, struct request_sense *); |
149 | int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); | 149 | int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); |
150 | void ide_cdrom_update_speed(ide_drive_t *, u8 *); | 150 | void ide_cdrom_update_speed(ide_drive_t *, u8 *); |
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c index 6d147ce6782f..24d002addf73 100644 --- a/drivers/ide/ide-cd_ioctl.c +++ b/drivers/ide/ide-cd_ioctl.c | |||
@@ -104,8 +104,8 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
104 | { | 104 | { |
105 | struct cdrom_info *cd = drive->driver_data; | 105 | struct cdrom_info *cd = drive->driver_data; |
106 | struct cdrom_device_info *cdi = &cd->devinfo; | 106 | struct cdrom_device_info *cdi = &cd->devinfo; |
107 | struct request req; | ||
108 | char loej = 0x02; | 107 | char loej = 0x02; |
108 | unsigned char cmd[BLK_MAX_CDB]; | ||
109 | 109 | ||
110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) | 110 | if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) |
111 | return -EDRIVE_CANT_DO_THIS; | 111 | return -EDRIVE_CANT_DO_THIS; |
@@ -114,17 +114,16 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag, | |||
114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) | 114 | if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) |
115 | return 0; | 115 | return 0; |
116 | 116 | ||
117 | ide_cd_init_rq(drive, &req); | ||
118 | |||
119 | /* only tell drive to close tray if open, if it can do that */ | 117 | /* only tell drive to close tray if open, if it can do that */ |
120 | if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) | 118 | if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) |
121 | loej = 0; | 119 | loej = 0; |
122 | 120 | ||
123 | req.sense = sense; | 121 | memset(cmd, 0, BLK_MAX_CDB); |
124 | req.cmd[0] = GPCMD_START_STOP_UNIT; | 122 | |
125 | req.cmd[4] = loej | (ejectflag != 0); | 123 | cmd[0] = GPCMD_START_STOP_UNIT; |
124 | cmd[4] = loej | (ejectflag != 0); | ||
126 | 125 | ||
127 | return ide_cd_queue_pc(drive, &req); | 126 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, 0); |
128 | } | 127 | } |
129 | 128 | ||
130 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ | 129 | /* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ |
@@ -134,7 +133,6 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
134 | { | 133 | { |
135 | struct cdrom_info *cd = drive->driver_data; | 134 | struct cdrom_info *cd = drive->driver_data; |
136 | struct request_sense my_sense; | 135 | struct request_sense my_sense; |
137 | struct request req; | ||
138 | int stat; | 136 | int stat; |
139 | 137 | ||
140 | if (sense == NULL) | 138 | if (sense == NULL) |
@@ -144,11 +142,15 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag, | |||
144 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { | 142 | if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { |
145 | stat = 0; | 143 | stat = 0; |
146 | } else { | 144 | } else { |
147 | ide_cd_init_rq(drive, &req); | 145 | unsigned char cmd[BLK_MAX_CDB]; |
148 | req.sense = sense; | 146 | |
149 | req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; | 147 | memset(cmd, 0, BLK_MAX_CDB); |
150 | req.cmd[4] = lockflag ? 1 : 0; | 148 | |
151 | stat = ide_cd_queue_pc(drive, &req); | 149 | cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; |
150 | cmd[4] = lockflag ? 1 : 0; | ||
151 | |||
152 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, | ||
153 | sense, 0, 0); | ||
152 | } | 154 | } |
153 | 155 | ||
154 | /* If we got an illegal field error, the drive | 156 | /* If we got an illegal field error, the drive |
@@ -206,32 +208,30 @@ int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed) | |||
206 | { | 208 | { |
207 | ide_drive_t *drive = cdi->handle; | 209 | ide_drive_t *drive = cdi->handle; |
208 | struct cdrom_info *cd = drive->driver_data; | 210 | struct cdrom_info *cd = drive->driver_data; |
209 | struct request rq; | ||
210 | struct request_sense sense; | 211 | struct request_sense sense; |
211 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; | 212 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; |
212 | int stat; | 213 | int stat; |
213 | 214 | unsigned char cmd[BLK_MAX_CDB]; | |
214 | ide_cd_init_rq(drive, &rq); | ||
215 | |||
216 | rq.sense = &sense; | ||
217 | 215 | ||
218 | if (speed == 0) | 216 | if (speed == 0) |
219 | speed = 0xffff; /* set to max */ | 217 | speed = 0xffff; /* set to max */ |
220 | else | 218 | else |
221 | speed *= 177; /* Nx to kbytes/s */ | 219 | speed *= 177; /* Nx to kbytes/s */ |
222 | 220 | ||
223 | rq.cmd[0] = GPCMD_SET_SPEED; | 221 | memset(cmd, 0, BLK_MAX_CDB); |
222 | |||
223 | cmd[0] = GPCMD_SET_SPEED; | ||
224 | /* Read Drive speed in kbytes/second MSB/LSB */ | 224 | /* Read Drive speed in kbytes/second MSB/LSB */ |
225 | rq.cmd[2] = (speed >> 8) & 0xff; | 225 | cmd[2] = (speed >> 8) & 0xff; |
226 | rq.cmd[3] = speed & 0xff; | 226 | cmd[3] = speed & 0xff; |
227 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != | 227 | if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != |
228 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { | 228 | (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { |
229 | /* Write Drive speed in kbytes/second MSB/LSB */ | 229 | /* Write Drive speed in kbytes/second MSB/LSB */ |
230 | rq.cmd[4] = (speed >> 8) & 0xff; | 230 | cmd[4] = (speed >> 8) & 0xff; |
231 | rq.cmd[5] = speed & 0xff; | 231 | cmd[5] = speed & 0xff; |
232 | } | 232 | } |
233 | 233 | ||
234 | stat = ide_cd_queue_pc(drive, &rq); | 234 | stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); |
235 | 235 | ||
236 | if (!ide_cdrom_get_capabilities(drive, buf)) { | 236 | if (!ide_cdrom_get_capabilities(drive, buf)) { |
237 | ide_cdrom_update_speed(drive, buf); | 237 | ide_cdrom_update_speed(drive, buf); |
@@ -268,21 +268,19 @@ int ide_cdrom_get_mcn(struct cdrom_device_info *cdi, | |||
268 | { | 268 | { |
269 | ide_drive_t *drive = cdi->handle; | 269 | ide_drive_t *drive = cdi->handle; |
270 | int stat, mcnlen; | 270 | int stat, mcnlen; |
271 | struct request rq; | ||
272 | char buf[24]; | 271 | char buf[24]; |
272 | unsigned char cmd[BLK_MAX_CDB]; | ||
273 | unsigned len = sizeof(buf); | ||
273 | 274 | ||
274 | ide_cd_init_rq(drive, &rq); | 275 | memset(cmd, 0, BLK_MAX_CDB); |
275 | 276 | ||
276 | rq.data = buf; | 277 | cmd[0] = GPCMD_READ_SUBCHANNEL; |
277 | rq.data_len = sizeof(buf); | 278 | cmd[1] = 2; /* MSF addressing */ |
279 | cmd[2] = 0x40; /* request subQ data */ | ||
280 | cmd[3] = 2; /* format */ | ||
281 | cmd[8] = len; | ||
278 | 282 | ||
279 | rq.cmd[0] = GPCMD_READ_SUBCHANNEL; | 283 | stat = ide_cd_queue_pc(drive, cmd, 0, buf, &len, NULL, 0, 0); |
280 | rq.cmd[1] = 2; /* MSF addressing */ | ||
281 | rq.cmd[2] = 0x40; /* request subQ data */ | ||
282 | rq.cmd[3] = 2; /* format */ | ||
283 | rq.cmd[8] = sizeof(buf); | ||
284 | |||
285 | stat = ide_cd_queue_pc(drive, &rq); | ||
286 | if (stat) | 284 | if (stat) |
287 | return stat; | 285 | return stat; |
288 | 286 | ||
@@ -298,14 +296,14 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi) | |||
298 | ide_drive_t *drive = cdi->handle; | 296 | ide_drive_t *drive = cdi->handle; |
299 | struct cdrom_info *cd = drive->driver_data; | 297 | struct cdrom_info *cd = drive->driver_data; |
300 | struct request_sense sense; | 298 | struct request_sense sense; |
301 | struct request req; | 299 | struct request *rq; |
302 | int ret; | 300 | int ret; |
303 | 301 | ||
304 | ide_cd_init_rq(drive, &req); | 302 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
305 | req.cmd_type = REQ_TYPE_SPECIAL; | 303 | rq->cmd_type = REQ_TYPE_SPECIAL; |
306 | req.cmd_flags = REQ_QUIET; | 304 | rq->cmd_flags = REQ_QUIET; |
307 | ret = ide_do_drive_cmd(drive, &req, ide_wait); | 305 | ret = blk_execute_rq(drive->queue, cd->disk, rq, 0); |
308 | 306 | blk_put_request(rq); | |
309 | /* | 307 | /* |
310 | * A reset will unlock the door. If it was previously locked, | 308 | * A reset will unlock the door. If it was previously locked, |
311 | * lock it again. | 309 | * lock it again. |
@@ -351,8 +349,8 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | |||
351 | struct atapi_toc_entry *first_toc, *last_toc; | 349 | struct atapi_toc_entry *first_toc, *last_toc; |
352 | unsigned long lba_start, lba_end; | 350 | unsigned long lba_start, lba_end; |
353 | int stat; | 351 | int stat; |
354 | struct request rq; | ||
355 | struct request_sense sense; | 352 | struct request_sense sense; |
353 | unsigned char cmd[BLK_MAX_CDB]; | ||
356 | 354 | ||
357 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); | 355 | stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); |
358 | if (stat) | 356 | if (stat) |
@@ -370,14 +368,13 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg) | |||
370 | if (lba_end <= lba_start) | 368 | if (lba_end <= lba_start) |
371 | return -EINVAL; | 369 | return -EINVAL; |
372 | 370 | ||
373 | ide_cd_init_rq(drive, &rq); | 371 | memset(cmd, 0, BLK_MAX_CDB); |
374 | 372 | ||
375 | rq.sense = &sense; | 373 | cmd[0] = GPCMD_PLAY_AUDIO_MSF; |
376 | rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF; | 374 | lba_to_msf(lba_start, &cmd[3], &cmd[4], &cmd[5]); |
377 | lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]); | 375 | lba_to_msf(lba_end - 1, &cmd[6], &cmd[7], &cmd[8]); |
378 | lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]); | ||
379 | 376 | ||
380 | return ide_cd_queue_pc(drive, &rq); | 377 | return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0); |
381 | } | 378 | } |
382 | 379 | ||
383 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) | 380 | static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) |
@@ -447,8 +444,9 @@ int ide_cdrom_audio_ioctl(struct cdrom_device_info *cdi, | |||
447 | int ide_cdrom_packet(struct cdrom_device_info *cdi, | 444 | int ide_cdrom_packet(struct cdrom_device_info *cdi, |
448 | struct packet_command *cgc) | 445 | struct packet_command *cgc) |
449 | { | 446 | { |
450 | struct request req; | ||
451 | ide_drive_t *drive = cdi->handle; | 447 | ide_drive_t *drive = cdi->handle; |
448 | unsigned int flags = 0; | ||
449 | unsigned len = cgc->buflen; | ||
452 | 450 | ||
453 | if (cgc->timeout <= 0) | 451 | if (cgc->timeout <= 0) |
454 | cgc->timeout = ATAPI_WAIT_PC; | 452 | cgc->timeout = ATAPI_WAIT_PC; |
@@ -456,24 +454,21 @@ int ide_cdrom_packet(struct cdrom_device_info *cdi, | |||
456 | /* here we queue the commands from the uniform CD-ROM | 454 | /* here we queue the commands from the uniform CD-ROM |
457 | layer. the packet must be complete, as we do not | 455 | layer. the packet must be complete, as we do not |
458 | touch it at all. */ | 456 | touch it at all. */ |
459 | ide_cd_init_rq(drive, &req); | ||
460 | 457 | ||
461 | if (cgc->data_direction == CGC_DATA_WRITE) | 458 | if (cgc->data_direction == CGC_DATA_WRITE) |
462 | req.cmd_flags |= REQ_RW; | 459 | flags |= REQ_RW; |
463 | 460 | ||
464 | memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE); | ||
465 | if (cgc->sense) | 461 | if (cgc->sense) |
466 | memset(cgc->sense, 0, sizeof(struct request_sense)); | 462 | memset(cgc->sense, 0, sizeof(struct request_sense)); |
467 | req.data = cgc->buffer; | ||
468 | req.data_len = cgc->buflen; | ||
469 | req.timeout = cgc->timeout; | ||
470 | 463 | ||
471 | if (cgc->quiet) | 464 | if (cgc->quiet) |
472 | req.cmd_flags |= REQ_QUIET; | 465 | flags |= REQ_QUIET; |
473 | 466 | ||
474 | req.sense = cgc->sense; | 467 | cgc->stat = ide_cd_queue_pc(drive, cgc->cmd, |
475 | cgc->stat = ide_cd_queue_pc(drive, &req); | 468 | cgc->data_direction == CGC_DATA_WRITE, |
469 | cgc->buffer, &len, | ||
470 | cgc->sense, cgc->timeout, flags); | ||
476 | if (!cgc->stat) | 471 | if (!cgc->stat) |
477 | cgc->buflen -= req.data_len; | 472 | cgc->buflen -= len; |
478 | return cgc->stat; | 473 | return cgc->stat; |
479 | } | 474 | } |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 8e08d083fce9..3a2e80237c10 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -198,8 +198,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
198 | } | 198 | } |
199 | 199 | ||
200 | memset(&task, 0, sizeof(task)); | 200 | memset(&task, 0, sizeof(task)); |
201 | task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ | 201 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
202 | task.tf_flags |= (IDE_TFLAG_TF | IDE_TFLAG_DEVICE); | ||
203 | 202 | ||
204 | if (drive->select.b.lba) { | 203 | if (drive->select.b.lba) { |
205 | if (lba48) { | 204 | if (lba48) { |
@@ -617,7 +616,8 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | |||
617 | */ | 616 | */ |
618 | static int set_multcount(ide_drive_t *drive, int arg) | 617 | static int set_multcount(ide_drive_t *drive, int arg) |
619 | { | 618 | { |
620 | struct request rq; | 619 | struct request *rq; |
620 | int error; | ||
621 | 621 | ||
622 | if (arg < 0 || arg > drive->id->max_multsect) | 622 | if (arg < 0 || arg > drive->id->max_multsect) |
623 | return -EINVAL; | 623 | return -EINVAL; |
@@ -625,12 +625,13 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
625 | if (drive->special.b.set_multmode) | 625 | if (drive->special.b.set_multmode) |
626 | return -EBUSY; | 626 | return -EBUSY; |
627 | 627 | ||
628 | ide_init_drive_cmd(&rq); | 628 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
629 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 629 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
630 | 630 | ||
631 | drive->mult_req = arg; | 631 | drive->mult_req = arg; |
632 | drive->special.b.set_multmode = 1; | 632 | drive->special.b.set_multmode = 1; |
633 | (void)ide_do_drive_cmd(drive, &rq, ide_wait); | 633 | error = blk_execute_rq(drive->queue, NULL, rq, 0); |
634 | blk_put_request(rq); | ||
634 | 635 | ||
635 | return (drive->mult_count == arg) ? 0 : -EIO; | 636 | return (drive->mult_count == arg) ? 0 : -EIO; |
636 | } | 637 | } |
@@ -984,7 +985,6 @@ static ide_driver_t idedisk_driver = { | |||
984 | .do_request = ide_do_rw_disk, | 985 | .do_request = ide_do_rw_disk, |
985 | .end_request = ide_end_request, | 986 | .end_request = ide_end_request, |
986 | .error = __ide_error, | 987 | .error = __ide_error, |
987 | .abort = __ide_abort, | ||
988 | #ifdef CONFIG_IDE_PROC_FS | 988 | #ifdef CONFIG_IDE_PROC_FS |
989 | .proc = idedisk_proc, | 989 | .proc = idedisk_proc, |
990 | #endif | 990 | #endif |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 653b1ade13d3..7ee44f86bc54 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
@@ -463,7 +463,7 @@ int ide_dma_setup(ide_drive_t *drive) | |||
463 | } | 463 | } |
464 | 464 | ||
465 | /* PRD table */ | 465 | /* PRD table */ |
466 | if (hwif->mmio) | 466 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
467 | writel(hwif->dmatable_dma, | 467 | writel(hwif->dmatable_dma, |
468 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); | 468 | (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); |
469 | else | 469 | else |
@@ -692,7 +692,7 @@ static int ide_tune_dma(ide_drive_t *drive) | |||
692 | ide_hwif_t *hwif = drive->hwif; | 692 | ide_hwif_t *hwif = drive->hwif; |
693 | u8 speed; | 693 | u8 speed; |
694 | 694 | ||
695 | if (noautodma || drive->nodma || (drive->id->capability & 1) == 0) | 695 | if (drive->nodma || (drive->id->capability & 1) == 0) |
696 | return 0; | 696 | return 0; |
697 | 697 | ||
698 | /* consult the list of known "bad" drives */ | 698 | /* consult the list of known "bad" drives */ |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index f05fbc2bd7a8..011d72011cc4 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -286,11 +286,12 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
286 | { | 286 | { |
287 | struct ide_floppy_obj *floppy = drive->driver_data; | 287 | struct ide_floppy_obj *floppy = drive->driver_data; |
288 | 288 | ||
289 | ide_init_drive_cmd(rq); | 289 | blk_rq_init(NULL, rq); |
290 | rq->buffer = (char *) pc; | 290 | rq->buffer = (char *) pc; |
291 | rq->cmd_type = REQ_TYPE_SPECIAL; | 291 | rq->cmd_type = REQ_TYPE_SPECIAL; |
292 | rq->cmd_flags |= REQ_PREEMPT; | ||
292 | rq->rq_disk = floppy->disk; | 293 | rq->rq_disk = floppy->disk; |
293 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 294 | ide_do_drive_cmd(drive, rq); |
294 | } | 295 | } |
295 | 296 | ||
296 | static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) | 297 | static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) |
@@ -311,61 +312,49 @@ static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) | |||
311 | return (&floppy->rq_stack[floppy->rq_stack_index++]); | 312 | return (&floppy->rq_stack[floppy->rq_stack_index++]); |
312 | } | 313 | } |
313 | 314 | ||
314 | static void idefloppy_request_sense_callback(ide_drive_t *drive) | 315 | static void ide_floppy_callback(ide_drive_t *drive) |
315 | { | 316 | { |
316 | idefloppy_floppy_t *floppy = drive->driver_data; | 317 | idefloppy_floppy_t *floppy = drive->driver_data; |
317 | u8 *buf = floppy->pc->buf; | 318 | struct ide_atapi_pc *pc = floppy->pc; |
319 | int uptodate = pc->error ? 0 : 1; | ||
318 | 320 | ||
319 | debug_log("Reached %s\n", __func__); | 321 | debug_log("Reached %s\n", __func__); |
320 | 322 | ||
321 | if (!floppy->pc->error) { | 323 | if (floppy->failed_pc == pc) |
322 | floppy->sense_key = buf[2] & 0x0F; | 324 | floppy->failed_pc = NULL; |
323 | floppy->asc = buf[12]; | ||
324 | floppy->ascq = buf[13]; | ||
325 | floppy->progress_indication = buf[15] & 0x80 ? | ||
326 | (u16)get_unaligned((u16 *)&buf[16]) : 0x10000; | ||
327 | |||
328 | if (floppy->failed_pc) | ||
329 | debug_log("pc = %x, sense key = %x, asc = %x," | ||
330 | " ascq = %x\n", | ||
331 | floppy->failed_pc->c[0], | ||
332 | floppy->sense_key, | ||
333 | floppy->asc, | ||
334 | floppy->ascq); | ||
335 | else | ||
336 | debug_log("sense key = %x, asc = %x, ascq = %x\n", | ||
337 | floppy->sense_key, | ||
338 | floppy->asc, | ||
339 | floppy->ascq); | ||
340 | 325 | ||
326 | if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || | ||
327 | (pc->rq && blk_pc_request(pc->rq))) | ||
328 | uptodate = 1; /* FIXME */ | ||
329 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { | ||
330 | u8 *buf = floppy->pc->buf; | ||
341 | 331 | ||
342 | idefloppy_end_request(drive, 1, 0); | 332 | if (!pc->error) { |
343 | } else { | 333 | floppy->sense_key = buf[2] & 0x0F; |
344 | printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting" | 334 | floppy->asc = buf[12]; |
345 | " request!\n"); | 335 | floppy->ascq = buf[13]; |
346 | idefloppy_end_request(drive, 0, 0); | 336 | floppy->progress_indication = buf[15] & 0x80 ? |
347 | } | 337 | (u16)get_unaligned((u16 *)&buf[16]) : 0x10000; |
348 | } | ||
349 | 338 | ||
350 | /* General packet command callback function. */ | 339 | if (floppy->failed_pc) |
351 | static void idefloppy_pc_callback(ide_drive_t *drive) | 340 | debug_log("pc = %x, ", floppy->failed_pc->c[0]); |
352 | { | ||
353 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
354 | 341 | ||
355 | debug_log("Reached %s\n", __func__); | 342 | debug_log("sense key = %x, asc = %x, ascq = %x\n", |
343 | floppy->sense_key, floppy->asc, floppy->ascq); | ||
344 | } else | ||
345 | printk(KERN_ERR "Error in REQUEST SENSE itself - " | ||
346 | "Aborting request!\n"); | ||
347 | } | ||
356 | 348 | ||
357 | idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0); | 349 | idefloppy_end_request(drive, uptodate, 0); |
358 | } | 350 | } |
359 | 351 | ||
360 | static void idefloppy_init_pc(struct ide_atapi_pc *pc) | 352 | static void idefloppy_init_pc(struct ide_atapi_pc *pc) |
361 | { | 353 | { |
362 | memset(pc->c, 0, 12); | 354 | memset(pc, 0, sizeof(*pc)); |
363 | pc->retries = 0; | ||
364 | pc->flags = 0; | ||
365 | pc->req_xfer = 0; | ||
366 | pc->buf = pc->pc_buf; | 355 | pc->buf = pc->pc_buf; |
367 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; | 356 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; |
368 | pc->idefloppy_callback = &idefloppy_pc_callback; | 357 | pc->callback = ide_floppy_callback; |
369 | } | 358 | } |
370 | 359 | ||
371 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | 360 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) |
@@ -374,7 +363,6 @@ static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | |||
374 | pc->c[0] = GPCMD_REQUEST_SENSE; | 363 | pc->c[0] = GPCMD_REQUEST_SENSE; |
375 | pc->c[4] = 255; | 364 | pc->c[4] = 255; |
376 | pc->req_xfer = 18; | 365 | pc->req_xfer = 18; |
377 | pc->idefloppy_callback = &idefloppy_request_sense_callback; | ||
378 | } | 366 | } |
379 | 367 | ||
380 | /* | 368 | /* |
@@ -397,174 +385,19 @@ static void idefloppy_retry_pc(ide_drive_t *drive) | |||
397 | static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) | 385 | static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) |
398 | { | 386 | { |
399 | idefloppy_floppy_t *floppy = drive->driver_data; | 387 | idefloppy_floppy_t *floppy = drive->driver_data; |
400 | ide_hwif_t *hwif = drive->hwif; | ||
401 | struct ide_atapi_pc *pc = floppy->pc; | ||
402 | struct request *rq = pc->rq; | ||
403 | xfer_func_t *xferfunc; | ||
404 | unsigned int temp; | ||
405 | int dma_error = 0; | ||
406 | u16 bcount; | ||
407 | u8 stat, ireason; | ||
408 | |||
409 | debug_log("Reached %s interrupt handler\n", __func__); | ||
410 | |||
411 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
412 | dma_error = hwif->dma_ops->dma_end(drive); | ||
413 | if (dma_error) { | ||
414 | printk(KERN_ERR "%s: DMA %s error\n", drive->name, | ||
415 | rq_data_dir(rq) ? "write" : "read"); | ||
416 | pc->flags |= PC_FLAG_DMA_ERROR; | ||
417 | } else { | ||
418 | pc->xferred = pc->req_xfer; | ||
419 | idefloppy_update_buffers(drive, pc); | ||
420 | } | ||
421 | debug_log("DMA finished\n"); | ||
422 | } | ||
423 | |||
424 | /* Clear the interrupt */ | ||
425 | stat = ide_read_status(drive); | ||
426 | |||
427 | /* No more interrupts */ | ||
428 | if ((stat & DRQ_STAT) == 0) { | ||
429 | debug_log("Packet command completed, %d bytes transferred\n", | ||
430 | pc->xferred); | ||
431 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
432 | |||
433 | local_irq_enable_in_hardirq(); | ||
434 | |||
435 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | ||
436 | /* Error detected */ | ||
437 | debug_log("%s: I/O error\n", drive->name); | ||
438 | rq->errors++; | ||
439 | if (pc->c[0] == GPCMD_REQUEST_SENSE) { | ||
440 | printk(KERN_ERR "ide-floppy: I/O error in " | ||
441 | "request sense command\n"); | ||
442 | return ide_do_reset(drive); | ||
443 | } | ||
444 | /* Retry operation */ | ||
445 | idefloppy_retry_pc(drive); | ||
446 | /* queued, but not started */ | ||
447 | return ide_stopped; | ||
448 | } | ||
449 | pc->error = 0; | ||
450 | if (floppy->failed_pc == pc) | ||
451 | floppy->failed_pc = NULL; | ||
452 | /* Command finished - Call the callback function */ | ||
453 | pc->idefloppy_callback(drive); | ||
454 | return ide_stopped; | ||
455 | } | ||
456 | |||
457 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
458 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
459 | printk(KERN_ERR "ide-floppy: The floppy wants to issue " | ||
460 | "more interrupts in DMA mode\n"); | ||
461 | ide_dma_off(drive); | ||
462 | return ide_do_reset(drive); | ||
463 | } | ||
464 | |||
465 | /* Get the number of bytes to transfer */ | ||
466 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
467 | hwif->INB(hwif->io_ports.lbam_addr); | ||
468 | /* on this interrupt */ | ||
469 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
470 | |||
471 | if (ireason & CD) { | ||
472 | printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); | ||
473 | return ide_do_reset(drive); | ||
474 | } | ||
475 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | ||
476 | /* Hopefully, we will never get here */ | ||
477 | printk(KERN_ERR "ide-floppy: We wanted to %s, ", | ||
478 | (ireason & IO) ? "Write" : "Read"); | ||
479 | printk(KERN_ERR "but the floppy wants us to %s !\n", | ||
480 | (ireason & IO) ? "Read" : "Write"); | ||
481 | return ide_do_reset(drive); | ||
482 | } | ||
483 | if (!(pc->flags & PC_FLAG_WRITING)) { | ||
484 | /* Reading - Check that we have enough space */ | ||
485 | temp = pc->xferred + bcount; | ||
486 | if (temp > pc->req_xfer) { | ||
487 | if (temp > pc->buf_size) { | ||
488 | printk(KERN_ERR "ide-floppy: The floppy wants " | ||
489 | "to send us more data than expected " | ||
490 | "- discarding data\n"); | ||
491 | ide_pad_transfer(drive, 0, bcount); | ||
492 | |||
493 | ide_set_handler(drive, | ||
494 | &idefloppy_pc_intr, | ||
495 | IDEFLOPPY_WAIT_CMD, | ||
496 | NULL); | ||
497 | return ide_started; | ||
498 | } | ||
499 | debug_log("The floppy wants to send us more data than" | ||
500 | " expected - allowing transfer\n"); | ||
501 | } | ||
502 | } | ||
503 | if (pc->flags & PC_FLAG_WRITING) | ||
504 | xferfunc = hwif->output_data; | ||
505 | else | ||
506 | xferfunc = hwif->input_data; | ||
507 | |||
508 | if (pc->buf) | ||
509 | xferfunc(drive, NULL, pc->cur_pos, bcount); | ||
510 | else | ||
511 | ide_floppy_io_buffers(drive, pc, bcount, | ||
512 | !!(pc->flags & PC_FLAG_WRITING)); | ||
513 | 388 | ||
514 | /* Update the current position */ | 389 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, |
515 | pc->xferred += bcount; | 390 | IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers, |
516 | pc->cur_pos += bcount; | 391 | idefloppy_retry_pc, NULL, ide_floppy_io_buffers); |
517 | |||
518 | /* And set the interrupt handler again */ | ||
519 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); | ||
520 | return ide_started; | ||
521 | } | 392 | } |
522 | 393 | ||
523 | /* | 394 | /* |
524 | * This is the original routine that did the packet transfer. | ||
525 | * It fails at high speeds on the Iomega ZIP drive, so there's a slower version | ||
526 | * for that drive below. The algorithm is chosen based on drive type | ||
527 | */ | ||
528 | static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) | ||
529 | { | ||
530 | ide_hwif_t *hwif = drive->hwif; | ||
531 | ide_startstop_t startstop; | ||
532 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
533 | u8 ireason; | ||
534 | |||
535 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
536 | printk(KERN_ERR "ide-floppy: Strange, packet command " | ||
537 | "initiated yet DRQ isn't asserted\n"); | ||
538 | return startstop; | ||
539 | } | ||
540 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
541 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
542 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " | ||
543 | "issuing a packet command\n"); | ||
544 | return ide_do_reset(drive); | ||
545 | } | ||
546 | |||
547 | /* Set the interrupt routine */ | ||
548 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); | ||
549 | |||
550 | /* Send the actual packet */ | ||
551 | hwif->output_data(drive, NULL, floppy->pc->c, 12); | ||
552 | |||
553 | return ide_started; | ||
554 | } | ||
555 | |||
556 | |||
557 | /* | ||
558 | * What we have here is a classic case of a top half / bottom half interrupt | 395 | * What we have here is a classic case of a top half / bottom half interrupt |
559 | * service routine. In interrupt mode, the device sends an interrupt to signal | 396 | * service routine. In interrupt mode, the device sends an interrupt to signal |
560 | * that it is ready to receive a packet. However, we need to delay about 2-3 | 397 | * that it is ready to receive a packet. However, we need to delay about 2-3 |
561 | * ticks before issuing the packet or we gets in trouble. | 398 | * ticks before issuing the packet or we gets in trouble. |
562 | * | ||
563 | * So, follow carefully. transfer_pc1 is called as an interrupt (or directly). | ||
564 | * In either case, when the device says it's ready for a packet, we schedule | ||
565 | * the packet transfer to occur about 2-3 ticks later in transfer_pc2. | ||
566 | */ | 399 | */ |
567 | static int idefloppy_transfer_pc2(ide_drive_t *drive) | 400 | static int idefloppy_transfer_pc(ide_drive_t *drive) |
568 | { | 401 | { |
569 | idefloppy_floppy_t *floppy = drive->driver_data; | 402 | idefloppy_floppy_t *floppy = drive->driver_data; |
570 | 403 | ||
@@ -575,24 +408,19 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive) | |||
575 | return IDEFLOPPY_WAIT_CMD; | 408 | return IDEFLOPPY_WAIT_CMD; |
576 | } | 409 | } |
577 | 410 | ||
578 | static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) | 411 | |
412 | /* | ||
413 | * Called as an interrupt (or directly). When the device says it's ready for a | ||
414 | * packet, we schedule the packet transfer to occur about 2-3 ticks later in | ||
415 | * transfer_pc. | ||
416 | */ | ||
417 | static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive) | ||
579 | { | 418 | { |
580 | ide_hwif_t *hwif = drive->hwif; | ||
581 | idefloppy_floppy_t *floppy = drive->driver_data; | 419 | idefloppy_floppy_t *floppy = drive->driver_data; |
582 | ide_startstop_t startstop; | 420 | struct ide_atapi_pc *pc = floppy->pc; |
583 | u8 ireason; | 421 | ide_expiry_t *expiry; |
422 | unsigned int timeout; | ||
584 | 423 | ||
585 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
586 | printk(KERN_ERR "ide-floppy: Strange, packet command " | ||
587 | "initiated yet DRQ isn't asserted\n"); | ||
588 | return startstop; | ||
589 | } | ||
590 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
591 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
592 | printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " | ||
593 | "while issuing a packet command\n"); | ||
594 | return ide_do_reset(drive); | ||
595 | } | ||
596 | /* | 424 | /* |
597 | * The following delay solves a problem with ATAPI Zip 100 drives | 425 | * The following delay solves a problem with ATAPI Zip 100 drives |
598 | * where the Busy flag was apparently being deasserted before the | 426 | * where the Busy flag was apparently being deasserted before the |
@@ -601,10 +429,15 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) | |||
601 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually | 429 | * 40 and 50msec work well. idefloppy_pc_intr will not be actually |
602 | * used until after the packet is moved in about 50 msec. | 430 | * used until after the packet is moved in about 50 msec. |
603 | */ | 431 | */ |
432 | if (pc->flags & PC_FLAG_ZIP_DRIVE) { | ||
433 | timeout = floppy->ticks; | ||
434 | expiry = &idefloppy_transfer_pc; | ||
435 | } else { | ||
436 | timeout = IDEFLOPPY_WAIT_CMD; | ||
437 | expiry = NULL; | ||
438 | } | ||
604 | 439 | ||
605 | ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks, | 440 | return ide_transfer_pc(drive, pc, idefloppy_pc_intr, timeout, expiry); |
606 | &idefloppy_transfer_pc2); | ||
607 | return ide_started; | ||
608 | } | 441 | } |
609 | 442 | ||
610 | static void ide_floppy_report_error(idefloppy_floppy_t *floppy, | 443 | static void ide_floppy_report_error(idefloppy_floppy_t *floppy, |
@@ -627,10 +460,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
627 | struct ide_atapi_pc *pc) | 460 | struct ide_atapi_pc *pc) |
628 | { | 461 | { |
629 | idefloppy_floppy_t *floppy = drive->driver_data; | 462 | idefloppy_floppy_t *floppy = drive->driver_data; |
630 | ide_hwif_t *hwif = drive->hwif; | ||
631 | ide_handler_t *pkt_xfer_routine; | ||
632 | u16 bcount; | ||
633 | u8 dma; | ||
634 | 463 | ||
635 | if (floppy->failed_pc == NULL && | 464 | if (floppy->failed_pc == NULL && |
636 | pc->c[0] != GPCMD_REQUEST_SENSE) | 465 | pc->c[0] != GPCMD_REQUEST_SENSE) |
@@ -645,65 +474,16 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
645 | pc->error = IDEFLOPPY_ERROR_GENERAL; | 474 | pc->error = IDEFLOPPY_ERROR_GENERAL; |
646 | 475 | ||
647 | floppy->failed_pc = NULL; | 476 | floppy->failed_pc = NULL; |
648 | pc->idefloppy_callback(drive); | 477 | pc->callback(drive); |
649 | return ide_stopped; | 478 | return ide_stopped; |
650 | } | 479 | } |
651 | 480 | ||
652 | debug_log("Retry number - %d\n", pc->retries); | 481 | debug_log("Retry number - %d\n", pc->retries); |
653 | 482 | ||
654 | pc->retries++; | 483 | pc->retries++; |
655 | /* We haven't transferred any data yet */ | ||
656 | pc->xferred = 0; | ||
657 | pc->cur_pos = pc->buf; | ||
658 | bcount = min(pc->req_xfer, 63 * 1024); | ||
659 | |||
660 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
661 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
662 | ide_dma_off(drive); | ||
663 | } | ||
664 | dma = 0; | ||
665 | |||
666 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | ||
667 | dma = !hwif->dma_ops->dma_setup(drive); | ||
668 | |||
669 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | ||
670 | IDE_TFLAG_OUT_DEVICE, bcount, dma); | ||
671 | 484 | ||
672 | if (dma) { | 485 | return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer, |
673 | /* Begin DMA, if necessary */ | 486 | IDEFLOPPY_WAIT_CMD, NULL); |
674 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
675 | hwif->dma_ops->dma_start(drive); | ||
676 | } | ||
677 | |||
678 | /* Can we transfer the packet when we get the interrupt or wait? */ | ||
679 | if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) { | ||
680 | /* wait */ | ||
681 | pkt_xfer_routine = &idefloppy_transfer_pc1; | ||
682 | } else { | ||
683 | /* immediate */ | ||
684 | pkt_xfer_routine = &idefloppy_transfer_pc; | ||
685 | } | ||
686 | |||
687 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { | ||
688 | /* Issue the packet command */ | ||
689 | ide_execute_command(drive, WIN_PACKETCMD, | ||
690 | pkt_xfer_routine, | ||
691 | IDEFLOPPY_WAIT_CMD, | ||
692 | NULL); | ||
693 | return ide_started; | ||
694 | } else { | ||
695 | /* Issue the packet command */ | ||
696 | ide_execute_pkt_cmd(drive); | ||
697 | return (*pkt_xfer_routine) (drive); | ||
698 | } | ||
699 | } | ||
700 | |||
701 | static void idefloppy_rw_callback(ide_drive_t *drive) | ||
702 | { | ||
703 | debug_log("Reached %s\n", __func__); | ||
704 | |||
705 | idefloppy_end_request(drive, 1, 0); | ||
706 | return; | ||
707 | } | 487 | } |
708 | 488 | ||
709 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) | 489 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) |
@@ -778,12 +558,6 @@ static void idefloppy_create_start_stop_cmd(struct ide_atapi_pc *pc, int start) | |||
778 | pc->c[4] = start; | 558 | pc->c[4] = start; |
779 | } | 559 | } |
780 | 560 | ||
781 | static void idefloppy_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | ||
782 | { | ||
783 | idefloppy_init_pc(pc); | ||
784 | pc->c[0] = GPCMD_TEST_UNIT_READY; | ||
785 | } | ||
786 | |||
787 | static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | 561 | static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, |
788 | struct ide_atapi_pc *pc, struct request *rq, | 562 | struct ide_atapi_pc *pc, struct request *rq, |
789 | unsigned long sector) | 563 | unsigned long sector) |
@@ -800,21 +574,19 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
800 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); | 574 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); |
801 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); | 575 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); |
802 | 576 | ||
803 | pc->idefloppy_callback = &idefloppy_rw_callback; | ||
804 | pc->rq = rq; | 577 | pc->rq = rq; |
805 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; | 578 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; |
806 | if (rq->cmd_flags & REQ_RW) | 579 | if (rq->cmd_flags & REQ_RW) |
807 | pc->flags |= PC_FLAG_WRITING; | 580 | pc->flags |= PC_FLAG_WRITING; |
808 | pc->buf = NULL; | 581 | pc->buf = NULL; |
809 | pc->req_xfer = pc->buf_size = blocks * floppy->block_size; | 582 | pc->req_xfer = pc->buf_size = blocks * floppy->block_size; |
810 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 583 | pc->flags |= PC_FLAG_DMA_OK; |
811 | } | 584 | } |
812 | 585 | ||
813 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, | 586 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, |
814 | struct ide_atapi_pc *pc, struct request *rq) | 587 | struct ide_atapi_pc *pc, struct request *rq) |
815 | { | 588 | { |
816 | idefloppy_init_pc(pc); | 589 | idefloppy_init_pc(pc); |
817 | pc->idefloppy_callback = &idefloppy_rw_callback; | ||
818 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); | 590 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); |
819 | pc->rq = rq; | 591 | pc->rq = rq; |
820 | pc->b_count = rq->data_len; | 592 | pc->b_count = rq->data_len; |
@@ -822,7 +594,7 @@ static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, | |||
822 | pc->flags |= PC_FLAG_WRITING; | 594 | pc->flags |= PC_FLAG_WRITING; |
823 | pc->buf = rq->data; | 595 | pc->buf = rq->data; |
824 | if (rq->bio) | 596 | if (rq->bio) |
825 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 597 | pc->flags |= PC_FLAG_DMA_OK; |
826 | /* | 598 | /* |
827 | * possibly problematic, doesn't look like ide-floppy correctly | 599 | * possibly problematic, doesn't look like ide-floppy correctly |
828 | * handled scattered requests if dma fails... | 600 | * handled scattered requests if dma fails... |
@@ -875,7 +647,14 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
875 | return ide_stopped; | 647 | return ide_stopped; |
876 | } | 648 | } |
877 | 649 | ||
650 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) | ||
651 | pc->flags |= PC_FLAG_DRQ_INTERRUPT; | ||
652 | |||
653 | if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) | ||
654 | pc->flags |= PC_FLAG_ZIP_DRIVE; | ||
655 | |||
878 | pc->rq = rq; | 656 | pc->rq = rq; |
657 | |||
879 | return idefloppy_issue_pc(drive, pc); | 658 | return idefloppy_issue_pc(drive, pc); |
880 | } | 659 | } |
881 | 660 | ||
@@ -886,14 +665,16 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
886 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | 665 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
887 | { | 666 | { |
888 | struct ide_floppy_obj *floppy = drive->driver_data; | 667 | struct ide_floppy_obj *floppy = drive->driver_data; |
889 | struct request rq; | 668 | struct request *rq; |
669 | int error; | ||
890 | 670 | ||
891 | ide_init_drive_cmd(&rq); | 671 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
892 | rq.buffer = (char *) pc; | 672 | rq->buffer = (char *) pc; |
893 | rq.cmd_type = REQ_TYPE_SPECIAL; | 673 | rq->cmd_type = REQ_TYPE_SPECIAL; |
894 | rq.rq_disk = floppy->disk; | 674 | error = blk_execute_rq(drive->queue, floppy->disk, rq, 0); |
675 | blk_put_request(rq); | ||
895 | 676 | ||
896 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 677 | return error; |
897 | } | 678 | } |
898 | 679 | ||
899 | /* | 680 | /* |
@@ -921,10 +702,10 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | |||
921 | set_disk_ro(floppy->disk, floppy->wp); | 702 | set_disk_ro(floppy->disk, floppy->wp); |
922 | page = &pc.buf[8]; | 703 | page = &pc.buf[8]; |
923 | 704 | ||
924 | transfer_rate = be16_to_cpu(*(u16 *)&pc.buf[8 + 2]); | 705 | transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); |
925 | sector_size = be16_to_cpu(*(u16 *)&pc.buf[8 + 6]); | 706 | sector_size = be16_to_cpup((__be16 *)&pc.buf[8 + 6]); |
926 | cyls = be16_to_cpu(*(u16 *)&pc.buf[8 + 8]); | 707 | cyls = be16_to_cpup((__be16 *)&pc.buf[8 + 8]); |
927 | rpm = be16_to_cpu(*(u16 *)&pc.buf[8 + 28]); | 708 | rpm = be16_to_cpup((__be16 *)&pc.buf[8 + 28]); |
928 | heads = pc.buf[8 + 4]; | 709 | heads = pc.buf[8 + 4]; |
929 | sectors = pc.buf[8 + 5]; | 710 | sectors = pc.buf[8 + 5]; |
930 | 711 | ||
@@ -999,8 +780,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
999 | for (i = 0; i < desc_cnt; i++) { | 780 | for (i = 0; i < desc_cnt; i++) { |
1000 | unsigned int desc_start = 4 + i*8; | 781 | unsigned int desc_start = 4 + i*8; |
1001 | 782 | ||
1002 | blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]); | 783 | blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); |
1003 | length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]); | 784 | length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); |
1004 | 785 | ||
1005 | debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", | 786 | debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", |
1006 | i, blocks * length / 1024, blocks, length); | 787 | i, blocks * length / 1024, blocks, length); |
@@ -1121,8 +902,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
1121 | if (u_index >= u_array_size) | 902 | if (u_index >= u_array_size) |
1122 | break; /* User-supplied buffer too small */ | 903 | break; /* User-supplied buffer too small */ |
1123 | 904 | ||
1124 | blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]); | 905 | blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); |
1125 | length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]); | 906 | length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); |
1126 | 907 | ||
1127 | if (put_user(blocks, argp)) | 908 | if (put_user(blocks, argp)) |
1128 | return(-EFAULT); | 909 | return(-EFAULT); |
@@ -1348,7 +1129,6 @@ static ide_driver_t idefloppy_driver = { | |||
1348 | .do_request = idefloppy_do_request, | 1129 | .do_request = idefloppy_do_request, |
1349 | .end_request = idefloppy_end_request, | 1130 | .end_request = idefloppy_end_request, |
1350 | .error = __ide_error, | 1131 | .error = __ide_error, |
1351 | .abort = __ide_abort, | ||
1352 | #ifdef CONFIG_IDE_PROC_FS | 1132 | #ifdef CONFIG_IDE_PROC_FS |
1353 | .proc = idefloppy_proc, | 1133 | .proc = idefloppy_proc, |
1354 | #endif | 1134 | #endif |
@@ -1376,7 +1156,9 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1376 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; | 1156 | floppy->flags &= ~IDEFLOPPY_FLAG_FORMAT_IN_PROGRESS; |
1377 | /* Just in case */ | 1157 | /* Just in case */ |
1378 | 1158 | ||
1379 | idefloppy_create_test_unit_ready_cmd(&pc); | 1159 | idefloppy_init_pc(&pc); |
1160 | pc.c[0] = GPCMD_TEST_UNIT_READY; | ||
1161 | |||
1380 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 1162 | if (idefloppy_queue_pc_tail(drive, &pc)) { |
1381 | idefloppy_create_start_stop_cmd(&pc, 1); | 1163 | idefloppy_create_start_stop_cmd(&pc, 1); |
1382 | (void) idefloppy_queue_pc_tail(drive, &pc); | 1164 | (void) idefloppy_queue_pc_tail(drive, &pc); |
@@ -1622,11 +1404,6 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
1622 | " of ide-floppy\n", drive->name); | 1404 | " of ide-floppy\n", drive->name); |
1623 | goto failed; | 1405 | goto failed; |
1624 | } | 1406 | } |
1625 | if (drive->scsi) { | ||
1626 | printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi" | ||
1627 | " emulation.\n", drive->name); | ||
1628 | goto failed; | ||
1629 | } | ||
1630 | floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); | 1407 | floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); |
1631 | if (!floppy) { | 1408 | if (!floppy) { |
1632 | printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" | 1409 | printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" |
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 696525342e9a..661b75a89d4d 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -358,31 +358,6 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) | |||
358 | 358 | ||
359 | EXPORT_SYMBOL(ide_end_drive_cmd); | 359 | EXPORT_SYMBOL(ide_end_drive_cmd); |
360 | 360 | ||
361 | /** | ||
362 | * try_to_flush_leftover_data - flush junk | ||
363 | * @drive: drive to flush | ||
364 | * | ||
365 | * try_to_flush_leftover_data() is invoked in response to a drive | ||
366 | * unexpectedly having its DRQ_STAT bit set. As an alternative to | ||
367 | * resetting the drive, this routine tries to clear the condition | ||
368 | * by read a sector's worth of data from the drive. Of course, | ||
369 | * this may not help if the drive is *waiting* for data from *us*. | ||
370 | */ | ||
371 | static void try_to_flush_leftover_data (ide_drive_t *drive) | ||
372 | { | ||
373 | int i = (drive->mult_count ? drive->mult_count : 1) * SECTOR_WORDS; | ||
374 | |||
375 | if (drive->media != ide_disk) | ||
376 | return; | ||
377 | while (i > 0) { | ||
378 | u32 buffer[16]; | ||
379 | u32 wcount = (i > 16) ? 16 : i; | ||
380 | |||
381 | i -= wcount; | ||
382 | drive->hwif->input_data(drive, NULL, buffer, wcount * 4); | ||
383 | } | ||
384 | } | ||
385 | |||
386 | static void ide_kill_rq(ide_drive_t *drive, struct request *rq) | 361 | static void ide_kill_rq(ide_drive_t *drive, struct request *rq) |
387 | { | 362 | { |
388 | if (rq->rq_disk) { | 363 | if (rq->rq_disk) { |
@@ -422,8 +397,11 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 | |||
422 | } | 397 | } |
423 | 398 | ||
424 | if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && | 399 | if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && |
425 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) | 400 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) { |
426 | try_to_flush_leftover_data(drive); | 401 | int nsect = drive->mult_count ? drive->mult_count : 1; |
402 | |||
403 | ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE); | ||
404 | } | ||
427 | 405 | ||
428 | if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) { | 406 | if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) { |
429 | ide_kill_rq(drive, rq); | 407 | ide_kill_rq(drive, rq); |
@@ -459,7 +437,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u | |||
459 | 437 | ||
460 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) | 438 | if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) |
461 | /* force an abort */ | 439 | /* force an abort */ |
462 | hwif->OUTBSYNC(drive, WIN_IDLEIMMEDIATE, | 440 | hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE, |
463 | hwif->io_ports.command_addr); | 441 | hwif->io_ports.command_addr); |
464 | 442 | ||
465 | if (rq->errors >= ERROR_MAX) { | 443 | if (rq->errors >= ERROR_MAX) { |
@@ -526,55 +504,6 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, u8 stat) | |||
526 | 504 | ||
527 | EXPORT_SYMBOL_GPL(ide_error); | 505 | EXPORT_SYMBOL_GPL(ide_error); |
528 | 506 | ||
529 | ide_startstop_t __ide_abort(ide_drive_t *drive, struct request *rq) | ||
530 | { | ||
531 | if (drive->media != ide_disk) | ||
532 | rq->errors |= ERROR_RESET; | ||
533 | |||
534 | ide_kill_rq(drive, rq); | ||
535 | |||
536 | return ide_stopped; | ||
537 | } | ||
538 | |||
539 | EXPORT_SYMBOL_GPL(__ide_abort); | ||
540 | |||
541 | /** | ||
542 | * ide_abort - abort pending IDE operations | ||
543 | * @drive: drive the error occurred on | ||
544 | * @msg: message to report | ||
545 | * | ||
546 | * ide_abort kills and cleans up when we are about to do a | ||
547 | * host initiated reset on active commands. Longer term we | ||
548 | * want handlers to have sensible abort handling themselves | ||
549 | * | ||
550 | * This differs fundamentally from ide_error because in | ||
551 | * this case the command is doing just fine when we | ||
552 | * blow it away. | ||
553 | */ | ||
554 | |||
555 | ide_startstop_t ide_abort(ide_drive_t *drive, const char *msg) | ||
556 | { | ||
557 | struct request *rq; | ||
558 | |||
559 | if (drive == NULL || (rq = HWGROUP(drive)->rq) == NULL) | ||
560 | return ide_stopped; | ||
561 | |||
562 | /* retry only "normal" I/O: */ | ||
563 | if (!blk_fs_request(rq)) { | ||
564 | rq->errors = 1; | ||
565 | ide_end_drive_cmd(drive, BUSY_STAT, 0); | ||
566 | return ide_stopped; | ||
567 | } | ||
568 | |||
569 | if (rq->rq_disk) { | ||
570 | ide_driver_t *drv; | ||
571 | |||
572 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | ||
573 | return drv->abort(drive, rq); | ||
574 | } else | ||
575 | return __ide_abort(drive, rq); | ||
576 | } | ||
577 | |||
578 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | 507 | static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) |
579 | { | 508 | { |
580 | tf->nsect = drive->sect; | 509 | tf->nsect = drive->sect; |
@@ -788,6 +717,18 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, | |||
788 | return ide_stopped; | 717 | return ide_stopped; |
789 | } | 718 | } |
790 | 719 | ||
720 | static 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 | |||
791 | static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) | 732 | static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) |
792 | { | 733 | { |
793 | struct request_pm_state *pm = rq->data; | 734 | struct request_pm_state *pm = rq->data; |
@@ -891,7 +832,16 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
891 | pm->pm_step == ide_pm_state_completed) | 832 | pm->pm_step == ide_pm_state_completed) |
892 | ide_complete_pm_request(drive, rq); | 833 | ide_complete_pm_request(drive, rq); |
893 | return startstop; | 834 | return startstop; |
894 | } | 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); | ||
895 | 845 | ||
896 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | 846 | drv = *(ide_driver_t **)rq->rq_disk->private_data; |
897 | return drv->do_request(drive, rq, block); | 847 | return drv->do_request(drive, rq, block); |
@@ -1539,88 +1489,30 @@ irqreturn_t ide_intr (int irq, void *dev_id) | |||
1539 | } | 1489 | } |
1540 | 1490 | ||
1541 | /** | 1491 | /** |
1542 | * ide_init_drive_cmd - initialize a drive command request | ||
1543 | * @rq: request object | ||
1544 | * | ||
1545 | * Initialize a request before we fill it in and send it down to | ||
1546 | * ide_do_drive_cmd. Commands must be set up by this function. Right | ||
1547 | * now it doesn't do a lot, but if that changes abusers will have a | ||
1548 | * nasty surprise. | ||
1549 | */ | ||
1550 | |||
1551 | void ide_init_drive_cmd (struct request *rq) | ||
1552 | { | ||
1553 | blk_rq_init(NULL, rq); | ||
1554 | } | ||
1555 | |||
1556 | EXPORT_SYMBOL(ide_init_drive_cmd); | ||
1557 | |||
1558 | /** | ||
1559 | * ide_do_drive_cmd - issue IDE special command | 1492 | * ide_do_drive_cmd - issue IDE special command |
1560 | * @drive: device to issue command | 1493 | * @drive: device to issue command |
1561 | * @rq: request to issue | 1494 | * @rq: request to issue |
1562 | * @action: action for processing | ||
1563 | * | 1495 | * |
1564 | * This function issues a special IDE device request | 1496 | * This function issues a special IDE device request |
1565 | * onto the request queue. | 1497 | * onto the request queue. |
1566 | * | 1498 | * |
1567 | * If action is ide_wait, then the rq is queued at the end of the | 1499 | * the rq is queued at the head of the request queue, displacing |
1568 | * request queue, and the function sleeps until it has been processed. | 1500 | * the currently-being-processed request and this function |
1569 | * This is for use when invoked from an ioctl handler. | 1501 | * returns immediately without waiting for the new rq to be |
1570 | * | 1502 | * completed. This is VERY DANGEROUS, and is intended for |
1571 | * If action is ide_preempt, then the rq is queued at the head of | 1503 | * careful use by the ATAPI tape/cdrom driver code. |
1572 | * the request queue, displacing the currently-being-processed | ||
1573 | * request and this function returns immediately without waiting | ||
1574 | * for the new rq to be completed. This is VERY DANGEROUS, and is | ||
1575 | * intended for careful use by the ATAPI tape/cdrom driver code. | ||
1576 | * | ||
1577 | * If action is ide_end, then the rq is queued at the end of the | ||
1578 | * request queue, and the function returns immediately without waiting | ||
1579 | * for the new rq to be completed. This is again intended for careful | ||
1580 | * use by the ATAPI tape/cdrom driver code. | ||
1581 | */ | 1504 | */ |
1582 | 1505 | ||
1583 | int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action) | 1506 | void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq) |
1584 | { | 1507 | { |
1585 | unsigned long flags; | 1508 | unsigned long flags; |
1586 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | 1509 | ide_hwgroup_t *hwgroup = HWGROUP(drive); |
1587 | DECLARE_COMPLETION_ONSTACK(wait); | ||
1588 | int where = ELEVATOR_INSERT_BACK, err; | ||
1589 | int must_wait = (action == ide_wait || action == ide_head_wait); | ||
1590 | |||
1591 | rq->errors = 0; | ||
1592 | |||
1593 | /* | ||
1594 | * we need to hold an extra reference to request for safe inspection | ||
1595 | * after completion | ||
1596 | */ | ||
1597 | if (must_wait) { | ||
1598 | rq->ref_count++; | ||
1599 | rq->end_io_data = &wait; | ||
1600 | rq->end_io = blk_end_sync_rq; | ||
1601 | } | ||
1602 | 1510 | ||
1603 | spin_lock_irqsave(&ide_lock, flags); | 1511 | spin_lock_irqsave(&ide_lock, flags); |
1604 | if (action == ide_preempt) | 1512 | hwgroup->rq = NULL; |
1605 | hwgroup->rq = NULL; | 1513 | __elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 1); |
1606 | if (action == ide_preempt || action == ide_head_wait) { | 1514 | __generic_unplug_device(drive->queue); |
1607 | where = ELEVATOR_INSERT_FRONT; | ||
1608 | rq->cmd_flags |= REQ_PREEMPT; | ||
1609 | } | ||
1610 | __elv_add_request(drive->queue, rq, where, 0); | ||
1611 | ide_do_request(hwgroup, IDE_NO_IRQ); | ||
1612 | spin_unlock_irqrestore(&ide_lock, flags); | 1515 | spin_unlock_irqrestore(&ide_lock, flags); |
1613 | |||
1614 | err = 0; | ||
1615 | if (must_wait) { | ||
1616 | wait_for_completion(&wait); | ||
1617 | if (rq->errors) | ||
1618 | err = -EIO; | ||
1619 | |||
1620 | blk_put_request(rq); | ||
1621 | } | ||
1622 | |||
1623 | return err; | ||
1624 | } | 1516 | } |
1625 | 1517 | ||
1626 | EXPORT_SYMBOL(ide_do_drive_cmd); | 1518 | EXPORT_SYMBOL(ide_do_drive_cmd); |
@@ -1637,6 +1529,8 @@ void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma) | |||
1637 | task.tf.lbah = (bcount >> 8) & 0xff; | 1529 | task.tf.lbah = (bcount >> 8) & 0xff; |
1638 | 1530 | ||
1639 | ide_tf_dump(drive->name, &task.tf); | 1531 | ide_tf_dump(drive->name, &task.tf); |
1532 | ide_set_irq(drive, 1); | ||
1533 | SELECT_MASK(drive, 0); | ||
1640 | drive->hwif->tf_load(drive, &task); | 1534 | drive->hwif->tf_load(drive, &task); |
1641 | } | 1535 | } |
1642 | 1536 | ||
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 0daf923541ff..44aaec256a30 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -42,7 +42,7 @@ static void ide_outb (u8 val, unsigned long port) | |||
42 | outb(val, port); | 42 | outb(val, port); |
43 | } | 43 | } |
44 | 44 | ||
45 | static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) | 45 | static void ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port) |
46 | { | 46 | { |
47 | outb(addr, port); | 47 | outb(addr, port); |
48 | } | 48 | } |
@@ -68,7 +68,7 @@ static void ide_mm_outb (u8 value, unsigned long port) | |||
68 | writeb(value, (void __iomem *) port); | 68 | writeb(value, (void __iomem *) port); |
69 | } | 69 | } |
70 | 70 | ||
71 | static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port) | 71 | static void ide_mm_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port) |
72 | { | 72 | { |
73 | writeb(value, (void __iomem *) port); | 73 | writeb(value, (void __iomem *) port); |
74 | } | 74 | } |
@@ -95,7 +95,7 @@ void SELECT_DRIVE (ide_drive_t *drive) | |||
95 | hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); | 95 | hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); |
96 | } | 96 | } |
97 | 97 | ||
98 | static void SELECT_MASK(ide_drive_t *drive, int mask) | 98 | void SELECT_MASK(ide_drive_t *drive, int mask) |
99 | { | 99 | { |
100 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; | 100 | const struct ide_port_ops *port_ops = drive->hwif->port_ops; |
101 | 101 | ||
@@ -120,11 +120,6 @@ static void ide_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
120 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | 120 | if (task->tf_flags & IDE_TFLAG_FLAGGED) |
121 | HIHI = 0xFF; | 121 | HIHI = 0xFF; |
122 | 122 | ||
123 | ide_set_irq(drive, 1); | ||
124 | |||
125 | if ((task->tf_flags & IDE_TFLAG_NO_SELECT_MASK) == 0) | ||
126 | SELECT_MASK(drive, 0); | ||
127 | |||
128 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { | 123 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) { |
129 | u16 data = (tf->hob_data << 8) | tf->data; | 124 | u16 data = (tf->hob_data << 8) | tf->data; |
130 | 125 | ||
@@ -191,7 +186,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
191 | } | 186 | } |
192 | 187 | ||
193 | /* be sure we're looking at the low order bits */ | 188 | /* be sure we're looking at the low order bits */ |
194 | tf_outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 189 | tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
195 | 190 | ||
196 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 191 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
197 | tf->nsect = tf_inb(io_ports->nsect_addr); | 192 | tf->nsect = tf_inb(io_ports->nsect_addr); |
@@ -205,7 +200,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
205 | tf->device = tf_inb(io_ports->device_addr); | 200 | tf->device = tf_inb(io_ports->device_addr); |
206 | 201 | ||
207 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 202 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
208 | tf_outb(drive->ctl | 0x80, io_ports->ctl_addr); | 203 | tf_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
209 | 204 | ||
210 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 205 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
211 | tf->hob_feature = tf_inb(io_ports->feature_addr); | 206 | tf->hob_feature = tf_inb(io_ports->feature_addr); |
@@ -689,9 +684,9 @@ int ide_driveid_update(ide_drive_t *drive) | |||
689 | */ | 684 | */ |
690 | 685 | ||
691 | SELECT_MASK(drive, 1); | 686 | SELECT_MASK(drive, 1); |
692 | ide_set_irq(drive, 1); | 687 | ide_set_irq(drive, 0); |
693 | msleep(50); | 688 | msleep(50); |
694 | hwif->OUTBSYNC(drive, WIN_IDENTIFY, hwif->io_ports.command_addr); | 689 | hwif->OUTBSYNC(hwif, WIN_IDENTIFY, hwif->io_ports.command_addr); |
695 | timeout = jiffies + WAIT_WORSTCASE; | 690 | timeout = jiffies + WAIT_WORSTCASE; |
696 | do { | 691 | do { |
697 | if (time_after(jiffies, timeout)) { | 692 | if (time_after(jiffies, timeout)) { |
@@ -744,9 +739,6 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
744 | int error = 0; | 739 | int error = 0; |
745 | u8 stat; | 740 | u8 stat; |
746 | 741 | ||
747 | // while (HWGROUP(drive)->busy) | ||
748 | // msleep(50); | ||
749 | |||
750 | #ifdef CONFIG_BLK_DEV_IDEDMA | 742 | #ifdef CONFIG_BLK_DEV_IDEDMA |
751 | if (hwif->dma_ops) /* check if host supports DMA */ | 743 | if (hwif->dma_ops) /* check if host supports DMA */ |
752 | hwif->dma_ops->dma_host_set(drive, 0); | 744 | hwif->dma_ops->dma_host_set(drive, 0); |
@@ -781,7 +773,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
781 | ide_set_irq(drive, 0); | 773 | ide_set_irq(drive, 0); |
782 | hwif->OUTB(speed, io_ports->nsect_addr); | 774 | hwif->OUTB(speed, io_ports->nsect_addr); |
783 | hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr); | 775 | hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr); |
784 | hwif->OUTBSYNC(drive, WIN_SETFEATURES, io_ports->command_addr); | 776 | hwif->OUTBSYNC(hwif, WIN_SETFEATURES, io_ports->command_addr); |
785 | if (drive->quirk_list == 2) | 777 | if (drive->quirk_list == 2) |
786 | ide_set_irq(drive, 1); | 778 | ide_set_irq(drive, 1); |
787 | 779 | ||
@@ -889,7 +881,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler, | |||
889 | 881 | ||
890 | spin_lock_irqsave(&ide_lock, flags); | 882 | spin_lock_irqsave(&ide_lock, flags); |
891 | __ide_set_handler(drive, handler, timeout, expiry); | 883 | __ide_set_handler(drive, handler, timeout, expiry); |
892 | hwif->OUTBSYNC(drive, cmd, hwif->io_ports.command_addr); | 884 | hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr); |
893 | /* | 885 | /* |
894 | * Drive takes 400nS to respond, we must avoid the IRQ being | 886 | * Drive takes 400nS to respond, we must avoid the IRQ being |
895 | * serviced before that. | 887 | * serviced before that. |
@@ -907,12 +899,20 @@ void ide_execute_pkt_cmd(ide_drive_t *drive) | |||
907 | unsigned long flags; | 899 | unsigned long flags; |
908 | 900 | ||
909 | spin_lock_irqsave(&ide_lock, flags); | 901 | spin_lock_irqsave(&ide_lock, flags); |
910 | hwif->OUTBSYNC(drive, WIN_PACKETCMD, hwif->io_ports.command_addr); | 902 | hwif->OUTBSYNC(hwif, WIN_PACKETCMD, hwif->io_ports.command_addr); |
911 | ndelay(400); | 903 | ndelay(400); |
912 | spin_unlock_irqrestore(&ide_lock, flags); | 904 | spin_unlock_irqrestore(&ide_lock, flags); |
913 | } | 905 | } |
914 | EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); | 906 | EXPORT_SYMBOL_GPL(ide_execute_pkt_cmd); |
915 | 907 | ||
908 | static 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 | |||
916 | /* needed below */ | 916 | /* needed below */ |
917 | static ide_startstop_t do_reset1 (ide_drive_t *, int); | 917 | static ide_startstop_t do_reset1 (ide_drive_t *, int); |
918 | 918 | ||
@@ -948,7 +948,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) | |||
948 | } | 948 | } |
949 | /* done polling */ | 949 | /* done polling */ |
950 | hwgroup->polling = 0; | 950 | hwgroup->polling = 0; |
951 | hwgroup->resetting = 0; | 951 | ide_complete_drive_reset(drive, 0); |
952 | return ide_stopped; | 952 | return ide_stopped; |
953 | } | 953 | } |
954 | 954 | ||
@@ -964,12 +964,14 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
964 | ide_hwif_t *hwif = HWIF(drive); | 964 | ide_hwif_t *hwif = HWIF(drive); |
965 | const struct ide_port_ops *port_ops = hwif->port_ops; | 965 | const struct ide_port_ops *port_ops = hwif->port_ops; |
966 | u8 tmp; | 966 | u8 tmp; |
967 | int err = 0; | ||
967 | 968 | ||
968 | if (port_ops && port_ops->reset_poll) { | 969 | if (port_ops && port_ops->reset_poll) { |
969 | if (port_ops->reset_poll(drive)) { | 970 | err = port_ops->reset_poll(drive); |
971 | if (err) { | ||
970 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", | 972 | printk(KERN_ERR "%s: host reset_poll failure for %s.\n", |
971 | hwif->name, drive->name); | 973 | hwif->name, drive->name); |
972 | return ide_stopped; | 974 | goto out; |
973 | } | 975 | } |
974 | } | 976 | } |
975 | 977 | ||
@@ -983,6 +985,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
983 | } | 985 | } |
984 | 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); |
985 | drive->failures++; | 987 | drive->failures++; |
988 | err = -EIO; | ||
986 | } else { | 989 | } else { |
987 | printk("%s: reset: ", hwif->name); | 990 | printk("%s: reset: ", hwif->name); |
988 | tmp = ide_read_error(drive); | 991 | tmp = ide_read_error(drive); |
@@ -1009,10 +1012,12 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
1009 | if (tmp & 0x80) | 1012 | if (tmp & 0x80) |
1010 | printk("; slave: failed"); | 1013 | printk("; slave: failed"); |
1011 | printk("\n"); | 1014 | printk("\n"); |
1015 | err = -EIO; | ||
1012 | } | 1016 | } |
1013 | } | 1017 | } |
1018 | out: | ||
1014 | hwgroup->polling = 0; /* done polling */ | 1019 | hwgroup->polling = 0; /* done polling */ |
1015 | hwgroup->resetting = 0; /* done reset attempt */ | 1020 | ide_complete_drive_reset(drive, err); |
1016 | return ide_stopped; | 1021 | return ide_stopped; |
1017 | } | 1022 | } |
1018 | 1023 | ||
@@ -1098,11 +1103,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1098 | 1103 | ||
1099 | /* For an ATAPI device, first try an ATAPI SRST. */ | 1104 | /* For an ATAPI device, first try an ATAPI SRST. */ |
1100 | if (drive->media != ide_disk && !do_not_try_atapi) { | 1105 | if (drive->media != ide_disk && !do_not_try_atapi) { |
1101 | hwgroup->resetting = 1; | ||
1102 | pre_reset(drive); | 1106 | pre_reset(drive); |
1103 | SELECT_DRIVE(drive); | 1107 | SELECT_DRIVE(drive); |
1104 | udelay (20); | 1108 | udelay (20); |
1105 | hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr); | 1109 | hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr); |
1106 | ndelay(400); | 1110 | ndelay(400); |
1107 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1111 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
1108 | hwgroup->polling = 1; | 1112 | hwgroup->polling = 1; |
@@ -1120,10 +1124,10 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1120 | 1124 | ||
1121 | if (io_ports->ctl_addr == 0) { | 1125 | if (io_ports->ctl_addr == 0) { |
1122 | spin_unlock_irqrestore(&ide_lock, flags); | 1126 | spin_unlock_irqrestore(&ide_lock, flags); |
1127 | ide_complete_drive_reset(drive, -ENXIO); | ||
1123 | return ide_stopped; | 1128 | return ide_stopped; |
1124 | } | 1129 | } |
1125 | 1130 | ||
1126 | hwgroup->resetting = 1; | ||
1127 | /* | 1131 | /* |
1128 | * Note that we also set nIEN while resetting the device, | 1132 | * Note that we also set nIEN while resetting the device, |
1129 | * to mask unwanted interrupts from the interface during the reset. | 1133 | * to mask unwanted interrupts from the interface during the reset. |
@@ -1133,14 +1137,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
1133 | * recover from reset very quickly, saving us the first 50ms wait time. | 1137 | * recover from reset very quickly, saving us the first 50ms wait time. |
1134 | */ | 1138 | */ |
1135 | /* set SRST and nIEN */ | 1139 | /* set SRST and nIEN */ |
1136 | hwif->OUTBSYNC(drive, drive->ctl|6, io_ports->ctl_addr); | 1140 | hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | 6, io_ports->ctl_addr); |
1137 | /* more than enough time */ | 1141 | /* more than enough time */ |
1138 | udelay(10); | 1142 | udelay(10); |
1139 | if (drive->quirk_list == 2) | 1143 | if (drive->quirk_list == 2) |
1140 | ctl = drive->ctl; /* clear SRST and nIEN */ | 1144 | ctl = ATA_DEVCTL_OBS; /* clear SRST and nIEN */ |
1141 | else | 1145 | else |
1142 | ctl = drive->ctl | 2; /* clear SRST, leave nIEN */ | 1146 | ctl = ATA_DEVCTL_OBS | 2; /* clear SRST, leave nIEN */ |
1143 | hwif->OUTBSYNC(drive, ctl, io_ports->ctl_addr); | 1147 | hwif->OUTBSYNC(hwif, ctl, io_ports->ctl_addr); |
1144 | /* more than enough time */ | 1148 | /* more than enough time */ |
1145 | udelay(10); | 1149 | udelay(10); |
1146 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1150 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
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 | |||
24 | static const char *udma_str[] = | 9 | static 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 | */ | ||
99 | const 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 | |||
108 | EXPORT_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 | */ | ||
121 | static 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 | |||
195 | static 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 | |||
206 | unsigned 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 | |||
227 | EXPORT_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 | |||
11 | static 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 | |||
85 | int 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 380fa0c8cc84..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 | ||
42 | static 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 |
@@ -293,7 +295,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
293 | hwif->OUTB(0, io_ports->feature_addr); | 295 | hwif->OUTB(0, io_ports->feature_addr); |
294 | 296 | ||
295 | /* ask drive for ID */ | 297 | /* ask drive for ID */ |
296 | hwif->OUTBSYNC(drive, cmd, io_ports->command_addr); | 298 | hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr); |
297 | 299 | ||
298 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 300 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
299 | timeout += jiffies; | 301 | timeout += jiffies; |
@@ -478,9 +480,9 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
478 | printk(KERN_ERR "%s: no response (status = 0x%02x), " | 480 | printk(KERN_ERR "%s: no response (status = 0x%02x), " |
479 | "resetting drive\n", drive->name, stat); | 481 | "resetting drive\n", drive->name, stat); |
480 | msleep(50); | 482 | msleep(50); |
481 | hwif->OUTB(drive->select.all, io_ports->device_addr); | 483 | SELECT_DRIVE(drive); |
482 | msleep(50); | 484 | msleep(50); |
483 | hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr); | 485 | hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr); |
484 | (void)ide_busy_sleep(hwif); | 486 | (void)ide_busy_sleep(hwif); |
485 | rc = try_to_identify(drive, cmd); | 487 | rc = try_to_identify(drive, cmd); |
486 | } | 488 | } |
@@ -516,7 +518,7 @@ static void enable_nest (ide_drive_t *drive) | |||
516 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); | 518 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); |
517 | SELECT_DRIVE(drive); | 519 | SELECT_DRIVE(drive); |
518 | msleep(50); | 520 | msleep(50); |
519 | hwif->OUTBSYNC(drive, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); | 521 | hwif->OUTBSYNC(hwif, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); |
520 | 522 | ||
521 | if (ide_busy_sleep(hwif)) { | 523 | if (ide_busy_sleep(hwif)) { |
522 | printk(KERN_CONT "failed (timeout)\n"); | 524 | printk(KERN_CONT "failed (timeout)\n"); |
@@ -646,8 +648,6 @@ static int ide_register_port(ide_hwif_t *hwif) | |||
646 | goto out; | 648 | goto out; |
647 | } | 649 | } |
648 | 650 | ||
649 | get_device(&hwif->gendev); | ||
650 | |||
651 | hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, | 651 | hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, |
652 | MKDEV(0, 0), hwif, hwif->name); | 652 | MKDEV(0, 0), hwif, hwif->name); |
653 | if (IS_ERR(hwif->portdev)) { | 653 | if (IS_ERR(hwif->portdev)) { |
@@ -1067,7 +1067,7 @@ static int init_irq (ide_hwif_t *hwif) | |||
1067 | 1067 | ||
1068 | if (io_ports->ctl_addr) | 1068 | if (io_ports->ctl_addr) |
1069 | /* clear nIEN */ | 1069 | /* clear nIEN */ |
1070 | hwif->OUTB(0x08, io_ports->ctl_addr); | 1070 | hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS, io_ports->ctl_addr); |
1071 | 1071 | ||
1072 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) | 1072 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) |
1073 | goto out_unlink; | 1073 | goto out_unlink; |
@@ -1220,16 +1220,12 @@ static void drive_release_dev (struct device *dev) | |||
1220 | complete(&drive->gendev_rel_comp); | 1220 | complete(&drive->gendev_rel_comp); |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | #ifndef ide_default_irq | ||
1224 | #define ide_default_irq(irq) 0 | ||
1225 | #endif | ||
1226 | |||
1227 | static int hwif_init(ide_hwif_t *hwif) | 1223 | static int hwif_init(ide_hwif_t *hwif) |
1228 | { | 1224 | { |
1229 | int old_irq; | 1225 | int old_irq; |
1230 | 1226 | ||
1231 | if (!hwif->irq) { | 1227 | if (!hwif->irq) { |
1232 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); | 1228 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
1233 | if (!hwif->irq) { | 1229 | if (!hwif->irq) { |
1234 | printk("%s: DISABLED, NO IRQ\n", hwif->name); | 1230 | printk("%s: DISABLED, NO IRQ\n", hwif->name); |
1235 | return 0; | 1231 | return 0; |
@@ -1259,7 +1255,7 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1259 | * It failed to initialise. Find the default IRQ for | 1255 | * It failed to initialise. Find the default IRQ for |
1260 | * this port and try that. | 1256 | * this port and try that. |
1261 | */ | 1257 | */ |
1262 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); | 1258 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
1263 | if (!hwif->irq) { | 1259 | if (!hwif->irq) { |
1264 | printk("%s: Disabled unable to get IRQ %d.\n", | 1260 | printk("%s: Disabled unable to get IRQ %d.\n", |
1265 | hwif->name, old_irq); | 1261 | hwif->name, old_irq); |
@@ -1324,10 +1320,10 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1324 | drive->unmask = 1; | 1320 | drive->unmask = 1; |
1325 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) | 1321 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) |
1326 | drive->no_unmask = 1; | 1322 | drive->no_unmask = 1; |
1327 | } | ||
1328 | 1323 | ||
1329 | if (port_ops && port_ops->port_init_devs) | 1324 | if (port_ops && port_ops->init_dev) |
1330 | port_ops->port_init_devs(hwif); | 1325 | port_ops->init_dev(drive); |
1326 | } | ||
1331 | } | 1327 | } |
1332 | 1328 | ||
1333 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, | 1329 | static void ide_init_port(ide_hwif_t *hwif, unsigned int port, |
@@ -1479,22 +1475,29 @@ ide_hwif_t *ide_find_port_slot(const struct ide_port_info *d) | |||
1479 | for (; i < MAX_HWIFS; i++) { | 1475 | for (; i < MAX_HWIFS; i++) { |
1480 | hwif = &ide_hwifs[i]; | 1476 | hwif = &ide_hwifs[i]; |
1481 | if (hwif->chipset == ide_unknown) | 1477 | if (hwif->chipset == ide_unknown) |
1482 | return hwif; | 1478 | goto out_found; |
1483 | } | 1479 | } |
1484 | } else { | 1480 | } else { |
1485 | for (i = 2; i < MAX_HWIFS; i++) { | 1481 | for (i = 2; i < MAX_HWIFS; i++) { |
1486 | hwif = &ide_hwifs[i]; | 1482 | hwif = &ide_hwifs[i]; |
1487 | if (hwif->chipset == ide_unknown) | 1483 | if (hwif->chipset == ide_unknown) |
1488 | return hwif; | 1484 | goto out_found; |
1489 | } | 1485 | } |
1490 | for (i = 0; i < 2 && i < MAX_HWIFS; i++) { | 1486 | for (i = 0; i < 2 && i < MAX_HWIFS; i++) { |
1491 | hwif = &ide_hwifs[i]; | 1487 | hwif = &ide_hwifs[i]; |
1492 | if (hwif->chipset == ide_unknown) | 1488 | if (hwif->chipset == ide_unknown) |
1493 | return hwif; | 1489 | goto out_found; |
1494 | } | 1490 | } |
1495 | } | 1491 | } |
1496 | 1492 | ||
1493 | printk(KERN_ERR "%s: no free slot for interface\n", | ||
1494 | d ? d->name : "ide"); | ||
1495 | |||
1497 | return NULL; | 1496 | return NULL; |
1497 | |||
1498 | out_found: | ||
1499 | ide_init_port_data(hwif, i); | ||
1500 | return hwif; | ||
1498 | } | 1501 | } |
1499 | EXPORT_SYMBOL_GPL(ide_find_port_slot); | 1502 | EXPORT_SYMBOL_GPL(ide_find_port_slot); |
1500 | 1503 | ||
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 1e1f26331a24..b711ab96e287 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -144,9 +144,6 @@ enum { | |||
144 | 144 | ||
145 | /*************************** End of tunable parameters ***********************/ | 145 | /*************************** End of tunable parameters ***********************/ |
146 | 146 | ||
147 | /* Read/Write error simulation */ | ||
148 | #define SIMULATE_ERRORS 0 | ||
149 | |||
150 | /* tape directions */ | 147 | /* tape directions */ |
151 | enum { | 148 | enum { |
152 | IDETAPE_DIR_NONE = (1 << 0), | 149 | IDETAPE_DIR_NONE = (1 << 0), |
@@ -442,7 +439,7 @@ static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
442 | } | 439 | } |
443 | } | 440 | } |
444 | 441 | ||
445 | static void idetape_update_buffers(struct ide_atapi_pc *pc) | 442 | static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc) |
446 | { | 443 | { |
447 | struct idetape_bh *bh = pc->bh; | 444 | struct idetape_bh *bh = pc->bh; |
448 | int count; | 445 | int count; |
@@ -506,18 +503,6 @@ static struct request *idetape_next_rq_storage(ide_drive_t *drive) | |||
506 | return (&tape->rq_stack[tape->rq_stack_index++]); | 503 | return (&tape->rq_stack[tape->rq_stack_index++]); |
507 | } | 504 | } |
508 | 505 | ||
509 | static void idetape_init_pc(struct ide_atapi_pc *pc) | ||
510 | { | ||
511 | memset(pc->c, 0, 12); | ||
512 | pc->retries = 0; | ||
513 | pc->flags = 0; | ||
514 | pc->req_xfer = 0; | ||
515 | pc->buf = pc->pc_buf; | ||
516 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; | ||
517 | pc->bh = NULL; | ||
518 | pc->b_data = NULL; | ||
519 | } | ||
520 | |||
521 | /* | 506 | /* |
522 | * called on each failed packet command retry to analyze the request sense. We | 507 | * called on each failed packet command retry to analyze the request sense. We |
523 | * currently do not utilize this information. | 508 | * currently do not utilize this information. |
@@ -538,8 +523,8 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
538 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 523 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
539 | pc->xferred = pc->req_xfer - | 524 | pc->xferred = pc->req_xfer - |
540 | tape->blk_size * | 525 | tape->blk_size * |
541 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); | 526 | get_unaligned_be32(&sense[3]); |
542 | idetape_update_buffers(pc); | 527 | idetape_update_buffers(drive, pc); |
543 | } | 528 | } |
544 | 529 | ||
545 | /* | 530 | /* |
@@ -634,21 +619,78 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
634 | return 0; | 619 | return 0; |
635 | } | 620 | } |
636 | 621 | ||
637 | static ide_startstop_t idetape_request_sense_callback(ide_drive_t *drive) | 622 | static void ide_tape_callback(ide_drive_t *drive) |
638 | { | 623 | { |
639 | idetape_tape_t *tape = drive->driver_data; | 624 | idetape_tape_t *tape = drive->driver_data; |
625 | struct ide_atapi_pc *pc = tape->pc; | ||
626 | int uptodate = pc->error ? 0 : 1; | ||
640 | 627 | ||
641 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 628 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
642 | 629 | ||
643 | if (!tape->pc->error) { | 630 | if (tape->failed_pc == pc) |
644 | idetape_analyze_error(drive, tape->pc->buf); | 631 | tape->failed_pc = NULL; |
645 | idetape_end_request(drive, 1, 0); | 632 | |
646 | } else { | 633 | if (pc->c[0] == REQUEST_SENSE) { |
647 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " | 634 | if (uptodate) |
648 | "Aborting request!\n"); | 635 | idetape_analyze_error(drive, pc->buf); |
649 | idetape_end_request(drive, 0, 0); | 636 | else |
637 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " | ||
638 | "itself - Aborting request!\n"); | ||
639 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | ||
640 | struct request *rq = drive->hwif->hwgroup->rq; | ||
641 | int blocks = pc->xferred / tape->blk_size; | ||
642 | |||
643 | tape->avg_size += blocks * tape->blk_size; | ||
644 | |||
645 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { | ||
646 | tape->avg_speed = tape->avg_size * HZ / | ||
647 | (jiffies - tape->avg_time) / 1024; | ||
648 | tape->avg_size = 0; | ||
649 | tape->avg_time = jiffies; | ||
650 | } | ||
651 | |||
652 | tape->first_frame += blocks; | ||
653 | rq->current_nr_sectors -= blocks; | ||
654 | |||
655 | if (pc->error) | ||
656 | uptodate = pc->error; | ||
657 | } else if (pc->c[0] == READ_POSITION && uptodate) { | ||
658 | u8 *readpos = tape->pc->buf; | ||
659 | |||
660 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
661 | (readpos[0] & 0x80) ? "Yes" : "No"); | ||
662 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
663 | (readpos[0] & 0x40) ? "Yes" : "No"); | ||
664 | |||
665 | if (readpos[0] & 0x4) { | ||
666 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
667 | "to the tape\n"); | ||
668 | clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
669 | uptodate = 0; | ||
670 | } else { | ||
671 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
672 | be32_to_cpu(*(u32 *)&readpos[4])); | ||
673 | |||
674 | tape->partition = readpos[1]; | ||
675 | tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]); | ||
676 | set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
677 | } | ||
650 | } | 678 | } |
651 | return ide_stopped; | 679 | |
680 | idetape_end_request(drive, uptodate, 0); | ||
681 | } | ||
682 | |||
683 | static void idetape_init_pc(struct ide_atapi_pc *pc) | ||
684 | { | ||
685 | memset(pc->c, 0, 12); | ||
686 | pc->retries = 0; | ||
687 | pc->flags = 0; | ||
688 | pc->req_xfer = 0; | ||
689 | pc->buf = pc->pc_buf; | ||
690 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; | ||
691 | pc->bh = NULL; | ||
692 | pc->b_data = NULL; | ||
693 | pc->callback = ide_tape_callback; | ||
652 | } | 694 | } |
653 | 695 | ||
654 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) | 696 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) |
@@ -657,7 +699,6 @@ static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) | |||
657 | pc->c[0] = REQUEST_SENSE; | 699 | pc->c[0] = REQUEST_SENSE; |
658 | pc->c[4] = 20; | 700 | pc->c[4] = 20; |
659 | pc->req_xfer = 20; | 701 | pc->req_xfer = 20; |
660 | pc->idetape_callback = &idetape_request_sense_callback; | ||
661 | } | 702 | } |
662 | 703 | ||
663 | static void idetape_init_rq(struct request *rq, u8 cmd) | 704 | static void idetape_init_rq(struct request *rq, u8 cmd) |
@@ -688,9 +729,10 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
688 | struct ide_tape_obj *tape = drive->driver_data; | 729 | struct ide_tape_obj *tape = drive->driver_data; |
689 | 730 | ||
690 | idetape_init_rq(rq, REQ_IDETAPE_PC1); | 731 | idetape_init_rq(rq, REQ_IDETAPE_PC1); |
732 | rq->cmd_flags |= REQ_PREEMPT; | ||
691 | rq->buffer = (char *) pc; | 733 | rq->buffer = (char *) pc; |
692 | rq->rq_disk = tape->disk; | 734 | rq->rq_disk = tape->disk; |
693 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 735 | ide_do_drive_cmd(drive, rq); |
694 | } | 736 | } |
695 | 737 | ||
696 | /* | 738 | /* |
@@ -698,7 +740,7 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
698 | * last packet command. We queue a request sense packet command in | 740 | * last packet command. We queue a request sense packet command in |
699 | * the head of the request list. | 741 | * the head of the request list. |
700 | */ | 742 | */ |
701 | static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) | 743 | static void idetape_retry_pc(ide_drive_t *drive) |
702 | { | 744 | { |
703 | idetape_tape_t *tape = drive->driver_data; | 745 | idetape_tape_t *tape = drive->driver_data; |
704 | struct ide_atapi_pc *pc; | 746 | struct ide_atapi_pc *pc; |
@@ -710,7 +752,6 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) | |||
710 | idetape_create_request_sense_cmd(pc); | 752 | idetape_create_request_sense_cmd(pc); |
711 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); | 753 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); |
712 | idetape_queue_pc_head(drive, pc, rq); | 754 | idetape_queue_pc_head(drive, pc, rq); |
713 | return ide_stopped; | ||
714 | } | 755 | } |
715 | 756 | ||
716 | /* | 757 | /* |
@@ -727,7 +768,26 @@ static void idetape_postpone_request(ide_drive_t *drive) | |||
727 | ide_stall_queue(drive, tape->dsc_poll_freq); | 768 | ide_stall_queue(drive, tape->dsc_poll_freq); |
728 | } | 769 | } |
729 | 770 | ||
730 | typedef void idetape_io_buf(ide_drive_t *, struct ide_atapi_pc *, unsigned int); | 771 | static void ide_tape_handle_dsc(ide_drive_t *drive) |
772 | { | ||
773 | idetape_tape_t *tape = drive->driver_data; | ||
774 | |||
775 | /* Media access command */ | ||
776 | tape->dsc_polling_start = jiffies; | ||
777 | tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; | ||
778 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; | ||
779 | /* Allow ide.c to handle other requests */ | ||
780 | idetape_postpone_request(drive); | ||
781 | } | ||
782 | |||
783 | static void ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
784 | unsigned int bcount, int write) | ||
785 | { | ||
786 | if (write) | ||
787 | idetape_output_buffers(drive, pc, bcount); | ||
788 | else | ||
789 | idetape_input_buffers(drive, pc, bcount); | ||
790 | } | ||
731 | 791 | ||
732 | /* | 792 | /* |
733 | * This is the usual interrupt handler which will be called during a packet | 793 | * This is the usual interrupt handler which will be called during a packet |
@@ -738,169 +798,11 @@ typedef void idetape_io_buf(ide_drive_t *, struct ide_atapi_pc *, unsigned int); | |||
738 | */ | 798 | */ |
739 | static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | 799 | static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) |
740 | { | 800 | { |
741 | ide_hwif_t *hwif = drive->hwif; | ||
742 | idetape_tape_t *tape = drive->driver_data; | 801 | idetape_tape_t *tape = drive->driver_data; |
743 | struct ide_atapi_pc *pc = tape->pc; | ||
744 | xfer_func_t *xferfunc; | ||
745 | idetape_io_buf *iobuf; | ||
746 | unsigned int temp; | ||
747 | #if SIMULATE_ERRORS | ||
748 | static int error_sim_count; | ||
749 | #endif | ||
750 | u16 bcount; | ||
751 | u8 stat, ireason; | ||
752 | |||
753 | debug_log(DBG_PROCS, "Enter %s - interrupt handler\n", __func__); | ||
754 | 802 | ||
755 | /* Clear the interrupt */ | 803 | return ide_pc_intr(drive, tape->pc, idetape_pc_intr, IDETAPE_WAIT_CMD, |
756 | stat = ide_read_status(drive); | 804 | NULL, idetape_update_buffers, idetape_retry_pc, |
757 | 805 | ide_tape_handle_dsc, ide_tape_io_buffers); | |
758 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
759 | if (hwif->dma_ops->dma_end(drive) || (stat & ERR_STAT)) { | ||
760 | /* | ||
761 | * A DMA error is sometimes expected. For example, | ||
762 | * if the tape is crossing a filemark during a | ||
763 | * READ command, it will issue an irq and position | ||
764 | * itself before the filemark, so that only a partial | ||
765 | * data transfer will occur (which causes the DMA | ||
766 | * error). In that case, we will later ask the tape | ||
767 | * how much bytes of the original request were | ||
768 | * actually transferred (we can't receive that | ||
769 | * information from the DMA engine on most chipsets). | ||
770 | */ | ||
771 | |||
772 | /* | ||
773 | * On the contrary, a DMA error is never expected; | ||
774 | * it usually indicates a hardware error or abort. | ||
775 | * If the tape crosses a filemark during a READ | ||
776 | * command, it will issue an irq and position itself | ||
777 | * after the filemark (not before). Only a partial | ||
778 | * data transfer will occur, but no DMA error. | ||
779 | * (AS, 19 Apr 2001) | ||
780 | */ | ||
781 | pc->flags |= PC_FLAG_DMA_ERROR; | ||
782 | } else { | ||
783 | pc->xferred = pc->req_xfer; | ||
784 | idetape_update_buffers(pc); | ||
785 | } | ||
786 | debug_log(DBG_PROCS, "DMA finished\n"); | ||
787 | |||
788 | } | ||
789 | |||
790 | /* No more interrupts */ | ||
791 | if ((stat & DRQ_STAT) == 0) { | ||
792 | debug_log(DBG_SENSE, "Packet command completed, %d bytes" | ||
793 | " transferred\n", pc->xferred); | ||
794 | |||
795 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
796 | local_irq_enable(); | ||
797 | |||
798 | #if SIMULATE_ERRORS | ||
799 | if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) && | ||
800 | (++error_sim_count % 100) == 0) { | ||
801 | printk(KERN_INFO "ide-tape: %s: simulating error\n", | ||
802 | tape->name); | ||
803 | stat |= ERR_STAT; | ||
804 | } | ||
805 | #endif | ||
806 | if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) | ||
807 | stat &= ~ERR_STAT; | ||
808 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | ||
809 | /* Error detected */ | ||
810 | debug_log(DBG_ERR, "%s: I/O error\n", tape->name); | ||
811 | |||
812 | if (pc->c[0] == REQUEST_SENSE) { | ||
813 | printk(KERN_ERR "ide-tape: I/O error in request" | ||
814 | " sense command\n"); | ||
815 | return ide_do_reset(drive); | ||
816 | } | ||
817 | debug_log(DBG_ERR, "[cmd %x]: check condition\n", | ||
818 | pc->c[0]); | ||
819 | |||
820 | /* Retry operation */ | ||
821 | return idetape_retry_pc(drive); | ||
822 | } | ||
823 | pc->error = 0; | ||
824 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && | ||
825 | (stat & SEEK_STAT) == 0) { | ||
826 | /* Media access command */ | ||
827 | tape->dsc_polling_start = jiffies; | ||
828 | tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST; | ||
829 | tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT; | ||
830 | /* Allow ide.c to handle other requests */ | ||
831 | idetape_postpone_request(drive); | ||
832 | return ide_stopped; | ||
833 | } | ||
834 | if (tape->failed_pc == pc) | ||
835 | tape->failed_pc = NULL; | ||
836 | /* Command finished - Call the callback function */ | ||
837 | return pc->idetape_callback(drive); | ||
838 | } | ||
839 | |||
840 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
841 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
842 | printk(KERN_ERR "ide-tape: The tape wants to issue more " | ||
843 | "interrupts in DMA mode\n"); | ||
844 | printk(KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n"); | ||
845 | ide_dma_off(drive); | ||
846 | return ide_do_reset(drive); | ||
847 | } | ||
848 | /* Get the number of bytes to transfer on this interrupt. */ | ||
849 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
850 | hwif->INB(hwif->io_ports.lbam_addr); | ||
851 | |||
852 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
853 | |||
854 | if (ireason & CD) { | ||
855 | printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); | ||
856 | return ide_do_reset(drive); | ||
857 | } | ||
858 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | ||
859 | /* Hopefully, we will never get here */ | ||
860 | printk(KERN_ERR "ide-tape: We wanted to %s, ", | ||
861 | (ireason & IO) ? "Write" : "Read"); | ||
862 | printk(KERN_ERR "ide-tape: but the tape wants us to %s !\n", | ||
863 | (ireason & IO) ? "Read" : "Write"); | ||
864 | return ide_do_reset(drive); | ||
865 | } | ||
866 | if (!(pc->flags & PC_FLAG_WRITING)) { | ||
867 | /* Reading - Check that we have enough space */ | ||
868 | temp = pc->xferred + bcount; | ||
869 | if (temp > pc->req_xfer) { | ||
870 | if (temp > pc->buf_size) { | ||
871 | printk(KERN_ERR "ide-tape: The tape wants to " | ||
872 | "send us more data than expected " | ||
873 | "- discarding data\n"); | ||
874 | ide_pad_transfer(drive, 0, bcount); | ||
875 | ide_set_handler(drive, &idetape_pc_intr, | ||
876 | IDETAPE_WAIT_CMD, NULL); | ||
877 | return ide_started; | ||
878 | } | ||
879 | debug_log(DBG_SENSE, "The tape wants to send us more " | ||
880 | "data than expected - allowing transfer\n"); | ||
881 | } | ||
882 | iobuf = &idetape_input_buffers; | ||
883 | xferfunc = hwif->input_data; | ||
884 | } else { | ||
885 | iobuf = &idetape_output_buffers; | ||
886 | xferfunc = hwif->output_data; | ||
887 | } | ||
888 | |||
889 | if (pc->bh) | ||
890 | iobuf(drive, pc, bcount); | ||
891 | else | ||
892 | xferfunc(drive, NULL, pc->cur_pos, bcount); | ||
893 | |||
894 | /* Update the current position */ | ||
895 | pc->xferred += bcount; | ||
896 | pc->cur_pos += bcount; | ||
897 | |||
898 | debug_log(DBG_SENSE, "[cmd %x] transferred %d bytes on that intr.\n", | ||
899 | pc->c[0], bcount); | ||
900 | |||
901 | /* And set the interrupt handler again */ | ||
902 | ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); | ||
903 | return ide_started; | ||
904 | } | 806 | } |
905 | 807 | ||
906 | /* | 808 | /* |
@@ -941,56 +843,16 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
941 | */ | 843 | */ |
942 | static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | 844 | static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) |
943 | { | 845 | { |
944 | ide_hwif_t *hwif = drive->hwif; | ||
945 | idetape_tape_t *tape = drive->driver_data; | 846 | idetape_tape_t *tape = drive->driver_data; |
946 | struct ide_atapi_pc *pc = tape->pc; | ||
947 | int retries = 100; | ||
948 | ide_startstop_t startstop; | ||
949 | u8 ireason; | ||
950 | |||
951 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | ||
952 | printk(KERN_ERR "ide-tape: Strange, packet command initiated " | ||
953 | "yet DRQ isn't asserted\n"); | ||
954 | return startstop; | ||
955 | } | ||
956 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
957 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | ||
958 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " | ||
959 | "a packet command, retrying\n"); | ||
960 | udelay(100); | ||
961 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | ||
962 | if (retries == 0) { | ||
963 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " | ||
964 | "issuing a packet command, ignoring\n"); | ||
965 | ireason |= CD; | ||
966 | ireason &= ~IO; | ||
967 | } | ||
968 | } | ||
969 | if ((ireason & CD) == 0 || (ireason & IO)) { | ||
970 | printk(KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing " | ||
971 | "a packet command\n"); | ||
972 | return ide_do_reset(drive); | ||
973 | } | ||
974 | /* Set the interrupt routine */ | ||
975 | ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); | ||
976 | #ifdef CONFIG_BLK_DEV_IDEDMA | ||
977 | /* Begin DMA, if necessary */ | ||
978 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) | ||
979 | hwif->dma_ops->dma_start(drive); | ||
980 | #endif | ||
981 | /* Send the actual packet */ | ||
982 | hwif->output_data(drive, NULL, pc->c, 12); | ||
983 | 847 | ||
984 | return ide_started; | 848 | return ide_transfer_pc(drive, tape->pc, idetape_pc_intr, |
849 | IDETAPE_WAIT_CMD, NULL); | ||
985 | } | 850 | } |
986 | 851 | ||
987 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | 852 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, |
988 | struct ide_atapi_pc *pc) | 853 | struct ide_atapi_pc *pc) |
989 | { | 854 | { |
990 | ide_hwif_t *hwif = drive->hwif; | ||
991 | idetape_tape_t *tape = drive->driver_data; | 855 | idetape_tape_t *tape = drive->driver_data; |
992 | int dma_ok = 0; | ||
993 | u16 bcount; | ||
994 | 856 | ||
995 | if (tape->pc->c[0] == REQUEST_SENSE && | 857 | if (tape->pc->c[0] == REQUEST_SENSE && |
996 | pc->c[0] == REQUEST_SENSE) { | 858 | pc->c[0] == REQUEST_SENSE) { |
@@ -1025,50 +887,15 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
1025 | pc->error = IDETAPE_ERROR_GENERAL; | 887 | pc->error = IDETAPE_ERROR_GENERAL; |
1026 | } | 888 | } |
1027 | tape->failed_pc = NULL; | 889 | tape->failed_pc = NULL; |
1028 | return pc->idetape_callback(drive); | 890 | pc->callback(drive); |
891 | return ide_stopped; | ||
1029 | } | 892 | } |
1030 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 893 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
1031 | 894 | ||
1032 | pc->retries++; | 895 | pc->retries++; |
1033 | /* We haven't transferred any data yet */ | ||
1034 | pc->xferred = 0; | ||
1035 | pc->cur_pos = pc->buf; | ||
1036 | /* Request to transfer the entire buffer at once */ | ||
1037 | bcount = pc->req_xfer; | ||
1038 | |||
1039 | if (pc->flags & PC_FLAG_DMA_ERROR) { | ||
1040 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
1041 | printk(KERN_WARNING "ide-tape: DMA disabled, " | ||
1042 | "reverting to PIO\n"); | ||
1043 | ide_dma_off(drive); | ||
1044 | } | ||
1045 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) | ||
1046 | dma_ok = !hwif->dma_ops->dma_setup(drive); | ||
1047 | |||
1048 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | ||
1049 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); | ||
1050 | |||
1051 | if (dma_ok) | ||
1052 | /* Will begin DMA later */ | ||
1053 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | ||
1054 | if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags)) { | ||
1055 | ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc, | ||
1056 | IDETAPE_WAIT_CMD, NULL); | ||
1057 | return ide_started; | ||
1058 | } else { | ||
1059 | ide_execute_pkt_cmd(drive); | ||
1060 | return idetape_transfer_pc(drive); | ||
1061 | } | ||
1062 | } | ||
1063 | |||
1064 | static ide_startstop_t idetape_pc_callback(ide_drive_t *drive) | ||
1065 | { | ||
1066 | idetape_tape_t *tape = drive->driver_data; | ||
1067 | |||
1068 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1069 | 896 | ||
1070 | idetape_end_request(drive, tape->pc->error ? 0 : 1, 0); | 897 | return ide_issue_pc(drive, pc, idetape_transfer_pc, |
1071 | return ide_stopped; | 898 | IDETAPE_WAIT_CMD, NULL); |
1072 | } | 899 | } |
1073 | 900 | ||
1074 | /* A mode sense command is used to "sense" tape parameters. */ | 901 | /* A mode sense command is used to "sense" tape parameters. */ |
@@ -1096,7 +923,6 @@ static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) | |||
1096 | pc->req_xfer = 24; | 923 | pc->req_xfer = 24; |
1097 | else | 924 | else |
1098 | pc->req_xfer = 50; | 925 | pc->req_xfer = 50; |
1099 | pc->idetape_callback = &idetape_pc_callback; | ||
1100 | } | 926 | } |
1101 | 927 | ||
1102 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | 928 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) |
@@ -1114,80 +940,41 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | |||
1114 | printk(KERN_ERR "ide-tape: %s: I/O error, ", | 940 | printk(KERN_ERR "ide-tape: %s: I/O error, ", |
1115 | tape->name); | 941 | tape->name); |
1116 | /* Retry operation */ | 942 | /* Retry operation */ |
1117 | return idetape_retry_pc(drive); | 943 | idetape_retry_pc(drive); |
944 | return ide_stopped; | ||
1118 | } | 945 | } |
1119 | pc->error = 0; | 946 | pc->error = 0; |
1120 | if (tape->failed_pc == pc) | ||
1121 | tape->failed_pc = NULL; | ||
1122 | } else { | 947 | } else { |
1123 | pc->error = IDETAPE_ERROR_GENERAL; | 948 | pc->error = IDETAPE_ERROR_GENERAL; |
1124 | tape->failed_pc = NULL; | 949 | tape->failed_pc = NULL; |
1125 | } | 950 | } |
1126 | return pc->idetape_callback(drive); | 951 | pc->callback(drive); |
1127 | } | ||
1128 | |||
1129 | static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) | ||
1130 | { | ||
1131 | idetape_tape_t *tape = drive->driver_data; | ||
1132 | struct request *rq = HWGROUP(drive)->rq; | ||
1133 | int blocks = tape->pc->xferred / tape->blk_size; | ||
1134 | |||
1135 | tape->avg_size += blocks * tape->blk_size; | ||
1136 | |||
1137 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { | ||
1138 | tape->avg_speed = tape->avg_size * HZ / | ||
1139 | (jiffies - tape->avg_time) / 1024; | ||
1140 | tape->avg_size = 0; | ||
1141 | tape->avg_time = jiffies; | ||
1142 | } | ||
1143 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1144 | |||
1145 | tape->first_frame += blocks; | ||
1146 | rq->current_nr_sectors -= blocks; | ||
1147 | |||
1148 | if (!tape->pc->error) | ||
1149 | idetape_end_request(drive, 1, 0); | ||
1150 | else | ||
1151 | idetape_end_request(drive, tape->pc->error, 0); | ||
1152 | return ide_stopped; | 952 | return ide_stopped; |
1153 | } | 953 | } |
1154 | 954 | ||
1155 | static void idetape_create_read_cmd(idetape_tape_t *tape, | 955 | static void ide_tape_create_rw_cmd(idetape_tape_t *tape, |
1156 | struct ide_atapi_pc *pc, | 956 | struct ide_atapi_pc *pc, unsigned int length, |
1157 | unsigned int length, struct idetape_bh *bh) | 957 | struct idetape_bh *bh, u8 opcode) |
1158 | { | 958 | { |
1159 | idetape_init_pc(pc); | 959 | idetape_init_pc(pc); |
1160 | pc->c[0] = READ_6; | ||
1161 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 960 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
1162 | pc->c[1] = 1; | 961 | pc->c[1] = 1; |
1163 | pc->idetape_callback = &idetape_rw_callback; | ||
1164 | pc->bh = bh; | 962 | pc->bh = bh; |
1165 | atomic_set(&bh->b_count, 0); | ||
1166 | pc->buf = NULL; | 963 | pc->buf = NULL; |
1167 | pc->buf_size = length * tape->blk_size; | 964 | pc->buf_size = length * tape->blk_size; |
1168 | pc->req_xfer = pc->buf_size; | 965 | pc->req_xfer = pc->buf_size; |
1169 | if (pc->req_xfer == tape->buffer_size) | 966 | if (pc->req_xfer == tape->buffer_size) |
1170 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 967 | pc->flags |= PC_FLAG_DMA_OK; |
1171 | } | ||
1172 | 968 | ||
1173 | static void idetape_create_write_cmd(idetape_tape_t *tape, | 969 | if (opcode == READ_6) { |
1174 | struct ide_atapi_pc *pc, | 970 | pc->c[0] = READ_6; |
1175 | unsigned int length, struct idetape_bh *bh) | 971 | atomic_set(&bh->b_count, 0); |
1176 | { | 972 | } else if (opcode == WRITE_6) { |
1177 | idetape_init_pc(pc); | 973 | pc->c[0] = WRITE_6; |
1178 | pc->c[0] = WRITE_6; | 974 | pc->flags |= PC_FLAG_WRITING; |
1179 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 975 | pc->b_data = bh->b_data; |
1180 | pc->c[1] = 1; | 976 | pc->b_count = atomic_read(&bh->b_count); |
1181 | pc->idetape_callback = &idetape_rw_callback; | 977 | } |
1182 | pc->flags |= PC_FLAG_WRITING; | ||
1183 | pc->bh = bh; | ||
1184 | pc->b_data = bh->b_data; | ||
1185 | pc->b_count = atomic_read(&bh->b_count); | ||
1186 | pc->buf = NULL; | ||
1187 | pc->buf_size = length * tape->blk_size; | ||
1188 | pc->req_xfer = pc->buf_size; | ||
1189 | if (pc->req_xfer == tape->buffer_size) | ||
1190 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | ||
1191 | } | 978 | } |
1192 | 979 | ||
1193 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, | 980 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, |
@@ -1211,8 +998,10 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1211 | } | 998 | } |
1212 | 999 | ||
1213 | /* Retry a failed packet command */ | 1000 | /* Retry a failed packet command */ |
1214 | if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) | 1001 | if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) { |
1215 | return idetape_issue_pc(drive, tape->failed_pc); | 1002 | pc = tape->failed_pc; |
1003 | goto out; | ||
1004 | } | ||
1216 | 1005 | ||
1217 | if (postponed_rq != NULL) | 1006 | if (postponed_rq != NULL) |
1218 | if (rq != postponed_rq) { | 1007 | if (rq != postponed_rq) { |
@@ -1262,14 +1051,16 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1262 | } | 1051 | } |
1263 | if (rq->cmd[0] & REQ_IDETAPE_READ) { | 1052 | if (rq->cmd[0] & REQ_IDETAPE_READ) { |
1264 | pc = idetape_next_pc_storage(drive); | 1053 | pc = idetape_next_pc_storage(drive); |
1265 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, | 1054 | ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors, |
1266 | (struct idetape_bh *)rq->special); | 1055 | (struct idetape_bh *)rq->special, |
1056 | READ_6); | ||
1267 | goto out; | 1057 | goto out; |
1268 | } | 1058 | } |
1269 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 1059 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { |
1270 | pc = idetape_next_pc_storage(drive); | 1060 | pc = idetape_next_pc_storage(drive); |
1271 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, | 1061 | ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors, |
1272 | (struct idetape_bh *)rq->special); | 1062 | (struct idetape_bh *)rq->special, |
1063 | WRITE_6); | ||
1273 | goto out; | 1064 | goto out; |
1274 | } | 1065 | } |
1275 | if (rq->cmd[0] & REQ_IDETAPE_PC1) { | 1066 | if (rq->cmd[0] & REQ_IDETAPE_PC1) { |
@@ -1284,6 +1075,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1284 | } | 1075 | } |
1285 | BUG(); | 1076 | BUG(); |
1286 | out: | 1077 | out: |
1078 | if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags)) | ||
1079 | pc->flags |= PC_FLAG_DRQ_INTERRUPT; | ||
1080 | |||
1287 | return idetape_issue_pc(drive, pc); | 1081 | return idetape_issue_pc(drive, pc); |
1288 | } | 1082 | } |
1289 | 1083 | ||
@@ -1447,40 +1241,6 @@ static void idetape_init_merge_buffer(idetape_tape_t *tape) | |||
1447 | } | 1241 | } |
1448 | } | 1242 | } |
1449 | 1243 | ||
1450 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | ||
1451 | { | ||
1452 | idetape_tape_t *tape = drive->driver_data; | ||
1453 | u8 *readpos = tape->pc->buf; | ||
1454 | |||
1455 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | ||
1456 | |||
1457 | if (!tape->pc->error) { | ||
1458 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
1459 | (readpos[0] & 0x80) ? "Yes" : "No"); | ||
1460 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
1461 | (readpos[0] & 0x40) ? "Yes" : "No"); | ||
1462 | |||
1463 | if (readpos[0] & 0x4) { | ||
1464 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
1465 | "to the tape\n"); | ||
1466 | clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
1467 | idetape_end_request(drive, 0, 0); | ||
1468 | } else { | ||
1469 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
1470 | be32_to_cpu(*(u32 *)&readpos[4])); | ||
1471 | |||
1472 | tape->partition = readpos[1]; | ||
1473 | tape->first_frame = | ||
1474 | be32_to_cpu(*(u32 *)&readpos[4]); | ||
1475 | set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); | ||
1476 | idetape_end_request(drive, 1, 0); | ||
1477 | } | ||
1478 | } else { | ||
1479 | idetape_end_request(drive, 0, 0); | ||
1480 | } | ||
1481 | return ide_stopped; | ||
1482 | } | ||
1483 | |||
1484 | /* | 1244 | /* |
1485 | * Write a filemark if write_filemark=1. Flush the device buffers without | 1245 | * Write a filemark if write_filemark=1. Flush the device buffers without |
1486 | * writing a filemark otherwise. | 1246 | * writing a filemark otherwise. |
@@ -1492,14 +1252,12 @@ static void idetape_create_write_filemark_cmd(ide_drive_t *drive, | |||
1492 | pc->c[0] = WRITE_FILEMARKS; | 1252 | pc->c[0] = WRITE_FILEMARKS; |
1493 | pc->c[4] = write_filemark; | 1253 | pc->c[4] = write_filemark; |
1494 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1254 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1495 | pc->idetape_callback = &idetape_pc_callback; | ||
1496 | } | 1255 | } |
1497 | 1256 | ||
1498 | static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | 1257 | static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) |
1499 | { | 1258 | { |
1500 | idetape_init_pc(pc); | 1259 | idetape_init_pc(pc); |
1501 | pc->c[0] = TEST_UNIT_READY; | 1260 | pc->c[0] = TEST_UNIT_READY; |
1502 | pc->idetape_callback = &idetape_pc_callback; | ||
1503 | } | 1261 | } |
1504 | 1262 | ||
1505 | /* | 1263 | /* |
@@ -1518,12 +1276,16 @@ static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | |||
1518 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | 1276 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
1519 | { | 1277 | { |
1520 | struct ide_tape_obj *tape = drive->driver_data; | 1278 | struct ide_tape_obj *tape = drive->driver_data; |
1521 | struct request rq; | 1279 | struct request *rq; |
1280 | int error; | ||
1522 | 1281 | ||
1523 | idetape_init_rq(&rq, REQ_IDETAPE_PC1); | 1282 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
1524 | rq.buffer = (char *) pc; | 1283 | rq->cmd_type = REQ_TYPE_SPECIAL; |
1525 | rq.rq_disk = tape->disk; | 1284 | rq->cmd[0] = REQ_IDETAPE_PC1; |
1526 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 1285 | rq->buffer = (char *)pc; |
1286 | error = blk_execute_rq(drive->queue, tape->disk, rq, 0); | ||
1287 | blk_put_request(rq); | ||
1288 | return error; | ||
1527 | } | 1289 | } |
1528 | 1290 | ||
1529 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, | 1291 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, |
@@ -1533,7 +1295,6 @@ static void idetape_create_load_unload_cmd(ide_drive_t *drive, | |||
1533 | pc->c[0] = START_STOP; | 1295 | pc->c[0] = START_STOP; |
1534 | pc->c[4] = cmd; | 1296 | pc->c[4] = cmd; |
1535 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1297 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1536 | pc->idetape_callback = &idetape_pc_callback; | ||
1537 | } | 1298 | } |
1538 | 1299 | ||
1539 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | 1300 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) |
@@ -1585,7 +1346,6 @@ static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) | |||
1585 | idetape_init_pc(pc); | 1346 | idetape_init_pc(pc); |
1586 | pc->c[0] = READ_POSITION; | 1347 | pc->c[0] = READ_POSITION; |
1587 | pc->req_xfer = 20; | 1348 | pc->req_xfer = 20; |
1588 | pc->idetape_callback = &idetape_read_position_callback; | ||
1589 | } | 1349 | } |
1590 | 1350 | ||
1591 | static int idetape_read_position(ide_drive_t *drive) | 1351 | static int idetape_read_position(ide_drive_t *drive) |
@@ -1613,7 +1373,6 @@ static void idetape_create_locate_cmd(ide_drive_t *drive, | |||
1613 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); | 1373 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); |
1614 | pc->c[8] = partition; | 1374 | pc->c[8] = partition; |
1615 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1375 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1616 | pc->idetape_callback = &idetape_pc_callback; | ||
1617 | } | 1376 | } |
1618 | 1377 | ||
1619 | static int idetape_create_prevent_cmd(ide_drive_t *drive, | 1378 | static int idetape_create_prevent_cmd(ide_drive_t *drive, |
@@ -1628,7 +1387,6 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive, | |||
1628 | idetape_init_pc(pc); | 1387 | idetape_init_pc(pc); |
1629 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; | 1388 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; |
1630 | pc->c[4] = prevent; | 1389 | pc->c[4] = prevent; |
1631 | pc->idetape_callback = &idetape_pc_callback; | ||
1632 | return 1; | 1390 | return 1; |
1633 | } | 1391 | } |
1634 | 1392 | ||
@@ -1700,26 +1458,33 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | |||
1700 | struct idetape_bh *bh) | 1458 | struct idetape_bh *bh) |
1701 | { | 1459 | { |
1702 | idetape_tape_t *tape = drive->driver_data; | 1460 | idetape_tape_t *tape = drive->driver_data; |
1703 | struct request rq; | 1461 | struct request *rq; |
1462 | int ret, errors; | ||
1704 | 1463 | ||
1705 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); | 1464 | debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); |
1706 | 1465 | ||
1707 | idetape_init_rq(&rq, cmd); | 1466 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
1708 | rq.rq_disk = tape->disk; | 1467 | rq->cmd_type = REQ_TYPE_SPECIAL; |
1709 | rq.special = (void *)bh; | 1468 | rq->cmd[0] = cmd; |
1710 | rq.sector = tape->first_frame; | 1469 | rq->rq_disk = tape->disk; |
1711 | rq.nr_sectors = blocks; | 1470 | rq->special = (void *)bh; |
1712 | rq.current_nr_sectors = blocks; | 1471 | rq->sector = tape->first_frame; |
1713 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); | 1472 | rq->nr_sectors = blocks; |
1473 | rq->current_nr_sectors = blocks; | ||
1474 | blk_execute_rq(drive->queue, tape->disk, rq, 0); | ||
1475 | |||
1476 | errors = rq->errors; | ||
1477 | ret = tape->blk_size * (blocks - rq->current_nr_sectors); | ||
1478 | blk_put_request(rq); | ||
1714 | 1479 | ||
1715 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) | 1480 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) |
1716 | return 0; | 1481 | return 0; |
1717 | 1482 | ||
1718 | if (tape->merge_bh) | 1483 | if (tape->merge_bh) |
1719 | idetape_init_merge_buffer(tape); | 1484 | idetape_init_merge_buffer(tape); |
1720 | if (rq.errors == IDETAPE_ERROR_GENERAL) | 1485 | if (errors == IDETAPE_ERROR_GENERAL) |
1721 | return -EIO; | 1486 | return -EIO; |
1722 | return (tape->blk_size * (blocks-rq.current_nr_sectors)); | 1487 | return ret; |
1723 | } | 1488 | } |
1724 | 1489 | ||
1725 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) | 1490 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) |
@@ -1728,7 +1493,6 @@ static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) | |||
1728 | pc->c[0] = INQUIRY; | 1493 | pc->c[0] = INQUIRY; |
1729 | pc->c[4] = 254; | 1494 | pc->c[4] = 254; |
1730 | pc->req_xfer = 254; | 1495 | pc->req_xfer = 254; |
1731 | pc->idetape_callback = &idetape_pc_callback; | ||
1732 | } | 1496 | } |
1733 | 1497 | ||
1734 | static void idetape_create_rewind_cmd(ide_drive_t *drive, | 1498 | static void idetape_create_rewind_cmd(ide_drive_t *drive, |
@@ -1737,7 +1501,6 @@ static void idetape_create_rewind_cmd(ide_drive_t *drive, | |||
1737 | idetape_init_pc(pc); | 1501 | idetape_init_pc(pc); |
1738 | pc->c[0] = REZERO_UNIT; | 1502 | pc->c[0] = REZERO_UNIT; |
1739 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1503 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1740 | pc->idetape_callback = &idetape_pc_callback; | ||
1741 | } | 1504 | } |
1742 | 1505 | ||
1743 | static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) | 1506 | static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) |
@@ -1746,7 +1509,6 @@ static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) | |||
1746 | pc->c[0] = ERASE; | 1509 | pc->c[0] = ERASE; |
1747 | pc->c[1] = 1; | 1510 | pc->c[1] = 1; |
1748 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1511 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1749 | pc->idetape_callback = &idetape_pc_callback; | ||
1750 | } | 1512 | } |
1751 | 1513 | ||
1752 | static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) | 1514 | static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) |
@@ -1756,7 +1518,6 @@ static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) | |||
1756 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); | 1518 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); |
1757 | pc->c[1] = cmd; | 1519 | pc->c[1] = cmd; |
1758 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1520 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
1759 | pc->idetape_callback = &idetape_pc_callback; | ||
1760 | } | 1521 | } |
1761 | 1522 | ||
1762 | /* Queue up a character device originated write request. */ | 1523 | /* Queue up a character device originated write request. */ |
@@ -2421,9 +2182,12 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
2421 | if (i >= MAX_HWIFS * MAX_DRIVES) | 2182 | if (i >= MAX_HWIFS * MAX_DRIVES) |
2422 | return -ENXIO; | 2183 | return -ENXIO; |
2423 | 2184 | ||
2185 | lock_kernel(); | ||
2424 | tape = ide_tape_chrdev_get(i); | 2186 | tape = ide_tape_chrdev_get(i); |
2425 | if (!tape) | 2187 | if (!tape) { |
2188 | unlock_kernel(); | ||
2426 | return -ENXIO; | 2189 | return -ENXIO; |
2190 | } | ||
2427 | 2191 | ||
2428 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); | 2192 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); |
2429 | 2193 | ||
@@ -2482,10 +2246,12 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
2482 | } | 2246 | } |
2483 | } | 2247 | } |
2484 | } | 2248 | } |
2249 | unlock_kernel(); | ||
2485 | return 0; | 2250 | return 0; |
2486 | 2251 | ||
2487 | out_put_tape: | 2252 | out_put_tape: |
2488 | ide_tape_put(tape); | 2253 | ide_tape_put(tape); |
2254 | unlock_kernel(); | ||
2489 | return retval; | 2255 | return retval; |
2490 | } | 2256 | } |
2491 | 2257 | ||
@@ -2746,9 +2512,8 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
2746 | * Ensure that the number we got makes sense; limit it within | 2512 | * Ensure that the number we got makes sense; limit it within |
2747 | * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. | 2513 | * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. |
2748 | */ | 2514 | */ |
2749 | tape->best_dsc_rw_freq = max_t(unsigned long, | 2515 | tape->best_dsc_rw_freq = clamp_t(unsigned long, t, IDETAPE_DSC_RW_MIN, |
2750 | min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), | 2516 | IDETAPE_DSC_RW_MAX); |
2751 | IDETAPE_DSC_RW_MIN); | ||
2752 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " | 2517 | printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " |
2753 | "%lums tDSC%s\n", | 2518 | "%lums tDSC%s\n", |
2754 | drive->name, tape->name, *(u16 *)&tape->caps[14], | 2519 | drive->name, tape->name, *(u16 *)&tape->caps[14], |
@@ -2826,7 +2591,6 @@ static ide_driver_t idetape_driver = { | |||
2826 | .do_request = idetape_do_request, | 2591 | .do_request = idetape_do_request, |
2827 | .end_request = idetape_end_request, | 2592 | .end_request = idetape_end_request, |
2828 | .error = __ide_error, | 2593 | .error = __ide_error, |
2829 | .abort = __ide_abort, | ||
2830 | #ifdef CONFIG_IDE_PROC_FS | 2594 | #ifdef CONFIG_IDE_PROC_FS |
2831 | .proc = idetape_proc, | 2595 | .proc = idetape_proc, |
2832 | #endif | 2596 | #endif |
@@ -2900,11 +2664,6 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
2900 | " the driver\n", drive->name); | 2664 | " the driver\n", drive->name); |
2901 | goto failed; | 2665 | goto failed; |
2902 | } | 2666 | } |
2903 | if (drive->scsi) { | ||
2904 | printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi" | ||
2905 | " emulation.\n", drive->name); | ||
2906 | goto failed; | ||
2907 | } | ||
2908 | tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); | 2667 | tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); |
2909 | if (tape == NULL) { | 2668 | if (tape == NULL) { |
2910 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", | 2669 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index ab545ffa1549..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 | ||
65 | static 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 | |||
84 | static ide_startstop_t task_no_data_intr(ide_drive_t *); | 55 | static ide_startstop_t task_no_data_intr(ide_drive_t *); |
85 | static ide_startstop_t set_geometry_intr(ide_drive_t *); | 56 | static ide_startstop_t set_geometry_intr(ide_drive_t *); |
86 | static ide_startstop_t recal_intr(ide_drive_t *); | 57 | static ide_startstop_t recal_intr(ide_drive_t *); |
@@ -109,13 +80,15 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
109 | 80 | ||
110 | if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { | 81 | if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { |
111 | ide_tf_dump(drive->name, tf); | 82 | ide_tf_dump(drive->name, tf); |
83 | ide_set_irq(drive, 1); | ||
84 | SELECT_MASK(drive, 0); | ||
112 | hwif->tf_load(drive, task); | 85 | hwif->tf_load(drive, task); |
113 | } | 86 | } |
114 | 87 | ||
115 | switch (task->data_phase) { | 88 | switch (task->data_phase) { |
116 | case TASKFILE_MULTI_OUT: | 89 | case TASKFILE_MULTI_OUT: |
117 | case TASKFILE_OUT: | 90 | case TASKFILE_OUT: |
118 | hwif->OUTBSYNC(drive, tf->command, hwif->io_ports.command_addr); | 91 | hwif->OUTBSYNC(hwif, tf->command, hwif->io_ports.command_addr); |
119 | ndelay(400); /* FIXME */ | 92 | ndelay(400); /* FIXME */ |
120 | return pre_task_out_intr(drive, task->rq); | 93 | return pre_task_out_intr(drive, task->rq); |
121 | case TASKFILE_MULTI_IN: | 94 | case TASKFILE_MULTI_IN: |
@@ -137,8 +110,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
137 | WAIT_WORSTCASE, NULL); | 110 | WAIT_WORSTCASE, NULL); |
138 | return ide_started; | 111 | return ide_started; |
139 | default: | 112 | default: |
140 | if (task_dma_ok(task) == 0 || drive->using_dma == 0 || | 113 | if (drive->using_dma == 0 || dma_ops->dma_setup(drive)) |
141 | dma_ops->dma_setup(drive)) | ||
142 | return ide_stopped; | 114 | return ide_stopped; |
143 | dma_ops->dma_exec_cmd(drive, tf->command); | 115 | dma_ops->dma_exec_cmd(drive, tf->command); |
144 | dma_ops->dma_start(drive); | 116 | dma_ops->dma_start(drive); |
@@ -181,7 +153,6 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | |||
181 | if (stat & (ERR_STAT|DRQ_STAT)) | 153 | if (stat & (ERR_STAT|DRQ_STAT)) |
182 | return ide_error(drive, "set_geometry_intr", stat); | 154 | return ide_error(drive, "set_geometry_intr", stat); |
183 | 155 | ||
184 | BUG_ON(HWGROUP(drive)->handler != NULL); | ||
185 | ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL); | 156 | ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL); |
186 | return ide_started; | 157 | return ide_started; |
187 | } | 158 | } |
@@ -492,11 +463,12 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq) | |||
492 | 463 | ||
493 | int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) | 464 | int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) |
494 | { | 465 | { |
495 | struct request rq; | 466 | struct request *rq; |
467 | int error; | ||
496 | 468 | ||
497 | blk_rq_init(NULL, &rq); | 469 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
498 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 470 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
499 | rq.buffer = buf; | 471 | rq->buffer = buf; |
500 | 472 | ||
501 | /* | 473 | /* |
502 | * (ks) We transfer currently only whole sectors. | 474 | * (ks) We transfer currently only whole sectors. |
@@ -504,16 +476,19 @@ int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) | |||
504 | * if we would find a solution to transfer any size. | 476 | * if we would find a solution to transfer any size. |
505 | * To support special commands like READ LONG. | 477 | * To support special commands like READ LONG. |
506 | */ | 478 | */ |
507 | rq.hard_nr_sectors = rq.nr_sectors = nsect; | 479 | rq->hard_nr_sectors = rq->nr_sectors = nsect; |
508 | rq.hard_cur_sectors = rq.current_nr_sectors = nsect; | 480 | rq->hard_cur_sectors = rq->current_nr_sectors = nsect; |
509 | 481 | ||
510 | if (task->tf_flags & IDE_TFLAG_WRITE) | 482 | if (task->tf_flags & IDE_TFLAG_WRITE) |
511 | rq.cmd_flags |= REQ_RW; | 483 | rq->cmd_flags |= REQ_RW; |
484 | |||
485 | rq->special = task; | ||
486 | task->rq = rq; | ||
512 | 487 | ||
513 | rq.special = task; | 488 | error = blk_execute_rq(drive->queue, NULL, rq, 0); |
514 | task->rq = &rq; | 489 | blk_put_request(rq); |
515 | 490 | ||
516 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 491 | return error; |
517 | } | 492 | } |
518 | 493 | ||
519 | EXPORT_SYMBOL(ide_raw_taskfile); | 494 | EXPORT_SYMBOL(ide_raw_taskfile); |
@@ -739,12 +714,14 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | |||
739 | struct hd_driveid *id = drive->id; | 714 | struct hd_driveid *id = drive->id; |
740 | 715 | ||
741 | if (NULL == (void *) arg) { | 716 | if (NULL == (void *) arg) { |
742 | struct request rq; | 717 | struct request *rq; |
743 | 718 | ||
744 | ide_init_drive_cmd(&rq); | 719 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
745 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 720 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
721 | err = blk_execute_rq(drive->queue, NULL, rq, 0); | ||
722 | blk_put_request(rq); | ||
746 | 723 | ||
747 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 724 | return err; |
748 | } | 725 | } |
749 | 726 | ||
750 | if (copy_from_user(args, (void __user *)arg, 4)) | 727 | if (copy_from_user(args, (void __user *)arg, 4)) |
diff --git a/drivers/ide/ide-timing.h b/drivers/ide/ide-timings.c index 3b12ffe77071..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 | |||
34 | struct 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 | ||
53 | static struct ide_timing ide_timing[] = { | 36 | static 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,30 +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 | 68 | struct 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 | 77 | EXPORT_SYMBOL_GPL(ide_timing_find_mode); |
97 | 78 | ||
98 | #define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin) | 79 | u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio) |
99 | #define ENOUGH(v,unit) (((v)-1)/(unit)+1) | 80 | { |
100 | #define EZ(v,unit) ((v)?ENOUGH(v,unit):0) | 81 | struct hd_driveid *id = drive->id; |
101 | 82 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | |
102 | #define XFER_MODE 0xf0 | 83 | u16 cycle = 0; |
103 | #define XFER_MWDMA 0x20 | 84 | |
104 | #define XFER_EPIO 0x01 | 85 | if (id->field_valid & 2) { |
105 | #define XFER_PIO 0x00 | 86 | if (id->capability & 8) |
106 | 87 | cycle = id->eide_pio_iordy; | |
107 | static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int T, int UT) | 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 | } | ||
98 | EXPORT_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 | |||
103 | static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, | ||
104 | int T, int UT) | ||
108 | { | 105 | { |
109 | q->setup = EZ(t->setup * 1000, T); | 106 | q->setup = EZ(t->setup * 1000, T); |
110 | q->act8b = EZ(t->act8b * 1000, T); | 107 | q->act8b = EZ(t->act8b * 1000, T); |
@@ -116,92 +113,83 @@ static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, int | |||
116 | q->udma = EZ(t->udma * 1000, UT); | 113 | q->udma = EZ(t->udma * 1000, UT); |
117 | } | 114 | } |
118 | 115 | ||
119 | static void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, struct ide_timing *m, unsigned int what) | 116 | void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, |
120 | { | 117 | struct ide_timing *m, unsigned int what) |
121 | if (what & IDE_TIMING_SETUP ) m->setup = max(a->setup, b->setup); | ||
122 | if (what & IDE_TIMING_ACT8B ) m->act8b = max(a->act8b, b->act8b); | ||
123 | if (what & IDE_TIMING_REC8B ) m->rec8b = max(a->rec8b, b->rec8b); | ||
124 | if (what & IDE_TIMING_CYC8B ) m->cyc8b = max(a->cyc8b, b->cyc8b); | ||
125 | if (what & IDE_TIMING_ACTIVE ) m->active = max(a->active, b->active); | ||
126 | if (what & IDE_TIMING_RECOVER) m->recover = max(a->recover, b->recover); | ||
127 | if (what & IDE_TIMING_CYCLE ) m->cycle = max(a->cycle, b->cycle); | ||
128 | if (what & IDE_TIMING_UDMA ) m->udma = max(a->udma, b->udma); | ||
129 | } | ||
130 | |||
131 | static struct ide_timing* ide_timing_find_mode(short speed) | ||
132 | { | 118 | { |
133 | struct ide_timing *t; | 119 | if (what & IDE_TIMING_SETUP) |
134 | 120 | m->setup = max(a->setup, b->setup); | |
135 | for (t = ide_timing; t->mode != speed; t++) | 121 | if (what & IDE_TIMING_ACT8B) |
136 | if (t->mode < 0) | 122 | m->act8b = max(a->act8b, b->act8b); |
137 | return NULL; | 123 | if (what & IDE_TIMING_REC8B) |
138 | 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); | ||
139 | } | 135 | } |
136 | EXPORT_SYMBOL_GPL(ide_timing_merge); | ||
140 | 137 | ||
141 | static int ide_timing_compute(ide_drive_t *drive, short speed, struct ide_timing *t, int T, int UT) | 138 | int ide_timing_compute(ide_drive_t *drive, u8 speed, |
139 | struct ide_timing *t, int T, int UT) | ||
142 | { | 140 | { |
143 | struct hd_driveid *id = drive->id; | 141 | struct hd_driveid *id = drive->id; |
144 | struct ide_timing *s, p; | 142 | struct ide_timing *s, p; |
145 | 143 | ||
146 | /* | 144 | /* |
147 | * Find the mode. | 145 | * Find the mode. |
148 | */ | 146 | */ |
149 | 147 | s = ide_timing_find_mode(speed); | |
150 | if (!(s = ide_timing_find_mode(speed))) | 148 | if (s == NULL) |
151 | return -EINVAL; | 149 | return -EINVAL; |
152 | 150 | ||
153 | /* | 151 | /* |
154 | * Copy the timing from the table. | 152 | * Copy the timing from the table. |
155 | */ | 153 | */ |
156 | |||
157 | *t = *s; | 154 | *t = *s; |
158 | 155 | ||
159 | /* | 156 | /* |
160 | * 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 |
161 | * PIO/MWDMA cycle timing. | 158 | * PIO/MWDMA cycle timing. |
162 | */ | 159 | */ |
163 | |||
164 | if (id && id->field_valid & 2) { /* EIDE drive */ | 160 | if (id && id->field_valid & 2) { /* EIDE drive */ |
165 | 161 | ||
166 | memset(&p, 0, sizeof(p)); | 162 | memset(&p, 0, sizeof(p)); |
167 | 163 | ||
168 | switch (speed & XFER_MODE) { | 164 | if (speed <= XFER_PIO_2) |
169 | 165 | p.cycle = p.cyc8b = id->eide_pio; | |
170 | case XFER_PIO: | 166 | else if (speed <= XFER_PIO_5) |
171 | if (speed <= XFER_PIO_2) p.cycle = p.cyc8b = id->eide_pio; | 167 | p.cycle = p.cyc8b = id->eide_pio_iordy; |
172 | else p.cycle = p.cyc8b = id->eide_pio_iordy; | 168 | else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) |
173 | break; | 169 | p.cycle = id->eide_dma_min; |
174 | |||
175 | case XFER_MWDMA: | ||
176 | p.cycle = id->eide_dma_min; | ||
177 | break; | ||
178 | } | ||
179 | 170 | ||
180 | 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); |
181 | } | 172 | } |
182 | 173 | ||
183 | /* | 174 | /* |
184 | * Convert the timing to bus clock counts. | 175 | * Convert the timing to bus clock counts. |
185 | */ | 176 | */ |
186 | |||
187 | ide_timing_quantize(t, t, T, UT); | 177 | ide_timing_quantize(t, t, T, UT); |
188 | 178 | ||
189 | /* | 179 | /* |
190 | * 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, |
191 | * 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 |
192 | * slower/equal than the fastest PIO timing. | 182 | * DMA cycle timing is slower/equal than the fastest PIO timing. |
193 | */ | 183 | */ |
194 | 184 | if (speed >= XFER_SW_DMA_0) { | |
195 | if ((speed & XFER_MODE) != XFER_PIO) { | ||
196 | u8 pio = ide_get_best_pio_mode(drive, 255, 5); | 185 | u8 pio = ide_get_best_pio_mode(drive, 255, 5); |
197 | ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT); | 186 | ide_timing_compute(drive, XFER_PIO_0 + pio, &p, T, UT); |
198 | ide_timing_merge(&p, t, t, IDE_TIMING_ALL); | 187 | ide_timing_merge(&p, t, t, IDE_TIMING_ALL); |
199 | } | 188 | } |
200 | 189 | ||
201 | /* | 190 | /* |
202 | * Lengthen active & recovery time so that cycle time is correct. | 191 | * Lengthen active & recovery time so that cycle time is correct. |
203 | */ | 192 | */ |
204 | |||
205 | if (t->act8b + t->rec8b < t->cyc8b) { | 193 | if (t->act8b + t->rec8b < t->cyc8b) { |
206 | t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2; | 194 | t->act8b += (t->cyc8b - (t->act8b + t->rec8b)) / 2; |
207 | t->rec8b = t->cyc8b - t->act8b; | 195 | t->rec8b = t->cyc8b - t->act8b; |
@@ -214,5 +202,4 @@ static int ide_timing_compute(ide_drive_t *drive, short speed, struct ide_timing | |||
214 | 202 | ||
215 | return 0; | 203 | return 0; |
216 | } | 204 | } |
217 | 205 | EXPORT_SYMBOL_GPL(ide_timing_compute); | |
218 | #endif | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index c758dcb13b14..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 */ |
@@ -86,15 +73,10 @@ static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR, | |||
86 | IDE6_MAJOR, IDE7_MAJOR, | 73 | IDE6_MAJOR, IDE7_MAJOR, |
87 | IDE8_MAJOR, IDE9_MAJOR }; | 74 | IDE8_MAJOR, IDE9_MAJOR }; |
88 | 75 | ||
89 | static int idebus_parameter; /* holds the "idebus=" parameter */ | ||
90 | static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */ | ||
91 | |||
92 | DEFINE_MUTEX(ide_cfg_mtx); | 76 | DEFINE_MUTEX(ide_cfg_mtx); |
93 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); | ||
94 | |||
95 | int noautodma = 0; | ||
96 | 77 | ||
97 | ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ | 78 | __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); |
79 | EXPORT_SYMBOL(ide_lock); | ||
98 | 80 | ||
99 | static void ide_port_init_devices_data(ide_hwif_t *); | 81 | static void ide_port_init_devices_data(ide_hwif_t *); |
100 | 82 | ||
@@ -124,7 +106,6 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | |||
124 | 106 | ||
125 | ide_port_init_devices_data(hwif); | 107 | ide_port_init_devices_data(hwif); |
126 | } | 108 | } |
127 | EXPORT_SYMBOL_GPL(ide_init_port_data); | ||
128 | 109 | ||
129 | static void ide_port_init_devices_data(ide_hwif_t *hwif) | 110 | static void ide_port_init_devices_data(ide_hwif_t *hwif) |
130 | { | 111 | { |
@@ -139,7 +120,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
139 | drive->media = ide_disk; | 120 | drive->media = ide_disk; |
140 | drive->select.all = (unit<<4)|0xa0; | 121 | drive->select.all = (unit<<4)|0xa0; |
141 | drive->hwif = hwif; | 122 | drive->hwif = hwif; |
142 | drive->ctl = 0x08; | ||
143 | drive->ready_stat = READY_STAT; | 123 | drive->ready_stat = READY_STAT; |
144 | drive->bad_wstat = BAD_W_STAT; | 124 | drive->bad_wstat = BAD_W_STAT; |
145 | drive->special.b.recalibrate = 1; | 125 | drive->special.b.recalibrate = 1; |
@@ -154,73 +134,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
154 | } | 134 | } |
155 | } | 135 | } |
156 | 136 | ||
157 | /* | ||
158 | * init_ide_data() sets reasonable default values into all fields | ||
159 | * of all instances of the hwifs and drives, but only on the first call. | ||
160 | * Subsequent calls have no effect (they don't wipe out anything). | ||
161 | * | ||
162 | * This routine is normally called at driver initialization time, | ||
163 | * but may also be called MUCH earlier during kernel "command-line" | ||
164 | * parameter processing. As such, we cannot depend on any other parts | ||
165 | * of the kernel (such as memory allocation) to be functioning yet. | ||
166 | * | ||
167 | * This is too bad, as otherwise we could dynamically allocate the | ||
168 | * ide_drive_t structs as needed, rather than always consuming memory | ||
169 | * for the max possible number (MAX_HWIFS * MAX_DRIVES) of them. | ||
170 | * | ||
171 | * FIXME: We should stuff the setup data into __init and copy the | ||
172 | * relevant hwifs/allocate them properly during boot. | ||
173 | */ | ||
174 | #define MAGIC_COOKIE 0x12345678 | ||
175 | static void __init init_ide_data (void) | ||
176 | { | ||
177 | unsigned int index; | ||
178 | static unsigned long magic_cookie = MAGIC_COOKIE; | ||
179 | |||
180 | if (magic_cookie != MAGIC_COOKIE) | ||
181 | return; /* already initialized */ | ||
182 | magic_cookie = 0; | ||
183 | |||
184 | /* Initialise all interface structures */ | ||
185 | for (index = 0; index < MAX_HWIFS; ++index) { | ||
186 | ide_hwif_t *hwif = &ide_hwifs[index]; | ||
187 | |||
188 | ide_init_port_data(hwif, index); | ||
189 | } | ||
190 | } | ||
191 | |||
192 | /** | ||
193 | * ide_system_bus_speed - guess bus speed | ||
194 | * | ||
195 | * ide_system_bus_speed() returns what we think is the system VESA/PCI | ||
196 | * bus speed (in MHz). This is used for calculating interface PIO timings. | ||
197 | * The default is 40 for known PCI systems, 50 otherwise. | ||
198 | * The "idebus=xx" parameter can be used to override this value. | ||
199 | * The actual value to be used is computed/displayed the first time | ||
200 | * through. Drivers should only use this as a last resort. | ||
201 | * | ||
202 | * Returns a guessed speed in MHz. | ||
203 | */ | ||
204 | |||
205 | static int ide_system_bus_speed(void) | ||
206 | { | ||
207 | #ifdef CONFIG_PCI | ||
208 | static struct pci_device_id pci_default[] = { | ||
209 | { PCI_DEVICE(PCI_ANY_ID, PCI_ANY_ID) }, | ||
210 | { } | ||
211 | }; | ||
212 | #else | ||
213 | #define pci_default 0 | ||
214 | #endif /* CONFIG_PCI */ | ||
215 | |||
216 | /* user supplied value */ | ||
217 | if (idebus_parameter) | ||
218 | return idebus_parameter; | ||
219 | |||
220 | /* safe default value for PCI or VESA and PCI*/ | ||
221 | return pci_dev_present(pci_default) ? 33 : 50; | ||
222 | } | ||
223 | |||
224 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) | 137 | void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) |
225 | { | 138 | { |
226 | ide_hwgroup_t *hwgroup = hwif->hwgroup; | 139 | ide_hwgroup_t *hwgroup = hwif->hwgroup; |
@@ -315,13 +228,14 @@ void ide_unregister(ide_hwif_t *hwif) | |||
315 | 228 | ||
316 | BUG_ON(in_interrupt()); | 229 | BUG_ON(in_interrupt()); |
317 | BUG_ON(irqs_disabled()); | 230 | BUG_ON(irqs_disabled()); |
231 | |||
318 | mutex_lock(&ide_cfg_mtx); | 232 | mutex_lock(&ide_cfg_mtx); |
319 | spin_lock_irq(&ide_lock); | ||
320 | if (!hwif->present) | ||
321 | goto abort; | ||
322 | __ide_port_unregister_devices(hwif); | ||
323 | hwif->present = 0; | ||
324 | 233 | ||
234 | spin_lock_irq(&ide_lock); | ||
235 | if (hwif->present) { | ||
236 | __ide_port_unregister_devices(hwif); | ||
237 | hwif->present = 0; | ||
238 | } | ||
325 | spin_unlock_irq(&ide_lock); | 239 | spin_unlock_irq(&ide_lock); |
326 | 240 | ||
327 | ide_proc_unregister_port(hwif); | 241 | ide_proc_unregister_port(hwif); |
@@ -351,16 +265,15 @@ void ide_unregister(ide_hwif_t *hwif) | |||
351 | blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); | 265 | blk_unregister_region(MKDEV(hwif->major, 0), MAX_DRIVES<<PARTN_BITS); |
352 | kfree(hwif->sg_table); | 266 | kfree(hwif->sg_table); |
353 | unregister_blkdev(hwif->major, hwif->name); | 267 | unregister_blkdev(hwif->major, hwif->name); |
354 | spin_lock_irq(&ide_lock); | ||
355 | 268 | ||
356 | if (hwif->dma_base) | 269 | if (hwif->dma_base) |
357 | ide_release_dma_engine(hwif); | 270 | ide_release_dma_engine(hwif); |
358 | 271 | ||
272 | spin_lock_irq(&ide_lock); | ||
359 | /* restore hwif data to pristine status */ | 273 | /* restore hwif data to pristine status */ |
360 | ide_init_port_data(hwif, hwif->index); | 274 | ide_init_port_data(hwif, hwif->index); |
361 | |||
362 | abort: | ||
363 | spin_unlock_irq(&ide_lock); | 275 | spin_unlock_irq(&ide_lock); |
276 | |||
364 | mutex_unlock(&ide_cfg_mtx); | 277 | mutex_unlock(&ide_cfg_mtx); |
365 | } | 278 | } |
366 | 279 | ||
@@ -371,7 +284,8 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | |||
371 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); | 284 | memcpy(&hwif->io_ports, &hw->io_ports, sizeof(hwif->io_ports)); |
372 | hwif->irq = hw->irq; | 285 | hwif->irq = hw->irq; |
373 | hwif->chipset = hw->chipset; | 286 | hwif->chipset = hw->chipset; |
374 | hwif->gendev.parent = hw->dev; | 287 | hwif->dev = hw->dev; |
288 | hwif->gendev.parent = hw->parent ? hw->parent : hw->dev; | ||
375 | hwif->ack_intr = hw->ack_intr; | 289 | hwif->ack_intr = hw->ack_intr; |
376 | } | 290 | } |
377 | EXPORT_SYMBOL_GPL(ide_init_port_hw); | 291 | EXPORT_SYMBOL_GPL(ide_init_port_hw); |
@@ -498,7 +412,7 @@ out: | |||
498 | 412 | ||
499 | int set_pio_mode(ide_drive_t *drive, int arg) | 413 | int set_pio_mode(ide_drive_t *drive, int arg) |
500 | { | 414 | { |
501 | struct request rq; | 415 | struct request *rq; |
502 | ide_hwif_t *hwif = drive->hwif; | 416 | ide_hwif_t *hwif = drive->hwif; |
503 | const struct ide_port_ops *port_ops = hwif->port_ops; | 417 | const struct ide_port_ops *port_ops = hwif->port_ops; |
504 | 418 | ||
@@ -512,12 +426,15 @@ int set_pio_mode(ide_drive_t *drive, int arg) | |||
512 | if (drive->special.b.set_tune) | 426 | if (drive->special.b.set_tune) |
513 | return -EBUSY; | 427 | return -EBUSY; |
514 | 428 | ||
515 | ide_init_drive_cmd(&rq); | 429 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
516 | rq.cmd_type = REQ_TYPE_ATA_TASKFILE; | 430 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; |
517 | 431 | ||
518 | drive->tune_req = (u8) arg; | 432 | drive->tune_req = (u8) arg; |
519 | drive->special.b.set_tune = 1; | 433 | drive->special.b.set_tune = 1; |
520 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); | 434 | |
435 | blk_execute_rq(drive->queue, NULL, rq, 0); | ||
436 | blk_put_request(rq); | ||
437 | |||
521 | return 0; | 438 | return 0; |
522 | } | 439 | } |
523 | 440 | ||
@@ -537,25 +454,11 @@ static int set_unmaskirq(ide_drive_t *drive, int arg) | |||
537 | return 0; | 454 | return 0; |
538 | } | 455 | } |
539 | 456 | ||
540 | /** | ||
541 | * system_bus_clock - clock guess | ||
542 | * | ||
543 | * External version of the bus clock guess used by very old IDE drivers | ||
544 | * for things like VLB timings. Should not be used. | ||
545 | */ | ||
546 | |||
547 | int system_bus_clock (void) | ||
548 | { | ||
549 | return system_bus_speed; | ||
550 | } | ||
551 | |||
552 | EXPORT_SYMBOL(system_bus_clock); | ||
553 | |||
554 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) | 457 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) |
555 | { | 458 | { |
556 | ide_drive_t *drive = dev->driver_data; | 459 | ide_drive_t *drive = dev->driver_data; |
557 | ide_hwif_t *hwif = HWIF(drive); | 460 | ide_hwif_t *hwif = HWIF(drive); |
558 | struct request rq; | 461 | struct request *rq; |
559 | struct request_pm_state rqpm; | 462 | struct request_pm_state rqpm; |
560 | ide_task_t args; | 463 | ide_task_t args; |
561 | int ret; | 464 | int ret; |
@@ -564,18 +467,19 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg) | |||
564 | if (!(drive->dn % 2)) | 467 | if (!(drive->dn % 2)) |
565 | ide_acpi_get_timing(hwif); | 468 | ide_acpi_get_timing(hwif); |
566 | 469 | ||
567 | blk_rq_init(NULL, &rq); | ||
568 | memset(&rqpm, 0, sizeof(rqpm)); | 470 | memset(&rqpm, 0, sizeof(rqpm)); |
569 | memset(&args, 0, sizeof(args)); | 471 | memset(&args, 0, sizeof(args)); |
570 | rq.cmd_type = REQ_TYPE_PM_SUSPEND; | 472 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
571 | rq.special = &args; | 473 | rq->cmd_type = REQ_TYPE_PM_SUSPEND; |
572 | rq.data = &rqpm; | 474 | rq->special = &args; |
475 | rq->data = &rqpm; | ||
573 | rqpm.pm_step = ide_pm_state_start_suspend; | 476 | rqpm.pm_step = ide_pm_state_start_suspend; |
574 | if (mesg.event == PM_EVENT_PRETHAW) | 477 | if (mesg.event == PM_EVENT_PRETHAW) |
575 | mesg.event = PM_EVENT_FREEZE; | 478 | mesg.event = PM_EVENT_FREEZE; |
576 | rqpm.pm_state = mesg.event; | 479 | rqpm.pm_state = mesg.event; |
577 | 480 | ||
578 | ret = ide_do_drive_cmd(drive, &rq, ide_wait); | 481 | ret = blk_execute_rq(drive->queue, NULL, rq, 0); |
482 | blk_put_request(rq); | ||
579 | /* only call ACPI _PS3 after both drivers are suspended */ | 483 | /* only call ACPI _PS3 after both drivers are suspended */ |
580 | if (!ret && (((drive->dn % 2) && hwif->drives[0].present | 484 | if (!ret && (((drive->dn % 2) && hwif->drives[0].present |
581 | && hwif->drives[1].present) | 485 | && hwif->drives[1].present) |
@@ -589,7 +493,7 @@ static int generic_ide_resume(struct device *dev) | |||
589 | { | 493 | { |
590 | ide_drive_t *drive = dev->driver_data; | 494 | ide_drive_t *drive = dev->driver_data; |
591 | ide_hwif_t *hwif = HWIF(drive); | 495 | ide_hwif_t *hwif = HWIF(drive); |
592 | struct request rq; | 496 | struct request *rq; |
593 | struct request_pm_state rqpm; | 497 | struct request_pm_state rqpm; |
594 | ide_task_t args; | 498 | ide_task_t args; |
595 | int err; | 499 | int err; |
@@ -602,16 +506,18 @@ static int generic_ide_resume(struct device *dev) | |||
602 | 506 | ||
603 | ide_acpi_exec_tfs(drive); | 507 | ide_acpi_exec_tfs(drive); |
604 | 508 | ||
605 | blk_rq_init(NULL, &rq); | ||
606 | memset(&rqpm, 0, sizeof(rqpm)); | 509 | memset(&rqpm, 0, sizeof(rqpm)); |
607 | memset(&args, 0, sizeof(args)); | 510 | memset(&args, 0, sizeof(args)); |
608 | rq.cmd_type = REQ_TYPE_PM_RESUME; | 511 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); |
609 | rq.special = &args; | 512 | rq->cmd_type = REQ_TYPE_PM_RESUME; |
610 | rq.data = &rqpm; | 513 | rq->cmd_flags |= REQ_PREEMPT; |
514 | rq->special = &args; | ||
515 | rq->data = &rqpm; | ||
611 | rqpm.pm_step = ide_pm_state_start_resume; | 516 | rqpm.pm_step = ide_pm_state_start_resume; |
612 | rqpm.pm_state = PM_EVENT_ON; | 517 | rqpm.pm_state = PM_EVENT_ON; |
613 | 518 | ||
614 | err = ide_do_drive_cmd(drive, &rq, ide_head_wait); | 519 | err = blk_execute_rq(drive->queue, NULL, rq, 1); |
520 | blk_put_request(rq); | ||
615 | 521 | ||
616 | if (err == 0 && dev->driver) { | 522 | if (err == 0 && dev->driver) { |
617 | ide_driver_t *drv = to_ide_driver(dev->driver); | 523 | ide_driver_t *drv = to_ide_driver(dev->driver); |
@@ -623,6 +529,22 @@ static int generic_ide_resume(struct device *dev) | |||
623 | return err; | 529 | return err; |
624 | } | 530 | } |
625 | 531 | ||
532 | static 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 | |||
626 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, | 548 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, |
627 | unsigned int cmd, unsigned long arg) | 549 | unsigned int cmd, unsigned long arg) |
628 | { | 550 | { |
@@ -697,33 +619,8 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device | |||
697 | if (!capable(CAP_SYS_ADMIN)) | 619 | if (!capable(CAP_SYS_ADMIN)) |
698 | return -EACCES; | 620 | return -EACCES; |
699 | 621 | ||
700 | /* | 622 | return generic_drive_reset(drive); |
701 | * Abort the current command on the | ||
702 | * group if there is one, taking | ||
703 | * care not to allow anything else | ||
704 | * to be queued and to die on the | ||
705 | * spot if we miss one somehow | ||
706 | */ | ||
707 | |||
708 | spin_lock_irqsave(&ide_lock, flags); | ||
709 | |||
710 | if (HWGROUP(drive)->resetting) { | ||
711 | spin_unlock_irqrestore(&ide_lock, flags); | ||
712 | return -EBUSY; | ||
713 | } | ||
714 | |||
715 | ide_abort(drive, "drive reset"); | ||
716 | 623 | ||
717 | BUG_ON(HWGROUP(drive)->handler); | ||
718 | |||
719 | /* Ensure nothing gets queued after we | ||
720 | drop the lock. Reset will clear the busy */ | ||
721 | |||
722 | HWGROUP(drive)->busy = 1; | ||
723 | spin_unlock_irqrestore(&ide_lock, flags); | ||
724 | (void) ide_do_reset(drive); | ||
725 | |||
726 | return 0; | ||
727 | case HDIO_GET_BUSSTATE: | 624 | case HDIO_GET_BUSSTATE: |
728 | if (!capable(CAP_SYS_ADMIN)) | 625 | if (!capable(CAP_SYS_ADMIN)) |
729 | return -EACCES; | 626 | return -EACCES; |
@@ -764,212 +661,6 @@ set_val: | |||
764 | 661 | ||
765 | EXPORT_SYMBOL(generic_ide_ioctl); | 662 | EXPORT_SYMBOL(generic_ide_ioctl); |
766 | 663 | ||
767 | /* | ||
768 | * stridx() returns the offset of c within s, | ||
769 | * or -1 if c is '\0' or not found within s. | ||
770 | */ | ||
771 | static int __init stridx (const char *s, char c) | ||
772 | { | ||
773 | char *i = strchr(s, c); | ||
774 | return (i && c) ? i - s : -1; | ||
775 | } | ||
776 | |||
777 | /* | ||
778 | * match_parm() does parsing for ide_setup(): | ||
779 | * | ||
780 | * 1. the first char of s must be '='. | ||
781 | * 2. if the remainder matches one of the supplied keywords, | ||
782 | * the index (1 based) of the keyword is negated and returned. | ||
783 | * 3. if the remainder is a series of no more than max_vals numbers | ||
784 | * separated by commas, the numbers are saved in vals[] and a | ||
785 | * count of how many were saved is returned. Base10 is assumed, | ||
786 | * and base16 is allowed when prefixed with "0x". | ||
787 | * 4. otherwise, zero is returned. | ||
788 | */ | ||
789 | static int __init match_parm (char *s, const char *keywords[], int vals[], int max_vals) | ||
790 | { | ||
791 | static const char *decimal = "0123456789"; | ||
792 | static const char *hex = "0123456789abcdef"; | ||
793 | int i, n; | ||
794 | |||
795 | if (*s++ == '=') { | ||
796 | /* | ||
797 | * Try matching against the supplied keywords, | ||
798 | * and return -(index+1) if we match one | ||
799 | */ | ||
800 | if (keywords != NULL) { | ||
801 | for (i = 0; *keywords != NULL; ++i) { | ||
802 | if (!strcmp(s, *keywords++)) | ||
803 | return -(i+1); | ||
804 | } | ||
805 | } | ||
806 | /* | ||
807 | * Look for a series of no more than "max_vals" | ||
808 | * numeric values separated by commas, in base10, | ||
809 | * or base16 when prefixed with "0x". | ||
810 | * Return a count of how many were found. | ||
811 | */ | ||
812 | for (n = 0; (i = stridx(decimal, *s)) >= 0;) { | ||
813 | vals[n] = i; | ||
814 | while ((i = stridx(decimal, *++s)) >= 0) | ||
815 | vals[n] = (vals[n] * 10) + i; | ||
816 | if (*s == 'x' && !vals[n]) { | ||
817 | while ((i = stridx(hex, *++s)) >= 0) | ||
818 | vals[n] = (vals[n] * 0x10) + i; | ||
819 | } | ||
820 | if (++n == max_vals) | ||
821 | break; | ||
822 | if (*s == ',' || *s == ';') | ||
823 | ++s; | ||
824 | } | ||
825 | if (!*s) | ||
826 | return n; | ||
827 | } | ||
828 | return 0; /* zero = nothing matched */ | ||
829 | } | ||
830 | |||
831 | /* | ||
832 | * ide_setup() gets called VERY EARLY during initialization, | ||
833 | * to handle kernel "command line" strings beginning with "hdx=" or "ide". | ||
834 | * | ||
835 | * Remember to update Documentation/ide/ide.txt if you change something here. | ||
836 | */ | ||
837 | static int __init ide_setup(char *s) | ||
838 | { | ||
839 | ide_hwif_t *hwif; | ||
840 | ide_drive_t *drive; | ||
841 | unsigned int hw, unit; | ||
842 | int vals[3]; | ||
843 | const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1); | ||
844 | |||
845 | if (strncmp(s,"hd",2) == 0 && s[2] == '=') /* hd= is for hd.c */ | ||
846 | return 0; /* driver and not us */ | ||
847 | |||
848 | if (strncmp(s,"ide",3) && strncmp(s,"idebus",6) && strncmp(s,"hd",2)) | ||
849 | return 0; | ||
850 | |||
851 | printk(KERN_INFO "ide_setup: %s", s); | ||
852 | init_ide_data (); | ||
853 | |||
854 | #ifdef CONFIG_BLK_DEV_IDEDOUBLER | ||
855 | if (!strcmp(s, "ide=doubler")) { | ||
856 | extern int ide_doubler; | ||
857 | |||
858 | printk(" : Enabled support for IDE doublers\n"); | ||
859 | ide_doubler = 1; | ||
860 | goto obsolete_option; | ||
861 | } | ||
862 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ | ||
863 | |||
864 | if (!strcmp(s, "ide=nodma")) { | ||
865 | printk(" : Prevented DMA\n"); | ||
866 | noautodma = 1; | ||
867 | goto obsolete_option; | ||
868 | } | ||
869 | |||
870 | #ifdef CONFIG_BLK_DEV_IDEACPI | ||
871 | if (!strcmp(s, "ide=noacpi")) { | ||
872 | //printk(" : Disable IDE ACPI support.\n"); | ||
873 | ide_noacpi = 1; | ||
874 | goto obsolete_option; | ||
875 | } | ||
876 | if (!strcmp(s, "ide=acpigtf")) { | ||
877 | //printk(" : Enable IDE ACPI _GTF support.\n"); | ||
878 | ide_acpigtf = 1; | ||
879 | goto obsolete_option; | ||
880 | } | ||
881 | if (!strcmp(s, "ide=acpionboot")) { | ||
882 | //printk(" : Call IDE ACPI methods on boot.\n"); | ||
883 | ide_acpionboot = 1; | ||
884 | goto obsolete_option; | ||
885 | } | ||
886 | #endif /* CONFIG_BLK_DEV_IDEACPI */ | ||
887 | |||
888 | /* | ||
889 | * Look for drive options: "hdx=" | ||
890 | */ | ||
891 | if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) { | ||
892 | const char *hd_words[] = { | ||
893 | "none", "noprobe", "nowerr", "cdrom", "nodma", | ||
894 | "-6", "-7", "-8", "-9", "-10", | ||
895 | "noflush", "remap", "remap63", "scsi", NULL }; | ||
896 | unit = s[2] - 'a'; | ||
897 | hw = unit / MAX_DRIVES; | ||
898 | unit = unit % MAX_DRIVES; | ||
899 | hwif = &ide_hwifs[hw]; | ||
900 | drive = &hwif->drives[unit]; | ||
901 | if (strncmp(s + 4, "ide-", 4) == 0) { | ||
902 | strlcpy(drive->driver_req, s + 4, sizeof(drive->driver_req)); | ||
903 | goto obsolete_option; | ||
904 | } | ||
905 | switch (match_parm(&s[3], hd_words, vals, 3)) { | ||
906 | case -1: /* "none" */ | ||
907 | case -2: /* "noprobe" */ | ||
908 | drive->noprobe = 1; | ||
909 | goto obsolete_option; | ||
910 | case -3: /* "nowerr" */ | ||
911 | drive->bad_wstat = BAD_R_STAT; | ||
912 | goto obsolete_option; | ||
913 | case -4: /* "cdrom" */ | ||
914 | drive->present = 1; | ||
915 | drive->media = ide_cdrom; | ||
916 | /* an ATAPI device ignores DRDY */ | ||
917 | drive->ready_stat = 0; | ||
918 | goto obsolete_option; | ||
919 | case -5: /* nodma */ | ||
920 | drive->nodma = 1; | ||
921 | goto obsolete_option; | ||
922 | case -11: /* noflush */ | ||
923 | drive->noflush = 1; | ||
924 | goto obsolete_option; | ||
925 | case -12: /* "remap" */ | ||
926 | drive->remap_0_to_1 = 1; | ||
927 | goto obsolete_option; | ||
928 | case -13: /* "remap63" */ | ||
929 | drive->sect0 = 63; | ||
930 | goto obsolete_option; | ||
931 | case -14: /* "scsi" */ | ||
932 | drive->scsi = 1; | ||
933 | goto obsolete_option; | ||
934 | case 3: /* cyl,head,sect */ | ||
935 | drive->media = ide_disk; | ||
936 | drive->ready_stat = READY_STAT; | ||
937 | drive->cyl = drive->bios_cyl = vals[0]; | ||
938 | drive->head = drive->bios_head = vals[1]; | ||
939 | drive->sect = drive->bios_sect = vals[2]; | ||
940 | drive->present = 1; | ||
941 | drive->forced_geom = 1; | ||
942 | goto obsolete_option; | ||
943 | default: | ||
944 | goto bad_option; | ||
945 | } | ||
946 | } | ||
947 | |||
948 | if (s[0] != 'i' || s[1] != 'd' || s[2] != 'e') | ||
949 | goto bad_option; | ||
950 | /* | ||
951 | * Look for bus speed option: "idebus=" | ||
952 | */ | ||
953 | if (s[3] == 'b' && s[4] == 'u' && s[5] == 's') { | ||
954 | if (match_parm(&s[6], NULL, vals, 1) != 1) | ||
955 | goto bad_option; | ||
956 | if (vals[0] >= 20 && vals[0] <= 66) { | ||
957 | idebus_parameter = vals[0]; | ||
958 | } else | ||
959 | printk(" -- BAD BUS SPEED! Expected value from 20 to 66"); | ||
960 | goto obsolete_option; | ||
961 | } | ||
962 | |||
963 | bad_option: | ||
964 | printk(" -- BAD OPTION\n"); | ||
965 | return 1; | ||
966 | obsolete_option: | ||
967 | printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n"); | ||
968 | return 1; | ||
969 | } | ||
970 | |||
971 | EXPORT_SYMBOL(ide_lock); | ||
972 | |||
973 | static int ide_bus_match(struct device *dev, struct device_driver *drv) | 664 | static int ide_bus_match(struct device *dev, struct device_driver *drv) |
974 | { | 665 | { |
975 | return 1; | 666 | return 1; |
@@ -1094,13 +785,6 @@ struct bus_type ide_bus_type = { | |||
1094 | 785 | ||
1095 | EXPORT_SYMBOL_GPL(ide_bus_type); | 786 | EXPORT_SYMBOL_GPL(ide_bus_type); |
1096 | 787 | ||
1097 | static void ide_port_class_release(struct device *portdev) | ||
1098 | { | ||
1099 | ide_hwif_t *hwif = dev_get_drvdata(portdev); | ||
1100 | |||
1101 | put_device(&hwif->gendev); | ||
1102 | } | ||
1103 | |||
1104 | int ide_vlb_clk; | 788 | int ide_vlb_clk; |
1105 | EXPORT_SYMBOL_GPL(ide_vlb_clk); | 789 | EXPORT_SYMBOL_GPL(ide_vlb_clk); |
1106 | 790 | ||
@@ -1288,11 +972,6 @@ static int __init ide_init(void) | |||
1288 | int ret; | 972 | int ret; |
1289 | 973 | ||
1290 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n"); | 974 | printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n"); |
1291 | system_bus_speed = ide_system_bus_speed(); | ||
1292 | |||
1293 | printk(KERN_INFO "ide: Assuming %dMHz system bus speed " | ||
1294 | "for PIO modes%s\n", system_bus_speed, | ||
1295 | idebus_parameter ? "" : "; override with idebus=xx"); | ||
1296 | 975 | ||
1297 | ret = bus_register(&ide_bus_type); | 976 | ret = bus_register(&ide_bus_type); |
1298 | if (ret < 0) { | 977 | if (ret < 0) { |
@@ -1305,9 +984,6 @@ static int __init ide_init(void) | |||
1305 | ret = PTR_ERR(ide_port_class); | 984 | ret = PTR_ERR(ide_port_class); |
1306 | goto out_port_class; | 985 | goto out_port_class; |
1307 | } | 986 | } |
1308 | ide_port_class->dev_release = ide_port_class_release; | ||
1309 | |||
1310 | init_ide_data(); | ||
1311 | 987 | ||
1312 | proc_ide_create(); | 988 | proc_ide_create(); |
1313 | 989 | ||
@@ -1319,32 +995,7 @@ out_port_class: | |||
1319 | return ret; | 995 | return ret; |
1320 | } | 996 | } |
1321 | 997 | ||
1322 | #ifdef MODULE | 998 | static void __exit ide_exit(void) |
1323 | static char *options = NULL; | ||
1324 | module_param(options, charp, 0); | ||
1325 | MODULE_LICENSE("GPL"); | ||
1326 | |||
1327 | static void __init parse_options (char *line) | ||
1328 | { | ||
1329 | char *next = line; | ||
1330 | |||
1331 | if (line == NULL || !*line) | ||
1332 | return; | ||
1333 | while ((line = next) != NULL) { | ||
1334 | if ((next = strchr(line,' ')) != NULL) | ||
1335 | *next++ = 0; | ||
1336 | if (!ide_setup(line)) | ||
1337 | printk (KERN_INFO "Unknown option '%s'\n", line); | ||
1338 | } | ||
1339 | } | ||
1340 | |||
1341 | int __init init_module (void) | ||
1342 | { | ||
1343 | parse_options(options); | ||
1344 | return ide_init(); | ||
1345 | } | ||
1346 | |||
1347 | void __exit cleanup_module (void) | ||
1348 | { | 999 | { |
1349 | proc_ide_destroy(); | 1000 | proc_ide_destroy(); |
1350 | 1001 | ||
@@ -1353,10 +1004,7 @@ void __exit cleanup_module (void) | |||
1353 | bus_unregister(&ide_bus_type); | 1004 | bus_unregister(&ide_bus_type); |
1354 | } | 1005 | } |
1355 | 1006 | ||
1356 | #else /* !MODULE */ | ||
1357 | |||
1358 | __setup("", ide_setup); | ||
1359 | |||
1360 | module_init(ide_init); | 1007 | module_init(ide_init); |
1008 | module_exit(ide_exit); | ||
1361 | 1009 | ||
1362 | #endif /* MODULE */ | 1010 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 90c65cf97448..4ec19737f3c5 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
@@ -116,11 +116,12 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
116 | int time1, time2; | 116 | int time1, time2; |
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 : system_bus_clock(); | 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 fed7d812761c..7e74b20202df 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
@@ -64,9 +64,7 @@ | |||
64 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) | 64 | #define GAYLE_HAS_CONTROL_REG (!ide_doubler) |
65 | #define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) | 65 | #define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) |
66 | 66 | ||
67 | int ide_doubler = 0; /* support IDE doublers? */ | 67 | static int ide_doubler; |
68 | EXPORT_SYMBOL_GPL(ide_doubler); | ||
69 | |||
70 | module_param_named(doubler, ide_doubler, bool, 0); | 68 | module_param_named(doubler, ide_doubler, bool, 0); |
71 | MODULE_PARM_DESC(doubler, "enable support for IDE doublers"); | 69 | MODULE_PARM_DESC(doubler, "enable support for IDE doublers"); |
72 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ | 70 | #endif /* CONFIG_BLK_DEV_IDEDOUBLER */ |
@@ -187,7 +185,6 @@ found: | |||
187 | if (hwif) { | 185 | if (hwif) { |
188 | u8 index = hwif->index; | 186 | u8 index = hwif->index; |
189 | 187 | ||
190 | ide_init_port_data(hwif, index); | ||
191 | ide_init_port_hw(hwif, &hw); | 188 | ide_init_port_hw(hwif, &hw); |
192 | 189 | ||
193 | idx[i] = index; | 190 | idx[i] = index; |
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c deleted file mode 100644 index abdedf56643e..000000000000 --- a/drivers/ide/legacy/hd.c +++ /dev/null | |||
@@ -1,815 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1991, 1992 Linus Torvalds | ||
3 | * | ||
4 | * This is the low-level hd interrupt support. It traverses the | ||
5 | * request-list, using interrupts to jump between functions. As | ||
6 | * all the functions are called within interrupts, we may not | ||
7 | * sleep. Special care is recommended. | ||
8 | * | ||
9 | * modified by Drew Eckhardt to check nr of hd's from the CMOS. | ||
10 | * | ||
11 | * Thanks to Branko Lankester, lankeste@fwi.uva.nl, who found a bug | ||
12 | * in the early extended-partition checks and added DM partitions | ||
13 | * | ||
14 | * IRQ-unmask, drive-id, multiple-mode, support for ">16 heads", | ||
15 | * and general streamlining by Mark Lord. | ||
16 | * | ||
17 | * Removed 99% of above. Use Mark's ide driver for those options. | ||
18 | * This is now a lightweight ST-506 driver. (Paul Gortmaker) | ||
19 | * | ||
20 | * Modified 1995 Russell King for ARM processor. | ||
21 | * | ||
22 | * Bugfix: max_sectors must be <= 255 or the wheels tend to come | ||
23 | * off in a hurry once you queue things up - Paul G. 02/2001 | ||
24 | */ | ||
25 | |||
26 | /* Uncomment the following if you want verbose error reports. */ | ||
27 | /* #define VERBOSE_ERRORS */ | ||
28 | |||
29 | #include <linux/blkdev.h> | ||
30 | #include <linux/errno.h> | ||
31 | #include <linux/signal.h> | ||
32 | #include <linux/interrupt.h> | ||
33 | #include <linux/timer.h> | ||
34 | #include <linux/fs.h> | ||
35 | #include <linux/kernel.h> | ||
36 | #include <linux/genhd.h> | ||
37 | #include <linux/slab.h> | ||
38 | #include <linux/string.h> | ||
39 | #include <linux/ioport.h> | ||
40 | #include <linux/mc146818rtc.h> /* CMOS defines */ | ||
41 | #include <linux/init.h> | ||
42 | #include <linux/blkpg.h> | ||
43 | #include <linux/hdreg.h> | ||
44 | |||
45 | #define REALLY_SLOW_IO | ||
46 | #include <asm/system.h> | ||
47 | #include <asm/io.h> | ||
48 | #include <asm/uaccess.h> | ||
49 | |||
50 | #ifdef __arm__ | ||
51 | #undef HD_IRQ | ||
52 | #endif | ||
53 | #include <asm/irq.h> | ||
54 | #ifdef __arm__ | ||
55 | #define HD_IRQ IRQ_HARDDISK | ||
56 | #endif | ||
57 | |||
58 | /* Hd controller regster ports */ | ||
59 | |||
60 | #define HD_DATA 0x1f0 /* _CTL when writing */ | ||
61 | #define HD_ERROR 0x1f1 /* see err-bits */ | ||
62 | #define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */ | ||
63 | #define HD_SECTOR 0x1f3 /* starting sector */ | ||
64 | #define HD_LCYL 0x1f4 /* starting cylinder */ | ||
65 | #define HD_HCYL 0x1f5 /* high byte of starting cyl */ | ||
66 | #define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */ | ||
67 | #define HD_STATUS 0x1f7 /* see status-bits */ | ||
68 | #define HD_FEATURE HD_ERROR /* same io address, read=error, write=feature */ | ||
69 | #define HD_PRECOMP HD_FEATURE /* obsolete use of this port - predates IDE */ | ||
70 | #define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ | ||
71 | |||
72 | #define HD_CMD 0x3f6 /* used for resets */ | ||
73 | #define HD_ALTSTATUS 0x3f6 /* same as HD_STATUS but doesn't clear irq */ | ||
74 | |||
75 | /* Bits of HD_STATUS */ | ||
76 | #define ERR_STAT 0x01 | ||
77 | #define INDEX_STAT 0x02 | ||
78 | #define ECC_STAT 0x04 /* Corrected error */ | ||
79 | #define DRQ_STAT 0x08 | ||
80 | #define SEEK_STAT 0x10 | ||
81 | #define SERVICE_STAT SEEK_STAT | ||
82 | #define WRERR_STAT 0x20 | ||
83 | #define READY_STAT 0x40 | ||
84 | #define BUSY_STAT 0x80 | ||
85 | |||
86 | /* Bits for HD_ERROR */ | ||
87 | #define MARK_ERR 0x01 /* Bad address mark */ | ||
88 | #define TRK0_ERR 0x02 /* couldn't find track 0 */ | ||
89 | #define ABRT_ERR 0x04 /* Command aborted */ | ||
90 | #define MCR_ERR 0x08 /* media change request */ | ||
91 | #define ID_ERR 0x10 /* ID field not found */ | ||
92 | #define MC_ERR 0x20 /* media changed */ | ||
93 | #define ECC_ERR 0x40 /* Uncorrectable ECC error */ | ||
94 | #define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ | ||
95 | #define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ | ||
96 | |||
97 | static DEFINE_SPINLOCK(hd_lock); | ||
98 | static struct request_queue *hd_queue; | ||
99 | |||
100 | #define MAJOR_NR HD_MAJOR | ||
101 | #define QUEUE (hd_queue) | ||
102 | #define CURRENT elv_next_request(hd_queue) | ||
103 | |||
104 | #define TIMEOUT_VALUE (6*HZ) | ||
105 | #define HD_DELAY 0 | ||
106 | |||
107 | #define MAX_ERRORS 16 /* Max read/write errors/sector */ | ||
108 | #define RESET_FREQ 8 /* Reset controller every 8th retry */ | ||
109 | #define RECAL_FREQ 4 /* Recalibrate every 4th retry */ | ||
110 | #define MAX_HD 2 | ||
111 | |||
112 | #define STAT_OK (READY_STAT|SEEK_STAT) | ||
113 | #define OK_STATUS(s) (((s)&(STAT_OK|(BUSY_STAT|WRERR_STAT|ERR_STAT)))==STAT_OK) | ||
114 | |||
115 | static void recal_intr(void); | ||
116 | static void bad_rw_intr(void); | ||
117 | |||
118 | static int reset; | ||
119 | static int hd_error; | ||
120 | |||
121 | /* | ||
122 | * This struct defines the HD's and their types. | ||
123 | */ | ||
124 | struct hd_i_struct { | ||
125 | unsigned int head, sect, cyl, wpcom, lzone, ctl; | ||
126 | int unit; | ||
127 | int recalibrate; | ||
128 | int special_op; | ||
129 | }; | ||
130 | |||
131 | #ifdef HD_TYPE | ||
132 | static struct hd_i_struct hd_info[] = { HD_TYPE }; | ||
133 | static int NR_HD = ARRAY_SIZE(hd_info); | ||
134 | #else | ||
135 | static struct hd_i_struct hd_info[MAX_HD]; | ||
136 | static int NR_HD; | ||
137 | #endif | ||
138 | |||
139 | static struct gendisk *hd_gendisk[MAX_HD]; | ||
140 | |||
141 | static struct timer_list device_timer; | ||
142 | |||
143 | #define TIMEOUT_VALUE (6*HZ) | ||
144 | |||
145 | #define SET_TIMER \ | ||
146 | do { \ | ||
147 | mod_timer(&device_timer, jiffies + TIMEOUT_VALUE); \ | ||
148 | } while (0) | ||
149 | |||
150 | static void (*do_hd)(void) = NULL; | ||
151 | #define SET_HANDLER(x) \ | ||
152 | if ((do_hd = (x)) != NULL) \ | ||
153 | SET_TIMER; \ | ||
154 | else \ | ||
155 | del_timer(&device_timer); | ||
156 | |||
157 | |||
158 | #if (HD_DELAY > 0) | ||
159 | |||
160 | #include <asm/i8253.h> | ||
161 | |||
162 | unsigned long last_req; | ||
163 | |||
164 | unsigned long read_timer(void) | ||
165 | { | ||
166 | unsigned long t, flags; | ||
167 | int i; | ||
168 | |||
169 | spin_lock_irqsave(&i8253_lock, flags); | ||
170 | t = jiffies * 11932; | ||
171 | outb_p(0, 0x43); | ||
172 | i = inb_p(0x40); | ||
173 | i |= inb(0x40) << 8; | ||
174 | spin_unlock_irqrestore(&i8253_lock, flags); | ||
175 | return(t - i); | ||
176 | } | ||
177 | #endif | ||
178 | |||
179 | static void __init hd_setup(char *str, int *ints) | ||
180 | { | ||
181 | int hdind = 0; | ||
182 | |||
183 | if (ints[0] != 3) | ||
184 | return; | ||
185 | if (hd_info[0].head != 0) | ||
186 | hdind = 1; | ||
187 | hd_info[hdind].head = ints[2]; | ||
188 | hd_info[hdind].sect = ints[3]; | ||
189 | hd_info[hdind].cyl = ints[1]; | ||
190 | hd_info[hdind].wpcom = 0; | ||
191 | hd_info[hdind].lzone = ints[1]; | ||
192 | hd_info[hdind].ctl = (ints[2] > 8 ? 8 : 0); | ||
193 | NR_HD = hdind+1; | ||
194 | } | ||
195 | |||
196 | static void dump_status(const char *msg, unsigned int stat) | ||
197 | { | ||
198 | char *name = "hd?"; | ||
199 | if (CURRENT) | ||
200 | name = CURRENT->rq_disk->disk_name; | ||
201 | |||
202 | #ifdef VERBOSE_ERRORS | ||
203 | printk("%s: %s: status=0x%02x { ", name, msg, stat & 0xff); | ||
204 | if (stat & BUSY_STAT) printk("Busy "); | ||
205 | if (stat & READY_STAT) printk("DriveReady "); | ||
206 | if (stat & WRERR_STAT) printk("WriteFault "); | ||
207 | if (stat & SEEK_STAT) printk("SeekComplete "); | ||
208 | if (stat & DRQ_STAT) printk("DataRequest "); | ||
209 | if (stat & ECC_STAT) printk("CorrectedError "); | ||
210 | if (stat & INDEX_STAT) printk("Index "); | ||
211 | if (stat & ERR_STAT) printk("Error "); | ||
212 | printk("}\n"); | ||
213 | if ((stat & ERR_STAT) == 0) { | ||
214 | hd_error = 0; | ||
215 | } else { | ||
216 | hd_error = inb(HD_ERROR); | ||
217 | printk("%s: %s: error=0x%02x { ", name, msg, hd_error & 0xff); | ||
218 | if (hd_error & BBD_ERR) printk("BadSector "); | ||
219 | if (hd_error & ECC_ERR) printk("UncorrectableError "); | ||
220 | if (hd_error & ID_ERR) printk("SectorIdNotFound "); | ||
221 | if (hd_error & ABRT_ERR) printk("DriveStatusError "); | ||
222 | if (hd_error & TRK0_ERR) printk("TrackZeroNotFound "); | ||
223 | if (hd_error & MARK_ERR) printk("AddrMarkNotFound "); | ||
224 | printk("}"); | ||
225 | if (hd_error & (BBD_ERR|ECC_ERR|ID_ERR|MARK_ERR)) { | ||
226 | printk(", CHS=%d/%d/%d", (inb(HD_HCYL)<<8) + inb(HD_LCYL), | ||
227 | inb(HD_CURRENT) & 0xf, inb(HD_SECTOR)); | ||
228 | if (CURRENT) | ||
229 | printk(", sector=%ld", CURRENT->sector); | ||
230 | } | ||
231 | printk("\n"); | ||
232 | } | ||
233 | #else | ||
234 | printk("%s: %s: status=0x%02x.\n", name, msg, stat & 0xff); | ||
235 | if ((stat & ERR_STAT) == 0) { | ||
236 | hd_error = 0; | ||
237 | } else { | ||
238 | hd_error = inb(HD_ERROR); | ||
239 | printk("%s: %s: error=0x%02x.\n", name, msg, hd_error & 0xff); | ||
240 | } | ||
241 | #endif | ||
242 | } | ||
243 | |||
244 | static void check_status(void) | ||
245 | { | ||
246 | int i = inb_p(HD_STATUS); | ||
247 | |||
248 | if (!OK_STATUS(i)) { | ||
249 | dump_status("check_status", i); | ||
250 | bad_rw_intr(); | ||
251 | } | ||
252 | } | ||
253 | |||
254 | static int controller_busy(void) | ||
255 | { | ||
256 | int retries = 100000; | ||
257 | unsigned char status; | ||
258 | |||
259 | do { | ||
260 | status = inb_p(HD_STATUS); | ||
261 | } while ((status & BUSY_STAT) && --retries); | ||
262 | return status; | ||
263 | } | ||
264 | |||
265 | static int status_ok(void) | ||
266 | { | ||
267 | unsigned char status = inb_p(HD_STATUS); | ||
268 | |||
269 | if (status & BUSY_STAT) | ||
270 | return 1; /* Ancient, but does it make sense??? */ | ||
271 | if (status & WRERR_STAT) | ||
272 | return 0; | ||
273 | if (!(status & READY_STAT)) | ||
274 | return 0; | ||
275 | if (!(status & SEEK_STAT)) | ||
276 | return 0; | ||
277 | return 1; | ||
278 | } | ||
279 | |||
280 | static int controller_ready(unsigned int drive, unsigned int head) | ||
281 | { | ||
282 | int retry = 100; | ||
283 | |||
284 | do { | ||
285 | if (controller_busy() & BUSY_STAT) | ||
286 | return 0; | ||
287 | outb_p(0xA0 | (drive<<4) | head, HD_CURRENT); | ||
288 | if (status_ok()) | ||
289 | return 1; | ||
290 | } while (--retry); | ||
291 | return 0; | ||
292 | } | ||
293 | |||
294 | static void hd_out(struct hd_i_struct *disk, | ||
295 | unsigned int nsect, | ||
296 | unsigned int sect, | ||
297 | unsigned int head, | ||
298 | unsigned int cyl, | ||
299 | unsigned int cmd, | ||
300 | void (*intr_addr)(void)) | ||
301 | { | ||
302 | unsigned short port; | ||
303 | |||
304 | #if (HD_DELAY > 0) | ||
305 | while (read_timer() - last_req < HD_DELAY) | ||
306 | /* nothing */; | ||
307 | #endif | ||
308 | if (reset) | ||
309 | return; | ||
310 | if (!controller_ready(disk->unit, head)) { | ||
311 | reset = 1; | ||
312 | return; | ||
313 | } | ||
314 | SET_HANDLER(intr_addr); | ||
315 | outb_p(disk->ctl, HD_CMD); | ||
316 | port = HD_DATA; | ||
317 | outb_p(disk->wpcom >> 2, ++port); | ||
318 | outb_p(nsect, ++port); | ||
319 | outb_p(sect, ++port); | ||
320 | outb_p(cyl, ++port); | ||
321 | outb_p(cyl >> 8, ++port); | ||
322 | outb_p(0xA0 | (disk->unit << 4) | head, ++port); | ||
323 | outb_p(cmd, ++port); | ||
324 | } | ||
325 | |||
326 | static void hd_request (void); | ||
327 | |||
328 | static int drive_busy(void) | ||
329 | { | ||
330 | unsigned int i; | ||
331 | unsigned char c; | ||
332 | |||
333 | for (i = 0; i < 500000 ; i++) { | ||
334 | c = inb_p(HD_STATUS); | ||
335 | if ((c & (BUSY_STAT | READY_STAT | SEEK_STAT)) == STAT_OK) | ||
336 | return 0; | ||
337 | } | ||
338 | dump_status("reset timed out", c); | ||
339 | return 1; | ||
340 | } | ||
341 | |||
342 | static void reset_controller(void) | ||
343 | { | ||
344 | int i; | ||
345 | |||
346 | outb_p(4, HD_CMD); | ||
347 | for (i = 0; i < 1000; i++) barrier(); | ||
348 | outb_p(hd_info[0].ctl & 0x0f, HD_CMD); | ||
349 | for (i = 0; i < 1000; i++) barrier(); | ||
350 | if (drive_busy()) | ||
351 | printk("hd: controller still busy\n"); | ||
352 | else if ((hd_error = inb(HD_ERROR)) != 1) | ||
353 | printk("hd: controller reset failed: %02x\n", hd_error); | ||
354 | } | ||
355 | |||
356 | static void reset_hd(void) | ||
357 | { | ||
358 | static int i; | ||
359 | |||
360 | repeat: | ||
361 | if (reset) { | ||
362 | reset = 0; | ||
363 | i = -1; | ||
364 | reset_controller(); | ||
365 | } else { | ||
366 | check_status(); | ||
367 | if (reset) | ||
368 | goto repeat; | ||
369 | } | ||
370 | if (++i < NR_HD) { | ||
371 | struct hd_i_struct *disk = &hd_info[i]; | ||
372 | disk->special_op = disk->recalibrate = 1; | ||
373 | hd_out(disk, disk->sect, disk->sect, disk->head-1, | ||
374 | disk->cyl, WIN_SPECIFY, &reset_hd); | ||
375 | if (reset) | ||
376 | goto repeat; | ||
377 | } else | ||
378 | hd_request(); | ||
379 | } | ||
380 | |||
381 | /* | ||
382 | * Ok, don't know what to do with the unexpected interrupts: on some machines | ||
383 | * doing a reset and a retry seems to result in an eternal loop. Right now I | ||
384 | * ignore it, and just set the timeout. | ||
385 | * | ||
386 | * On laptops (and "green" PCs), an unexpected interrupt occurs whenever the | ||
387 | * drive enters "idle", "standby", or "sleep" mode, so if the status looks | ||
388 | * "good", we just ignore the interrupt completely. | ||
389 | */ | ||
390 | static void unexpected_hd_interrupt(void) | ||
391 | { | ||
392 | unsigned int stat = inb_p(HD_STATUS); | ||
393 | |||
394 | if (stat & (BUSY_STAT|DRQ_STAT|ECC_STAT|ERR_STAT)) { | ||
395 | dump_status("unexpected interrupt", stat); | ||
396 | SET_TIMER; | ||
397 | } | ||
398 | } | ||
399 | |||
400 | /* | ||
401 | * bad_rw_intr() now tries to be a bit smarter and does things | ||
402 | * according to the error returned by the controller. | ||
403 | * -Mika Liljeberg (liljeber@cs.Helsinki.FI) | ||
404 | */ | ||
405 | static void bad_rw_intr(void) | ||
406 | { | ||
407 | struct request *req = CURRENT; | ||
408 | if (req != NULL) { | ||
409 | struct hd_i_struct *disk = req->rq_disk->private_data; | ||
410 | if (++req->errors >= MAX_ERRORS || (hd_error & BBD_ERR)) { | ||
411 | end_request(req, 0); | ||
412 | disk->special_op = disk->recalibrate = 1; | ||
413 | } else if (req->errors % RESET_FREQ == 0) | ||
414 | reset = 1; | ||
415 | else if ((hd_error & TRK0_ERR) || req->errors % RECAL_FREQ == 0) | ||
416 | disk->special_op = disk->recalibrate = 1; | ||
417 | /* Otherwise just retry */ | ||
418 | } | ||
419 | } | ||
420 | |||
421 | static inline int wait_DRQ(void) | ||
422 | { | ||
423 | int retries; | ||
424 | int stat; | ||
425 | |||
426 | for (retries = 0; retries < 100000; retries++) { | ||
427 | stat = inb_p(HD_STATUS); | ||
428 | if (stat & DRQ_STAT) | ||
429 | return 0; | ||
430 | } | ||
431 | dump_status("wait_DRQ", stat); | ||
432 | return -1; | ||
433 | } | ||
434 | |||
435 | static void read_intr(void) | ||
436 | { | ||
437 | struct request *req; | ||
438 | int i, retries = 100000; | ||
439 | |||
440 | do { | ||
441 | i = (unsigned) inb_p(HD_STATUS); | ||
442 | if (i & BUSY_STAT) | ||
443 | continue; | ||
444 | if (!OK_STATUS(i)) | ||
445 | break; | ||
446 | if (i & DRQ_STAT) | ||
447 | goto ok_to_read; | ||
448 | } while (--retries > 0); | ||
449 | dump_status("read_intr", i); | ||
450 | bad_rw_intr(); | ||
451 | hd_request(); | ||
452 | return; | ||
453 | ok_to_read: | ||
454 | req = CURRENT; | ||
455 | insw(HD_DATA, req->buffer, 256); | ||
456 | req->sector++; | ||
457 | req->buffer += 512; | ||
458 | req->errors = 0; | ||
459 | i = --req->nr_sectors; | ||
460 | --req->current_nr_sectors; | ||
461 | #ifdef DEBUG | ||
462 | printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n", | ||
463 | req->rq_disk->disk_name, req->sector, req->nr_sectors, | ||
464 | req->buffer+512); | ||
465 | #endif | ||
466 | if (req->current_nr_sectors <= 0) | ||
467 | end_request(req, 1); | ||
468 | if (i > 0) { | ||
469 | SET_HANDLER(&read_intr); | ||
470 | return; | ||
471 | } | ||
472 | (void) inb_p(HD_STATUS); | ||
473 | #if (HD_DELAY > 0) | ||
474 | last_req = read_timer(); | ||
475 | #endif | ||
476 | if (elv_next_request(QUEUE)) | ||
477 | hd_request(); | ||
478 | return; | ||
479 | } | ||
480 | |||
481 | static void write_intr(void) | ||
482 | { | ||
483 | struct request *req = CURRENT; | ||
484 | int i; | ||
485 | int retries = 100000; | ||
486 | |||
487 | do { | ||
488 | i = (unsigned) inb_p(HD_STATUS); | ||
489 | if (i & BUSY_STAT) | ||
490 | continue; | ||
491 | if (!OK_STATUS(i)) | ||
492 | break; | ||
493 | if ((req->nr_sectors <= 1) || (i & DRQ_STAT)) | ||
494 | goto ok_to_write; | ||
495 | } while (--retries > 0); | ||
496 | dump_status("write_intr", i); | ||
497 | bad_rw_intr(); | ||
498 | hd_request(); | ||
499 | return; | ||
500 | ok_to_write: | ||
501 | req->sector++; | ||
502 | i = --req->nr_sectors; | ||
503 | --req->current_nr_sectors; | ||
504 | req->buffer += 512; | ||
505 | if (!i || (req->bio && req->current_nr_sectors <= 0)) | ||
506 | end_request(req, 1); | ||
507 | if (i > 0) { | ||
508 | SET_HANDLER(&write_intr); | ||
509 | outsw(HD_DATA, req->buffer, 256); | ||
510 | local_irq_enable(); | ||
511 | } else { | ||
512 | #if (HD_DELAY > 0) | ||
513 | last_req = read_timer(); | ||
514 | #endif | ||
515 | hd_request(); | ||
516 | } | ||
517 | return; | ||
518 | } | ||
519 | |||
520 | static void recal_intr(void) | ||
521 | { | ||
522 | check_status(); | ||
523 | #if (HD_DELAY > 0) | ||
524 | last_req = read_timer(); | ||
525 | #endif | ||
526 | hd_request(); | ||
527 | } | ||
528 | |||
529 | /* | ||
530 | * This is another of the error-routines I don't know what to do with. The | ||
531 | * best idea seems to just set reset, and start all over again. | ||
532 | */ | ||
533 | static void hd_times_out(unsigned long dummy) | ||
534 | { | ||
535 | char *name; | ||
536 | |||
537 | do_hd = NULL; | ||
538 | |||
539 | if (!CURRENT) | ||
540 | return; | ||
541 | |||
542 | disable_irq(HD_IRQ); | ||
543 | local_irq_enable(); | ||
544 | reset = 1; | ||
545 | name = CURRENT->rq_disk->disk_name; | ||
546 | printk("%s: timeout\n", name); | ||
547 | if (++CURRENT->errors >= MAX_ERRORS) { | ||
548 | #ifdef DEBUG | ||
549 | printk("%s: too many errors\n", name); | ||
550 | #endif | ||
551 | end_request(CURRENT, 0); | ||
552 | } | ||
553 | local_irq_disable(); | ||
554 | hd_request(); | ||
555 | enable_irq(HD_IRQ); | ||
556 | } | ||
557 | |||
558 | static int do_special_op(struct hd_i_struct *disk, struct request *req) | ||
559 | { | ||
560 | if (disk->recalibrate) { | ||
561 | disk->recalibrate = 0; | ||
562 | hd_out(disk, disk->sect, 0, 0, 0, WIN_RESTORE, &recal_intr); | ||
563 | return reset; | ||
564 | } | ||
565 | if (disk->head > 16) { | ||
566 | printk("%s: cannot handle device with more than 16 heads - giving up\n", req->rq_disk->disk_name); | ||
567 | end_request(req, 0); | ||
568 | } | ||
569 | disk->special_op = 0; | ||
570 | return 1; | ||
571 | } | ||
572 | |||
573 | /* | ||
574 | * The driver enables interrupts as much as possible. In order to do this, | ||
575 | * (a) the device-interrupt is disabled before entering hd_request(), | ||
576 | * and (b) the timeout-interrupt is disabled before the sti(). | ||
577 | * | ||
578 | * Interrupts are still masked (by default) whenever we are exchanging | ||
579 | * data/cmds with a drive, because some drives seem to have very poor | ||
580 | * tolerance for latency during I/O. The IDE driver has support to unmask | ||
581 | * interrupts for non-broken hardware, so use that driver if required. | ||
582 | */ | ||
583 | static void hd_request(void) | ||
584 | { | ||
585 | unsigned int block, nsect, sec, track, head, cyl; | ||
586 | struct hd_i_struct *disk; | ||
587 | struct request *req; | ||
588 | |||
589 | if (do_hd) | ||
590 | return; | ||
591 | repeat: | ||
592 | del_timer(&device_timer); | ||
593 | local_irq_enable(); | ||
594 | |||
595 | req = CURRENT; | ||
596 | if (!req) { | ||
597 | do_hd = NULL; | ||
598 | return; | ||
599 | } | ||
600 | |||
601 | if (reset) { | ||
602 | local_irq_disable(); | ||
603 | reset_hd(); | ||
604 | return; | ||
605 | } | ||
606 | disk = req->rq_disk->private_data; | ||
607 | block = req->sector; | ||
608 | nsect = req->nr_sectors; | ||
609 | if (block >= get_capacity(req->rq_disk) || | ||
610 | ((block+nsect) > get_capacity(req->rq_disk))) { | ||
611 | printk("%s: bad access: block=%d, count=%d\n", | ||
612 | req->rq_disk->disk_name, block, nsect); | ||
613 | end_request(req, 0); | ||
614 | goto repeat; | ||
615 | } | ||
616 | |||
617 | if (disk->special_op) { | ||
618 | if (do_special_op(disk, req)) | ||
619 | goto repeat; | ||
620 | return; | ||
621 | } | ||
622 | sec = block % disk->sect + 1; | ||
623 | track = block / disk->sect; | ||
624 | head = track % disk->head; | ||
625 | cyl = track / disk->head; | ||
626 | #ifdef DEBUG | ||
627 | printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n", | ||
628 | req->rq_disk->disk_name, | ||
629 | req_data_dir(req) == READ ? "read" : "writ", | ||
630 | cyl, head, sec, nsect, req->buffer); | ||
631 | #endif | ||
632 | if (blk_fs_request(req)) { | ||
633 | switch (rq_data_dir(req)) { | ||
634 | case READ: | ||
635 | hd_out(disk, nsect, sec, head, cyl, WIN_READ, | ||
636 | &read_intr); | ||
637 | if (reset) | ||
638 | goto repeat; | ||
639 | break; | ||
640 | case WRITE: | ||
641 | hd_out(disk, nsect, sec, head, cyl, WIN_WRITE, | ||
642 | &write_intr); | ||
643 | if (reset) | ||
644 | goto repeat; | ||
645 | if (wait_DRQ()) { | ||
646 | bad_rw_intr(); | ||
647 | goto repeat; | ||
648 | } | ||
649 | outsw(HD_DATA, req->buffer, 256); | ||
650 | break; | ||
651 | default: | ||
652 | printk("unknown hd-command\n"); | ||
653 | end_request(req, 0); | ||
654 | break; | ||
655 | } | ||
656 | } | ||
657 | } | ||
658 | |||
659 | static void do_hd_request(struct request_queue *q) | ||
660 | { | ||
661 | disable_irq(HD_IRQ); | ||
662 | hd_request(); | ||
663 | enable_irq(HD_IRQ); | ||
664 | } | ||
665 | |||
666 | static int hd_getgeo(struct block_device *bdev, struct hd_geometry *geo) | ||
667 | { | ||
668 | struct hd_i_struct *disk = bdev->bd_disk->private_data; | ||
669 | |||
670 | geo->heads = disk->head; | ||
671 | geo->sectors = disk->sect; | ||
672 | geo->cylinders = disk->cyl; | ||
673 | return 0; | ||
674 | } | ||
675 | |||
676 | /* | ||
677 | * Releasing a block device means we sync() it, so that it can safely | ||
678 | * be forgotten about... | ||
679 | */ | ||
680 | |||
681 | static irqreturn_t hd_interrupt(int irq, void *dev_id) | ||
682 | { | ||
683 | void (*handler)(void) = do_hd; | ||
684 | |||
685 | do_hd = NULL; | ||
686 | del_timer(&device_timer); | ||
687 | if (!handler) | ||
688 | handler = unexpected_hd_interrupt; | ||
689 | handler(); | ||
690 | local_irq_enable(); | ||
691 | return IRQ_HANDLED; | ||
692 | } | ||
693 | |||
694 | static struct block_device_operations hd_fops = { | ||
695 | .getgeo = hd_getgeo, | ||
696 | }; | ||
697 | |||
698 | /* | ||
699 | * This is the hard disk IRQ description. The IRQF_DISABLED in sa_flags | ||
700 | * means we run the IRQ-handler with interrupts disabled: this is bad for | ||
701 | * interrupt latency, but anything else has led to problems on some | ||
702 | * machines. | ||
703 | * | ||
704 | * We enable interrupts in some of the routines after making sure it's | ||
705 | * safe. | ||
706 | */ | ||
707 | |||
708 | static int __init hd_init(void) | ||
709 | { | ||
710 | int drive; | ||
711 | |||
712 | if (register_blkdev(MAJOR_NR, "hd")) | ||
713 | return -1; | ||
714 | |||
715 | hd_queue = blk_init_queue(do_hd_request, &hd_lock); | ||
716 | if (!hd_queue) { | ||
717 | unregister_blkdev(MAJOR_NR, "hd"); | ||
718 | return -ENOMEM; | ||
719 | } | ||
720 | |||
721 | blk_queue_max_sectors(hd_queue, 255); | ||
722 | init_timer(&device_timer); | ||
723 | device_timer.function = hd_times_out; | ||
724 | blk_queue_hardsect_size(hd_queue, 512); | ||
725 | |||
726 | if (!NR_HD) { | ||
727 | /* | ||
728 | * We don't know anything about the drive. This means | ||
729 | * that you *MUST* specify the drive parameters to the | ||
730 | * kernel yourself. | ||
731 | * | ||
732 | * If we were on an i386, we used to read this info from | ||
733 | * the BIOS or CMOS. This doesn't work all that well, | ||
734 | * since this assumes that this is a primary or secondary | ||
735 | * drive, and if we're using this legacy driver, it's | ||
736 | * probably an auxilliary controller added to recover | ||
737 | * legacy data off an ST-506 drive. Either way, it's | ||
738 | * definitely safest to have the user explicitly specify | ||
739 | * the information. | ||
740 | */ | ||
741 | printk("hd: no drives specified - use hd=cyl,head,sectors" | ||
742 | " on kernel command line\n"); | ||
743 | goto out; | ||
744 | } | ||
745 | |||
746 | for (drive = 0 ; drive < NR_HD ; drive++) { | ||
747 | struct gendisk *disk = alloc_disk(64); | ||
748 | struct hd_i_struct *p = &hd_info[drive]; | ||
749 | if (!disk) | ||
750 | goto Enomem; | ||
751 | disk->major = MAJOR_NR; | ||
752 | disk->first_minor = drive << 6; | ||
753 | disk->fops = &hd_fops; | ||
754 | sprintf(disk->disk_name, "hd%c", 'a'+drive); | ||
755 | disk->private_data = p; | ||
756 | set_capacity(disk, p->head * p->sect * p->cyl); | ||
757 | disk->queue = hd_queue; | ||
758 | p->unit = drive; | ||
759 | hd_gendisk[drive] = disk; | ||
760 | printk("%s: %luMB, CHS=%d/%d/%d\n", | ||
761 | disk->disk_name, (unsigned long)get_capacity(disk)/2048, | ||
762 | p->cyl, p->head, p->sect); | ||
763 | } | ||
764 | |||
765 | if (request_irq(HD_IRQ, hd_interrupt, IRQF_DISABLED, "hd", NULL)) { | ||
766 | printk("hd: unable to get IRQ%d for the hard disk driver\n", | ||
767 | HD_IRQ); | ||
768 | goto out1; | ||
769 | } | ||
770 | if (!request_region(HD_DATA, 8, "hd")) { | ||
771 | printk(KERN_WARNING "hd: port 0x%x busy\n", HD_DATA); | ||
772 | goto out2; | ||
773 | } | ||
774 | if (!request_region(HD_CMD, 1, "hd(cmd)")) { | ||
775 | printk(KERN_WARNING "hd: port 0x%x busy\n", HD_CMD); | ||
776 | goto out3; | ||
777 | } | ||
778 | |||
779 | /* Let them fly */ | ||
780 | for (drive = 0; drive < NR_HD; drive++) | ||
781 | add_disk(hd_gendisk[drive]); | ||
782 | |||
783 | return 0; | ||
784 | |||
785 | out3: | ||
786 | release_region(HD_DATA, 8); | ||
787 | out2: | ||
788 | free_irq(HD_IRQ, NULL); | ||
789 | out1: | ||
790 | for (drive = 0; drive < NR_HD; drive++) | ||
791 | put_disk(hd_gendisk[drive]); | ||
792 | NR_HD = 0; | ||
793 | out: | ||
794 | del_timer(&device_timer); | ||
795 | unregister_blkdev(MAJOR_NR, "hd"); | ||
796 | blk_cleanup_queue(hd_queue); | ||
797 | return -1; | ||
798 | Enomem: | ||
799 | while (drive--) | ||
800 | put_disk(hd_gendisk[drive]); | ||
801 | goto out; | ||
802 | } | ||
803 | |||
804 | static int __init parse_hd_setup(char *line) | ||
805 | { | ||
806 | int ints[6]; | ||
807 | |||
808 | (void) get_options(line, ARRAY_SIZE(ints), ints); | ||
809 | hd_setup(NULL, ints); | ||
810 | |||
811 | return 1; | ||
812 | } | ||
813 | __setup("hd=", parse_hd_setup); | ||
814 | |||
815 | module_init(hd_init); | ||
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 4fe516df9f74..7bc8fd59ea9e 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
@@ -212,10 +212,11 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio) | |||
212 | { | 212 | { |
213 | int active_time, recovery_time; | 213 | int active_time, recovery_time; |
214 | int active_cycles, recovery_cycles; | 214 | int active_cycles, recovery_cycles; |
215 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); | 215 | int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; |
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 | ||
314 | static void __init ht6560b_port_init_devs(ide_hwif_t *hwif) | 313 | static 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 | ||
326 | static int probe_ht6560b; | 325 | static int probe_ht6560b; |
@@ -329,7 +328,7 @@ module_param_named(probe, probe_ht6560b, bool, 0); | |||
329 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); | 328 | MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); |
330 | 329 | ||
331 | static const struct ide_port_ops ht6560b_port_ops = { | 330 | static 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; | |||
11 | module_param_named(probe, probe_4drives, bool, 0); | 11 | module_param_named(probe, probe_4drives, bool, 0); |
12 | MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); | 12 | MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port"); |
13 | 13 | ||
14 | static void ide_4drives_init_dev(ide_drive_t *drive) | ||
15 | { | ||
16 | if (drive->hwif->channel) | ||
17 | drive->select.all ^= 0x20; | ||
18 | } | ||
19 | |||
20 | static const struct ide_port_ops ide_4drives_port_ops = { | ||
21 | .init_dev = ide_4drives_init_dev, | ||
22 | }; | ||
23 | |||
24 | static 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 | |||
14 | static int __init ide_4drives_init(void) | 29 | static 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 3381424d70a1..27b1e0b7ecb4 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
@@ -63,11 +63,9 @@ MODULE_LICENSE("Dual MPL/GPL"); | |||
63 | 63 | ||
64 | #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0) | 64 | #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0) |
65 | 65 | ||
66 | #ifdef PCMCIA_DEBUG | 66 | #ifdef CONFIG_PCMCIA_DEBUG |
67 | INT_MODULE_PARM(pc_debug, PCMCIA_DEBUG); | 67 | INT_MODULE_PARM(pc_debug, 0); |
68 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) | 68 | #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args) |
69 | static char *version = | ||
70 | "ide-cs.c 1.3 2002/10/26 05:45:31 (David Hinds)"; | ||
71 | #else | 69 | #else |
72 | #define DEBUG(n, args...) | 70 | #define DEBUG(n, args...) |
73 | #endif | 71 | #endif |
@@ -154,6 +152,11 @@ static const struct ide_port_ops idecs_port_ops = { | |||
154 | .quirkproc = ide_undecoded_slave, | 152 | .quirkproc = ide_undecoded_slave, |
155 | }; | 153 | }; |
156 | 154 | ||
155 | static const struct ide_port_info idecs_port_info = { | ||
156 | .port_ops = &idecs_port_ops, | ||
157 | .host_flags = IDE_HFLAG_NO_DMA, | ||
158 | }; | ||
159 | |||
157 | static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, | 160 | static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, |
158 | unsigned long irq, struct pcmcia_device *handle) | 161 | unsigned long irq, struct pcmcia_device *handle) |
159 | { | 162 | { |
@@ -187,13 +190,11 @@ static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, | |||
187 | 190 | ||
188 | i = hwif->index; | 191 | i = hwif->index; |
189 | 192 | ||
190 | ide_init_port_data(hwif, i); | ||
191 | ide_init_port_hw(hwif, &hw); | 193 | ide_init_port_hw(hwif, &hw); |
192 | hwif->port_ops = &idecs_port_ops; | ||
193 | 194 | ||
194 | idx[0] = i; | 195 | idx[0] = i; |
195 | 196 | ||
196 | ide_device_add(idx, NULL); | 197 | ide_device_add(idx, &idecs_port_info); |
197 | 198 | ||
198 | if (hwif->present) | 199 | if (hwif->present) |
199 | return hwif; | 200 | return hwif; |
@@ -375,7 +376,7 @@ failed: | |||
375 | 376 | ||
376 | ======================================================================*/ | 377 | ======================================================================*/ |
377 | 378 | ||
378 | void ide_release(struct pcmcia_device *link) | 379 | static void ide_release(struct pcmcia_device *link) |
379 | { | 380 | { |
380 | ide_info_t *info = link->priv; | 381 | ide_info_t *info = link->priv; |
381 | ide_hwif_t *hwif = info->hwif; | 382 | ide_hwif_t *hwif = info->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 | ||
47 | static const struct ide_port_info platform_ide_port_info = { | ||
48 | .host_flags = IDE_HFLAG_NO_DMA, | ||
49 | }; | ||
50 | |||
47 | static int __devinit plat_ide_probe(struct platform_device *pdev) | 51 | static 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 6424af154325..2338f344ea24 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -110,7 +110,7 @@ static void qd65xx_select(ide_drive_t *drive) | |||
110 | 110 | ||
111 | static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time) | 111 | static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time) |
112 | { | 112 | { |
113 | int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); | 113 | int clk = ide_vlb_clk ? ide_vlb_clk : 50; |
114 | u8 act_cyc, rec_cyc; | 114 | u8 act_cyc, rec_cyc; |
115 | 115 | ||
116 | if (clk <= 33) { | 116 | if (clk <= 33) { |
@@ -132,7 +132,7 @@ static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery | |||
132 | 132 | ||
133 | static u8 qd6580_compute_timing (int active_time, int recovery_time) | 133 | static u8 qd6580_compute_timing (int active_time, int recovery_time) |
134 | { | 134 | { |
135 | int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); | 135 | int clk = ide_vlb_clk ? ide_vlb_clk : 50; |
136 | u8 act_cyc, rec_cyc; | 136 | u8 act_cyc, rec_cyc; |
137 | 137 | ||
138 | act_cyc = 17 - IDE_IN(active_time * clk / 1000 + 1, 2, 17); | 138 | act_cyc = 17 - IDE_IN(active_time * clk / 1000 + 1, 2, 17); |
@@ -207,6 +207,7 @@ static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
207 | static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | 207 | static 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 | ||
284 | static void __init qd6500_port_init_devs(ide_hwif_t *hwif) | 285 | static 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 | ||
293 | static void __init qd6580_port_init_devs(ide_hwif_t *hwif) | 294 | static 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 | ||
309 | static const struct ide_port_ops qd6500_port_ops = { | 310 | static 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 | ||
315 | static const struct ide_port_ops qd6580_port_ops = { | 316 | static 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 | ||
403 | static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) | 401 | static 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 |
464 | static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) | 462 | static 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 | ||
62 | static struct platform_device *swarm_ide_dev; | 62 | static struct platform_device *swarm_ide_dev; |
63 | 63 | ||
64 | static 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; |
135 | err: | ||
136 | release_resource(&swarm_ide_resource); | ||
137 | iounmap(base); | ||
138 | return -ENOMEM; | ||
133 | } | 139 | } |
134 | 140 | ||
135 | static struct device_driver swarm_ide_driver = { | 141 | static struct device_driver swarm_ide_driver = { |
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 7f46c224b7c4..ae7a4329a581 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
@@ -140,7 +140,7 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
140 | 140 | ||
141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) | 141 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) |
142 | { | 142 | { |
143 | int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); | 143 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
144 | 144 | ||
145 | if (bus_speed <= 33) | 145 | if (bus_speed <= 33) |
146 | pci_set_drvdata(dev, (void *) aec6xxx_33_base); | 146 | pci_set_drvdata(dev, (void *) aec6xxx_33_base); |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index f2129d5e07f2..80d19c0eb780 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -69,22 +69,20 @@ 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 : system_bus_clock(); | 76 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
76 | int port = hwif->channel ? 0x5c : 0x58; | 77 | int port = hwif->channel ? 0x5c : 0x58; |
77 | int portFIFO = hwif->channel ? 0x55 : 0x54; | 78 | int portFIFO = hwif->channel ? 0x55 : 0x54; |
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 efcf54338be7..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 | |||
26 | enum { | 24 | enum { |
27 | AMD_IDE_CONFIG = 0x41, | 25 | AMD_IDE_CONFIG = 0x41, |
28 | AMD_CABLE_DETECT = 0x42, | 26 | AMD_CABLE_DETECT = 0x42, |
@@ -53,20 +51,20 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask, | |||
53 | u8 t = 0, offset = amd_offset(dev); | 51 | u8 t = 0, offset = amd_offset(dev); |
54 | 52 | ||
55 | pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t); | 53 | pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t); |
56 | t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); | 54 | t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); |
57 | pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t); | 55 | pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t); |
58 | 56 | ||
59 | pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)), | 57 | pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)), |
60 | ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); | 58 | ((clamp_val(timing->act8b, 1, 16) - 1) << 4) | (clamp_val(timing->rec8b, 1, 16) - 1)); |
61 | 59 | ||
62 | pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn), | 60 | pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn), |
63 | ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); | 61 | ((clamp_val(timing->active, 1, 16) - 1) << 4) | (clamp_val(timing->recover, 1, 16) - 1)); |
64 | 62 | ||
65 | switch (udma_mask) { | 63 | switch (udma_mask) { |
66 | case ATA_UDMA2: t = timing->udma ? (0xc0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; | 64 | case ATA_UDMA2: t = timing->udma ? (0xc0 | (clamp_val(timing->udma, 2, 5) - 2)) : 0x03; break; |
67 | case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 2, 10)]) : 0x03; break; | 65 | case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 2, 10)]) : 0x03; break; |
68 | case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 10)]) : 0x03; break; | 66 | case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 1, 10)]) : 0x03; break; |
69 | case ATA_UDMA6: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 15)]) : 0x03; break; | 67 | case ATA_UDMA6: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 1, 15)]) : 0x03; break; |
70 | default: return; | 68 | default: return; |
71 | } | 69 | } |
72 | 70 | ||
@@ -179,7 +177,7 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, | |||
179 | * Determine the system bus clock. | 177 | * Determine the system bus clock. |
180 | */ | 178 | */ |
181 | 179 | ||
182 | amd_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; | 180 | amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; |
183 | 181 | ||
184 | switch (amd_clock) { | 182 | switch (amd_clock) { |
185 | case 33000: amd_clock = 33333; break; | 183 | case 33000: amd_clock = 33333; break; |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index b38a1980dcd5..1ad1e23e3105 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
@@ -521,21 +521,23 @@ static void program_drive_counts(ide_drive_t *drive, unsigned int index) | |||
521 | static void cmd640_set_mode(ide_drive_t *drive, unsigned int index, | 521 | static 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; |
527 | 528 | ||
528 | if (cmd640_vlb && ide_vlb_clk) | 529 | if (cmd640_vlb) |
529 | bus_speed = ide_vlb_clk; | 530 | bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; |
530 | else if (!cmd640_vlb && ide_pci_clk) | ||
531 | bus_speed = ide_pci_clk; | ||
532 | else | 531 | else |
533 | bus_speed = system_bus_clock(); | 532 | bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
534 | 533 | ||
535 | if (pio_mode > 5) | 534 | if (pio_mode > 5) |
536 | pio_mode = 5; | 535 | pio_mode = 5; |
537 | setup_time = ide_pio_timings[pio_mode].setup_time; | 536 | |
538 | 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 | |||
539 | recovery_time = cycle_time - (setup_time + active_time); | 541 | recovery_time = cycle_time - (setup_time + active_time); |
540 | clock_time = 1000 / bus_speed; | 542 | clock_time = 1000 / bus_speed; |
541 | cycle_count = DIV_ROUND_UP(cycle_time, clock_time); | 543 | cycle_count = DIV_ROUND_UP(cycle_time, clock_time); |
@@ -609,11 +611,40 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
609 | 611 | ||
610 | display_clocks(index); | 612 | display_clocks(index); |
611 | } | 613 | } |
614 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
615 | |||
616 | static 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 | |||
612 | 641 | ||
613 | static const struct ide_port_ops cmd640_port_ops = { | 642 | static const struct ide_port_ops cmd640_port_ops = { |
643 | .init_dev = cmd640_init_dev, | ||
644 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
614 | .set_pio_mode = cmd640_set_pio_mode, | 645 | .set_pio_mode = cmd640_set_pio_mode, |
646 | #endif | ||
615 | }; | 647 | }; |
616 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
617 | 648 | ||
618 | static int pci_conf1(void) | 649 | static int pci_conf1(void) |
619 | { | 650 | { |
@@ -656,10 +687,8 @@ static const struct ide_port_info cmd640_port_info __initdata = { | |||
656 | IDE_HFLAG_NO_DMA | | 687 | IDE_HFLAG_NO_DMA | |
657 | IDE_HFLAG_ABUSE_PREFETCH | | 688 | IDE_HFLAG_ABUSE_PREFETCH | |
658 | IDE_HFLAG_ABUSE_FAST_DEVSEL, | 689 | IDE_HFLAG_ABUSE_FAST_DEVSEL, |
659 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
660 | .port_ops = &cmd640_port_ops, | 690 | .port_ops = &cmd640_port_ops, |
661 | .pio_mask = ATA_PIO5, | 691 | .pio_mask = ATA_PIO5, |
662 | #endif | ||
663 | }; | 692 | }; |
664 | 693 | ||
665 | static int cmd640x_init_one(unsigned long base, unsigned long ctl) | 694 | static int cmd640x_init_one(unsigned long base, unsigned long ctl) |
@@ -685,12 +714,8 @@ static int cmd640x_init_one(unsigned long base, unsigned long ctl) | |||
685 | */ | 714 | */ |
686 | static int __init cmd640x_init(void) | 715 | static int __init cmd640x_init(void) |
687 | { | 716 | { |
688 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
689 | int second_port_toggled = 0; | ||
690 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
691 | int second_port_cmd640 = 0, rc; | 717 | int second_port_cmd640 = 0, rc; |
692 | const char *bus_type, *port2; | 718 | const char *bus_type, *port2; |
693 | unsigned int index; | ||
694 | u8 b, cfr; | 719 | u8 b, cfr; |
695 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 720 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
696 | hw_regs_t hw[2]; | 721 | hw_regs_t hw[2]; |
@@ -776,88 +801,44 @@ static int __init cmd640x_init(void) | |||
776 | put_cmd640_reg(CMDTIM, 0); | 801 | put_cmd640_reg(CMDTIM, 0); |
777 | put_cmd640_reg(BRST, 0x40); | 802 | put_cmd640_reg(BRST, 0x40); |
778 | 803 | ||
779 | cmd_hwif1 = ide_find_port(); | 804 | b = get_cmd640_reg(CNTRL); |
780 | 805 | ||
781 | /* | 806 | /* |
782 | * Try to enable the secondary interface, if not already enabled | 807 | * Try to enable the secondary interface, if not already enabled |
783 | */ | 808 | */ |
784 | if (cmd_hwif1 && | 809 | if (secondary_port_responding()) { |
785 | cmd_hwif1->drives[0].noprobe && cmd_hwif1->drives[1].noprobe) { | 810 | if ((b & CNTRL_ENA_2ND)) { |
786 | 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"; | ||
787 | } else { | 818 | } else { |
788 | b = get_cmd640_reg(CNTRL); | 819 | put_cmd640_reg(CNTRL, b ^ CNTRL_ENA_2ND); /* toggle the bit */ |
789 | if (secondary_port_responding()) { | 820 | if (secondary_port_responding()) { |
790 | if ((b & CNTRL_ENA_2ND)) { | 821 | second_port_cmd640 = 1; |
791 | second_port_cmd640 = 1; | 822 | port2 = "enabled"; |
792 | port2 = "okay"; | ||
793 | } else if (cmd640_vlb) { | ||
794 | second_port_cmd640 = 1; | ||
795 | port2 = "alive"; | ||
796 | } else | ||
797 | port2 = "not cmd640"; | ||
798 | } else { | 823 | } else { |
799 | put_cmd640_reg(CNTRL, b ^ CNTRL_ENA_2ND); /* toggle the bit */ | 824 | put_cmd640_reg(CNTRL, b); /* restore original setting */ |
800 | if (secondary_port_responding()) { | 825 | port2 = "not responding"; |
801 | second_port_cmd640 = 1; | ||
802 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
803 | second_port_toggled = 1; | ||
804 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
805 | port2 = "enabled"; | ||
806 | } else { | ||
807 | put_cmd640_reg(CNTRL, b); /* restore original setting */ | ||
808 | port2 = "not responding"; | ||
809 | } | ||
810 | } | 826 | } |
811 | } | 827 | } |
812 | 828 | ||
813 | /* | 829 | /* |
814 | * Initialize data for secondary cmd640 port, if enabled | 830 | * Initialize data for secondary cmd640 port, if enabled |
815 | */ | 831 | */ |
816 | if (second_port_cmd640 && cmd_hwif1) { | 832 | if (second_port_cmd640) { |
817 | ide_init_port_hw(cmd_hwif1, &hw[1]); | 833 | cmd_hwif1 = ide_find_port(); |
818 | 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 | } | ||
819 | } | 838 | } |
820 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", | 839 | printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n", |
821 | second_port_cmd640 ? "" : "not ", port2); | 840 | second_port_cmd640 ? "" : "not ", port2); |
822 | 841 | ||
823 | /* | ||
824 | * Establish initial timings/prefetch for all drives. | ||
825 | * Do not unnecessarily disturb any prior BIOS setup of these. | ||
826 | */ | ||
827 | for (index = 0; index < (2 + (second_port_cmd640 << 1)); index++) { | ||
828 | ide_drive_t *drive; | ||
829 | |||
830 | if (index > 1) { | ||
831 | if (cmd_hwif1 == NULL) | ||
832 | continue; | ||
833 | drive = &cmd_hwif1->drives[index & 1]; | ||
834 | } else { | ||
835 | if (cmd_hwif0 == NULL) | ||
836 | continue; | ||
837 | drive = &cmd_hwif0->drives[index & 1]; | ||
838 | } | ||
839 | |||
840 | #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED | ||
841 | /* | ||
842 | * Reset timing to the slowest speed and turn off prefetch. | ||
843 | * This way, the drive identify code has a better chance. | ||
844 | */ | ||
845 | setup_counts [index] = 4; /* max possible */ | ||
846 | active_counts [index] = 16; /* max possible */ | ||
847 | recovery_counts [index] = 16; /* max possible */ | ||
848 | program_drive_counts(drive, index); | ||
849 | set_prefetch_mode(drive, index, 0); | ||
850 | printk("cmd640: drive%d timings/prefetch cleared\n", index); | ||
851 | #else | ||
852 | /* | ||
853 | * Set the drive unmask flags to match the prefetch setting | ||
854 | */ | ||
855 | check_prefetch(drive, index); | ||
856 | printk("cmd640: drive%d timings/prefetch(%s) preserved\n", | ||
857 | index, drive->no_io_32bit ? "off" : "on"); | ||
858 | #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ | ||
859 | } | ||
860 | |||
861 | #ifdef CMD640_DUMP_REGS | 842 | #ifdef CMD640_DUMP_REGS |
862 | cmd640_dump_regs(); | 843 | cmd640_dump_regs(); |
863 | #endif | 844 | #endif |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 08674711d089..cfa784bacf48 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
@@ -69,7 +69,7 @@ static u8 quantize_timing(int timing, int quant) | |||
69 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) | 69 | static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) |
70 | { | 70 | { |
71 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); | 71 | struct pci_dev *dev = to_pci_dev(drive->hwif->dev); |
72 | int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : system_bus_clock()); | 72 | int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : 33); |
73 | u8 cycle_count, active_count, recovery_count, drwtim; | 73 | u8 cycle_count, active_count, recovery_count, drwtim; |
74 | static const u8 recovery_values[] = | 74 | static const u8 recovery_values[] = |
75 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; | 75 | {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; |
@@ -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,11 +125,10 @@ 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 : system_bus_clock())); | 131 | 1000 / (ide_pci_clk ? ide_pci_clk : 33)); |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * The primary channel has individual address setup timing registers | 134 | * The primary channel has individual address setup timing registers |
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 | */ |
76 | static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) | 74 | static 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 77cc22c2ad45..e14ad5530fa4 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
@@ -133,23 +133,22 @@ static int calc_clk(int time, int bus_speed) | |||
133 | */ | 133 | */ |
134 | static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) | 134 | static 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 : system_bus_clock(); | 138 | int bus_speed = ide_pci_clk ? ide_pci_clk : 33; |
138 | 139 | ||
139 | /* we don't check against CY82C693's min and max speed, | 140 | /* we don't check against CY82C693's min and max speed, |
140 | * so you can play with the idebus=xx parameter | 141 | * so you can play with the idebus=xx parameter |
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/hpt366.c b/drivers/ide/pci/hpt366.c index c929dadaaaff..397c6cbe953c 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
@@ -759,8 +759,7 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask) | |||
759 | enable_irq (hwif->irq); | 759 | enable_irq (hwif->irq); |
760 | } | 760 | } |
761 | } else | 761 | } else |
762 | outb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), | 762 | outb(ATA_DEVCTL_OBS | (mask ? 2 : 0), hwif->io_ports.ctl_addr); |
763 | hwif->io_ports.ctl_addr); | ||
764 | } | 763 | } |
765 | 764 | ||
766 | /* | 765 | /* |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 9053c8771e6e..2b71bdf74e73 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
@@ -184,8 +184,7 @@ static const struct ide_port_info it8213_chipsets[] __devinitdata = { | |||
184 | 184 | ||
185 | static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 185 | static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
186 | { | 186 | { |
187 | ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]); | 187 | return ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]); |
188 | return 0; | ||
189 | } | 188 | } |
190 | 189 | ||
191 | static const struct pci_device_id it8213_pci_tbl[] = { | 190 | static const struct pci_device_id it8213_pci_tbl[] = { |
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 | ||
514 | static struct ide_dma_ops it821x_pass_through_dma_ops = { | 514 | static 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/ns87415.c b/drivers/ide/pci/ns87415.c index fec4955f449b..45ba71a7182f 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
@@ -76,7 +76,7 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | /* be sure we're looking at the low order bits */ | 78 | /* be sure we're looking at the low order bits */ |
79 | outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 79 | outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
80 | 80 | ||
81 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 81 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
82 | tf->nsect = inb(io_ports->nsect_addr); | 82 | tf->nsect = inb(io_ports->nsect_addr); |
@@ -90,7 +90,7 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
90 | tf->device = superio_ide_inb(io_ports->device_addr); | 90 | tf->device = superio_ide_inb(io_ports->device_addr); |
91 | 91 | ||
92 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 92 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
93 | outb(drive->ctl | 0x80, io_ports->ctl_addr); | 93 | outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
94 | 94 | ||
95 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 95 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
96 | tf->hob_feature = inb(io_ports->feature_addr); | 96 | tf->hob_feature = inb(io_ports->feature_addr); |
@@ -225,10 +225,6 @@ static int ns87415_dma_setup(ide_drive_t *drive) | |||
225 | return 1; | 225 | return 1; |
226 | } | 226 | } |
227 | 227 | ||
228 | #ifndef ide_default_irq | ||
229 | #define ide_default_irq(irq) 0 | ||
230 | #endif | ||
231 | |||
232 | static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | 228 | static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) |
233 | { | 229 | { |
234 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 230 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
@@ -288,7 +284,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
288 | } | 284 | } |
289 | 285 | ||
290 | if (!using_inta) | 286 | if (!using_inta) |
291 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); | 287 | hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); |
292 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) | 288 | else if (!hwif->irq && hwif->mate && hwif->mate->irq) |
293 | hwif->irq = hwif->mate->irq; /* share IRQ with mate */ | 289 | hwif->irq = hwif->mate->irq; /* share IRQ with mate */ |
294 | 290 | ||
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 910fb00deb71..789c66dfbde5 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -148,11 +148,8 @@ static void scc_ide_outb(u8 addr, unsigned long port) | |||
148 | out_be32((void*)port, addr); | 148 | out_be32((void*)port, addr); |
149 | } | 149 | } |
150 | 150 | ||
151 | static void | 151 | static void scc_ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port) |
152 | scc_ide_outbsync(ide_drive_t * drive, u8 addr, unsigned long port) | ||
153 | { | 152 | { |
154 | ide_hwif_t *hwif = HWIF(drive); | ||
155 | |||
156 | out_be32((void*)port, addr); | 153 | out_be32((void*)port, addr); |
157 | eieio(); | 154 | eieio(); |
158 | in_be32((void*)(hwif->dma_base + 0x01c)); | 155 | in_be32((void*)(hwif->dma_base + 0x01c)); |
@@ -561,12 +558,9 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
561 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | 558 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
562 | int i; | 559 | int i; |
563 | 560 | ||
564 | hwif = ide_find_port(); | 561 | hwif = ide_find_port_slot(d); |
565 | if (hwif == NULL) { | 562 | if (hwif == NULL) |
566 | printk(KERN_ERR "%s: too many IDE interfaces, " | ||
567 | "no room in table\n", SCC_PATA_NAME); | ||
568 | return -ENOMEM; | 563 | return -ENOMEM; |
569 | } | ||
570 | 564 | ||
571 | memset(&hw, 0, sizeof(hw)); | 565 | memset(&hw, 0, sizeof(hw)); |
572 | for (i = 0; i <= 8; i++) | 566 | for (i = 0; i <= 8; i++) |
@@ -575,7 +569,6 @@ static int scc_ide_setup_pci_device(struct pci_dev *dev, | |||
575 | hw.dev = &dev->dev; | 569 | hw.dev = &dev->dev; |
576 | hw.chipset = ide_pci; | 570 | hw.chipset = ide_pci; |
577 | ide_init_port_hw(hwif, &hw); | 571 | ide_init_port_hw(hwif, &hw); |
578 | hwif->dev = &dev->dev; | ||
579 | 572 | ||
580 | idx[0] = hwif->index; | 573 | idx[0] = hwif->index; |
581 | 574 | ||
@@ -662,8 +655,6 @@ static void scc_tf_load(ide_drive_t *drive, ide_task_t *task) | |||
662 | if (task->tf_flags & IDE_TFLAG_FLAGGED) | 655 | if (task->tf_flags & IDE_TFLAG_FLAGGED) |
663 | HIHI = 0xFF; | 656 | HIHI = 0xFF; |
664 | 657 | ||
665 | ide_set_irq(drive, 1); | ||
666 | |||
667 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) | 658 | if (task->tf_flags & IDE_TFLAG_OUT_DATA) |
668 | out_be32((void *)io_ports->data_addr, | 659 | out_be32((void *)io_ports->data_addr, |
669 | (tf->hob_data << 8) | tf->data); | 660 | (tf->hob_data << 8) | tf->data); |
@@ -708,7 +699,7 @@ static void scc_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
708 | } | 699 | } |
709 | 700 | ||
710 | /* be sure we're looking at the low order bits */ | 701 | /* be sure we're looking at the low order bits */ |
711 | scc_ide_outb(drive->ctl & ~0x80, io_ports->ctl_addr); | 702 | scc_ide_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr); |
712 | 703 | ||
713 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) | 704 | if (task->tf_flags & IDE_TFLAG_IN_NSECT) |
714 | tf->nsect = scc_ide_inb(io_ports->nsect_addr); | 705 | tf->nsect = scc_ide_inb(io_ports->nsect_addr); |
@@ -722,7 +713,7 @@ static void scc_tf_read(ide_drive_t *drive, ide_task_t *task) | |||
722 | tf->device = scc_ide_inb(io_ports->device_addr); | 713 | tf->device = scc_ide_inb(io_ports->device_addr); |
723 | 714 | ||
724 | if (task->tf_flags & IDE_TFLAG_LBA48) { | 715 | if (task->tf_flags & IDE_TFLAG_LBA48) { |
725 | scc_ide_outb(drive->ctl | 0x80, io_ports->ctl_addr); | 716 | scc_ide_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr); |
726 | 717 | ||
727 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) | 718 | if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) |
728 | tf->hob_feature = scc_ide_inb(io_ports->feature_addr); | 719 | tf->hob_feature = scc_ide_inb(io_ports->feature_addr); |
@@ -795,7 +786,6 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | |||
795 | 786 | ||
796 | hwif->dma_base = dma_base; | 787 | hwif->dma_base = dma_base; |
797 | hwif->config_data = ports->ctl; | 788 | hwif->config_data = ports->ctl; |
798 | hwif->mmio = 1; | ||
799 | } | 789 | } |
800 | 790 | ||
801 | /** | 791 | /** |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 16a0bce17d69..c79ff5b41088 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
@@ -111,7 +111,7 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port, | |||
111 | static void | 111 | static void |
112 | sgiioc4_maskproc(ide_drive_t * drive, int mask) | 112 | sgiioc4_maskproc(ide_drive_t * drive, int mask) |
113 | { | 113 | { |
114 | writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), | 114 | writeb(ATA_DEVCTL_OBS | (mask ? 2 : 0), |
115 | (void __iomem *)drive->hwif->io_ports.ctl_addr); | 115 | (void __iomem *)drive->hwif->io_ports.ctl_addr); |
116 | } | 116 | } |
117 | 117 | ||
@@ -369,8 +369,7 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
369 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; | 369 | hwif->sg_max_nents = IOC4_PRD_ENTRIES; |
370 | 370 | ||
371 | pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, | 371 | pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, |
372 | (dma_addr_t *) &(hwif->dma_status)); | 372 | (dma_addr_t *)&hwif->extra_base); |
373 | |||
374 | if (pad) { | 373 | if (pad) { |
375 | ide_set_hwifdata(hwif, pad); | 374 | ide_set_hwifdata(hwif, pad); |
376 | return 0; | 375 | return 0; |
@@ -439,7 +438,7 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive) | |||
439 | 438 | ||
440 | /* Address of the Ending DMA */ | 439 | /* Address of the Ending DMA */ |
441 | memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE); | 440 | memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE); |
442 | ending_dma_addr = cpu_to_le32(hwif->dma_status); | 441 | ending_dma_addr = cpu_to_le32(hwif->extra_base); |
443 | writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4)); | 442 | writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4)); |
444 | 443 | ||
445 | writel(dma_direction, (void __iomem *)ioc4_dma_addr); | 444 | writel(dma_direction, (void __iomem *)ioc4_dma_addr); |
@@ -569,6 +568,7 @@ static const struct ide_dma_ops sgiioc4_dma_ops = { | |||
569 | }; | 568 | }; |
570 | 569 | ||
571 | static const struct ide_port_info sgiioc4_port_info __devinitdata = { | 570 | static const struct ide_port_info sgiioc4_port_info __devinitdata = { |
571 | .name = DRV_NAME, | ||
572 | .chipset = ide_pci, | 572 | .chipset = ide_pci, |
573 | .init_dma = ide_dma_sgiioc4, | 573 | .init_dma = ide_dma_sgiioc4, |
574 | .port_ops = &sgiioc4_port_ops, | 574 | .port_ops = &sgiioc4_port_ops, |
@@ -588,13 +588,6 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
588 | hw_regs_t hw; | 588 | hw_regs_t hw; |
589 | struct ide_port_info d = sgiioc4_port_info; | 589 | struct ide_port_info d = sgiioc4_port_info; |
590 | 590 | ||
591 | hwif = ide_find_port(); | ||
592 | if (hwif == NULL) { | ||
593 | printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", | ||
594 | DRV_NAME); | ||
595 | return -ENOMEM; | ||
596 | } | ||
597 | |||
598 | /* Get the CmdBlk and CtrlBlk Base Registers */ | 591 | /* Get the CmdBlk and CtrlBlk Base Registers */ |
599 | bar0 = pci_resource_start(dev, 0); | 592 | bar0 = pci_resource_start(dev, 0); |
600 | virt_base = ioremap(bar0, pci_resource_len(dev, 0)); | 593 | virt_base = ioremap(bar0, pci_resource_len(dev, 0)); |
@@ -609,11 +602,11 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
609 | 602 | ||
610 | cmd_phys_base = bar0 + IOC4_CMD_OFFSET; | 603 | cmd_phys_base = bar0 + IOC4_CMD_OFFSET; |
611 | 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, |
612 | hwif->name)) { | 605 | DRV_NAME)) { |
613 | printk(KERN_ERR | 606 | printk(KERN_ERR |
614 | "%s : %s -- ERROR, Addresses " | 607 | "%s : %s -- ERROR, Addresses " |
615 | "0x%p to 0x%p ALREADY in use\n", | 608 | "0x%p to 0x%p ALREADY in use\n", |
616 | __func__, hwif->name, (void *) cmd_phys_base, | 609 | __func__, DRV_NAME, (void *) cmd_phys_base, |
617 | (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); | 610 | (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); |
618 | return -ENOMEM; | 611 | return -ENOMEM; |
619 | } | 612 | } |
@@ -624,9 +617,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
624 | hw.irq = dev->irq; | 617 | hw.irq = dev->irq; |
625 | hw.chipset = ide_pci; | 618 | hw.chipset = ide_pci; |
626 | hw.dev = &dev->dev; | 619 | hw.dev = &dev->dev; |
627 | ide_init_port_hw(hwif, &hw); | ||
628 | 620 | ||
629 | 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); | ||
630 | 626 | ||
631 | /* The IOC4 uses MMIO rather than Port IO. */ | 627 | /* The IOC4 uses MMIO rather than Port IO. */ |
632 | default_hwif_mmiops(hwif); | 628 | default_hwif_mmiops(hwif); |
@@ -642,6 +638,10 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev) | |||
642 | return -EIO; | 638 | return -EIO; |
643 | 639 | ||
644 | return 0; | 640 | return 0; |
641 | err: | ||
642 | release_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE); | ||
643 | iounmap(virt_base); | ||
644 | return -ENOMEM; | ||
645 | } | 645 | } |
646 | 646 | ||
647 | static unsigned int __devinit | 647 | static unsigned int __devinit |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 0006b9e58567..6e9d7655d89c 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
@@ -94,7 +94,7 @@ static unsigned long siimage_selreg(ide_hwif_t *hwif, int r) | |||
94 | unsigned long base = (unsigned long)hwif->hwif_data; | 94 | unsigned long base = (unsigned long)hwif->hwif_data; |
95 | 95 | ||
96 | base += 0xA0 + r; | 96 | base += 0xA0 + r; |
97 | if (hwif->mmio) | 97 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
98 | base += hwif->channel << 6; | 98 | base += hwif->channel << 6; |
99 | else | 99 | else |
100 | base += hwif->channel << 4; | 100 | base += hwif->channel << 4; |
@@ -117,7 +117,7 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r) | |||
117 | unsigned long base = (unsigned long)hwif->hwif_data; | 117 | unsigned long base = (unsigned long)hwif->hwif_data; |
118 | 118 | ||
119 | base += 0xA0 + r; | 119 | base += 0xA0 + r; |
120 | if (hwif->mmio) | 120 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
121 | base += hwif->channel << 6; | 121 | base += hwif->channel << 6; |
122 | else | 122 | else |
123 | base += hwif->channel << 4; | 123 | base += hwif->channel << 4; |
@@ -190,7 +190,9 @@ static u8 sil_pata_udma_filter(ide_drive_t *drive) | |||
190 | unsigned long base = (unsigned long)hwif->hwif_data; | 190 | unsigned long base = (unsigned long)hwif->hwif_data; |
191 | u8 scsc, mask = 0; | 191 | u8 scsc, mask = 0; |
192 | 192 | ||
193 | scsc = sil_ioread8(dev, base + (hwif->mmio ? 0x4A : 0x8A)); | 193 | base += (hwif->host_flags & IDE_HFLAG_MMIO) ? 0x4A : 0x8A; |
194 | |||
195 | scsc = sil_ioread8(dev, base); | ||
194 | 196 | ||
195 | switch (scsc & 0x30) { | 197 | switch (scsc & 0x30) { |
196 | case 0x10: /* 133 */ | 198 | case 0x10: /* 133 */ |
@@ -238,8 +240,9 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
238 | unsigned long tfaddr = siimage_selreg(hwif, 0x02); | 240 | unsigned long tfaddr = siimage_selreg(hwif, 0x02); |
239 | unsigned long base = (unsigned long)hwif->hwif_data; | 241 | unsigned long base = (unsigned long)hwif->hwif_data; |
240 | u8 tf_pio = pio; | 242 | u8 tf_pio = pio; |
241 | u8 addr_mask = hwif->channel ? (hwif->mmio ? 0xF4 : 0x84) | 243 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
242 | : (hwif->mmio ? 0xB4 : 0x80); | 244 | u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) |
245 | : (mmio ? 0xB4 : 0x80); | ||
243 | u8 mode = 0; | 246 | u8 mode = 0; |
244 | u8 unit = drive->select.b.unit; | 247 | u8 unit = drive->select.b.unit; |
245 | 248 | ||
@@ -290,13 +293,13 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
290 | u16 ultra = 0, multi = 0; | 293 | u16 ultra = 0, multi = 0; |
291 | u8 mode = 0, unit = drive->select.b.unit; | 294 | u8 mode = 0, unit = drive->select.b.unit; |
292 | unsigned long base = (unsigned long)hwif->hwif_data; | 295 | unsigned long base = (unsigned long)hwif->hwif_data; |
293 | u8 scsc = 0, addr_mask = hwif->channel ? | 296 | u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; |
294 | (hwif->mmio ? 0xF4 : 0x84) : | 297 | u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) |
295 | (hwif->mmio ? 0xB4 : 0x80); | 298 | : (mmio ? 0xB4 : 0x80); |
296 | unsigned long ma = siimage_seldev(drive, 0x08); | 299 | unsigned long ma = siimage_seldev(drive, 0x08); |
297 | unsigned long ua = siimage_seldev(drive, 0x0C); | 300 | unsigned long ua = siimage_seldev(drive, 0x0C); |
298 | 301 | ||
299 | scsc = sil_ioread8 (dev, base + (hwif->mmio ? 0x4A : 0x8A)); | 302 | scsc = sil_ioread8 (dev, base + (mmio ? 0x4A : 0x8A)); |
300 | mode = sil_ioread8 (dev, base + addr_mask); | 303 | mode = sil_ioread8 (dev, base + addr_mask); |
301 | multi = sil_ioread16(dev, ma); | 304 | multi = sil_ioread16(dev, ma); |
302 | ultra = sil_ioread16(dev, ua); | 305 | ultra = sil_ioread16(dev, ua); |
@@ -391,7 +394,7 @@ static int siimage_mmio_dma_test_irq(ide_drive_t *drive) | |||
391 | 394 | ||
392 | static int siimage_dma_test_irq(ide_drive_t *drive) | 395 | static int siimage_dma_test_irq(ide_drive_t *drive) |
393 | { | 396 | { |
394 | if (drive->hwif->mmio) | 397 | if (drive->hwif->host_flags & IDE_HFLAG_MMIO) |
395 | return siimage_mmio_dma_test_irq(drive); | 398 | return siimage_mmio_dma_test_irq(drive); |
396 | else | 399 | else |
397 | return siimage_io_dma_test_irq(drive); | 400 | return siimage_io_dma_test_irq(drive); |
@@ -418,8 +421,7 @@ static int sil_sata_reset_poll(ide_drive_t *drive) | |||
418 | if ((sata_stat & 0x03) != 0x03) { | 421 | if ((sata_stat & 0x03) != 0x03) { |
419 | printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", | 422 | printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n", |
420 | hwif->name, sata_stat); | 423 | hwif->name, sata_stat); |
421 | HWGROUP(drive)->polling = 0; | 424 | return -ENXIO; |
422 | return ide_started; | ||
423 | } | 425 | } |
424 | } | 426 | } |
425 | 427 | ||
@@ -640,8 +642,6 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
640 | hwif->irq = dev->irq; | 642 | hwif->irq = dev->irq; |
641 | 643 | ||
642 | hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); | 644 | hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); |
643 | |||
644 | hwif->mmio = 1; | ||
645 | } | 645 | } |
646 | 646 | ||
647 | static int is_dev_seagate_sata(ide_drive_t *drive) | 647 | static int is_dev_seagate_sata(ide_drive_t *drive) |
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 | */ |
48 | static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) | 48 | static 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 566e0ecb8db1..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 |
@@ -120,21 +118,21 @@ static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) | |||
120 | 118 | ||
121 | if (~vdev->via_config->flags & VIA_BAD_AST) { | 119 | if (~vdev->via_config->flags & VIA_BAD_AST) { |
122 | pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); | 120 | pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); |
123 | t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); | 121 | t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); |
124 | pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); | 122 | pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); |
125 | } | 123 | } |
126 | 124 | ||
127 | pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)), | 125 | pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)), |
128 | ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); | 126 | ((clamp_val(timing->act8b, 1, 16) - 1) << 4) | (clamp_val(timing->rec8b, 1, 16) - 1)); |
129 | 127 | ||
130 | pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), | 128 | pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), |
131 | ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); | 129 | ((clamp_val(timing->active, 1, 16) - 1) << 4) | (clamp_val(timing->recover, 1, 16) - 1)); |
132 | 130 | ||
133 | switch (vdev->via_config->udma_mask) { | 131 | switch (vdev->via_config->udma_mask) { |
134 | case ATA_UDMA2: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; | 132 | case ATA_UDMA2: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 5) - 2)) : 0x03; break; |
135 | case ATA_UDMA4: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; | 133 | case ATA_UDMA4: t = timing->udma ? (0xe8 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x0f; break; |
136 | case ATA_UDMA5: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; | 134 | case ATA_UDMA5: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; |
137 | case ATA_UDMA6: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; | 135 | case ATA_UDMA6: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break; |
138 | default: return; | 136 | default: return; |
139 | } | 137 | } |
140 | 138 | ||
@@ -340,7 +338,7 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const | |||
340 | * Determine system bus clock. | 338 | * Determine system bus clock. |
341 | */ | 339 | */ |
342 | 340 | ||
343 | via_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; | 341 | via_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000; |
344 | 342 | ||
345 | switch (via_clock) { | 343 | switch (via_clock) { |
346 | case 33000: via_clock = 33333; break; | 344 | case 33000: via_clock = 33333; break; |
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 | ||
2 | obj-$(CONFIG_BLK_DEV_IDE_PMAC) += pmac.o | 2 | obj-$(CONFIG_BLK_DEV_IDE_PMAC) += pmac.o |
3 | obj-$(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 | |||
41 | static int identify (volatile u8 *p); | ||
42 | static void print_fixed (volatile u8 *p); | ||
43 | static void print_funcid (int func); | ||
44 | static int check_ide_device (unsigned long base); | ||
45 | |||
46 | static void ide_interrupt_ack (void *dev); | ||
47 | static void m8xx_ide_set_pio_mode(ide_drive_t *drive, const u8 pio); | ||
48 | |||
49 | typedef 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 | |||
55 | ide_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 | |||
92 | ide_pio_timings_t ide_pio_clocks[6]; | ||
93 | int 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 | */ | ||
99 | static 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 */ | ||
120 | static 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) | ||
132 | static 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) | ||
317 | static 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 */ | ||
400 | static 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 | |||
449 | static const struct ide_port_ops m8xx_port_ops = { | ||
450 | .set_pio_mode = m8xx_ide_set_pio_mode, | ||
451 | }; | ||
452 | |||
453 | static void | ||
454 | ide_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 | |||
576 | static 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 | |||
660 | static 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 | |||
699 | static 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 | |||
757 | static u8 *known_cards[] = { | ||
758 | "ARGOSY PnPIDE D5", | ||
759 | NULL | ||
760 | }; | ||
761 | |||
762 | static 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 | |||
810 | static 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 | |||
849 | module_init(mpc8xx_ide_probe); | ||
850 | |||
851 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index ba2d58727964..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 |
@@ -480,13 +478,13 @@ pmac_ide_do_update_timings(ide_drive_t *drive) | |||
480 | pmac_ide_selectproc(drive); | 478 | pmac_ide_selectproc(drive); |
481 | } | 479 | } |
482 | 480 | ||
483 | static void | 481 | static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port) |
484 | pmac_outbsync(ide_drive_t *drive, u8 value, unsigned long port) | ||
485 | { | 482 | { |
486 | u32 tmp; | 483 | u32 tmp; |
487 | 484 | ||
488 | writeb(value, (void __iomem *) port); | 485 | writeb(value, (void __iomem *) port); |
489 | tmp = readl(PMAC_IDE_REG(IDE_TIMING_CONFIG)); | 486 | tmp = readl((void __iomem *)(hwif->io_ports.data_addr |
487 | + IDE_TIMING_CONFIG)); | ||
490 | } | 488 | } |
491 | 489 | ||
492 | /* | 490 | /* |
@@ -495,6 +493,7 @@ pmac_outbsync(ide_drive_t *drive, u8 value, unsigned long port) | |||
495 | static void | 493 | static void |
496 | pmac_ide_set_pio_mode(ide_drive_t *drive, const u8 pio) | 494 | pmac_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 5171601fb255..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 |
@@ -87,7 +83,7 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
87 | unsigned long dma_base = 0; | 83 | unsigned long dma_base = 0; |
88 | u8 dma_stat = 0; | 84 | u8 dma_stat = 0; |
89 | 85 | ||
90 | if (hwif->mmio) | 86 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
91 | return hwif->dma_base; | 87 | return hwif->dma_base; |
92 | 88 | ||
93 | if (hwif->mate && hwif->mate->dma_base) { | 89 | if (hwif->mate && hwif->mate->dma_base) { |
@@ -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 | ||
@@ -374,7 +365,7 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) | |||
374 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) | 365 | if (base == 0 || ide_pci_set_master(dev, d->name) < 0) |
375 | return -1; | 366 | return -1; |
376 | 367 | ||
377 | if (hwif->mmio) | 368 | if (hwif->host_flags & IDE_HFLAG_MMIO) |
378 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); | 369 | printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); |
379 | else | 370 | else |
380 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", | 371 | printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", |