1 /* $Id: cmd64x.c,v 1.21 2000/01/30 23:23:16
3 * linux/drivers/ide/pci/cmd64x.c Version 1.41 Feb 3, 2007
5 * cmd64x.c: Enable interrupts at initialization time on Ultra/PCI machines.
6 * Note, this driver is not used at all on other systems because
7 * there the "BIOS" has done all of the following already.
8 * Due to massive hardware bugs, UltraDMA is only supported
9 * on the 646U2 and not on the 646U.
11 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
12 * Copyright (C) 1998 David S. Miller (davem@redhat.com)
14 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org>
15 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
18 #include <linux/module.h>
19 #include <linux/types.h>
20 #include <linux/pci.h>
21 #include <linux/delay.h>
22 #include <linux/hdreg.h>
23 #include <linux/ide.h>
24 #include <linux/init.h>
28 #define DISPLAY_CMD64X_TIMINGS
33 #define cmdprintk(x...) printk(x)
35 #define cmdprintk(x...)
39 * CMD64x specific registers definition.
42 #define CFR_INTR_CH0 0x02
44 #define CNTRL_DIS_RA0 0x40
45 #define CNTRL_DIS_RA1 0x80
46 #define CNTRL_ENA_2ND 0x08
54 #define ARTTIM23_DIS_RA2 0x04
55 #define ARTTIM23_DIS_RA3 0x08
56 #define ARTTIM23_INTR_CH1 0x10
66 #define MRDMODE_INTR_CH0 0x04
67 #define MRDMODE_INTR_CH1 0x08
68 #define MRDMODE_BLK_CH0 0x10
69 #define MRDMODE_BLK_CH1 0x20
71 #define UDIDETCR0 0x73
76 #define UDIDETCR1 0x7B
79 #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS)
80 #include <linux/stat.h>
81 #include <linux/proc_fs.h>
83 static u8 cmd64x_proc = 0;
85 #define CMD_MAX_DEVS 5
87 static struct pci_dev *cmd_devs[CMD_MAX_DEVS];
88 static int n_cmd_devs;
90 static char * print_cmd64x_get_info (char *buf, struct pci_dev *dev, int index)
94 u8 reg53 = 0, reg54 = 0, reg55 = 0, reg56 = 0; /* primary */
95 u8 reg57 = 0, reg58 = 0, reg5b; /* secondary */
96 u8 reg72 = 0, reg73 = 0; /* primary */
97 u8 reg7a = 0, reg7b = 0; /* secondary */
98 u8 reg50 = 0, reg71 = 0; /* extra */
100 p += sprintf(p, "\nController: %d\n", index);
101 p += sprintf(p, "CMD%x Chipset.\n", dev->device);
102 (void) pci_read_config_byte(dev, CFR, ®50);
103 (void) pci_read_config_byte(dev, ARTTIM0, ®53);
104 (void) pci_read_config_byte(dev, DRWTIM0, ®54);
105 (void) pci_read_config_byte(dev, ARTTIM1, ®55);
106 (void) pci_read_config_byte(dev, DRWTIM1, ®56);
107 (void) pci_read_config_byte(dev, ARTTIM2, ®57);
108 (void) pci_read_config_byte(dev, DRWTIM2, ®58);
109 (void) pci_read_config_byte(dev, DRWTIM3, ®5b);
110 (void) pci_read_config_byte(dev, MRDMODE, ®71);
111 (void) pci_read_config_byte(dev, BMIDESR0, ®72);
112 (void) pci_read_config_byte(dev, UDIDETCR0, ®73);
113 (void) pci_read_config_byte(dev, BMIDESR1, ®7a);
114 (void) pci_read_config_byte(dev, UDIDETCR1, ®7b);
116 p += sprintf(p, "--------------- Primary Channel "
117 "---------------- Secondary Channel "
119 p += sprintf(p, " %sabled "
121 (reg72&0x80)?"dis":" en",
122 (reg7a&0x80)?"dis":" en");
123 p += sprintf(p, "--------------- drive0 "
124 "--------- drive1 -------- drive0 "
125 "---------- drive1 ------\n");
126 p += sprintf(p, "DMA enabled: %s %s"
128 (reg72&0x20)?"yes":"no ", (reg72&0x40)?"yes":"no ",
129 (reg7a&0x20)?"yes":"no ", (reg7a&0x40)?"yes":"no ");
131 p += sprintf(p, "DMA Mode: %s(%s) %s(%s)",
132 (reg72&0x20)?((reg73&0x01)?"UDMA":" DMA"):" PIO",
134 ((reg73&0x30)==0x30)?(((reg73&0x35)==0x35)?"3":"0"):
135 ((reg73&0x20)==0x20)?(((reg73&0x25)==0x25)?"3":"1"):
136 ((reg73&0x10)==0x10)?(((reg73&0x15)==0x15)?"4":"2"):
137 ((reg73&0x00)==0x00)?(((reg73&0x05)==0x05)?"5":"2"):
139 (reg72&0x40)?((reg73&0x02)?"UDMA":" DMA"):" PIO",
141 ((reg73&0xC0)==0xC0)?(((reg73&0xC5)==0xC5)?"3":"0"):
142 ((reg73&0x80)==0x80)?(((reg73&0x85)==0x85)?"3":"1"):
143 ((reg73&0x40)==0x40)?(((reg73&0x4A)==0x4A)?"4":"2"):
144 ((reg73&0x00)==0x00)?(((reg73&0x0A)==0x0A)?"5":"2"):
146 p += sprintf(p, " %s(%s) %s(%s)\n",
147 (reg7a&0x20)?((reg7b&0x01)?"UDMA":" DMA"):" PIO",
149 ((reg7b&0x30)==0x30)?(((reg7b&0x35)==0x35)?"3":"0"):
150 ((reg7b&0x20)==0x20)?(((reg7b&0x25)==0x25)?"3":"1"):
151 ((reg7b&0x10)==0x10)?(((reg7b&0x15)==0x15)?"4":"2"):
152 ((reg7b&0x00)==0x00)?(((reg7b&0x05)==0x05)?"5":"2"):
154 (reg7a&0x40)?((reg7b&0x02)?"UDMA":" DMA"):" PIO",
156 ((reg7b&0xC0)==0xC0)?(((reg7b&0xC5)==0xC5)?"3":"0"):
157 ((reg7b&0x80)==0x80)?(((reg7b&0x85)==0x85)?"3":"1"):
158 ((reg7b&0x40)==0x40)?(((reg7b&0x4A)==0x4A)?"4":"2"):
159 ((reg7b&0x00)==0x00)?(((reg7b&0x0A)==0x0A)?"5":"2"):
161 p += sprintf(p, "PIO Mode: %s %s"
164 p += sprintf(p, " %s %s\n",
165 (reg50 & CFR_INTR_CH0) ? "interrupting" : "polling ",
166 (reg57 & ARTTIM23_INTR_CH1) ? "interrupting" : "polling");
167 p += sprintf(p, " %s %s\n",
168 (reg71 & MRDMODE_INTR_CH0) ? "pending" : "clear ",
169 (reg71 & MRDMODE_INTR_CH1) ? "pending" : "clear");
170 p += sprintf(p, " %s %s\n",
171 (reg71 & MRDMODE_BLK_CH0) ? "blocked" : "enabled",
172 (reg71 & MRDMODE_BLK_CH1) ? "blocked" : "enabled");
177 static int cmd64x_get_info (char *buffer, char **addr, off_t offset, int count)
182 p += sprintf(p, "\n");
183 for (i = 0; i < n_cmd_devs; i++) {
184 struct pci_dev *dev = cmd_devs[i];
185 p = print_cmd64x_get_info(p, dev, i);
187 return p-buffer; /* => must be less than 4k! */
190 #endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) */
193 * This routine writes the prepared setup/active/recovery counts
194 * for a drive into the cmd646 chipset registers to active them.
196 static void program_drive_counts (ide_drive_t *drive, int setup_count, int active_count, int recovery_count)
199 struct pci_dev *dev = HWIF(drive)->pci_dev;
200 ide_drive_t *drives = HWIF(drive)->drives;
202 static const u8 setup_counts[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0};
203 static const u8 recovery_counts[] =
204 {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0};
205 static const u8 arttim_regs[2][2] = {
206 { ARTTIM0, ARTTIM1 },
207 { ARTTIM23, ARTTIM23 }
209 static const u8 drwtim_regs[2][2] = {
210 { DRWTIM0, DRWTIM1 },
213 int channel = (int) HWIF(drive)->channel;
214 int slave = (drives != drive); /* Is this really the best way to determine this?? */
216 cmdprintk("program_drive_count parameters = s(%d),a(%d),r(%d),p(%d)\n",
217 setup_count, active_count, recovery_count, drive->present);
219 * Set up address setup count registers.
220 * Primary interface has individual count/timing registers for
221 * each drive. Secondary interface has one common set of registers,
222 * for address setup so we merge these timings, using the slowest
226 drive->drive_data = setup_count;
227 setup_count = max(drives[0].drive_data,
228 drives[1].drive_data);
229 cmdprintk("Secondary interface, setup_count = %d\n",
234 * Convert values to internal chipset representation
236 setup_count = (setup_count > 5) ? 0xc0 : (int) setup_counts[setup_count];
237 active_count &= 0xf; /* Remember, max value is 16 */
238 recovery_count = (int) recovery_counts[recovery_count];
240 cmdprintk("Final values = %d,%d,%d\n",
241 setup_count, active_count, recovery_count);
244 * Now that everything is ready, program the new timings
246 local_irq_save(flags);
248 * Program the address_setup clocks into ARTTIM reg,
249 * and then the active/recovery counts into the DRWTIM reg
251 (void) pci_read_config_byte(dev, arttim_regs[channel][slave], &temp_b);
252 (void) pci_write_config_byte(dev, arttim_regs[channel][slave],
253 ((u8) setup_count) | (temp_b & 0x3f));
254 (void) pci_write_config_byte(dev, drwtim_regs[channel][slave],
255 (u8) ((active_count << 4) | recovery_count));
256 cmdprintk ("Write %x to %x\n",
257 ((u8) setup_count) | (temp_b & 0x3f),
258 arttim_regs[channel][slave]);
259 cmdprintk ("Write %x to %x\n",
260 (u8) ((active_count << 4) | recovery_count),
261 drwtim_regs[channel][slave]);
262 local_irq_restore(flags);
266 * This routine selects drive's best PIO mode, calculates setup/active/recovery
267 * counts, and then writes them into the chipset registers.
269 static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted)
271 int setup_time, active_time, recovery_time;
272 int clock_time, pio_mode, cycle_time;
273 u8 recovery_count2, cycle_count;
274 int setup_count, active_count, recovery_count;
275 int bus_speed = system_bus_clock();
278 pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, &d);
279 cycle_time = d.cycle_time;
282 * I copied all this complicated stuff from cmd640.c and made a few
283 * minor changes. For now I am just going to pray that it is correct.
285 setup_time = ide_pio_timings[pio_mode].setup_time;
286 active_time = ide_pio_timings[pio_mode].active_time;
287 recovery_time = cycle_time - (setup_time + active_time);
288 clock_time = 1000 / bus_speed;
289 cycle_count = (cycle_time + clock_time - 1) / clock_time;
291 setup_count = (setup_time + clock_time - 1) / clock_time;
293 active_count = (active_time + clock_time - 1) / clock_time;
295 recovery_count = (recovery_time + clock_time - 1) / clock_time;
296 recovery_count2 = cycle_count - (setup_count + active_count);
297 if (recovery_count2 > recovery_count)
298 recovery_count = recovery_count2;
299 if (recovery_count > 16) {
300 active_count += recovery_count - 16;
303 if (active_count > 16)
304 active_count = 16; /* maximum allowed by cmd646 */
306 program_drive_counts (drive, setup_count, active_count, recovery_count);
308 cmdprintk("%s: PIO mode wanted %d, selected %d (%dns)%s, "
310 drive->name, mode_wanted, pio_mode, cycle_time,
311 d.overridden ? " (overriding vendor mode)" : "",
312 setup_count, active_count, recovery_count);
318 * Attempts to set drive's PIO mode.
319 * Special cases are 8: prefetch off, 9: prefetch on (both never worked),
320 * and 255: auto-select best mode (used at boot time).
322 static void cmd64x_tune_drive (ide_drive_t *drive, u8 pio)
325 * Filter out the prefetch control values
326 * to prevent PIO5 from being programmed
328 if (pio == 8 || pio == 9)
331 pio = cmd64x_tune_pio(drive, pio);
332 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
335 static u8 cmd64x_ratemask (ide_drive_t *drive)
337 struct pci_dev *dev = HWIF(drive)->pci_dev;
340 switch(dev->device) {
341 case PCI_DEVICE_ID_CMD_649:
344 case PCI_DEVICE_ID_CMD_648:
347 case PCI_DEVICE_ID_CMD_643:
350 case PCI_DEVICE_ID_CMD_646:
352 unsigned int class_rev = 0;
353 pci_read_config_dword(dev,
354 PCI_CLASS_REVISION, &class_rev);
357 * UltraDMA only supported on PCI646U and PCI646U2, which
358 * correspond to revisions 0x03, 0x05 and 0x07 respectively.
359 * Actually, although the CMD tech support people won't
360 * tell me the details, the 0x03 revision cannot support
361 * UDMA correctly without hardware modifications, and even
362 * then it only works with Quantum disks due to some
363 * hold time assumptions in the 646U part which are fixed
366 * So we only do UltraDMA on revision 0x05 and 0x07 chipsets.
379 if (!eighty_ninty_three(drive))
380 mode = min(mode, (u8)1);
384 static int cmd64x_tune_chipset (ide_drive_t *drive, u8 xferspeed)
386 ide_hwif_t *hwif = HWIF(drive);
387 struct pci_dev *dev = hwif->pci_dev;
389 u8 unit = (drive->select.b.unit & 0x01);
390 u8 regU = 0, pciU = (hwif->channel) ? UDIDETCR1 : UDIDETCR0;
391 u8 regD = 0, pciD = (hwif->channel) ? BMIDESR1 : BMIDESR0;
393 u8 speed = ide_rate_filter(cmd64x_ratemask(drive), xferspeed);
395 if (speed >= XFER_SW_DMA_0) {
396 (void) pci_read_config_byte(dev, pciD, ®D);
397 (void) pci_read_config_byte(dev, pciU, ®U);
398 regD &= ~(unit ? 0x40 : 0x20);
399 regU &= ~(unit ? 0xCA : 0x35);
400 (void) pci_write_config_byte(dev, pciD, regD);
401 (void) pci_write_config_byte(dev, pciU, regU);
402 (void) pci_read_config_byte(dev, pciD, ®D);
403 (void) pci_read_config_byte(dev, pciU, ®U);
407 case XFER_UDMA_5: regU |= (unit ? 0x0A : 0x05); break;
408 case XFER_UDMA_4: regU |= (unit ? 0x4A : 0x15); break;
409 case XFER_UDMA_3: regU |= (unit ? 0x8A : 0x25); break;
410 case XFER_UDMA_2: regU |= (unit ? 0x42 : 0x11); break;
411 case XFER_UDMA_1: regU |= (unit ? 0x82 : 0x21); break;
412 case XFER_UDMA_0: regU |= (unit ? 0xC2 : 0x31); break;
413 case XFER_MW_DMA_2: regD |= (unit ? 0x40 : 0x10); break;
414 case XFER_MW_DMA_1: regD |= (unit ? 0x80 : 0x20); break;
415 case XFER_MW_DMA_0: regD |= (unit ? 0xC0 : 0x30); break;
416 case XFER_SW_DMA_2: regD |= (unit ? 0x40 : 0x10); break;
417 case XFER_SW_DMA_1: regD |= (unit ? 0x80 : 0x20); break;
418 case XFER_SW_DMA_0: regD |= (unit ? 0xC0 : 0x30); break;
425 (void) cmd64x_tune_pio(drive, speed - XFER_PIO_0);
432 if (speed >= XFER_SW_DMA_0) {
433 (void) pci_write_config_byte(dev, pciU, regU);
434 regD |= (unit ? 0x40 : 0x20);
435 (void) pci_write_config_byte(dev, pciD, regD);
438 return (ide_config_drive_speed(drive, speed));
441 static int config_chipset_for_dma (ide_drive_t *drive)
443 u8 speed = ide_dma_speed(drive, cmd64x_ratemask(drive));
448 if (cmd64x_tune_chipset(drive, speed))
451 return ide_dma_enable(drive);
454 static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
456 if (ide_use_dma(drive) && config_chipset_for_dma(drive))
459 if (ide_use_fast_pio(drive))
460 cmd64x_tune_drive(drive, 255);
465 static int cmd64x_alt_dma_status (struct pci_dev *dev)
467 switch(dev->device) {
468 case PCI_DEVICE_ID_CMD_648:
469 case PCI_DEVICE_ID_CMD_649:
477 static int cmd64x_ide_dma_end (ide_drive_t *drive)
479 u8 dma_stat = 0, dma_cmd = 0;
480 ide_hwif_t *hwif = HWIF(drive);
481 struct pci_dev *dev = hwif->pci_dev;
483 drive->waiting_for_dma = 0;
484 /* read DMA command state */
485 dma_cmd = inb(hwif->dma_command);
487 outb(dma_cmd & ~1, hwif->dma_command);
489 dma_stat = inb(hwif->dma_status);
490 /* clear the INTR & ERROR bits */
491 outb(dma_stat | 6, hwif->dma_status);
492 if (cmd64x_alt_dma_status(dev)) {
494 u8 dma_mask = (hwif->channel) ? ARTTIM23_INTR_CH1 :
496 u8 dma_reg = (hwif->channel) ? ARTTIM2 : CFR;
497 (void) pci_read_config_byte(dev, dma_reg, &dma_intr);
498 /* clear the INTR bit */
499 (void) pci_write_config_byte(dev, dma_reg, dma_intr|dma_mask);
501 /* purge DMA mappings */
502 ide_destroy_dmatable(drive);
503 /* verify good DMA status */
504 return (dma_stat & 7) != 4;
507 static int cmd64x_ide_dma_test_irq (ide_drive_t *drive)
509 ide_hwif_t *hwif = HWIF(drive);
510 struct pci_dev *dev = hwif->pci_dev;
511 u8 dma_alt_stat = 0, mask = (hwif->channel) ? MRDMODE_INTR_CH1 :
513 u8 dma_stat = inb(hwif->dma_status);
515 (void) pci_read_config_byte(dev, MRDMODE, &dma_alt_stat);
517 printk("%s: dma_stat: 0x%02x dma_alt_stat: "
518 "0x%02x mask: 0x%02x\n", drive->name,
519 dma_stat, dma_alt_stat, mask);
521 if (!(dma_alt_stat & mask))
524 /* return 1 if INTR asserted */
525 if ((dma_stat & 4) == 4)
532 * ASUS P55T2P4D with CMD646 chipset revision 0x01 requires the old
533 * event order for DMA transfers.
536 static int cmd646_1_ide_dma_end (ide_drive_t *drive)
538 ide_hwif_t *hwif = HWIF(drive);
539 u8 dma_stat = 0, dma_cmd = 0;
541 drive->waiting_for_dma = 0;
543 dma_stat = inb(hwif->dma_status);
544 /* read DMA command state */
545 dma_cmd = inb(hwif->dma_command);
547 outb(dma_cmd & ~1, hwif->dma_command);
548 /* clear the INTR & ERROR bits */
549 outb(dma_stat | 6, hwif->dma_status);
550 /* and free any DMA resources */
551 ide_destroy_dmatable(drive);
552 /* verify good DMA status */
553 return (dma_stat & 7) != 4;
556 static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const char *name)
561 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
564 switch(dev->device) {
565 case PCI_DEVICE_ID_CMD_643:
567 case PCI_DEVICE_ID_CMD_646:
568 printk(KERN_INFO "%s: chipset revision 0x%02X, ", name, class_rev);
572 printk("UltraDMA Capable");
575 printk("MultiWord DMA Force Limited");
579 printk("MultiWord DMA Limited, IRQ workaround enabled");
584 case PCI_DEVICE_ID_CMD_648:
585 case PCI_DEVICE_ID_CMD_649:
591 /* Set a good latency timer and cache line size value. */
592 (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
593 /* FIXME: pci_set_master() to ensure a good latency timer value */
595 /* Setup interrupts. */
596 (void) pci_read_config_byte(dev, MRDMODE, &mrdmode);
598 (void) pci_write_config_byte(dev, MRDMODE, mrdmode);
600 /* Use MEMORY READ LINE for reads.
601 * NOTE: Although not mentioned in the PCI0646U specs,
602 * these bits are write only and won't be read
603 * back as set or not. The PCI0646U2 specs clarify
606 (void) pci_write_config_byte(dev, MRDMODE, mrdmode | 0x02);
608 /* Set reasonable active/recovery/address-setup values. */
609 (void) pci_write_config_byte(dev, ARTTIM0, 0x40);
610 (void) pci_write_config_byte(dev, DRWTIM0, 0x3f);
611 (void) pci_write_config_byte(dev, ARTTIM1, 0x40);
612 (void) pci_write_config_byte(dev, DRWTIM1, 0x3f);
614 (void) pci_write_config_byte(dev, ARTTIM23, 0x1c);
616 (void) pci_write_config_byte(dev, ARTTIM23, 0x5c);
618 (void) pci_write_config_byte(dev, DRWTIM23, 0x3f);
619 (void) pci_write_config_byte(dev, DRWTIM3, 0x3f);
621 (void) pci_write_config_byte(dev, UDIDETCR0, 0xf0);
622 #endif /* CONFIG_PPC */
624 #if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS)
626 cmd_devs[n_cmd_devs++] = dev;
630 ide_pci_create_host_proc("cmd64x", cmd64x_get_info);
632 #endif /* DISPLAY_CMD64X_TIMINGS && CONFIG_PROC_FS */
637 static unsigned int __devinit ata66_cmd64x(ide_hwif_t *hwif)
639 u8 ata66 = 0, mask = (hwif->channel) ? 0x02 : 0x01;
641 switch(hwif->pci_dev->device) {
642 case PCI_DEVICE_ID_CMD_643:
643 case PCI_DEVICE_ID_CMD_646:
648 pci_read_config_byte(hwif->pci_dev, BMIDECSR, &ata66);
649 return (ata66 & mask) ? 1 : 0;
652 static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
654 struct pci_dev *dev = hwif->pci_dev;
655 unsigned int class_rev;
658 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
661 hwif->tuneproc = &cmd64x_tune_drive;
662 hwif->speedproc = &cmd64x_tune_chipset;
664 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
671 hwif->ultra_mask = 0x3f;
672 hwif->mwdma_mask = 0x07;
673 hwif->swdma_mask = 0x07;
675 if (dev->device == PCI_DEVICE_ID_CMD_643)
676 hwif->ultra_mask = 0x80;
677 if (dev->device == PCI_DEVICE_ID_CMD_646)
678 hwif->ultra_mask = (class_rev > 0x04) ? 0x07 : 0x80;
679 if (dev->device == PCI_DEVICE_ID_CMD_648)
680 hwif->ultra_mask = 0x1f;
682 hwif->ide_dma_check = &cmd64x_config_drive_for_dma;
683 if (!(hwif->udma_four))
684 hwif->udma_four = ata66_cmd64x(hwif);
686 if (dev->device == PCI_DEVICE_ID_CMD_646) {
687 hwif->chipset = ide_cmd646;
688 if (class_rev == 0x01) {
689 hwif->ide_dma_end = &cmd646_1_ide_dma_end;
691 hwif->ide_dma_end = &cmd64x_ide_dma_end;
692 hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq;
695 hwif->ide_dma_end = &cmd64x_ide_dma_end;
696 hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq;
702 hwif->drives[0].autodma = hwif->autodma;
703 hwif->drives[1].autodma = hwif->autodma;
706 static ide_pci_device_t cmd64x_chipsets[] __devinitdata = {
709 .init_chipset = init_chipset_cmd64x,
710 .init_hwif = init_hwif_cmd64x,
713 .bootable = ON_BOARD,
716 .init_chipset = init_chipset_cmd64x,
717 .init_hwif = init_hwif_cmd64x,
720 .enablebits = {{0x00,0x00,0x00}, {0x51,0x80,0x80}},
721 .bootable = ON_BOARD,
724 .init_chipset = init_chipset_cmd64x,
725 .init_hwif = init_hwif_cmd64x,
728 .bootable = ON_BOARD,
731 .init_chipset = init_chipset_cmd64x,
732 .init_hwif = init_hwif_cmd64x,
735 .bootable = ON_BOARD,
739 static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
741 return ide_setup_pci_device(dev, &cmd64x_chipsets[id->driver_data]);
744 static struct pci_device_id cmd64x_pci_tbl[] = {
745 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_643, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
746 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
747 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_648, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
748 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3},
751 MODULE_DEVICE_TABLE(pci, cmd64x_pci_tbl);
753 static struct pci_driver driver = {
754 .name = "CMD64x_IDE",
755 .id_table = cmd64x_pci_tbl,
756 .probe = cmd64x_init_one,
759 static int __init cmd64x_ide_init(void)
761 return ide_pci_register_driver(&driver);
764 module_init(cmd64x_ide_init);
766 MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick");
767 MODULE_DESCRIPTION("PCI driver module for CMD64x IDE");
768 MODULE_LICENSE("GPL");