aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-11-10 03:10:44 -0500
committerIngo Molnar <mingo@elte.hu>2008-11-10 03:10:44 -0500
commita5a64498c194c82ecad3a2d67cff6231cda8d3dd (patch)
tree723d5d81419f9960b8d30ed9a2ece8a58d6c4328 /drivers/ide
parentbb93d802ae5c1949977cc6da247b218240677f11 (diff)
parentf7160c7573615ec82c691e294cf80d920b5d588d (diff)
Merge commit 'v2.6.28-rc4' into timers/rtc
Conflicts: drivers/rtc/rtc-cmos.c
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/Kconfig98
-rw-r--r--drivers/ide/Makefile103
-rw-r--r--drivers/ide/aec62xx.c (renamed from drivers/ide/pci/aec62xx.c)0
-rw-r--r--drivers/ide/ali14xx.c (renamed from drivers/ide/legacy/ali14xx.c)0
-rw-r--r--drivers/ide/alim15x3.c (renamed from drivers/ide/pci/alim15x3.c)2
-rw-r--r--drivers/ide/amd74xx.c (renamed from drivers/ide/pci/amd74xx.c)0
-rw-r--r--drivers/ide/arm/Makefile10
-rw-r--r--drivers/ide/atiixp.c (renamed from drivers/ide/pci/atiixp.c)0
-rw-r--r--drivers/ide/au1xxx-ide.c (renamed from drivers/ide/mips/au1xxx-ide.c)0
-rw-r--r--drivers/ide/buddha.c (renamed from drivers/ide/legacy/buddha.c)0
-rw-r--r--drivers/ide/cmd640.c (renamed from drivers/ide/pci/cmd640.c)0
-rw-r--r--drivers/ide/cmd64x.c (renamed from drivers/ide/pci/cmd64x.c)0
-rw-r--r--drivers/ide/cs5520.c (renamed from drivers/ide/pci/cs5520.c)0
-rw-r--r--drivers/ide/cs5530.c (renamed from drivers/ide/pci/cs5530.c)0
-rw-r--r--drivers/ide/cs5535.c (renamed from drivers/ide/pci/cs5535.c)0
-rw-r--r--drivers/ide/cy82c693.c (renamed from drivers/ide/pci/cy82c693.c)0
-rw-r--r--drivers/ide/delkin_cb.c (renamed from drivers/ide/pci/delkin_cb.c)63
-rw-r--r--drivers/ide/dtc2278.c (renamed from drivers/ide/legacy/dtc2278.c)0
-rw-r--r--drivers/ide/falconide.c (renamed from drivers/ide/legacy/falconide.c)0
-rw-r--r--drivers/ide/gayle.c (renamed from drivers/ide/legacy/gayle.c)0
-rw-r--r--drivers/ide/h8300/Makefile2
-rw-r--r--drivers/ide/hpt366.c (renamed from drivers/ide/pci/hpt366.c)37
-rw-r--r--drivers/ide/ht6560b.c (renamed from drivers/ide/legacy/ht6560b.c)0
-rw-r--r--drivers/ide/icside.c (renamed from drivers/ide/arm/icside.c)4
-rw-r--r--drivers/ide/ide-4drives.c (renamed from drivers/ide/legacy/ide-4drives.c)0
-rw-r--r--drivers/ide/ide-atapi.c2
-rw-r--r--drivers/ide/ide-cd.c87
-rw-r--r--drivers/ide/ide-cd_ioctl.c8
-rw-r--r--drivers/ide/ide-cs.c (renamed from drivers/ide/legacy/ide-cs.c)0
-rw-r--r--drivers/ide/ide-disk.c392
-rw-r--r--drivers/ide/ide-disk.h21
-rw-r--r--drivers/ide/ide-disk_ioctl.c7
-rw-r--r--drivers/ide/ide-disk_proc.c2
-rw-r--r--drivers/ide/ide-dma-sff.c2
-rw-r--r--drivers/ide/ide-floppy.c357
-rw-r--r--drivers/ide/ide-floppy.h41
-rw-r--r--drivers/ide/ide-floppy_ioctl.c36
-rw-r--r--drivers/ide/ide-floppy_proc.c2
-rw-r--r--drivers/ide/ide-gd.c401
-rw-r--r--drivers/ide/ide-gd.h44
-rw-r--r--drivers/ide/ide-h8300.c (renamed from drivers/ide/h8300/ide-h8300.c)0
-rw-r--r--drivers/ide/ide-ioctls.c3
-rw-r--r--drivers/ide/ide-iops.c4
-rw-r--r--drivers/ide/ide-pci-generic.c (renamed from drivers/ide/pci/generic.c)2
-rw-r--r--drivers/ide/ide-probe.c1
-rw-r--r--drivers/ide/ide-proc.c8
-rw-r--r--drivers/ide/ide-tape.c33
-rw-r--r--drivers/ide/ide_arm.c (renamed from drivers/ide/arm/ide_arm.c)0
-rw-r--r--drivers/ide/ide_platform.c (renamed from drivers/ide/legacy/ide_platform.c)0
-rw-r--r--drivers/ide/it8213.c (renamed from drivers/ide/pci/it8213.c)0
-rw-r--r--drivers/ide/it821x.c (renamed from drivers/ide/pci/it821x.c)2
-rw-r--r--drivers/ide/jmicron.c (renamed from drivers/ide/pci/jmicron.c)2
-rw-r--r--drivers/ide/legacy/Makefile25
-rw-r--r--drivers/ide/macide.c (renamed from drivers/ide/legacy/macide.c)0
-rw-r--r--drivers/ide/mips/Makefile3
-rw-r--r--drivers/ide/ns87415.c (renamed from drivers/ide/pci/ns87415.c)0
-rw-r--r--drivers/ide/opti621.c (renamed from drivers/ide/pci/opti621.c)0
-rw-r--r--drivers/ide/palm_bk3710.c (renamed from drivers/ide/arm/palm_bk3710.c)0
-rw-r--r--drivers/ide/pci/Makefile44
-rw-r--r--drivers/ide/pci/hpt34x.c193
-rw-r--r--drivers/ide/pdc202xx_new.c (renamed from drivers/ide/pci/pdc202xx_new.c)0
-rw-r--r--drivers/ide/pdc202xx_old.c (renamed from drivers/ide/pci/pdc202xx_old.c)0
-rw-r--r--drivers/ide/piix.c (renamed from drivers/ide/pci/piix.c)2
-rw-r--r--drivers/ide/pmac.c (renamed from drivers/ide/ppc/pmac.c)0
-rw-r--r--drivers/ide/ppc/Makefile2
-rw-r--r--drivers/ide/q40ide.c (renamed from drivers/ide/legacy/q40ide.c)0
-rw-r--r--drivers/ide/qd65xx.c (renamed from drivers/ide/legacy/qd65xx.c)0
-rw-r--r--drivers/ide/qd65xx.h (renamed from drivers/ide/legacy/qd65xx.h)0
-rw-r--r--drivers/ide/rapide.c (renamed from drivers/ide/arm/rapide.c)4
-rw-r--r--drivers/ide/rz1000.c (renamed from drivers/ide/pci/rz1000.c)0
-rw-r--r--drivers/ide/sc1200.c (renamed from drivers/ide/pci/sc1200.c)0
-rw-r--r--drivers/ide/scc_pata.c (renamed from drivers/ide/pci/scc_pata.c)16
-rw-r--r--drivers/ide/serverworks.c (renamed from drivers/ide/pci/serverworks.c)0
-rw-r--r--drivers/ide/sgiioc4.c (renamed from drivers/ide/pci/sgiioc4.c)73
-rw-r--r--drivers/ide/siimage.c (renamed from drivers/ide/pci/siimage.c)4
-rw-r--r--drivers/ide/sis5513.c (renamed from drivers/ide/pci/sis5513.c)0
-rw-r--r--drivers/ide/sl82c105.c (renamed from drivers/ide/pci/sl82c105.c)0
-rw-r--r--drivers/ide/slc90e66.c (renamed from drivers/ide/pci/slc90e66.c)0
-rw-r--r--drivers/ide/tc86c001.c (renamed from drivers/ide/pci/tc86c001.c)0
-rw-r--r--drivers/ide/triflex.c (renamed from drivers/ide/pci/triflex.c)0
-rw-r--r--drivers/ide/trm290.c (renamed from drivers/ide/pci/trm290.c)0
-rw-r--r--drivers/ide/tx4938ide.c323
-rw-r--r--drivers/ide/tx4939ide.c754
-rw-r--r--drivers/ide/umc8672.c (renamed from drivers/ide/legacy/umc8672.c)0
-rw-r--r--drivers/ide/via82cxxx.c (renamed from drivers/ide/pci/via82cxxx.c)0
85 files changed, 1983 insertions, 1236 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 74a369a6116f..6d7401772a8f 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -84,21 +84,40 @@ config BLK_DEV_IDE_SATA
84 84
85 If unsure, say N. 85 If unsure, say N.
86 86
87config BLK_DEV_IDEDISK 87config IDE_GD
88 tristate "Include IDE/ATA-2 DISK support" 88 tristate "generic ATA/ATAPI disk support"
89 ---help--- 89 default y
90 This will include enhanced support for MFM/RLL/IDE hard disks. If 90 help
91 you have a MFM/RLL/IDE disk, and there is no special reason to use 91 Support for ATA/ATAPI disks (including ATAPI floppy drives).
92 the old hard disk driver instead, say Y. If you have an SCSI-only
93 system, you can say N here.
94 92
95 To compile this driver as a module, choose M here: the 93 To compile this driver as a module, choose M here.
96 module will be called ide-disk. 94 The module will be called ide-gd_mod.
97 Do not compile this driver as a module if your root file system 95
98 (the one containing the directory /) is located on the IDE disk. 96 If unsure, say Y.
97
98config IDE_GD_ATA
99 bool "ATA disk support"
100 depends on IDE_GD
101 default y
102 help
103 This will include support for ATA hard disks.
99 104
100 If unsure, say Y. 105 If unsure, say Y.
101 106
107config IDE_GD_ATAPI
108 bool "ATAPI floppy support"
109 depends on IDE_GD
110 select IDE_ATAPI
111 help
112 This will include support for ATAPI floppy drives
113 (i.e. Iomega ZIP or MKE LS-120).
114
115 For information about jumper settings and the question
116 of when a ZIP drive uses a partition table, see
117 <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>.
118
119 If unsure, say N.
120
102config BLK_DEV_IDECS 121config BLK_DEV_IDECS
103 tristate "PCMCIA IDE support" 122 tristate "PCMCIA IDE support"
104 depends on PCMCIA 123 depends on PCMCIA
@@ -163,29 +182,6 @@ config BLK_DEV_IDETAPE
163 To compile this driver as a module, choose M here: the 182 To compile this driver as a module, choose M here: the
164 module will be called ide-tape. 183 module will be called ide-tape.
165 184
166config BLK_DEV_IDEFLOPPY
167 tristate "Include IDE/ATAPI FLOPPY support"
168 select IDE_ATAPI
169 ---help---
170 If you have an IDE floppy drive which uses the ATAPI protocol,
171 answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy
172 drives, similar to the SCSI protocol.
173
174 The LS-120 and the IDE/ATAPI Iomega ZIP drive are also supported by
175 this driver. For information about jumper settings and the question
176 of when a ZIP drive uses a partition table, see
177 <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>.
178 (ATAPI PD-CD/CDR drives are not supported by this driver; support
179 for PD-CD/CDR drives is available if you answer Y to
180 "SCSI emulation support", below).
181
182 If you say Y here, the FLOPPY drive will be identified along with
183 other IDE devices, as "hdb" or "hdc", or something similar (check
184 the boot messages with dmesg).
185
186 To compile this driver as a module, choose M here: the
187 module will be called ide-floppy.
188
189config BLK_DEV_IDESCSI 185config BLK_DEV_IDESCSI
190 tristate "SCSI emulation support (DEPRECATED)" 186 tristate "SCSI emulation support (DEPRECATED)"
191 depends on SCSI 187 depends on SCSI
@@ -332,7 +328,7 @@ config IDEPCI_PCIBUS_ORDER
332# TODO: split it on per host driver config options (or module parameters) 328# TODO: split it on per host driver config options (or module parameters)
333config BLK_DEV_OFFBOARD 329config BLK_DEV_OFFBOARD
334 bool "Boot off-board chipsets first support (DEPRECATED)" 330 bool "Boot off-board chipsets first support (DEPRECATED)"
335 depends on BLK_DEV_IDEPCI && (BLK_DEV_AEC62XX || BLK_DEV_GENERIC || BLK_DEV_HPT34X || BLK_DEV_HPT366 || BLK_DEV_PDC202XX_NEW || BLK_DEV_PDC202XX_OLD || BLK_DEV_TC86C001) 331 depends on BLK_DEV_IDEPCI && (BLK_DEV_AEC62XX || BLK_DEV_GENERIC || BLK_DEV_HPT366 || BLK_DEV_PDC202XX_NEW || BLK_DEV_PDC202XX_OLD || BLK_DEV_TC86C001)
336 help 332 help
337 Normally, IDE controllers built into the motherboard (on-board 333 Normally, IDE controllers built into the motherboard (on-board
338 controllers) are assigned to ide0 and ide1 while those on add-in PCI 334 controllers) are assigned to ide0 and ide1 while those on add-in PCI
@@ -482,28 +478,6 @@ config BLK_DEV_CS5535
482 478
483 It is safe to say Y to this question. 479 It is safe to say Y to this question.
484 480
485config BLK_DEV_HPT34X
486 tristate "HPT34X chipset support"
487 depends on BROKEN
488 select BLK_DEV_IDEDMA_PCI
489 help
490 This driver adds up to 4 more EIDE devices sharing a single
491 interrupt. The HPT343 chipset in its current form is a non-bootable
492 controller; the HPT345/HPT363 chipset is a bootable (needs BIOS FIX)
493 PCI UDMA controllers. This driver requires dynamic tuning of the
494 chipset during the ide-probe at boot time. It is reported to support
495 DVD II drives, by the manufacturer.
496
497config HPT34X_AUTODMA
498 bool "HPT34X AUTODMA support (EXPERIMENTAL)"
499 depends on BLK_DEV_HPT34X && EXPERIMENTAL
500 help
501 This is a dangerous thing to attempt currently! Please read the
502 comments at the top of <file:drivers/ide/pci/hpt34x.c>. If you say Y
503 here, then say Y to "Use DMA by default when available" as well.
504
505 If unsure, say N.
506
507config BLK_DEV_HPT366 481config BLK_DEV_HPT366
508 tristate "HPT36X/37X chipset support" 482 tristate "HPT36X/37X chipset support"
509 select BLK_DEV_IDEDMA_PCI 483 select BLK_DEV_IDEDMA_PCI
@@ -746,6 +720,16 @@ config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
746 default "128" 720 default "128"
747 depends on BLK_DEV_IDE_AU1XXX 721 depends on BLK_DEV_IDE_AU1XXX
748 722
723config BLK_DEV_IDE_TX4938
724 tristate "TX4938 internal IDE support"
725 depends on SOC_TX4938
726 select IDE_TIMINGS
727
728config BLK_DEV_IDE_TX4939
729 tristate "TX4939 internal IDE support"
730 depends on SOC_TX4939
731 select BLK_DEV_IDEDMA_SFF
732
749config IDE_ARM 733config IDE_ARM
750 tristate "ARM IDE support" 734 tristate "ARM IDE support"
751 depends on ARM && (ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK) 735 depends on ARM && (ARCH_CLPS7500 || ARCH_RPC || ARCH_SHARK)
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index ceaf779054ea..7818d402b188 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -18,47 +18,98 @@ ide-core-$(CONFIG_BLK_DEV_IDEACPI) += ide-acpi.o
18 18
19obj-$(CONFIG_IDE) += ide-core.o 19obj-$(CONFIG_IDE) += ide-core.o
20 20
21ifeq ($(CONFIG_IDE_ARM), y) 21obj-$(CONFIG_IDE_ARM) += ide_arm.o
22 ide-arm-core-y += arm/ide_arm.o 22
23 obj-y += ide-arm-core.o 23obj-$(CONFIG_BLK_DEV_ALI14XX) += ali14xx.o
24endif 24obj-$(CONFIG_BLK_DEV_UMC8672) += umc8672.o
25obj-$(CONFIG_BLK_DEV_DTC2278) += dtc2278.o
26obj-$(CONFIG_BLK_DEV_HT6560B) += ht6560b.o
27obj-$(CONFIG_BLK_DEV_QD65XX) += qd65xx.o
28obj-$(CONFIG_BLK_DEV_4DRIVES) += ide-4drives.o
29
30obj-$(CONFIG_BLK_DEV_GAYLE) += gayle.o
31obj-$(CONFIG_BLK_DEV_FALCON_IDE) += falconide.o
32obj-$(CONFIG_BLK_DEV_MAC_IDE) += macide.o
33obj-$(CONFIG_BLK_DEV_Q40IDE) += q40ide.o
34obj-$(CONFIG_BLK_DEV_BUDDHA) += buddha.o
35
36obj-$(CONFIG_BLK_DEV_AEC62XX) += aec62xx.o
37obj-$(CONFIG_BLK_DEV_ALI15X3) += alim15x3.o
38obj-$(CONFIG_BLK_DEV_AMD74XX) += amd74xx.o
39obj-$(CONFIG_BLK_DEV_ATIIXP) += atiixp.o
40obj-$(CONFIG_BLK_DEV_CELLEB) += scc_pata.o
41obj-$(CONFIG_BLK_DEV_CMD64X) += cmd64x.o
42obj-$(CONFIG_BLK_DEV_CS5520) += cs5520.o
43obj-$(CONFIG_BLK_DEV_CS5530) += cs5530.o
44obj-$(CONFIG_BLK_DEV_CS5535) += cs5535.o
45obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o
46obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o
47obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o
48obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o
49obj-$(CONFIG_BLK_DEV_IT8213) += it8213.o
50obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o
51obj-$(CONFIG_BLK_DEV_JMICRON) += jmicron.o
52obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o
53obj-$(CONFIG_BLK_DEV_OPTI621) += opti621.o
54obj-$(CONFIG_BLK_DEV_PDC202XX_OLD) += pdc202xx_old.o
55obj-$(CONFIG_BLK_DEV_PDC202XX_NEW) += pdc202xx_new.o
56obj-$(CONFIG_BLK_DEV_PIIX) += piix.o
57obj-$(CONFIG_BLK_DEV_RZ1000) += rz1000.o
58obj-$(CONFIG_BLK_DEV_SVWKS) += serverworks.o
59obj-$(CONFIG_BLK_DEV_SGIIOC4) += sgiioc4.o
60obj-$(CONFIG_BLK_DEV_SIIMAGE) += siimage.o
61obj-$(CONFIG_BLK_DEV_SIS5513) += sis5513.o
62obj-$(CONFIG_BLK_DEV_SL82C105) += sl82c105.o
63obj-$(CONFIG_BLK_DEV_SLC90E66) += slc90e66.o
64obj-$(CONFIG_BLK_DEV_TC86C001) += tc86c001.o
65obj-$(CONFIG_BLK_DEV_TRIFLEX) += triflex.o
66obj-$(CONFIG_BLK_DEV_TRM290) += trm290.o
67obj-$(CONFIG_BLK_DEV_VIA82CXXX) += via82cxxx.o
25 68
26obj-$(CONFIG_IDE) += legacy/ pci/ 69# Must appear at the end of the block
70obj-$(CONFIG_BLK_DEV_GENERIC) += ide-pci-generic.o
27 71
28obj-$(CONFIG_IDEPCI_PCIBUS_ORDER) += ide-scan-pci.o 72obj-$(CONFIG_IDEPCI_PCIBUS_ORDER) += ide-scan-pci.o
29 73
30ifeq ($(CONFIG_BLK_DEV_CMD640), y) 74obj-$(CONFIG_BLK_DEV_CMD640) += cmd640.o
31 cmd640-core-y += pci/cmd640.o 75
32 obj-y += cmd640-core.o 76obj-$(CONFIG_BLK_DEV_IDE_PMAC) += pmac.o
33endif 77
78obj-$(CONFIG_IDE_H8300) += ide-h8300.o
34 79
35obj-$(CONFIG_IDE) += ppc/
36obj-$(CONFIG_IDE_H8300) += h8300/
37obj-$(CONFIG_IDE_GENERIC) += ide-generic.o 80obj-$(CONFIG_IDE_GENERIC) += ide-generic.o
38obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o 81obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o
39 82
40ide-disk_mod-y += ide-disk.o ide-disk_ioctl.o 83ide-gd_mod-y += ide-gd.o
41ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o 84ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o
42ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o
43 85
86ifeq ($(CONFIG_IDE_GD_ATA), y)
87 ide-gd_mod-y += ide-disk.o ide-disk_ioctl.o
88ifeq ($(CONFIG_IDE_PROC_FS), y)
89 ide-gd_mod-y += ide-disk_proc.o
90endif
91endif
92
93ifeq ($(CONFIG_IDE_GD_ATAPI), y)
94 ide-gd_mod-y += ide-floppy.o ide-floppy_ioctl.o
44ifeq ($(CONFIG_IDE_PROC_FS), y) 95ifeq ($(CONFIG_IDE_PROC_FS), y)
45 ide-disk_mod-y += ide-disk_proc.o 96 ide-gd_mod-y += ide-floppy_proc.o
46 ide-floppy_mod-y += ide-floppy_proc.o 97endif
47endif 98endif
48 99
49obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk_mod.o 100obj-$(CONFIG_IDE_GD) += ide-gd_mod.o
50obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o 101obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o
51obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o
52obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o 102obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o
53 103
54ifeq ($(CONFIG_BLK_DEV_IDECS), y) 104obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o
55 ide-cs-core-y += legacy/ide-cs.o
56 obj-y += ide-cs-core.o
57endif
58 105
59ifeq ($(CONFIG_BLK_DEV_PLATFORM), y) 106obj-$(CONFIG_BLK_DEV_PLATFORM) += ide_platform.o
60 ide-platform-core-y += legacy/ide_platform.o 107
61 obj-y += ide-platform-core.o 108obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o
62endif 109obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o
110obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o
111
112obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o
63 113
64obj-$(CONFIG_IDE) += arm/ mips/ 114obj-$(CONFIG_BLK_DEV_IDE_TX4938) += tx4938ide.o
115obj-$(CONFIG_BLK_DEV_IDE_TX4939) += tx4939ide.o
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/aec62xx.c
index 4142c698e0d3..4142c698e0d3 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/aec62xx.c
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/ali14xx.c
index 90da1f953ed0..90da1f953ed0 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/ali14xx.c
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/alim15x3.c
index daf9dce39e52..e56c7b72f9e2 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/alim15x3.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 1998-2000 Andre Hedrick (andre@linux-ide.org) 6 * Copyright (C) 1998-2000 Andre Hedrick (andre@linux-ide.org)
7 * May be copied or modified under the terms of the GNU General Public License 7 * May be copied or modified under the terms of the GNU General Public License
8 * Copyright (C) 2002 Alan Cox <alan@redhat.com> 8 * Copyright (C) 2002 Alan Cox
9 * ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw> 9 * ALi (now ULi M5228) support by Clear Zhang <Clear.Zhang@ali.com.tw>
10 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> 10 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
11 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> 11 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/amd74xx.c
index 81ec73134eda..81ec73134eda 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/amd74xx.c
diff --git a/drivers/ide/arm/Makefile b/drivers/ide/arm/Makefile
deleted file mode 100644
index 5bc26053afa6..000000000000
--- a/drivers/ide/arm/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
1
2obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o
3obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o
4obj-$(CONFIG_BLK_DEV_PALMCHIP_BK3710) += palm_bk3710.o
5
6ifeq ($(CONFIG_IDE_ARM), m)
7 obj-m += ide_arm.o
8endif
9
10EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/atiixp.c
index b2735d28f5cc..b2735d28f5cc 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/atiixp.c
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/au1xxx-ide.c
index 0ec8fd1e4dcb..0ec8fd1e4dcb 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/au1xxx-ide.c
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/buddha.c
index c5a3c9ef6a5d..c5a3c9ef6a5d 100644
--- a/drivers/ide/legacy/buddha.c
+++ b/drivers/ide/buddha.c
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/cmd640.c
index e4306647d00d..e4306647d00d 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/cmd640.c
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/cmd64x.c
index 935385c77e06..935385c77e06 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/cmd64x.c
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/cs5520.c
index 5efb467f8fa0..5efb467f8fa0 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/cs5520.c
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/cs5530.c
index 53f079cc00af..53f079cc00af 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/cs5530.c
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/cs5535.c
index 983d957a0189..983d957a0189 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/cs5535.c
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/cy82c693.c
index 5297f07d2933..5297f07d2933 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/cy82c693.c
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/delkin_cb.c
index 8689a706f537..8f1b2d9f0513 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/delkin_cb.c
@@ -46,10 +46,27 @@ static const struct ide_port_ops delkin_cb_port_ops = {
46 .quirkproc = ide_undecoded_slave, 46 .quirkproc = ide_undecoded_slave,
47}; 47};
48 48
49static unsigned int delkin_cb_init_chipset(struct pci_dev *dev)
50{
51 unsigned long base = pci_resource_start(dev, 0);
52 int i;
53
54 outb(0x02, base + 0x1e); /* set nIEN to block interrupts */
55 inb(base + 0x17); /* read status to clear interrupts */
56
57 for (i = 0; i < sizeof(setup); ++i) {
58 if (setup[i])
59 outb(setup[i], base + i);
60 }
61
62 return 0;
63}
64
49static const struct ide_port_info delkin_cb_port_info = { 65static const struct ide_port_info delkin_cb_port_info = {
50 .port_ops = &delkin_cb_port_ops, 66 .port_ops = &delkin_cb_port_ops,
51 .host_flags = IDE_HFLAG_IO_32BIT | IDE_HFLAG_UNMASK_IRQS | 67 .host_flags = IDE_HFLAG_IO_32BIT | IDE_HFLAG_UNMASK_IRQS |
52 IDE_HFLAG_NO_DMA, 68 IDE_HFLAG_NO_DMA,
69 .init_chipset = delkin_cb_init_chipset,
53}; 70};
54 71
55static int __devinit 72static int __devinit
@@ -57,7 +74,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
57{ 74{
58 struct ide_host *host; 75 struct ide_host *host;
59 unsigned long base; 76 unsigned long base;
60 int i, rc; 77 int rc;
61 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 78 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
62 79
63 rc = pci_enable_device(dev); 80 rc = pci_enable_device(dev);
@@ -72,12 +89,8 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
72 return rc; 89 return rc;
73 } 90 }
74 base = pci_resource_start(dev, 0); 91 base = pci_resource_start(dev, 0);
75 outb(0x02, base + 0x1e); /* set nIEN to block interrupts */ 92
76 inb(base + 0x17); /* read status to clear interrupts */ 93 delkin_cb_init_chipset(dev);
77 for (i = 0; i < sizeof(setup); ++i) {
78 if (setup[i])
79 outb(setup[i], base + i);
80 }
81 94
82 memset(&hw, 0, sizeof(hw)); 95 memset(&hw, 0, sizeof(hw));
83 ide_std_init_ports(&hw, base + 0x10, base + 0x1e); 96 ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
@@ -110,6 +123,40 @@ delkin_cb_remove (struct pci_dev *dev)
110 pci_disable_device(dev); 123 pci_disable_device(dev);
111} 124}
112 125
126#ifdef CONFIG_PM
127static int delkin_cb_suspend(struct pci_dev *dev, pm_message_t state)
128{
129 pci_save_state(dev);
130 pci_disable_device(dev);
131 pci_set_power_state(dev, pci_choose_state(dev, state));
132
133 return 0;
134}
135
136static int delkin_cb_resume(struct pci_dev *dev)
137{
138 struct ide_host *host = pci_get_drvdata(dev);
139 int rc;
140
141 pci_set_power_state(dev, PCI_D0);
142
143 rc = pci_enable_device(dev);
144 if (rc)
145 return rc;
146
147 pci_restore_state(dev);
148 pci_set_master(dev);
149
150 if (host->init_chipset)
151 host->init_chipset(dev);
152
153 return 0;
154}
155#else
156#define delkin_cb_suspend NULL
157#define delkin_cb_resume NULL
158#endif
159
113static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = { 160static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
114 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 161 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
115 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 162 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -122,6 +169,8 @@ static struct pci_driver delkin_cb_pci_driver = {
122 .id_table = delkin_cb_pci_tbl, 169 .id_table = delkin_cb_pci_tbl,
123 .probe = delkin_cb_probe, 170 .probe = delkin_cb_probe,
124 .remove = delkin_cb_remove, 171 .remove = delkin_cb_remove,
172 .suspend = delkin_cb_suspend,
173 .resume = delkin_cb_resume,
125}; 174};
126 175
127static int __init delkin_cb_init(void) 176static int __init delkin_cb_init(void)
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/dtc2278.c
index 689b2e493413..689b2e493413 100644
--- a/drivers/ide/legacy/dtc2278.c
+++ b/drivers/ide/dtc2278.c
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/falconide.c
index 39d500d84b07..39d500d84b07 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/falconide.c
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/gayle.c
index 691506886561..691506886561 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/gayle.c
diff --git a/drivers/ide/h8300/Makefile b/drivers/ide/h8300/Makefile
deleted file mode 100644
index 5eba16f423f4..000000000000
--- a/drivers/ide/h8300/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1
2obj-$(CONFIG_IDE_H8300) += ide-h8300.o
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/hpt366.c
index 9cf171cb9376..f5afd46ed51c 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -3,7 +3,7 @@
3 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 3 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
4 * Portions Copyright (C) 2003 Red Hat Inc 4 * Portions Copyright (C) 2003 Red Hat Inc
5 * Portions Copyright (C) 2007 Bartlomiej Zolnierkiewicz 5 * Portions Copyright (C) 2007 Bartlomiej Zolnierkiewicz
6 * Portions Copyright (C) 2005-2007 MontaVista Software, Inc. 6 * Portions Copyright (C) 2005-2008 MontaVista Software, Inc.
7 * 7 *
8 * Thanks to HighPoint Technologies for their assistance, and hardware. 8 * Thanks to HighPoint Technologies for their assistance, and hardware.
9 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his 9 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his
@@ -52,7 +52,7 @@
52 * different clocks on read/write. This requires overloading rw_disk and 52 * different clocks on read/write. This requires overloading rw_disk and
53 * other deeply crazy things. Thanks to <http://www.hoerstreich.de> for 53 * other deeply crazy things. Thanks to <http://www.hoerstreich.de> for
54 * keeping me sane. 54 * keeping me sane.
55 * Alan Cox <alan@redhat.com> 55 * Alan Cox <alan@lxorguk.ukuu.org.uk>
56 * 56 *
57 * - fix the clock turnaround code: it was writing to the wrong ports when 57 * - fix the clock turnaround code: it was writing to the wrong ports when
58 * called for the secondary channel, caching the current clock mode per- 58 * called for the secondary channel, caching the current clock mode per-
@@ -748,26 +748,24 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
748 struct pci_dev *dev = to_pci_dev(hwif->dev); 748 struct pci_dev *dev = to_pci_dev(hwif->dev);
749 struct hpt_info *info = hpt3xx_get_info(hwif->dev); 749 struct hpt_info *info = hpt3xx_get_info(hwif->dev);
750 750
751 if (drive->quirk_list) { 751 if (drive->quirk_list == 0)
752 if (info->chip_type >= HPT370) { 752 return;
753 u8 scr1 = 0; 753
754 754 if (info->chip_type >= HPT370) {
755 pci_read_config_byte(dev, 0x5a, &scr1); 755 u8 scr1 = 0;
756 if (((scr1 & 0x10) >> 4) != mask) { 756
757 if (mask) 757 pci_read_config_byte(dev, 0x5a, &scr1);
758 scr1 |= 0x10; 758 if (((scr1 & 0x10) >> 4) != mask) {
759 else
760 scr1 &= ~0x10;
761 pci_write_config_byte(dev, 0x5a, scr1);
762 }
763 } else {
764 if (mask) 759 if (mask)
765 disable_irq(hwif->irq); 760 scr1 |= 0x10;
766 else 761 else
767 enable_irq (hwif->irq); 762 scr1 &= ~0x10;
763 pci_write_config_byte(dev, 0x5a, scr1);
768 } 764 }
769 } else 765 } else if (mask)
770 outb(ATA_DEVCTL_OBS | (mask ? 2 : 0), hwif->io_ports.ctl_addr); 766 disable_irq(hwif->irq);
767 else
768 enable_irq(hwif->irq);
771} 769}
772 770
773/* 771/*
@@ -1289,7 +1287,6 @@ static u8 hpt3xx_cable_detect(ide_hwif_t *hwif)
1289 1287
1290static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) 1288static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1291{ 1289{
1292 struct pci_dev *dev = to_pci_dev(hwif->dev);
1293 struct hpt_info *info = hpt3xx_get_info(hwif->dev); 1290 struct hpt_info *info = hpt3xx_get_info(hwif->dev);
1294 int serialize = HPT_SERIALIZE_IO; 1291 int serialize = HPT_SERIALIZE_IO;
1295 u8 chip_type = info->chip_type; 1292 u8 chip_type = info->chip_type;
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/ht6560b.c
index c7e5c2246b79..c7e5c2246b79 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/ht6560b.c
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/icside.c
index 76bdc9a27f6f..2d848010499d 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/icside.c
@@ -690,9 +690,9 @@ static int __init icside_init(void)
690 return ecard_register_driver(&icside_driver); 690 return ecard_register_driver(&icside_driver);
691} 691}
692 692
693static void __exit icside_exit(void); 693static void __exit icside_exit(void)
694{ 694{
695 ecard_unregister_driver(&icside_driver); 695 ecard_remove_driver(&icside_driver);
696} 696}
697 697
698MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); 698MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
diff --git a/drivers/ide/legacy/ide-4drives.c b/drivers/ide/ide-4drives.c
index 9e85b1ec9607..9e85b1ec9607 100644
--- a/drivers/ide/legacy/ide-4drives.c
+++ b/drivers/ide/ide-4drives.c
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 2e305714c209..4e58b9e7a58a 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -191,7 +191,7 @@ int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on)
191{ 191{
192 struct ide_atapi_pc pc; 192 struct ide_atapi_pc pc;
193 193
194 if (drive->atapi_flags & IDE_AFLAG_NO_DOORLOCK) 194 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
195 return 0; 195 return 0;
196 196
197 ide_init_pc(&pc); 197 ide_init_pc(&pc);
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 3308b1cd3a33..42ab6d8715f2 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -99,7 +99,7 @@ static void ide_cd_put(struct cdrom_info *cd)
99/* Mark that we've seen a media change and invalidate our internal buffers. */ 99/* Mark that we've seen a media change and invalidate our internal buffers. */
100static void cdrom_saw_media_change(ide_drive_t *drive) 100static void cdrom_saw_media_change(ide_drive_t *drive)
101{ 101{
102 drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; 102 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
103 drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID; 103 drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID;
104} 104}
105 105
@@ -340,8 +340,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
340 } 340 }
341 341
342 ide_debug_log(IDE_DBG_RQ, "%s: stat: 0x%x, good_stat: 0x%x, " 342 ide_debug_log(IDE_DBG_RQ, "%s: stat: 0x%x, good_stat: 0x%x, "
343 "rq->cmd_type: 0x%x, err: 0x%x\n", __func__, stat, 343 "rq->cmd[0]: 0x%x, rq->cmd_type: 0x%x, err: 0x%x\n",
344 good_stat, rq->cmd_type, err); 344 __func__, stat, good_stat, rq->cmd[0], rq->cmd_type, err);
345 345
346 if (blk_sense_request(rq)) { 346 if (blk_sense_request(rq)) {
347 /* 347 /*
@@ -843,13 +843,10 @@ static void ide_cd_restore_request(ide_drive_t *drive, struct request *rq)
843 rq->q->prep_rq_fn(rq->q, rq); 843 rq->q->prep_rq_fn(rq->q, rq);
844} 844}
845 845
846/*
847 * All other packet commands.
848 */
849static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct request *rq) 846static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct request *rq)
850{ 847{
851 848 ide_debug_log(IDE_DBG_FUNC, "Call %s, rq->cmd[0]: 0x%x\n",
852 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 849 __func__, rq->cmd[0]);
853 850
854 /* 851 /*
855 * Some of the trailing request sense fields are optional, 852 * Some of the trailing request sense fields are optional,
@@ -876,7 +873,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
876 if (!sense) 873 if (!sense)
877 sense = &local_sense; 874 sense = &local_sense;
878 875
879 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x, " 876 ide_debug_log(IDE_DBG_PC, "Call %s, cmd[0]: 0x%x, write: 0x%x, "
880 "timeout: %d, cmd_flags: 0x%x\n", __func__, cmd[0], write, 877 "timeout: %d, cmd_flags: 0x%x\n", __func__, cmd[0], write,
881 timeout, cmd_flags); 878 timeout, cmd_flags);
882 879
@@ -1177,8 +1174,9 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
1177 unsigned short sectors_per_frame = 1174 unsigned short sectors_per_frame =
1178 queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1175 queue_hardsect_size(drive->queue) >> SECTOR_BITS;
1179 1176
1180 ide_debug_log(IDE_DBG_RQ, "Call %s, write: 0x%x, secs_per_frame: %u\n", 1177 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x, "
1181 __func__, write, sectors_per_frame); 1178 "secs_per_frame: %u\n",
1179 __func__, rq->cmd[0], write, sectors_per_frame);
1182 1180
1183 if (write) { 1181 if (write) {
1184 /* disk has become write protected */ 1182 /* disk has become write protected */
@@ -1221,7 +1219,8 @@ static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive)
1221static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) 1219static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1222{ 1220{
1223 1221
1224 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd_type: 0x%x\n", __func__, 1222 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, "
1223 "rq->cmd_type: 0x%x\n", __func__, rq->cmd[0],
1225 rq->cmd_type); 1224 rq->cmd_type);
1226 1225
1227 if (blk_pc_request(rq)) 1226 if (blk_pc_request(rq))
@@ -1251,15 +1250,13 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1251 * separate masks. 1250 * separate masks.
1252 */ 1251 */
1253 alignment = queue_dma_alignment(q) | q->dma_pad_mask; 1252 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
1254 if ((unsigned long)buf & alignment || rq->data_len & alignment 1253 if ((unsigned long)buf & alignment
1254 || rq->data_len & q->dma_pad_mask
1255 || object_is_on_stack(buf)) 1255 || object_is_on_stack(buf))
1256 drive->dma = 0; 1256 drive->dma = 0;
1257 } 1257 }
1258} 1258}
1259 1259
1260/*
1261 * cdrom driver request routine.
1262 */
1263static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, 1260static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1264 sector_t block) 1261 sector_t block)
1265{ 1262{
@@ -1267,8 +1264,10 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1267 ide_handler_t *fn; 1264 ide_handler_t *fn;
1268 int xferlen; 1265 int xferlen;
1269 1266
1270 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd_type: 0x%x, block: %llu\n", 1267 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, "
1271 __func__, rq->cmd_type, (unsigned long long)block); 1268 "rq->cmd_type: 0x%x, block: %llu\n",
1269 __func__, rq->cmd[0], rq->cmd_type,
1270 (unsigned long long)block);
1272 1271
1273 if (blk_fs_request(rq)) { 1272 if (blk_fs_request(rq)) {
1274 if (drive->atapi_flags & IDE_AFLAG_SEEKING) { 1273 if (drive->atapi_flags & IDE_AFLAG_SEEKING) {
@@ -1412,6 +1411,10 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1412 1411
1413 *capacity = 1 + be32_to_cpu(capbuf.lba); 1412 *capacity = 1 + be32_to_cpu(capbuf.lba);
1414 *sectors_per_frame = blocklen >> SECTOR_BITS; 1413 *sectors_per_frame = blocklen >> SECTOR_BITS;
1414
1415 ide_debug_log(IDE_DBG_PROBE, "%s: cap: %lu, sectors_per_frame: %lu\n",
1416 __func__, *capacity, *sectors_per_frame);
1417
1415 return 0; 1418 return 0;
1416} 1419}
1417 1420
@@ -1643,6 +1646,9 @@ void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf)
1643 maxspeed = be16_to_cpup((__be16 *)&buf[8 + 8]); 1646 maxspeed = be16_to_cpup((__be16 *)&buf[8 + 8]);
1644 } 1647 }
1645 1648
1649 ide_debug_log(IDE_DBG_PROBE, "%s: curspeed: %u, maxspeed: %u\n",
1650 __func__, curspeed, maxspeed);
1651
1646 cd->current_speed = (curspeed + (176/2)) / 176; 1652 cd->current_speed = (curspeed + (176/2)) / 176;
1647 cd->max_speed = (maxspeed + (176/2)) / 176; 1653 cd->max_speed = (maxspeed + (176/2)) / 176;
1648} 1654}
@@ -1732,7 +1738,7 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1732 return 0; 1738 return 0;
1733 1739
1734 if ((buf[8 + 6] & 0x01) == 0) 1740 if ((buf[8 + 6] & 0x01) == 0)
1735 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 1741 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
1736 if (buf[8 + 6] & 0x08) 1742 if (buf[8 + 6] & 0x08)
1737 drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT; 1743 drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT;
1738 if (buf[8 + 3] & 0x01) 1744 if (buf[8 + 3] & 0x01)
@@ -1777,7 +1783,7 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1777 if ((cdi->mask & CDC_DVD_R) == 0 || (cdi->mask & CDC_DVD_RAM) == 0) 1783 if ((cdi->mask & CDC_DVD_R) == 0 || (cdi->mask & CDC_DVD_RAM) == 0)
1778 printk(KERN_CONT " DVD%s%s", 1784 printk(KERN_CONT " DVD%s%s",
1779 (cdi->mask & CDC_DVD_R) ? "" : "-R", 1785 (cdi->mask & CDC_DVD_R) ? "" : "-R",
1780 (cdi->mask & CDC_DVD_RAM) ? "" : "-RAM"); 1786 (cdi->mask & CDC_DVD_RAM) ? "" : "/RAM");
1781 1787
1782 if ((cdi->mask & CDC_CD_R) == 0 || (cdi->mask & CDC_CD_RW) == 0) 1788 if ((cdi->mask & CDC_CD_R) == 0 || (cdi->mask & CDC_CD_RW) == 0)
1783 printk(KERN_CONT " CD%s%s", 1789 printk(KERN_CONT " CD%s%s",
@@ -1908,6 +1914,16 @@ static const struct ide_proc_devset idecd_settings[] = {
1908 IDE_PROC_DEVSET(dsc_overlap, 0, 1), 1914 IDE_PROC_DEVSET(dsc_overlap, 0, 1),
1909 { 0 }, 1915 { 0 },
1910}; 1916};
1917
1918static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive)
1919{
1920 return idecd_proc;
1921}
1922
1923static const struct ide_proc_devset *ide_cd_proc_devsets(ide_drive_t *drive)
1924{
1925 return idecd_settings;
1926}
1911#endif 1927#endif
1912 1928
1913static const struct cd_list_entry ide_cd_quirks_list[] = { 1929static const struct cd_list_entry ide_cd_quirks_list[] = {
@@ -1951,6 +1967,7 @@ static const struct cd_list_entry ide_cd_quirks_list[] = {
1951 { "Optiarc DVD RW AD-5200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1967 { "Optiarc DVD RW AD-5200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1952 { "Optiarc DVD RW AD-7200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK }, 1968 { "Optiarc DVD RW AD-7200A", NULL, IDE_AFLAG_PLAY_AUDIO_OK },
1953 { "Optiarc DVD RW AD-7543A", NULL, IDE_AFLAG_NO_AUTOCLOSE }, 1969 { "Optiarc DVD RW AD-7543A", NULL, IDE_AFLAG_NO_AUTOCLOSE },
1970 { "TEAC CD-ROM CD-224E", NULL, IDE_AFLAG_NO_AUTOCLOSE },
1954 { NULL, NULL, 0 } 1971 { NULL, NULL, 0 }
1955}; 1972};
1956 1973
@@ -1986,8 +2003,8 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1986 if (!drive->queue->unplug_delay) 2003 if (!drive->queue->unplug_delay)
1987 drive->queue->unplug_delay = 1; 2004 drive->queue->unplug_delay = 1;
1988 2005
1989 drive->atapi_flags = IDE_AFLAG_MEDIA_CHANGED | IDE_AFLAG_NO_EJECT | 2006 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
1990 ide_cd_flags(id); 2007 drive->atapi_flags = IDE_AFLAG_NO_EJECT | ide_cd_flags(id);
1991 2008
1992 if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) && 2009 if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) &&
1993 fw_rev[4] == '1' && fw_rev[6] <= '2') 2010 fw_rev[4] == '1' && fw_rev[6] <= '2')
@@ -2069,22 +2086,20 @@ static ide_driver_t ide_cdrom_driver = {
2069 .end_request = ide_end_request, 2086 .end_request = ide_end_request,
2070 .error = __ide_error, 2087 .error = __ide_error,
2071#ifdef CONFIG_IDE_PROC_FS 2088#ifdef CONFIG_IDE_PROC_FS
2072 .proc = idecd_proc, 2089 .proc_entries = ide_cd_proc_entries,
2073 .settings = idecd_settings, 2090 .proc_devsets = ide_cd_proc_devsets,
2074#endif 2091#endif
2075}; 2092};
2076 2093
2077static int idecd_open(struct inode *inode, struct file *file) 2094static int idecd_open(struct block_device *bdev, fmode_t mode)
2078{ 2095{
2079 struct gendisk *disk = inode->i_bdev->bd_disk; 2096 struct cdrom_info *info = ide_cd_get(bdev->bd_disk);
2080 struct cdrom_info *info;
2081 int rc = -ENOMEM; 2097 int rc = -ENOMEM;
2082 2098
2083 info = ide_cd_get(disk);
2084 if (!info) 2099 if (!info)
2085 return -ENXIO; 2100 return -ENXIO;
2086 2101
2087 rc = cdrom_open(&info->devinfo, inode, file); 2102 rc = cdrom_open(&info->devinfo, bdev, mode);
2088 2103
2089 if (rc < 0) 2104 if (rc < 0)
2090 ide_cd_put(info); 2105 ide_cd_put(info);
@@ -2092,12 +2107,11 @@ static int idecd_open(struct inode *inode, struct file *file)
2092 return rc; 2107 return rc;
2093} 2108}
2094 2109
2095static int idecd_release(struct inode *inode, struct file *file) 2110static int idecd_release(struct gendisk *disk, fmode_t mode)
2096{ 2111{
2097 struct gendisk *disk = inode->i_bdev->bd_disk;
2098 struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 2112 struct cdrom_info *info = ide_drv_g(disk, cdrom_info);
2099 2113
2100 cdrom_release(&info->devinfo, file); 2114 cdrom_release(&info->devinfo, mode);
2101 2115
2102 ide_cd_put(info); 2116 ide_cd_put(info);
2103 2117
@@ -2143,10 +2157,9 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
2143 return 0; 2157 return 0;
2144} 2158}
2145 2159
2146static int idecd_ioctl(struct inode *inode, struct file *file, 2160static int idecd_ioctl(struct block_device *bdev, fmode_t mode,
2147 unsigned int cmd, unsigned long arg) 2161 unsigned int cmd, unsigned long arg)
2148{ 2162{
2149 struct block_device *bdev = inode->i_bdev;
2150 struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info); 2163 struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info);
2151 int err; 2164 int err;
2152 2165
@@ -2159,9 +2172,9 @@ static int idecd_ioctl(struct inode *inode, struct file *file,
2159 break; 2172 break;
2160 } 2173 }
2161 2174
2162 err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); 2175 err = generic_ide_ioctl(info->drive, bdev, cmd, arg);
2163 if (err == -EINVAL) 2176 if (err == -EINVAL)
2164 err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); 2177 err = cdrom_ioctl(&info->devinfo, bdev, mode, cmd, arg);
2165 2178
2166 return err; 2179 return err;
2167} 2180}
@@ -2186,7 +2199,7 @@ static struct block_device_operations idecd_ops = {
2186 .owner = THIS_MODULE, 2199 .owner = THIS_MODULE,
2187 .open = idecd_open, 2200 .open = idecd_open,
2188 .release = idecd_release, 2201 .release = idecd_release,
2189 .ioctl = idecd_ioctl, 2202 .locked_ioctl = idecd_ioctl,
2190 .media_changed = idecd_media_changed, 2203 .media_changed = idecd_media_changed,
2191 .revalidate_disk = idecd_revalidate_disk 2204 .revalidate_disk = idecd_revalidate_disk
2192}; 2205};
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 74231b41f611..df3df0041eb6 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -86,8 +86,8 @@ int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi,
86 86
87 if (slot_nr == CDSL_CURRENT) { 87 if (slot_nr == CDSL_CURRENT) {
88 (void) cdrom_check_status(drive, NULL); 88 (void) cdrom_check_status(drive, NULL);
89 retval = (drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED) ? 1 : 0; 89 retval = (drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED) ? 1 : 0;
90 drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED; 90 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
91 return retval; 91 return retval;
92 } else { 92 } else {
93 return -EINVAL; 93 return -EINVAL;
@@ -136,7 +136,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
136 sense = &my_sense; 136 sense = &my_sense;
137 137
138 /* If the drive cannot lock the door, just pretend. */ 138 /* If the drive cannot lock the door, just pretend. */
139 if (drive->atapi_flags & IDE_AFLAG_NO_DOORLOCK) { 139 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0) {
140 stat = 0; 140 stat = 0;
141 } else { 141 } else {
142 unsigned char cmd[BLK_MAX_CDB]; 142 unsigned char cmd[BLK_MAX_CDB];
@@ -157,7 +157,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
157 (sense->asc == 0x24 || sense->asc == 0x20)) { 157 (sense->asc == 0x24 || sense->asc == 0x20)) {
158 printk(KERN_ERR "%s: door locking not supported\n", 158 printk(KERN_ERR "%s: door locking not supported\n",
159 drive->name); 159 drive->name);
160 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 160 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
161 stat = 0; 161 stat = 0;
162 } 162 }
163 163
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/ide-cs.c
index cb199c815b53..cb199c815b53 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/ide-cs.c
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 3853bde8eedc..eb9fac4d0f0c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -2,7 +2,7 @@
2 * Copyright (C) 1994-1998 Linus Torvalds & authors (see below) 2 * Copyright (C) 1994-1998 Linus Torvalds & authors (see below)
3 * Copyright (C) 1998-2002 Linux ATA Development 3 * Copyright (C) 1998-2002 Linux ATA Development
4 * Andre Hedrick <andre@linux-ide.org> 4 * Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 5 * Copyright (C) 2003 Red Hat
6 * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz 6 * Copyright (C) 2003-2005, 2007 Bartlomiej Zolnierkiewicz
7 */ 7 */
8 8
@@ -14,9 +14,6 @@
14 * This is the IDE/ATA disk driver, as evolved from hd.c and ide.c. 14 * This is the IDE/ATA disk driver, as evolved from hd.c and ide.c.
15 */ 15 */
16 16
17#define IDEDISK_VERSION "1.18"
18
19#include <linux/module.h>
20#include <linux/types.h> 17#include <linux/types.h>
21#include <linux/string.h> 18#include <linux/string.h>
22#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -39,46 +36,8 @@
39#include <asm/io.h> 36#include <asm/io.h>
40#include <asm/div64.h> 37#include <asm/div64.h>
41 38
42#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
43#define IDE_DISK_MINORS (1 << PARTN_BITS)
44#else
45#define IDE_DISK_MINORS 0
46#endif
47
48#include "ide-disk.h" 39#include "ide-disk.h"
49 40
50static DEFINE_MUTEX(idedisk_ref_mutex);
51
52#define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref)
53
54static void ide_disk_release(struct kref *);
55
56static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
57{
58 struct ide_disk_obj *idkp = NULL;
59
60 mutex_lock(&idedisk_ref_mutex);
61 idkp = ide_disk_g(disk);
62 if (idkp) {
63 if (ide_device_get(idkp->drive))
64 idkp = NULL;
65 else
66 kref_get(&idkp->kref);
67 }
68 mutex_unlock(&idedisk_ref_mutex);
69 return idkp;
70}
71
72static void ide_disk_put(struct ide_disk_obj *idkp)
73{
74 ide_drive_t *drive = idkp->drive;
75
76 mutex_lock(&idedisk_ref_mutex);
77 kref_put(&idkp->kref, ide_disk_release);
78 ide_device_put(drive);
79 mutex_unlock(&idedisk_ref_mutex);
80}
81
82static const u8 ide_rw_cmds[] = { 41static const u8 ide_rw_cmds[] = {
83 ATA_CMD_READ_MULTI, 42 ATA_CMD_READ_MULTI,
84 ATA_CMD_WRITE_MULTI, 43 ATA_CMD_WRITE_MULTI,
@@ -374,7 +333,7 @@ static void idedisk_check_hpa(ide_drive_t *drive)
374 } 333 }
375} 334}
376 335
377static void init_idedisk_capacity(ide_drive_t *drive) 336static int ide_disk_get_capacity(ide_drive_t *drive)
378{ 337{
379 u16 *id = drive->id; 338 u16 *id = drive->id;
380 int lba; 339 int lba;
@@ -403,11 +362,28 @@ static void init_idedisk_capacity(ide_drive_t *drive)
403 if (ata_id_hpa_enabled(id)) 362 if (ata_id_hpa_enabled(id))
404 idedisk_check_hpa(drive); 363 idedisk_check_hpa(drive);
405 } 364 }
406}
407 365
408sector_t ide_disk_capacity(ide_drive_t *drive) 366 /* limit drive capacity to 137GB if LBA48 cannot be used */
409{ 367 if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 &&
410 return drive->capacity64; 368 drive->capacity64 > 1ULL << 28) {
369 printk(KERN_WARNING "%s: cannot use LBA48 - full capacity "
370 "%llu sectors (%llu MB)\n",
371 drive->name, (unsigned long long)drive->capacity64,
372 sectors_to_MB(drive->capacity64));
373 drive->capacity64 = 1ULL << 28;
374 }
375
376 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
377 (drive->dev_flags & IDE_DFLAG_LBA48)) {
378 if (drive->capacity64 > 1ULL << 28) {
379 printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode"
380 " will be used for accessing sectors "
381 "> %u\n", drive->name, 1 << 28);
382 } else
383 drive->dev_flags &= ~IDE_DFLAG_LBA48;
384 }
385
386 return 0;
411} 387}
412 388
413static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 389static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
@@ -508,7 +484,7 @@ static void update_ordered(ide_drive_t *drive)
508 * time we have trimmed the drive capacity if LBA48 is 484 * time we have trimmed the drive capacity if LBA48 is
509 * not available so we don't need to recheck that. 485 * not available so we don't need to recheck that.
510 */ 486 */
511 capacity = ide_disk_capacity(drive); 487 capacity = ide_gd_capacity(drive);
512 barrier = ata_id_flush_enabled(id) && 488 barrier = ata_id_flush_enabled(id) &&
513 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 && 489 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 &&
514 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 || 490 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 ||
@@ -616,9 +592,15 @@ ide_ext_devset_rw(wcache, wcache);
616 592
617ide_ext_devset_rw_sync(nowerr, nowerr); 593ide_ext_devset_rw_sync(nowerr, nowerr);
618 594
619static void idedisk_setup(ide_drive_t *drive) 595static int ide_disk_check(ide_drive_t *drive, const char *s)
596{
597 return 1;
598}
599
600static void ide_disk_setup(ide_drive_t *drive)
620{ 601{
621 struct ide_disk_obj *idkp = drive->driver_data; 602 struct ide_disk_obj *idkp = drive->driver_data;
603 struct request_queue *q = drive->queue;
622 ide_hwif_t *hwif = drive->hwif; 604 ide_hwif_t *hwif = drive->hwif;
623 u16 *id = drive->id; 605 u16 *id = drive->id;
624 char *m = (char *)&id[ATA_ID_PROD]; 606 char *m = (char *)&id[ATA_ID_PROD];
@@ -645,40 +627,23 @@ static void idedisk_setup(ide_drive_t *drive)
645 if (max_s > hwif->rqsize) 627 if (max_s > hwif->rqsize)
646 max_s = hwif->rqsize; 628 max_s = hwif->rqsize;
647 629
648 blk_queue_max_sectors(drive->queue, max_s); 630 blk_queue_max_sectors(q, max_s);
649 } 631 }
650 632
651 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name, 633 printk(KERN_INFO "%s: max request size: %dKiB\n", drive->name,
652 drive->queue->max_sectors / 2); 634 q->max_sectors / 2);
653 635
654 /* calculate drive capacity, and select LBA if possible */ 636 if (ata_id_is_ssd(id) || ata_id_is_cfa(id))
655 init_idedisk_capacity(drive); 637 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
656
657 /* limit drive capacity to 137GB if LBA48 cannot be used */
658 if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 &&
659 drive->capacity64 > 1ULL << 28) {
660 printk(KERN_WARNING "%s: cannot use LBA48 - full capacity "
661 "%llu sectors (%llu MB)\n",
662 drive->name, (unsigned long long)drive->capacity64,
663 sectors_to_MB(drive->capacity64));
664 drive->capacity64 = 1ULL << 28;
665 }
666 638
667 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && 639 /* calculate drive capacity, and select LBA if possible */
668 (drive->dev_flags & IDE_DFLAG_LBA48)) { 640 ide_disk_get_capacity(drive);
669 if (drive->capacity64 > 1ULL << 28) {
670 printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode"
671 " will be used for accessing sectors "
672 "> %u\n", drive->name, 1 << 28);
673 } else
674 drive->dev_flags &= ~IDE_DFLAG_LBA48;
675 }
676 641
677 /* 642 /*
678 * if possible, give fdisk access to more of the drive, 643 * if possible, give fdisk access to more of the drive,
679 * by correcting bios_cyls: 644 * by correcting bios_cyls:
680 */ 645 */
681 capacity = ide_disk_capacity(drive); 646 capacity = ide_gd_capacity(drive);
682 647
683 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) { 648 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) {
684 if (ata_id_lba48_enabled(drive->id)) { 649 if (ata_id_lba48_enabled(drive->id)) {
@@ -718,9 +683,17 @@ static void idedisk_setup(ide_drive_t *drive)
718 drive->dev_flags |= IDE_DFLAG_WCACHE; 683 drive->dev_flags |= IDE_DFLAG_WCACHE;
719 684
720 set_wcache(drive, 1); 685 set_wcache(drive, 1);
686
687 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 &&
688 (drive->head == 0 || drive->head > 16)) {
689 printk(KERN_ERR "%s: invalid geometry: %d physical heads?\n",
690 drive->name, drive->head);
691 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
692 } else
693 drive->dev_flags |= IDE_DFLAG_ATTACH;
721} 694}
722 695
723static void ide_cacheflush_p(ide_drive_t *drive) 696static void ide_disk_flush(ide_drive_t *drive)
724{ 697{
725 if (ata_id_flush_enabled(drive->id) == 0 || 698 if (ata_id_flush_enabled(drive->id) == 0 ||
726 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) 699 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0)
@@ -730,267 +703,40 @@ static void ide_cacheflush_p(ide_drive_t *drive)
730 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); 703 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
731} 704}
732 705
733static void ide_disk_remove(ide_drive_t *drive) 706static int ide_disk_init_media(ide_drive_t *drive, struct gendisk *disk)
734{
735 struct ide_disk_obj *idkp = drive->driver_data;
736 struct gendisk *g = idkp->disk;
737
738 ide_proc_unregister_driver(drive, idkp->driver);
739
740 del_gendisk(g);
741
742 ide_cacheflush_p(drive);
743
744 ide_disk_put(idkp);
745}
746
747static void ide_disk_release(struct kref *kref)
748{
749 struct ide_disk_obj *idkp = to_ide_disk(kref);
750 ide_drive_t *drive = idkp->drive;
751 struct gendisk *g = idkp->disk;
752
753 drive->driver_data = NULL;
754 g->private_data = NULL;
755 put_disk(g);
756 kfree(idkp);
757}
758
759static int ide_disk_probe(ide_drive_t *drive);
760
761/*
762 * On HPA drives the capacity needs to be
763 * reinitilized on resume otherwise the disk
764 * can not be used and a hard reset is required
765 */
766static void ide_disk_resume(ide_drive_t *drive)
767{
768 if (ata_id_hpa_enabled(drive->id))
769 init_idedisk_capacity(drive);
770}
771
772static void ide_device_shutdown(ide_drive_t *drive)
773{ 707{
774#ifdef CONFIG_ALPHA 708 return 0;
775 /* On Alpha, halt(8) doesn't actually turn the machine off,
776 it puts you into the sort of firmware monitor. Typically,
777 it's used to boot another kernel image, so it's not much
778 different from reboot(8). Therefore, we don't need to
779 spin down the disk in this case, especially since Alpha
780 firmware doesn't handle disks in standby mode properly.
781 On the other hand, it's reasonably safe to turn the power
782 off when the shutdown process reaches the firmware prompt,
783 as the firmware initialization takes rather long time -
784 at least 10 seconds, which should be sufficient for
785 the disk to expire its write cache. */
786 if (system_state != SYSTEM_POWER_OFF) {
787#else
788 if (system_state == SYSTEM_RESTART) {
789#endif
790 ide_cacheflush_p(drive);
791 return;
792 }
793
794 printk(KERN_INFO "Shutdown: %s\n", drive->name);
795
796 drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
797} 709}
798 710
799static ide_driver_t idedisk_driver = { 711static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
800 .gen_driver = { 712 int on)
801 .owner = THIS_MODULE,
802 .name = "ide-disk",
803 .bus = &ide_bus_type,
804 },
805 .probe = ide_disk_probe,
806 .remove = ide_disk_remove,
807 .resume = ide_disk_resume,
808 .shutdown = ide_device_shutdown,
809 .version = IDEDISK_VERSION,
810 .do_request = ide_do_rw_disk,
811 .end_request = ide_end_request,
812 .error = __ide_error,
813#ifdef CONFIG_IDE_PROC_FS
814 .proc = ide_disk_proc,
815 .settings = ide_disk_settings,
816#endif
817};
818
819static int idedisk_set_doorlock(ide_drive_t *drive, int on)
820{ 713{
821 ide_task_t task; 714 ide_task_t task;
715 int ret;
716
717 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
718 return 0;
822 719
823 memset(&task, 0, sizeof(task)); 720 memset(&task, 0, sizeof(task));
824 task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK; 721 task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK;
825 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 722 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
826 723
827 return ide_no_data_taskfile(drive, &task); 724 ret = ide_no_data_taskfile(drive, &task);
828}
829
830static int idedisk_open(struct inode *inode, struct file *filp)
831{
832 struct gendisk *disk = inode->i_bdev->bd_disk;
833 struct ide_disk_obj *idkp;
834 ide_drive_t *drive;
835
836 idkp = ide_disk_get(disk);
837 if (idkp == NULL)
838 return -ENXIO;
839
840 drive = idkp->drive;
841
842 idkp->openers++;
843
844 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
845 check_disk_change(inode->i_bdev);
846 /*
847 * Ignore the return code from door_lock,
848 * since the open() has already succeeded,
849 * and the door_lock is irrelevant at this point.
850 */
851 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
852 idedisk_set_doorlock(drive, 1))
853 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
854 }
855 return 0;
856}
857
858static int idedisk_release(struct inode *inode, struct file *filp)
859{
860 struct gendisk *disk = inode->i_bdev->bd_disk;
861 struct ide_disk_obj *idkp = ide_disk_g(disk);
862 ide_drive_t *drive = idkp->drive;
863
864 if (idkp->openers == 1)
865 ide_cacheflush_p(drive);
866
867 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
868 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
869 idedisk_set_doorlock(drive, 0))
870 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
871 }
872
873 idkp->openers--;
874
875 ide_disk_put(idkp);
876
877 return 0;
878}
879
880static int idedisk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
881{
882 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk);
883 ide_drive_t *drive = idkp->drive;
884
885 geo->heads = drive->bios_head;
886 geo->sectors = drive->bios_sect;
887 geo->cylinders = (u16)drive->bios_cyl; /* truncate */
888 return 0;
889}
890
891static int idedisk_media_changed(struct gendisk *disk)
892{
893 struct ide_disk_obj *idkp = ide_disk_g(disk);
894 ide_drive_t *drive = idkp->drive;
895
896 /* do not scan partitions twice if this is a removable device */
897 if (drive->dev_flags & IDE_DFLAG_ATTACH) {
898 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
899 return 0;
900 }
901 725
902 /* if removable, always assume it was changed */ 726 if (ret)
903 return !!(drive->dev_flags & IDE_DFLAG_REMOVABLE); 727 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
904}
905 728
906static int idedisk_revalidate_disk(struct gendisk *disk) 729 return ret;
907{
908 struct ide_disk_obj *idkp = ide_disk_g(disk);
909 set_capacity(disk, ide_disk_capacity(idkp->drive));
910 return 0;
911} 730}
912 731
913static struct block_device_operations idedisk_ops = { 732const struct ide_disk_ops ide_ata_disk_ops = {
914 .owner = THIS_MODULE, 733 .check = ide_disk_check,
915 .open = idedisk_open, 734 .get_capacity = ide_disk_get_capacity,
916 .release = idedisk_release, 735 .setup = ide_disk_setup,
917 .ioctl = ide_disk_ioctl, 736 .flush = ide_disk_flush,
918 .getgeo = idedisk_getgeo, 737 .init_media = ide_disk_init_media,
919 .media_changed = idedisk_media_changed, 738 .set_doorlock = ide_disk_set_doorlock,
920 .revalidate_disk = idedisk_revalidate_disk 739 .do_request = ide_do_rw_disk,
740 .end_request = ide_end_request,
741 .ioctl = ide_disk_ioctl,
921}; 742};
922
923MODULE_DESCRIPTION("ATA DISK Driver");
924
925static int ide_disk_probe(ide_drive_t *drive)
926{
927 struct ide_disk_obj *idkp;
928 struct gendisk *g;
929
930 /* strstr("foo", "") is non-NULL */
931 if (!strstr("ide-disk", drive->driver_req))
932 goto failed;
933
934 if (drive->media != ide_disk)
935 goto failed;
936
937 idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
938 if (!idkp)
939 goto failed;
940
941 g = alloc_disk_node(IDE_DISK_MINORS, hwif_to_node(drive->hwif));
942 if (!g)
943 goto out_free_idkp;
944
945 ide_init_disk(g, drive);
946
947 kref_init(&idkp->kref);
948
949 idkp->drive = drive;
950 idkp->driver = &idedisk_driver;
951 idkp->disk = g;
952
953 g->private_data = &idkp->driver;
954
955 drive->driver_data = idkp;
956
957 idedisk_setup(drive);
958 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 &&
959 (drive->head == 0 || drive->head > 16)) {
960 printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n",
961 drive->name, drive->head);
962 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
963 } else
964 drive->dev_flags |= IDE_DFLAG_ATTACH;
965
966 g->minors = IDE_DISK_MINORS;
967 g->driverfs_dev = &drive->gendev;
968 g->flags |= GENHD_FL_EXT_DEVT;
969 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
970 g->flags = GENHD_FL_REMOVABLE;
971 set_capacity(g, ide_disk_capacity(drive));
972 g->fops = &idedisk_ops;
973 add_disk(g);
974 return 0;
975
976out_free_idkp:
977 kfree(idkp);
978failed:
979 return -ENODEV;
980}
981
982static void __exit idedisk_exit(void)
983{
984 driver_unregister(&idedisk_driver.gen_driver);
985}
986
987static int __init idedisk_init(void)
988{
989 return driver_register(&idedisk_driver.gen_driver);
990}
991
992MODULE_ALIAS("ide:*m-disk*");
993MODULE_ALIAS("ide-disk");
994module_init(idedisk_init);
995module_exit(idedisk_exit);
996MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-disk.h b/drivers/ide/ide-disk.h
index a82fa4355665..d511dab7c4aa 100644
--- a/drivers/ide/ide-disk.h
+++ b/drivers/ide/ide-disk.h
@@ -1,19 +1,11 @@
1#ifndef __IDE_DISK_H 1#ifndef __IDE_DISK_H
2#define __IDE_DISK_H 2#define __IDE_DISK_H
3 3
4struct ide_disk_obj { 4#include "ide-gd.h"
5 ide_drive_t *drive;
6 ide_driver_t *driver;
7 struct gendisk *disk;
8 struct kref kref;
9 unsigned int openers; /* protected by BKL for now */
10};
11
12#define ide_disk_g(disk) \
13 container_of((disk)->private_data, struct ide_disk_obj, driver)
14 5
6#ifdef CONFIG_IDE_GD_ATA
15/* ide-disk.c */ 7/* ide-disk.c */
16sector_t ide_disk_capacity(ide_drive_t *); 8extern const struct ide_disk_ops ide_ata_disk_ops;
17ide_decl_devset(address); 9ide_decl_devset(address);
18ide_decl_devset(multcount); 10ide_decl_devset(multcount);
19ide_decl_devset(nowerr); 11ide_decl_devset(nowerr);
@@ -21,12 +13,17 @@ ide_decl_devset(wcache);
21ide_decl_devset(acoustic); 13ide_decl_devset(acoustic);
22 14
23/* ide-disk_ioctl.c */ 15/* ide-disk_ioctl.c */
24int ide_disk_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 16int ide_disk_ioctl(ide_drive_t *, struct block_device *, fmode_t, unsigned int,
17 unsigned long);
25 18
26#ifdef CONFIG_IDE_PROC_FS 19#ifdef CONFIG_IDE_PROC_FS
27/* ide-disk_proc.c */ 20/* ide-disk_proc.c */
28extern ide_proc_entry_t ide_disk_proc[]; 21extern ide_proc_entry_t ide_disk_proc[];
29extern const struct ide_proc_devset ide_disk_settings[]; 22extern const struct ide_proc_devset ide_disk_settings[];
30#endif 23#endif
24#else
25#define ide_disk_proc NULL
26#define ide_disk_settings NULL
27#endif
31 28
32#endif /* __IDE_DISK_H */ 29#endif /* __IDE_DISK_H */
diff --git a/drivers/ide/ide-disk_ioctl.c b/drivers/ide/ide-disk_ioctl.c
index a6cf1a03a806..7b783dd7c0be 100644
--- a/drivers/ide/ide-disk_ioctl.c
+++ b/drivers/ide/ide-disk_ioctl.c
@@ -13,17 +13,14 @@ static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
13{ 0 } 13{ 0 }
14}; 14};
15 15
16int ide_disk_ioctl(struct inode *inode, struct file *file, 16int ide_disk_ioctl(ide_drive_t *drive, struct block_device *bdev, fmode_t mode,
17 unsigned int cmd, unsigned long arg) 17 unsigned int cmd, unsigned long arg)
18{ 18{
19 struct block_device *bdev = inode->i_bdev;
20 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk);
21 ide_drive_t *drive = idkp->drive;
22 int err; 19 int err;
23 20
24 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 21 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings);
25 if (err != -EOPNOTSUPP) 22 if (err != -EOPNOTSUPP)
26 return err; 23 return err;
27 24
28 return generic_ide_ioctl(drive, file, bdev, cmd, arg); 25 return generic_ide_ioctl(drive, bdev, cmd, arg);
29} 26}
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 4724976afe71..1146f4204c6e 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -56,7 +56,7 @@ static int proc_idedisk_read_capacity
56 ide_drive_t*drive = (ide_drive_t *)data; 56 ide_drive_t*drive = (ide_drive_t *)data;
57 int len; 57 int len;
58 58
59 len = sprintf(page, "%llu\n", (long long)ide_disk_capacity(drive)); 59 len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive));
60 60
61 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 61 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
62} 62}
diff --git a/drivers/ide/ide-dma-sff.c b/drivers/ide/ide-dma-sff.c
index 0903782689e9..cac431f0df17 100644
--- a/drivers/ide/ide-dma-sff.c
+++ b/drivers/ide/ide-dma-sff.c
@@ -130,7 +130,7 @@ int ide_build_dmatable(ide_drive_t *drive, struct request *rq)
130 xcount = bcount & 0xffff; 130 xcount = bcount & 0xffff;
131 if (is_trm290) 131 if (is_trm290)
132 xcount = ((xcount >> 2) - 1) << 16; 132 xcount = ((xcount >> 2) - 1) << 16;
133 if (xcount == 0x0000) { 133 else if (xcount == 0x0000) {
134 if (count++ >= PRD_ENTRIES) 134 if (count++ >= PRD_ENTRIES)
135 goto use_pio_instead; 135 goto use_pio_instead;
136 *table++ = cpu_to_le32(0x8000); 136 *table++ = cpu_to_le32(0x8000);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index cf0aa25470ee..aeb1ad782f54 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -15,12 +15,6 @@
15 * Documentation/ide/ChangeLog.ide-floppy.1996-2002 15 * Documentation/ide/ChangeLog.ide-floppy.1996-2002
16 */ 16 */
17 17
18#define DRV_NAME "ide-floppy"
19#define PFX DRV_NAME ": "
20
21#define IDEFLOPPY_VERSION "1.00"
22
23#include <linux/module.h>
24#include <linux/types.h> 18#include <linux/types.h>
25#include <linux/string.h> 19#include <linux/string.h>
26#include <linux/kernel.h> 20#include <linux/kernel.h>
@@ -49,19 +43,6 @@
49 43
50#include "ide-floppy.h" 44#include "ide-floppy.h"
51 45
52/* module parameters */
53static unsigned long debug_mask;
54module_param(debug_mask, ulong, 0644);
55
56/* define to see debug info */
57#define IDEFLOPPY_DEBUG_LOG 0
58
59#if IDEFLOPPY_DEBUG_LOG
60#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args)
61#else
62#define ide_debug_log(lvl, fmt, args...) do {} while (0)
63#endif
64
65/* 46/*
66 * After each failed packet command we issue a request sense command and retry 47 * After each failed packet command we issue a request sense command and retry
67 * the packet command IDEFLOPPY_MAX_PC_RETRIES times. 48 * the packet command IDEFLOPPY_MAX_PC_RETRIES times.
@@ -83,43 +64,13 @@ module_param(debug_mask, ulong, 0644);
83/* Error code returned in rq->errors to the higher part of the driver. */ 64/* Error code returned in rq->errors to the higher part of the driver. */
84#define IDEFLOPPY_ERROR_GENERAL 101 65#define IDEFLOPPY_ERROR_GENERAL 101
85 66
86static DEFINE_MUTEX(idefloppy_ref_mutex);
87
88static void idefloppy_cleanup_obj(struct kref *);
89
90static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
91{
92 struct ide_floppy_obj *floppy = NULL;
93
94 mutex_lock(&idefloppy_ref_mutex);
95 floppy = ide_drv_g(disk, ide_floppy_obj);
96 if (floppy) {
97 if (ide_device_get(floppy->drive))
98 floppy = NULL;
99 else
100 kref_get(&floppy->kref);
101 }
102 mutex_unlock(&idefloppy_ref_mutex);
103 return floppy;
104}
105
106static void ide_floppy_put(struct ide_floppy_obj *floppy)
107{
108 ide_drive_t *drive = floppy->drive;
109
110 mutex_lock(&idefloppy_ref_mutex);
111 kref_put(&floppy->kref, idefloppy_cleanup_obj);
112 ide_device_put(drive);
113 mutex_unlock(&idefloppy_ref_mutex);
114}
115
116/* 67/*
117 * Used to finish servicing a request. For read/write requests, we will call 68 * Used to finish servicing a request. For read/write requests, we will call
118 * ide_end_request to pass to the next buffer. 69 * ide_end_request to pass to the next buffer.
119 */ 70 */
120static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) 71static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs)
121{ 72{
122 idefloppy_floppy_t *floppy = drive->driver_data; 73 struct ide_disk_obj *floppy = drive->driver_data;
123 struct request *rq = HWGROUP(drive)->rq; 74 struct request *rq = HWGROUP(drive)->rq;
124 int error; 75 int error;
125 76
@@ -161,12 +112,12 @@ static void idefloppy_update_buffers(ide_drive_t *drive,
161 struct bio *bio = rq->bio; 112 struct bio *bio = rq->bio;
162 113
163 while ((bio = rq->bio) != NULL) 114 while ((bio = rq->bio) != NULL)
164 idefloppy_end_request(drive, 1, 0); 115 ide_floppy_end_request(drive, 1, 0);
165} 116}
166 117
167static void ide_floppy_callback(ide_drive_t *drive, int dsc) 118static void ide_floppy_callback(ide_drive_t *drive, int dsc)
168{ 119{
169 idefloppy_floppy_t *floppy = drive->driver_data; 120 struct ide_disk_obj *floppy = drive->driver_data;
170 struct ide_atapi_pc *pc = drive->pc; 121 struct ide_atapi_pc *pc = drive->pc;
171 int uptodate = pc->error ? 0 : 1; 122 int uptodate = pc->error ? 0 : 1;
172 123
@@ -200,10 +151,10 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc)
200 "Aborting request!\n"); 151 "Aborting request!\n");
201 } 152 }
202 153
203 idefloppy_end_request(drive, uptodate, 0); 154 ide_floppy_end_request(drive, uptodate, 0);
204} 155}
205 156
206static void ide_floppy_report_error(idefloppy_floppy_t *floppy, 157static void ide_floppy_report_error(struct ide_disk_obj *floppy,
207 struct ide_atapi_pc *pc) 158 struct ide_atapi_pc *pc)
208{ 159{
209 /* supress error messages resulting from Medium not present */ 160 /* supress error messages resulting from Medium not present */
@@ -222,7 +173,7 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
222static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, 173static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
223 struct ide_atapi_pc *pc) 174 struct ide_atapi_pc *pc)
224{ 175{
225 idefloppy_floppy_t *floppy = drive->driver_data; 176 struct ide_disk_obj *floppy = drive->driver_data;
226 177
227 if (floppy->failed_pc == NULL && 178 if (floppy->failed_pc == NULL &&
228 pc->c[0] != GPCMD_REQUEST_SENSE) 179 pc->c[0] != GPCMD_REQUEST_SENSE)
@@ -286,7 +237,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
286 struct ide_atapi_pc *pc, struct request *rq, 237 struct ide_atapi_pc *pc, struct request *rq,
287 unsigned long sector) 238 unsigned long sector)
288{ 239{
289 idefloppy_floppy_t *floppy = drive->driver_data; 240 struct ide_disk_obj *floppy = drive->driver_data;
290 int block = sector / floppy->bs_factor; 241 int block = sector / floppy->bs_factor;
291 int blocks = rq->nr_sectors / floppy->bs_factor; 242 int blocks = rq->nr_sectors / floppy->bs_factor;
292 int cmd = rq_data_dir(rq); 243 int cmd = rq_data_dir(rq);
@@ -310,7 +261,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
310 pc->flags |= PC_FLAG_DMA_OK; 261 pc->flags |= PC_FLAG_DMA_OK;
311} 262}
312 263
313static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, 264static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy,
314 struct ide_atapi_pc *pc, struct request *rq) 265 struct ide_atapi_pc *pc, struct request *rq)
315{ 266{
316 ide_init_pc(pc); 267 ide_init_pc(pc);
@@ -329,13 +280,12 @@ static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
329 pc->req_xfer = pc->buf_size = rq->data_len; 280 pc->req_xfer = pc->buf_size = rq->data_len;
330} 281}
331 282
332static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, 283static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
333 struct request *rq, sector_t block_s) 284 struct request *rq, sector_t block)
334{ 285{
335 idefloppy_floppy_t *floppy = drive->driver_data; 286 struct ide_disk_obj *floppy = drive->driver_data;
336 ide_hwif_t *hwif = drive->hwif; 287 ide_hwif_t *hwif = drive->hwif;
337 struct ide_atapi_pc *pc; 288 struct ide_atapi_pc *pc;
338 unsigned long block = (unsigned long)block_s;
339 289
340 ide_debug_log(IDE_DBG_FUNC, "%s: dev: %s, cmd: 0x%x, cmd_type: %x, " 290 ide_debug_log(IDE_DBG_FUNC, "%s: dev: %s, cmd: 0x%x, cmd_type: %x, "
341 "errors: %d\n", 291 "errors: %d\n",
@@ -353,7 +303,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
353 else 303 else
354 printk(KERN_ERR PFX "%s: I/O error\n", drive->name); 304 printk(KERN_ERR PFX "%s: I/O error\n", drive->name);
355 305
356 idefloppy_end_request(drive, 0, 0); 306 ide_floppy_end_request(drive, 0, 0);
357 return ide_stopped; 307 return ide_stopped;
358 } 308 }
359 if (blk_fs_request(rq)) { 309 if (blk_fs_request(rq)) {
@@ -361,11 +311,11 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
361 (rq->nr_sectors % floppy->bs_factor)) { 311 (rq->nr_sectors % floppy->bs_factor)) {
362 printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", 312 printk(KERN_ERR PFX "%s: unsupported r/w rq size\n",
363 drive->name); 313 drive->name);
364 idefloppy_end_request(drive, 0, 0); 314 ide_floppy_end_request(drive, 0, 0);
365 return ide_stopped; 315 return ide_stopped;
366 } 316 }
367 pc = &floppy->queued_pc; 317 pc = &floppy->queued_pc;
368 idefloppy_create_rw_cmd(drive, pc, rq, block); 318 idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
369 } else if (blk_special_request(rq)) { 319 } else if (blk_special_request(rq)) {
370 pc = (struct ide_atapi_pc *) rq->buffer; 320 pc = (struct ide_atapi_pc *) rq->buffer;
371 } else if (blk_pc_request(rq)) { 321 } else if (blk_pc_request(rq)) {
@@ -373,7 +323,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
373 idefloppy_blockpc_cmd(floppy, pc, rq); 323 idefloppy_blockpc_cmd(floppy, pc, rq);
374 } else { 324 } else {
375 blk_dump_rq_flags(rq, PFX "unsupported command in queue"); 325 blk_dump_rq_flags(rq, PFX "unsupported command in queue");
376 idefloppy_end_request(drive, 0, 0); 326 ide_floppy_end_request(drive, 0, 0);
377 return ide_stopped; 327 return ide_stopped;
378 } 328 }
379 329
@@ -394,7 +344,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
394 */ 344 */
395static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) 345static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
396{ 346{
397 idefloppy_floppy_t *floppy = drive->driver_data; 347 struct ide_disk_obj *floppy = drive->driver_data;
398 struct gendisk *disk = floppy->disk; 348 struct gendisk *disk = floppy->disk;
399 struct ide_atapi_pc pc; 349 struct ide_atapi_pc pc;
400 u8 *page; 350 u8 *page;
@@ -410,11 +360,11 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
410 } 360 }
411 361
412 if (pc.buf[3] & 0x80) 362 if (pc.buf[3] & 0x80)
413 drive->atapi_flags |= IDE_AFLAG_WP; 363 drive->dev_flags |= IDE_DFLAG_WP;
414 else 364 else
415 drive->atapi_flags &= ~IDE_AFLAG_WP; 365 drive->dev_flags &= ~IDE_DFLAG_WP;
416 366
417 set_disk_ro(disk, !!(drive->atapi_flags & IDE_AFLAG_WP)); 367 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP));
418 368
419 page = &pc.buf[8]; 369 page = &pc.buf[8];
420 370
@@ -445,7 +395,9 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
445 drive->name, lba_capacity, capacity); 395 drive->name, lba_capacity, capacity);
446 floppy->blocks = floppy->block_size ? 396 floppy->blocks = floppy->block_size ?
447 capacity / floppy->block_size : 0; 397 capacity / floppy->block_size : 0;
398 drive->capacity64 = floppy->blocks * floppy->bs_factor;
448 } 399 }
400
449 return 0; 401 return 0;
450} 402}
451 403
@@ -455,7 +407,7 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
455 */ 407 */
456static int ide_floppy_get_capacity(ide_drive_t *drive) 408static int ide_floppy_get_capacity(ide_drive_t *drive)
457{ 409{
458 idefloppy_floppy_t *floppy = drive->driver_data; 410 struct ide_disk_obj *floppy = drive->driver_data;
459 struct gendisk *disk = floppy->disk; 411 struct gendisk *disk = floppy->disk;
460 struct ide_atapi_pc pc; 412 struct ide_atapi_pc pc;
461 u8 *cap_desc; 413 u8 *cap_desc;
@@ -466,7 +418,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
466 drive->bios_head = drive->bios_sect = 0; 418 drive->bios_head = drive->bios_sect = 0;
467 floppy->blocks = 0; 419 floppy->blocks = 0;
468 floppy->bs_factor = 1; 420 floppy->bs_factor = 1;
469 set_capacity(floppy->disk, 0); 421 drive->capacity64 = 0;
470 422
471 ide_floppy_create_read_capacity_cmd(&pc); 423 ide_floppy_create_read_capacity_cmd(&pc);
472 if (ide_queue_pc_tail(drive, disk, &pc)) { 424 if (ide_queue_pc_tail(drive, disk, &pc)) {
@@ -523,6 +475,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
523 "non 512 bytes block size not " 475 "non 512 bytes block size not "
524 "fully supported\n", 476 "fully supported\n",
525 drive->name); 477 drive->name);
478 drive->capacity64 =
479 floppy->blocks * floppy->bs_factor;
526 rc = 0; 480 rc = 0;
527 } 481 }
528 break; 482 break;
@@ -547,21 +501,12 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
547 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) 501 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
548 (void) ide_floppy_get_flexible_disk_page(drive); 502 (void) ide_floppy_get_flexible_disk_page(drive);
549 503
550 set_capacity(disk, floppy->blocks * floppy->bs_factor);
551
552 return rc; 504 return rc;
553} 505}
554 506
555sector_t ide_floppy_capacity(ide_drive_t *drive) 507static void ide_floppy_setup(ide_drive_t *drive)
556{
557 idefloppy_floppy_t *floppy = drive->driver_data;
558 unsigned long capacity = floppy->blocks * floppy->bs_factor;
559
560 return capacity;
561}
562
563static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
564{ 508{
509 struct ide_disk_obj *floppy = drive->driver_data;
565 u16 *id = drive->id; 510 u16 *id = drive->id;
566 511
567 drive->pc_callback = ide_floppy_callback; 512 drive->pc_callback = ide_floppy_callback;
@@ -592,252 +537,42 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
592 blk_queue_max_sectors(drive->queue, 64); 537 blk_queue_max_sectors(drive->queue, 64);
593 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; 538 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE;
594 /* IOMEGA Clik! drives do not support lock/unlock commands */ 539 /* IOMEGA Clik! drives do not support lock/unlock commands */
595 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 540 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
596 } 541 }
597 542
598 (void) ide_floppy_get_capacity(drive); 543 (void) ide_floppy_get_capacity(drive);
599 544
600 ide_proc_register_driver(drive, floppy->driver); 545 ide_proc_register_driver(drive, floppy->driver);
601}
602 546
603static void ide_floppy_remove(ide_drive_t *drive) 547 drive->dev_flags |= IDE_DFLAG_ATTACH;
604{
605 idefloppy_floppy_t *floppy = drive->driver_data;
606 struct gendisk *g = floppy->disk;
607
608 ide_proc_unregister_driver(drive, floppy->driver);
609
610 del_gendisk(g);
611
612 ide_floppy_put(floppy);
613} 548}
614 549
615static void idefloppy_cleanup_obj(struct kref *kref) 550static void ide_floppy_flush(ide_drive_t *drive)
616{ 551{
617 struct ide_floppy_obj *floppy = to_ide_drv(kref, ide_floppy_obj);
618 ide_drive_t *drive = floppy->drive;
619 struct gendisk *g = floppy->disk;
620
621 drive->driver_data = NULL;
622 g->private_data = NULL;
623 put_disk(g);
624 kfree(floppy);
625} 552}
626 553
627static int ide_floppy_probe(ide_drive_t *); 554static int ide_floppy_init_media(ide_drive_t *drive, struct gendisk *disk)
628
629static ide_driver_t idefloppy_driver = {
630 .gen_driver = {
631 .owner = THIS_MODULE,
632 .name = "ide-floppy",
633 .bus = &ide_bus_type,
634 },
635 .probe = ide_floppy_probe,
636 .remove = ide_floppy_remove,
637 .version = IDEFLOPPY_VERSION,
638 .do_request = idefloppy_do_request,
639 .end_request = idefloppy_end_request,
640 .error = __ide_error,
641#ifdef CONFIG_IDE_PROC_FS
642 .proc = ide_floppy_proc,
643 .settings = ide_floppy_settings,
644#endif
645};
646
647static int idefloppy_open(struct inode *inode, struct file *filp)
648{ 555{
649 struct gendisk *disk = inode->i_bdev->bd_disk;
650 struct ide_floppy_obj *floppy;
651 ide_drive_t *drive;
652 int ret = 0; 556 int ret = 0;
653 557
654 floppy = ide_floppy_get(disk); 558 if (ide_do_test_unit_ready(drive, disk))
655 if (!floppy) 559 ide_do_start_stop(drive, disk, 1);
656 return -ENXIO;
657
658 drive = floppy->drive;
659
660 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
661
662 floppy->openers++;
663
664 if (floppy->openers == 1) {
665 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
666 /* Just in case */
667
668 if (ide_do_test_unit_ready(drive, disk))
669 ide_do_start_stop(drive, disk, 1);
670
671 if (ide_floppy_get_capacity(drive)
672 && (filp->f_flags & O_NDELAY) == 0
673 /*
674 * Allow O_NDELAY to open a drive without a disk, or with an
675 * unreadable disk, so that we can get the format capacity
676 * of the drive or begin the format - Sam
677 */
678 ) {
679 ret = -EIO;
680 goto out_put_floppy;
681 }
682
683 if ((drive->atapi_flags & IDE_AFLAG_WP) && (filp->f_mode & 2)) {
684 ret = -EROFS;
685 goto out_put_floppy;
686 }
687
688 drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED;
689 ide_set_media_lock(drive, disk, 1);
690 check_disk_change(inode->i_bdev);
691 } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) {
692 ret = -EBUSY;
693 goto out_put_floppy;
694 }
695 return 0;
696
697out_put_floppy:
698 floppy->openers--;
699 ide_floppy_put(floppy);
700 return ret;
701}
702
703static int idefloppy_release(struct inode *inode, struct file *filp)
704{
705 struct gendisk *disk = inode->i_bdev->bd_disk;
706 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
707 ide_drive_t *drive = floppy->drive;
708
709 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
710
711 if (floppy->openers == 1) {
712 ide_set_media_lock(drive, disk, 0);
713 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
714 }
715
716 floppy->openers--;
717
718 ide_floppy_put(floppy);
719
720 return 0;
721}
722
723static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
724{
725 struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
726 ide_floppy_obj);
727 ide_drive_t *drive = floppy->drive;
728 560
729 geo->heads = drive->bios_head; 561 ret = ide_floppy_get_capacity(drive);
730 geo->sectors = drive->bios_sect;
731 geo->cylinders = (u16)drive->bios_cyl; /* truncate */
732 return 0;
733}
734 562
735static int idefloppy_media_changed(struct gendisk *disk) 563 set_capacity(disk, ide_gd_capacity(drive));
736{
737 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
738 ide_drive_t *drive = floppy->drive;
739 int ret;
740 564
741 /* do not scan partitions twice if this is a removable device */
742 if (drive->dev_flags & IDE_DFLAG_ATTACH) {
743 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
744 return 0;
745 }
746 ret = !!(drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED);
747 drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED;
748 return ret; 565 return ret;
749} 566}
750 567
751static int idefloppy_revalidate_disk(struct gendisk *disk) 568const struct ide_disk_ops ide_atapi_disk_ops = {
752{ 569 .check = ide_check_atapi_device,
753 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); 570 .get_capacity = ide_floppy_get_capacity,
754 set_capacity(disk, ide_floppy_capacity(floppy->drive)); 571 .setup = ide_floppy_setup,
755 return 0; 572 .flush = ide_floppy_flush,
756} 573 .init_media = ide_floppy_init_media,
757 574 .set_doorlock = ide_set_media_lock,
758static struct block_device_operations idefloppy_ops = { 575 .do_request = ide_floppy_do_request,
759 .owner = THIS_MODULE, 576 .end_request = ide_floppy_end_request,
760 .open = idefloppy_open, 577 .ioctl = ide_floppy_ioctl,
761 .release = idefloppy_release,
762 .ioctl = ide_floppy_ioctl,
763 .getgeo = idefloppy_getgeo,
764 .media_changed = idefloppy_media_changed,
765 .revalidate_disk = idefloppy_revalidate_disk
766}; 578};
767
768static int ide_floppy_probe(ide_drive_t *drive)
769{
770 idefloppy_floppy_t *floppy;
771 struct gendisk *g;
772
773 if (!strstr("ide-floppy", drive->driver_req))
774 goto failed;
775
776 if (drive->media != ide_floppy)
777 goto failed;
778
779 if (!ide_check_atapi_device(drive, DRV_NAME)) {
780 printk(KERN_ERR PFX "%s: not supported by this version of "
781 DRV_NAME "\n", drive->name);
782 goto failed;
783 }
784 floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL);
785 if (!floppy) {
786 printk(KERN_ERR PFX "%s: Can't allocate a floppy structure\n",
787 drive->name);
788 goto failed;
789 }
790
791 g = alloc_disk(1 << PARTN_BITS);
792 if (!g)
793 goto out_free_floppy;
794
795 ide_init_disk(g, drive);
796
797 kref_init(&floppy->kref);
798
799 floppy->drive = drive;
800 floppy->driver = &idefloppy_driver;
801 floppy->disk = g;
802
803 g->private_data = &floppy->driver;
804
805 drive->driver_data = floppy;
806
807 drive->debug_mask = debug_mask;
808
809 idefloppy_setup(drive, floppy);
810 drive->dev_flags |= IDE_DFLAG_ATTACH;
811
812 g->minors = 1 << PARTN_BITS;
813 g->driverfs_dev = &drive->gendev;
814 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
815 g->flags = GENHD_FL_REMOVABLE;
816 g->fops = &idefloppy_ops;
817 add_disk(g);
818 return 0;
819
820out_free_floppy:
821 kfree(floppy);
822failed:
823 return -ENODEV;
824}
825
826static void __exit idefloppy_exit(void)
827{
828 driver_unregister(&idefloppy_driver.gen_driver);
829}
830
831static int __init idefloppy_init(void)
832{
833 printk(KERN_INFO DRV_NAME " driver " IDEFLOPPY_VERSION "\n");
834 return driver_register(&idefloppy_driver.gen_driver);
835}
836
837MODULE_ALIAS("ide:*m-floppy*");
838MODULE_ALIAS("ide-floppy");
839module_init(idefloppy_init);
840module_exit(idefloppy_exit);
841MODULE_LICENSE("GPL");
842MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
843
diff --git a/drivers/ide/ide-floppy.h b/drivers/ide/ide-floppy.h
index 17cf865e583d..6dd2beb48434 100644
--- a/drivers/ide/ide-floppy.h
+++ b/drivers/ide/ide-floppy.h
@@ -1,37 +1,9 @@
1#ifndef __IDE_FLOPPY_H 1#ifndef __IDE_FLOPPY_H
2#define __IDE_FLOPPY_H 2#define __IDE_FLOPPY_H
3 3
4/* 4#include "ide-gd.h"
5 * Most of our global data which we need to save even as we leave the driver
6 * due to an interrupt or a timer event is stored in a variable of type
7 * idefloppy_floppy_t, defined below.
8 */
9typedef struct ide_floppy_obj {
10 ide_drive_t *drive;
11 ide_driver_t *driver;
12 struct gendisk *disk;
13 struct kref kref;
14 unsigned int openers; /* protected by BKL for now */
15
16 /* Last failed packet command */
17 struct ide_atapi_pc *failed_pc;
18 /* used for blk_{fs,pc}_request() requests */
19 struct ide_atapi_pc queued_pc;
20
21 /* Last error information */
22 u8 sense_key, asc, ascq;
23
24 int progress_indication;
25
26 /* Device information */
27 /* Current format */
28 int blocks, block_size, bs_factor;
29 /* Last format capacity descriptor */
30 u8 cap_desc[8];
31 /* Copy of the flexible disk page */
32 u8 flexible_disk_page[32];
33} idefloppy_floppy_t;
34 5
6#ifdef CONFIG_IDE_GD_ATAPI
35/* 7/*
36 * Pages of the SELECT SENSE / MODE SENSE packet commands. 8 * Pages of the SELECT SENSE / MODE SENSE packet commands.
37 * See SFF-8070i spec. 9 * See SFF-8070i spec.
@@ -46,17 +18,22 @@ typedef struct ide_floppy_obj {
46#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 18#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603
47 19
48/* ide-floppy.c */ 20/* ide-floppy.c */
21extern const struct ide_disk_ops ide_atapi_disk_ops;
49void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8); 22void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
50void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *); 23void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);
51sector_t ide_floppy_capacity(ide_drive_t *);
52 24
53/* ide-floppy_ioctl.c */ 25/* ide-floppy_ioctl.c */
54int ide_floppy_ioctl(struct inode *, struct file *, unsigned, unsigned long); 26int ide_floppy_ioctl(ide_drive_t *, struct block_device *, fmode_t,
27 unsigned int, unsigned long);
55 28
56#ifdef CONFIG_IDE_PROC_FS 29#ifdef CONFIG_IDE_PROC_FS
57/* ide-floppy_proc.c */ 30/* ide-floppy_proc.c */
58extern ide_proc_entry_t ide_floppy_proc[]; 31extern ide_proc_entry_t ide_floppy_proc[];
59extern const struct ide_proc_devset ide_floppy_settings[]; 32extern const struct ide_proc_devset ide_floppy_settings[];
60#endif 33#endif
34#else
35#define ide_floppy_proc NULL
36#define ide_floppy_settings NULL
37#endif
61 38
62#endif /*__IDE_FLOPPY_H */ 39#endif /*__IDE_FLOPPY_H */
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index a3a7a0809e2b..2bc51ff73fee 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -33,7 +33,7 @@
33 33
34static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) 34static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
35{ 35{
36 struct ide_floppy_obj *floppy = drive->driver_data; 36 struct ide_disk_obj *floppy = drive->driver_data;
37 struct ide_atapi_pc pc; 37 struct ide_atapi_pc pc;
38 u8 header_len, desc_cnt; 38 u8 header_len, desc_cnt;
39 int i, blocks, length, u_array_size, u_index; 39 int i, blocks, length, u_array_size, u_index;
@@ -113,7 +113,7 @@ static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b,
113 113
114static int ide_floppy_get_sfrp_bit(ide_drive_t *drive) 114static int ide_floppy_get_sfrp_bit(ide_drive_t *drive)
115{ 115{
116 idefloppy_floppy_t *floppy = drive->driver_data; 116 struct ide_disk_obj *floppy = drive->driver_data;
117 struct ide_atapi_pc pc; 117 struct ide_atapi_pc pc;
118 118
119 drive->atapi_flags &= ~IDE_AFLAG_SRFP; 119 drive->atapi_flags &= ~IDE_AFLAG_SRFP;
@@ -132,17 +132,17 @@ static int ide_floppy_get_sfrp_bit(ide_drive_t *drive)
132 132
133static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) 133static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg)
134{ 134{
135 idefloppy_floppy_t *floppy = drive->driver_data; 135 struct ide_disk_obj *floppy = drive->driver_data;
136 struct ide_atapi_pc pc; 136 struct ide_atapi_pc pc;
137 int blocks, length, flags, err = 0; 137 int blocks, length, flags, err = 0;
138 138
139 if (floppy->openers > 1) { 139 if (floppy->openers > 1) {
140 /* Don't format if someone is using the disk */ 140 /* Don't format if someone is using the disk */
141 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; 141 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
142 return -EBUSY; 142 return -EBUSY;
143 } 143 }
144 144
145 drive->atapi_flags |= IDE_AFLAG_FORMAT_IN_PROGRESS; 145 drive->dev_flags |= IDE_DFLAG_FORMAT_IN_PROGRESS;
146 146
147 /* 147 /*
148 * Send ATAPI_FORMAT_UNIT to the drive. 148 * Send ATAPI_FORMAT_UNIT to the drive.
@@ -174,7 +174,7 @@ static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg)
174 174
175out: 175out:
176 if (err) 176 if (err)
177 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; 177 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
178 return err; 178 return err;
179} 179}
180 180
@@ -190,7 +190,7 @@ out:
190 190
191static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) 191static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
192{ 192{
193 idefloppy_floppy_t *floppy = drive->driver_data; 193 struct ide_disk_obj *floppy = drive->driver_data;
194 struct ide_atapi_pc pc; 194 struct ide_atapi_pc pc;
195 int progress_indication = 0x10000; 195 int progress_indication = 0x10000;
196 196
@@ -226,7 +226,7 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
226static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, 226static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
227 unsigned long arg, unsigned int cmd) 227 unsigned long arg, unsigned int cmd)
228{ 228{
229 idefloppy_floppy_t *floppy = drive->driver_data; 229 struct ide_disk_obj *floppy = drive->driver_data;
230 struct gendisk *disk = floppy->disk; 230 struct gendisk *disk = floppy->disk;
231 int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; 231 int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;
232 232
@@ -241,7 +241,7 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
241 return 0; 241 return 0;
242} 242}
243 243
244static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, 244static int ide_floppy_format_ioctl(ide_drive_t *drive, fmode_t mode,
245 unsigned int cmd, void __user *argp) 245 unsigned int cmd, void __user *argp)
246{ 246{
247 switch (cmd) { 247 switch (cmd) {
@@ -250,7 +250,7 @@ static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
250 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: 250 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
251 return ide_floppy_get_format_capacities(drive, argp); 251 return ide_floppy_get_format_capacities(drive, argp);
252 case IDEFLOPPY_IOCTL_FORMAT_START: 252 case IDEFLOPPY_IOCTL_FORMAT_START:
253 if (!(file->f_mode & 2)) 253 if (!(mode & FMODE_WRITE))
254 return -EPERM; 254 return -EPERM;
255 return ide_floppy_format_unit(drive, (int __user *)argp); 255 return ide_floppy_format_unit(drive, (int __user *)argp);
256 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: 256 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
@@ -260,13 +260,9 @@ static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
260 } 260 }
261} 261}
262 262
263int ide_floppy_ioctl(struct inode *inode, struct file *file, 263int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev,
264 unsigned int cmd, unsigned long arg) 264 fmode_t mode, unsigned int cmd, unsigned long arg)
265{ 265{
266 struct block_device *bdev = inode->i_bdev;
267 struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
268 ide_floppy_obj);
269 ide_drive_t *drive = floppy->drive;
270 struct ide_atapi_pc pc; 266 struct ide_atapi_pc pc;
271 void __user *argp = (void __user *)arg; 267 void __user *argp = (void __user *)arg;
272 int err; 268 int err;
@@ -274,7 +270,7 @@ int ide_floppy_ioctl(struct inode *inode, struct file *file,
274 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) 270 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR)
275 return ide_floppy_lockdoor(drive, &pc, arg, cmd); 271 return ide_floppy_lockdoor(drive, &pc, arg, cmd);
276 272
277 err = ide_floppy_format_ioctl(drive, file, cmd, argp); 273 err = ide_floppy_format_ioctl(drive, mode, cmd, argp);
278 if (err != -ENOTTY) 274 if (err != -ENOTTY)
279 return err; 275 return err;
280 276
@@ -283,11 +279,11 @@ int ide_floppy_ioctl(struct inode *inode, struct file *file,
283 * and CDROM_SEND_PACKET (legacy) ioctls 279 * and CDROM_SEND_PACKET (legacy) ioctls
284 */ 280 */
285 if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) 281 if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND)
286 err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, 282 err = scsi_cmd_ioctl(bdev->bd_disk->queue, bdev->bd_disk,
287 bdev->bd_disk, cmd, argp); 283 mode, cmd, argp);
288 284
289 if (err == -ENOTTY) 285 if (err == -ENOTTY)
290 err = generic_ide_ioctl(drive, file, bdev, cmd, arg); 286 err = generic_ide_ioctl(drive, bdev, cmd, arg);
291 287
292 return err; 288 return err;
293} 289}
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c
index 76f0c6c4eca3..3ec762cb60ab 100644
--- a/drivers/ide/ide-floppy_proc.c
+++ b/drivers/ide/ide-floppy_proc.c
@@ -9,7 +9,7 @@ static int proc_idefloppy_read_capacity(char *page, char **start, off_t off,
9 ide_drive_t*drive = (ide_drive_t *)data; 9 ide_drive_t*drive = (ide_drive_t *)data;
10 int len; 10 int len;
11 11
12 len = sprintf(page, "%llu\n", (long long)ide_floppy_capacity(drive)); 12 len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive));
13 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 13 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
14} 14}
15 15
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
new file mode 100644
index 000000000000..b8078b3231f7
--- /dev/null
+++ b/drivers/ide/ide-gd.c
@@ -0,0 +1,401 @@
1#include <linux/module.h>
2#include <linux/types.h>
3#include <linux/string.h>
4#include <linux/kernel.h>
5#include <linux/errno.h>
6#include <linux/genhd.h>
7#include <linux/mutex.h>
8#include <linux/ide.h>
9#include <linux/hdreg.h>
10
11#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
12#define IDE_DISK_MINORS (1 << PARTN_BITS)
13#else
14#define IDE_DISK_MINORS 0
15#endif
16
17#include "ide-disk.h"
18#include "ide-floppy.h"
19
20#define IDE_GD_VERSION "1.18"
21
22/* module parameters */
23static unsigned long debug_mask;
24module_param(debug_mask, ulong, 0644);
25
26static DEFINE_MUTEX(ide_disk_ref_mutex);
27
28static void ide_disk_release(struct kref *);
29
30static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
31{
32 struct ide_disk_obj *idkp = NULL;
33
34 mutex_lock(&ide_disk_ref_mutex);
35 idkp = ide_drv_g(disk, ide_disk_obj);
36 if (idkp) {
37 if (ide_device_get(idkp->drive))
38 idkp = NULL;
39 else
40 kref_get(&idkp->kref);
41 }
42 mutex_unlock(&ide_disk_ref_mutex);
43 return idkp;
44}
45
46static void ide_disk_put(struct ide_disk_obj *idkp)
47{
48 ide_drive_t *drive = idkp->drive;
49
50 mutex_lock(&ide_disk_ref_mutex);
51 kref_put(&idkp->kref, ide_disk_release);
52 ide_device_put(drive);
53 mutex_unlock(&ide_disk_ref_mutex);
54}
55
56sector_t ide_gd_capacity(ide_drive_t *drive)
57{
58 return drive->capacity64;
59}
60
61static int ide_gd_probe(ide_drive_t *);
62
63static void ide_gd_remove(ide_drive_t *drive)
64{
65 struct ide_disk_obj *idkp = drive->driver_data;
66 struct gendisk *g = idkp->disk;
67
68 ide_proc_unregister_driver(drive, idkp->driver);
69
70 del_gendisk(g);
71
72 drive->disk_ops->flush(drive);
73
74 ide_disk_put(idkp);
75}
76
77static void ide_disk_release(struct kref *kref)
78{
79 struct ide_disk_obj *idkp = to_ide_drv(kref, ide_disk_obj);
80 ide_drive_t *drive = idkp->drive;
81 struct gendisk *g = idkp->disk;
82
83 drive->disk_ops = NULL;
84 drive->driver_data = NULL;
85 g->private_data = NULL;
86 put_disk(g);
87 kfree(idkp);
88}
89
90/*
91 * On HPA drives the capacity needs to be
92 * reinitilized on resume otherwise the disk
93 * can not be used and a hard reset is required
94 */
95static void ide_gd_resume(ide_drive_t *drive)
96{
97 if (ata_id_hpa_enabled(drive->id))
98 (void)drive->disk_ops->get_capacity(drive);
99}
100
101static void ide_gd_shutdown(ide_drive_t *drive)
102{
103#ifdef CONFIG_ALPHA
104 /* On Alpha, halt(8) doesn't actually turn the machine off,
105 it puts you into the sort of firmware monitor. Typically,
106 it's used to boot another kernel image, so it's not much
107 different from reboot(8). Therefore, we don't need to
108 spin down the disk in this case, especially since Alpha
109 firmware doesn't handle disks in standby mode properly.
110 On the other hand, it's reasonably safe to turn the power
111 off when the shutdown process reaches the firmware prompt,
112 as the firmware initialization takes rather long time -
113 at least 10 seconds, which should be sufficient for
114 the disk to expire its write cache. */
115 if (system_state != SYSTEM_POWER_OFF) {
116#else
117 if (system_state == SYSTEM_RESTART) {
118#endif
119 drive->disk_ops->flush(drive);
120 return;
121 }
122
123 printk(KERN_INFO "Shutdown: %s\n", drive->name);
124
125 drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
126}
127
128#ifdef CONFIG_IDE_PROC_FS
129static ide_proc_entry_t *ide_disk_proc_entries(ide_drive_t *drive)
130{
131 return (drive->media == ide_disk) ? ide_disk_proc : ide_floppy_proc;
132}
133
134static const struct ide_proc_devset *ide_disk_proc_devsets(ide_drive_t *drive)
135{
136 return (drive->media == ide_disk) ? ide_disk_settings
137 : ide_floppy_settings;
138}
139#endif
140
141static ide_startstop_t ide_gd_do_request(ide_drive_t *drive,
142 struct request *rq, sector_t sector)
143{
144 return drive->disk_ops->do_request(drive, rq, sector);
145}
146
147static int ide_gd_end_request(ide_drive_t *drive, int uptodate, int nrsecs)
148{
149 return drive->disk_ops->end_request(drive, uptodate, nrsecs);
150}
151
152static ide_driver_t ide_gd_driver = {
153 .gen_driver = {
154 .owner = THIS_MODULE,
155 .name = "ide-gd",
156 .bus = &ide_bus_type,
157 },
158 .probe = ide_gd_probe,
159 .remove = ide_gd_remove,
160 .resume = ide_gd_resume,
161 .shutdown = ide_gd_shutdown,
162 .version = IDE_GD_VERSION,
163 .do_request = ide_gd_do_request,
164 .end_request = ide_gd_end_request,
165 .error = __ide_error,
166#ifdef CONFIG_IDE_PROC_FS
167 .proc_entries = ide_disk_proc_entries,
168 .proc_devsets = ide_disk_proc_devsets,
169#endif
170};
171
172static int ide_gd_open(struct block_device *bdev, fmode_t mode)
173{
174 struct gendisk *disk = bdev->bd_disk;
175 struct ide_disk_obj *idkp;
176 ide_drive_t *drive;
177 int ret = 0;
178
179 idkp = ide_disk_get(disk);
180 if (idkp == NULL)
181 return -ENXIO;
182
183 drive = idkp->drive;
184
185 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
186
187 idkp->openers++;
188
189 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
190 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
191 /* Just in case */
192
193 ret = drive->disk_ops->init_media(drive, disk);
194
195 /*
196 * Allow O_NDELAY to open a drive without a disk, or with an
197 * unreadable disk, so that we can get the format capacity
198 * of the drive or begin the format - Sam
199 */
200 if (ret && (mode & FMODE_NDELAY) == 0) {
201 ret = -EIO;
202 goto out_put_idkp;
203 }
204
205 if ((drive->dev_flags & IDE_DFLAG_WP) && (mode & FMODE_WRITE)) {
206 ret = -EROFS;
207 goto out_put_idkp;
208 }
209
210 /*
211 * Ignore the return code from door_lock,
212 * since the open() has already succeeded,
213 * and the door_lock is irrelevant at this point.
214 */
215 drive->disk_ops->set_doorlock(drive, disk, 1);
216 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
217 check_disk_change(bdev);
218 } else if (drive->dev_flags & IDE_DFLAG_FORMAT_IN_PROGRESS) {
219 ret = -EBUSY;
220 goto out_put_idkp;
221 }
222 return 0;
223
224out_put_idkp:
225 idkp->openers--;
226 ide_disk_put(idkp);
227 return ret;
228}
229
230static int ide_gd_release(struct gendisk *disk, fmode_t mode)
231{
232 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
233 ide_drive_t *drive = idkp->drive;
234
235 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
236
237 if (idkp->openers == 1)
238 drive->disk_ops->flush(drive);
239
240 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
241 drive->disk_ops->set_doorlock(drive, disk, 0);
242 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
243 }
244
245 idkp->openers--;
246
247 ide_disk_put(idkp);
248
249 return 0;
250}
251
252static int ide_gd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
253{
254 struct ide_disk_obj *idkp = ide_drv_g(bdev->bd_disk, ide_disk_obj);
255 ide_drive_t *drive = idkp->drive;
256
257 geo->heads = drive->bios_head;
258 geo->sectors = drive->bios_sect;
259 geo->cylinders = (u16)drive->bios_cyl; /* truncate */
260 return 0;
261}
262
263static int ide_gd_media_changed(struct gendisk *disk)
264{
265 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
266 ide_drive_t *drive = idkp->drive;
267 int ret;
268
269 /* do not scan partitions twice if this is a removable device */
270 if (drive->dev_flags & IDE_DFLAG_ATTACH) {
271 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
272 return 0;
273 }
274
275 ret = !!(drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED);
276 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
277
278 return ret;
279}
280
281static int ide_gd_revalidate_disk(struct gendisk *disk)
282{
283 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
284 ide_drive_t *drive = idkp->drive;
285
286 if (ide_gd_media_changed(disk))
287 drive->disk_ops->get_capacity(drive);
288
289 set_capacity(disk, ide_gd_capacity(drive));
290 return 0;
291}
292
293static int ide_gd_ioctl(struct block_device *bdev, fmode_t mode,
294 unsigned int cmd, unsigned long arg)
295{
296 struct ide_disk_obj *idkp = ide_drv_g(bdev->bd_disk, ide_disk_obj);
297 ide_drive_t *drive = idkp->drive;
298
299 return drive->disk_ops->ioctl(drive, bdev, mode, cmd, arg);
300}
301
302static struct block_device_operations ide_gd_ops = {
303 .owner = THIS_MODULE,
304 .open = ide_gd_open,
305 .release = ide_gd_release,
306 .locked_ioctl = ide_gd_ioctl,
307 .getgeo = ide_gd_getgeo,
308 .media_changed = ide_gd_media_changed,
309 .revalidate_disk = ide_gd_revalidate_disk
310};
311
312static int ide_gd_probe(ide_drive_t *drive)
313{
314 const struct ide_disk_ops *disk_ops = NULL;
315 struct ide_disk_obj *idkp;
316 struct gendisk *g;
317
318 /* strstr("foo", "") is non-NULL */
319 if (!strstr("ide-gd", drive->driver_req))
320 goto failed;
321
322#ifdef CONFIG_IDE_GD_ATA
323 if (drive->media == ide_disk)
324 disk_ops = &ide_ata_disk_ops;
325#endif
326#ifdef CONFIG_IDE_GD_ATAPI
327 if (drive->media == ide_floppy)
328 disk_ops = &ide_atapi_disk_ops;
329#endif
330 if (disk_ops == NULL)
331 goto failed;
332
333 if (disk_ops->check(drive, DRV_NAME) == 0) {
334 printk(KERN_ERR PFX "%s: not supported by this driver\n",
335 drive->name);
336 goto failed;
337 }
338
339 idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
340 if (!idkp) {
341 printk(KERN_ERR PFX "%s: can't allocate a disk structure\n",
342 drive->name);
343 goto failed;
344 }
345
346 g = alloc_disk_node(IDE_DISK_MINORS, hwif_to_node(drive->hwif));
347 if (!g)
348 goto out_free_idkp;
349
350 ide_init_disk(g, drive);
351
352 kref_init(&idkp->kref);
353
354 idkp->drive = drive;
355 idkp->driver = &ide_gd_driver;
356 idkp->disk = g;
357
358 g->private_data = &idkp->driver;
359
360 drive->driver_data = idkp;
361 drive->debug_mask = debug_mask;
362 drive->disk_ops = disk_ops;
363
364 disk_ops->setup(drive);
365
366 set_capacity(g, ide_gd_capacity(drive));
367
368 g->minors = IDE_DISK_MINORS;
369 g->driverfs_dev = &drive->gendev;
370 g->flags |= GENHD_FL_EXT_DEVT;
371 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
372 g->flags = GENHD_FL_REMOVABLE;
373 g->fops = &ide_gd_ops;
374 add_disk(g);
375 return 0;
376
377out_free_idkp:
378 kfree(idkp);
379failed:
380 return -ENODEV;
381}
382
383static int __init ide_gd_init(void)
384{
385 printk(KERN_INFO DRV_NAME " driver " IDE_GD_VERSION "\n");
386 return driver_register(&ide_gd_driver.gen_driver);
387}
388
389static void __exit ide_gd_exit(void)
390{
391 driver_unregister(&ide_gd_driver.gen_driver);
392}
393
394MODULE_ALIAS("ide:*m-disk*");
395MODULE_ALIAS("ide-disk");
396MODULE_ALIAS("ide:*m-floppy*");
397MODULE_ALIAS("ide-floppy");
398module_init(ide_gd_init);
399module_exit(ide_gd_exit);
400MODULE_LICENSE("GPL");
401MODULE_DESCRIPTION("generic ATA/ATAPI disk driver");
diff --git a/drivers/ide/ide-gd.h b/drivers/ide/ide-gd.h
new file mode 100644
index 000000000000..7d3d101713e0
--- /dev/null
+++ b/drivers/ide/ide-gd.h
@@ -0,0 +1,44 @@
1#ifndef __IDE_GD_H
2#define __IDE_GD_H
3
4#define DRV_NAME "ide-gd"
5#define PFX DRV_NAME ": "
6
7/* define to see debug info */
8#define IDE_GD_DEBUG_LOG 0
9
10#if IDE_GD_DEBUG_LOG
11#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args)
12#else
13#define ide_debug_log(lvl, fmt, args...) do {} while (0)
14#endif
15
16struct ide_disk_obj {
17 ide_drive_t *drive;
18 ide_driver_t *driver;
19 struct gendisk *disk;
20 struct kref kref;
21 unsigned int openers; /* protected by BKL for now */
22
23 /* Last failed packet command */
24 struct ide_atapi_pc *failed_pc;
25 /* used for blk_{fs,pc}_request() requests */
26 struct ide_atapi_pc queued_pc;
27
28 /* Last error information */
29 u8 sense_key, asc, ascq;
30
31 int progress_indication;
32
33 /* Device information */
34 /* Current format */
35 int blocks, block_size, bs_factor;
36 /* Last format capacity descriptor */
37 u8 cap_desc[8];
38 /* Copy of the flexible disk page */
39 u8 flexible_disk_page[32];
40};
41
42sector_t ide_gd_capacity(ide_drive_t *);
43
44#endif /* __IDE_GD_H */
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/ide-h8300.c
index e2cdd2e9cdec..e2cdd2e9cdec 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/ide-h8300.c
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index a90945f49792..fcde16bb53a7 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -240,8 +240,7 @@ static int generic_drive_reset(ide_drive_t *drive)
240 return ret; 240 return ret;
241} 241}
242 242
243int generic_ide_ioctl(ide_drive_t *drive, struct file *file, 243int generic_ide_ioctl(ide_drive_t *drive, struct block_device *bdev,
244 struct block_device *bdev,
245 unsigned int cmd, unsigned long arg) 244 unsigned int cmd, unsigned long arg)
246{ 245{
247 int err; 246 int err;
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index b762deb2dacb..5d6ba14e211d 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 2 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org>
3 * Copyright (C) 2003 Red Hat <alan@redhat.com> 3 * Copyright (C) 2003 Red Hat
4 * 4 *
5 */ 5 */
6 6
@@ -755,7 +755,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
755 755
756 udelay(1); 756 udelay(1);
757 SELECT_DRIVE(drive); 757 SELECT_DRIVE(drive);
758 SELECT_MASK(drive, 0); 758 SELECT_MASK(drive, 1);
759 udelay(1); 759 udelay(1);
760 tp_ops->set_irq(hwif, 0); 760 tp_ops->set_irq(hwif, 0);
761 761
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/ide-pci-generic.c
index 474f96a7c076..bddae2b329a0 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/ide-pci-generic.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 2 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
3 * Portions (C) Copyright 2002 Red Hat Inc <alan@redhat.com> 3 * Portions (C) Copyright 2002 Red Hat Inc
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the 6 * under the terms of the GNU General Public License as published by the
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 19f8c7770a25..1649ea54f76c 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -208,6 +208,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
208 drive->ready_stat = 0; 208 drive->ready_stat = 0;
209 if (ata_id_cdb_intr(id)) 209 if (ata_id_cdb_intr(id))
210 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; 210 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT;
211 drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
211 /* we don't do head unloading on ATAPI devices */ 212 /* we don't do head unloading on ATAPI devices */
212 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 213 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
213 return; 214 return;
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index b26926487cc0..f3cddd1b2f8f 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 1997-1998 Mark Lord 2 * Copyright (C) 1997-1998 Mark Lord
3 * Copyright (C) 2003 Red Hat <alan@redhat.com> 3 * Copyright (C) 2003 Red Hat
4 * 4 *
5 * Some code was moved here from ide.c, see it for original copyrights. 5 * Some code was moved here from ide.c, see it for original copyrights.
6 */ 6 */
@@ -567,10 +567,10 @@ static void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t
567void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) 567void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver)
568{ 568{
569 mutex_lock(&ide_setting_mtx); 569 mutex_lock(&ide_setting_mtx);
570 drive->settings = driver->settings; 570 drive->settings = driver->proc_devsets(drive);
571 mutex_unlock(&ide_setting_mtx); 571 mutex_unlock(&ide_setting_mtx);
572 572
573 ide_add_proc_entries(drive->proc, driver->proc, drive); 573 ide_add_proc_entries(drive->proc, driver->proc_entries(drive), drive);
574} 574}
575 575
576EXPORT_SYMBOL(ide_proc_register_driver); 576EXPORT_SYMBOL(ide_proc_register_driver);
@@ -591,7 +591,7 @@ void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver)
591{ 591{
592 unsigned long flags; 592 unsigned long flags;
593 593
594 ide_remove_proc_entries(drive->proc, driver->proc); 594 ide_remove_proc_entries(drive->proc, driver->proc_entries(drive));
595 595
596 mutex_lock(&ide_setting_mtx); 596 mutex_lock(&ide_setting_mtx);
597 spin_lock_irqsave(&ide_lock, flags); 597 spin_lock_irqsave(&ide_lock, flags);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index d879c7797cde..a2d470eb2b55 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2108,7 +2108,7 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive)
2108 2108
2109 /* device lacks locking support according to capabilities page */ 2109 /* device lacks locking support according to capabilities page */
2110 if ((caps[6] & 1) == 0) 2110 if ((caps[6] & 1) == 0)
2111 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 2111 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
2112 2112
2113 if (caps[7] & 0x02) 2113 if (caps[7] & 0x02)
2114 tape->blk_size = 512; 2114 tape->blk_size = 512;
@@ -2298,6 +2298,16 @@ static ide_proc_entry_t idetape_proc[] = {
2298 { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, 2298 { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL },
2299 { NULL, 0, NULL, NULL } 2299 { NULL, 0, NULL, NULL }
2300}; 2300};
2301
2302static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive)
2303{
2304 return idetape_proc;
2305}
2306
2307static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive)
2308{
2309 return idetape_settings;
2310}
2301#endif 2311#endif
2302 2312
2303static int ide_tape_probe(ide_drive_t *); 2313static int ide_tape_probe(ide_drive_t *);
@@ -2315,8 +2325,8 @@ static ide_driver_t idetape_driver = {
2315 .end_request = idetape_end_request, 2325 .end_request = idetape_end_request,
2316 .error = __ide_error, 2326 .error = __ide_error,
2317#ifdef CONFIG_IDE_PROC_FS 2327#ifdef CONFIG_IDE_PROC_FS
2318 .proc = idetape_proc, 2328 .proc_entries = ide_tape_proc_entries,
2319 .settings = idetape_settings, 2329 .proc_devsets = ide_tape_proc_devsets,
2320#endif 2330#endif
2321}; 2331};
2322 2332
@@ -2330,35 +2340,30 @@ static const struct file_operations idetape_fops = {
2330 .release = idetape_chrdev_release, 2340 .release = idetape_chrdev_release,
2331}; 2341};
2332 2342
2333static int idetape_open(struct inode *inode, struct file *filp) 2343static int idetape_open(struct block_device *bdev, fmode_t mode)
2334{ 2344{
2335 struct gendisk *disk = inode->i_bdev->bd_disk; 2345 struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk);
2336 struct ide_tape_obj *tape;
2337 2346
2338 tape = ide_tape_get(disk);
2339 if (!tape) 2347 if (!tape)
2340 return -ENXIO; 2348 return -ENXIO;
2341 2349
2342 return 0; 2350 return 0;
2343} 2351}
2344 2352
2345static int idetape_release(struct inode *inode, struct file *filp) 2353static int idetape_release(struct gendisk *disk, fmode_t mode)
2346{ 2354{
2347 struct gendisk *disk = inode->i_bdev->bd_disk;
2348 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 2355 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj);
2349 2356
2350 ide_tape_put(tape); 2357 ide_tape_put(tape);
2351
2352 return 0; 2358 return 0;
2353} 2359}
2354 2360
2355static int idetape_ioctl(struct inode *inode, struct file *file, 2361static int idetape_ioctl(struct block_device *bdev, fmode_t mode,
2356 unsigned int cmd, unsigned long arg) 2362 unsigned int cmd, unsigned long arg)
2357{ 2363{
2358 struct block_device *bdev = inode->i_bdev;
2359 struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj); 2364 struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj);
2360 ide_drive_t *drive = tape->drive; 2365 ide_drive_t *drive = tape->drive;
2361 int err = generic_ide_ioctl(drive, file, bdev, cmd, arg); 2366 int err = generic_ide_ioctl(drive, bdev, cmd, arg);
2362 if (err == -EINVAL) 2367 if (err == -EINVAL)
2363 err = idetape_blkdev_ioctl(drive, cmd, arg); 2368 err = idetape_blkdev_ioctl(drive, cmd, arg);
2364 return err; 2369 return err;
@@ -2368,7 +2373,7 @@ static struct block_device_operations idetape_block_ops = {
2368 .owner = THIS_MODULE, 2373 .owner = THIS_MODULE,
2369 .open = idetape_open, 2374 .open = idetape_open,
2370 .release = idetape_release, 2375 .release = idetape_release,
2371 .ioctl = idetape_ioctl, 2376 .locked_ioctl = idetape_ioctl,
2372}; 2377};
2373 2378
2374static int ide_tape_probe(ide_drive_t *drive) 2379static int ide_tape_probe(ide_drive_t *drive)
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/ide_arm.c
index f728f2927b5a..f728f2927b5a 100644
--- a/drivers/ide/arm/ide_arm.c
+++ b/drivers/ide/ide_arm.c
diff --git a/drivers/ide/legacy/ide_platform.c b/drivers/ide/ide_platform.c
index 051b4ab0f359..051b4ab0f359 100644
--- a/drivers/ide/legacy/ide_platform.c
+++ b/drivers/ide/ide_platform.c
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/it8213.c
index 7c2feeb3c5ec..7c2feeb3c5ec 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/it8213.c
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/it821x.c
index 995e18bb3139..ef004089761b 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/it821x.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2004 Red Hat <alan@redhat.com> 2 * Copyright (C) 2004 Red Hat
3 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 3 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
4 * 4 *
5 * May be copied or modified under the terms of the GNU General Public License 5 * May be copied or modified under the terms of the GNU General Public License
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/jmicron.c
index 9a68433cf46d..bf2be6431b20 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/jmicron.c
@@ -1,6 +1,6 @@
1 1
2/* 2/*
3 * Copyright (C) 2006 Red Hat <alan@redhat.com> 3 * Copyright (C) 2006 Red Hat
4 * 4 *
5 * May be copied or modified under the terms of the GNU General Public License 5 * May be copied or modified under the terms of the GNU General Public License
6 */ 6 */
diff --git a/drivers/ide/legacy/Makefile b/drivers/ide/legacy/Makefile
deleted file mode 100644
index 6939329f89e8..000000000000
--- a/drivers/ide/legacy/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
1
2# link order is important here
3
4obj-$(CONFIG_BLK_DEV_ALI14XX) += ali14xx.o
5obj-$(CONFIG_BLK_DEV_UMC8672) += umc8672.o
6obj-$(CONFIG_BLK_DEV_DTC2278) += dtc2278.o
7obj-$(CONFIG_BLK_DEV_HT6560B) += ht6560b.o
8obj-$(CONFIG_BLK_DEV_QD65XX) += qd65xx.o
9obj-$(CONFIG_BLK_DEV_4DRIVES) += ide-4drives.o
10
11obj-$(CONFIG_BLK_DEV_GAYLE) += gayle.o
12obj-$(CONFIG_BLK_DEV_FALCON_IDE) += falconide.o
13obj-$(CONFIG_BLK_DEV_MAC_IDE) += macide.o
14obj-$(CONFIG_BLK_DEV_Q40IDE) += q40ide.o
15obj-$(CONFIG_BLK_DEV_BUDDHA) += buddha.o
16
17ifeq ($(CONFIG_BLK_DEV_IDECS), m)
18 obj-m += ide-cs.o
19endif
20
21ifeq ($(CONFIG_BLK_DEV_PLATFORM), m)
22 obj-m += ide_platform.o
23endif
24
25EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/macide.c
index 43f97cc1d30e..43f97cc1d30e 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/macide.c
diff --git a/drivers/ide/mips/Makefile b/drivers/ide/mips/Makefile
deleted file mode 100644
index 5873fa0b8769..000000000000
--- a/drivers/ide/mips/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
1obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o
2
3EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/ns87415.c
index 13789060f407..13789060f407 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/ns87415.c
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/opti621.c
index 6048eda3cd61..6048eda3cd61 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/opti621.c
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/palm_bk3710.c
index 122ed3c072fd..122ed3c072fd 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/palm_bk3710.c
diff --git a/drivers/ide/pci/Makefile b/drivers/ide/pci/Makefile
deleted file mode 100644
index 02e6ee7d751d..000000000000
--- a/drivers/ide/pci/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
1
2obj-$(CONFIG_BLK_DEV_AEC62XX) += aec62xx.o
3obj-$(CONFIG_BLK_DEV_ALI15X3) += alim15x3.o
4obj-$(CONFIG_BLK_DEV_AMD74XX) += amd74xx.o
5obj-$(CONFIG_BLK_DEV_ATIIXP) += atiixp.o
6obj-$(CONFIG_BLK_DEV_CELLEB) += scc_pata.o
7obj-$(CONFIG_BLK_DEV_CMD64X) += cmd64x.o
8obj-$(CONFIG_BLK_DEV_CS5520) += cs5520.o
9obj-$(CONFIG_BLK_DEV_CS5530) += cs5530.o
10obj-$(CONFIG_BLK_DEV_CS5535) += cs5535.o
11obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o
12obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o
13obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o
14obj-$(CONFIG_BLK_DEV_HPT34X) += hpt34x.o
15obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o
16obj-$(CONFIG_BLK_DEV_IT8213) += it8213.o
17obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o
18obj-$(CONFIG_BLK_DEV_JMICRON) += jmicron.o
19obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o
20obj-$(CONFIG_BLK_DEV_OPTI621) += opti621.o
21obj-$(CONFIG_BLK_DEV_PDC202XX_OLD) += pdc202xx_old.o
22obj-$(CONFIG_BLK_DEV_PDC202XX_NEW) += pdc202xx_new.o
23obj-$(CONFIG_BLK_DEV_PIIX) += piix.o
24obj-$(CONFIG_BLK_DEV_RZ1000) += rz1000.o
25obj-$(CONFIG_BLK_DEV_SVWKS) += serverworks.o
26obj-$(CONFIG_BLK_DEV_SGIIOC4) += sgiioc4.o
27obj-$(CONFIG_BLK_DEV_SIIMAGE) += siimage.o
28obj-$(CONFIG_BLK_DEV_SIS5513) += sis5513.o
29obj-$(CONFIG_BLK_DEV_SL82C105) += sl82c105.o
30obj-$(CONFIG_BLK_DEV_SLC90E66) += slc90e66.o
31obj-$(CONFIG_BLK_DEV_TC86C001) += tc86c001.o
32obj-$(CONFIG_BLK_DEV_TRIFLEX) += triflex.o
33obj-$(CONFIG_BLK_DEV_TRM290) += trm290.o
34obj-$(CONFIG_BLK_DEV_VIA82CXXX) += via82cxxx.o
35
36# Must appear at the end of the block
37obj-$(CONFIG_BLK_DEV_GENERIC) += ide-pci-generic.o
38ide-pci-generic-y += generic.o
39
40ifeq ($(CONFIG_BLK_DEV_CMD640), m)
41 obj-m += cmd640.o
42endif
43
44EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
deleted file mode 100644
index fb1a3aa57f07..000000000000
--- a/drivers/ide/pci/hpt34x.c
+++ /dev/null
@@ -1,193 +0,0 @@
1/*
2 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
3 *
4 * May be copied or modified under the terms of the GNU General Public License
5 *
6 *
7 * 00:12.0 Unknown mass storage controller:
8 * Triones Technologies, Inc.
9 * Unknown device 0003 (rev 01)
10 *
11 * hde: UDMA 2 (0x0000 0x0002) (0x0000 0x0010)
12 * hdf: UDMA 2 (0x0002 0x0012) (0x0010 0x0030)
13 * hde: DMA 2 (0x0000 0x0002) (0x0000 0x0010)
14 * hdf: DMA 2 (0x0002 0x0012) (0x0010 0x0030)
15 * hdg: DMA 1 (0x0012 0x0052) (0x0030 0x0070)
16 * hdh: DMA 1 (0x0052 0x0252) (0x0070 0x00f0)
17 *
18 * ide-pci.c reference
19 *
20 * Since there are two cards that report almost identically,
21 * the only discernable difference is the values reported in pcicmd.
22 * Booting-BIOS card or HPT363 :: pcicmd == 0x07
23 * Non-bootable card or HPT343 :: pcicmd == 0x05
24 */
25
26#include <linux/module.h>
27#include <linux/types.h>
28#include <linux/kernel.h>
29#include <linux/ioport.h>
30#include <linux/interrupt.h>
31#include <linux/pci.h>
32#include <linux/init.h>
33#include <linux/ide.h>
34
35#define DRV_NAME "hpt34x"
36
37#define HPT343_DEBUG_DRIVE_INFO 0
38
39static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed)
40{
41 struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
42 u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0;
43 u8 hi_speed, lo_speed;
44
45 hi_speed = speed >> 4;
46 lo_speed = speed & 0x0f;
47
48 if (hi_speed & 7) {
49 hi_speed = (hi_speed & 4) ? 0x01 : 0x10;
50 } else {
51 lo_speed <<= 5;
52 lo_speed >>= 5;
53 }
54
55 pci_read_config_dword(dev, 0x44, &reg1);
56 pci_read_config_dword(dev, 0x48, &reg2);
57 tmp1 = ((lo_speed << (3*drive->dn)) | (reg1 & ~(7 << (3*drive->dn))));
58 tmp2 = ((hi_speed << drive->dn) | (reg2 & ~(0x11 << drive->dn)));
59 pci_write_config_dword(dev, 0x44, tmp1);
60 pci_write_config_dword(dev, 0x48, tmp2);
61
62#if HPT343_DEBUG_DRIVE_INFO
63 printk("%s: %s drive%d (0x%04x 0x%04x) (0x%04x 0x%04x)" \
64 " (0x%02x 0x%02x)\n",
65 drive->name, ide_xfer_verbose(speed),
66 drive->dn, reg1, tmp1, reg2, tmp2,
67 hi_speed, lo_speed);
68#endif /* HPT343_DEBUG_DRIVE_INFO */
69}
70
71static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio)
72{
73 hpt34x_set_mode(drive, XFER_PIO_0 + pio);
74}
75
76/*
77 * If the BIOS does not set the IO base addaress to XX00, 343 will fail.
78 */
79#define HPT34X_PCI_INIT_REG 0x80
80
81static unsigned int init_chipset_hpt34x(struct pci_dev *dev)
82{
83 int i = 0;
84 unsigned long hpt34xIoBase = pci_resource_start(dev, 4);
85 unsigned long hpt_addr[4] = { 0x20, 0x34, 0x28, 0x3c };
86 unsigned long hpt_addr_len[4] = { 7, 3, 7, 3 };
87 u16 cmd;
88 unsigned long flags;
89
90 local_irq_save(flags);
91
92 pci_write_config_byte(dev, HPT34X_PCI_INIT_REG, 0x00);
93 pci_read_config_word(dev, PCI_COMMAND, &cmd);
94
95 if (cmd & PCI_COMMAND_MEMORY)
96 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0);
97 else
98 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
99
100 /*
101 * Since 20-23 can be assigned and are R/W, we correct them.
102 */
103 pci_write_config_word(dev, PCI_COMMAND, cmd & ~PCI_COMMAND_IO);
104 for(i=0; i<4; i++) {
105 dev->resource[i].start = (hpt34xIoBase + hpt_addr[i]);
106 dev->resource[i].end = dev->resource[i].start + hpt_addr_len[i];
107 dev->resource[i].flags = IORESOURCE_IO;
108 pci_write_config_dword(dev,
109 (PCI_BASE_ADDRESS_0 + (i * 4)),
110 dev->resource[i].start);
111 }
112 pci_write_config_word(dev, PCI_COMMAND, cmd);
113
114 local_irq_restore(flags);
115
116 return dev->irq;
117}
118
119static const struct ide_port_ops hpt34x_port_ops = {
120 .set_pio_mode = hpt34x_set_pio_mode,
121 .set_dma_mode = hpt34x_set_mode,
122};
123
124#define IDE_HFLAGS_HPT34X \
125 (IDE_HFLAG_NO_ATAPI_DMA | \
126 IDE_HFLAG_NO_DSC | \
127 IDE_HFLAG_NO_AUTODMA)
128
129static const struct ide_port_info hpt34x_chipsets[] __devinitdata = {
130 { /* 0: HPT343 */
131 .name = DRV_NAME,
132 .init_chipset = init_chipset_hpt34x,
133 .port_ops = &hpt34x_port_ops,
134 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE,
135 .pio_mask = ATA_PIO5,
136 },
137 { /* 1: HPT345 */
138 .name = DRV_NAME,
139 .init_chipset = init_chipset_hpt34x,
140 .port_ops = &hpt34x_port_ops,
141 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD,
142 .pio_mask = ATA_PIO5,
143#ifdef CONFIG_HPT34X_AUTODMA
144 .swdma_mask = ATA_SWDMA2,
145 .mwdma_mask = ATA_MWDMA2,
146 .udma_mask = ATA_UDMA2,
147#endif
148 }
149};
150
151static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
152{
153 const struct ide_port_info *d;
154 u16 pcicmd = 0;
155
156 pci_read_config_word(dev, PCI_COMMAND, &pcicmd);
157
158 d = &hpt34x_chipsets[(pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0];
159
160 return ide_pci_init_one(dev, d, NULL);
161}
162
163static const struct pci_device_id hpt34x_pci_tbl[] = {
164 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT343), 0 },
165 { 0, },
166};
167MODULE_DEVICE_TABLE(pci, hpt34x_pci_tbl);
168
169static struct pci_driver hpt34x_pci_driver = {
170 .name = "HPT34x_IDE",
171 .id_table = hpt34x_pci_tbl,
172 .probe = hpt34x_init_one,
173 .remove = ide_pci_remove,
174 .suspend = ide_pci_suspend,
175 .resume = ide_pci_resume,
176};
177
178static int __init hpt34x_ide_init(void)
179{
180 return ide_pci_register_driver(&hpt34x_pci_driver);
181}
182
183static void __exit hpt34x_ide_exit(void)
184{
185 pci_unregister_driver(&hpt34x_pci_driver);
186}
187
188module_init(hpt34x_ide_init);
189module_exit(hpt34x_ide_exit);
190
191MODULE_AUTHOR("Andre Hedrick");
192MODULE_DESCRIPTION("PCI driver module for Highpoint 34x IDE");
193MODULE_LICENSE("GPL");
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pdc202xx_new.c
index 211ae46e3e0c..211ae46e3e0c 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pdc202xx_new.c
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pdc202xx_old.c
index 799557c25eef..799557c25eef 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pdc202xx_old.c
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/piix.c
index d63f9fdca76b..61d2d920a5cd 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/piix.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer 2 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
3 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 3 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
4 * Copyright (C) 2003 Red Hat Inc <alan@redhat.com> 4 * Copyright (C) 2003 Red Hat
5 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> 5 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com>
6 * 6 *
7 * May be copied or modified under the terms of the GNU General Public License 7 * May be copied or modified under the terms of the GNU General Public License
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/pmac.c
index 2e19d6298536..2e19d6298536 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/pmac.c
diff --git a/drivers/ide/ppc/Makefile b/drivers/ide/ppc/Makefile
deleted file mode 100644
index 74e52adcdf4b..000000000000
--- a/drivers/ide/ppc/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
1
2obj-$(CONFIG_BLK_DEV_IDE_PMAC) += pmac.o
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/q40ide.c
index 4af4a8ce4cdf..4af4a8ce4cdf 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/q40ide.c
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/qd65xx.c
index bc27c7aba936..bc27c7aba936 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/qd65xx.c
diff --git a/drivers/ide/legacy/qd65xx.h b/drivers/ide/qd65xx.h
index c83dea85e621..c83dea85e621 100644
--- a/drivers/ide/legacy/qd65xx.h
+++ b/drivers/ide/qd65xx.h
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/rapide.c
index 78d27d9ae430..d5003ca69801 100644
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/rapide.c
@@ -11,7 +11,7 @@
11 11
12#include <asm/ecard.h> 12#include <asm/ecard.h>
13 13
14static struct const ide_port_info rapide_port_info = { 14static const struct ide_port_info rapide_port_info = {
15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA, 15 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
16}; 16};
17 17
@@ -97,7 +97,7 @@ static int __init rapide_init(void)
97 97
98static void __exit rapide_exit(void) 98static void __exit rapide_exit(void)
99{ 99{
100 ecard_unregister_driver(&rapide_driver); 100 ecard_remove_driver(&rapide_driver);
101} 101}
102 102
103MODULE_LICENSE("GPL"); 103MODULE_LICENSE("GPL");
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/rz1000.c
index 7daf0135cbac..7daf0135cbac 100644
--- a/drivers/ide/pci/rz1000.c
+++ b/drivers/ide/rz1000.c
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/sc1200.c
index f1a8758e3a99..f1a8758e3a99 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/sc1200.c
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/scc_pata.c
index 9ce1d8059921..0f48f9dacfa5 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * This code is based on drivers/ide/pci/siimage.c: 6 * This code is based on drivers/ide/pci/siimage.c:
7 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 7 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
8 * Copyright (C) 2003 Red Hat <alan@redhat.com> 8 * Copyright (C) 2003 Red Hat
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -536,10 +536,6 @@ static u8 scc_udma_filter(ide_drive_t *drive)
536 536
537static int setup_mmio_scc (struct pci_dev *dev, const char *name) 537static int setup_mmio_scc (struct pci_dev *dev, const char *name)
538{ 538{
539 unsigned long ctl_base = pci_resource_start(dev, 0);
540 unsigned long dma_base = pci_resource_start(dev, 1);
541 unsigned long ctl_size = pci_resource_len(dev, 0);
542 unsigned long dma_size = pci_resource_len(dev, 1);
543 void __iomem *ctl_addr; 539 void __iomem *ctl_addr;
544 void __iomem *dma_addr; 540 void __iomem *dma_addr;
545 int i, ret; 541 int i, ret;
@@ -557,10 +553,12 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name)
557 return ret; 553 return ret;
558 } 554 }
559 555
560 if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL) 556 ctl_addr = pci_ioremap_bar(dev, 0);
557 if (!ctl_addr)
561 goto fail_0; 558 goto fail_0;
562 559
563 if ((dma_addr = ioremap(dma_base, dma_size)) == NULL) 560 dma_addr = pci_ioremap_bar(dev, 1);
561 if (!dma_addr)
564 goto fail_1; 562 goto fail_1;
565 563
566 pci_set_master(dev); 564 pci_set_master(dev);
@@ -617,7 +615,6 @@ static int __devinit init_setup_scc(struct pci_dev *dev,
617 unsigned long intmask_port; 615 unsigned long intmask_port;
618 unsigned long mode_port; 616 unsigned long mode_port;
619 unsigned long ecmode_port; 617 unsigned long ecmode_port;
620 unsigned long dma_status_port;
621 u32 reg = 0; 618 u32 reg = 0;
622 struct scc_ports *ports; 619 struct scc_ports *ports;
623 int rc; 620 int rc;
@@ -637,7 +634,6 @@ static int __devinit init_setup_scc(struct pci_dev *dev,
637 intmask_port = dma_base + 0x010; 634 intmask_port = dma_base + 0x010;
638 mode_port = ctl_base + 0x024; 635 mode_port = ctl_base + 0x024;
639 ecmode_port = ctl_base + 0xf00; 636 ecmode_port = ctl_base + 0xf00;
640 dma_status_port = dma_base + 0x004;
641 637
642 /* controller initialization */ 638 /* controller initialization */
643 reg = 0; 639 reg = 0;
@@ -843,8 +839,6 @@ static u8 scc_cable_detect(ide_hwif_t *hwif)
843 839
844static void __devinit init_hwif_scc(ide_hwif_t *hwif) 840static void __devinit init_hwif_scc(ide_hwif_t *hwif)
845{ 841{
846 struct scc_ports *ports = ide_get_hwifdata(hwif);
847
848 /* PTERADD */ 842 /* PTERADD */
849 out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); 843 out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma);
850 844
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/serverworks.c
index 437bc919dafd..437bc919dafd 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/serverworks.c
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/sgiioc4.c
index dd634541ce36..7defa0ae2014 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/sgiioc4.c
@@ -101,18 +101,8 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
101 for (i = 0; i <= 7; i++) 101 for (i = 0; i <= 7; i++)
102 hw->io_ports_array[i] = reg + i * 4; 102 hw->io_ports_array[i] = reg + i * 4;
103 103
104 if (ctrl_port) 104 hw->io_ports.ctl_addr = ctrl_port;
105 hw->io_ports.ctl_addr = ctrl_port; 105 hw->io_ports.irq_addr = irq_port;
106
107 if (irq_port)
108 hw->io_ports.irq_addr = irq_port;
109}
110
111static void
112sgiioc4_maskproc(ide_drive_t * drive, int mask)
113{
114 writeb(ATA_DEVCTL_OBS | (mask ? 2 : 0),
115 (void __iomem *)drive->hwif->io_ports.ctl_addr);
116} 106}
117 107
118static int 108static int
@@ -310,16 +300,14 @@ static u8 sgiioc4_read_status(ide_hwif_t *hwif)
310 unsigned long port = hwif->io_ports.status_addr; 300 unsigned long port = hwif->io_ports.status_addr;
311 u8 reg = (u8) readb((void __iomem *) port); 301 u8 reg = (u8) readb((void __iomem *) port);
312 302
313 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ 303 if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */
314 if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */ 304 unsigned long other_ir = port - 0x110;
315 unsigned long other_ir = port - 0x110; 305 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
316 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
317 306
318 /* Clear the Interrupt, Error bits on the IOC4 */ 307 /* Clear the Interrupt, Error bits on the IOC4 */
319 if (intr_reg & 0x03) { 308 if (intr_reg & 0x03) {
320 writel(0x03, (void __iomem *) other_ir); 309 writel(0x03, (void __iomem *) other_ir);
321 intr_reg = (u32) readl((void __iomem *) other_ir); 310 intr_reg = (u32) readl((void __iomem *) other_ir);
322 }
323 } 311 }
324 } 312 }
325 313
@@ -332,13 +320,9 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
332{ 320{
333 struct pci_dev *dev = to_pci_dev(hwif->dev); 321 struct pci_dev *dev = to_pci_dev(hwif->dev);
334 unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; 322 unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET;
335 void __iomem *virt_dma_base;
336 int num_ports = sizeof (ioc4_dma_regs_t); 323 int num_ports = sizeof (ioc4_dma_regs_t);
337 void *pad; 324 void *pad;
338 325
339 if (dma_base == 0)
340 return -1;
341
342 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); 326 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name);
343 327
344 if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) { 328 if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) {
@@ -348,14 +332,8 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
348 return -1; 332 return -1;
349 } 333 }
350 334
351 virt_dma_base = ioremap(dma_base, num_ports); 335 hwif->dma_base = (unsigned long)hwif->io_ports.irq_addr +
352 if (virt_dma_base == NULL) { 336 IOC4_DMA_OFFSET;
353 printk(KERN_ERR "%s(%s) -- ERROR: unable to map addresses "
354 "0x%lx to 0x%lx\n", __func__, hwif->name,
355 dma_base, dma_base + num_ports - 1);
356 goto dma_remap_failure;
357 }
358 hwif->dma_base = (unsigned long) virt_dma_base;
359 337
360 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 338 hwif->sg_max_nents = IOC4_PRD_ENTRIES;
361 339
@@ -379,9 +357,6 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
379 printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name); 357 printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name);
380 358
381dma_pci_alloc_failure: 359dma_pci_alloc_failure:
382 iounmap(virt_dma_base);
383
384dma_remap_failure:
385 release_mem_region(dma_base, num_ports); 360 release_mem_region(dma_base, num_ports);
386 361
387 return -1; 362 return -1;
@@ -563,8 +538,6 @@ static const struct ide_port_ops sgiioc4_port_ops = {
563 .set_dma_mode = sgiioc4_set_dma_mode, 538 .set_dma_mode = sgiioc4_set_dma_mode,
564 /* reset DMA engine, clear IRQs */ 539 /* reset DMA engine, clear IRQs */
565 .resetproc = sgiioc4_resetproc, 540 .resetproc = sgiioc4_resetproc,
566 /* mask on/off NIEN register */
567 .maskproc = sgiioc4_maskproc,
568}; 541};
569 542
570static const struct ide_dma_ops sgiioc4_dma_ops = { 543static const struct ide_dma_ops sgiioc4_dma_ops = {
@@ -594,14 +567,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
594 unsigned long cmd_base, irqport; 567 unsigned long cmd_base, irqport;
595 unsigned long bar0, cmd_phys_base, ctl; 568 unsigned long bar0, cmd_phys_base, ctl;
596 void __iomem *virt_base; 569 void __iomem *virt_base;
597 struct ide_host *host;
598 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 570 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
599 struct ide_port_info d = sgiioc4_port_info;
600 int rc; 571 int rc;
601 572
602 /* Get the CmdBlk and CtrlBlk Base Registers */ 573 /* Get the CmdBlk and CtrlBlk Base Registers */
603 bar0 = pci_resource_start(dev, 0); 574 bar0 = pci_resource_start(dev, 0);
604 virt_base = ioremap(bar0, pci_resource_len(dev, 0)); 575 virt_base = pci_ioremap_bar(dev, 0);
605 if (virt_base == NULL) { 576 if (virt_base == NULL) {
606 printk(KERN_ERR "%s: Unable to remap BAR 0 address: 0x%lx\n", 577 printk(KERN_ERR "%s: Unable to remap BAR 0 address: 0x%lx\n",
607 DRV_NAME, bar0); 578 DRV_NAME, bar0);
@@ -617,7 +588,8 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
617 printk(KERN_ERR "%s %s -- ERROR: addresses 0x%08lx to 0x%08lx " 588 printk(KERN_ERR "%s %s -- ERROR: addresses 0x%08lx to 0x%08lx "
618 "already in use\n", DRV_NAME, pci_name(dev), 589 "already in use\n", DRV_NAME, pci_name(dev),
619 cmd_phys_base, cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); 590 cmd_phys_base, cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE);
620 return -EBUSY; 591 rc = -EBUSY;
592 goto req_mem_rgn_err;
621 } 593 }
622 594
623 /* Initialize the IO registers */ 595 /* Initialize the IO registers */
@@ -630,21 +602,12 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
630 /* Initializing chipset IRQ Registers */ 602 /* Initializing chipset IRQ Registers */
631 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 603 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
632 604
633 host = ide_host_alloc(&d, hws); 605 rc = ide_host_add(&sgiioc4_port_info, hws, NULL);
634 if (host == NULL) { 606 if (!rc)
635 rc = -ENOMEM; 607 return 0;
636 goto err;
637 }
638
639 rc = ide_host_register(host, &d, hws);
640 if (rc)
641 goto err_free;
642 608
643 return 0;
644err_free:
645 ide_host_free(host);
646err:
647 release_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE); 609 release_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE);
610req_mem_rgn_err:
648 iounmap(virt_base); 611 iounmap(virt_base);
649 return rc; 612 return rc;
650} 613}
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/siimage.c
index eb4faf92c571..7d622d20bc4c 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/siimage.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org> 2 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
3 * Copyright (C) 2003 Red Hat <alan@redhat.com> 3 * Copyright (C) 2003 Red Hat
4 * Copyright (C) 2007-2008 MontaVista Software, Inc. 4 * Copyright (C) 2007-2008 MontaVista Software, Inc.
5 * Copyright (C) 2007-2008 Bartlomiej Zolnierkiewicz 5 * Copyright (C) 2007-2008 Bartlomiej Zolnierkiewicz
6 * 6 *
@@ -784,7 +784,7 @@ static int __devinit siimage_init_one(struct pci_dev *dev,
784 printk(KERN_WARNING DRV_NAME " %s: MMIO ports not " 784 printk(KERN_WARNING DRV_NAME " %s: MMIO ports not "
785 "available\n", pci_name(dev)); 785 "available\n", pci_name(dev));
786 } else { 786 } else {
787 ioaddr = ioremap(bar5, barsize); 787 ioaddr = pci_ioremap_bar(dev, 5);
788 if (ioaddr == NULL) 788 if (ioaddr == NULL)
789 release_mem_region(bar5, barsize); 789 release_mem_region(bar5, barsize);
790 } 790 }
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/sis5513.c
index ad32e18c5ba3..ad32e18c5ba3 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/sis5513.c
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/sl82c105.c
index 84dc33602ff8..84dc33602ff8 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/sl82c105.c
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/slc90e66.c
index 0f759e4ed779..0f759e4ed779 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/slc90e66.c
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/tc86c001.c
index 93e2cce4b296..93e2cce4b296 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/tc86c001.c
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/triflex.c
index b6ff40336aa9..b6ff40336aa9 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/triflex.c
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/trm290.c
index 75ea61526566..75ea61526566 100644
--- a/drivers/ide/pci/trm290.c
+++ b/drivers/ide/trm290.c
diff --git a/drivers/ide/tx4938ide.c b/drivers/ide/tx4938ide.c
new file mode 100644
index 000000000000..9120063e8f87
--- /dev/null
+++ b/drivers/ide/tx4938ide.c
@@ -0,0 +1,323 @@
1/*
2 * TX4938 internal IDE driver
3 * Based on tx4939ide.c.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * (C) Copyright TOSHIBA CORPORATION 2005-2007
10 */
11
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/ide.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/io.h>
18#include <asm/txx9/tx4938.h>
19
20static void tx4938ide_tune_ebusc(unsigned int ebus_ch,
21 unsigned int gbus_clock,
22 u8 pio)
23{
24 struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio);
25 u64 cr = __raw_readq(&tx4938_ebuscptr->cr[ebus_ch]);
26 unsigned int sp = (cr >> 4) & 3;
27 unsigned int clock = gbus_clock / (4 - sp);
28 unsigned int cycle = 1000000000 / clock;
29 unsigned int shwt;
30 int wt;
31
32 /* Minimum DIOx- active time */
33 wt = DIV_ROUND_UP(t->act8b, cycle) - 2;
34 /* IORDY setup time: 35ns */
35 wt = max_t(int, wt, DIV_ROUND_UP(35, cycle));
36 /* actual wait-cycle is max(wt & ~1, 1) */
37 if (wt > 2 && (wt & 1))
38 wt++;
39 wt &= ~1;
40 /* Address-valid to DIOR/DIOW setup */
41 shwt = DIV_ROUND_UP(t->setup, cycle);
42
43 /* -DIOx recovery time (SHWT * 4) and cycle time requirement */
44 while ((shwt * 4 + wt + (wt ? 2 : 3)) * cycle < t->cycle)
45 shwt++;
46 if (shwt > 7) {
47 pr_warning("tx4938ide: SHWT violation (%d)\n", shwt);
48 shwt = 7;
49 }
50 pr_debug("tx4938ide: ebus %d, bus cycle %dns, WT %d, SHWT %d\n",
51 ebus_ch, cycle, wt, shwt);
52
53 __raw_writeq((cr & ~0x3f007ull) | (wt << 12) | shwt,
54 &tx4938_ebuscptr->cr[ebus_ch]);
55}
56
57static void tx4938ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
58{
59 ide_hwif_t *hwif = drive->hwif;
60 struct tx4938ide_platform_info *pdata = hwif->dev->platform_data;
61 u8 safe = pio;
62 ide_drive_t *pair;
63
64 pair = ide_get_pair_dev(drive);
65 if (pair)
66 safe = min(safe, ide_get_best_pio_mode(pair, 255, 5));
67 tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, safe);
68}
69
70#ifdef __BIG_ENDIAN
71
72/* custom iops (independent from SWAP_IO_SPACE) */
73static u8 tx4938ide_inb(unsigned long port)
74{
75 return __raw_readb((void __iomem *)port);
76}
77
78static void tx4938ide_outb(u8 value, unsigned long port)
79{
80 __raw_writeb(value, (void __iomem *)port);
81}
82
83static void tx4938ide_tf_load(ide_drive_t *drive, ide_task_t *task)
84{
85 ide_hwif_t *hwif = drive->hwif;
86 struct ide_io_ports *io_ports = &hwif->io_ports;
87 struct ide_taskfile *tf = &task->tf;
88 u8 HIHI = task->tf_flags & IDE_TFLAG_LBA48 ? 0xE0 : 0xEF;
89
90 if (task->tf_flags & IDE_TFLAG_FLAGGED)
91 HIHI = 0xFF;
92
93 if (task->tf_flags & IDE_TFLAG_OUT_DATA) {
94 u16 data = (tf->hob_data << 8) | tf->data;
95
96 /* no endian swap */
97 __raw_writew(data, (void __iomem *)io_ports->data_addr);
98 }
99
100 if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
101 tx4938ide_outb(tf->hob_feature, io_ports->feature_addr);
102 if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
103 tx4938ide_outb(tf->hob_nsect, io_ports->nsect_addr);
104 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
105 tx4938ide_outb(tf->hob_lbal, io_ports->lbal_addr);
106 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
107 tx4938ide_outb(tf->hob_lbam, io_ports->lbam_addr);
108 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
109 tx4938ide_outb(tf->hob_lbah, io_ports->lbah_addr);
110
111 if (task->tf_flags & IDE_TFLAG_OUT_FEATURE)
112 tx4938ide_outb(tf->feature, io_ports->feature_addr);
113 if (task->tf_flags & IDE_TFLAG_OUT_NSECT)
114 tx4938ide_outb(tf->nsect, io_ports->nsect_addr);
115 if (task->tf_flags & IDE_TFLAG_OUT_LBAL)
116 tx4938ide_outb(tf->lbal, io_ports->lbal_addr);
117 if (task->tf_flags & IDE_TFLAG_OUT_LBAM)
118 tx4938ide_outb(tf->lbam, io_ports->lbam_addr);
119 if (task->tf_flags & IDE_TFLAG_OUT_LBAH)
120 tx4938ide_outb(tf->lbah, io_ports->lbah_addr);
121
122 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
123 tx4938ide_outb((tf->device & HIHI) | drive->select,
124 io_ports->device_addr);
125}
126
127static void tx4938ide_tf_read(ide_drive_t *drive, ide_task_t *task)
128{
129 ide_hwif_t *hwif = drive->hwif;
130 struct ide_io_ports *io_ports = &hwif->io_ports;
131 struct ide_taskfile *tf = &task->tf;
132
133 if (task->tf_flags & IDE_TFLAG_IN_DATA) {
134 u16 data;
135
136 /* no endian swap */
137 data = __raw_readw((void __iomem *)io_ports->data_addr);
138 tf->data = data & 0xff;
139 tf->hob_data = (data >> 8) & 0xff;
140 }
141
142 /* be sure we're looking at the low order bits */
143 tx4938ide_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
144
145 if (task->tf_flags & IDE_TFLAG_IN_FEATURE)
146 tf->feature = tx4938ide_inb(io_ports->feature_addr);
147 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
148 tf->nsect = tx4938ide_inb(io_ports->nsect_addr);
149 if (task->tf_flags & IDE_TFLAG_IN_LBAL)
150 tf->lbal = tx4938ide_inb(io_ports->lbal_addr);
151 if (task->tf_flags & IDE_TFLAG_IN_LBAM)
152 tf->lbam = tx4938ide_inb(io_ports->lbam_addr);
153 if (task->tf_flags & IDE_TFLAG_IN_LBAH)
154 tf->lbah = tx4938ide_inb(io_ports->lbah_addr);
155 if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
156 tf->device = tx4938ide_inb(io_ports->device_addr);
157
158 if (task->tf_flags & IDE_TFLAG_LBA48) {
159 tx4938ide_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
160
161 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
162 tf->hob_feature =
163 tx4938ide_inb(io_ports->feature_addr);
164 if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
165 tf->hob_nsect = tx4938ide_inb(io_ports->nsect_addr);
166 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
167 tf->hob_lbal = tx4938ide_inb(io_ports->lbal_addr);
168 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
169 tf->hob_lbam = tx4938ide_inb(io_ports->lbam_addr);
170 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
171 tf->hob_lbah = tx4938ide_inb(io_ports->lbah_addr);
172 }
173}
174
175static void tx4938ide_input_data_swap(ide_drive_t *drive, struct request *rq,
176 void *buf, unsigned int len)
177{
178 unsigned long port = drive->hwif->io_ports.data_addr;
179 unsigned short *ptr = buf;
180 unsigned int count = (len + 1) / 2;
181
182 while (count--)
183 *ptr++ = cpu_to_le16(__raw_readw((void __iomem *)port));
184 __ide_flush_dcache_range((unsigned long)buf, count * 2);
185}
186
187static void tx4938ide_output_data_swap(ide_drive_t *drive, struct request *rq,
188 void *buf, unsigned int len)
189{
190 unsigned long port = drive->hwif->io_ports.data_addr;
191 unsigned short *ptr = buf;
192 unsigned int count = (len + 1) / 2;
193
194 while (count--) {
195 __raw_writew(le16_to_cpu(*ptr), (void __iomem *)port);
196 ptr++;
197 }
198 __ide_flush_dcache_range((unsigned long)buf, count * 2);
199}
200
201static const struct ide_tp_ops tx4938ide_tp_ops = {
202 .exec_command = ide_exec_command,
203 .read_status = ide_read_status,
204 .read_altstatus = ide_read_altstatus,
205 .read_sff_dma_status = ide_read_sff_dma_status,
206
207 .set_irq = ide_set_irq,
208
209 .tf_load = tx4938ide_tf_load,
210 .tf_read = tx4938ide_tf_read,
211
212 .input_data = tx4938ide_input_data_swap,
213 .output_data = tx4938ide_output_data_swap,
214};
215
216#endif /* __BIG_ENDIAN */
217
218static const struct ide_port_ops tx4938ide_port_ops = {
219 .set_pio_mode = tx4938ide_set_pio_mode,
220};
221
222static const struct ide_port_info tx4938ide_port_info __initdata = {
223 .port_ops = &tx4938ide_port_ops,
224#ifdef __BIG_ENDIAN
225 .tp_ops = &tx4938ide_tp_ops,
226#endif
227 .host_flags = IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
228 .pio_mask = ATA_PIO5,
229};
230
231static int __init tx4938ide_probe(struct platform_device *pdev)
232{
233 hw_regs_t hw;
234 hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
235 struct ide_host *host;
236 struct resource *res;
237 struct tx4938ide_platform_info *pdata = pdev->dev.platform_data;
238 int irq, ret, i;
239 unsigned long mapbase, mapctl;
240 struct ide_port_info d = tx4938ide_port_info;
241
242 irq = platform_get_irq(pdev, 0);
243 if (irq < 0)
244 return -ENODEV;
245 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
246 if (!res)
247 return -ENODEV;
248
249 if (!devm_request_mem_region(&pdev->dev, res->start,
250 res->end - res->start + 1, "tx4938ide"))
251 return -EBUSY;
252 mapbase = (unsigned long)devm_ioremap(&pdev->dev, res->start,
253 8 << pdata->ioport_shift);
254 mapctl = (unsigned long)devm_ioremap(&pdev->dev,
255 res->start + 0x10000 +
256 (6 << pdata->ioport_shift),
257 1 << pdata->ioport_shift);
258 if (!mapbase || !mapctl)
259 return -EBUSY;
260
261 memset(&hw, 0, sizeof(hw));
262 if (pdata->ioport_shift) {
263 unsigned long port = mapbase;
264 unsigned long ctl = mapctl;
265
266 hw.io_ports_array[0] = port;
267#ifdef __BIG_ENDIAN
268 port++;
269 ctl++;
270#endif
271 for (i = 1; i <= 7; i++)
272 hw.io_ports_array[i] =
273 port + (i << pdata->ioport_shift);
274 hw.io_ports.ctl_addr = ctl;
275 } else
276 ide_std_init_ports(&hw, mapbase, mapctl);
277 hw.irq = irq;
278 hw.dev = &pdev->dev;
279
280 pr_info("TX4938 IDE interface (base %#lx, ctl %#lx, irq %d)\n",
281 mapbase, mapctl, hw.irq);
282 if (pdata->gbus_clock)
283 tx4938ide_tune_ebusc(pdata->ebus_ch, pdata->gbus_clock, 0);
284 else
285 d.port_ops = NULL;
286 ret = ide_host_add(&d, hws, &host);
287 if (!ret)
288 platform_set_drvdata(pdev, host);
289 return ret;
290}
291
292static int __exit tx4938ide_remove(struct platform_device *pdev)
293{
294 struct ide_host *host = platform_get_drvdata(pdev);
295
296 ide_host_remove(host);
297 return 0;
298}
299
300static struct platform_driver tx4938ide_driver = {
301 .driver = {
302 .name = "tx4938ide",
303 .owner = THIS_MODULE,
304 },
305 .remove = __exit_p(tx4938ide_remove),
306};
307
308static int __init tx4938ide_init(void)
309{
310 return platform_driver_probe(&tx4938ide_driver, tx4938ide_probe);
311}
312
313static void __exit tx4938ide_exit(void)
314{
315 platform_driver_unregister(&tx4938ide_driver);
316}
317
318module_init(tx4938ide_init);
319module_exit(tx4938ide_exit);
320
321MODULE_DESCRIPTION("TX4938 internal IDE driver");
322MODULE_LICENSE("GPL");
323MODULE_ALIAS("platform:tx4938ide");
diff --git a/drivers/ide/tx4939ide.c b/drivers/ide/tx4939ide.c
new file mode 100644
index 000000000000..bafb7d1a22e2
--- /dev/null
+++ b/drivers/ide/tx4939ide.c
@@ -0,0 +1,754 @@
1/*
2 * TX4939 internal IDE driver
3 * Based on RBTX49xx patch from CELF patch archive.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * (C) Copyright TOSHIBA CORPORATION 2005-2007
10 */
11
12#include <linux/module.h>
13#include <linux/types.h>
14#include <linux/ide.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/platform_device.h>
18#include <linux/io.h>
19#include <linux/scatterlist.h>
20
21#define MODNAME "tx4939ide"
22
23/* ATA Shadow Registers (8-bit except for Data which is 16-bit) */
24#define TX4939IDE_Data 0x000
25#define TX4939IDE_Error_Feature 0x001
26#define TX4939IDE_Sec 0x002
27#define TX4939IDE_LBA0 0x003
28#define TX4939IDE_LBA1 0x004
29#define TX4939IDE_LBA2 0x005
30#define TX4939IDE_DevHead 0x006
31#define TX4939IDE_Stat_Cmd 0x007
32#define TX4939IDE_AltStat_DevCtl 0x402
33/* H/W DMA Registers */
34#define TX4939IDE_DMA_Cmd 0x800 /* 8-bit */
35#define TX4939IDE_DMA_Stat 0x802 /* 8-bit */
36#define TX4939IDE_PRD_Ptr 0x804 /* 32-bit */
37/* ATA100 CORE Registers (16-bit) */
38#define TX4939IDE_Sys_Ctl 0xc00
39#define TX4939IDE_Xfer_Cnt_1 0xc08
40#define TX4939IDE_Xfer_Cnt_2 0xc0a
41#define TX4939IDE_Sec_Cnt 0xc10
42#define TX4939IDE_Start_Lo_Addr 0xc18
43#define TX4939IDE_Start_Up_Addr 0xc20
44#define TX4939IDE_Add_Ctl 0xc28
45#define TX4939IDE_Lo_Burst_Cnt 0xc30
46#define TX4939IDE_Up_Burst_Cnt 0xc38
47#define TX4939IDE_PIO_Addr 0xc88
48#define TX4939IDE_H_Rst_Tim 0xc90
49#define TX4939IDE_Int_Ctl 0xc98
50#define TX4939IDE_Pkt_Cmd 0xcb8
51#define TX4939IDE_Bxfer_Cnt_Hi 0xcc0
52#define TX4939IDE_Bxfer_Cnt_Lo 0xcc8
53#define TX4939IDE_Dev_TErr 0xcd0
54#define TX4939IDE_Pkt_Xfer_Ctl 0xcd8
55#define TX4939IDE_Start_TAddr 0xce0
56
57/* bits for Int_Ctl */
58#define TX4939IDE_INT_ADDRERR 0x80
59#define TX4939IDE_INT_REACHMUL 0x40
60#define TX4939IDE_INT_DEVTIMING 0x20
61#define TX4939IDE_INT_UDMATERM 0x10
62#define TX4939IDE_INT_TIMER 0x08
63#define TX4939IDE_INT_BUSERR 0x04
64#define TX4939IDE_INT_XFEREND 0x02
65#define TX4939IDE_INT_HOST 0x01
66
67#define TX4939IDE_IGNORE_INTS \
68 (TX4939IDE_INT_ADDRERR | TX4939IDE_INT_REACHMUL | \
69 TX4939IDE_INT_DEVTIMING | TX4939IDE_INT_UDMATERM | \
70 TX4939IDE_INT_TIMER | TX4939IDE_INT_XFEREND)
71
72#ifdef __BIG_ENDIAN
73#define tx4939ide_swizzlel(a) ((a) ^ 4)
74#define tx4939ide_swizzlew(a) ((a) ^ 6)
75#define tx4939ide_swizzleb(a) ((a) ^ 7)
76#else
77#define tx4939ide_swizzlel(a) (a)
78#define tx4939ide_swizzlew(a) (a)
79#define tx4939ide_swizzleb(a) (a)
80#endif
81
82static u16 tx4939ide_readw(void __iomem *base, u32 reg)
83{
84 return __raw_readw(base + tx4939ide_swizzlew(reg));
85}
86static u8 tx4939ide_readb(void __iomem *base, u32 reg)
87{
88 return __raw_readb(base + tx4939ide_swizzleb(reg));
89}
90static void tx4939ide_writel(u32 val, void __iomem *base, u32 reg)
91{
92 __raw_writel(val, base + tx4939ide_swizzlel(reg));
93}
94static void tx4939ide_writew(u16 val, void __iomem *base, u32 reg)
95{
96 __raw_writew(val, base + tx4939ide_swizzlew(reg));
97}
98static void tx4939ide_writeb(u8 val, void __iomem *base, u32 reg)
99{
100 __raw_writeb(val, base + tx4939ide_swizzleb(reg));
101}
102
103#define TX4939IDE_BASE(hwif) ((void __iomem *)(hwif)->extra_base)
104
105static void tx4939ide_set_pio_mode(ide_drive_t *drive, const u8 pio)
106{
107 ide_hwif_t *hwif = drive->hwif;
108 int is_slave = drive->dn;
109 u32 mask, val;
110 u8 safe = pio;
111 ide_drive_t *pair;
112
113 pair = ide_get_pair_dev(drive);
114 if (pair)
115 safe = min(safe, ide_get_best_pio_mode(pair, 255, 4));
116 /*
117 * Update Command Transfer Mode for master/slave and Data
118 * Transfer Mode for this drive.
119 */
120 mask = is_slave ? 0x07f00000 : 0x000007f0;
121 val = ((safe << 8) | (pio << 4)) << (is_slave ? 16 : 0);
122 hwif->select_data = (hwif->select_data & ~mask) | val;
123 /* tx4939ide_tf_load_fixup() will set the Sys_Ctl register */
124}
125
126static void tx4939ide_set_dma_mode(ide_drive_t *drive, const u8 mode)
127{
128 ide_hwif_t *hwif = drive->hwif;
129 u32 mask, val;
130
131 /* Update Data Transfer Mode for this drive. */
132 if (mode >= XFER_UDMA_0)
133 val = mode - XFER_UDMA_0 + 8;
134 else
135 val = mode - XFER_MW_DMA_0 + 5;
136 if (drive->dn) {
137 mask = 0x00f00000;
138 val <<= 20;
139 } else {
140 mask = 0x000000f0;
141 val <<= 4;
142 }
143 hwif->select_data = (hwif->select_data & ~mask) | val;
144 /* tx4939ide_tf_load_fixup() will set the Sys_Ctl register */
145}
146
147static u16 tx4939ide_check_error_ints(ide_hwif_t *hwif)
148{
149 void __iomem *base = TX4939IDE_BASE(hwif);
150 u16 ctl = tx4939ide_readw(base, TX4939IDE_Int_Ctl);
151
152 if (ctl & TX4939IDE_INT_BUSERR) {
153 /* reset FIFO */
154 u16 sysctl = tx4939ide_readw(base, TX4939IDE_Sys_Ctl);
155
156 tx4939ide_writew(sysctl | 0x4000, base, TX4939IDE_Sys_Ctl);
157 mmiowb();
158 /* wait 12GBUSCLK (typ. 60ns @ GBUS200MHz, max 270ns) */
159 ndelay(270);
160 tx4939ide_writew(sysctl, base, TX4939IDE_Sys_Ctl);
161 }
162 if (ctl & (TX4939IDE_INT_ADDRERR |
163 TX4939IDE_INT_DEVTIMING | TX4939IDE_INT_BUSERR))
164 pr_err("%s: Error interrupt %#x (%s%s%s )\n",
165 hwif->name, ctl,
166 ctl & TX4939IDE_INT_ADDRERR ? " Address-Error" : "",
167 ctl & TX4939IDE_INT_DEVTIMING ? " DEV-Timing" : "",
168 ctl & TX4939IDE_INT_BUSERR ? " Bus-Error" : "");
169 return ctl;
170}
171
172static void tx4939ide_clear_irq(ide_drive_t *drive)
173{
174 ide_hwif_t *hwif;
175 void __iomem *base;
176 u16 ctl;
177
178 /*
179 * tx4939ide_dma_test_irq() and tx4939ide_dma_end() do all job
180 * for DMA case.
181 */
182 if (drive->waiting_for_dma)
183 return;
184 hwif = drive->hwif;
185 base = TX4939IDE_BASE(hwif);
186 ctl = tx4939ide_check_error_ints(hwif);
187 tx4939ide_writew(ctl, base, TX4939IDE_Int_Ctl);
188}
189
190static u8 tx4939ide_cable_detect(ide_hwif_t *hwif)
191{
192 void __iomem *base = TX4939IDE_BASE(hwif);
193
194 return tx4939ide_readw(base, TX4939IDE_Sys_Ctl) & 0x2000 ?
195 ATA_CBL_PATA40 : ATA_CBL_PATA80;
196}
197
198#ifdef __BIG_ENDIAN
199static void tx4939ide_dma_host_set(ide_drive_t *drive, int on)
200{
201 ide_hwif_t *hwif = drive->hwif;
202 u8 unit = drive->dn;
203 void __iomem *base = TX4939IDE_BASE(hwif);
204 u8 dma_stat = tx4939ide_readb(base, TX4939IDE_DMA_Stat);
205
206 if (on)
207 dma_stat |= (1 << (5 + unit));
208 else
209 dma_stat &= ~(1 << (5 + unit));
210
211 tx4939ide_writeb(dma_stat, base, TX4939IDE_DMA_Stat);
212}
213#else
214#define tx4939ide_dma_host_set ide_dma_host_set
215#endif
216
217static u8 tx4939ide_clear_dma_status(void __iomem *base)
218{
219 u8 dma_stat;
220
221 /* read DMA status for INTR & ERROR flags */
222 dma_stat = tx4939ide_readb(base, TX4939IDE_DMA_Stat);
223 /* clear INTR & ERROR flags */
224 tx4939ide_writeb(dma_stat | ATA_DMA_INTR | ATA_DMA_ERR, base,
225 TX4939IDE_DMA_Stat);
226 /* recover intmask cleared by writing to bit2 of DMA_Stat */
227 tx4939ide_writew(TX4939IDE_IGNORE_INTS << 8, base, TX4939IDE_Int_Ctl);
228 return dma_stat;
229}
230
231#ifdef __BIG_ENDIAN
232/* custom ide_build_dmatable to handle swapped layout */
233static int tx4939ide_build_dmatable(ide_drive_t *drive, struct request *rq)
234{
235 ide_hwif_t *hwif = drive->hwif;
236 u32 *table = (u32 *)hwif->dmatable_cpu;
237 unsigned int count = 0;
238 int i;
239 struct scatterlist *sg;
240
241 hwif->sg_nents = ide_build_sglist(drive, rq);
242 if (hwif->sg_nents == 0)
243 return 0;
244
245 for_each_sg(hwif->sg_table, sg, hwif->sg_nents, i) {
246 u32 cur_addr, cur_len, bcount;
247
248 cur_addr = sg_dma_address(sg);
249 cur_len = sg_dma_len(sg);
250
251 /*
252 * Fill in the DMA table, without crossing any 64kB boundaries.
253 */
254
255 while (cur_len) {
256 if (count++ >= PRD_ENTRIES)
257 goto use_pio_instead;
258
259 bcount = 0x10000 - (cur_addr & 0xffff);
260 if (bcount > cur_len)
261 bcount = cur_len;
262 *table++ = bcount & 0xffff;
263 *table++ = cur_addr;
264 cur_addr += bcount;
265 cur_len -= bcount;
266 }
267 }
268
269 if (count) {
270 *(table - 2) |= 0x80000000;
271 return count;
272 }
273
274use_pio_instead:
275 printk(KERN_ERR "%s: %s\n", drive->name,
276 count ? "DMA table too small" : "empty DMA table?");
277
278 ide_destroy_dmatable(drive);
279
280 return 0; /* revert to PIO for this request */
281}
282#else
283#define tx4939ide_build_dmatable ide_build_dmatable
284#endif
285
286static int tx4939ide_dma_setup(ide_drive_t *drive)
287{
288 ide_hwif_t *hwif = drive->hwif;
289 void __iomem *base = TX4939IDE_BASE(hwif);
290 struct request *rq = hwif->hwgroup->rq;
291 u8 reading;
292 int nent;
293
294 if (rq_data_dir(rq))
295 reading = 0;
296 else
297 reading = ATA_DMA_WR;
298
299 /* fall back to PIO! */
300 nent = tx4939ide_build_dmatable(drive, rq);
301 if (!nent) {
302 ide_map_sg(drive, rq);
303 return 1;
304 }
305
306 /* PRD table */
307 tx4939ide_writel(hwif->dmatable_dma, base, TX4939IDE_PRD_Ptr);
308
309 /* specify r/w */
310 tx4939ide_writeb(reading, base, TX4939IDE_DMA_Cmd);
311
312 /* clear INTR & ERROR flags */
313 tx4939ide_clear_dma_status(base);
314
315 drive->waiting_for_dma = 1;
316
317 tx4939ide_writew(SECTOR_SIZE / 2, base, drive->dn ?
318 TX4939IDE_Xfer_Cnt_2 : TX4939IDE_Xfer_Cnt_1);
319 tx4939ide_writew(rq->nr_sectors, base, TX4939IDE_Sec_Cnt);
320 return 0;
321}
322
323static int tx4939ide_dma_end(ide_drive_t *drive)
324{
325 ide_hwif_t *hwif = drive->hwif;
326 u8 dma_stat, dma_cmd;
327 void __iomem *base = TX4939IDE_BASE(hwif);
328 u16 ctl = tx4939ide_readw(base, TX4939IDE_Int_Ctl);
329
330 drive->waiting_for_dma = 0;
331
332 /* get DMA command mode */
333 dma_cmd = tx4939ide_readb(base, TX4939IDE_DMA_Cmd);
334 /* stop DMA */
335 tx4939ide_writeb(dma_cmd & ~ATA_DMA_START, base, TX4939IDE_DMA_Cmd);
336
337 /* read and clear the INTR & ERROR bits */
338 dma_stat = tx4939ide_clear_dma_status(base);
339
340 /* purge DMA mappings */
341 ide_destroy_dmatable(drive);
342 /* verify good DMA status */
343 wmb();
344
345 if ((dma_stat & (ATA_DMA_INTR | ATA_DMA_ERR | ATA_DMA_ACTIVE)) == 0 &&
346 (ctl & (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST)) ==
347 (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST))
348 /* INT_IDE lost... bug? */
349 return 0;
350 return ((dma_stat & (ATA_DMA_INTR | ATA_DMA_ERR | ATA_DMA_ACTIVE)) !=
351 ATA_DMA_INTR) ? 0x10 | dma_stat : 0;
352}
353
354/* returns 1 if DMA IRQ issued, 0 otherwise */
355static int tx4939ide_dma_test_irq(ide_drive_t *drive)
356{
357 ide_hwif_t *hwif = drive->hwif;
358 void __iomem *base = TX4939IDE_BASE(hwif);
359 u16 ctl, ide_int;
360 u8 dma_stat, stat;
361 int found = 0;
362
363 ctl = tx4939ide_check_error_ints(hwif);
364 ide_int = ctl & (TX4939IDE_INT_XFEREND | TX4939IDE_INT_HOST);
365 switch (ide_int) {
366 case TX4939IDE_INT_HOST:
367 /* On error, XFEREND might not be asserted. */
368 stat = tx4939ide_readb(base, TX4939IDE_AltStat_DevCtl);
369 if ((stat & (ATA_BUSY | ATA_DRQ | ATA_ERR)) == ATA_ERR)
370 found = 1;
371 else
372 /* Wait for XFEREND (Mask HOST and unmask XFEREND) */
373 ctl &= ~TX4939IDE_INT_XFEREND << 8;
374 ctl |= ide_int << 8;
375 break;
376 case TX4939IDE_INT_HOST | TX4939IDE_INT_XFEREND:
377 dma_stat = tx4939ide_readb(base, TX4939IDE_DMA_Stat);
378 if (!(dma_stat & ATA_DMA_INTR))
379 pr_warning("%s: weird interrupt status. "
380 "DMA_Stat %#02x int_ctl %#04x\n",
381 hwif->name, dma_stat, ctl);
382 found = 1;
383 break;
384 }
385 /*
386 * Do not clear XFEREND, HOST now. They will be cleared by
387 * clearing bit2 of DMA_Stat.
388 */
389 ctl &= ~ide_int;
390 tx4939ide_writew(ctl, base, TX4939IDE_Int_Ctl);
391 return found;
392}
393
394static void tx4939ide_init_hwif(ide_hwif_t *hwif)
395{
396 void __iomem *base = TX4939IDE_BASE(hwif);
397
398 /* Soft Reset */
399 tx4939ide_writew(0x8000, base, TX4939IDE_Sys_Ctl);
400 mmiowb();
401 /* at least 20 GBUSCLK (typ. 100ns @ GBUS200MHz, max 450ns) */
402 ndelay(450);
403 tx4939ide_writew(0x0000, base, TX4939IDE_Sys_Ctl);
404 /* mask some interrupts and clear all interrupts */
405 tx4939ide_writew((TX4939IDE_IGNORE_INTS << 8) | 0xff, base,
406 TX4939IDE_Int_Ctl);
407
408 tx4939ide_writew(0x0008, base, TX4939IDE_Lo_Burst_Cnt);
409 tx4939ide_writew(0, base, TX4939IDE_Up_Burst_Cnt);
410}
411
412static int tx4939ide_init_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
413{
414 hwif->dma_base =
415 hwif->extra_base + tx4939ide_swizzleb(TX4939IDE_DMA_Cmd);
416 /*
417 * Note that we cannot use ATA_DMA_TABLE_OFS, ATA_DMA_STATUS
418 * for big endian.
419 */
420 return ide_allocate_dma_engine(hwif);
421}
422
423static void tx4939ide_tf_load_fixup(ide_drive_t *drive, ide_task_t *task)
424{
425 ide_hwif_t *hwif = drive->hwif;
426 void __iomem *base = TX4939IDE_BASE(hwif);
427 u16 sysctl = hwif->select_data >> (drive->dn ? 16 : 0);
428
429 /*
430 * Fix ATA100 CORE System Control Register. (The write to the
431 * Device/Head register may write wrong data to the System
432 * Control Register)
433 * While Sys_Ctl is written here, selectproc is not needed.
434 */
435 tx4939ide_writew(sysctl, base, TX4939IDE_Sys_Ctl);
436}
437
438#ifdef __BIG_ENDIAN
439
440static u8 tx4939ide_read_sff_dma_status(ide_hwif_t *hwif)
441{
442 void __iomem *base = TX4939IDE_BASE(hwif);
443
444 return tx4939ide_readb(base, TX4939IDE_DMA_Stat);
445}
446
447/* custom iops (independent from SWAP_IO_SPACE) */
448static u8 tx4939ide_inb(unsigned long port)
449{
450 return __raw_readb((void __iomem *)port);
451}
452
453static void tx4939ide_outb(u8 value, unsigned long port)
454{
455 __raw_writeb(value, (void __iomem *)port);
456}
457
458static void tx4939ide_tf_load(ide_drive_t *drive, ide_task_t *task)
459{
460 ide_hwif_t *hwif = drive->hwif;
461 struct ide_io_ports *io_ports = &hwif->io_ports;
462 struct ide_taskfile *tf = &task->tf;
463 u8 HIHI = task->tf_flags & IDE_TFLAG_LBA48 ? 0xE0 : 0xEF;
464
465 if (task->tf_flags & IDE_TFLAG_FLAGGED)
466 HIHI = 0xFF;
467
468 if (task->tf_flags & IDE_TFLAG_OUT_DATA) {
469 u16 data = (tf->hob_data << 8) | tf->data;
470
471 /* no endian swap */
472 __raw_writew(data, (void __iomem *)io_ports->data_addr);
473 }
474
475 if (task->tf_flags & IDE_TFLAG_OUT_HOB_FEATURE)
476 tx4939ide_outb(tf->hob_feature, io_ports->feature_addr);
477 if (task->tf_flags & IDE_TFLAG_OUT_HOB_NSECT)
478 tx4939ide_outb(tf->hob_nsect, io_ports->nsect_addr);
479 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAL)
480 tx4939ide_outb(tf->hob_lbal, io_ports->lbal_addr);
481 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAM)
482 tx4939ide_outb(tf->hob_lbam, io_ports->lbam_addr);
483 if (task->tf_flags & IDE_TFLAG_OUT_HOB_LBAH)
484 tx4939ide_outb(tf->hob_lbah, io_ports->lbah_addr);
485
486 if (task->tf_flags & IDE_TFLAG_OUT_FEATURE)
487 tx4939ide_outb(tf->feature, io_ports->feature_addr);
488 if (task->tf_flags & IDE_TFLAG_OUT_NSECT)
489 tx4939ide_outb(tf->nsect, io_ports->nsect_addr);
490 if (task->tf_flags & IDE_TFLAG_OUT_LBAL)
491 tx4939ide_outb(tf->lbal, io_ports->lbal_addr);
492 if (task->tf_flags & IDE_TFLAG_OUT_LBAM)
493 tx4939ide_outb(tf->lbam, io_ports->lbam_addr);
494 if (task->tf_flags & IDE_TFLAG_OUT_LBAH)
495 tx4939ide_outb(tf->lbah, io_ports->lbah_addr);
496
497 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) {
498 tx4939ide_outb((tf->device & HIHI) | drive->select,
499 io_ports->device_addr);
500 tx4939ide_tf_load_fixup(drive, task);
501 }
502}
503
504static void tx4939ide_tf_read(ide_drive_t *drive, ide_task_t *task)
505{
506 ide_hwif_t *hwif = drive->hwif;
507 struct ide_io_ports *io_ports = &hwif->io_ports;
508 struct ide_taskfile *tf = &task->tf;
509
510 if (task->tf_flags & IDE_TFLAG_IN_DATA) {
511 u16 data;
512
513 /* no endian swap */
514 data = __raw_readw((void __iomem *)io_ports->data_addr);
515 tf->data = data & 0xff;
516 tf->hob_data = (data >> 8) & 0xff;
517 }
518
519 /* be sure we're looking at the low order bits */
520 tx4939ide_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
521
522 if (task->tf_flags & IDE_TFLAG_IN_FEATURE)
523 tf->feature = tx4939ide_inb(io_ports->feature_addr);
524 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
525 tf->nsect = tx4939ide_inb(io_ports->nsect_addr);
526 if (task->tf_flags & IDE_TFLAG_IN_LBAL)
527 tf->lbal = tx4939ide_inb(io_ports->lbal_addr);
528 if (task->tf_flags & IDE_TFLAG_IN_LBAM)
529 tf->lbam = tx4939ide_inb(io_ports->lbam_addr);
530 if (task->tf_flags & IDE_TFLAG_IN_LBAH)
531 tf->lbah = tx4939ide_inb(io_ports->lbah_addr);
532 if (task->tf_flags & IDE_TFLAG_IN_DEVICE)
533 tf->device = tx4939ide_inb(io_ports->device_addr);
534
535 if (task->tf_flags & IDE_TFLAG_LBA48) {
536 tx4939ide_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
537
538 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
539 tf->hob_feature =
540 tx4939ide_inb(io_ports->feature_addr);
541 if (task->tf_flags & IDE_TFLAG_IN_HOB_NSECT)
542 tf->hob_nsect = tx4939ide_inb(io_ports->nsect_addr);
543 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAL)
544 tf->hob_lbal = tx4939ide_inb(io_ports->lbal_addr);
545 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAM)
546 tf->hob_lbam = tx4939ide_inb(io_ports->lbam_addr);
547 if (task->tf_flags & IDE_TFLAG_IN_HOB_LBAH)
548 tf->hob_lbah = tx4939ide_inb(io_ports->lbah_addr);
549 }
550}
551
552static void tx4939ide_input_data_swap(ide_drive_t *drive, struct request *rq,
553 void *buf, unsigned int len)
554{
555 unsigned long port = drive->hwif->io_ports.data_addr;
556 unsigned short *ptr = buf;
557 unsigned int count = (len + 1) / 2;
558
559 while (count--)
560 *ptr++ = cpu_to_le16(__raw_readw((void __iomem *)port));
561 __ide_flush_dcache_range((unsigned long)buf, count * 2);
562}
563
564static void tx4939ide_output_data_swap(ide_drive_t *drive, struct request *rq,
565 void *buf, unsigned int len)
566{
567 unsigned long port = drive->hwif->io_ports.data_addr;
568 unsigned short *ptr = buf;
569 unsigned int count = (len + 1) / 2;
570
571 while (count--) {
572 __raw_writew(le16_to_cpu(*ptr), (void __iomem *)port);
573 ptr++;
574 }
575 __ide_flush_dcache_range((unsigned long)buf, count * 2);
576}
577
578static const struct ide_tp_ops tx4939ide_tp_ops = {
579 .exec_command = ide_exec_command,
580 .read_status = ide_read_status,
581 .read_altstatus = ide_read_altstatus,
582 .read_sff_dma_status = tx4939ide_read_sff_dma_status,
583
584 .set_irq = ide_set_irq,
585
586 .tf_load = tx4939ide_tf_load,
587 .tf_read = tx4939ide_tf_read,
588
589 .input_data = tx4939ide_input_data_swap,
590 .output_data = tx4939ide_output_data_swap,
591};
592
593#else /* __LITTLE_ENDIAN */
594
595static void tx4939ide_tf_load(ide_drive_t *drive, ide_task_t *task)
596{
597 ide_tf_load(drive, task);
598 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE)
599 tx4939ide_tf_load_fixup(drive, task);
600}
601
602static const struct ide_tp_ops tx4939ide_tp_ops = {
603 .exec_command = ide_exec_command,
604 .read_status = ide_read_status,
605 .read_altstatus = ide_read_altstatus,
606 .read_sff_dma_status = ide_read_sff_dma_status,
607
608 .set_irq = ide_set_irq,
609
610 .tf_load = tx4939ide_tf_load,
611 .tf_read = ide_tf_read,
612
613 .input_data = ide_input_data,
614 .output_data = ide_output_data,
615};
616
617#endif /* __LITTLE_ENDIAN */
618
619static const struct ide_port_ops tx4939ide_port_ops = {
620 .set_pio_mode = tx4939ide_set_pio_mode,
621 .set_dma_mode = tx4939ide_set_dma_mode,
622 .clear_irq = tx4939ide_clear_irq,
623 .cable_detect = tx4939ide_cable_detect,
624};
625
626static const struct ide_dma_ops tx4939ide_dma_ops = {
627 .dma_host_set = tx4939ide_dma_host_set,
628 .dma_setup = tx4939ide_dma_setup,
629 .dma_exec_cmd = ide_dma_exec_cmd,
630 .dma_start = ide_dma_start,
631 .dma_end = tx4939ide_dma_end,
632 .dma_test_irq = tx4939ide_dma_test_irq,
633 .dma_lost_irq = ide_dma_lost_irq,
634 .dma_timeout = ide_dma_timeout,
635};
636
637static const struct ide_port_info tx4939ide_port_info __initdata = {
638 .init_hwif = tx4939ide_init_hwif,
639 .init_dma = tx4939ide_init_dma,
640 .port_ops = &tx4939ide_port_ops,
641 .dma_ops = &tx4939ide_dma_ops,
642 .tp_ops = &tx4939ide_tp_ops,
643 .host_flags = IDE_HFLAG_MMIO,
644 .pio_mask = ATA_PIO4,
645 .mwdma_mask = ATA_MWDMA2,
646 .udma_mask = ATA_UDMA5,
647};
648
649static int __init tx4939ide_probe(struct platform_device *pdev)
650{
651 hw_regs_t hw;
652 hw_regs_t *hws[] = { &hw, NULL, NULL, NULL };
653 struct ide_host *host;
654 struct resource *res;
655 int irq, ret;
656 unsigned long mapbase;
657
658 irq = platform_get_irq(pdev, 0);
659 if (irq < 0)
660 return -ENODEV;
661 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
662 if (!res)
663 return -ENODEV;
664
665 if (!devm_request_mem_region(&pdev->dev, res->start,
666 res->end - res->start + 1, "tx4938ide"))
667 return -EBUSY;
668 mapbase = (unsigned long)devm_ioremap(&pdev->dev, res->start,
669 res->end - res->start + 1);
670 if (!mapbase)
671 return -EBUSY;
672 memset(&hw, 0, sizeof(hw));
673 hw.io_ports.data_addr =
674 mapbase + tx4939ide_swizzlew(TX4939IDE_Data);
675 hw.io_ports.error_addr =
676 mapbase + tx4939ide_swizzleb(TX4939IDE_Error_Feature);
677 hw.io_ports.nsect_addr =
678 mapbase + tx4939ide_swizzleb(TX4939IDE_Sec);
679 hw.io_ports.lbal_addr =
680 mapbase + tx4939ide_swizzleb(TX4939IDE_LBA0);
681 hw.io_ports.lbam_addr =
682 mapbase + tx4939ide_swizzleb(TX4939IDE_LBA1);
683 hw.io_ports.lbah_addr =
684 mapbase + tx4939ide_swizzleb(TX4939IDE_LBA2);
685 hw.io_ports.device_addr =
686 mapbase + tx4939ide_swizzleb(TX4939IDE_DevHead);
687 hw.io_ports.command_addr =
688 mapbase + tx4939ide_swizzleb(TX4939IDE_Stat_Cmd);
689 hw.io_ports.ctl_addr =
690 mapbase + tx4939ide_swizzleb(TX4939IDE_AltStat_DevCtl);
691 hw.irq = irq;
692 hw.dev = &pdev->dev;
693
694 pr_info("TX4939 IDE interface (base %#lx, irq %d)\n", mapbase, irq);
695 host = ide_host_alloc(&tx4939ide_port_info, hws);
696 if (!host)
697 return -ENOMEM;
698 /* use extra_base for base address of the all registers */
699 host->ports[0]->extra_base = mapbase;
700 ret = ide_host_register(host, &tx4939ide_port_info, hws);
701 if (ret) {
702 ide_host_free(host);
703 return ret;
704 }
705 platform_set_drvdata(pdev, host);
706 return 0;
707}
708
709static int __exit tx4939ide_remove(struct platform_device *pdev)
710{
711 struct ide_host *host = platform_get_drvdata(pdev);
712
713 ide_host_remove(host);
714 return 0;
715}
716
717#ifdef CONFIG_PM
718static int tx4939ide_resume(struct platform_device *dev)
719{
720 struct ide_host *host = platform_get_drvdata(dev);
721 ide_hwif_t *hwif = host->ports[0];
722
723 tx4939ide_init_hwif(hwif);
724 return 0;
725}
726#else
727#define tx4939ide_resume NULL
728#endif
729
730static struct platform_driver tx4939ide_driver = {
731 .driver = {
732 .name = MODNAME,
733 .owner = THIS_MODULE,
734 },
735 .remove = __exit_p(tx4939ide_remove),
736 .resume = tx4939ide_resume,
737};
738
739static int __init tx4939ide_init(void)
740{
741 return platform_driver_probe(&tx4939ide_driver, tx4939ide_probe);
742}
743
744static void __exit tx4939ide_exit(void)
745{
746 platform_driver_unregister(&tx4939ide_driver);
747}
748
749module_init(tx4939ide_init);
750module_exit(tx4939ide_exit);
751
752MODULE_DESCRIPTION("TX4939 internal IDE driver");
753MODULE_LICENSE("GPL");
754MODULE_ALIAS("platform:tx4939ide");
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/umc8672.c
index 1da076e0c917..1da076e0c917 100644
--- a/drivers/ide/legacy/umc8672.c
+++ b/drivers/ide/umc8672.c
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/via82cxxx.c
index 2a812d3207e9..2a812d3207e9 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c