27 #include <linux/module.h>
28 #include <linux/kernel.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
35 #ifdef CONFIG_PPC_CHRP
36 #include <asm/processor.h>
39 #define DRV_NAME "via82cxxx"
41 #define VIA_IDE_ENABLE 0x40
42 #define VIA_IDE_CONFIG 0x41
43 #define VIA_FIFO_CONFIG 0x43
44 #define VIA_MISC_1 0x44
45 #define VIA_MISC_2 0x45
46 #define VIA_MISC_3 0x46
47 #define VIA_DRIVE_TIMING 0x48
48 #define VIA_8BIT_TIMING 0x4e
49 #define VIA_ADDRESS_SETUP 0x4c
50 #define VIA_UDMA_TIMING 0x50
52 #define VIA_BAD_PREQ 0x01
53 #define VIA_BAD_CLK66 0x02
54 #define VIA_SET_FIFO 0x04
55 #define VIA_NO_UNMASK 0x08
56 #define VIA_BAD_ID 0x10
57 #define VIA_BAD_AST 0x20
58 #define VIA_SATA_PATA 0x80
68 static struct via_isa_bridge {
75 } via_isa_bridges[] = {
108 static char *via_dma[] = {
"16",
"25",
"33",
"44",
"66",
"100",
"133" };
134 t = (t & ~(3 << ((3 -
dn) << 1))) | ((
clamp_val(timing->
setup, 1, 4) - 1) << ((3 - dn) << 1));
183 struct ide_host *host = pci_get_drvdata(dev);
189 T = 1000000000 / via_clock;
206 via_set_speed(hwif, drive->
dn, &t);
220 via_set_drive(hwif, drive);
223 static struct via_isa_bridge *via_config_find(
struct pci_dev **
isa)
225 struct via_isa_bridge *via_config;
227 for (via_config = via_isa_bridges;
231 via_config->id,
NULL))) {
233 if ((*isa)->revision >= via_config->rev_min &&
234 (*isa)->revision <= via_config->rev_max)
251 for (i = 24; i >= 0; i -= 8)
252 if (((u >> (i & 16)) & 8) &&
254 (((u >> i) & 7) < 2)) {
259 vdev->
via_80w |= (1 << (1 - (i >> 4)));
264 for (i = 24; i >= 0; i -= 8)
265 if (((u >> i) & 0x10) ||
266 (((u >> i) & 0x20) &&
267 (((u >> i) & 7) < 4))) {
271 vdev->
via_80w |= (1 << (1 - (i >> 4)));
276 for (i = 24; i >= 0; i -= 8)
277 if (((u >> i) & 0x10) ||
278 (((u >> i) & 0x20) &&
279 (((u >> i) & 7) < 6))) {
283 vdev->
via_80w |= (1 << (1 - (i >> 4)));
297 static int init_chipset_via82cxxx(
struct pci_dev *dev)
299 struct ide_host *host = pci_get_drvdata(dev);
301 struct via_isa_bridge *via_config = vdev->
via_config;
310 via_cable_detect(vdev, u);
312 if (via_config->udma_mask ==
ATA_UDMA4) {
342 case 2: t |= 0x00;
break;
343 case 1: t |= 0x60;
break;
344 case 3: t |= 0x20;
break;
359 .ident =
"Acer Ferrari 3400",
368 static int via_cable_override(
struct pci_dev *pdev)
385 struct ide_host *host = pci_get_drvdata(pdev);
388 if (via_cable_override(pdev))
401 .set_pio_mode = via_set_pio_mode,
402 .set_dma_mode = via_set_drive,
403 .cable_detect = via82cxxx_cable_detect,
408 .init_chipset = init_chipset_via82cxxx,
409 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
410 .port_ops = &via_port_ops,
422 struct via_isa_bridge *via_config;
425 u8 idx =
id->driver_data;
428 d = via82cxxx_chipset;
433 via_config = via_config_find(&isa);
439 pci_name(dev), via_config->name, isa->
revision,
440 via_config->udma_mask ?
"U" :
"MW",
441 via_dma[via_config->udma_mask ?
442 (fls(via_config->udma_mask) - 1) : 0]);
452 case 33000: via_clock = 33333;
break;
453 case 37000: via_clock = 37500;
break;
454 case 41000: via_clock = 41666;
break;
459 "impossible (%d), using 33 MHz instead.\n", via_clock);
464 d.enablebits[1].reg = d.enablebits[0].reg = 0;
474 d.udma_mask = via_config->udma_mask;
494 struct ide_host *host = pci_get_drvdata(dev);
515 .id_table = via_pci_tbl,
516 .probe = via_init_one,
522 static int __init via_ide_init(
void)
527 static void __exit via_ide_exit(
void)
535 MODULE_AUTHOR(
"Vojtech Pavlik, Bartlomiej Zolnierkiewicz, Michel Aubry, Jeff Garzik, Andre Hedrick");