aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2006-10-03 04:14:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-03 11:04:07 -0400
commitbbb3bbdb0f78cb02451daf5687a99627f7ad1140 (patch)
tree6359d29b2df96f3ac7b89e4f6d75c536126b0794 /drivers/ide
parentce164428c4cabfd284ca81913415cacd889aac33 (diff)
[PATCH] non-libata driver for Jmicron devices
Less functional than libata this just uses the merged interface provided for dumb legacy OS's. This is basically a bridge for people not yet ready to use libata for some reason or another. Port visibility is entirely dependant on the BIOS setup. Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/Kconfig6
-rw-r--r--drivers/ide/pci/Makefile1
-rw-r--r--drivers/ide/pci/jmicron.c269
3 files changed, 276 insertions, 0 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 69d627bd537a..0524f17175fd 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -594,6 +594,12 @@ config BLK_DEV_HPT366
594 ide-probe at boot. It is reported to support DVD II drives, by the 594 ide-probe at boot. It is reported to support DVD II drives, by the
595 manufacturer. 595 manufacturer.
596 596
597config BLK_DEV_JMICRON
598 tristate "JMicron JMB36x support"
599 help
600 Basic support for the JMicron ATA controllers. For full support
601 use the libata drivers.
602
597config BLK_DEV_SC1200 603config BLK_DEV_SC1200
598 tristate "National SCx200 chipset support" 604 tristate "National SCx200 chipset support"
599 help 605 help
diff --git a/drivers/ide/pci/Makefile b/drivers/ide/pci/Makefile
index f35d684edc25..640a54b09b5a 100644
--- a/drivers/ide/pci/Makefile
+++ b/drivers/ide/pci/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o
14#obj-$(CONFIG_BLK_DEV_HPT37X) += hpt37x.o 14#obj-$(CONFIG_BLK_DEV_HPT37X) += hpt37x.o
15obj-$(CONFIG_BLK_DEV_IT8172) += it8172.o 15obj-$(CONFIG_BLK_DEV_IT8172) += it8172.o
16obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o 16obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o
17obj-$(CONFIG_BLK_DEV_JMICRON) += jmicron.o
17obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o 18obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o
18obj-$(CONFIG_BLK_DEV_OPTI621) += opti621.o 19obj-$(CONFIG_BLK_DEV_OPTI621) += opti621.o
19obj-$(CONFIG_BLK_DEV_PDC202XX_OLD) += pdc202xx_old.o 20obj-$(CONFIG_BLK_DEV_PDC202XX_OLD) += pdc202xx_old.o
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
new file mode 100644
index 000000000000..68c74bbf8b06
--- /dev/null
+++ b/drivers/ide/pci/jmicron.c
@@ -0,0 +1,269 @@
1
2/*
3 * Copyright (C) 2006 Red Hat <alan@redhat.com>
4 *
5 * May be copied or modified under the terms of the GNU General Public License
6 */
7
8#include <linux/config.h>
9#include <linux/types.h>
10#include <linux/module.h>
11#include <linux/pci.h>
12#include <linux/delay.h>
13#include <linux/hdreg.h>
14#include <linux/ide.h>
15#include <linux/init.h>
16
17#include <asm/io.h>
18
19typedef enum {
20 PORT_PATA0 = 0,
21 PORT_PATA1 = 1,
22 PORT_SATA = 2,
23} port_type;
24
25/**
26 * jmicron_ratemask - Compute available modes
27 * @drive: IDE drive
28 *
29 * Compute the available speeds for the devices on the interface. This
30 * is all modes to ATA133 clipped by drive cable setup.
31 */
32
33static u8 jmicron_ratemask(ide_drive_t *drive)
34{
35 u8 mode = 4;
36 if (!eighty_ninty_three(drive))
37 mode = min(mode, (u8)1);
38 return mode;
39}
40
41/**
42 * ata66_jmicron - Cable check
43 * @hwif: IDE port
44 *
45 * Return 1 if the cable is 80pin
46 */
47
48static int __devinit ata66_jmicron(ide_hwif_t *hwif)
49{
50 struct pci_dev *pdev = hwif->pci_dev;
51
52 u32 control;
53 u32 control5;
54
55 int port = hwif->channel;
56 port_type port_map[2];
57
58 pci_read_config_dword(pdev, 0x40, &control);
59
60 /* There are two basic mappings. One has the two SATA ports merged
61 as master/slave and the secondary as PATA, the other has only the
62 SATA port mapped */
63 if (control & (1 << 23)) {
64 port_map[0] = PORT_SATA;
65 port_map[1] = PORT_PATA0;
66 } else {
67 port_map[0] = PORT_SATA;
68 port_map[1] = PORT_SATA;
69 }
70
71 /* The 365/366 may have this bit set to map the second PATA port
72 as the internal primary channel */
73 pci_read_config_dword(pdev, 0x80, &control5);
74 if (control5 & (1<<24))
75 port_map[0] = PORT_PATA1;
76
77 /* The two ports may then be logically swapped by the firmware */
78 if (control & (1 << 22))
79 port = port ^ 1;
80
81 /*
82 * Now we know which physical port we are talking about we can
83 * actually do our cable checking etc. Thankfully we don't need
84 * to do the plumbing for other cases.
85 */
86 switch (port_map[port])
87 {
88 case PORT_PATA0:
89 if (control & (1 << 3)) /* 40/80 pin primary */
90 return 1;
91 return 0;
92 case PORT_PATA1:
93 if (control5 & (1 << 19)) /* 40/80 pin secondary */
94 return 0;
95 return 1;
96 case PORT_SATA:
97 return 1;
98 }
99}
100
101static void jmicron_tuneproc (ide_drive_t *drive, byte mode_wanted)
102{
103 return;
104}
105
106/**
107 * config_jmicron_chipset_for_pio - set drive timings
108 * @drive: drive to tune
109 * @speed we want
110 *
111 */
112
113static void config_jmicron_chipset_for_pio (ide_drive_t *drive, byte set_speed)
114{
115 u8 speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL);
116 if (set_speed)
117 (void) ide_config_drive_speed(drive, speed);
118}
119
120/**
121 * jmicron_tune_chipset - set controller timings
122 * @drive: Drive to set up
123 * @xferspeed: speed we want to achieve
124 *
125 * As the JMicron snoops for timings all we actually need to do is
126 * make sure we don't set an invalid mode. We do need to honour
127 * the cable detect here.
128 */
129
130static int jmicron_tune_chipset (ide_drive_t *drive, byte xferspeed)
131{
132
133 u8 speed = ide_rate_filter(jmicron_ratemask(drive), xferspeed);
134
135 return ide_config_drive_speed(drive, speed);
136}
137
138/**
139 * config_chipset_for_dma - configure for DMA
140 * @drive: drive to configure
141 *
142 * As the JMicron snoops for timings all we actually need to do is
143 * make sure we don't set an invalid mode.
144 */
145
146static int config_chipset_for_dma (ide_drive_t *drive)
147{
148 u8 speed = ide_dma_speed(drive, jmicron_ratemask(drive));
149
150 config_jmicron_chipset_for_pio(drive, !speed);
151 jmicron_tune_chipset(drive, speed);
152 return ide_dma_enable(drive);
153}
154
155/**
156 * jmicron_configure_drive_for_dma - set up for DMA transfers
157 * @drive: drive we are going to set up
158 *
159 * As the JMicron snoops for timings all we actually need to do is
160 * make sure we don't set an invalid mode.
161 */
162
163static int jmicron_config_drive_for_dma (ide_drive_t *drive)
164{
165 ide_hwif_t *hwif = drive->hwif;
166
167 if (ide_use_dma(drive)) {
168 if (config_chipset_for_dma(drive))
169 return hwif->ide_dma_on(drive);
170 }
171 config_jmicron_chipset_for_pio(drive, 1);
172 return hwif->ide_dma_off_quietly(drive);
173}
174
175/**
176 * init_hwif_jmicron - set up hwif structs
177 * @hwif: interface to set up
178 *
179 * Minimal set up is required for the Jmicron hardware.
180 */
181
182static void __devinit init_hwif_jmicron(ide_hwif_t *hwif)
183{
184 hwif->speedproc = &jmicron_tune_chipset;
185 hwif->tuneproc = &jmicron_tuneproc;
186
187 hwif->drives[0].autotune = 1;
188 hwif->drives[1].autotune = 1;
189
190 if (!hwif->dma_base)
191 goto fallback;
192
193 hwif->atapi_dma = 1;
194 hwif->ultra_mask = 0x7f;
195 hwif->mwdma_mask = 0x07;
196
197 hwif->ide_dma_check = &jmicron_config_drive_for_dma;
198 if (!(hwif->udma_four))
199 hwif->udma_four = ata66_jmicron(hwif);
200
201 hwif->autodma = 1;
202 hwif->drives[0].autodma = hwif->autodma;
203 hwif->drives[1].autodma = hwif->autodma;
204 return;
205fallback:
206 hwif->autodma = 0;
207 return;
208}
209
210#define DECLARE_JMB_DEV(name_str) \
211 { \
212 .name = name_str, \
213 .init_hwif = init_hwif_jmicron, \
214 .channels = 2, \
215 .autodma = AUTODMA, \
216 .bootable = ON_BOARD, \
217 .enablebits = { {0x40, 1, 1}, {0x40, 0x10, 0x10} }, \
218 }
219
220static ide_pci_device_t jmicron_chipsets[] __devinitdata = {
221 /* 0 */ DECLARE_JMB_DEV("JMB361"),
222 /* 1 */ DECLARE_JMB_DEV("JMB363"),
223 /* 2 */ DECLARE_JMB_DEV("JMB365"),
224 /* 3 */ DECLARE_JMB_DEV("JMB366"),
225 /* 4 */ DECLARE_JMB_DEV("JMB368"),
226};
227
228/**
229 * jmicron_init_one - pci layer discovery entry
230 * @dev: PCI device
231 * @id: ident table entry
232 *
233 * Called by the PCI code when it finds a Jmicron controller.
234 * We then use the IDE PCI generic helper to do most of the work.
235 */
236
237static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id)
238{
239 ide_setup_pci_device(dev, &jmicron_chipsets[id->driver_data]);
240 return 0;
241}
242
243static struct pci_device_id jmicron_pci_tbl[] = {
244 { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361), 0},
245 { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363), 1},
246 { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365), 2},
247 { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366), 3},
248 { PCI_DEVICE(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368), 4},
249 { 0, },
250};
251
252MODULE_DEVICE_TABLE(pci, jmicron_pci_tbl);
253
254static struct pci_driver driver = {
255 .name = "JMicron IDE",
256 .id_table = jmicron_pci_tbl,
257 .probe = jmicron_init_one,
258};
259
260static int __init jmicron_ide_init(void)
261{
262 return ide_pci_register_driver(&driver);
263}
264
265module_init(jmicron_ide_init);
266
267MODULE_AUTHOR("Alan Cox");
268MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes");
269MODULE_LICENSE("GPL");