10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/pci.h>
16 #include <linux/device.h>
21 #define DRV_NAME "pata_it8213"
22 #define DRV_VERSION "0.0.3"
33 static int it8213_pre_reset(
struct ata_link *
link,
unsigned long deadline)
35 static const struct pci_bits it8213_enable_bits[] = {
36 { 0x41
U, 1
U, 0x80
UL, 0x80UL },
40 if (!pci_test_config_bits(pdev, &it8213_enable_bits[ap->
port_no]))
54 static int it8213_cable_detect(
struct ata_port *ap)
58 pci_read_config_byte(pdev, 0x42, &tmp);
79 unsigned int master_port = ap->
port_no ? 0x42 : 0x40;
103 pci_read_config_word(dev, master_port, &master_data);
106 if (adev->
devno == 0) {
107 master_data &= 0xCCF0;
109 master_data |= (timings[
pio][0] << 12) |
110 (timings[pio][1] << 8);
114 master_data &= 0xFF0F;
115 master_data |= (control << 4);
118 pci_read_config_byte(dev, 0x44, &slave_data);
120 slave_data |= (timings[
pio][0] << 2) | timings[pio][1];
121 pci_write_config_byte(dev, 0x44, slave_data);
124 master_data |= 0x4000;
125 pci_write_config_word(dev, master_port, master_data);
149 u8 timings[][2] = { { 0, 0 },
155 pci_read_config_word(dev, 0x40, &master_data);
156 pci_read_config_byte(dev, 0x48, &udma_enable);
162 int u_clock, u_speed;
165 u_speed =
min(2 - (udma & 1), udma);
173 udma_enable |= (1 <<
devid);
176 pci_read_config_word(dev, 0x4A, &udma_timing);
177 udma_timing &= ~(3 << (4 *
devid));
178 udma_timing |= u_speed << (4 *
devid);
179 pci_write_config_word(dev, 0x4A, udma_timing);
182 pci_read_config_word(dev, 0x54, &ideconf);
183 ideconf &= ~(0x1001 <<
devid);
184 ideconf |= u_clock <<
devid;
185 pci_write_config_word(dev, 0x54, ideconf);
195 static const unsigned int needed_pio[3] = {
205 if (adev->
pio_mode < needed_pio[mwdma])
210 master_data &= 0xFF4F;
211 master_data |= control << 4;
212 pci_read_config_byte(dev, 0x44, &slave_data);
215 slave_data |= ((timings[
pio][0] << 2) | timings[pio][1]) << (ap->
port_no ? 4 : 0);
216 pci_write_config_byte(dev, 0x44, slave_data);
218 master_data &= 0xCCF4;
222 (timings[
pio][0] << 12) |
223 (timings[pio][1] << 8);
225 udma_enable &= ~(1 <<
devid);
226 pci_write_config_word(dev, 0x40, master_data);
228 pci_write_config_byte(dev, 0x48, udma_enable);
237 .inherits = &ata_bmdma_port_ops,
238 .cable_detect = it8213_cable_detect,
239 .set_piomode = it8213_set_piomode,
240 .set_dmamode = it8213_set_dmamode,
241 .prereset = it8213_pre_reset,
266 .port_ops = &it8213_ops,
273 return ata_pci_bmdma_init_one(pdev, ppi, &it8213_sht,
NULL, 0);
282 static struct pci_driver it8213_pci_driver = {
284 .id_table = it8213_pci_tbl,
285 .probe = it8213_init_one,
286 .remove = ata_pci_remove_one,
288 .suspend = ata_pci_device_suspend,
289 .resume = ata_pci_device_resume,