37 #include <linux/kernel.h>
38 #include <linux/module.h>
39 #include <linux/pci.h>
44 #include <linux/device.h>
49 #define DRV_NAME "sata_sil"
50 #define DRV_VERSION "2.4"
52 #define SIL_DMA_BOUNDARY 0x7fffffffUL
117 static int sil_pci_device_resume(
struct pci_dev *pdev);
127 static void sil_freeze(
struct ata_port *ap);
128 static void sil_thaw(
struct ata_port *ap);
145 static const struct sil_drivelist {
148 } sil_blacklist [] = {
166 .id_table = sil_pci_tbl,
167 .probe = sil_init_one,
168 .remove = ata_pci_remove_one,
170 .suspend = ata_pci_device_suspend,
171 .resume = sil_pci_device_resume,
185 .inherits = &ata_bmdma32_port_ops,
186 .dev_config = sil_dev_config,
187 .set_mode = sil_set_mode,
188 .bmdma_setup = sil_bmdma_setup,
189 .bmdma_start = sil_bmdma_start,
190 .bmdma_stop = sil_bmdma_stop,
191 .qc_prep = sil_qc_prep,
192 .freeze = sil_freeze,
194 .scr_read = sil_scr_read,
195 .scr_write = sil_scr_write,
205 .port_ops = &sil_ops,
214 .port_ops = &sil_ops,
222 .port_ops = &sil_ops,
230 .port_ops = &sil_ops,
236 static const struct {
249 { 0x80, 0x8A, 0x0, 0x10, 0x40, 0x100, 0x148, 0xb4, 0x14c },
250 { 0xC0, 0xCA, 0x8, 0x18, 0x44, 0x180, 0x1c8, 0xf4, 0x1cc },
251 { 0x280, 0x28A, 0x200, 0x210, 0x240, 0x300, 0x348, 0x2b4, 0x34c },
252 { 0x2C0, 0x2CA, 0x208, 0x218, 0x244, 0x380, 0x3c8, 0x2f4, 0x3cc },
262 static int slow_down;
264 MODULE_PARM_DESC(slow_down,
"Sledgehammer used to work around random problems, by limiting commands to 15 sectors (0=off, 1=on)");
289 ap->
ops->sff_exec_command(ap, &qc->
tf);
316 prd = &ap->bmdma_prd[0];
326 VPRINTK(
"PRD[%u] = (0x%X, 0x%X)\n", si, addr, sg_len);
344 static unsigned char sil_get_device_cache_line(
struct pci_dev *pdev)
366 u32 tmp, dev_mode[2] = { };
374 if (!ata_dev_enabled(dev))
375 dev_mode[dev->
devno] = 0;
377 dev_mode[dev->
devno] = 1;
379 dev_mode[dev->
devno] = 3;
384 tmp &= ~((1<<5) | (1<<4) | (1<<1) | (1<<0));
386 tmp |= (dev_mode[1] << 4);
412 static int sil_scr_read(
struct ata_link *link,
unsigned int sc_reg,
u32 *
val)
414 void __iomem *mmio = sil_scr_addr(link->
ap, sc_reg);
423 static int sil_scr_write(
struct ata_link *link,
unsigned int sc_reg,
u32 val)
425 void __iomem *mmio = sil_scr_addr(link->
ap, sc_reg);
434 static void sil_host_intr(
struct ata_port *ap,
u32 bmdma2)
441 u32 serror = 0xffffffff;
454 ap->
link.eh_info.serror |= serror;
464 ap->
ops->sff_check_status(ap);
483 if (ata_is_dma(qc->
tf.protocol)) {
485 ap->
ops->bmdma_stop(qc);
500 status = ap->
ops->sff_check_status(ap);
505 ata_bmdma_irq_clear(ap);
521 static irqreturn_t sil_interrupt(
int irq,
void *dev_instance)
528 spin_lock(&host->
lock);
530 for (i = 0; i < host->
n_ports; i++) {
536 bmdma2 &= ~SIL_DMA_SATA_IRQ;
538 if (bmdma2 == 0xffffffff ||
542 sil_host_intr(ap, bmdma2);
546 spin_unlock(&host->
lock);
551 static void sil_freeze(
struct ata_port *ap)
571 ap->ioaddr.bmdma_addr);
576 ioread8(ap->ioaddr.bmdma_addr);
579 static void sil_thaw(
struct ata_port *ap)
585 ap->
ops->sff_check_status(ap);
586 ata_bmdma_irq_clear(ap);
626 static void sil_dev_config(
struct ata_device *dev)
630 unsigned int n, quirks = 0;
635 for (n = 0; sil_blacklist[
n].product; n++)
637 quirks = sil_blacklist[
n].quirk;
647 "applying Seagate errata fix (mod15write workaround)\n");
662 static void sil_init_controller(
struct ata_host *host)
671 cls = sil_get_device_cache_line(pdev);
675 for (i = 0; i < host->
n_ports; i++)
680 "cache line size not set. Driver may not function\n");
686 for (i = 0, cnt = 0; i < host->
n_ports; i++) {
688 if ((tmp & 0x3) != 0x01)
692 "Applying R_ERR on DMA activate FIS errata fix\n");
700 tmp =
readl(mmio_base + sil_port[2].bmdma);
702 writel(tmp | SIL_INTR_STEERING,
703 mmio_base + sil_port[2].bmdma);
707 static bool sil_broken_system_poweroff(
struct pci_dev *pdev)
711 .
ident =
"HP Compaq nx6325",
717 .driver_data = (
void *)0x12UL,
725 unsigned long slot = (
unsigned long)dmi->driver_data;
750 if (sil_broken_system_poweroff(pdev)) {
753 dev_info(&pdev->
dev,
"quirky BIOS, skipping spindown "
754 "on poweroff and hibernation\n");
782 for (i = 0; i < host->
n_ports; i++) {
784 struct ata_ioports *ioaddr = &ap->ioaddr;
786 ioaddr->cmd_addr = mmio_base + sil_port[
i].tf;
787 ioaddr->altstatus_addr =
788 ioaddr->ctl_addr = mmio_base + sil_port[
i].ctl;
789 ioaddr->bmdma_addr = mmio_base + sil_port[
i].bmdma;
790 ioaddr->scr_addr = mmio_base + sil_port[
i].scr;
798 sil_init_controller(host);
806 static int sil_pci_device_resume(
struct pci_dev *pdev)
811 rc = ata_pci_device_do_resume(pdev);
815 sil_init_controller(host);
816 ata_host_resume(host);