34 #include <linux/kernel.h>
35 #include <linux/module.h>
36 #include <linux/pci.h>
43 #define DRV_NAME "pata_cs5520"
44 #define DRV_VERSION "0.6.6"
53 static const struct pio_clocks cs5520_pio_clocks[]={
78 pci_write_config_byte(pdev, 0x62 + ap->
port_no,
79 (cs5520_pio_clocks[pio].
recovery << 4) |
80 (cs5520_pio_clocks[pio].
assert));
83 pci_write_config_byte(pdev, 0x64 + 4*ap->
port_no + slave,
84 (cs5520_pio_clocks[pio].
recovery << 4) |
85 (cs5520_pio_clocks[pio].
assert));
87 pci_write_config_byte(pdev, 0x66 + 4*ap->
port_no + slave,
88 (cs5520_pio_clocks[pio].
recovery << 4) |
89 (cs5520_pio_clocks[pio].
assert));
103 cs5520_set_timings(ap, adev, adev->
pio_mode);
112 .inherits = &ata_bmdma_port_ops,
113 .qc_prep = ata_bmdma_dumb_qc_prep,
115 .set_piomode = cs5520_set_piomode,
120 static const unsigned int cmd_port[] = { 0x1F0, 0x170 };
121 static const unsigned int ctl_port[] = { 0x3F6, 0x376 };
125 .port_ops = &cs5520_port_ops,
131 struct ata_ioports *ioaddr;
139 pci_read_config_byte(pdev, 0x60, &pcicfg);
142 if ((pcicfg & 3) == 0)
151 if ((pcicfg & 0x40) == 0) {
152 dev_warn(&pdev->
dev,
"DMA mode disabled. Enabling.\n");
153 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
172 if (pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32))) {
178 iomap[0] = devm_ioport_map(&pdev->
dev, cmd_port[0], 8);
179 iomap[1] = devm_ioport_map(&pdev->
dev, ctl_port[0], 1);
180 iomap[2] = devm_ioport_map(&pdev->
dev, cmd_port[1], 8);
181 iomap[3] = devm_ioport_map(&pdev->
dev, ctl_port[1], 1);
184 if (!iomap[0] || !iomap[1] || !iomap[2] || !iomap[3] || !iomap[4])
187 ioaddr = &host->
ports[0]->ioaddr;
188 ioaddr->cmd_addr = iomap[0];
189 ioaddr->ctl_addr = iomap[1];
190 ioaddr->altstatus_addr = iomap[1];
191 ioaddr->bmdma_addr = iomap[4];
195 "cmd 0x%x ctl 0x%x", cmd_port[0], ctl_port[0]);
196 ata_port_pbar_desc(host->
ports[0], 4, 0,
"bmdma");
198 ioaddr = &host->
ports[1]->ioaddr;
199 ioaddr->cmd_addr = iomap[2];
200 ioaddr->ctl_addr = iomap[3];
201 ioaddr->altstatus_addr = iomap[3];
202 ioaddr->bmdma_addr = iomap[4] + 8;
206 "cmd 0x%x ctl 0x%x", cmd_port[1], ctl_port[1]);
207 ata_port_pbar_desc(host->
ports[1], 4, 8,
"bmdma");
215 for (i = 0; i < 2; i++) {
216 static const int irq[] = { 14, 15 };
219 if (ata_port_is_dummy(ap))
222 rc = devm_request_irq(&pdev->
dev, irq[ap->
port_no],
223 ata_bmdma_interrupt, 0,
DRV_NAME, host);
242 static int cs5520_reinit_one(
struct pci_dev *pdev)
248 rc = ata_pci_device_do_resume(pdev);
252 pci_read_config_byte(pdev, 0x60, &pcicfg);
253 if ((pcicfg & 0x40) == 0)
254 pci_write_config_byte(pdev, 0x60, pcicfg | 0x40);
256 ata_host_resume(host);
275 rc = ata_host_suspend(host, mesg);
294 static struct pci_driver cs5520_pci_driver = {
296 .id_table = pata_cs5520,
297 .probe = cs5520_init_one,
298 .remove = ata_pci_remove_one,
300 .suspend = cs5520_pci_device_suspend,
301 .resume = cs5520_reinit_one,