aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_hpt3x2n.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-08-31 00:03:49 -0400
committerJeff Garzik <jeff@garzik.org>2006-08-31 00:03:49 -0400
commit85cd7251b9112e3dabeac9fd3b175601ca607241 (patch)
treeb33b80f54883e224a586661165bd0aee2c47ed39 /drivers/ata/pata_hpt3x2n.c
parent481ff126e8d9be63809e7854badf815e54066eed (diff)
[libata #pata-drivers] Trim trailing whitespace.
Diffstat (limited to 'drivers/ata/pata_hpt3x2n.c')
-rw-r--r--drivers/ata/pata_hpt3x2n.c94
1 files changed, 47 insertions, 47 deletions
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index 40fcda62c7a2..06c8db079b91 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -65,7 +65,7 @@ struct hpt_chip {
65 * PIO. 65 * PIO.
66 * 31 FIFO enable. 66 * 31 FIFO enable.
67 */ 67 */
68 68
69/* 66MHz DPLL clocks */ 69/* 66MHz DPLL clocks */
70 70
71static struct hpt_clock hpt3x2n_clocks[] = { 71static struct hpt_clock hpt3x2n_clocks[] = {
@@ -100,11 +100,11 @@ static struct hpt_clock hpt3x2n_clocks[] = {
100 * is hard coded but easy to change. This will be needed if we use 100 * is hard coded but easy to change. This will be needed if we use
101 * different DPLLs 101 * different DPLLs
102 */ 102 */
103 103
104static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed) 104static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed)
105{ 105{
106 struct hpt_clock *clocks = hpt3x2n_clocks; 106 struct hpt_clock *clocks = hpt3x2n_clocks;
107 107
108 while(clocks->xfer_speed) { 108 while(clocks->xfer_speed) {
109 if (clocks->xfer_speed == speed) 109 if (clocks->xfer_speed == speed)
110 return clocks->timing; 110 return clocks->timing;
@@ -121,52 +121,52 @@ static u32 hpt3x2n_find_mode(struct ata_port *ap, int speed)
121 * Perform the initial reset handling for the 3x2n series controllers. 121 * Perform the initial reset handling for the 3x2n series controllers.
122 * Reset the hardware and state machine, obtain the cable type. 122 * Reset the hardware and state machine, obtain the cable type.
123 */ 123 */
124 124
125static int hpt3xn_pre_reset(struct ata_port *ap) 125static int hpt3xn_pre_reset(struct ata_port *ap)
126{ 126{
127 u8 scr2, ata66; 127 u8 scr2, ata66;
128 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 128 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
129 129
130 pci_read_config_byte(pdev, 0x5B, &scr2); 130 pci_read_config_byte(pdev, 0x5B, &scr2);
131 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 131 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
132 /* Cable register now active */ 132 /* Cable register now active */
133 pci_read_config_byte(pdev, 0x5A, &ata66); 133 pci_read_config_byte(pdev, 0x5A, &ata66);
134 /* Restore state */ 134 /* Restore state */
135 pci_write_config_byte(pdev, 0x5B, scr2); 135 pci_write_config_byte(pdev, 0x5B, scr2);
136 136
137 if (ata66 & (1 << ap->port_no)) 137 if (ata66 & (1 << ap->port_no))
138 ap->cbl = ATA_CBL_PATA40; 138 ap->cbl = ATA_CBL_PATA40;
139 else 139 else
140 ap->cbl = ATA_CBL_PATA80; 140 ap->cbl = ATA_CBL_PATA80;
141 141
142 /* Reset the state machine */ 142 /* Reset the state machine */
143 pci_write_config_byte(pdev, 0x50, 0x37); 143 pci_write_config_byte(pdev, 0x50, 0x37);
144 pci_write_config_byte(pdev, 0x54, 0x37); 144 pci_write_config_byte(pdev, 0x54, 0x37);
145 udelay(100); 145 udelay(100);
146 146
147 return ata_std_prereset(ap); 147 return ata_std_prereset(ap);
148} 148}
149 149
150/** 150/**
151 * hpt3x2n_error_handler - probe the hpt3x2n bus 151 * hpt3x2n_error_handler - probe the hpt3x2n bus
152 * @ap: ATA port to reset 152 * @ap: ATA port to reset
153 * 153 *
154 * Perform the probe reset handling for the 3x2N 154 * Perform the probe reset handling for the 3x2N
155 */ 155 */
156 156
157static void hpt3x2n_error_handler(struct ata_port *ap) 157static void hpt3x2n_error_handler(struct ata_port *ap)
158{ 158{
159 ata_bmdma_drive_eh(ap, hpt3xn_pre_reset, ata_std_softreset, NULL, ata_std_postreset); 159 ata_bmdma_drive_eh(ap, hpt3xn_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
160} 160}
161 161
162/** 162/**
163 * hpt3x2n_set_piomode - PIO setup 163 * hpt3x2n_set_piomode - PIO setup
164 * @ap: ATA interface 164 * @ap: ATA interface
165 * @adev: device on the interface 165 * @adev: device on the interface
166 * 166 *
167 * Perform PIO mode setup. 167 * Perform PIO mode setup.
168 */ 168 */
169 169
170static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev) 170static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
171{ 171{
172 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 172 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -177,12 +177,12 @@ static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
177 177
178 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 178 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
179 addr2 = 0x51 + 4 * ap->port_no; 179 addr2 = 0x51 + 4 * ap->port_no;
180 180
181 /* Fast interrupt prediction disable, hold off interrupt disable */ 181 /* Fast interrupt prediction disable, hold off interrupt disable */
182 pci_read_config_byte(pdev, addr2, &fast); 182 pci_read_config_byte(pdev, addr2, &fast);
183 fast &= ~0x07; 183 fast &= ~0x07;
184 pci_write_config_byte(pdev, addr2, fast); 184 pci_write_config_byte(pdev, addr2, fast);
185 185
186 pci_read_config_dword(pdev, addr1, &reg); 186 pci_read_config_dword(pdev, addr1, &reg);
187 mode = hpt3x2n_find_mode(ap, adev->pio_mode); 187 mode = hpt3x2n_find_mode(ap, adev->pio_mode);
188 mode &= ~0x8000000; /* No FIFO in PIO */ 188 mode &= ~0x8000000; /* No FIFO in PIO */
@@ -199,7 +199,7 @@ static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
199 * Set up the channel for MWDMA or UDMA modes. Much the same as with 199 * Set up the channel for MWDMA or UDMA modes. Much the same as with
200 * PIO, load the mode number and then set MWDMA or UDMA flag. 200 * PIO, load the mode number and then set MWDMA or UDMA flag.
201 */ 201 */
202 202
203static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev) 203static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
204{ 204{
205 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 205 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
@@ -210,12 +210,12 @@ static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
210 210
211 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 211 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
212 addr2 = 0x51 + 4 * ap->port_no; 212 addr2 = 0x51 + 4 * ap->port_no;
213 213
214 /* Fast interrupt prediction disable, hold off interrupt disable */ 214 /* Fast interrupt prediction disable, hold off interrupt disable */
215 pci_read_config_byte(pdev, addr2, &fast); 215 pci_read_config_byte(pdev, addr2, &fast);
216 fast &= ~0x07; 216 fast &= ~0x07;
217 pci_write_config_byte(pdev, addr2, fast); 217 pci_write_config_byte(pdev, addr2, fast);
218 218
219 pci_read_config_dword(pdev, addr1, &reg); 219 pci_read_config_dword(pdev, addr1, &reg);
220 mode = hpt3x2n_find_mode(ap, adev->dma_mode); 220 mode = hpt3x2n_find_mode(ap, adev->dma_mode);
221 mode |= 0x8000000; /* FIFO in MWDMA or UDMA */ 221 mode |= 0x8000000; /* FIFO in MWDMA or UDMA */
@@ -230,14 +230,14 @@ static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
230 * 230 *
231 * Clean up after the HPT3x2n and later DMA engine 231 * Clean up after the HPT3x2n and later DMA engine
232 */ 232 */
233 233
234static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc) 234static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc)
235{ 235{
236 struct ata_port *ap = qc->ap; 236 struct ata_port *ap = qc->ap;
237 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 237 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
238 int mscreg = 0x50 + 2 * ap->port_no; 238 int mscreg = 0x50 + 2 * ap->port_no;
239 u8 bwsr_stat, msc_stat; 239 u8 bwsr_stat, msc_stat;
240 240
241 pci_read_config_byte(pdev, 0x6A, &bwsr_stat); 241 pci_read_config_byte(pdev, 0x6A, &bwsr_stat);
242 pci_read_config_byte(pdev, mscreg, &msc_stat); 242 pci_read_config_byte(pdev, mscreg, &msc_stat);
243 if (bwsr_stat & (1 << ap->port_no)) 243 if (bwsr_stat & (1 << ap->port_no))
@@ -257,29 +257,29 @@ static void hpt3x2n_bmdma_stop(struct ata_queued_cmd *qc)
257 * - writing 257 * - writing
258 * - second channel UDMA7 (SATA ports) or higher 258 * - second channel UDMA7 (SATA ports) or higher
259 * - 66MHz PCI 259 * - 66MHz PCI
260 * 260 *
261 * or we will underclock the device and get reduced performance. 261 * or we will underclock the device and get reduced performance.
262 */ 262 */
263 263
264static void hpt3x2n_set_clock(struct ata_port *ap, int source) 264static void hpt3x2n_set_clock(struct ata_port *ap, int source)
265{ 265{
266 unsigned long bmdma = ap->ioaddr.bmdma_addr; 266 unsigned long bmdma = ap->ioaddr.bmdma_addr;
267 267
268 /* Tristate the bus */ 268 /* Tristate the bus */
269 outb(0x80, bmdma+0x73); 269 outb(0x80, bmdma+0x73);
270 outb(0x80, bmdma+0x77); 270 outb(0x80, bmdma+0x77);
271 271
272 /* Switch clock and reset channels */ 272 /* Switch clock and reset channels */
273 outb(source, bmdma+0x7B); 273 outb(source, bmdma+0x7B);
274 outb(0xC0, bmdma+0x79); 274 outb(0xC0, bmdma+0x79);
275 275
276 /* Reset state machines */ 276 /* Reset state machines */
277 outb(0x37, bmdma+0x70); 277 outb(0x37, bmdma+0x70);
278 outb(0x37, bmdma+0x74); 278 outb(0x37, bmdma+0x74);
279 279
280 /* Complete reset */ 280 /* Complete reset */
281 outb(0x00, bmdma+0x79); 281 outb(0x00, bmdma+0x79);
282 282
283 /* Reconnect channels to bus */ 283 /* Reconnect channels to bus */
284 outb(0x00, bmdma+0x73); 284 outb(0x00, bmdma+0x73);
285 outb(0x00, bmdma+0x77); 285 outb(0x00, bmdma+0x77);
@@ -291,7 +291,7 @@ static int hpt3x2n_pair_idle(struct ata_port *ap)
291{ 291{
292 struct ata_host *host = ap->host; 292 struct ata_host *host = ap->host;
293 struct ata_port *pair = host->ports[ap->port_no ^ 1]; 293 struct ata_port *pair = host->ports[ap->port_no ^ 1];
294 294
295 if (pair->hsm_task_state == HSM_ST_IDLE) 295 if (pair->hsm_task_state == HSM_ST_IDLE)
296 return 1; 296 return 1;
297 return 0; 297 return 0;
@@ -305,7 +305,7 @@ static int hpt3x2n_use_dpll(struct ata_port *ap, int reading)
305 return USE_DPLL; /* Needed for write */ 305 return USE_DPLL; /* Needed for write */
306 if (flags & PCI66) 306 if (flags & PCI66)
307 return USE_DPLL; /* Needed at 66Mhz */ 307 return USE_DPLL; /* Needed at 66Mhz */
308 return 0; 308 return 0;
309} 309}
310 310
311static unsigned int hpt3x2n_qc_issue_prot(struct ata_queued_cmd *qc) 311static unsigned int hpt3x2n_qc_issue_prot(struct ata_queued_cmd *qc)
@@ -313,7 +313,7 @@ static unsigned int hpt3x2n_qc_issue_prot(struct ata_queued_cmd *qc)
313 struct ata_taskfile *tf = &qc->tf; 313 struct ata_taskfile *tf = &qc->tf;
314 struct ata_port *ap = qc->ap; 314 struct ata_port *ap = qc->ap;
315 int flags = (long)ap->host->private_data; 315 int flags = (long)ap->host->private_data;
316 316
317 if (hpt3x2n_pair_idle(ap)) { 317 if (hpt3x2n_pair_idle(ap)) {
318 int dpll = hpt3x2n_use_dpll(ap, (tf->flags & ATA_TFLAG_WRITE)); 318 int dpll = hpt3x2n_use_dpll(ap, (tf->flags & ATA_TFLAG_WRITE));
319 if ((flags & USE_DPLL) != dpll) { 319 if ((flags & USE_DPLL) != dpll) {
@@ -347,13 +347,13 @@ static struct scsi_host_template hpt3x2n_sht = {
347/* 347/*
348 * Configuration for HPT3x2n. 348 * Configuration for HPT3x2n.
349 */ 349 */
350 350
351static struct ata_port_operations hpt3x2n_port_ops = { 351static struct ata_port_operations hpt3x2n_port_ops = {
352 .port_disable = ata_port_disable, 352 .port_disable = ata_port_disable,
353 .set_piomode = hpt3x2n_set_piomode, 353 .set_piomode = hpt3x2n_set_piomode,
354 .set_dmamode = hpt3x2n_set_dmamode, 354 .set_dmamode = hpt3x2n_set_dmamode,
355 .mode_filter = ata_pci_default_filter, 355 .mode_filter = ata_pci_default_filter,
356 356
357 .tf_load = ata_tf_load, 357 .tf_load = ata_tf_load,
358 .tf_read = ata_tf_read, 358 .tf_read = ata_tf_read,
359 .check_status = ata_check_status, 359 .check_status = ata_check_status,
@@ -381,11 +381,11 @@ static struct ata_port_operations hpt3x2n_port_ops = {
381 .port_start = ata_port_start, 381 .port_start = ata_port_start,
382 .port_stop = ata_port_stop, 382 .port_stop = ata_port_stop,
383 .host_stop = ata_host_stop 383 .host_stop = ata_host_stop
384}; 384};
385 385
386/** 386/**
387 * hpt3xn_calibrate_dpll - Calibrate the DPLL loop 387 * hpt3xn_calibrate_dpll - Calibrate the DPLL loop
388 * @dev: PCI device 388 * @dev: PCI device
389 * 389 *
390 * Perform a calibration cycle on the HPT3xN DPLL. Returns 1 if this 390 * Perform a calibration cycle on the HPT3xN DPLL. Returns 1 if this
391 * succeeds 391 * succeeds
@@ -396,7 +396,7 @@ static int hpt3xn_calibrate_dpll(struct pci_dev *dev)
396 u8 reg5b; 396 u8 reg5b;
397 u32 reg5c; 397 u32 reg5c;
398 int tries; 398 int tries;
399 399
400 for(tries = 0; tries < 0x5000; tries++) { 400 for(tries = 0; tries < 0x5000; tries++) {
401 udelay(50); 401 udelay(50);
402 pci_read_config_byte(dev, 0x5b, &reg5b); 402 pci_read_config_byte(dev, 0x5b, &reg5b);
@@ -422,16 +422,16 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
422{ 422{
423 unsigned long freq; 423 unsigned long freq;
424 u32 fcnt; 424 u32 fcnt;
425 425
426 pci_read_config_dword(pdev, 0x70/*CHECKME*/, &fcnt); 426 pci_read_config_dword(pdev, 0x70/*CHECKME*/, &fcnt);
427 if ((fcnt >> 12) != 0xABCDE) { 427 if ((fcnt >> 12) != 0xABCDE) {
428 printk(KERN_WARNING "hpt3xn: BIOS clock data not set.\n"); 428 printk(KERN_WARNING "hpt3xn: BIOS clock data not set.\n");
429 return 33; /* Not BIOS set */ 429 return 33; /* Not BIOS set */
430 } 430 }
431 fcnt &= 0x1FF; 431 fcnt &= 0x1FF;
432 432
433 freq = (fcnt * 77) / 192; 433 freq = (fcnt * 77) / 192;
434 434
435 /* Clamp to bands */ 435 /* Clamp to bands */
436 if (freq < 40) 436 if (freq < 40)
437 return 33; 437 return 33;
@@ -471,7 +471,7 @@ static int hpt3x2n_pci_clock(struct pci_dev *pdev)
471 * 471 *
472 * To pin down HPT371N 472 * To pin down HPT371N
473 */ 473 */
474 474
475static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id) 475static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
476{ 476{
477 /* HPT372N and friends - UDMA133 */ 477 /* HPT372N and friends - UDMA133 */
@@ -488,14 +488,14 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
488 488
489 u8 irqmask; 489 u8 irqmask;
490 u32 class_rev; 490 u32 class_rev;
491 491
492 unsigned int pci_mhz; 492 unsigned int pci_mhz;
493 unsigned int f_low, f_high; 493 unsigned int f_low, f_high;
494 int adjust; 494 int adjust;
495 495
496 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); 496 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
497 class_rev &= 0xFF; 497 class_rev &= 0xFF;
498 498
499 switch(dev->device) { 499 switch(dev->device) {
500 case PCI_DEVICE_ID_TTI_HPT366: 500 case PCI_DEVICE_ID_TTI_HPT366:
501 if (class_rev < 6) 501 if (class_rev < 6)
@@ -530,16 +530,16 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
530 530
531 /* Tune the PLL. HPT recommend using 75 for SATA, 66 for UDMA133 or 531 /* Tune the PLL. HPT recommend using 75 for SATA, 66 for UDMA133 or
532 50 for UDMA100. Right now we always use 66 */ 532 50 for UDMA100. Right now we always use 66 */
533 533
534 pci_mhz = hpt3x2n_pci_clock(dev); 534 pci_mhz = hpt3x2n_pci_clock(dev);
535 535
536 f_low = (pci_mhz * 48) / 66; /* PCI Mhz for 66Mhz DPLL */ 536 f_low = (pci_mhz * 48) / 66; /* PCI Mhz for 66Mhz DPLL */
537 f_high = f_low + 2; /* Tolerance */ 537 f_high = f_low + 2; /* Tolerance */
538 538
539 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100); 539 pci_write_config_dword(dev, 0x5C, (f_high << 16) | f_low | 0x100);
540 /* PLL clock */ 540 /* PLL clock */
541 pci_write_config_byte(dev, 0x5B, 0x21); 541 pci_write_config_byte(dev, 0x5B, 0x21);
542 542
543 /* Unlike the 37x we don't try jiggling the frequency */ 543 /* Unlike the 37x we don't try jiggling the frequency */
544 for(adjust = 0; adjust < 8; adjust++) { 544 for(adjust = 0; adjust < 8; adjust++) {
545 if (hpt3xn_calibrate_dpll(dev)) 545 if (hpt3xn_calibrate_dpll(dev))
@@ -554,7 +554,7 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
554 port->private_data = NULL; 554 port->private_data = NULL;
555 if (pci_mhz > 60) 555 if (pci_mhz > 60)
556 port->private_data = (void *)PCI66; 556 port->private_data = (void *)PCI66;
557 557
558 /* Now kick off ATA set up */ 558 /* Now kick off ATA set up */
559 port_info[0] = port_info[1] = port; 559 port_info[0] = port_info[1] = port;
560 return ata_pci_init_one(dev, port_info, 2); 560 return ata_pci_init_one(dev, port_info, 2);