aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/ata_piix.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/ata_piix.c')
-rw-r--r--drivers/ata/ata_piix.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 47701b286f8b..4d716c7347e7 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -118,7 +118,7 @@ enum {
118 PIIX_80C_SEC = (1 << 7) | (1 << 6), 118 PIIX_80C_SEC = (1 << 7) | (1 << 6),
119 119
120 /* controller IDs */ 120 /* controller IDs */
121 piix_pata_33 = 0, /* PIIX3 or 4 at 33Mhz */ 121 piix_pata_33 = 0, /* PIIX4 at 33Mhz */
122 ich_pata_33 = 1, /* ICH up to UDMA 33 only */ 122 ich_pata_33 = 1, /* ICH up to UDMA 33 only */
123 ich_pata_66 = 2, /* ICH up to 66 Mhz */ 123 ich_pata_66 = 2, /* ICH up to 66 Mhz */
124 ich_pata_100 = 3, /* ICH up to UDMA 100 */ 124 ich_pata_100 = 3, /* ICH up to UDMA 100 */
@@ -128,6 +128,7 @@ enum {
128 ich6_sata_ahci = 7, 128 ich6_sata_ahci = 7,
129 ich6m_sata_ahci = 8, 129 ich6m_sata_ahci = 8,
130 ich8_sata_ahci = 9, 130 ich8_sata_ahci = 9,
131 piix_pata_mwdma = 10, /* PIIX3 MWDMA only */
131 132
132 /* constants for mapping table */ 133 /* constants for mapping table */
133 P0 = 0, /* port 0 */ 134 P0 = 0, /* port 0 */
@@ -153,7 +154,6 @@ struct piix_host_priv {
153 154
154static int piix_init_one (struct pci_dev *pdev, 155static int piix_init_one (struct pci_dev *pdev,
155 const struct pci_device_id *ent); 156 const struct pci_device_id *ent);
156static void piix_host_stop(struct ata_host *host);
157static void piix_pata_error_handler(struct ata_port *ap); 157static void piix_pata_error_handler(struct ata_port *ap);
158static void ich_pata_error_handler(struct ata_port *ap); 158static void ich_pata_error_handler(struct ata_port *ap);
159static void piix_sata_error_handler(struct ata_port *ap); 159static void piix_sata_error_handler(struct ata_port *ap);
@@ -164,7 +164,8 @@ static void ich_set_dmamode (struct ata_port *ap, struct ata_device *adev);
164static unsigned int in_module_init = 1; 164static unsigned int in_module_init = 1;
165 165
166static const struct pci_device_id piix_pci_tbl[] = { 166static const struct pci_device_id piix_pci_tbl[] = {
167#ifdef ATA_ENABLE_PATA 167 /* Intel PIIX3 for the 430HX etc */
168 { 0x8086, 0x7010, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_mwdma },
168 /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */ 169 /* Intel PIIX4 for the 430TX/440BX/MX chipset: UDMA 33 */
169 /* Also PIIX4E (fn3 rev 2) and PIIX4M (fn3 rev 3) */ 170 /* Also PIIX4E (fn3 rev 2) and PIIX4M (fn3 rev 3) */
170 { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 }, 171 { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix_pata_33 },
@@ -202,7 +203,6 @@ static const struct pci_device_id piix_pci_tbl[] = {
202 /* ICH7/7-R (i945, i975) UDMA 100*/ 203 /* ICH7/7-R (i945, i975) UDMA 100*/
203 { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 }, 204 { 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
204 { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 }, 205 { 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
205#endif
206 206
207 /* NOTE: The following PCI ids must be kept in sync with the 207 /* NOTE: The following PCI ids must be kept in sync with the
208 * list in drivers/pci/quirks.c. 208 * list in drivers/pci/quirks.c.
@@ -297,7 +297,7 @@ static const struct ata_port_operations piix_pata_ops = {
297 .bmdma_status = ata_bmdma_status, 297 .bmdma_status = ata_bmdma_status,
298 .qc_prep = ata_qc_prep, 298 .qc_prep = ata_qc_prep,
299 .qc_issue = ata_qc_issue_prot, 299 .qc_issue = ata_qc_issue_prot,
300 .data_xfer = ata_pio_data_xfer, 300 .data_xfer = ata_data_xfer,
301 301
302 .freeze = ata_bmdma_freeze, 302 .freeze = ata_bmdma_freeze,
303 .thaw = ata_bmdma_thaw, 303 .thaw = ata_bmdma_thaw,
@@ -306,10 +306,10 @@ static const struct ata_port_operations piix_pata_ops = {
306 306
307 .irq_handler = ata_interrupt, 307 .irq_handler = ata_interrupt,
308 .irq_clear = ata_bmdma_irq_clear, 308 .irq_clear = ata_bmdma_irq_clear,
309 .irq_on = ata_irq_on,
310 .irq_ack = ata_irq_ack,
309 311
310 .port_start = ata_port_start, 312 .port_start = ata_port_start,
311 .port_stop = ata_port_stop,
312 .host_stop = piix_host_stop,
313}; 313};
314 314
315static const struct ata_port_operations ich_pata_ops = { 315static const struct ata_port_operations ich_pata_ops = {
@@ -330,7 +330,7 @@ static const struct ata_port_operations ich_pata_ops = {
330 .bmdma_status = ata_bmdma_status, 330 .bmdma_status = ata_bmdma_status,
331 .qc_prep = ata_qc_prep, 331 .qc_prep = ata_qc_prep,
332 .qc_issue = ata_qc_issue_prot, 332 .qc_issue = ata_qc_issue_prot,
333 .data_xfer = ata_pio_data_xfer, 333 .data_xfer = ata_data_xfer,
334 334
335 .freeze = ata_bmdma_freeze, 335 .freeze = ata_bmdma_freeze,
336 .thaw = ata_bmdma_thaw, 336 .thaw = ata_bmdma_thaw,
@@ -339,10 +339,10 @@ static const struct ata_port_operations ich_pata_ops = {
339 339
340 .irq_handler = ata_interrupt, 340 .irq_handler = ata_interrupt,
341 .irq_clear = ata_bmdma_irq_clear, 341 .irq_clear = ata_bmdma_irq_clear,
342 .irq_on = ata_irq_on,
343 .irq_ack = ata_irq_ack,
342 344
343 .port_start = ata_port_start, 345 .port_start = ata_port_start,
344 .port_stop = ata_port_stop,
345 .host_stop = piix_host_stop,
346}; 346};
347 347
348static const struct ata_port_operations piix_sata_ops = { 348static const struct ata_port_operations piix_sata_ops = {
@@ -360,7 +360,7 @@ static const struct ata_port_operations piix_sata_ops = {
360 .bmdma_status = ata_bmdma_status, 360 .bmdma_status = ata_bmdma_status,
361 .qc_prep = ata_qc_prep, 361 .qc_prep = ata_qc_prep,
362 .qc_issue = ata_qc_issue_prot, 362 .qc_issue = ata_qc_issue_prot,
363 .data_xfer = ata_pio_data_xfer, 363 .data_xfer = ata_data_xfer,
364 364
365 .freeze = ata_bmdma_freeze, 365 .freeze = ata_bmdma_freeze,
366 .thaw = ata_bmdma_thaw, 366 .thaw = ata_bmdma_thaw,
@@ -369,10 +369,10 @@ static const struct ata_port_operations piix_sata_ops = {
369 369
370 .irq_handler = ata_interrupt, 370 .irq_handler = ata_interrupt,
371 .irq_clear = ata_bmdma_irq_clear, 371 .irq_clear = ata_bmdma_irq_clear,
372 .irq_on = ata_irq_on,
373 .irq_ack = ata_irq_ack,
372 374
373 .port_start = ata_port_start, 375 .port_start = ata_port_start,
374 .port_stop = ata_port_stop,
375 .host_stop = piix_host_stop,
376}; 376};
377 377
378static const struct piix_map_db ich5_map_db = { 378static const struct piix_map_db ich5_map_db = {
@@ -441,7 +441,7 @@ static const struct piix_map_db *piix_map_db_table[] = {
441}; 441};
442 442
443static struct ata_port_info piix_port_info[] = { 443static struct ata_port_info piix_port_info[] = {
444 /* piix_pata_33: 0: PIIX3 or 4 at 33MHz */ 444 /* piix_pata_33: 0: PIIX4 at 33MHz */
445 { 445 {
446 .sht = &piix_sht, 446 .sht = &piix_sht,
447 .flags = PIIX_PATA_FLAGS, 447 .flags = PIIX_PATA_FLAGS,
@@ -543,6 +543,14 @@ static struct ata_port_info piix_port_info[] = {
543 .port_ops = &piix_sata_ops, 543 .port_ops = &piix_sata_ops,
544 }, 544 },
545 545
546 /* piix_pata_mwdma: 10: PIIX3 MWDMA only */
547 {
548 .sht = &piix_sht,
549 .flags = PIIX_PATA_FLAGS,
550 .pio_mask = 0x1f, /* pio0-4 */
551 .mwdma_mask = 0x06, /* mwdma1-2 ?? CHECK 0 should be ok but slow */
552 .port_ops = &piix_pata_ops,
553 },
546}; 554};
547 555
548static struct pci_bits piix_enable_bits[] = { 556static struct pci_bits piix_enable_bits[] = {
@@ -569,6 +577,7 @@ struct ich_laptop {
569static const struct ich_laptop ich_laptop[] = { 577static const struct ich_laptop ich_laptop[] = {
570 /* devid, subvendor, subdev */ 578 /* devid, subvendor, subdev */
571 { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */ 579 { 0x27DF, 0x0005, 0x0280 }, /* ICH7 on Acer 5602WLMi */
580 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */
572 /* end marker */ 581 /* end marker */
573 { 0, } 582 { 0, }
574}; 583};
@@ -632,7 +641,7 @@ static int piix_pata_prereset(struct ata_port *ap)
632 641
633 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no])) 642 if (!pci_test_config_bits(pdev, &piix_enable_bits[ap->port_no]))
634 return -ENOENT; 643 return -ENOENT;
635 644
636 ap->cbl = ATA_CBL_PATA40; 645 ap->cbl = ATA_CBL_PATA40;
637 return ata_std_prereset(ap); 646 return ata_std_prereset(ap);
638} 647}
@@ -776,7 +785,7 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
776 u16 master_data; 785 u16 master_data;
777 u8 speed = adev->dma_mode; 786 u8 speed = adev->dma_mode;
778 int devid = adev->devno + 2 * ap->port_no; 787 int devid = adev->devno + 2 * ap->port_no;
779 u8 udma_enable; 788 u8 udma_enable = 0;
780 789
781 static const /* ISP RTC */ 790 static const /* ISP RTC */
782 u8 timings[][2] = { { 0, 0 }, 791 u8 timings[][2] = { { 0, 0 },
@@ -786,7 +795,8 @@ static void do_pata_set_dmamode (struct ata_port *ap, struct ata_device *adev, i
786 { 2, 3 }, }; 795 { 2, 3 }, };
787 796
788 pci_read_config_word(dev, master_port, &master_data); 797 pci_read_config_word(dev, master_port, &master_data);
789 pci_read_config_byte(dev, 0x48, &udma_enable); 798 if (ap->udma_mask)
799 pci_read_config_byte(dev, 0x48, &udma_enable);
790 800
791 if (speed >= XFER_UDMA_0) { 801 if (speed >= XFER_UDMA_0) {
792 unsigned int udma = adev->dma_mode - XFER_UDMA_0; 802 unsigned int udma = adev->dma_mode - XFER_UDMA_0;
@@ -1059,6 +1069,7 @@ static void __devinit piix_init_sata_map(struct pci_dev *pdev,
1059static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 1069static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1060{ 1070{
1061 static int printed_version; 1071 static int printed_version;
1072 struct device *dev = &pdev->dev;
1062 struct ata_port_info port_info[2]; 1073 struct ata_port_info port_info[2];
1063 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] }; 1074 struct ata_port_info *ppinfo[2] = { &port_info[0], &port_info[1] };
1064 struct piix_host_priv *hpriv; 1075 struct piix_host_priv *hpriv;
@@ -1072,7 +1083,7 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1072 if (!in_module_init) 1083 if (!in_module_init)
1073 return -ENODEV; 1084 return -ENODEV;
1074 1085
1075 hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL); 1086 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
1076 if (!hpriv) 1087 if (!hpriv)
1077 return -ENOMEM; 1088 return -ENOMEM;
1078 1089
@@ -1122,15 +1133,6 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1122 return ata_pci_init_one(pdev, ppinfo, 2); 1133 return ata_pci_init_one(pdev, ppinfo, 2);
1123} 1134}
1124 1135
1125static void piix_host_stop(struct ata_host *host)
1126{
1127 struct piix_host_priv *hpriv = host->private_data;
1128
1129 ata_host_stop(host);
1130
1131 kfree(hpriv);
1132}
1133
1134static int __init piix_init(void) 1136static int __init piix_init(void)
1135{ 1137{
1136 int rc; 1138 int rc;