62 #include <linux/types.h>
63 #include <linux/module.h>
64 #include <linux/slab.h>
65 #include <linux/pci.h>
69 #define DRV_NAME "it821x"
71 #define QUIRK_VORTEX86 1
101 static int it8212_noraid;
116 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
124 conf = timing & 0xFF;
126 pci_write_config_byte(dev, 0x54 + 4 * channel, conf);
142 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
150 conf = timing & 0xFF;
153 pci_write_config_byte(dev, 0x56 + 4 * channel + unit, conf);
155 pci_write_config_byte(dev, 0x56 + 4 * channel, conf);
156 pci_write_config_byte(dev, 0x56 + 4 * channel + 1, conf);
168 static void it821x_clock_strategy(
ide_drive_t *drive)
172 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
175 u8 unit = drive->
dn & 1,
v;
177 if(itdev->
want[0][0] > itdev->
want[1][0]) {
178 clock = itdev->
want[0][1];
179 altclock = itdev->
want[1][1];
181 clock = itdev->
want[1][1];
182 altclock = itdev->
want[0][1];
207 pci_read_config_byte(dev, 0x50, &
v);
210 pci_write_config_byte(dev, 0x50,
v);
217 it821x_program_udma(pair, itdev->
udma[1-unit]);
218 it821x_program(pair, itdev->
pio[1-unit]);
225 it821x_program_udma(drive, itdev->
udma[unit]);
226 it821x_program(drive, itdev->
pio[unit]);
241 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
244 u8 unit = drive->
dn & 1, set_pio =
pio;
247 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
258 if (pair_pio < set_pio)
263 itdev->
want[
unit][1] = pio_want[set_pio];
265 itdev->
pio[
unit] = pio_timings[set_pio];
266 it821x_clock_strategy(drive);
267 it821x_program(drive, itdev->
pio[unit]);
281 static void it821x_tune_mwdma(
ide_drive_t *drive,
u8 mode_wanted)
285 struct it821x_dev *itdev = (
void *)ide_get_hwifdata(hwif);
286 u8 unit = drive->
dn & 1, channel = hwif->
channel, conf;
288 static u16 dma[] = { 0x8866, 0x3222, 0x3121 };
291 itdev->
want[
unit][1] = mwdma_want[mode_wanted];
297 pci_read_config_byte(dev, 0x50, &conf);
299 conf |= channel ? 0x60: 0x18;
301 conf |= 1 << (3 + 2 * channel +
unit);
302 pci_write_config_byte(dev, 0x50, conf);
304 it821x_clock_strategy(drive);
318 static void it821x_tune_udma(
ide_drive_t *drive,
u8 mode_wanted)
322 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
323 u8 unit = drive->
dn & 1, channel = hwif->
channel, conf;
325 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 };
328 itdev->
want[
unit][1] = udma_want[mode_wanted];
331 itdev->
udma[
unit] = udma[mode_wanted];
336 pci_read_config_byte(dev, 0x50, &conf);
338 conf &= channel ? 0x9F: 0xE7;
340 conf &= ~ (1 << (3 + 2 * channel +
unit));
341 pci_write_config_byte(dev, 0x50, conf);
343 it821x_clock_strategy(drive);
344 it821x_program_udma(drive, itdev->
udma[unit]);
364 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
365 u8 unit = drive->
dn & 1;
368 it821x_program(drive, itdev->
mwdma[unit]);
370 it821x_program_udma(drive, itdev->
udma[unit]);
386 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
388 u8 unit = drive->
dn & 1;
391 it821x_program(drive, itdev->
pio[unit]);
465 "Integrated Technology Express")) {
474 drive->
name,
id[147] ?
"Bootable " :
"",
511 static struct ide_dma_ops it821x_pass_through_dma_ops = {
514 .dma_start = it821x_dma_start,
515 .dma_end = it821x_dma_end,
539 ide_set_hwifdata(hwif, idev);
541 pci_read_config_byte(dev, 0x50, &conf);
551 if (conf & (1 << (1 + hwif->
channel)))
567 if (idev->
smart == 0)
569 "workarounds activated\n", pci_name(dev));
572 if (idev->
smart == 0) {
574 hwif->
dma_ops = &it821x_pass_through_dma_ops;
591 static void it8212_disable_raid(
struct pci_dev *dev)
594 pci_write_config_byte(dev, 0x5E, 0x01);
597 pci_write_config_byte(dev, 0x50, 0x00);
601 pci_write_config_word(dev, 0x40, 0xA0F3);
603 pci_write_config_dword(dev,0x4C, 0x02040204);
604 pci_write_config_byte(dev, 0x42, 0x36);
608 static int init_chipset_it821x(
struct pci_dev *dev)
611 static char *
mode[2] = {
"pass through",
"smart" };
617 it8212_disable_raid(dev);
619 pci_read_config_byte(dev, 0x50, &conf);
621 pci_name(dev), mode[conf & 1]);
627 .set_pio_mode = it821x_set_pio_mode,
628 .set_dma_mode = it821x_set_dma_mode,
629 .quirkproc = it821x_quirkproc,
630 .cable_detect = it821x_cable_detect,
635 .init_chipset = init_chipset_it821x,
636 .init_hwif = init_hwif_it821x,
637 .port_ops = &it821x_port_ops,
655 itdevs = kzalloc(2 *
sizeof(*itdevs),
GFP_KERNEL);
656 if (itdevs ==
NULL) {
661 itdevs->
quirks =
id->driver_data;
672 struct ide_host *host = pci_get_drvdata(dev);
688 static struct pci_driver it821x_pci_driver = {
689 .name =
"ITE821x IDE",
690 .id_table = it821x_pci_tbl,
691 .probe = it821x_init_one,
697 static int __init it821x_ide_init(
void)
702 static void __exit it821x_ide_exit(
void)