aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/ata_piix.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/ata/ata_piix.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/ata/ata_piix.c')
-rw-r--r--drivers/ata/ata_piix.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index d712675d0a96..6f6e7718b05c 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -38,16 +38,16 @@
38 * Hardware documentation available at http://developer.intel.com/ 38 * Hardware documentation available at http://developer.intel.com/
39 * 39 *
40 * Documentation 40 * Documentation
41 * Publically available from Intel web site. Errata documentation 41 * Publicly available from Intel web site. Errata documentation
42 * is also publically available. As an aide to anyone hacking on this 42 * is also publicly available. As an aide to anyone hacking on this
43 * driver the list of errata that are relevant is below, going back to 43 * driver the list of errata that are relevant is below, going back to
44 * PIIX4. Older device documentation is now a bit tricky to find. 44 * PIIX4. Older device documentation is now a bit tricky to find.
45 * 45 *
46 * The chipsets all follow very much the same design. The original Triton 46 * The chipsets all follow very much the same design. The original Triton
47 * series chipsets do _not_ support independant device timings, but this 47 * series chipsets do _not_ support independent device timings, but this
48 * is fixed in Triton II. With the odd mobile exception the chips then 48 * is fixed in Triton II. With the odd mobile exception the chips then
49 * change little except in gaining more modes until SATA arrives. This 49 * change little except in gaining more modes until SATA arrives. This
50 * driver supports only the chips with independant timing (that is those 50 * driver supports only the chips with independent timing (that is those
51 * with SITRE and the 0x44 timing register). See pata_oldpiix and pata_mpiix 51 * with SITRE and the 0x44 timing register). See pata_oldpiix and pata_mpiix
52 * for the early chip drivers. 52 * for the early chip drivers.
53 * 53 *
@@ -122,7 +122,7 @@ enum {
122 P2 = 2, /* port 2 */ 122 P2 = 2, /* port 2 */
123 P3 = 3, /* port 3 */ 123 P3 = 3, /* port 3 */
124 IDE = -1, /* IDE */ 124 IDE = -1, /* IDE */
125 NA = -2, /* not avaliable */ 125 NA = -2, /* not available */
126 RV = -3, /* reserved */ 126 RV = -3, /* reserved */
127 127
128 PIIX_AHCI_DEVICE = 6, 128 PIIX_AHCI_DEVICE = 6,
@@ -158,7 +158,6 @@ struct piix_map_db {
158struct piix_host_priv { 158struct piix_host_priv {
159 const int *map; 159 const int *map;
160 u32 saved_iocfg; 160 u32 saved_iocfg;
161 spinlock_t sidpr_lock; /* FIXME: remove once locking in EH is fixed */
162 void __iomem *sidpr; 161 void __iomem *sidpr;
163}; 162};
164 163
@@ -175,6 +174,8 @@ static int piix_sidpr_scr_read(struct ata_link *link,
175 unsigned int reg, u32 *val); 174 unsigned int reg, u32 *val);
176static int piix_sidpr_scr_write(struct ata_link *link, 175static int piix_sidpr_scr_write(struct ata_link *link,
177 unsigned int reg, u32 val); 176 unsigned int reg, u32 val);
177static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
178 unsigned hints);
178static bool piix_irq_check(struct ata_port *ap); 179static bool piix_irq_check(struct ata_port *ap);
179#ifdef CONFIG_PM 180#ifdef CONFIG_PM
180static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); 181static int piix_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
@@ -209,6 +210,8 @@ static const struct pci_device_id piix_pci_tbl[] = {
209 { 0x8086, 0x248A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 210 { 0x8086, 0x248A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
210 /* Intel ICH3 (E7500/1) UDMA 100 */ 211 /* Intel ICH3 (E7500/1) UDMA 100 */
211 { 0x8086, 0x248B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 212 { 0x8086, 0x248B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
213 /* Intel ICH4-L */
214 { 0x8086, 0x24C1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
212 /* Intel ICH4 (i845GV, i845E, i852, i855) UDMA 100 */ 215 /* Intel ICH4 (i845GV, i845E, i852, i855) UDMA 100 */
213 { 0x8086, 0x24CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 216 { 0x8086, 0x24CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
214 { 0x8086, 0x24CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 217 { 0x8086, 0x24CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
@@ -227,7 +230,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
227 { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 230 { 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
228 231
229 /* SATA ports */ 232 /* SATA ports */
230 233
231 /* 82801EB (ICH5) */ 234 /* 82801EB (ICH5) */
232 { 0x8086, 0x24d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 235 { 0x8086, 0x24d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
233 /* 82801EB (ICH5) */ 236 /* 82801EB (ICH5) */
@@ -306,6 +309,14 @@ static const struct pci_device_id piix_pci_tbl[] = {
306 { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata }, 309 { 0x8086, 0x1d00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
307 /* SATA Controller IDE (PBG) */ 310 /* SATA Controller IDE (PBG) */
308 { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, 311 { 0x8086, 0x1d08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
312 /* SATA Controller IDE (Panther Point) */
313 { 0x8086, 0x1e00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
314 /* SATA Controller IDE (Panther Point) */
315 { 0x8086, 0x1e01, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata },
316 /* SATA Controller IDE (Panther Point) */
317 { 0x8086, 0x1e08, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
318 /* SATA Controller IDE (Panther Point) */
319 { 0x8086, 0x1e09, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata },
309 { } /* terminate list */ 320 { } /* terminate list */
310}; 321};
311 322
@@ -348,11 +359,22 @@ static struct ata_port_operations ich_pata_ops = {
348 .set_dmamode = ich_set_dmamode, 359 .set_dmamode = ich_set_dmamode,
349}; 360};
350 361
362static struct device_attribute *piix_sidpr_shost_attrs[] = {
363 &dev_attr_link_power_management_policy,
364 NULL
365};
366
367static struct scsi_host_template piix_sidpr_sht = {
368 ATA_BMDMA_SHT(DRV_NAME),
369 .shost_attrs = piix_sidpr_shost_attrs,
370};
371
351static struct ata_port_operations piix_sidpr_sata_ops = { 372static struct ata_port_operations piix_sidpr_sata_ops = {
352 .inherits = &piix_sata_ops, 373 .inherits = &piix_sata_ops,
353 .hardreset = sata_std_hardreset, 374 .hardreset = sata_std_hardreset,
354 .scr_read = piix_sidpr_scr_read, 375 .scr_read = piix_sidpr_scr_read,
355 .scr_write = piix_sidpr_scr_write, 376 .scr_write = piix_sidpr_scr_write,
377 .set_lpm = piix_sidpr_set_lpm,
356}; 378};
357 379
358static const struct piix_map_db ich5_map_db = { 380static const struct piix_map_db ich5_map_db = {
@@ -956,15 +978,12 @@ static int piix_sidpr_scr_read(struct ata_link *link,
956 unsigned int reg, u32 *val) 978 unsigned int reg, u32 *val)
957{ 979{
958 struct piix_host_priv *hpriv = link->ap->host->private_data; 980 struct piix_host_priv *hpriv = link->ap->host->private_data;
959 unsigned long flags;
960 981
961 if (reg >= ARRAY_SIZE(piix_sidx_map)) 982 if (reg >= ARRAY_SIZE(piix_sidx_map))
962 return -EINVAL; 983 return -EINVAL;
963 984
964 spin_lock_irqsave(&hpriv->sidpr_lock, flags);
965 piix_sidpr_sel(link, reg); 985 piix_sidpr_sel(link, reg);
966 *val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA); 986 *val = ioread32(hpriv->sidpr + PIIX_SIDPR_DATA);
967 spin_unlock_irqrestore(&hpriv->sidpr_lock, flags);
968 return 0; 987 return 0;
969} 988}
970 989
@@ -972,18 +991,21 @@ static int piix_sidpr_scr_write(struct ata_link *link,
972 unsigned int reg, u32 val) 991 unsigned int reg, u32 val)
973{ 992{
974 struct piix_host_priv *hpriv = link->ap->host->private_data; 993 struct piix_host_priv *hpriv = link->ap->host->private_data;
975 unsigned long flags;
976 994
977 if (reg >= ARRAY_SIZE(piix_sidx_map)) 995 if (reg >= ARRAY_SIZE(piix_sidx_map))
978 return -EINVAL; 996 return -EINVAL;
979 997
980 spin_lock_irqsave(&hpriv->sidpr_lock, flags);
981 piix_sidpr_sel(link, reg); 998 piix_sidpr_sel(link, reg);
982 iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA); 999 iowrite32(val, hpriv->sidpr + PIIX_SIDPR_DATA);
983 spin_unlock_irqrestore(&hpriv->sidpr_lock, flags);
984 return 0; 1000 return 0;
985} 1001}
986 1002
1003static int piix_sidpr_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
1004 unsigned hints)
1005{
1006 return sata_link_scr_lpm(link, policy, false);
1007}
1008
987static bool piix_irq_check(struct ata_port *ap) 1009static bool piix_irq_check(struct ata_port *ap)
988{ 1010{
989 if (unlikely(!ap->ioaddr.bmdma_addr)) 1011 if (unlikely(!ap->ioaddr.bmdma_addr))
@@ -1543,6 +1565,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1543 struct device *dev = &pdev->dev; 1565 struct device *dev = &pdev->dev;
1544 struct ata_port_info port_info[2]; 1566 struct ata_port_info port_info[2];
1545 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] }; 1567 const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
1568 struct scsi_host_template *sht = &piix_sht;
1546 unsigned long port_flags; 1569 unsigned long port_flags;
1547 struct ata_host *host; 1570 struct ata_host *host;
1548 struct piix_host_priv *hpriv; 1571 struct piix_host_priv *hpriv;
@@ -1577,7 +1600,6 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1577 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL); 1600 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
1578 if (!hpriv) 1601 if (!hpriv)
1579 return -ENOMEM; 1602 return -ENOMEM;
1580 spin_lock_init(&hpriv->sidpr_lock);
1581 1603
1582 /* Save IOCFG, this will be used for cable detection, quirk 1604 /* Save IOCFG, this will be used for cable detection, quirk
1583 * detection and restoration on detach. This is necessary 1605 * detection and restoration on detach. This is necessary
@@ -1612,6 +1634,8 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1612 rc = piix_init_sidpr(host); 1634 rc = piix_init_sidpr(host);
1613 if (rc) 1635 if (rc)
1614 return rc; 1636 return rc;
1637 if (host->ports[0]->ops == &piix_sidpr_sata_ops)
1638 sht = &piix_sidpr_sht;
1615 } 1639 }
1616 1640
1617 /* apply IOCFG bit18 quirk */ 1641 /* apply IOCFG bit18 quirk */
@@ -1638,7 +1662,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
1638 host->flags |= ATA_HOST_PARALLEL_SCAN; 1662 host->flags |= ATA_HOST_PARALLEL_SCAN;
1639 1663
1640 pci_set_master(pdev); 1664 pci_set_master(pdev);
1641 return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, &piix_sht); 1665 return ata_pci_sff_activate_host(host, ata_bmdma_interrupt, sht);
1642} 1666}
1643 1667
1644static void piix_remove_one(struct pci_dev *pdev) 1668static void piix_remove_one(struct pci_dev *pdev)