aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/pata_optidma.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 9764907e8a13..b70e04c144df 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -33,7 +33,7 @@
33#include <linux/libata.h> 33#include <linux/libata.h>
34 34
35#define DRV_NAME "pata_optidma" 35#define DRV_NAME "pata_optidma"
36#define DRV_VERSION "0.2.4" 36#define DRV_VERSION "0.3.2"
37 37
38enum { 38enum {
39 READ_REG = 0, /* index of Read cycle timing register */ 39 READ_REG = 0, /* index of Read cycle timing register */
@@ -62,7 +62,6 @@ static int optidma_pre_reset(struct ata_port *ap)
62 if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits)) 62 if (ap->port_no && !pci_test_config_bits(pdev, &optidma_enable_bits))
63 return -ENOENT; 63 return -ENOENT;
64 64
65 ap->cbl = ATA_CBL_PATA40;
66 return ata_std_prereset(ap); 65 return ata_std_prereset(ap);
67} 66}
68 67
@@ -115,7 +114,7 @@ static void optidma_lock(struct ata_port *ap)
115} 114}
116 115
117/** 116/**
118 * optidma_set_mode - set mode data 117 * optidma_mode_setup - set mode data
119 * @ap: ATA interface 118 * @ap: ATA interface
120 * @adev: ATA device 119 * @adev: ATA device
121 * @mode: Mode to set 120 * @mode: Mode to set
@@ -128,7 +127,7 @@ static void optidma_lock(struct ata_port *ap)
128 * IRQ here we depend on the host set locking to avoid catastrophe. 127 * IRQ here we depend on the host set locking to avoid catastrophe.
129 */ 128 */
130 129
131static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mode) 130static void optidma_mode_setup(struct ata_port *ap, struct ata_device *adev, u8 mode)
132{ 131{
133 struct ata_device *pair = ata_dev_pair(adev); 132 struct ata_device *pair = ata_dev_pair(adev);
134 int pio = adev->pio_mode - XFER_PIO_0; 133 int pio = adev->pio_mode - XFER_PIO_0;
@@ -202,7 +201,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
202} 201}
203 202
204/** 203/**
205 * optiplus_set_mode - DMA setup for Firestar Plus 204 * optiplus_mode_setup - DMA setup for Firestar Plus
206 * @ap: ATA port 205 * @ap: ATA port
207 * @adev: device 206 * @adev: device
208 * @mode: desired mode 207 * @mode: desired mode
@@ -213,7 +212,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
213 * one 212 * one
214 */ 213 */
215 214
216static void optiplus_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mode) 215static void optiplus_mode_setup(struct ata_port *ap, struct ata_device *adev, u8 mode)
217{ 216{
218 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 217 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
219 u8 udcfg; 218 u8 udcfg;
@@ -225,7 +224,7 @@ static void optiplus_set_mode(struct ata_port *ap, struct ata_device *adev, u8 m
225 pci_read_config_byte(pdev, 0x44, &udcfg); 224 pci_read_config_byte(pdev, 0x44, &udcfg);
226 if (mode <= XFER_UDMA_0) { 225 if (mode <= XFER_UDMA_0) {
227 udcfg &= ~(1 << unit); 226 udcfg &= ~(1 << unit);
228 optidma_set_mode(ap, adev, adev->dma_mode); 227 optidma_mode_setup(ap, adev, adev->dma_mode);
229 } else { 228 } else {
230 udcfg |= (1 << unit); 229 udcfg |= (1 << unit);
231 if (ap->port_no) { 230 if (ap->port_no) {
@@ -253,7 +252,7 @@ static void optiplus_set_mode(struct ata_port *ap, struct ata_device *adev, u8 m
253 252
254static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev) 253static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
255{ 254{
256 optidma_set_mode(ap, adev, adev->pio_mode); 255 optidma_mode_setup(ap, adev, adev->pio_mode);
257} 256}
258 257
259/** 258/**
@@ -268,7 +267,7 @@ static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
268 267
269static void optidma_set_dma_mode(struct ata_port *ap, struct ata_device *adev) 268static void optidma_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
270{ 269{
271 optidma_set_mode(ap, adev, adev->dma_mode); 270 optidma_mode_setup(ap, adev, adev->dma_mode);
272} 271}
273 272
274/** 273/**
@@ -283,7 +282,7 @@ static void optidma_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
283 282
284static void optiplus_set_pio_mode(struct ata_port *ap, struct ata_device *adev) 283static void optiplus_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
285{ 284{
286 optiplus_set_mode(ap, adev, adev->pio_mode); 285 optiplus_mode_setup(ap, adev, adev->pio_mode);
287} 286}
288 287
289/** 288/**
@@ -298,7 +297,7 @@ static void optiplus_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
298 297
299static void optiplus_set_dma_mode(struct ata_port *ap, struct ata_device *adev) 298static void optiplus_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
300{ 299{
301 optiplus_set_mode(ap, adev, adev->dma_mode); 300 optiplus_mode_setup(ap, adev, adev->dma_mode);
302} 301}
303 302
304/** 303/**
@@ -322,26 +321,29 @@ static u8 optidma_make_bits43(struct ata_device *adev)
322} 321}
323 322
324/** 323/**
325 * optidma_post_set_mode - finalize PCI setup 324 * optidma_set_mode - mode setup
326 * @ap: port to set up 325 * @ap: port to set up
327 * 326 *
328 * Finalise the configuration by writing the nibble of extra bits 327 * Use the standard setup to tune the chipset and then finalise the
329 * of data into the chip. 328 * configuration by writing the nibble of extra bits of data into
329 * the chip.
330 */ 330 */
331 331
332static void optidma_post_set_mode(struct ata_port *ap) 332static int optidma_set_mode(struct ata_port *ap, struct ata_device **r_failed)
333{ 333{
334 u8 r; 334 u8 r;
335 int nybble = 4 * ap->port_no; 335 int nybble = 4 * ap->port_no;
336 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 336 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
337 337 int rc = ata_do_set_mode(ap, r_failed);
338 pci_read_config_byte(pdev, 0x43, &r); 338 if (rc == 0) {
339 339 pci_read_config_byte(pdev, 0x43, &r);
340 r &= (0x0F << nybble); 340
341 r |= (optidma_make_bits43(&ap->device[0]) + 341 r &= (0x0F << nybble);
342 (optidma_make_bits43(&ap->device[0]) << 2)) << nybble; 342 r |= (optidma_make_bits43(&ap->device[0]) +
343 343 (optidma_make_bits43(&ap->device[0]) << 2)) << nybble;
344 pci_write_config_byte(pdev, 0x43, r); 344 pci_write_config_byte(pdev, 0x43, r);
345 }
346 return rc;
345} 347}
346 348
347static struct scsi_host_template optidma_sht = { 349static struct scsi_host_template optidma_sht = {
@@ -381,7 +383,8 @@ static struct ata_port_operations optidma_port_ops = {
381 .thaw = ata_bmdma_thaw, 383 .thaw = ata_bmdma_thaw,
382 .post_internal_cmd = ata_bmdma_post_internal_cmd, 384 .post_internal_cmd = ata_bmdma_post_internal_cmd,
383 .error_handler = optidma_error_handler, 385 .error_handler = optidma_error_handler,
384 .post_set_mode = optidma_post_set_mode, 386 .set_mode = optidma_set_mode,
387 .cable_detect = ata_cable_40wire,
385 388
386 .bmdma_setup = ata_bmdma_setup, 389 .bmdma_setup = ata_bmdma_setup,
387 .bmdma_start = ata_bmdma_start, 390 .bmdma_start = ata_bmdma_start,
@@ -416,7 +419,8 @@ static struct ata_port_operations optiplus_port_ops = {
416 .thaw = ata_bmdma_thaw, 419 .thaw = ata_bmdma_thaw,
417 .post_internal_cmd = ata_bmdma_post_internal_cmd, 420 .post_internal_cmd = ata_bmdma_post_internal_cmd,
418 .error_handler = optidma_error_handler, 421 .error_handler = optidma_error_handler,
419 .post_set_mode = optidma_post_set_mode, 422 .set_mode = optidma_set_mode,
423 .cable_detect = ata_cable_40wire,
420 424
421 .bmdma_setup = ata_bmdma_setup, 425 .bmdma_setup = ata_bmdma_setup,
422 .bmdma_start = ata_bmdma_start, 426 .bmdma_start = ata_bmdma_start,