Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 32699
b: refs/heads/master
c: ea35d29
h: refs/heads/master
i:
  32697: 11ad3e5
  32695: 61c06d5
v: v3
  • Loading branch information
Jeff Garzik committed Jul 16, 2006
1 parent dba2e4b commit b1ab257
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d96715c1acb119cef4b2443ba9b3777b730139e6
refs/heads/master: ea35d29e2fa8b3d766a2ce8fbcce599dce8d2734
53 changes: 28 additions & 25 deletions trunk/drivers/scsi/ata_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ enum {

struct piix_map_db {
const u32 mask;
const u32 port_enable;
const int map[][4];
};

Expand Down Expand Up @@ -294,6 +295,7 @@ static const struct ata_port_operations piix_sata_ops = {

static const struct piix_map_db ich5_map_db = {
.mask = 0x7,
.port_enable = 0x3,
.map = {
/* PM PS SM SS MAP */
{ P0, NA, P1, NA }, /* 000b */
Expand All @@ -309,6 +311,7 @@ static const struct piix_map_db ich5_map_db = {

static const struct piix_map_db ich6_map_db = {
.mask = 0x3,
.port_enable = 0xf,
.map = {
/* PM PS SM SS MAP */
{ P0, P2, P1, P3 }, /* 00b */
Expand All @@ -320,6 +323,7 @@ static const struct piix_map_db ich6_map_db = {

static const struct piix_map_db ich6m_map_db = {
.mask = 0x3,
.port_enable = 0x5,
.map = {
/* PM PS SM SS MAP */
{ P0, P2, RV, RV }, /* 00b */
Expand Down Expand Up @@ -519,44 +523,25 @@ static int piix_sata_prereset(struct ata_port *ap)
struct piix_host_priv *hpriv = ap->host_set->private_data;
const unsigned int *map = hpriv->map;
int base = 2 * ap->hard_port_no;
unsigned int present_mask = 0;
unsigned int present = 0;
int port, i;
u8 pcs;
u16 pcs;

pci_read_config_byte(pdev, ICH5_PCS, &pcs);
pci_read_config_word(pdev, ICH5_PCS, &pcs);
DPRINTK("ata%u: ENTER, pcs=0x%x base=%d\n", ap->id, pcs, base);

/* enable all ports on this ap and wait for them to settle */
for (i = 0; i < 2; i++) {
port = map[base + i];
if (port >= 0)
pcs |= 1 << port;
}

pci_write_config_byte(pdev, ICH5_PCS, pcs);
msleep(100);

/* let's see which devices are present */
pci_read_config_byte(pdev, ICH5_PCS, &pcs);

for (i = 0; i < 2; i++) {
port = map[base + i];
if (port < 0)
continue;
if (ap->flags & PIIX_FLAG_IGNORE_PCS || pcs & 1 << (4 + port))
present_mask |= 1 << i;
else
pcs &= ~(1 << port);
present = 1;
}

/* disable offline ports on non-AHCI controllers */
if (!(ap->flags & PIIX_FLAG_AHCI))
pci_write_config_byte(pdev, ICH5_PCS, pcs);

DPRINTK("ata%u: LEAVE, pcs=0x%x present_mask=0x%x\n",
ap->id, pcs, present_mask);

if (!present_mask) {
if (!present) {
ata_port_printk(ap, KERN_INFO, "SATA port has no device.\n");
ap->eh_context.i.action &= ~ATA_EH_RESET_MASK;
return 0;
Expand Down Expand Up @@ -770,6 +755,22 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
return no_piix_dma;
}

static void __devinit piix_init_pcs(struct pci_dev *pdev,
const struct piix_map_db *map_db)
{
u16 pcs, new_pcs;

pci_read_config_word(pdev, ICH5_PCS, &pcs);

new_pcs = pcs | map_db->port_enable;

if (new_pcs != pcs) {
DPRINTK("updating PCS from 0x%x to 0x%x\n", pcs, new_pcs);
pci_write_config_word(pdev, ICH5_PCS, new_pcs);
msleep(150);
}
}

static void __devinit piix_init_sata_map(struct pci_dev *pdev,
struct ata_port_info *pinfo,
const struct piix_map_db *map_db)
Expand Down Expand Up @@ -871,9 +872,11 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
}

/* Initialize SATA map */
if (host_flags & ATA_FLAG_SATA)
if (host_flags & ATA_FLAG_SATA) {
piix_init_sata_map(pdev, port_info,
piix_map_db_table[ent->driver_data]);
piix_init_pcs(pdev, piix_map_db_table[ent->driver_data]);
}

/* On ICH5, some BIOSen disable the interrupt using the
* PCI_COMMAND_INTX_DISABLE bit added in PCI 2.3.
Expand Down

0 comments on commit b1ab257

Please sign in to comment.