14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/pci.h>
22 #define DRV_NAME "cmd64x"
28 #define CFR_INTR_CH0 0x04
36 #define ARTTIM23_DIS_RA2 0x04
37 #define ARTTIM23_DIS_RA3 0x08
38 #define ARTTIM23_INTR_CH1 0x10
45 #define MRDMODE_INTR_CH0 0x04
46 #define MRDMODE_INTR_CH1 0x08
47 #define UDIDETCR0 0x73
51 #define UDIDETCR1 0x7B
59 const unsigned long T = 1000000 / bus_speed;
60 static const u8 recovery_values[] =
61 {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0};
62 static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0};
88 pci_write_config_byte(dev, drwtim_regs[drive->
dn],
120 (
void) pci_read_config_byte (dev, arttim_regs[drive->
dn], &arttim);
124 arttim |= setup_values[t.
setup];
125 (
void) pci_write_config_byte(dev, arttim_regs[drive->
dn], arttim);
141 if (pio == 8 || pio == 9)
144 cmd64x_program_timings(drive,
XFER_PIO_0 + pio);
154 pci_read_config_byte(dev, pciU, ®U);
155 regU &= ~(unit ? 0xCA : 0x35);
159 regU |= unit ? 0x0A : 0x05;
162 regU |= unit ? 0x4A : 0x15;
165 regU |= unit ? 0x8A : 0x25;
168 regU |= unit ? 0x42 : 0x11;
171 regU |= unit ? 0x82 : 0x21;
174 regU |= unit ? 0xC2 : 0x31;
179 cmd64x_program_timings(drive, speed);
183 pci_write_config_byte(dev, pciU, regU);
193 u8 mrdmode =
inb(base + 1);
209 (
void) pci_read_config_byte(dev, irq_reg, &irq_stat);
211 (
void) pci_write_config_byte(dev, irq_reg, irq_stat | irq_mask);
220 u8 mrdmode =
inb(base + 1);
222 pr_debug(
"%s: mrdmode: 0x%02x irq_mask: 0x%02x\n",
223 hwif->
name, mrdmode, irq_mask);
225 return (mrdmode & irq_mask) ? 1 : 0;
236 (
void) pci_read_config_byte(dev, irq_reg, &irq_stat);
238 pr_debug(
"%s: irq_stat: 0x%02x irq_mask: 0x%02x\n",
239 hwif->
name, irq_stat, irq_mask);
241 return (irq_stat & irq_mask) ? 1 : 0;
252 u8 dma_stat = 0, dma_cmd = 0;
263 return (dma_stat & 7) != 4;
266 static int init_chipset_cmd64x(
struct pci_dev *dev)
281 (
void) pci_read_config_byte (dev,
MRDMODE, &mrdmode);
283 (
void) pci_write_config_byte(dev,
MRDMODE, (mrdmode | 0x02));
296 pci_read_config_byte(dev,
BMIDECSR, &bmidecsr);
304 .set_pio_mode = cmd64x_set_pio_mode,
305 .set_dma_mode = cmd64x_set_dma_mode,
306 .clear_irq = cmd64x_clear_irq,
307 .test_irq = cmd64x_test_irq,
308 .cable_detect = cmd64x_cable_detect,
312 .set_pio_mode = cmd64x_set_pio_mode,
313 .set_dma_mode = cmd64x_set_dma_mode,
314 .clear_irq = cmd648_clear_irq,
315 .test_irq = cmd648_test_irq,
316 .cable_detect = cmd64x_cable_detect,
319 static const struct ide_dma_ops cmd646_rev1_dma_ops = {
323 .dma_end = cmd646_1_dma_end,
333 .init_chipset = init_chipset_cmd64x,
334 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}},
335 .port_ops = &cmd64x_port_ops,
345 .init_chipset = init_chipset_cmd64x,
346 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
347 .port_ops = &cmd648_port_ops,
356 .init_chipset = init_chipset_cmd64x,
357 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
358 .port_ops = &cmd648_port_ops,
366 .init_chipset = init_chipset_cmd64x,
367 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
368 .port_ops = &cmd648_port_ops,
379 u8 idx =
id->driver_data;
381 d = cmd64x_chipsets[
idx];
404 d.enablebits[0].reg = 0;
405 d.port_ops = &cmd64x_port_ops;
407 d.dma_ops = &cmd646_rev1_dma_ops;
424 static struct pci_driver cmd64x_pci_driver = {
425 .name =
"CMD64x_IDE",
426 .id_table = cmd64x_pci_tbl,
427 .probe = cmd64x_init_one,
433 static int __init cmd64x_ide_init(
void)
438 static void __exit cmd64x_ide_exit(
void)
446 MODULE_AUTHOR(
"Eddie Dost, David Miller, Andre Hedrick, Bartlomiej Zolnierkiewicz");