aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_optidma.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_optidma.c')
-rw-r--r--drivers/ata/pata_optidma.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/ata/pata_optidma.c b/drivers/ata/pata_optidma.c
index 800aea7b9444..177a455f4251 100644
--- a/drivers/ata/pata_optidma.c
+++ b/drivers/ata/pata_optidma.c
@@ -51,11 +51,11 @@ static int pci_clock; /* 0 = 33 1 = 25 */
51 * 51 *
52 * Set up cable type and use generic probe init 52 * Set up cable type and use generic probe init
53 */ 53 */
54 54
55static int optidma_pre_reset(struct ata_port *ap) 55static int optidma_pre_reset(struct ata_port *ap)
56{ 56{
57 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 57 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
58 static const struct pci_bits optidma_enable_bits = { 58 static const struct pci_bits optidma_enable_bits = {
59 0x40, 1, 0x08, 0x00 59 0x40, 1, 0x08, 0x00
60 }; 60 };
61 61
@@ -90,11 +90,11 @@ static void optidma_error_handler(struct ata_port *ap)
90 * Unlock the control register block for this adapter. Registers must not 90 * Unlock the control register block for this adapter. Registers must not
91 * be unlocked in a situation where libata might look at them. 91 * be unlocked in a situation where libata might look at them.
92 */ 92 */
93 93
94static void optidma_unlock(struct ata_port *ap) 94static void optidma_unlock(struct ata_port *ap)
95{ 95{
96 unsigned long regio = ap->ioaddr.cmd_addr; 96 unsigned long regio = ap->ioaddr.cmd_addr;
97 97
98 /* These 3 unlock the control register access */ 98 /* These 3 unlock the control register access */
99 inw(regio + 1); 99 inw(regio + 1);
100 inw(regio + 1); 100 inw(regio + 1);
@@ -107,11 +107,11 @@ static void optidma_unlock(struct ata_port *ap)
107 * 107 *
108 * Re-lock the configuration register settings. 108 * Re-lock the configuration register settings.
109 */ 109 */
110 110
111static void optidma_lock(struct ata_port *ap) 111static void optidma_lock(struct ata_port *ap)
112{ 112{
113 unsigned long regio = ap->ioaddr.cmd_addr; 113 unsigned long regio = ap->ioaddr.cmd_addr;
114 114
115 /* Relock */ 115 /* Relock */
116 outb(0x83, regio + 2); 116 outb(0x83, regio + 2);
117} 117}
@@ -154,7 +154,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
154 154
155 /* Switch from IDE to control mode */ 155 /* Switch from IDE to control mode */
156 optidma_unlock(ap); 156 optidma_unlock(ap);
157 157
158 158
159 /* 159 /*
160 * As with many controllers the address setup time is shared 160 * As with many controllers the address setup time is shared
@@ -166,7 +166,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
166 addr = 0; 166 addr = 0;
167 else 167 else
168 addr = addr_timing[pci_clock][pio]; 168 addr = addr_timing[pci_clock][pio];
169 169
170 if (pair) { 170 if (pair) {
171 u8 pair_addr; 171 u8 pair_addr;
172 /* Hardware constraint */ 172 /* Hardware constraint */
@@ -177,7 +177,7 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
177 if (pair_addr > addr) 177 if (pair_addr > addr)
178 addr = pair_addr; 178 addr = pair_addr;
179 } 179 }
180 180
181 /* Commence primary programming sequence */ 181 /* Commence primary programming sequence */
182 /* First we load the device number into the timing select */ 182 /* First we load the device number into the timing select */
183 outb(adev->devno, regio + MISC_REG); 183 outb(adev->devno, regio + MISC_REG);
@@ -194,10 +194,10 @@ static void optidma_set_mode(struct ata_port *ap, struct ata_device *adev, u8 mo
194 194
195 /* Programming sequence complete, timing 0 dev 0, timing 1 dev 1 */ 195 /* Programming sequence complete, timing 0 dev 0, timing 1 dev 1 */
196 outb(0x85, regio + CNTRL_REG); 196 outb(0x85, regio + CNTRL_REG);
197 197
198 /* Switch back to IDE mode */ 198 /* Switch back to IDE mode */
199 optidma_lock(ap); 199 optidma_lock(ap);
200 200
201 /* Note: at this point our programming is incomplete. We are 201 /* Note: at this point our programming is incomplete. We are
202 not supposed to program PCI 0x43 "things we hacked onto the chip" 202 not supposed to program PCI 0x43 "things we hacked onto the chip"
203 until we've done both sets of PIO/DMA timings */ 203 until we've done both sets of PIO/DMA timings */
@@ -223,7 +223,7 @@ static void optiplus_set_mode(struct ata_port *ap, struct ata_device *adev, u8 m
223 int dev2 = 2 * adev->devno; 223 int dev2 = 2 * adev->devno;
224 int unit = 2 * ap->port_no + adev->devno; 224 int unit = 2 * ap->port_no + adev->devno;
225 int udma = mode - XFER_UDMA_0; 225 int udma = mode - XFER_UDMA_0;
226 226
227 pci_read_config_byte(pdev, 0x44, &udcfg); 227 pci_read_config_byte(pdev, 0x44, &udcfg);
228 if (mode <= XFER_UDMA_0) { 228 if (mode <= XFER_UDMA_0) {
229 udcfg &= ~(1 << unit); 229 udcfg &= ~(1 << unit);
@@ -252,7 +252,7 @@ static void optiplus_set_mode(struct ata_port *ap, struct ata_device *adev, u8 m
252 * DMA programming. The architecture of the Firestar makes it easier 252 * DMA programming. The architecture of the Firestar makes it easier
253 * for us to have a common function so we provide wrappers 253 * for us to have a common function so we provide wrappers
254 */ 254 */
255 255
256static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev) 256static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
257{ 257{
258 optidma_set_mode(ap, adev, adev->pio_mode); 258 optidma_set_mode(ap, adev, adev->pio_mode);
@@ -267,7 +267,7 @@ static void optidma_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
267 * DMA programming. The architecture of the Firestar makes it easier 267 * DMA programming. The architecture of the Firestar makes it easier
268 * for us to have a common function so we provide wrappers 268 * for us to have a common function so we provide wrappers
269 */ 269 */
270 270
271static void optidma_set_dma_mode(struct ata_port *ap, struct ata_device *adev) 271static void optidma_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
272{ 272{
273 optidma_set_mode(ap, adev, adev->dma_mode); 273 optidma_set_mode(ap, adev, adev->dma_mode);
@@ -282,7 +282,7 @@ static void optidma_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
282 * DMA programming. The architecture of the Firestar makes it easier 282 * DMA programming. The architecture of the Firestar makes it easier
283 * for us to have a common function so we provide wrappers 283 * for us to have a common function so we provide wrappers
284 */ 284 */
285 285
286static void optiplus_set_pio_mode(struct ata_port *ap, struct ata_device *adev) 286static void optiplus_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
287{ 287{
288 optiplus_set_mode(ap, adev, adev->pio_mode); 288 optiplus_set_mode(ap, adev, adev->pio_mode);
@@ -297,7 +297,7 @@ static void optiplus_set_pio_mode(struct ata_port *ap, struct ata_device *adev)
297 * DMA programming. The architecture of the Firestar makes it easier 297 * DMA programming. The architecture of the Firestar makes it easier
298 * for us to have a common function so we provide wrappers 298 * for us to have a common function so we provide wrappers
299 */ 299 */
300 300
301static void optiplus_set_dma_mode(struct ata_port *ap, struct ata_device *adev) 301static void optiplus_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
302{ 302{
303 optiplus_set_mode(ap, adev, adev->dma_mode); 303 optiplus_set_mode(ap, adev, adev->dma_mode);
@@ -310,7 +310,7 @@ static void optiplus_set_dma_mode(struct ata_port *ap, struct ata_device *adev)
310 * Turn the ATA device setup into PCI configuration bits 310 * Turn the ATA device setup into PCI configuration bits
311 * for register 0x43 and return the two bits needed. 311 * for register 0x43 and return the two bits needed.
312 */ 312 */
313 313
314static u8 optidma_make_bits43(struct ata_device *adev) 314static u8 optidma_make_bits43(struct ata_device *adev)
315{ 315{
316 static const u8 bits43[5] = { 316 static const u8 bits43[5] = {
@@ -330,17 +330,17 @@ static u8 optidma_make_bits43(struct ata_device *adev)
330 * Finalise the configuration by writing the nibble of extra bits 330 * Finalise the configuration by writing the nibble of extra bits
331 * of data into the chip. 331 * of data into the chip.
332 */ 332 */
333 333
334static void optidma_post_set_mode(struct ata_port *ap) 334static void optidma_post_set_mode(struct ata_port *ap)
335{ 335{
336 u8 r; 336 u8 r;
337 int nybble = 4 * ap->port_no; 337 int nybble = 4 * ap->port_no;
338 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 338 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
339 339
340 pci_read_config_byte(pdev, 0x43, &r); 340 pci_read_config_byte(pdev, 0x43, &r);
341 341
342 r &= (0x0F << nybble); 342 r &= (0x0F << nybble);
343 r |= (optidma_make_bits43(&ap->device[0]) + 343 r |= (optidma_make_bits43(&ap->device[0]) +
344 (optidma_make_bits43(&ap->device[0]) << 2)) << nybble; 344 (optidma_make_bits43(&ap->device[0]) << 2)) << nybble;
345 345
346 pci_write_config_byte(pdev, 0x43, r); 346 pci_write_config_byte(pdev, 0x43, r);
@@ -438,19 +438,19 @@ static struct ata_port_operations optiplus_port_ops = {
438 * optiplus_with_udma - Look for UDMA capable setup 438 * optiplus_with_udma - Look for UDMA capable setup
439 * @pdev; ATA controller 439 * @pdev; ATA controller
440 */ 440 */
441 441
442static int optiplus_with_udma(struct pci_dev *pdev) 442static int optiplus_with_udma(struct pci_dev *pdev)
443{ 443{
444 u8 r; 444 u8 r;
445 int ret = 0; 445 int ret = 0;
446 int ioport = 0x22; 446 int ioport = 0x22;
447 struct pci_dev *dev1; 447 struct pci_dev *dev1;
448 448
449 /* Find function 1 */ 449 /* Find function 1 */
450 dev1 = pci_get_device(0x1045, 0xC701, NULL); 450 dev1 = pci_get_device(0x1045, 0xC701, NULL);
451 if(dev1 == NULL) 451 if(dev1 == NULL)
452 return 0; 452 return 0;
453 453
454 /* Rev must be >= 0x10 */ 454 /* Rev must be >= 0x10 */
455 pci_read_config_byte(dev1, 0x08, &r); 455 pci_read_config_byte(dev1, 0x08, &r);
456 if (r < 0x10) 456 if (r < 0x10)
@@ -470,7 +470,7 @@ static int optiplus_with_udma(struct pci_dev *pdev)
470 pci_read_config_byte(dev1, 0x52, &r); 470 pci_read_config_byte(dev1, 0x52, &r);
471 if (r & 0x80) /* IDEDIR disabled */ 471 if (r & 0x80) /* IDEDIR disabled */
472 ret = 1; 472 ret = 1;
473done: 473done:
474 printk(KERN_WARNING "UDMA not supported in this configuration.\n"); 474 printk(KERN_WARNING "UDMA not supported in this configuration.\n");
475done_nomsg: /* Wrong chip revision */ 475done_nomsg: /* Wrong chip revision */
476 pci_dev_put(dev1); 476 pci_dev_put(dev1);
@@ -505,7 +505,7 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
505 inw(0x1F1); 505 inw(0x1F1);
506 inw(0x1F1); 506 inw(0x1F1);
507 pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */ 507 pci_clock = inb(0x1F5) & 1; /* 0 = 33Mhz, 1 = 25Mhz */
508 508
509 if (optiplus_with_udma(dev)) 509 if (optiplus_with_udma(dev))
510 info = &info_82c700_udma; 510 info = &info_82c700_udma;
511 511