static int marvell_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); u32 devices; void __iomem *barp; int i; /* Check if our port is enabled */ barp = pci_iomap(pdev, 5, 0x10); if (barp == NULL) return -ENOMEM; printk("BAR5:"); for(i = 0; i <= 0x0F; i++) printk("%02X:%02X ", i, ioread8(barp + i)); printk("\n"); devices = ioread32(barp + 0x0C); pci_iounmap(pdev, barp); if ((pdev->device == 0x6145) && (ap->port_no == 0) && (!(devices & 0x10))) /* PATA enable ? */ return -ENOENT; return ata_sff_prereset(link, deadline); }
static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); u32 control; u32 control5; int port_mask = 1<< (4 * ap->port_no); int port = ap->port_no; port_type port_map[2]; pci_read_config_dword(pdev, 0x40, &control); if ((control & port_mask) == 0) return -ENOENT; if (control & (1 << 23)) { port_map[0] = PORT_SATA; port_map[1] = PORT_PATA0; } else { port_map[0] = PORT_SATA; port_map[1] = PORT_SATA; } pci_read_config_dword(pdev, 0x80, &control5); if (control5 & (1<<24)) port_map[0] = PORT_PATA1; if (control & (1 << 22)) port = port ^ 1; switch (port_map[port]) { case PORT_PATA0: if ((control & (1 << 5)) == 0) return -ENOENT; if (control & (1 << 3)) ap->cbl = ATA_CBL_PATA40; else ap->cbl = ATA_CBL_PATA80; break; case PORT_PATA1: if ((control5 & (1 << 21)) == 0) return -ENOENT; if (control5 & (1 << 19)) ap->cbl = ATA_CBL_PATA40; else ap->cbl = ATA_CBL_PATA80; break; case PORT_SATA: ap->cbl = ATA_CBL_SATA; break; } return ata_sff_prereset(link, deadline); }
static int pacpi_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pata_acpi *acpi = ap->private_data; if (ap->acpi_handle == NULL || ata_acpi_gtm(ap, &acpi->gtm) < 0) return -ENODEV; return ata_sff_prereset(link, deadline); }
static int marvell_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); if (pdev->device == 0x6145 && ap->port_no == 0 && !marvell_pata_active(pdev)) /* PATA enable ? */ return -ENOENT; return ata_sff_prereset(link, deadline); }
static int optidma_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); static const struct pci_bits optidma_enable_bits = { 0x40, 1, 0x08, 0x00 }; if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) return -ENOENT; return ata_sff_prereset(link, deadline); }
static int sl82c105_pre_reset(struct ata_link *link, unsigned long deadline) { static const struct pci_bits sl82c105_enable_bits[] = { { 0x40, 1, 0x01, 0x01 }, { 0x40, 1, 0x10, 0x10 } }; struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); if (ap->port_no && !pci_test_config_bits(pdev, &sl82c105_enable_bits[ap->port_no])) return -ENOENT; return ata_sff_prereset(link, deadline); }
static int artop6210_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); const struct pci_bits artop_enable_bits[] = { { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */ { 0x4AU, 1U, 0x04UL, 0x04UL }, /* port 1 */ }; if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) return -ENOENT; return ata_sff_prereset(link, deadline); }
static int atiixp_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; static const struct pci_bits atiixp_enable_bits[] = { { 0x48, 1, 0x01, 0x00 }, { 0x48, 1, 0x08, 0x00 } }; struct pci_dev *pdev = to_pci_dev(ap->host->dev); if (!pci_test_config_bits(pdev, &atiixp_enable_bits[ap->port_no])) return -ENOENT; return ata_sff_prereset(link, deadline); }
static int artop6260_pre_reset(struct ata_link *link, unsigned long deadline) { static const struct pci_bits artop_enable_bits[] = { { 0x4AU, 1U, 0x02UL, 0x02UL }, /* port 0 */ { 0x4AU, 1U, 0x04UL, 0x04UL }, /* port 1 */ }; struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); /* Odd numbered device ids are the units with enable bits (the -R cards) */ if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no])) return -ENOENT; return ata_sff_prereset(link, deadline); }
/** * jmicron_pre_reset - check for 40/80 pin * @link: ATA link * @deadline: deadline jiffies for the operation * * Perform the PATA port setup we need. * * On the Jmicron 361/363 there is a single PATA port that can be mapped * either as primary or secondary (or neither). We don't do any policy * and setup here. We assume that has been done by init_one and the * BIOS. */ static int jmicron_pre_reset(struct ata_link *link, unsigned long deadline) { struct ata_port *ap = link->ap; struct pci_dev *pdev = to_pci_dev(ap->host->dev); u32 control; u32 control5; int port_mask = 1<< (4 * ap->port_no); int port = ap->port_no; port_type port_map[2]; /* Check if our port is enabled */ pci_read_config_dword(pdev, 0x40, &control); if ((control & port_mask) == 0) return -ENOENT; /* There are two basic mappings. One has the two SATA ports merged as master/slave and the secondary as PATA, the other has only the SATA port mapped */ if (control & (1 << 23)) { port_map[0] = PORT_SATA; port_map[1] = PORT_PATA0; } else { port_map[0] = PORT_SATA; port_map[1] = PORT_SATA; } /* The 365/366 may have this bit set to map the second PATA port as the internal primary channel */ pci_read_config_dword(pdev, 0x80, &control5); if (control5 & (1<<24)) port_map[0] = PORT_PATA1; /* The two ports may then be logically swapped by the firmware */ if (control & (1 << 22)) port = port ^ 1; /* * Now we know which physical port we are talking about we can * actually do our cable checking etc. Thankfully we don't need * to do the plumbing for other cases. */ switch (port_map[port]) { case PORT_PATA0: if ((control & (1 << 5)) == 0) return -ENOENT; if (control & (1 << 3)) /* 40/80 pin primary */ ap->cbl = ATA_CBL_PATA40; else ap->cbl = ATA_CBL_PATA80; break; case PORT_PATA1: /* Bit 21 is set if the port is enabled */ if ((control5 & (1 << 21)) == 0) return -ENOENT; if (control5 & (1 << 19)) /* 40/80 pin secondary */ ap->cbl = ATA_CBL_PATA40; else ap->cbl = ATA_CBL_PATA80; break; case PORT_SATA: ap->cbl = ATA_CBL_SATA; break; } return ata_sff_prereset(link, deadline); }