aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/pata_sis.c109
1 files changed, 29 insertions, 80 deletions
diff --git a/drivers/ata/pata_sis.c b/drivers/ata/pata_sis.c
index 8dc3bc4f5863..a3fbcee6fb33 100644
--- a/drivers/ata/pata_sis.c
+++ b/drivers/ata/pata_sis.c
@@ -35,7 +35,7 @@
35#include "sis.h" 35#include "sis.h"
36 36
37#define DRV_NAME "pata_sis" 37#define DRV_NAME "pata_sis"
38#define DRV_VERSION "0.5.0" 38#define DRV_VERSION "0.5.1"
39 39
40struct sis_chipset { 40struct sis_chipset {
41 u16 device; /* PCI host ID */ 41 u16 device; /* PCI host ID */
@@ -86,106 +86,55 @@ static int sis_port_base(struct ata_device *adev)
86} 86}
87 87
88/** 88/**
89 * sis_133_pre_reset - check for 40/80 pin 89 * sis_133_cable_detect - check for 40/80 pin
90 * @ap: Port 90 * @ap: Port
91 * 91 *
92 * Perform cable detection for the later UDMA133 capable 92 * Perform cable detection for the later UDMA133 capable
93 * SiS chipset. 93 * SiS chipset.
94 */ 94 */
95 95
96static int sis_133_pre_reset(struct ata_port *ap) 96static int sis_133_cable_detect(struct ata_port *ap)
97{ 97{
98 static const struct pci_bits sis_enable_bits[] = {
99 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */
100 { 0x4aU, 1U, 0x04UL, 0x04UL }, /* port 1 */
101 };
102
103 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 98 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
104 u16 tmp; 99 u16 tmp;
105 100
106 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
107 return -ENOENT;
108
109 /* The top bit of this register is the cable detect bit */ 101 /* The top bit of this register is the cable detect bit */
110 pci_read_config_word(pdev, 0x50 + 2 * ap->port_no, &tmp); 102 pci_read_config_word(pdev, 0x50 + 2 * ap->port_no, &tmp);
111 if ((tmp & 0x8000) && !sis_short_ata40(pdev)) 103 if ((tmp & 0x8000) && !sis_short_ata40(pdev))
112 ap->cbl = ATA_CBL_PATA40; 104 return ATA_CBL_PATA40;
113 else 105 return ATA_CBL_PATA80;
114 ap->cbl = ATA_CBL_PATA80;
115
116 return ata_std_prereset(ap);
117} 106}
118 107
119/** 108/**
120 * sis_error_handler - Probe specified port on PATA host controller 109 * sis_66_cable_detect - check for 40/80 pin
121 * @ap: Port to probe
122 *
123 * LOCKING:
124 * None (inherited from caller).
125 */
126
127static void sis_133_error_handler(struct ata_port *ap)
128{
129 ata_bmdma_drive_eh(ap, sis_133_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
130}
131
132
133/**
134 * sis_66_pre_reset - check for 40/80 pin
135 * @ap: Port 110 * @ap: Port
136 * 111 *
137 * Perform cable detection on the UDMA66, UDMA100 and early UDMA133 112 * Perform cable detection on the UDMA66, UDMA100 and early UDMA133
138 * SiS IDE controllers. 113 * SiS IDE controllers.
139 */ 114 */
140 115
141static int sis_66_pre_reset(struct ata_port *ap) 116static int sis_66_cable_detect(struct ata_port *ap)
142{ 117{
143 static const struct pci_bits sis_enable_bits[] = {
144 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */
145 { 0x4aU, 1U, 0x04UL, 0x04UL }, /* port 1 */
146 };
147
148 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 118 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
149 u8 tmp; 119 u8 tmp;
150 120
151 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) {
152 ata_port_disable(ap);
153 ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
154 return 0;
155 }
156 /* Older chips keep cable detect in bits 4/5 of reg 0x48 */ 121 /* Older chips keep cable detect in bits 4/5 of reg 0x48 */
157 pci_read_config_byte(pdev, 0x48, &tmp); 122 pci_read_config_byte(pdev, 0x48, &tmp);
158 tmp >>= ap->port_no; 123 tmp >>= ap->port_no;
159 if ((tmp & 0x10) && !sis_short_ata40(pdev)) 124 if ((tmp & 0x10) && !sis_short_ata40(pdev))
160 ap->cbl = ATA_CBL_PATA40; 125 return ATA_CBL_PATA40;
161 else 126 return ATA_CBL_PATA80;
162 ap->cbl = ATA_CBL_PATA80;
163
164 return ata_std_prereset(ap);
165} 127}
166 128
167/**
168 * sis_66_error_handler - Probe specified port on PATA host controller
169 * @ap: Port to probe
170 * @classes:
171 *
172 * LOCKING:
173 * None (inherited from caller).
174 */
175
176static void sis_66_error_handler(struct ata_port *ap)
177{
178 ata_bmdma_drive_eh(ap, sis_66_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
179}
180 129
181/** 130/**
182 * sis_old_pre_reset - probe begin 131 * sis_pre_reset - probe begin
183 * @ap: ATA port 132 * @ap: ATA port
184 * 133 *
185 * Set up cable type and use generic probe init 134 * Set up cable type and use generic probe init
186 */ 135 */
187 136
188static int sis_old_pre_reset(struct ata_port *ap) 137static int sis_pre_reset(struct ata_port *ap)
189{ 138{
190 static const struct pci_bits sis_enable_bits[] = { 139 static const struct pci_bits sis_enable_bits[] = {
191 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */ 140 { 0x4aU, 1U, 0x02UL, 0x02UL }, /* port 0 */
@@ -194,27 +143,23 @@ static int sis_old_pre_reset(struct ata_port *ap)
194 143
195 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 144 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
196 145
197 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no])) { 146 if (!pci_test_config_bits(pdev, &sis_enable_bits[ap->port_no]))
198 ata_port_disable(ap); 147 return -ENOENT;
199 ata_port_printk(ap, KERN_INFO, "port disabled. ignoring.\n");
200 return 0;
201 }
202 ap->cbl = ATA_CBL_PATA40;
203 return ata_std_prereset(ap); 148 return ata_std_prereset(ap);
204} 149}
205 150
206 151
207/** 152/**
208 * sis_old_error_handler - Probe specified port on PATA host controller 153 * sis_error_handler - Probe specified port on PATA host controller
209 * @ap: Port to probe 154 * @ap: Port to probe
210 * 155 *
211 * LOCKING: 156 * LOCKING:
212 * None (inherited from caller). 157 * None (inherited from caller).
213 */ 158 */
214 159
215static void sis_old_error_handler(struct ata_port *ap) 160static void sis_error_handler(struct ata_port *ap)
216{ 161{
217 ata_bmdma_drive_eh(ap, sis_old_pre_reset, ata_std_softreset, NULL, ata_std_postreset); 162 ata_bmdma_drive_eh(ap, sis_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
218} 163}
219 164
220/** 165/**
@@ -494,7 +439,7 @@ static void sis_133_early_set_dmamode (struct ata_port *ap, struct ata_device *a
494 int drive_pci = sis_port_base(adev); 439 int drive_pci = sis_port_base(adev);
495 u16 timing; 440 u16 timing;
496 441
497 const u16 udma_bits[] = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100}; 442 static const u16 udma_bits[] = { 0x8F00, 0x8A00, 0x8700, 0x8500, 0x8300, 0x8200, 0x8100};
498 443
499 pci_read_config_word(pdev, drive_pci, &timing); 444 pci_read_config_word(pdev, drive_pci, &timing);
500 445
@@ -531,8 +476,8 @@ static void sis_133_set_dmamode (struct ata_port *ap, struct ata_device *adev)
531 u32 reg54; 476 u32 reg54;
532 477
533 /* bits 4- cycle time 8 - cvs time */ 478 /* bits 4- cycle time 8 - cvs time */
534 const u32 timing_u100[] = { 0x6B0, 0x470, 0x350, 0x140, 0x120, 0x110, 0x000 }; 479 static const u32 timing_u100[] = { 0x6B0, 0x470, 0x350, 0x140, 0x120, 0x110, 0x000 };
535 const u32 timing_u133[] = { 0x9F0, 0x6A0, 0x470, 0x250, 0x230, 0x220, 0x210 }; 480 static const u32 timing_u133[] = { 0x9F0, 0x6A0, 0x470, 0x250, 0x230, 0x220, 0x210 };
536 481
537 /* If bit 14 is set then the registers are mapped at 0x70 not 0x40 */ 482 /* If bit 14 is set then the registers are mapped at 0x70 not 0x40 */
538 pci_read_config_dword(pdev, 0x54, &reg54); 483 pci_read_config_dword(pdev, 0x54, &reg54);
@@ -595,8 +540,9 @@ static const struct ata_port_operations sis_133_ops = {
595 540
596 .freeze = ata_bmdma_freeze, 541 .freeze = ata_bmdma_freeze,
597 .thaw = ata_bmdma_thaw, 542 .thaw = ata_bmdma_thaw,
598 .error_handler = sis_133_error_handler, 543 .error_handler = sis_error_handler,
599 .post_internal_cmd = ata_bmdma_post_internal_cmd, 544 .post_internal_cmd = ata_bmdma_post_internal_cmd,
545 .cable_detect = sis_133_cable_detect,
600 546
601 .bmdma_setup = ata_bmdma_setup, 547 .bmdma_setup = ata_bmdma_setup,
602 .bmdma_start = ata_bmdma_start, 548 .bmdma_start = ata_bmdma_start,
@@ -628,8 +574,9 @@ static const struct ata_port_operations sis_133_early_ops = {
628 574
629 .freeze = ata_bmdma_freeze, 575 .freeze = ata_bmdma_freeze,
630 .thaw = ata_bmdma_thaw, 576 .thaw = ata_bmdma_thaw,
631 .error_handler = sis_66_error_handler, 577 .error_handler = sis_error_handler,
632 .post_internal_cmd = ata_bmdma_post_internal_cmd, 578 .post_internal_cmd = ata_bmdma_post_internal_cmd,
579 .cable_detect = sis_66_cable_detect,
633 580
634 .bmdma_setup = ata_bmdma_setup, 581 .bmdma_setup = ata_bmdma_setup,
635 .bmdma_start = ata_bmdma_start, 582 .bmdma_start = ata_bmdma_start,
@@ -661,9 +608,9 @@ static const struct ata_port_operations sis_100_ops = {
661 608
662 .freeze = ata_bmdma_freeze, 609 .freeze = ata_bmdma_freeze,
663 .thaw = ata_bmdma_thaw, 610 .thaw = ata_bmdma_thaw,
664 .error_handler = sis_66_error_handler, 611 .error_handler = sis_error_handler,
665 .post_internal_cmd = ata_bmdma_post_internal_cmd, 612 .post_internal_cmd = ata_bmdma_post_internal_cmd,
666 613 .cable_detect = sis_66_cable_detect,
667 614
668 .bmdma_setup = ata_bmdma_setup, 615 .bmdma_setup = ata_bmdma_setup,
669 .bmdma_start = ata_bmdma_start, 616 .bmdma_start = ata_bmdma_start,
@@ -692,10 +639,11 @@ static const struct ata_port_operations sis_66_ops = {
692 .check_status = ata_check_status, 639 .check_status = ata_check_status,
693 .exec_command = ata_exec_command, 640 .exec_command = ata_exec_command,
694 .dev_select = ata_std_dev_select, 641 .dev_select = ata_std_dev_select,
642 .cable_detect = sis_66_cable_detect,
695 643
696 .freeze = ata_bmdma_freeze, 644 .freeze = ata_bmdma_freeze,
697 .thaw = ata_bmdma_thaw, 645 .thaw = ata_bmdma_thaw,
698 .error_handler = sis_66_error_handler, 646 .error_handler = sis_error_handler,
699 .post_internal_cmd = ata_bmdma_post_internal_cmd, 647 .post_internal_cmd = ata_bmdma_post_internal_cmd,
700 648
701 .bmdma_setup = ata_bmdma_setup, 649 .bmdma_setup = ata_bmdma_setup,
@@ -728,8 +676,9 @@ static const struct ata_port_operations sis_old_ops = {
728 676
729 .freeze = ata_bmdma_freeze, 677 .freeze = ata_bmdma_freeze,
730 .thaw = ata_bmdma_thaw, 678 .thaw = ata_bmdma_thaw,
731 .error_handler = sis_old_error_handler, 679 .error_handler = sis_error_handler,
732 .post_internal_cmd = ata_bmdma_post_internal_cmd, 680 .post_internal_cmd = ata_bmdma_post_internal_cmd,
681 .cable_detect = ata_cable_40wire,
733 682
734 .bmdma_setup = ata_bmdma_setup, 683 .bmdma_setup = ata_bmdma_setup,
735 .bmdma_start = ata_bmdma_start, 684 .bmdma_start = ata_bmdma_start,