blob: ef5b39fa042b1c51eed9ee77442b50acf1658dda [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Copyright (C) 2001-2002 Andre Hedrick <andre@linux-ide.org>
3 * Copyright (C) 2003 Red Hat <alan@redhat.com>
Sergei Shtylyov075cb652007-02-17 02:40:22 +01004 * Copyright (C) 2007 MontaVista Software, Inc.
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +02005 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * May be copied or modified under the terms of the GNU General Public License
8 *
Jeff Garzikbf4c7962005-11-18 22:55:47 +01009 * Documentation for CMD680:
10 * http://gkernel.sourceforge.net/specs/sii/sii-0680a-v1.31.pdf.bz2
11 *
12 * Documentation for SiI 3112:
13 * http://gkernel.sourceforge.net/specs/sii/3112A_SiI-DS-0095-B2.pdf.bz2
14 *
15 * Errata and other documentation only available under NDA.
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 *
17 *
18 * FAQ Items:
19 * If you are using Marvell SATA-IDE adapters with Maxtor drives
20 * ensure the system is set up for ATA100/UDMA5 not UDMA6.
21 *
22 * If you are using WD drives with SATA bridges you must set the
23 * drive to "Single". "Master" will hang
24 *
25 * If you have strange problems with nVidia chipset systems please
26 * see the SI support documentation and update your system BIOS
Robert P. J. Day3a4fa0a2007-10-19 23:10:43 +020027 * if necessary
Alan Cox8693d3e2007-03-03 17:48:54 +010028 *
29 * The Dell DRAC4 has some interesting features including effectively hot
30 * unplugging/replugging the virtual CD interface when the DRAC is reset.
31 * This often causes drivers/ide/siimage to panic but is ok with the rather
32 * smarter code in libata.
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +020033 *
34 * TODO:
35 * - IORDY fixes
36 * - VDMA support
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 */
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/types.h>
40#include <linux/module.h>
41#include <linux/pci.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/hdreg.h>
43#include <linux/ide.h>
44#include <linux/init.h>
45
46#include <asm/io.h>
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048/**
49 * pdev_is_sata - check if device is SATA
50 * @pdev: PCI device to check
51 *
52 * Returns true if this is a SATA controller
53 */
54
55static int pdev_is_sata(struct pci_dev *pdev)
56{
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +020057#ifdef CONFIG_BLK_DEV_IDE_SATA
58 switch(pdev->device) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 case PCI_DEVICE_ID_SII_3112:
60 case PCI_DEVICE_ID_SII_1210SA:
61 return 1;
62 case PCI_DEVICE_ID_SII_680:
63 return 0;
64 }
65 BUG();
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +020066#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 return 0;
68}
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +020069
Linus Torvalds1da177e2005-04-16 15:20:36 -070070/**
71 * is_sata - check if hwif is SATA
72 * @hwif: interface to check
73 *
74 * Returns true if this is a SATA controller
75 */
76
77static inline int is_sata(ide_hwif_t *hwif)
78{
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +010079 return pdev_is_sata(to_pci_dev(hwif->dev));
Linus Torvalds1da177e2005-04-16 15:20:36 -070080}
81
82/**
83 * siimage_selreg - return register base
84 * @hwif: interface
85 * @r: config offset
86 *
87 * Turn a config register offset into the right address in either
88 * PCI space or MMIO space to access the control register in question
89 * Thankfully this is a configuration operation so isnt performance
90 * criticial.
91 */
92
93static unsigned long siimage_selreg(ide_hwif_t *hwif, int r)
94{
95 unsigned long base = (unsigned long)hwif->hwif_data;
96 base += 0xA0 + r;
97 if(hwif->mmio)
98 base += (hwif->channel << 6);
99 else
100 base += (hwif->channel << 4);
101 return base;
102}
103
104/**
105 * siimage_seldev - return register base
106 * @hwif: interface
107 * @r: config offset
108 *
109 * Turn a config register offset into the right address in either
110 * PCI space or MMIO space to access the control register in question
111 * including accounting for the unit shift.
112 */
113
114static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
115{
116 ide_hwif_t *hwif = HWIF(drive);
117 unsigned long base = (unsigned long)hwif->hwif_data;
118 base += 0xA0 + r;
119 if(hwif->mmio)
120 base += (hwif->channel << 6);
121 else
122 base += (hwif->channel << 4);
123 base |= drive->select.b.unit << drive->select.b.unit;
124 return base;
125}
126
127/**
Bartlomiej Zolnierkiewicz2d5eaa62007-05-10 00:01:08 +0200128 * sil_udma_filter - compute UDMA mask
129 * @drive: IDE device
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 *
Bartlomiej Zolnierkiewicz2d5eaa62007-05-10 00:01:08 +0200131 * Compute the available UDMA speeds for the device on the interface.
132 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 * For the CMD680 this depends on the clocking mode (scsc), for the
Bartlomiej Zolnierkiewicz2d5eaa62007-05-10 00:01:08 +0200134 * SI3112 SATA controller life is a bit simpler.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 */
Bartlomiej Zolnierkiewicz2d5eaa62007-05-10 00:01:08 +0200136
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200137static u8 sil_pata_udma_filter(ide_drive_t *drive)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138{
Bartlomiej Zolnierkiewicz2d5eaa62007-05-10 00:01:08 +0200139 ide_hwif_t *hwif = drive->hwif;
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100140 struct pci_dev *dev = to_pci_dev(hwif->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 unsigned long base = (unsigned long) hwif->hwif_data;
Bartlomiej Zolnierkiewicz2d5eaa62007-05-10 00:01:08 +0200142 u8 mask = 0, scsc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144 if (hwif->mmio)
145 scsc = hwif->INB(base + 0x4A);
146 else
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100147 pci_read_config_byte(dev, 0x8A, &scsc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 if ((scsc & 0x30) == 0x10) /* 133 */
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200150 mask = ATA_UDMA6;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 else if ((scsc & 0x30) == 0x20) /* 2xPCI */
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200152 mask = ATA_UDMA6;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 else if ((scsc & 0x30) == 0x00) /* 100 */
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200154 mask = ATA_UDMA5;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 else /* Disabled ? */
156 BUG();
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200157
Bartlomiej Zolnierkiewicz2d5eaa62007-05-10 00:01:08 +0200158 return mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159}
160
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200161static u8 sil_sata_udma_filter(ide_drive_t *drive)
162{
163 return strstr(drive->id->model, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6;
164}
165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166/**
Bartlomiej Zolnierkiewicz88b2b322007-10-13 17:47:51 +0200167 * sil_set_pio_mode - set host controller for PIO mode
168 * @drive: drive
169 * @pio: PIO mode number
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 *
171 * Load the timing settings for this device mode into the
172 * controller. If we are in PIO mode 3 or 4 turn on IORDY
173 * monitoring (bit 9). The TF timing is bits 31:16
174 */
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200175
Bartlomiej Zolnierkiewicz88b2b322007-10-13 17:47:51 +0200176static void sil_set_pio_mode(ide_drive_t *drive, u8 pio)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200178 const u16 tf_speed[] = { 0x328a, 0x2283, 0x1281, 0x10c3, 0x10c1 };
179 const u16 data_speed[] = { 0x328a, 0x2283, 0x1104, 0x10c3, 0x10c1 };
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 ide_hwif_t *hwif = HWIF(drive);
Benjamin Herrenschmidta87a87c2007-10-19 00:30:05 +0200182 ide_drive_t *pair = ide_get_paired_drive(drive);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 u32 speedt = 0;
184 u16 speedp = 0;
185 unsigned long addr = siimage_seldev(drive, 0x04);
186 unsigned long tfaddr = siimage_selreg(hwif, 0x02);
Bartlomiej Zolnierkiewiczffe54152007-10-11 23:54:01 +0200187 unsigned long base = (unsigned long)hwif->hwif_data;
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200188 u8 tf_pio = pio;
Bartlomiej Zolnierkiewiczffe54152007-10-11 23:54:01 +0200189 u8 addr_mask = hwif->channel ? (hwif->mmio ? 0xF4 : 0x84)
190 : (hwif->mmio ? 0xB4 : 0x80);
191 u8 mode = 0;
192 u8 unit = drive->select.b.unit;
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200193
194 /* trim *taskfile* PIO to the slowest of the master/slave */
195 if (pair->present) {
Bartlomiej Zolnierkiewicz21347582007-07-20 01:11:58 +0200196 u8 pair_pio = ide_get_best_pio_mode(pair, 255, 4);
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200197
198 if (pair_pio < tf_pio)
199 tf_pio = pair_pio;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 }
Sergei Shtylyov075cb652007-02-17 02:40:22 +0100201
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200202 /* cheat for now and use the docs */
203 speedp = data_speed[pio];
204 speedt = tf_speed[tf_pio];
205
Sergei Shtylyov075cb652007-02-17 02:40:22 +0100206 if (hwif->mmio) {
207 hwif->OUTW(speedp, addr);
208 hwif->OUTW(speedt, tfaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 /* Now set up IORDY */
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200210 if (pio > 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 hwif->OUTW(hwif->INW(tfaddr-2)|0x200, tfaddr-2);
212 else
213 hwif->OUTW(hwif->INW(tfaddr-2)&~0x200, tfaddr-2);
Bartlomiej Zolnierkiewiczffe54152007-10-11 23:54:01 +0200214
215 mode = hwif->INB(base + addr_mask);
216 mode &= ~(unit ? 0x30 : 0x03);
217 mode |= (unit ? 0x10 : 0x01);
218 hwif->OUTB(mode, base + addr_mask);
Sergei Shtylyov075cb652007-02-17 02:40:22 +0100219 } else {
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100220 struct pci_dev *dev = to_pci_dev(hwif->dev);
221
222 pci_write_config_word(dev, addr, speedp);
223 pci_write_config_word(dev, tfaddr, speedt);
224 pci_read_config_word(dev, tfaddr - 2, &speedp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 speedp &= ~0x200;
226 /* Set IORDY for mode 3 or 4 */
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200227 if (pio > 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 speedp |= 0x200;
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100229 pci_write_config_word(dev, tfaddr - 2, speedp);
Bartlomiej Zolnierkiewiczffe54152007-10-11 23:54:01 +0200230
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100231 pci_read_config_byte(dev, addr_mask, &mode);
Bartlomiej Zolnierkiewiczffe54152007-10-11 23:54:01 +0200232 mode &= ~(unit ? 0x30 : 0x03);
233 mode |= (unit ? 0x10 : 0x01);
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100234 pci_write_config_byte(dev, addr_mask, mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 }
236}
237
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238/**
Bartlomiej Zolnierkiewicz88b2b322007-10-13 17:47:51 +0200239 * sil_set_dma_mode - set host controller for DMA mode
240 * @drive: drive
241 * @speed: DMA mode
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 *
Bartlomiej Zolnierkiewicz88b2b322007-10-13 17:47:51 +0200243 * Tune the SiI chipset for the desired DMA mode.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 */
Bartlomiej Zolnierkiewiczf212ff22007-10-11 23:53:59 +0200245
Bartlomiej Zolnierkiewicz88b2b322007-10-13 17:47:51 +0200246static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247{
248 u8 ultra6[] = { 0x0F, 0x0B, 0x07, 0x05, 0x03, 0x02, 0x01 };
249 u8 ultra5[] = { 0x0C, 0x07, 0x05, 0x04, 0x02, 0x01 };
250 u16 dma[] = { 0x2208, 0x10C2, 0x10C1 };
251
252 ide_hwif_t *hwif = HWIF(drive);
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100253 struct pci_dev *dev = to_pci_dev(hwif->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 u16 ultra = 0, multi = 0;
255 u8 mode = 0, unit = drive->select.b.unit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 unsigned long base = (unsigned long)hwif->hwif_data;
257 u8 scsc = 0, addr_mask = ((hwif->channel) ?
258 ((hwif->mmio) ? 0xF4 : 0x84) :
259 ((hwif->mmio) ? 0xB4 : 0x80));
260
261 unsigned long ma = siimage_seldev(drive, 0x08);
262 unsigned long ua = siimage_seldev(drive, 0x0C);
263
264 if (hwif->mmio) {
265 scsc = hwif->INB(base + 0x4A);
266 mode = hwif->INB(base + addr_mask);
267 multi = hwif->INW(ma);
268 ultra = hwif->INW(ua);
269 } else {
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100270 pci_read_config_byte(dev, 0x8A, &scsc);
271 pci_read_config_byte(dev, addr_mask, &mode);
272 pci_read_config_word(dev, ma, &multi);
273 pci_read_config_word(dev, ua, &ultra);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 }
275
276 mode &= ~((unit) ? 0x30 : 0x03);
277 ultra &= ~0x3F;
278 scsc = ((scsc & 0x30) == 0x00) ? 0 : 1;
279
280 scsc = is_sata(hwif) ? 1 : scsc;
281
Bartlomiej Zolnierkiewicz4db90a12008-01-25 22:17:18 +0100282 if (speed >= XFER_UDMA_0) {
283 multi = dma[2];
284 ultra |= (scsc ? ultra6[speed - XFER_UDMA_0] :
285 ultra5[speed - XFER_UDMA_0]);
286 mode |= (unit ? 0x30 : 0x03);
287 } else {
288 multi = dma[speed - XFER_MW_DMA_0];
289 mode |= (unit ? 0x20 : 0x02);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 }
291
292 if (hwif->mmio) {
293 hwif->OUTB(mode, base + addr_mask);
294 hwif->OUTW(multi, ma);
295 hwif->OUTW(ultra, ua);
296 } else {
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100297 pci_write_config_byte(dev, addr_mask, mode);
298 pci_write_config_word(dev, ma, multi);
299 pci_write_config_word(dev, ua, ultra);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301}
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303/* returns 1 if dma irq issued, 0 otherwise */
304static int siimage_io_ide_dma_test_irq (ide_drive_t *drive)
305{
306 ide_hwif_t *hwif = HWIF(drive);
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100307 struct pci_dev *dev = to_pci_dev(hwif->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 u8 dma_altstat = 0;
309 unsigned long addr = siimage_selreg(hwif, 1);
310
311 /* return 1 if INTR asserted */
312 if ((hwif->INB(hwif->dma_status) & 4) == 4)
313 return 1;
314
315 /* return 1 if Device INTR asserted */
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100316 pci_read_config_byte(dev, addr, &dma_altstat);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 if (dma_altstat & 8)
318 return 0; //return 1;
319 return 0;
320}
321
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322/**
323 * siimage_mmio_ide_dma_test_irq - check we caused an IRQ
324 * @drive: drive we are testing
325 *
326 * Check if we caused an IDE DMA interrupt. We may also have caused
327 * SATA status interrupts, if so we clean them up and continue.
328 */
329
330static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive)
331{
332 ide_hwif_t *hwif = HWIF(drive);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 unsigned long addr = siimage_selreg(hwif, 0x1);
Bartlomiej Zolnierkiewicz835457d2008-02-02 19:56:45 +0100334 void __iomem *sata_error_addr
335 = (void __iomem *)hwif->sata_scr[SATA_ERROR_OFFSET];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
Bartlomiej Zolnierkiewicz835457d2008-02-02 19:56:45 +0100337 if (sata_error_addr) {
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200338 unsigned long base = (unsigned long)hwif->hwif_data;
Bartlomiej Zolnierkiewicz0ecdca22007-02-17 02:40:25 +0100339 u32 ext_stat = readl((void __iomem *)(base + 0x10));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 u8 watchdog = 0;
Bartlomiej Zolnierkiewicz835457d2008-02-02 19:56:45 +0100341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 if (ext_stat & ((hwif->channel) ? 0x40 : 0x10)) {
Bartlomiej Zolnierkiewicz835457d2008-02-02 19:56:45 +0100343 u32 sata_error = readl(sata_error_addr);
344
345 writel(sata_error, sata_error_addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 watchdog = (sata_error & 0x00680000) ? 1 : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 printk(KERN_WARNING "%s: sata_error = 0x%08x, "
348 "watchdog = %d, %s\n",
349 drive->name, sata_error, watchdog,
350 __FUNCTION__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351
352 } else {
353 watchdog = (ext_stat & 0x8000) ? 1 : 0;
354 }
355 ext_stat >>= 16;
356
357 if (!(ext_stat & 0x0404) && !watchdog)
358 return 0;
359 }
360
361 /* return 1 if INTR asserted */
Bartlomiej Zolnierkiewicz0ecdca22007-02-17 02:40:25 +0100362 if ((readb((void __iomem *)hwif->dma_status) & 0x04) == 0x04)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 return 1;
364
365 /* return 1 if Device INTR asserted */
Bartlomiej Zolnierkiewicz0ecdca22007-02-17 02:40:25 +0100366 if ((readb((void __iomem *)addr) & 8) == 8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 return 0; //return 1;
368
369 return 0;
370}
371
372/**
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200373 * sil_sata_busproc - bus isolation IOCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 * @drive: drive to isolate/restore
375 * @state: bus state to set
376 *
377 * Used by the SII3112 to handle bus isolation. As this is a
378 * SATA controller the work required is quite limited, we
379 * just have to clean up the statistics
380 */
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200381
382static int sil_sata_busproc(ide_drive_t * drive, int state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383{
384 ide_hwif_t *hwif = HWIF(drive);
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100385 struct pci_dev *dev = to_pci_dev(hwif->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 u32 stat_config = 0;
387 unsigned long addr = siimage_selreg(hwif, 0);
388
Bartlomiej Zolnierkiewicz0ecdca22007-02-17 02:40:25 +0100389 if (hwif->mmio)
390 stat_config = readl((void __iomem *)addr);
391 else
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100392 pci_read_config_dword(dev, addr, &stat_config);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394 switch (state) {
395 case BUSSTATE_ON:
396 hwif->drives[0].failures = 0;
397 hwif->drives[1].failures = 0;
398 break;
399 case BUSSTATE_OFF:
400 hwif->drives[0].failures = hwif->drives[0].max_failures + 1;
401 hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
402 break;
403 case BUSSTATE_TRISTATE:
404 hwif->drives[0].failures = hwif->drives[0].max_failures + 1;
405 hwif->drives[1].failures = hwif->drives[1].max_failures + 1;
406 break;
407 default:
408 return -EINVAL;
409 }
410 hwif->bus_state = state;
411 return 0;
412}
413
414/**
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200415 * sil_sata_reset_poll - wait for SATA reset
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 * @drive: drive we are resetting
417 *
418 * Poll the SATA phy and see whether it has come back from the dead
419 * yet.
420 */
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200421
422static int sil_sata_reset_poll(ide_drive_t *drive)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423{
Bartlomiej Zolnierkiewicz835457d2008-02-02 19:56:45 +0100424 ide_hwif_t *hwif = drive->hwif;
425 void __iomem *sata_status_addr
426 = (void __iomem *)hwif->sata_scr[SATA_STATUS_OFFSET];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427
Bartlomiej Zolnierkiewicz835457d2008-02-02 19:56:45 +0100428 if (sata_status_addr) {
429 /* SATA Status is available only when in MMIO mode */
430 u32 sata_stat = readl(sata_status_addr);
431
432 if ((sata_stat & 0x03) != 0x03) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 printk(KERN_WARNING "%s: reset phy dead, status=0x%08x\n",
Bartlomiej Zolnierkiewicz835457d2008-02-02 19:56:45 +0100434 hwif->name, sata_stat);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 HWGROUP(drive)->polling = 0;
436 return ide_started;
437 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 }
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200439
440 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441}
442
443/**
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200444 * sil_sata_pre_reset - reset hook
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 * @drive: IDE device being reset
446 *
447 * For the SATA devices we need to handle recalibration/geometry
448 * differently
449 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200451static void sil_sata_pre_reset(ide_drive_t *drive)
452{
453 if (drive->media == ide_disk) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 drive->special.b.set_geometry = 0;
455 drive->special.b.recalibrate = 0;
456 }
457}
458
459/**
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 * proc_reports_siimage - add siimage controller to proc
461 * @dev: PCI device
462 * @clocking: SCSC value
463 * @name: controller name
464 *
465 * Report the clocking mode of the controller and add it to
466 * the /proc interface layer
467 */
468
469static void proc_reports_siimage (struct pci_dev *dev, u8 clocking, const char *name)
470{
471 if (!pdev_is_sata(dev)) {
472 printk(KERN_INFO "%s: BASE CLOCK ", name);
473 clocking &= 0x03;
474 switch (clocking) {
475 case 0x03: printk("DISABLED!\n"); break;
476 case 0x02: printk("== 2X PCI\n"); break;
477 case 0x01: printk("== 133\n"); break;
478 case 0x00: printk("== 100\n"); break;
479 }
480 }
481}
482
483/**
484 * setup_mmio_siimage - switch an SI controller into MMIO
485 * @dev: PCI device we are configuring
486 * @name: device name
487 *
488 * Attempt to put the device into mmio mode. There are some slight
489 * complications here with certain systems where the mmio bar isnt
490 * mapped so we have to be sure we can fall back to I/O.
491 */
492
493static unsigned int setup_mmio_siimage (struct pci_dev *dev, const char *name)
494{
495 unsigned long bar5 = pci_resource_start(dev, 5);
496 unsigned long barsize = pci_resource_len(dev, 5);
497 u8 tmpbyte = 0;
498 void __iomem *ioaddr;
John W. Linvilled868dd12005-11-10 00:19:14 +0100499 u32 tmp, irq_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
501 /*
502 * Drop back to PIO if we can't map the mmio. Some
503 * systems seem to get terminally confused in the PCI
504 * spaces.
505 */
506
507 if(!request_mem_region(bar5, barsize, name))
508 {
509 printk(KERN_WARNING "siimage: IDE controller MMIO ports not available.\n");
510 return 0;
511 }
512
513 ioaddr = ioremap(bar5, barsize);
514
515 if (ioaddr == NULL)
516 {
517 release_mem_region(bar5, barsize);
518 return 0;
519 }
520
521 pci_set_master(dev);
522 pci_set_drvdata(dev, (void *) ioaddr);
523
524 if (pdev_is_sata(dev)) {
John W. Linvilled868dd12005-11-10 00:19:14 +0100525 /* make sure IDE0/1 interrupts are not masked */
526 irq_mask = (1 << 22) | (1 << 23);
527 tmp = readl(ioaddr + 0x48);
528 if (tmp & irq_mask) {
529 tmp &= ~irq_mask;
530 writel(tmp, ioaddr + 0x48);
531 readl(ioaddr + 0x48); /* flush */
532 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 writel(0, ioaddr + 0x148);
534 writel(0, ioaddr + 0x1C8);
535 }
536
537 writeb(0, ioaddr + 0xB4);
538 writeb(0, ioaddr + 0xF4);
539 tmpbyte = readb(ioaddr + 0x4A);
540
541 switch(tmpbyte & 0x30) {
542 case 0x00:
543 /* In 100 MHz clocking, try and switch to 133 */
544 writeb(tmpbyte|0x10, ioaddr + 0x4A);
545 break;
546 case 0x10:
547 /* On 133Mhz clocking */
548 break;
549 case 0x20:
550 /* On PCIx2 clocking */
551 break;
552 case 0x30:
553 /* Clocking is disabled */
554 /* 133 clock attempt to force it on */
555 writeb(tmpbyte & ~0x20, ioaddr + 0x4A);
556 break;
557 }
558
559 writeb( 0x72, ioaddr + 0xA1);
560 writew( 0x328A, ioaddr + 0xA2);
561 writel(0x62DD62DD, ioaddr + 0xA4);
562 writel(0x43924392, ioaddr + 0xA8);
563 writel(0x40094009, ioaddr + 0xAC);
564 writeb( 0x72, ioaddr + 0xE1);
565 writew( 0x328A, ioaddr + 0xE2);
566 writel(0x62DD62DD, ioaddr + 0xE4);
567 writel(0x43924392, ioaddr + 0xE8);
568 writel(0x40094009, ioaddr + 0xEC);
569
570 if (pdev_is_sata(dev)) {
571 writel(0xFFFF0000, ioaddr + 0x108);
572 writel(0xFFFF0000, ioaddr + 0x188);
573 writel(0x00680000, ioaddr + 0x148);
574 writel(0x00680000, ioaddr + 0x1C8);
575 }
576
577 tmpbyte = readb(ioaddr + 0x4A);
578
579 proc_reports_siimage(dev, (tmpbyte>>4), name);
580 return 1;
581}
582
583/**
584 * init_chipset_siimage - set up an SI device
585 * @dev: PCI device
586 * @name: device name
587 *
588 * Perform the initial PCI set up for this device. Attempt to switch
589 * to 133MHz clocking if the system isn't already set up to do it.
590 */
591
592static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, const char *name)
593{
Bartlomiej Zolnierkiewiczfc212bb2007-10-19 00:30:08 +0200594 u8 rev = dev->revision, tmpbyte = 0, BA5_EN = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595
Bartlomiej Zolnierkiewiczfc212bb2007-10-19 00:30:08 +0200596 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, rev ? 1 : 255);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
598 pci_read_config_byte(dev, 0x8A, &BA5_EN);
599 if ((BA5_EN & 0x01) || (pci_resource_start(dev, 5))) {
600 if (setup_mmio_siimage(dev, name)) {
601 return 0;
602 }
603 }
604
605 pci_write_config_byte(dev, 0x80, 0x00);
606 pci_write_config_byte(dev, 0x84, 0x00);
607 pci_read_config_byte(dev, 0x8A, &tmpbyte);
608 switch(tmpbyte & 0x30) {
609 case 0x00:
610 /* 133 clock attempt to force it on */
611 pci_write_config_byte(dev, 0x8A, tmpbyte|0x10);
612 case 0x30:
613 /* if clocking is disabled */
614 /* 133 clock attempt to force it on */
615 pci_write_config_byte(dev, 0x8A, tmpbyte & ~0x20);
616 case 0x10:
617 /* 133 already */
618 break;
619 case 0x20:
620 /* BIOS set PCI x2 clocking */
621 break;
622 }
623
624 pci_read_config_byte(dev, 0x8A, &tmpbyte);
625
626 pci_write_config_byte(dev, 0xA1, 0x72);
627 pci_write_config_word(dev, 0xA2, 0x328A);
628 pci_write_config_dword(dev, 0xA4, 0x62DD62DD);
629 pci_write_config_dword(dev, 0xA8, 0x43924392);
630 pci_write_config_dword(dev, 0xAC, 0x40094009);
631 pci_write_config_byte(dev, 0xB1, 0x72);
632 pci_write_config_word(dev, 0xB2, 0x328A);
633 pci_write_config_dword(dev, 0xB4, 0x62DD62DD);
634 pci_write_config_dword(dev, 0xB8, 0x43924392);
635 pci_write_config_dword(dev, 0xBC, 0x40094009);
636
637 proc_reports_siimage(dev, (tmpbyte>>4), name);
638 return 0;
639}
640
641/**
642 * init_mmio_iops_siimage - set up the iops for MMIO
643 * @hwif: interface to set up
644 *
645 * The basic setup here is fairly simple, we can use standard MMIO
646 * operations. However we do have to set the taskfile register offsets
647 * by hand as there isnt a standard defined layout for them this
648 * time.
649 *
650 * The hardware supports buffered taskfiles and also some rather nice
Alan Cox19c1ef52006-06-28 04:26:59 -0700651 * extended PRD tables. For better SI3112 support use the libata driver
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 */
653
654static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
655{
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100656 struct pci_dev *dev = to_pci_dev(hwif->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 void *addr = pci_get_drvdata(dev);
658 u8 ch = hwif->channel;
659 hw_regs_t hw;
660 unsigned long base;
661
662 /*
663 * Fill in the basic HWIF bits
664 */
665
666 default_hwif_mmiops(hwif);
667 hwif->hwif_data = addr;
668
669 /*
670 * Now set up the hw. We have to do this ourselves as
Michael Opdenacker59c51592007-05-09 08:57:56 +0200671 * the MMIO layout isnt the same as the standard port
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 * based I/O
673 */
674
675 memset(&hw, 0, sizeof(hw_regs_t));
676
677 base = (unsigned long)addr;
678 if (ch)
679 base += 0xC0;
680 else
681 base += 0x80;
682
683 /*
684 * The buffered task file doesn't have status/control
685 * so we can't currently use it sanely since we want to
686 * use LBA48 mode.
687 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 hw.io_ports[IDE_DATA_OFFSET] = base;
689 hw.io_ports[IDE_ERROR_OFFSET] = base + 1;
690 hw.io_ports[IDE_NSECTOR_OFFSET] = base + 2;
691 hw.io_ports[IDE_SECTOR_OFFSET] = base + 3;
692 hw.io_ports[IDE_LCYL_OFFSET] = base + 4;
693 hw.io_ports[IDE_HCYL_OFFSET] = base + 5;
694 hw.io_ports[IDE_SELECT_OFFSET] = base + 6;
695 hw.io_ports[IDE_STATUS_OFFSET] = base + 7;
696 hw.io_ports[IDE_CONTROL_OFFSET] = base + 10;
697
698 hw.io_ports[IDE_IRQ_OFFSET] = 0;
699
700 if (pdev_is_sata(dev)) {
701 base = (unsigned long)addr;
702 if (ch)
703 base += 0x80;
704 hwif->sata_scr[SATA_STATUS_OFFSET] = base + 0x104;
705 hwif->sata_scr[SATA_ERROR_OFFSET] = base + 0x108;
706 hwif->sata_scr[SATA_CONTROL_OFFSET] = base + 0x100;
707 hwif->sata_misc[SATA_MISC_OFFSET] = base + 0x140;
708 hwif->sata_misc[SATA_PHY_OFFSET] = base + 0x144;
709 hwif->sata_misc[SATA_IEN_OFFSET] = base + 0x148;
710 }
711
Bartlomiej Zolnierkiewicz9239b332007-10-20 00:32:33 +0200712 memcpy(hwif->io_ports, hw.io_ports, sizeof(hwif->io_ports));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713
Bartlomiej Zolnierkiewicz9239b332007-10-20 00:32:33 +0200714 hwif->irq = dev->irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715
Bartlomiej Zolnierkiewicz9239b332007-10-20 00:32:33 +0200716 hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00);
Bartlomiej Zolnierkiewicz2ad1e552007-02-17 02:40:25 +0100717
718 hwif->mmio = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719}
720
721static int is_dev_seagate_sata(ide_drive_t *drive)
722{
723 const char *s = &drive->id->model[0];
724 unsigned len;
725
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 len = strnlen(s, sizeof(drive->id->model));
727
728 if ((len > 4) && (!memcmp(s, "ST", 2))) {
729 if ((!memcmp(s + len - 2, "AS", 2)) ||
730 (!memcmp(s + len - 3, "ASL", 3))) {
731 printk(KERN_INFO "%s: applying pessimistic Seagate "
732 "errata fix\n", drive->name);
733 return 1;
734 }
735 }
736 return 0;
737}
738
739/**
Bartlomiej Zolnierkiewiczf01393e2008-01-26 20:13:03 +0100740 * sil_quirkproc - post probe fixups
741 * @drive: drive
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 *
743 * Called after drive probe we use this to decide whether the
744 * Seagate fixup must be applied. This used to be in init_iops but
745 * that can occur before we know what drives are present.
746 */
747
Bartlomiej Zolnierkiewiczf01393e2008-01-26 20:13:03 +0100748static void __devinit sil_quirkproc(ide_drive_t *drive)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749{
Bartlomiej Zolnierkiewiczf01393e2008-01-26 20:13:03 +0100750 ide_hwif_t *hwif = drive->hwif;
751
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 /* Try and raise the rqsize */
Bartlomiej Zolnierkiewiczf01393e2008-01-26 20:13:03 +0100753 if (!is_sata(hwif) || !is_dev_seagate_sata(drive))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 hwif->rqsize = 128;
755}
756
757/**
758 * init_iops_siimage - set up iops
759 * @hwif: interface to set up
760 *
761 * Do the basic setup for the SIIMAGE hardware interface
762 * and then do the MMIO setup if we can. This is the first
763 * look in we get for setting up the hwif so that we
764 * can get the iops right before using them.
765 */
766
767static void __devinit init_iops_siimage(ide_hwif_t *hwif)
768{
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100769 struct pci_dev *dev = to_pci_dev(hwif->dev);
770
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 hwif->hwif_data = NULL;
772
773 /* Pessimal until we finish probing */
774 hwif->rqsize = 15;
775
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100776 if (pci_get_drvdata(dev) == NULL)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 return;
Bartlomiej Zolnierkiewiczfc212bb2007-10-19 00:30:08 +0200778
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 init_mmio_iops_siimage(hwif);
780}
781
782/**
783 * ata66_siimage - check for 80 pin cable
784 * @hwif: interface to check
785 *
786 * Check for the presence of an ATA66 capable cable on the
787 * interface.
788 */
789
Bartlomiej Zolnierkiewicz49521f92007-07-09 23:17:58 +0200790static u8 __devinit ata66_siimage(ide_hwif_t *hwif)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791{
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100792 struct pci_dev *dev = to_pci_dev(hwif->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 unsigned long addr = siimage_selreg(hwif, 0);
Bartlomiej Zolnierkiewicz49521f92007-07-09 23:17:58 +0200794 u8 ata66 = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795
Bartlomiej Zolnierkiewicz36501652008-02-01 23:09:31 +0100796 if (pci_get_drvdata(dev) == NULL)
797 pci_read_config_byte(dev, addr, &ata66);
Bartlomiej Zolnierkiewicz49521f92007-07-09 23:17:58 +0200798 else
799 ata66 = hwif->INB(addr);
800
801 return (ata66 & 0x01) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802}
803
804/**
805 * init_hwif_siimage - set up hwif structs
806 * @hwif: interface to set up
807 *
808 * We do the basic set up of the interface structure. The SIIMAGE
809 * requires several custom handlers so we override the default
810 * ide DMA handlers appropriately
811 */
812
813static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
814{
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200815 u8 sata = is_sata(hwif);
816
Bartlomiej Zolnierkiewicz26bcb872007-10-11 23:54:00 +0200817 hwif->set_pio_mode = &sil_set_pio_mode;
Bartlomiej Zolnierkiewicz88b2b322007-10-13 17:47:51 +0200818 hwif->set_dma_mode = &sil_set_dma_mode;
Bartlomiej Zolnierkiewiczf01393e2008-01-26 20:13:03 +0100819 hwif->quirkproc = &sil_quirkproc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200821 if (sata) {
Alan Cox19c1ef52006-06-28 04:26:59 -0700822 static int first = 1;
823
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200824 hwif->busproc = &sil_sata_busproc;
825 hwif->reset_poll = &sil_sata_reset_poll;
826 hwif->pre_reset = &sil_sata_pre_reset;
827 hwif->udma_filter = &sil_sata_udma_filter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828
Alan Cox19c1ef52006-06-28 04:26:59 -0700829 if (first) {
830 printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n");
831 first = 0;
832 }
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200833 } else
834 hwif->udma_filter = &sil_pata_udma_filter;
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200835
Bartlomiej Zolnierkiewiczbfa14b42008-02-02 19:56:31 +0100836 hwif->cable_detect = ata66_siimage;
837
Bartlomiej Zolnierkiewicz328dcbb2007-07-20 01:11:54 +0200838 if (hwif->dma_base == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840
Bartlomiej Zolnierkiewicz438c4702007-10-20 00:32:31 +0200841 if (sata)
Bartlomiej Zolnierkiewicz33c10022007-10-19 00:30:06 +0200842 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 if (hwif->mmio) {
845 hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq;
846 } else {
847 hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq;
848 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849}
850
851#define DECLARE_SII_DEV(name_str) \
852 { \
853 .name = name_str, \
854 .init_chipset = init_chipset_siimage, \
855 .init_iops = init_iops_siimage, \
856 .init_hwif = init_hwif_siimage, \
Bartlomiej Zolnierkiewicz7cab14a2007-10-19 00:30:06 +0200857 .host_flags = IDE_HFLAG_BOOTABLE, \
Bartlomiej Zolnierkiewicz4099d142007-07-20 01:11:59 +0200858 .pio_mask = ATA_PIO4, \
Bartlomiej Zolnierkiewicz5f8b6c32007-10-19 00:30:07 +0200859 .mwdma_mask = ATA_MWDMA2, \
860 .udma_mask = ATA_UDMA6, \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 }
862
Bartlomiej Zolnierkiewicz85620432007-10-20 00:32:34 +0200863static const struct ide_port_info siimage_chipsets[] __devinitdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 /* 0 */ DECLARE_SII_DEV("SiI680"),
865 /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"),
866 /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA")
867};
868
869/**
870 * siimage_init_one - pci layer discovery entry
871 * @dev: PCI device
872 * @id: ident table entry
873 *
874 * Called by the PCI code when it finds an SI680 or SI3112 controller.
875 * We then use the IDE PCI generic helper to do most of the work.
876 */
877
878static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id)
879{
880 return ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]);
881}
882
Bartlomiej Zolnierkiewicz9cbcc5e2007-10-16 22:29:56 +0200883static const struct pci_device_id siimage_pci_tbl[] = {
884 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885#ifdef CONFIG_BLK_DEV_IDE_SATA
Bartlomiej Zolnierkiewicz9cbcc5e2007-10-16 22:29:56 +0200886 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_3112), 1 },
887 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_1210SA), 2 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888#endif
889 { 0, },
890};
891MODULE_DEVICE_TABLE(pci, siimage_pci_tbl);
892
893static struct pci_driver driver = {
894 .name = "SiI_IDE",
895 .id_table = siimage_pci_tbl,
896 .probe = siimage_init_one,
897};
898
Bartlomiej Zolnierkiewicz82ab1ee2007-01-27 13:46:56 +0100899static int __init siimage_ide_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900{
901 return ide_pci_register_driver(&driver);
902}
903
904module_init(siimage_ide_init);
905
906MODULE_AUTHOR("Andre Hedrick, Alan Cox");
907MODULE_DESCRIPTION("PCI driver module for SiI IDE");
908MODULE_LICENSE("GPL");