30 #include <linux/module.h>
31 #include <linux/types.h>
32 #include <linux/kernel.h>
33 #include <linux/pci.h>
40 #define DRV_NAME "alim15x3"
47 static u8 m5229_revision;
48 static u8 chip_is_1543c_e;
54 int pio_fifo = 0x54 + hwif->
channel;
56 int shift = 4 * (drive->
dn & 1);
58 pci_read_config_byte(pdev, pio_fifo, &fifo);
59 fifo &= ~(0x0F << shift);
60 fifo |= (on << shift);
61 pci_write_config_byte(pdev, pio_fifo, fifo);
69 int udmat = 0x56 + hwif->
channel;
74 pci_read_config_byte(dev, udmat, &udma);
75 udma &= ~(0x0F << shift);
76 udma |= ultra << shift;
77 pci_write_config_byte(dev, udmat, udma);
88 pci_write_config_byte(dev, port, t->
setup);
89 pci_write_config_byte(dev, port + 1, (t->
act8b << 4) | t->
rec8b);
90 pci_write_config_byte(dev, port + unit + 2,
106 unsigned long T = 1000000 / bus_speed;
126 ali_fifo_control(hwif, drive, (drive->
media ==
ide_disk) ? 0x05 : 0x00);
128 ali_program_timings(hwif, drive, &t, 0);
145 if (m5229_revision > 0x20 && m5229_revision < 0xC2) {
148 if (chip_is_1543c_e &&
153 return drive->
hwif->ultra_mask;
166 static u8 udma_timing[7] = { 0xC, 0xB, 0xA, 0x9, 0x8, 0xF, 0xD };
170 unsigned long T = 1000000 / bus_speed;
190 ali_program_timings(hwif, drive, &t, 0);
192 ali_program_timings(hwif, drive,
NULL,
195 pci_read_config_byte(dev, 0x4b, &tmpbyte);
197 pci_write_config_byte(dev, 0x4b, tmpbyte);
212 if (m5229_revision < 0xC2 && drive->media !=
ide_disk) {
227 static int init_chipset_ali15x3(
struct pci_dev *dev)
239 if (m5229_revision < 0xC2) {
245 pci_read_config_byte(dev, 0x4b, &tmpbyte);
249 pci_write_config_byte(dev, 0x4b, tmpbyte & 0x7F);
253 if (m5229_revision >= 0x20 && isa_dev) {
254 pci_read_config_byte(isa_dev, 0x5e, &tmpbyte);
255 chip_is_1543c_e = ((tmpbyte & 0x1e) == 0x12) ? 1: 0;
271 pci_read_config_byte(dev, 0x4b, &tmpbyte);
272 pci_write_config_byte(dev, 0x4b, tmpbyte | 0x08);
283 if (m5229_revision < 0xC5 && isa_dev)
289 pci_read_config_byte(isa_dev, 0x79, &tmpbyte);
290 if (m5229_revision == 0xC2) {
294 pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x04);
295 }
else if (m5229_revision >= 0xC3) {
299 pci_write_config_byte(isa_dev, 0x79, tmpbyte | 0x02);
314 if (m5229_revision >= 0x20) {
315 pci_read_config_byte(dev, 0x53, &tmpbyte);
317 if (m5229_revision <= 0x20)
318 tmpbyte = (tmpbyte & (~0x02)) | 0x01;
319 else if (m5229_revision == 0xc7 || m5229_revision == 0xc8)
324 pci_write_config_byte(dev, 0x53, tmpbyte);
338 .ident =
"HP Pavilion N5430",
345 .ident =
"Toshiba Satellite S1800-814",
354 static int ali_cable_override(
struct pci_dev *pdev)
386 if (m5229_revision >= 0xC2) {
396 if (ali_cable_override(dev))
399 pci_read_config_byte(dev, 0x4a, &tmpbyte);
400 if ((tmpbyte & (1 << hwif->
channel)) == 0)
408 #ifndef CONFIG_SPARC64
422 1, 11, 0, 12, 0, 14, 0, 15 };
429 pci_read_config_byte(isa_dev, 0x58, &ideic);
432 ideic = ideic & 0x03;
435 if ((hwif->
channel && ideic == 0x03) ||
440 pci_read_config_byte(isa_dev, 0x44, &inmir);
441 inmir = inmir & 0x0f;
442 irq = irq_routing_table[inmir];
443 }
else if (hwif->
channel && !(ideic & 0x01)) {
447 pci_read_config_byte(isa_dev, 0x75, &inmir);
448 inmir = inmir & 0x0f;
449 irq = irq_routing_table[inmir];
456 #define init_hwif_ali15x3 NULL
471 unsigned long base = ide_pci_dma_base(hwif, d);
478 if (ide_pci_check_simplex(hwif, d) < 0)
481 if (ide_pci_set_master(dev, d->
name) < 0)
485 outb(
inb(base + 2) & 0x60, base + 2);
488 hwif->
name, base, base + 7);
497 .set_pio_mode = ali_set_pio_mode,
498 .set_dma_mode = ali_set_dma_mode,
499 .udma_filter = ali_udma_filter,
500 .cable_detect = ali_cable_detect,
510 .dma_check = ali_dma_check,
517 .init_chipset = init_chipset_ali15x3,
518 .init_hwif = init_hwif_ali15x3,
519 .init_dma = init_dma_ali15x3,
520 .port_ops = &ali_port_ops,
550 else if (rev == 0xC2 || rev == 0xC3)
552 else if (rev == 0xC4)
578 static struct pci_driver alim15x3_pci_driver = {
579 .name =
"ALI15x3_IDE",
580 .id_table = alim15x3_pci_tbl,
581 .probe = alim15x3_init_one,
587 static int __init ali15x3_ide_init(
void)
592 static void __exit ali15x3_ide_exit(
void)
600 MODULE_AUTHOR(
"Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox, Bartlomiej Zolnierkiewicz");