aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport/parport_pc.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-06-11 17:31:52 -0400
committerIngo Molnar <mingo@elte.hu>2009-06-11 17:31:52 -0400
commit0d5959723e1db3fd7323c198a50c16cecf96c7a9 (patch)
tree802b623fff261ebcbbddadf84af5524398364a18 /drivers/parport/parport_pc.c
parent62fdac5913f71f8f200bd2c9bd59a02e9a1498e9 (diff)
parent512626a04e72aca60effe111fa0333ed0b195d21 (diff)
Merge branch 'linus' into x86/mce3
Conflicts: arch/x86/kernel/cpu/mcheck/mce_64.c arch/x86/kernel/irq.c Merge reason: Resolve the conflicts above. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/parport/parport_pc.c')
-rw-r--r--drivers/parport/parport_pc.c1802
1 files changed, 953 insertions, 849 deletions
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 4e63cc9e2778..151bf5bc8afe 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1,5 +1,5 @@
1/* Low-level parallel-port routines for 8255-based PC-style hardware. 1/* Low-level parallel-port routines for 8255-based PC-style hardware.
2 * 2 *
3 * Authors: Phil Blundell <philb@gnu.org> 3 * Authors: Phil Blundell <philb@gnu.org>
4 * Tim Waugh <tim@cyberelk.demon.co.uk> 4 * Tim Waugh <tim@cyberelk.demon.co.uk>
5 * Jose Renau <renau@acm.org> 5 * Jose Renau <renau@acm.org>
@@ -11,7 +11,7 @@
11 * Cleaned up include files - Russell King <linux@arm.uk.linux.org> 11 * Cleaned up include files - Russell King <linux@arm.uk.linux.org>
12 * DMA support - Bert De Jonghe <bert@sophis.be> 12 * DMA support - Bert De Jonghe <bert@sophis.be>
13 * Many ECP bugs fixed. Fred Barnes & Jamie Lokier, 1999 13 * Many ECP bugs fixed. Fred Barnes & Jamie Lokier, 1999
14 * More PCI support now conditional on CONFIG_PCI, 03/2001, Paul G. 14 * More PCI support now conditional on CONFIG_PCI, 03/2001, Paul G.
15 * Various hacks, Fred Barnes, 04/2001 15 * Various hacks, Fred Barnes, 04/2001
16 * Updated probing logic - Adam Belay <ambx1@neo.rr.com> 16 * Updated probing logic - Adam Belay <ambx1@neo.rr.com>
17 */ 17 */
@@ -56,10 +56,10 @@
56#include <linux/pnp.h> 56#include <linux/pnp.h>
57#include <linux/platform_device.h> 57#include <linux/platform_device.h>
58#include <linux/sysctl.h> 58#include <linux/sysctl.h>
59#include <linux/io.h>
60#include <linux/uaccess.h>
59 61
60#include <asm/io.h>
61#include <asm/dma.h> 62#include <asm/dma.h>
62#include <asm/uaccess.h>
63 63
64#include <linux/parport.h> 64#include <linux/parport.h>
65#include <linux/parport_pc.h> 65#include <linux/parport_pc.h>
@@ -82,7 +82,7 @@
82#define ECR_TST 06 82#define ECR_TST 06
83#define ECR_CNF 07 83#define ECR_CNF 07
84#define ECR_MODE_MASK 0xe0 84#define ECR_MODE_MASK 0xe0
85#define ECR_WRITE(p,v) frob_econtrol((p),0xff,(v)) 85#define ECR_WRITE(p, v) frob_econtrol((p), 0xff, (v))
86 86
87#undef DEBUG 87#undef DEBUG
88 88
@@ -109,27 +109,27 @@ static int pci_registered_parport;
109static int pnp_registered_parport; 109static int pnp_registered_parport;
110 110
111/* frob_control, but for ECR */ 111/* frob_control, but for ECR */
112static void frob_econtrol (struct parport *pb, unsigned char m, 112static void frob_econtrol(struct parport *pb, unsigned char m,
113 unsigned char v) 113 unsigned char v)
114{ 114{
115 unsigned char ectr = 0; 115 unsigned char ectr = 0;
116 116
117 if (m != 0xff) 117 if (m != 0xff)
118 ectr = inb (ECONTROL (pb)); 118 ectr = inb(ECONTROL(pb));
119 119
120 DPRINTK (KERN_DEBUG "frob_econtrol(%02x,%02x): %02x -> %02x\n", 120 DPRINTK(KERN_DEBUG "frob_econtrol(%02x,%02x): %02x -> %02x\n",
121 m, v, ectr, (ectr & ~m) ^ v); 121 m, v, ectr, (ectr & ~m) ^ v);
122 122
123 outb ((ectr & ~m) ^ v, ECONTROL (pb)); 123 outb((ectr & ~m) ^ v, ECONTROL(pb));
124} 124}
125 125
126static __inline__ void frob_set_mode (struct parport *p, int mode) 126static inline void frob_set_mode(struct parport *p, int mode)
127{ 127{
128 frob_econtrol (p, ECR_MODE_MASK, mode << 5); 128 frob_econtrol(p, ECR_MODE_MASK, mode << 5);
129} 129}
130 130
131#ifdef CONFIG_PARPORT_PC_FIFO 131#ifdef CONFIG_PARPORT_PC_FIFO
132/* Safely change the mode bits in the ECR 132/* Safely change the mode bits in the ECR
133 Returns: 133 Returns:
134 0 : Success 134 0 : Success
135 -EBUSY: Could not drain FIFO in some finite amount of time, 135 -EBUSY: Could not drain FIFO in some finite amount of time,
@@ -141,17 +141,18 @@ static int change_mode(struct parport *p, int m)
141 unsigned char oecr; 141 unsigned char oecr;
142 int mode; 142 int mode;
143 143
144 DPRINTK(KERN_INFO "parport change_mode ECP-ISA to mode 0x%02x\n",m); 144 DPRINTK(KERN_INFO "parport change_mode ECP-ISA to mode 0x%02x\n", m);
145 145
146 if (!priv->ecr) { 146 if (!priv->ecr) {
147 printk (KERN_DEBUG "change_mode: but there's no ECR!\n"); 147 printk(KERN_DEBUG "change_mode: but there's no ECR!\n");
148 return 0; 148 return 0;
149 } 149 }
150 150
151 /* Bits <7:5> contain the mode. */ 151 /* Bits <7:5> contain the mode. */
152 oecr = inb (ECONTROL (p)); 152 oecr = inb(ECONTROL(p));
153 mode = (oecr >> 5) & 0x7; 153 mode = (oecr >> 5) & 0x7;
154 if (mode == m) return 0; 154 if (mode == m)
155 return 0;
155 156
156 if (mode >= 2 && !(priv->ctr & 0x20)) { 157 if (mode >= 2 && !(priv->ctr & 0x20)) {
157 /* This mode resets the FIFO, so we may 158 /* This mode resets the FIFO, so we may
@@ -163,19 +164,21 @@ static int change_mode(struct parport *p, int m)
163 case ECR_ECP: /* ECP Parallel Port mode */ 164 case ECR_ECP: /* ECP Parallel Port mode */
164 /* Busy wait for 200us */ 165 /* Busy wait for 200us */
165 for (counter = 0; counter < 40; counter++) { 166 for (counter = 0; counter < 40; counter++) {
166 if (inb (ECONTROL (p)) & 0x01) 167 if (inb(ECONTROL(p)) & 0x01)
168 break;
169 if (signal_pending(current))
167 break; 170 break;
168 if (signal_pending (current)) break; 171 udelay(5);
169 udelay (5);
170 } 172 }
171 173
172 /* Poll slowly. */ 174 /* Poll slowly. */
173 while (!(inb (ECONTROL (p)) & 0x01)) { 175 while (!(inb(ECONTROL(p)) & 0x01)) {
174 if (time_after_eq (jiffies, expire)) 176 if (time_after_eq(jiffies, expire))
175 /* The FIFO is stuck. */ 177 /* The FIFO is stuck. */
176 return -EBUSY; 178 return -EBUSY;
177 schedule_timeout_interruptible(msecs_to_jiffies(10)); 179 schedule_timeout_interruptible(
178 if (signal_pending (current)) 180 msecs_to_jiffies(10));
181 if (signal_pending(current))
179 break; 182 break;
180 } 183 }
181 } 184 }
@@ -185,20 +188,20 @@ static int change_mode(struct parport *p, int m)
185 /* We have to go through mode 001 */ 188 /* We have to go through mode 001 */
186 oecr &= ~(7 << 5); 189 oecr &= ~(7 << 5);
187 oecr |= ECR_PS2 << 5; 190 oecr |= ECR_PS2 << 5;
188 ECR_WRITE (p, oecr); 191 ECR_WRITE(p, oecr);
189 } 192 }
190 193
191 /* Set the mode. */ 194 /* Set the mode. */
192 oecr &= ~(7 << 5); 195 oecr &= ~(7 << 5);
193 oecr |= m << 5; 196 oecr |= m << 5;
194 ECR_WRITE (p, oecr); 197 ECR_WRITE(p, oecr);
195 return 0; 198 return 0;
196} 199}
197 200
198#ifdef CONFIG_PARPORT_1284 201#ifdef CONFIG_PARPORT_1284
199/* Find FIFO lossage; FIFO is reset */ 202/* Find FIFO lossage; FIFO is reset */
200#if 0 203#if 0
201static int get_fifo_residue (struct parport *p) 204static int get_fifo_residue(struct parport *p)
202{ 205{
203 int residue; 206 int residue;
204 int cnfga; 207 int cnfga;
@@ -206,26 +209,26 @@ static int get_fifo_residue (struct parport *p)
206 209
207 /* Adjust for the contents of the FIFO. */ 210 /* Adjust for the contents of the FIFO. */
208 for (residue = priv->fifo_depth; ; residue--) { 211 for (residue = priv->fifo_depth; ; residue--) {
209 if (inb (ECONTROL (p)) & 0x2) 212 if (inb(ECONTROL(p)) & 0x2)
210 /* Full up. */ 213 /* Full up. */
211 break; 214 break;
212 215
213 outb (0, FIFO (p)); 216 outb(0, FIFO(p));
214 } 217 }
215 218
216 printk (KERN_DEBUG "%s: %d PWords were left in FIFO\n", p->name, 219 printk(KERN_DEBUG "%s: %d PWords were left in FIFO\n", p->name,
217 residue); 220 residue);
218 221
219 /* Reset the FIFO. */ 222 /* Reset the FIFO. */
220 frob_set_mode (p, ECR_PS2); 223 frob_set_mode(p, ECR_PS2);
221 224
222 /* Now change to config mode and clean up. FIXME */ 225 /* Now change to config mode and clean up. FIXME */
223 frob_set_mode (p, ECR_CNF); 226 frob_set_mode(p, ECR_CNF);
224 cnfga = inb (CONFIGA (p)); 227 cnfga = inb(CONFIGA(p));
225 printk (KERN_DEBUG "%s: cnfgA contains 0x%02x\n", p->name, cnfga); 228 printk(KERN_DEBUG "%s: cnfgA contains 0x%02x\n", p->name, cnfga);
226 229
227 if (!(cnfga & (1<<2))) { 230 if (!(cnfga & (1<<2))) {
228 printk (KERN_DEBUG "%s: Accounting for extra byte\n", p->name); 231 printk(KERN_DEBUG "%s: Accounting for extra byte\n", p->name);
229 residue++; 232 residue++;
230 } 233 }
231 234
@@ -233,9 +236,11 @@ static int get_fifo_residue (struct parport *p)
233 * PWord != 1 byte. */ 236 * PWord != 1 byte. */
234 237
235 /* Back to PS2 mode. */ 238 /* Back to PS2 mode. */
236 frob_set_mode (p, ECR_PS2); 239 frob_set_mode(p, ECR_PS2);
237 240
238 DPRINTK (KERN_DEBUG "*** get_fifo_residue: done residue collecting (ecr = 0x%2.2x)\n", inb (ECONTROL (p))); 241 DPRINTK(KERN_DEBUG
242 "*** get_fifo_residue: done residue collecting (ecr = 0x%2.2x)\n",
243 inb(ECONTROL(p)));
239 return residue; 244 return residue;
240} 245}
241#endif /* 0 */ 246#endif /* 0 */
@@ -257,8 +262,8 @@ static int clear_epp_timeout(struct parport *pb)
257 /* To clear timeout some chips require double read */ 262 /* To clear timeout some chips require double read */
258 parport_pc_read_status(pb); 263 parport_pc_read_status(pb);
259 r = parport_pc_read_status(pb); 264 r = parport_pc_read_status(pb);
260 outb (r | 0x01, STATUS (pb)); /* Some reset by writing 1 */ 265 outb(r | 0x01, STATUS(pb)); /* Some reset by writing 1 */
261 outb (r & 0xfe, STATUS (pb)); /* Others by writing 0 */ 266 outb(r & 0xfe, STATUS(pb)); /* Others by writing 0 */
262 r = parport_pc_read_status(pb); 267 r = parport_pc_read_status(pb);
263 268
264 return !(r & 0x01); 269 return !(r & 0x01);
@@ -272,7 +277,8 @@ static int clear_epp_timeout(struct parport *pb)
272 * of these are in parport_pc.h. 277 * of these are in parport_pc.h.
273 */ 278 */
274 279
275static void parport_pc_init_state(struct pardevice *dev, struct parport_state *s) 280static void parport_pc_init_state(struct pardevice *dev,
281 struct parport_state *s)
276{ 282{
277 s->u.pc.ctr = 0xc; 283 s->u.pc.ctr = 0xc;
278 if (dev->irq_func && 284 if (dev->irq_func &&
@@ -289,22 +295,23 @@ static void parport_pc_save_state(struct parport *p, struct parport_state *s)
289 const struct parport_pc_private *priv = p->physport->private_data; 295 const struct parport_pc_private *priv = p->physport->private_data;
290 s->u.pc.ctr = priv->ctr; 296 s->u.pc.ctr = priv->ctr;
291 if (priv->ecr) 297 if (priv->ecr)
292 s->u.pc.ecr = inb (ECONTROL (p)); 298 s->u.pc.ecr = inb(ECONTROL(p));
293} 299}
294 300
295static void parport_pc_restore_state(struct parport *p, struct parport_state *s) 301static void parport_pc_restore_state(struct parport *p,
302 struct parport_state *s)
296{ 303{
297 struct parport_pc_private *priv = p->physport->private_data; 304 struct parport_pc_private *priv = p->physport->private_data;
298 register unsigned char c = s->u.pc.ctr & priv->ctr_writable; 305 register unsigned char c = s->u.pc.ctr & priv->ctr_writable;
299 outb (c, CONTROL (p)); 306 outb(c, CONTROL(p));
300 priv->ctr = c; 307 priv->ctr = c;
301 if (priv->ecr) 308 if (priv->ecr)
302 ECR_WRITE (p, s->u.pc.ecr); 309 ECR_WRITE(p, s->u.pc.ecr);
303} 310}
304 311
305#ifdef CONFIG_PARPORT_1284 312#ifdef CONFIG_PARPORT_1284
306static size_t parport_pc_epp_read_data (struct parport *port, void *buf, 313static size_t parport_pc_epp_read_data(struct parport *port, void *buf,
307 size_t length, int flags) 314 size_t length, int flags)
308{ 315{
309 size_t got = 0; 316 size_t got = 0;
310 317
@@ -316,54 +323,52 @@ static size_t parport_pc_epp_read_data (struct parport *port, void *buf,
316 * nFault is 0 if there is at least 1 byte in the Warp's FIFO 323 * nFault is 0 if there is at least 1 byte in the Warp's FIFO
317 * pError is 1 if there are 16 bytes in the Warp's FIFO 324 * pError is 1 if there are 16 bytes in the Warp's FIFO
318 */ 325 */
319 status = inb (STATUS (port)); 326 status = inb(STATUS(port));
320 327
321 while (!(status & 0x08) && (got < length)) { 328 while (!(status & 0x08) && got < length) {
322 if ((left >= 16) && (status & 0x20) && !(status & 0x08)) { 329 if (left >= 16 && (status & 0x20) && !(status & 0x08)) {
323 /* can grab 16 bytes from warp fifo */ 330 /* can grab 16 bytes from warp fifo */
324 if (!((long)buf & 0x03)) { 331 if (!((long)buf & 0x03))
325 insl (EPPDATA (port), buf, 4); 332 insl(EPPDATA(port), buf, 4);
326 } else { 333 else
327 insb (EPPDATA (port), buf, 16); 334 insb(EPPDATA(port), buf, 16);
328 }
329 buf += 16; 335 buf += 16;
330 got += 16; 336 got += 16;
331 left -= 16; 337 left -= 16;
332 } else { 338 } else {
333 /* grab single byte from the warp fifo */ 339 /* grab single byte from the warp fifo */
334 *((char *)buf) = inb (EPPDATA (port)); 340 *((char *)buf) = inb(EPPDATA(port));
335 buf++; 341 buf++;
336 got++; 342 got++;
337 left--; 343 left--;
338 } 344 }
339 status = inb (STATUS (port)); 345 status = inb(STATUS(port));
340 if (status & 0x01) { 346 if (status & 0x01) {
341 /* EPP timeout should never occur... */ 347 /* EPP timeout should never occur... */
342 printk (KERN_DEBUG "%s: EPP timeout occurred while talking to " 348 printk(KERN_DEBUG
343 "w91284pic (should not have done)\n", port->name); 349"%s: EPP timeout occurred while talking to w91284pic (should not have done)\n", port->name);
344 clear_epp_timeout (port); 350 clear_epp_timeout(port);
345 } 351 }
346 } 352 }
347 return got; 353 return got;
348 } 354 }
349 if ((flags & PARPORT_EPP_FAST) && (length > 1)) { 355 if ((flags & PARPORT_EPP_FAST) && (length > 1)) {
350 if (!(((long)buf | length) & 0x03)) { 356 if (!(((long)buf | length) & 0x03))
351 insl (EPPDATA (port), buf, (length >> 2)); 357 insl(EPPDATA(port), buf, (length >> 2));
352 } else { 358 else
353 insb (EPPDATA (port), buf, length); 359 insb(EPPDATA(port), buf, length);
354 } 360 if (inb(STATUS(port)) & 0x01) {
355 if (inb (STATUS (port)) & 0x01) { 361 clear_epp_timeout(port);
356 clear_epp_timeout (port);
357 return -EIO; 362 return -EIO;
358 } 363 }
359 return length; 364 return length;
360 } 365 }
361 for (; got < length; got++) { 366 for (; got < length; got++) {
362 *((char*)buf) = inb (EPPDATA(port)); 367 *((char *)buf) = inb(EPPDATA(port));
363 buf++; 368 buf++;
364 if (inb (STATUS (port)) & 0x01) { 369 if (inb(STATUS(port)) & 0x01) {
365 /* EPP timeout */ 370 /* EPP timeout */
366 clear_epp_timeout (port); 371 clear_epp_timeout(port);
367 break; 372 break;
368 } 373 }
369 } 374 }
@@ -371,28 +376,27 @@ static size_t parport_pc_epp_read_data (struct parport *port, void *buf,
371 return got; 376 return got;
372} 377}
373 378
374static size_t parport_pc_epp_write_data (struct parport *port, const void *buf, 379static size_t parport_pc_epp_write_data(struct parport *port, const void *buf,
375 size_t length, int flags) 380 size_t length, int flags)
376{ 381{
377 size_t written = 0; 382 size_t written = 0;
378 383
379 if ((flags & PARPORT_EPP_FAST) && (length > 1)) { 384 if ((flags & PARPORT_EPP_FAST) && (length > 1)) {
380 if (!(((long)buf | length) & 0x03)) { 385 if (!(((long)buf | length) & 0x03))
381 outsl (EPPDATA (port), buf, (length >> 2)); 386 outsl(EPPDATA(port), buf, (length >> 2));
382 } else { 387 else
383 outsb (EPPDATA (port), buf, length); 388 outsb(EPPDATA(port), buf, length);
384 } 389 if (inb(STATUS(port)) & 0x01) {
385 if (inb (STATUS (port)) & 0x01) { 390 clear_epp_timeout(port);
386 clear_epp_timeout (port);
387 return -EIO; 391 return -EIO;
388 } 392 }
389 return length; 393 return length;
390 } 394 }
391 for (; written < length; written++) { 395 for (; written < length; written++) {
392 outb (*((char*)buf), EPPDATA(port)); 396 outb(*((char *)buf), EPPDATA(port));
393 buf++; 397 buf++;
394 if (inb (STATUS(port)) & 0x01) { 398 if (inb(STATUS(port)) & 0x01) {
395 clear_epp_timeout (port); 399 clear_epp_timeout(port);
396 break; 400 break;
397 } 401 }
398 } 402 }
@@ -400,24 +404,24 @@ static size_t parport_pc_epp_write_data (struct parport *port, const void *buf,
400 return written; 404 return written;
401} 405}
402 406
403static size_t parport_pc_epp_read_addr (struct parport *port, void *buf, 407static size_t parport_pc_epp_read_addr(struct parport *port, void *buf,
404 size_t length, int flags) 408 size_t length, int flags)
405{ 409{
406 size_t got = 0; 410 size_t got = 0;
407 411
408 if ((flags & PARPORT_EPP_FAST) && (length > 1)) { 412 if ((flags & PARPORT_EPP_FAST) && (length > 1)) {
409 insb (EPPADDR (port), buf, length); 413 insb(EPPADDR(port), buf, length);
410 if (inb (STATUS (port)) & 0x01) { 414 if (inb(STATUS(port)) & 0x01) {
411 clear_epp_timeout (port); 415 clear_epp_timeout(port);
412 return -EIO; 416 return -EIO;
413 } 417 }
414 return length; 418 return length;
415 } 419 }
416 for (; got < length; got++) { 420 for (; got < length; got++) {
417 *((char*)buf) = inb (EPPADDR (port)); 421 *((char *)buf) = inb(EPPADDR(port));
418 buf++; 422 buf++;
419 if (inb (STATUS (port)) & 0x01) { 423 if (inb(STATUS(port)) & 0x01) {
420 clear_epp_timeout (port); 424 clear_epp_timeout(port);
421 break; 425 break;
422 } 426 }
423 } 427 }
@@ -425,25 +429,25 @@ static size_t parport_pc_epp_read_addr (struct parport *port, void *buf,
425 return got; 429 return got;
426} 430}
427 431
428static size_t parport_pc_epp_write_addr (struct parport *port, 432static size_t parport_pc_epp_write_addr(struct parport *port,
429 const void *buf, size_t length, 433 const void *buf, size_t length,
430 int flags) 434 int flags)
431{ 435{
432 size_t written = 0; 436 size_t written = 0;
433 437
434 if ((flags & PARPORT_EPP_FAST) && (length > 1)) { 438 if ((flags & PARPORT_EPP_FAST) && (length > 1)) {
435 outsb (EPPADDR (port), buf, length); 439 outsb(EPPADDR(port), buf, length);
436 if (inb (STATUS (port)) & 0x01) { 440 if (inb(STATUS(port)) & 0x01) {
437 clear_epp_timeout (port); 441 clear_epp_timeout(port);
438 return -EIO; 442 return -EIO;
439 } 443 }
440 return length; 444 return length;
441 } 445 }
442 for (; written < length; written++) { 446 for (; written < length; written++) {
443 outb (*((char*)buf), EPPADDR (port)); 447 outb(*((char *)buf), EPPADDR(port));
444 buf++; 448 buf++;
445 if (inb (STATUS (port)) & 0x01) { 449 if (inb(STATUS(port)) & 0x01) {
446 clear_epp_timeout (port); 450 clear_epp_timeout(port);
447 break; 451 break;
448 } 452 }
449 } 453 }
@@ -451,74 +455,74 @@ static size_t parport_pc_epp_write_addr (struct parport *port,
451 return written; 455 return written;
452} 456}
453 457
454static size_t parport_pc_ecpepp_read_data (struct parport *port, void *buf, 458static size_t parport_pc_ecpepp_read_data(struct parport *port, void *buf,
455 size_t length, int flags) 459 size_t length, int flags)
456{ 460{
457 size_t got; 461 size_t got;
458 462
459 frob_set_mode (port, ECR_EPP); 463 frob_set_mode(port, ECR_EPP);
460 parport_pc_data_reverse (port); 464 parport_pc_data_reverse(port);
461 parport_pc_write_control (port, 0x4); 465 parport_pc_write_control(port, 0x4);
462 got = parport_pc_epp_read_data (port, buf, length, flags); 466 got = parport_pc_epp_read_data(port, buf, length, flags);
463 frob_set_mode (port, ECR_PS2); 467 frob_set_mode(port, ECR_PS2);
464 468
465 return got; 469 return got;
466} 470}
467 471
468static size_t parport_pc_ecpepp_write_data (struct parport *port, 472static size_t parport_pc_ecpepp_write_data(struct parport *port,
469 const void *buf, size_t length, 473 const void *buf, size_t length,
470 int flags) 474 int flags)
471{ 475{
472 size_t written; 476 size_t written;
473 477
474 frob_set_mode (port, ECR_EPP); 478 frob_set_mode(port, ECR_EPP);
475 parport_pc_write_control (port, 0x4); 479 parport_pc_write_control(port, 0x4);
476 parport_pc_data_forward (port); 480 parport_pc_data_forward(port);
477 written = parport_pc_epp_write_data (port, buf, length, flags); 481 written = parport_pc_epp_write_data(port, buf, length, flags);
478 frob_set_mode (port, ECR_PS2); 482 frob_set_mode(port, ECR_PS2);
479 483
480 return written; 484 return written;
481} 485}
482 486
483static size_t parport_pc_ecpepp_read_addr (struct parport *port, void *buf, 487static size_t parport_pc_ecpepp_read_addr(struct parport *port, void *buf,
484 size_t length, int flags) 488 size_t length, int flags)
485{ 489{
486 size_t got; 490 size_t got;
487 491
488 frob_set_mode (port, ECR_EPP); 492 frob_set_mode(port, ECR_EPP);
489 parport_pc_data_reverse (port); 493 parport_pc_data_reverse(port);
490 parport_pc_write_control (port, 0x4); 494 parport_pc_write_control(port, 0x4);
491 got = parport_pc_epp_read_addr (port, buf, length, flags); 495 got = parport_pc_epp_read_addr(port, buf, length, flags);
492 frob_set_mode (port, ECR_PS2); 496 frob_set_mode(port, ECR_PS2);
493 497
494 return got; 498 return got;
495} 499}
496 500
497static size_t parport_pc_ecpepp_write_addr (struct parport *port, 501static size_t parport_pc_ecpepp_write_addr(struct parport *port,
498 const void *buf, size_t length, 502 const void *buf, size_t length,
499 int flags) 503 int flags)
500{ 504{
501 size_t written; 505 size_t written;
502 506
503 frob_set_mode (port, ECR_EPP); 507 frob_set_mode(port, ECR_EPP);
504 parport_pc_write_control (port, 0x4); 508 parport_pc_write_control(port, 0x4);
505 parport_pc_data_forward (port); 509 parport_pc_data_forward(port);
506 written = parport_pc_epp_write_addr (port, buf, length, flags); 510 written = parport_pc_epp_write_addr(port, buf, length, flags);
507 frob_set_mode (port, ECR_PS2); 511 frob_set_mode(port, ECR_PS2);
508 512
509 return written; 513 return written;
510} 514}
511#endif /* IEEE 1284 support */ 515#endif /* IEEE 1284 support */
512 516
513#ifdef CONFIG_PARPORT_PC_FIFO 517#ifdef CONFIG_PARPORT_PC_FIFO
514static size_t parport_pc_fifo_write_block_pio (struct parport *port, 518static size_t parport_pc_fifo_write_block_pio(struct parport *port,
515 const void *buf, size_t length) 519 const void *buf, size_t length)
516{ 520{
517 int ret = 0; 521 int ret = 0;
518 const unsigned char *bufp = buf; 522 const unsigned char *bufp = buf;
519 size_t left = length; 523 size_t left = length;
520 unsigned long expire = jiffies + port->physport->cad->timeout; 524 unsigned long expire = jiffies + port->physport->cad->timeout;
521 const int fifo = FIFO (port); 525 const int fifo = FIFO(port);
522 int poll_for = 8; /* 80 usecs */ 526 int poll_for = 8; /* 80 usecs */
523 const struct parport_pc_private *priv = port->physport->private_data; 527 const struct parport_pc_private *priv = port->physport->private_data;
524 const int fifo_depth = priv->fifo_depth; 528 const int fifo_depth = priv->fifo_depth;
@@ -526,25 +530,25 @@ static size_t parport_pc_fifo_write_block_pio (struct parport *port,
526 port = port->physport; 530 port = port->physport;
527 531
528 /* We don't want to be interrupted every character. */ 532 /* We don't want to be interrupted every character. */
529 parport_pc_disable_irq (port); 533 parport_pc_disable_irq(port);
530 /* set nErrIntrEn and serviceIntr */ 534 /* set nErrIntrEn and serviceIntr */
531 frob_econtrol (port, (1<<4) | (1<<2), (1<<4) | (1<<2)); 535 frob_econtrol(port, (1<<4) | (1<<2), (1<<4) | (1<<2));
532 536
533 /* Forward mode. */ 537 /* Forward mode. */
534 parport_pc_data_forward (port); /* Must be in PS2 mode */ 538 parport_pc_data_forward(port); /* Must be in PS2 mode */
535 539
536 while (left) { 540 while (left) {
537 unsigned char byte; 541 unsigned char byte;
538 unsigned char ecrval = inb (ECONTROL (port)); 542 unsigned char ecrval = inb(ECONTROL(port));
539 int i = 0; 543 int i = 0;
540 544
541 if (need_resched() && time_before (jiffies, expire)) 545 if (need_resched() && time_before(jiffies, expire))
542 /* Can't yield the port. */ 546 /* Can't yield the port. */
543 schedule (); 547 schedule();
544 548
545 /* Anyone else waiting for the port? */ 549 /* Anyone else waiting for the port? */
546 if (port->waithead) { 550 if (port->waithead) {
547 printk (KERN_DEBUG "Somebody wants the port\n"); 551 printk(KERN_DEBUG "Somebody wants the port\n");
548 break; 552 break;
549 } 553 }
550 554
@@ -552,21 +556,22 @@ static size_t parport_pc_fifo_write_block_pio (struct parport *port,
552 /* FIFO is full. Wait for interrupt. */ 556 /* FIFO is full. Wait for interrupt. */
553 557
554 /* Clear serviceIntr */ 558 /* Clear serviceIntr */
555 ECR_WRITE (port, ecrval & ~(1<<2)); 559 ECR_WRITE(port, ecrval & ~(1<<2));
556 false_alarm: 560false_alarm:
557 ret = parport_wait_event (port, HZ); 561 ret = parport_wait_event(port, HZ);
558 if (ret < 0) break; 562 if (ret < 0)
563 break;
559 ret = 0; 564 ret = 0;
560 if (!time_before (jiffies, expire)) { 565 if (!time_before(jiffies, expire)) {
561 /* Timed out. */ 566 /* Timed out. */
562 printk (KERN_DEBUG "FIFO write timed out\n"); 567 printk(KERN_DEBUG "FIFO write timed out\n");
563 break; 568 break;
564 } 569 }
565 ecrval = inb (ECONTROL (port)); 570 ecrval = inb(ECONTROL(port));
566 if (!(ecrval & (1<<2))) { 571 if (!(ecrval & (1<<2))) {
567 if (need_resched() && 572 if (need_resched() &&
568 time_before (jiffies, expire)) 573 time_before(jiffies, expire))
569 schedule (); 574 schedule();
570 575
571 goto false_alarm; 576 goto false_alarm;
572 } 577 }
@@ -577,38 +582,38 @@ static size_t parport_pc_fifo_write_block_pio (struct parport *port,
577 /* Can't fail now. */ 582 /* Can't fail now. */
578 expire = jiffies + port->cad->timeout; 583 expire = jiffies + port->cad->timeout;
579 584
580 poll: 585poll:
581 if (signal_pending (current)) 586 if (signal_pending(current))
582 break; 587 break;
583 588
584 if (ecrval & 0x01) { 589 if (ecrval & 0x01) {
585 /* FIFO is empty. Blast it full. */ 590 /* FIFO is empty. Blast it full. */
586 const int n = left < fifo_depth ? left : fifo_depth; 591 const int n = left < fifo_depth ? left : fifo_depth;
587 outsb (fifo, bufp, n); 592 outsb(fifo, bufp, n);
588 bufp += n; 593 bufp += n;
589 left -= n; 594 left -= n;
590 595
591 /* Adjust the poll time. */ 596 /* Adjust the poll time. */
592 if (i < (poll_for - 2)) poll_for--; 597 if (i < (poll_for - 2))
598 poll_for--;
593 continue; 599 continue;
594 } else if (i++ < poll_for) { 600 } else if (i++ < poll_for) {
595 udelay (10); 601 udelay(10);
596 ecrval = inb (ECONTROL (port)); 602 ecrval = inb(ECONTROL(port));
597 goto poll; 603 goto poll;
598 } 604 }
599 605
600 /* Half-full (call me an optimist) */ 606 /* Half-full(call me an optimist) */
601 byte = *bufp++; 607 byte = *bufp++;
602 outb (byte, fifo); 608 outb(byte, fifo);
603 left--; 609 left--;
604 } 610 }
605 611 dump_parport_state("leave fifo_write_block_pio", port);
606dump_parport_state ("leave fifo_write_block_pio", port);
607 return length - left; 612 return length - left;
608} 613}
609 614
610#ifdef HAS_DMA 615#ifdef HAS_DMA
611static size_t parport_pc_fifo_write_block_dma (struct parport *port, 616static size_t parport_pc_fifo_write_block_dma(struct parport *port,
612 const void *buf, size_t length) 617 const void *buf, size_t length)
613{ 618{
614 int ret = 0; 619 int ret = 0;
@@ -621,7 +626,7 @@ static size_t parport_pc_fifo_write_block_dma (struct parport *port,
621 unsigned long start = (unsigned long) buf; 626 unsigned long start = (unsigned long) buf;
622 unsigned long end = (unsigned long) buf + length - 1; 627 unsigned long end = (unsigned long) buf + length - 1;
623 628
624dump_parport_state ("enter fifo_write_block_dma", port); 629 dump_parport_state("enter fifo_write_block_dma", port);
625 if (end < MAX_DMA_ADDRESS) { 630 if (end < MAX_DMA_ADDRESS) {
626 /* If it would cross a 64k boundary, cap it at the end. */ 631 /* If it would cross a 64k boundary, cap it at the end. */
627 if ((start ^ end) & ~0xffffUL) 632 if ((start ^ end) & ~0xffffUL)
@@ -629,8 +634,9 @@ dump_parport_state ("enter fifo_write_block_dma", port);
629 634
630 dma_addr = dma_handle = dma_map_single(dev, (void *)buf, length, 635 dma_addr = dma_handle = dma_map_single(dev, (void *)buf, length,
631 DMA_TO_DEVICE); 636 DMA_TO_DEVICE);
632 } else { 637 } else {
633 /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */ 638 /* above 16 MB we use a bounce buffer as ISA-DMA
639 is not possible */
634 maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */ 640 maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */
635 dma_addr = priv->dma_handle; 641 dma_addr = priv->dma_handle;
636 dma_handle = 0; 642 dma_handle = 0;
@@ -639,12 +645,12 @@ dump_parport_state ("enter fifo_write_block_dma", port);
639 port = port->physport; 645 port = port->physport;
640 646
641 /* We don't want to be interrupted every character. */ 647 /* We don't want to be interrupted every character. */
642 parport_pc_disable_irq (port); 648 parport_pc_disable_irq(port);
643 /* set nErrIntrEn and serviceIntr */ 649 /* set nErrIntrEn and serviceIntr */
644 frob_econtrol (port, (1<<4) | (1<<2), (1<<4) | (1<<2)); 650 frob_econtrol(port, (1<<4) | (1<<2), (1<<4) | (1<<2));
645 651
646 /* Forward mode. */ 652 /* Forward mode. */
647 parport_pc_data_forward (port); /* Must be in PS2 mode */ 653 parport_pc_data_forward(port); /* Must be in PS2 mode */
648 654
649 while (left) { 655 while (left) {
650 unsigned long expire = jiffies + port->physport->cad->timeout; 656 unsigned long expire = jiffies + port->physport->cad->timeout;
@@ -665,10 +671,10 @@ dump_parport_state ("enter fifo_write_block_dma", port);
665 set_dma_count(port->dma, count); 671 set_dma_count(port->dma, count);
666 672
667 /* Set DMA mode */ 673 /* Set DMA mode */
668 frob_econtrol (port, 1<<3, 1<<3); 674 frob_econtrol(port, 1<<3, 1<<3);
669 675
670 /* Clear serviceIntr */ 676 /* Clear serviceIntr */
671 frob_econtrol (port, 1<<2, 0); 677 frob_econtrol(port, 1<<2, 0);
672 678
673 enable_dma(port->dma); 679 enable_dma(port->dma);
674 release_dma_lock(dmaflag); 680 release_dma_lock(dmaflag);
@@ -676,20 +682,22 @@ dump_parport_state ("enter fifo_write_block_dma", port);
676 /* assume DMA will be successful */ 682 /* assume DMA will be successful */
677 left -= count; 683 left -= count;
678 buf += count; 684 buf += count;
679 if (dma_handle) dma_addr += count; 685 if (dma_handle)
686 dma_addr += count;
680 687
681 /* Wait for interrupt. */ 688 /* Wait for interrupt. */
682 false_alarm: 689false_alarm:
683 ret = parport_wait_event (port, HZ); 690 ret = parport_wait_event(port, HZ);
684 if (ret < 0) break; 691 if (ret < 0)
692 break;
685 ret = 0; 693 ret = 0;
686 if (!time_before (jiffies, expire)) { 694 if (!time_before(jiffies, expire)) {
687 /* Timed out. */ 695 /* Timed out. */
688 printk (KERN_DEBUG "DMA write timed out\n"); 696 printk(KERN_DEBUG "DMA write timed out\n");
689 break; 697 break;
690 } 698 }
691 /* Is serviceIntr set? */ 699 /* Is serviceIntr set? */
692 if (!(inb (ECONTROL (port)) & (1<<2))) { 700 if (!(inb(ECONTROL(port)) & (1<<2))) {
693 cond_resched(); 701 cond_resched();
694 702
695 goto false_alarm; 703 goto false_alarm;
@@ -705,14 +713,15 @@ dump_parport_state ("enter fifo_write_block_dma", port);
705 713
706 /* Anyone else waiting for the port? */ 714 /* Anyone else waiting for the port? */
707 if (port->waithead) { 715 if (port->waithead) {
708 printk (KERN_DEBUG "Somebody wants the port\n"); 716 printk(KERN_DEBUG "Somebody wants the port\n");
709 break; 717 break;
710 } 718 }
711 719
712 /* update for possible DMA residue ! */ 720 /* update for possible DMA residue ! */
713 buf -= count; 721 buf -= count;
714 left += count; 722 left += count;
715 if (dma_handle) dma_addr -= count; 723 if (dma_handle)
724 dma_addr -= count;
716 } 725 }
717 726
718 /* Maybe got here through break, so adjust for DMA residue! */ 727 /* Maybe got here through break, so adjust for DMA residue! */
@@ -723,12 +732,12 @@ dump_parport_state ("enter fifo_write_block_dma", port);
723 release_dma_lock(dmaflag); 732 release_dma_lock(dmaflag);
724 733
725 /* Turn off DMA mode */ 734 /* Turn off DMA mode */
726 frob_econtrol (port, 1<<3, 0); 735 frob_econtrol(port, 1<<3, 0);
727 736
728 if (dma_handle) 737 if (dma_handle)
729 dma_unmap_single(dev, dma_handle, length, DMA_TO_DEVICE); 738 dma_unmap_single(dev, dma_handle, length, DMA_TO_DEVICE);
730 739
731dump_parport_state ("leave fifo_write_block_dma", port); 740 dump_parport_state("leave fifo_write_block_dma", port);
732 return length - left; 741 return length - left;
733} 742}
734#endif 743#endif
@@ -738,13 +747,13 @@ static inline size_t parport_pc_fifo_write_block(struct parport *port,
738{ 747{
739#ifdef HAS_DMA 748#ifdef HAS_DMA
740 if (port->dma != PARPORT_DMA_NONE) 749 if (port->dma != PARPORT_DMA_NONE)
741 return parport_pc_fifo_write_block_dma (port, buf, length); 750 return parport_pc_fifo_write_block_dma(port, buf, length);
742#endif 751#endif
743 return parport_pc_fifo_write_block_pio (port, buf, length); 752 return parport_pc_fifo_write_block_pio(port, buf, length);
744} 753}
745 754
746/* Parallel Port FIFO mode (ECP chipsets) */ 755/* Parallel Port FIFO mode (ECP chipsets) */
747static size_t parport_pc_compat_write_block_pio (struct parport *port, 756static size_t parport_pc_compat_write_block_pio(struct parport *port,
748 const void *buf, size_t length, 757 const void *buf, size_t length,
749 int flags) 758 int flags)
750{ 759{
@@ -756,14 +765,16 @@ static size_t parport_pc_compat_write_block_pio (struct parport *port,
756 /* Special case: a timeout of zero means we cannot call schedule(). 765 /* Special case: a timeout of zero means we cannot call schedule().
757 * Also if O_NONBLOCK is set then use the default implementation. */ 766 * Also if O_NONBLOCK is set then use the default implementation. */
758 if (port->physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK) 767 if (port->physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK)
759 return parport_ieee1284_write_compat (port, buf, 768 return parport_ieee1284_write_compat(port, buf,
760 length, flags); 769 length, flags);
761 770
762 /* Set up parallel port FIFO mode.*/ 771 /* Set up parallel port FIFO mode.*/
763 parport_pc_data_forward (port); /* Must be in PS2 mode */ 772 parport_pc_data_forward(port); /* Must be in PS2 mode */
764 parport_pc_frob_control (port, PARPORT_CONTROL_STROBE, 0); 773 parport_pc_frob_control(port, PARPORT_CONTROL_STROBE, 0);
765 r = change_mode (port, ECR_PPF); /* Parallel port FIFO */ 774 r = change_mode(port, ECR_PPF); /* Parallel port FIFO */
766 if (r) printk (KERN_DEBUG "%s: Warning change_mode ECR_PPF failed\n", port->name); 775 if (r)
776 printk(KERN_DEBUG "%s: Warning change_mode ECR_PPF failed\n",
777 port->name);
767 778
768 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 779 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
769 780
@@ -775,40 +786,39 @@ static size_t parport_pc_compat_write_block_pio (struct parport *port,
775 * the FIFO is empty, so allow 4 seconds for each position 786 * the FIFO is empty, so allow 4 seconds for each position
776 * in the fifo. 787 * in the fifo.
777 */ 788 */
778 expire = jiffies + (priv->fifo_depth * HZ * 4); 789 expire = jiffies + (priv->fifo_depth * HZ * 4);
779 do { 790 do {
780 /* Wait for the FIFO to empty */ 791 /* Wait for the FIFO to empty */
781 r = change_mode (port, ECR_PS2); 792 r = change_mode(port, ECR_PS2);
782 if (r != -EBUSY) { 793 if (r != -EBUSY)
783 break; 794 break;
784 } 795 } while (time_before(jiffies, expire));
785 } while (time_before (jiffies, expire));
786 if (r == -EBUSY) { 796 if (r == -EBUSY) {
787 797
788 printk (KERN_DEBUG "%s: FIFO is stuck\n", port->name); 798 printk(KERN_DEBUG "%s: FIFO is stuck\n", port->name);
789 799
790 /* Prevent further data transfer. */ 800 /* Prevent further data transfer. */
791 frob_set_mode (port, ECR_TST); 801 frob_set_mode(port, ECR_TST);
792 802
793 /* Adjust for the contents of the FIFO. */ 803 /* Adjust for the contents of the FIFO. */
794 for (written -= priv->fifo_depth; ; written++) { 804 for (written -= priv->fifo_depth; ; written++) {
795 if (inb (ECONTROL (port)) & 0x2) { 805 if (inb(ECONTROL(port)) & 0x2) {
796 /* Full up. */ 806 /* Full up. */
797 break; 807 break;
798 } 808 }
799 outb (0, FIFO (port)); 809 outb(0, FIFO(port));
800 } 810 }
801 811
802 /* Reset the FIFO and return to PS2 mode. */ 812 /* Reset the FIFO and return to PS2 mode. */
803 frob_set_mode (port, ECR_PS2); 813 frob_set_mode(port, ECR_PS2);
804 } 814 }
805 815
806 r = parport_wait_peripheral (port, 816 r = parport_wait_peripheral(port,
807 PARPORT_STATUS_BUSY, 817 PARPORT_STATUS_BUSY,
808 PARPORT_STATUS_BUSY); 818 PARPORT_STATUS_BUSY);
809 if (r) 819 if (r)
810 printk (KERN_DEBUG 820 printk(KERN_DEBUG
811 "%s: BUSY timeout (%d) in compat_write_block_pio\n", 821 "%s: BUSY timeout (%d) in compat_write_block_pio\n",
812 port->name, r); 822 port->name, r);
813 823
814 port->physport->ieee1284.phase = IEEE1284_PH_FWD_IDLE; 824 port->physport->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
@@ -818,7 +828,7 @@ static size_t parport_pc_compat_write_block_pio (struct parport *port,
818 828
819/* ECP */ 829/* ECP */
820#ifdef CONFIG_PARPORT_1284 830#ifdef CONFIG_PARPORT_1284
821static size_t parport_pc_ecp_write_block_pio (struct parport *port, 831static size_t parport_pc_ecp_write_block_pio(struct parport *port,
822 const void *buf, size_t length, 832 const void *buf, size_t length,
823 int flags) 833 int flags)
824{ 834{
@@ -830,36 +840,38 @@ static size_t parport_pc_ecp_write_block_pio (struct parport *port,
830 /* Special case: a timeout of zero means we cannot call schedule(). 840 /* Special case: a timeout of zero means we cannot call schedule().
831 * Also if O_NONBLOCK is set then use the default implementation. */ 841 * Also if O_NONBLOCK is set then use the default implementation. */
832 if (port->physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK) 842 if (port->physport->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK)
833 return parport_ieee1284_ecp_write_data (port, buf, 843 return parport_ieee1284_ecp_write_data(port, buf,
834 length, flags); 844 length, flags);
835 845
836 /* Switch to forward mode if necessary. */ 846 /* Switch to forward mode if necessary. */
837 if (port->physport->ieee1284.phase != IEEE1284_PH_FWD_IDLE) { 847 if (port->physport->ieee1284.phase != IEEE1284_PH_FWD_IDLE) {
838 /* Event 47: Set nInit high. */ 848 /* Event 47: Set nInit high. */
839 parport_frob_control (port, 849 parport_frob_control(port,
840 PARPORT_CONTROL_INIT 850 PARPORT_CONTROL_INIT
841 | PARPORT_CONTROL_AUTOFD, 851 | PARPORT_CONTROL_AUTOFD,
842 PARPORT_CONTROL_INIT 852 PARPORT_CONTROL_INIT
843 | PARPORT_CONTROL_AUTOFD); 853 | PARPORT_CONTROL_AUTOFD);
844 854
845 /* Event 49: PError goes high. */ 855 /* Event 49: PError goes high. */
846 r = parport_wait_peripheral (port, 856 r = parport_wait_peripheral(port,
847 PARPORT_STATUS_PAPEROUT, 857 PARPORT_STATUS_PAPEROUT,
848 PARPORT_STATUS_PAPEROUT); 858 PARPORT_STATUS_PAPEROUT);
849 if (r) { 859 if (r) {
850 printk (KERN_DEBUG "%s: PError timeout (%d) " 860 printk(KERN_DEBUG "%s: PError timeout (%d) "
851 "in ecp_write_block_pio\n", port->name, r); 861 "in ecp_write_block_pio\n", port->name, r);
852 } 862 }
853 } 863 }
854 864
855 /* Set up ECP parallel port mode.*/ 865 /* Set up ECP parallel port mode.*/
856 parport_pc_data_forward (port); /* Must be in PS2 mode */ 866 parport_pc_data_forward(port); /* Must be in PS2 mode */
857 parport_pc_frob_control (port, 867 parport_pc_frob_control(port,
858 PARPORT_CONTROL_STROBE | 868 PARPORT_CONTROL_STROBE |
859 PARPORT_CONTROL_AUTOFD, 869 PARPORT_CONTROL_AUTOFD,
860 0); 870 0);
861 r = change_mode (port, ECR_ECP); /* ECP FIFO */ 871 r = change_mode(port, ECR_ECP); /* ECP FIFO */
862 if (r) printk (KERN_DEBUG "%s: Warning change_mode ECR_ECP failed\n", port->name); 872 if (r)
873 printk(KERN_DEBUG "%s: Warning change_mode ECR_ECP failed\n",
874 port->name);
863 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA; 875 port->physport->ieee1284.phase = IEEE1284_PH_FWD_DATA;
864 876
865 /* Write the data to the FIFO. */ 877 /* Write the data to the FIFO. */
@@ -873,55 +885,54 @@ static size_t parport_pc_ecp_write_block_pio (struct parport *port,
873 expire = jiffies + (priv->fifo_depth * (HZ * 4)); 885 expire = jiffies + (priv->fifo_depth * (HZ * 4));
874 do { 886 do {
875 /* Wait for the FIFO to empty */ 887 /* Wait for the FIFO to empty */
876 r = change_mode (port, ECR_PS2); 888 r = change_mode(port, ECR_PS2);
877 if (r != -EBUSY) { 889 if (r != -EBUSY)
878 break; 890 break;
879 } 891 } while (time_before(jiffies, expire));
880 } while (time_before (jiffies, expire));
881 if (r == -EBUSY) { 892 if (r == -EBUSY) {
882 893
883 printk (KERN_DEBUG "%s: FIFO is stuck\n", port->name); 894 printk(KERN_DEBUG "%s: FIFO is stuck\n", port->name);
884 895
885 /* Prevent further data transfer. */ 896 /* Prevent further data transfer. */
886 frob_set_mode (port, ECR_TST); 897 frob_set_mode(port, ECR_TST);
887 898
888 /* Adjust for the contents of the FIFO. */ 899 /* Adjust for the contents of the FIFO. */
889 for (written -= priv->fifo_depth; ; written++) { 900 for (written -= priv->fifo_depth; ; written++) {
890 if (inb (ECONTROL (port)) & 0x2) { 901 if (inb(ECONTROL(port)) & 0x2) {
891 /* Full up. */ 902 /* Full up. */
892 break; 903 break;
893 } 904 }
894 outb (0, FIFO (port)); 905 outb(0, FIFO(port));
895 } 906 }
896 907
897 /* Reset the FIFO and return to PS2 mode. */ 908 /* Reset the FIFO and return to PS2 mode. */
898 frob_set_mode (port, ECR_PS2); 909 frob_set_mode(port, ECR_PS2);
899 910
900 /* Host transfer recovery. */ 911 /* Host transfer recovery. */
901 parport_pc_data_reverse (port); /* Must be in PS2 mode */ 912 parport_pc_data_reverse(port); /* Must be in PS2 mode */
902 udelay (5); 913 udelay(5);
903 parport_frob_control (port, PARPORT_CONTROL_INIT, 0); 914 parport_frob_control(port, PARPORT_CONTROL_INIT, 0);
904 r = parport_wait_peripheral (port, PARPORT_STATUS_PAPEROUT, 0); 915 r = parport_wait_peripheral(port, PARPORT_STATUS_PAPEROUT, 0);
905 if (r) 916 if (r)
906 printk (KERN_DEBUG "%s: PE,1 timeout (%d) " 917 printk(KERN_DEBUG "%s: PE,1 timeout (%d) "
907 "in ecp_write_block_pio\n", port->name, r); 918 "in ecp_write_block_pio\n", port->name, r);
908 919
909 parport_frob_control (port, 920 parport_frob_control(port,
910 PARPORT_CONTROL_INIT, 921 PARPORT_CONTROL_INIT,
911 PARPORT_CONTROL_INIT); 922 PARPORT_CONTROL_INIT);
912 r = parport_wait_peripheral (port, 923 r = parport_wait_peripheral(port,
913 PARPORT_STATUS_PAPEROUT, 924 PARPORT_STATUS_PAPEROUT,
914 PARPORT_STATUS_PAPEROUT); 925 PARPORT_STATUS_PAPEROUT);
915 if (r) 926 if (r)
916 printk (KERN_DEBUG "%s: PE,2 timeout (%d) " 927 printk(KERN_DEBUG "%s: PE,2 timeout (%d) "
917 "in ecp_write_block_pio\n", port->name, r); 928 "in ecp_write_block_pio\n", port->name, r);
918 } 929 }
919 930
920 r = parport_wait_peripheral (port, 931 r = parport_wait_peripheral(port,
921 PARPORT_STATUS_BUSY, 932 PARPORT_STATUS_BUSY,
922 PARPORT_STATUS_BUSY); 933 PARPORT_STATUS_BUSY);
923 if(r) 934 if (r)
924 printk (KERN_DEBUG 935 printk(KERN_DEBUG
925 "%s: BUSY timeout (%d) in ecp_write_block_pio\n", 936 "%s: BUSY timeout (%d) in ecp_write_block_pio\n",
926 port->name, r); 937 port->name, r);
927 938
@@ -931,7 +942,7 @@ static size_t parport_pc_ecp_write_block_pio (struct parport *port,
931} 942}
932 943
933#if 0 944#if 0
934static size_t parport_pc_ecp_read_block_pio (struct parport *port, 945static size_t parport_pc_ecp_read_block_pio(struct parport *port,
935 void *buf, size_t length, 946 void *buf, size_t length,
936 int flags) 947 int flags)
937{ 948{
@@ -944,13 +955,13 @@ static size_t parport_pc_ecp_read_block_pio (struct parport *port,
944 char *bufp = buf; 955 char *bufp = buf;
945 956
946 port = port->physport; 957 port = port->physport;
947DPRINTK (KERN_DEBUG "parport_pc: parport_pc_ecp_read_block_pio\n"); 958 DPRINTK(KERN_DEBUG "parport_pc: parport_pc_ecp_read_block_pio\n");
948dump_parport_state ("enter fcn", port); 959 dump_parport_state("enter fcn", port);
949 960
950 /* Special case: a timeout of zero means we cannot call schedule(). 961 /* Special case: a timeout of zero means we cannot call schedule().
951 * Also if O_NONBLOCK is set then use the default implementation. */ 962 * Also if O_NONBLOCK is set then use the default implementation. */
952 if (port->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK) 963 if (port->cad->timeout <= PARPORT_INACTIVITY_O_NONBLOCK)
953 return parport_ieee1284_ecp_read_data (port, buf, 964 return parport_ieee1284_ecp_read_data(port, buf,
954 length, flags); 965 length, flags);
955 966
956 if (port->ieee1284.mode == IEEE1284_MODE_ECPRLE) { 967 if (port->ieee1284.mode == IEEE1284_MODE_ECPRLE) {
@@ -966,173 +977,178 @@ dump_parport_state ("enter fcn", port);
966 * go through software emulation. Otherwise we may have to throw 977 * go through software emulation. Otherwise we may have to throw
967 * away data. */ 978 * away data. */
968 if (length < fifofull) 979 if (length < fifofull)
969 return parport_ieee1284_ecp_read_data (port, buf, 980 return parport_ieee1284_ecp_read_data(port, buf,
970 length, flags); 981 length, flags);
971 982
972 if (port->ieee1284.phase != IEEE1284_PH_REV_IDLE) { 983 if (port->ieee1284.phase != IEEE1284_PH_REV_IDLE) {
973 /* change to reverse-idle phase (must be in forward-idle) */ 984 /* change to reverse-idle phase (must be in forward-idle) */
974 985
975 /* Event 38: Set nAutoFd low (also make sure nStrobe is high) */ 986 /* Event 38: Set nAutoFd low (also make sure nStrobe is high) */
976 parport_frob_control (port, 987 parport_frob_control(port,
977 PARPORT_CONTROL_AUTOFD 988 PARPORT_CONTROL_AUTOFD
978 | PARPORT_CONTROL_STROBE, 989 | PARPORT_CONTROL_STROBE,
979 PARPORT_CONTROL_AUTOFD); 990 PARPORT_CONTROL_AUTOFD);
980 parport_pc_data_reverse (port); /* Must be in PS2 mode */ 991 parport_pc_data_reverse(port); /* Must be in PS2 mode */
981 udelay (5); 992 udelay(5);
982 /* Event 39: Set nInit low to initiate bus reversal */ 993 /* Event 39: Set nInit low to initiate bus reversal */
983 parport_frob_control (port, 994 parport_frob_control(port,
984 PARPORT_CONTROL_INIT, 995 PARPORT_CONTROL_INIT,
985 0); 996 0);
986 /* Event 40: Wait for nAckReverse (PError) to go low */ 997 /* Event 40: Wait for nAckReverse (PError) to go low */
987 r = parport_wait_peripheral (port, PARPORT_STATUS_PAPEROUT, 0); 998 r = parport_wait_peripheral(port, PARPORT_STATUS_PAPEROUT, 0);
988 if (r) { 999 if (r) {
989 printk (KERN_DEBUG "%s: PE timeout Event 40 (%d) " 1000 printk(KERN_DEBUG "%s: PE timeout Event 40 (%d) "
990 "in ecp_read_block_pio\n", port->name, r); 1001 "in ecp_read_block_pio\n", port->name, r);
991 return 0; 1002 return 0;
992 } 1003 }
993 } 1004 }
994 1005
995 /* Set up ECP FIFO mode.*/ 1006 /* Set up ECP FIFO mode.*/
996/* parport_pc_frob_control (port, 1007/* parport_pc_frob_control(port,
997 PARPORT_CONTROL_STROBE | 1008 PARPORT_CONTROL_STROBE |
998 PARPORT_CONTROL_AUTOFD, 1009 PARPORT_CONTROL_AUTOFD,
999 PARPORT_CONTROL_AUTOFD); */ 1010 PARPORT_CONTROL_AUTOFD); */
1000 r = change_mode (port, ECR_ECP); /* ECP FIFO */ 1011 r = change_mode(port, ECR_ECP); /* ECP FIFO */
1001 if (r) printk (KERN_DEBUG "%s: Warning change_mode ECR_ECP failed\n", port->name); 1012 if (r)
1013 printk(KERN_DEBUG "%s: Warning change_mode ECR_ECP failed\n",
1014 port->name);
1002 1015
1003 port->ieee1284.phase = IEEE1284_PH_REV_DATA; 1016 port->ieee1284.phase = IEEE1284_PH_REV_DATA;
1004 1017
1005 /* the first byte must be collected manually */ 1018 /* the first byte must be collected manually */
1006dump_parport_state ("pre 43", port); 1019 dump_parport_state("pre 43", port);
1007 /* Event 43: Wait for nAck to go low */ 1020 /* Event 43: Wait for nAck to go low */
1008 r = parport_wait_peripheral (port, PARPORT_STATUS_ACK, 0); 1021 r = parport_wait_peripheral(port, PARPORT_STATUS_ACK, 0);
1009 if (r) { 1022 if (r) {
1010 /* timed out while reading -- no data */ 1023 /* timed out while reading -- no data */
1011 printk (KERN_DEBUG "PIO read timed out (initial byte)\n"); 1024 printk(KERN_DEBUG "PIO read timed out (initial byte)\n");
1012 goto out_no_data; 1025 goto out_no_data;
1013 } 1026 }
1014 /* read byte */ 1027 /* read byte */
1015 *bufp++ = inb (DATA (port)); 1028 *bufp++ = inb(DATA(port));
1016 left--; 1029 left--;
1017dump_parport_state ("43-44", port); 1030 dump_parport_state("43-44", port);
1018 /* Event 44: nAutoFd (HostAck) goes high to acknowledge */ 1031 /* Event 44: nAutoFd (HostAck) goes high to acknowledge */
1019 parport_pc_frob_control (port, 1032 parport_pc_frob_control(port,
1020 PARPORT_CONTROL_AUTOFD, 1033 PARPORT_CONTROL_AUTOFD,
1021 0); 1034 0);
1022dump_parport_state ("pre 45", port); 1035 dump_parport_state("pre 45", port);
1023 /* Event 45: Wait for nAck to go high */ 1036 /* Event 45: Wait for nAck to go high */
1024/* r = parport_wait_peripheral (port, PARPORT_STATUS_ACK, PARPORT_STATUS_ACK); */ 1037 /* r = parport_wait_peripheral(port, PARPORT_STATUS_ACK,
1025dump_parport_state ("post 45", port); 1038 PARPORT_STATUS_ACK); */
1026r = 0; 1039 dump_parport_state("post 45", port);
1040 r = 0;
1027 if (r) { 1041 if (r) {
1028 /* timed out while waiting for peripheral to respond to ack */ 1042 /* timed out while waiting for peripheral to respond to ack */
1029 printk (KERN_DEBUG "ECP PIO read timed out (waiting for nAck)\n"); 1043 printk(KERN_DEBUG "ECP PIO read timed out (waiting for nAck)\n");
1030 1044
1031 /* keep hold of the byte we've got already */ 1045 /* keep hold of the byte we've got already */
1032 goto out_no_data; 1046 goto out_no_data;
1033 } 1047 }
1034 /* Event 46: nAutoFd (HostAck) goes low to accept more data */ 1048 /* Event 46: nAutoFd (HostAck) goes low to accept more data */
1035 parport_pc_frob_control (port, 1049 parport_pc_frob_control(port,
1036 PARPORT_CONTROL_AUTOFD, 1050 PARPORT_CONTROL_AUTOFD,
1037 PARPORT_CONTROL_AUTOFD); 1051 PARPORT_CONTROL_AUTOFD);
1038 1052
1039 1053
1040dump_parport_state ("rev idle", port); 1054 dump_parport_state("rev idle", port);
1041 /* Do the transfer. */ 1055 /* Do the transfer. */
1042 while (left > fifofull) { 1056 while (left > fifofull) {
1043 int ret; 1057 int ret;
1044 unsigned long expire = jiffies + port->cad->timeout; 1058 unsigned long expire = jiffies + port->cad->timeout;
1045 unsigned char ecrval = inb (ECONTROL (port)); 1059 unsigned char ecrval = inb(ECONTROL(port));
1046 1060
1047 if (need_resched() && time_before (jiffies, expire)) 1061 if (need_resched() && time_before(jiffies, expire))
1048 /* Can't yield the port. */ 1062 /* Can't yield the port. */
1049 schedule (); 1063 schedule();
1050 1064
1051 /* At this point, the FIFO may already be full. In 1065 /* At this point, the FIFO may already be full. In
1052 * that case ECP is already holding back the 1066 * that case ECP is already holding back the
1053 * peripheral (assuming proper design) with a delayed 1067 * peripheral (assuming proper design) with a delayed
1054 * handshake. Work fast to avoid a peripheral 1068 * handshake. Work fast to avoid a peripheral
1055 * timeout. */ 1069 * timeout. */
1056 1070
1057 if (ecrval & 0x01) { 1071 if (ecrval & 0x01) {
1058 /* FIFO is empty. Wait for interrupt. */ 1072 /* FIFO is empty. Wait for interrupt. */
1059dump_parport_state ("FIFO empty", port); 1073 dump_parport_state("FIFO empty", port);
1060 1074
1061 /* Anyone else waiting for the port? */ 1075 /* Anyone else waiting for the port? */
1062 if (port->waithead) { 1076 if (port->waithead) {
1063 printk (KERN_DEBUG "Somebody wants the port\n"); 1077 printk(KERN_DEBUG "Somebody wants the port\n");
1064 break; 1078 break;
1065 } 1079 }
1066 1080
1067 /* Clear serviceIntr */ 1081 /* Clear serviceIntr */
1068 ECR_WRITE (port, ecrval & ~(1<<2)); 1082 ECR_WRITE(port, ecrval & ~(1<<2));
1069 false_alarm: 1083false_alarm:
1070dump_parport_state ("waiting", port); 1084 dump_parport_state("waiting", port);
1071 ret = parport_wait_event (port, HZ); 1085 ret = parport_wait_event(port, HZ);
1072DPRINTK (KERN_DEBUG "parport_wait_event returned %d\n", ret); 1086 DPRINTK(KERN_DEBUG "parport_wait_event returned %d\n",
1087 ret);
1073 if (ret < 0) 1088 if (ret < 0)
1074 break; 1089 break;
1075 ret = 0; 1090 ret = 0;
1076 if (!time_before (jiffies, expire)) { 1091 if (!time_before(jiffies, expire)) {
1077 /* Timed out. */ 1092 /* Timed out. */
1078dump_parport_state ("timeout", port); 1093 dump_parport_state("timeout", port);
1079 printk (KERN_DEBUG "PIO read timed out\n"); 1094 printk(KERN_DEBUG "PIO read timed out\n");
1080 break; 1095 break;
1081 } 1096 }
1082 ecrval = inb (ECONTROL (port)); 1097 ecrval = inb(ECONTROL(port));
1083 if (!(ecrval & (1<<2))) { 1098 if (!(ecrval & (1<<2))) {
1084 if (need_resched() && 1099 if (need_resched() &&
1085 time_before (jiffies, expire)) { 1100 time_before(jiffies, expire)) {
1086 schedule (); 1101 schedule();
1087 } 1102 }
1088 goto false_alarm; 1103 goto false_alarm;
1089 } 1104 }
1090 1105
1091 /* Depending on how the FIFO threshold was 1106 /* Depending on how the FIFO threshold was
1092 * set, how long interrupt service took, and 1107 * set, how long interrupt service took, and
1093 * how fast the peripheral is, we might be 1108 * how fast the peripheral is, we might be
1094 * lucky and have a just filled FIFO. */ 1109 * lucky and have a just filled FIFO. */
1095 continue; 1110 continue;
1096 } 1111 }
1097 1112
1098 if (ecrval & 0x02) { 1113 if (ecrval & 0x02) {
1099 /* FIFO is full. */ 1114 /* FIFO is full. */
1100dump_parport_state ("FIFO full", port); 1115 dump_parport_state("FIFO full", port);
1101 insb (fifo, bufp, fifo_depth); 1116 insb(fifo, bufp, fifo_depth);
1102 bufp += fifo_depth; 1117 bufp += fifo_depth;
1103 left -= fifo_depth; 1118 left -= fifo_depth;
1104 continue; 1119 continue;
1105 } 1120 }
1106 1121
1107DPRINTK (KERN_DEBUG "*** ecp_read_block_pio: reading one byte from the FIFO\n"); 1122 DPRINTK(KERN_DEBUG
1123 "*** ecp_read_block_pio: reading one byte from the FIFO\n");
1108 1124
1109 /* FIFO not filled. We will cycle this loop for a while 1125 /* FIFO not filled. We will cycle this loop for a while
1110 * and either the peripheral will fill it faster, 1126 * and either the peripheral will fill it faster,
1111 * tripping a fast empty with insb, or we empty it. */ 1127 * tripping a fast empty with insb, or we empty it. */
1112 *bufp++ = inb (fifo); 1128 *bufp++ = inb(fifo);
1113 left--; 1129 left--;
1114 } 1130 }
1115 1131
1116 /* scoop up anything left in the FIFO */ 1132 /* scoop up anything left in the FIFO */
1117 while (left && !(inb (ECONTROL (port) & 0x01))) { 1133 while (left && !(inb(ECONTROL(port) & 0x01))) {
1118 *bufp++ = inb (fifo); 1134 *bufp++ = inb(fifo);
1119 left--; 1135 left--;
1120 } 1136 }
1121 1137
1122 port->ieee1284.phase = IEEE1284_PH_REV_IDLE; 1138 port->ieee1284.phase = IEEE1284_PH_REV_IDLE;
1123dump_parport_state ("rev idle2", port); 1139 dump_parport_state("rev idle2", port);
1124 1140
1125out_no_data: 1141out_no_data:
1126 1142
1127 /* Go to forward idle mode to shut the peripheral up (event 47). */ 1143 /* Go to forward idle mode to shut the peripheral up (event 47). */
1128 parport_frob_control (port, PARPORT_CONTROL_INIT, PARPORT_CONTROL_INIT); 1144 parport_frob_control(port, PARPORT_CONTROL_INIT, PARPORT_CONTROL_INIT);
1129 1145
1130 /* event 49: PError goes high */ 1146 /* event 49: PError goes high */
1131 r = parport_wait_peripheral (port, 1147 r = parport_wait_peripheral(port,
1132 PARPORT_STATUS_PAPEROUT, 1148 PARPORT_STATUS_PAPEROUT,
1133 PARPORT_STATUS_PAPEROUT); 1149 PARPORT_STATUS_PAPEROUT);
1134 if (r) { 1150 if (r) {
1135 printk (KERN_DEBUG 1151 printk(KERN_DEBUG
1136 "%s: PE timeout FWDIDLE (%d) in ecp_read_block_pio\n", 1152 "%s: PE timeout FWDIDLE (%d) in ecp_read_block_pio\n",
1137 port->name, r); 1153 port->name, r);
1138 } 1154 }
@@ -1141,14 +1157,14 @@ out_no_data:
1141 1157
1142 /* Finish up. */ 1158 /* Finish up. */
1143 { 1159 {
1144 int lost = get_fifo_residue (port); 1160 int lost = get_fifo_residue(port);
1145 if (lost) 1161 if (lost)
1146 /* Shouldn't happen with compliant peripherals. */ 1162 /* Shouldn't happen with compliant peripherals. */
1147 printk (KERN_DEBUG "%s: DATA LOSS (%d bytes)!\n", 1163 printk(KERN_DEBUG "%s: DATA LOSS (%d bytes)!\n",
1148 port->name, lost); 1164 port->name, lost);
1149 } 1165 }
1150 1166
1151dump_parport_state ("fwd idle", port); 1167 dump_parport_state("fwd idle", port);
1152 return length - left; 1168 return length - left;
1153} 1169}
1154#endif /* 0 */ 1170#endif /* 0 */
@@ -1164,8 +1180,7 @@ dump_parport_state ("fwd idle", port);
1164 1180
1165/* GCC is not inlining extern inline function later overwriten to non-inline, 1181/* GCC is not inlining extern inline function later overwriten to non-inline,
1166 so we use outlined_ variants here. */ 1182 so we use outlined_ variants here. */
1167static const struct parport_operations parport_pc_ops = 1183static const struct parport_operations parport_pc_ops = {
1168{
1169 .write_data = parport_pc_write_data, 1184 .write_data = parport_pc_write_data,
1170 .read_data = parport_pc_read_data, 1185 .read_data = parport_pc_read_data,
1171 1186
@@ -1202,88 +1217,107 @@ static const struct parport_operations parport_pc_ops =
1202}; 1217};
1203 1218
1204#ifdef CONFIG_PARPORT_PC_SUPERIO 1219#ifdef CONFIG_PARPORT_PC_SUPERIO
1220
1221static struct superio_struct *find_free_superio(void)
1222{
1223 int i;
1224 for (i = 0; i < NR_SUPERIOS; i++)
1225 if (superios[i].io == 0)
1226 return &superios[i];
1227 return NULL;
1228}
1229
1230
1205/* Super-IO chipset detection, Winbond, SMSC */ 1231/* Super-IO chipset detection, Winbond, SMSC */
1206static void __devinit show_parconfig_smsc37c669(int io, int key) 1232static void __devinit show_parconfig_smsc37c669(int io, int key)
1207{ 1233{
1208 int cr1,cr4,cra,cr23,cr26,cr27,i=0; 1234 int cr1, cr4, cra, cr23, cr26, cr27;
1209 static const char *const modes[]={ 1235 struct superio_struct *s;
1236
1237 static const char *const modes[] = {
1210 "SPP and Bidirectional (PS/2)", 1238 "SPP and Bidirectional (PS/2)",
1211 "EPP and SPP", 1239 "EPP and SPP",
1212 "ECP", 1240 "ECP",
1213 "ECP and EPP" }; 1241 "ECP and EPP" };
1214 1242
1215 outb(key,io); 1243 outb(key, io);
1216 outb(key,io); 1244 outb(key, io);
1217 outb(1,io); 1245 outb(1, io);
1218 cr1=inb(io+1); 1246 cr1 = inb(io + 1);
1219 outb(4,io); 1247 outb(4, io);
1220 cr4=inb(io+1); 1248 cr4 = inb(io + 1);
1221 outb(0x0a,io); 1249 outb(0x0a, io);
1222 cra=inb(io+1); 1250 cra = inb(io + 1);
1223 outb(0x23,io); 1251 outb(0x23, io);
1224 cr23=inb(io+1); 1252 cr23 = inb(io + 1);
1225 outb(0x26,io); 1253 outb(0x26, io);
1226 cr26=inb(io+1); 1254 cr26 = inb(io + 1);
1227 outb(0x27,io); 1255 outb(0x27, io);
1228 cr27=inb(io+1); 1256 cr27 = inb(io + 1);
1229 outb(0xaa,io); 1257 outb(0xaa, io);
1230 1258
1231 if (verbose_probing) { 1259 if (verbose_probing) {
1232 printk (KERN_INFO "SMSC 37c669 LPT Config: cr_1=0x%02x, 4=0x%02x, " 1260 printk(KERN_INFO
1261 "SMSC 37c669 LPT Config: cr_1=0x%02x, 4=0x%02x, "
1233 "A=0x%2x, 23=0x%02x, 26=0x%02x, 27=0x%02x\n", 1262 "A=0x%2x, 23=0x%02x, 26=0x%02x, 27=0x%02x\n",
1234 cr1,cr4,cra,cr23,cr26,cr27); 1263 cr1, cr4, cra, cr23, cr26, cr27);
1235 1264
1236 /* The documentation calls DMA and IRQ-Lines by letters, so 1265 /* The documentation calls DMA and IRQ-Lines by letters, so
1237 the board maker can/will wire them 1266 the board maker can/will wire them
1238 appropriately/randomly... G=reserved H=IDE-irq, */ 1267 appropriately/randomly... G=reserved H=IDE-irq, */
1239 printk (KERN_INFO "SMSC LPT Config: io=0x%04x, irq=%c, dma=%c, " 1268 printk(KERN_INFO
1240 "fifo threshold=%d\n", cr23*4, 1269 "SMSC LPT Config: io=0x%04x, irq=%c, dma=%c, fifo threshold=%d\n",
1241 (cr27 &0x0f) ? 'A'-1+(cr27 &0x0f): '-', 1270 cr23 * 4,
1242 (cr26 &0x0f) ? 'A'-1+(cr26 &0x0f): '-', cra & 0x0f); 1271 (cr27 & 0x0f) ? 'A' - 1 + (cr27 & 0x0f) : '-',
1272 (cr26 & 0x0f) ? 'A' - 1 + (cr26 & 0x0f) : '-',
1273 cra & 0x0f);
1243 printk(KERN_INFO "SMSC LPT Config: enabled=%s power=%s\n", 1274 printk(KERN_INFO "SMSC LPT Config: enabled=%s power=%s\n",
1244 (cr23*4 >=0x100) ?"yes":"no", (cr1 & 4) ? "yes" : "no"); 1275 (cr23 * 4 >= 0x100) ? "yes" : "no",
1245 printk(KERN_INFO "SMSC LPT Config: Port mode=%s, EPP version =%s\n", 1276 (cr1 & 4) ? "yes" : "no");
1246 (cr1 & 0x08 ) ? "Standard mode only (SPP)" : modes[cr4 & 0x03], 1277 printk(KERN_INFO
1247 (cr4 & 0x40) ? "1.7" : "1.9"); 1278 "SMSC LPT Config: Port mode=%s, EPP version =%s\n",
1279 (cr1 & 0x08) ? "Standard mode only (SPP)"
1280 : modes[cr4 & 0x03],
1281 (cr4 & 0x40) ? "1.7" : "1.9");
1248 } 1282 }
1249 1283
1250 /* Heuristics ! BIOS setup for this mainboard device limits 1284 /* Heuristics ! BIOS setup for this mainboard device limits
1251 the choices to standard settings, i.e. io-address and IRQ 1285 the choices to standard settings, i.e. io-address and IRQ
1252 are related, however DMA can be 1 or 3, assume DMA_A=DMA1, 1286 are related, however DMA can be 1 or 3, assume DMA_A=DMA1,
1253 DMA_C=DMA3 (this is true e.g. for TYAN 1564D Tomcat IV) */ 1287 DMA_C=DMA3 (this is true e.g. for TYAN 1564D Tomcat IV) */
1254 if(cr23*4 >=0x100) { /* if active */ 1288 if (cr23 * 4 >= 0x100) { /* if active */
1255 while((superios[i].io!= 0) && (i<NR_SUPERIOS)) 1289 s = find_free_superio();
1256 i++; 1290 if (s == NULL)
1257 if(i==NR_SUPERIOS)
1258 printk(KERN_INFO "Super-IO: too many chips!\n"); 1291 printk(KERN_INFO "Super-IO: too many chips!\n");
1259 else { 1292 else {
1260 int d; 1293 int d;
1261 switch (cr23*4) { 1294 switch (cr23 * 4) {
1262 case 0x3bc: 1295 case 0x3bc:
1263 superios[i].io = 0x3bc; 1296 s->io = 0x3bc;
1264 superios[i].irq = 7; 1297 s->irq = 7;
1265 break; 1298 break;
1266 case 0x378: 1299 case 0x378:
1267 superios[i].io = 0x378; 1300 s->io = 0x378;
1268 superios[i].irq = 7; 1301 s->irq = 7;
1269 break; 1302 break;
1270 case 0x278: 1303 case 0x278:
1271 superios[i].io = 0x278; 1304 s->io = 0x278;
1272 superios[i].irq = 5; 1305 s->irq = 5;
1273 } 1306 }
1274 d=(cr26 &0x0f); 1307 d = (cr26 & 0x0f);
1275 if((d==1) || (d==3)) 1308 if (d == 1 || d == 3)
1276 superios[i].dma= d; 1309 s->dma = d;
1277 else 1310 else
1278 superios[i].dma= PARPORT_DMA_NONE; 1311 s->dma = PARPORT_DMA_NONE;
1279 } 1312 }
1280 } 1313 }
1281} 1314}
1282 1315
1283 1316
1284static void __devinit show_parconfig_winbond(int io, int key) 1317static void __devinit show_parconfig_winbond(int io, int key)
1285{ 1318{
1286 int cr30,cr60,cr61,cr70,cr74,crf0,i=0; 1319 int cr30, cr60, cr61, cr70, cr74, crf0;
1320 struct superio_struct *s;
1287 static const char *const modes[] = { 1321 static const char *const modes[] = {
1288 "Standard (SPP) and Bidirectional(PS/2)", /* 0 */ 1322 "Standard (SPP) and Bidirectional(PS/2)", /* 0 */
1289 "EPP-1.9 and SPP", 1323 "EPP-1.9 and SPP",
@@ -1296,110 +1330,134 @@ static void __devinit show_parconfig_winbond(int io, int key)
1296 static char *const irqtypes[] = { 1330 static char *const irqtypes[] = {
1297 "pulsed low, high-Z", 1331 "pulsed low, high-Z",
1298 "follows nACK" }; 1332 "follows nACK" };
1299 1333
1300 /* The registers are called compatible-PnP because the 1334 /* The registers are called compatible-PnP because the
1301 register layout is modelled after ISA-PnP, the access 1335 register layout is modelled after ISA-PnP, the access
1302 method is just another ... */ 1336 method is just another ... */
1303 outb(key,io); 1337 outb(key, io);
1304 outb(key,io); 1338 outb(key, io);
1305 outb(0x07,io); /* Register 7: Select Logical Device */ 1339 outb(0x07, io); /* Register 7: Select Logical Device */
1306 outb(0x01,io+1); /* LD1 is Parallel Port */ 1340 outb(0x01, io + 1); /* LD1 is Parallel Port */
1307 outb(0x30,io); 1341 outb(0x30, io);
1308 cr30=inb(io+1); 1342 cr30 = inb(io + 1);
1309 outb(0x60,io); 1343 outb(0x60, io);
1310 cr60=inb(io+1); 1344 cr60 = inb(io + 1);
1311 outb(0x61,io); 1345 outb(0x61, io);
1312 cr61=inb(io+1); 1346 cr61 = inb(io + 1);
1313 outb(0x70,io); 1347 outb(0x70, io);
1314 cr70=inb(io+1); 1348 cr70 = inb(io + 1);
1315 outb(0x74,io); 1349 outb(0x74, io);
1316 cr74=inb(io+1); 1350 cr74 = inb(io + 1);
1317 outb(0xf0,io); 1351 outb(0xf0, io);
1318 crf0=inb(io+1); 1352 crf0 = inb(io + 1);
1319 outb(0xaa,io); 1353 outb(0xaa, io);
1320 1354
1321 if (verbose_probing) { 1355 if (verbose_probing) {
1322 printk(KERN_INFO "Winbond LPT Config: cr_30=%02x 60,61=%02x%02x " 1356 printk(KERN_INFO
1323 "70=%02x 74=%02x, f0=%02x\n", cr30,cr60,cr61,cr70,cr74,crf0); 1357 "Winbond LPT Config: cr_30=%02x 60,61=%02x%02x 70=%02x 74=%02x, f0=%02x\n",
1324 printk(KERN_INFO "Winbond LPT Config: active=%s, io=0x%02x%02x irq=%d, ", 1358 cr30, cr60, cr61, cr70, cr74, crf0);
1325 (cr30 & 0x01) ? "yes":"no", cr60,cr61,cr70&0x0f ); 1359 printk(KERN_INFO "Winbond LPT Config: active=%s, io=0x%02x%02x irq=%d, ",
1360 (cr30 & 0x01) ? "yes" : "no", cr60, cr61, cr70 & 0x0f);
1326 if ((cr74 & 0x07) > 3) 1361 if ((cr74 & 0x07) > 3)
1327 printk("dma=none\n"); 1362 printk("dma=none\n");
1328 else 1363 else
1329 printk("dma=%d\n",cr74 & 0x07); 1364 printk("dma=%d\n", cr74 & 0x07);
1330 printk(KERN_INFO "Winbond LPT Config: irqtype=%s, ECP fifo threshold=%d\n", 1365 printk(KERN_INFO
1331 irqtypes[crf0>>7], (crf0>>3)&0x0f); 1366 "Winbond LPT Config: irqtype=%s, ECP fifo threshold=%d\n",
1332 printk(KERN_INFO "Winbond LPT Config: Port mode=%s\n", modes[crf0 & 0x07]); 1367 irqtypes[crf0>>7], (crf0>>3)&0x0f);
1368 printk(KERN_INFO "Winbond LPT Config: Port mode=%s\n",
1369 modes[crf0 & 0x07]);
1333 } 1370 }
1334 1371
1335 if(cr30 & 0x01) { /* the settings can be interrogated later ... */ 1372 if (cr30 & 0x01) { /* the settings can be interrogated later ... */
1336 while((superios[i].io!= 0) && (i<NR_SUPERIOS)) 1373 s = find_free_superio();
1337 i++; 1374 if (s == NULL)
1338 if(i==NR_SUPERIOS)
1339 printk(KERN_INFO "Super-IO: too many chips!\n"); 1375 printk(KERN_INFO "Super-IO: too many chips!\n");
1340 else { 1376 else {
1341 superios[i].io = (cr60<<8)|cr61; 1377 s->io = (cr60 << 8) | cr61;
1342 superios[i].irq = cr70&0x0f; 1378 s->irq = cr70 & 0x0f;
1343 superios[i].dma = (((cr74 & 0x07) > 3) ? 1379 s->dma = (((cr74 & 0x07) > 3) ?
1344 PARPORT_DMA_NONE : (cr74 & 0x07)); 1380 PARPORT_DMA_NONE : (cr74 & 0x07));
1345 } 1381 }
1346 } 1382 }
1347} 1383}
1348 1384
1349static void __devinit decode_winbond(int efer, int key, int devid, int devrev, int oldid) 1385static void __devinit decode_winbond(int efer, int key, int devid,
1386 int devrev, int oldid)
1350{ 1387{
1351 const char *type = "unknown"; 1388 const char *type = "unknown";
1352 int id,progif=2; 1389 int id, progif = 2;
1353 1390
1354 if (devid == devrev) 1391 if (devid == devrev)
1355 /* simple heuristics, we happened to read some 1392 /* simple heuristics, we happened to read some
1356 non-winbond register */ 1393 non-winbond register */
1357 return; 1394 return;
1358 1395
1359 id=(devid<<8) | devrev; 1396 id = (devid << 8) | devrev;
1360 1397
1361 /* Values are from public data sheets pdf files, I can just 1398 /* Values are from public data sheets pdf files, I can just
1362 confirm 83977TF is correct :-) */ 1399 confirm 83977TF is correct :-) */
1363 if (id == 0x9771) type="83977F/AF"; 1400 if (id == 0x9771)
1364 else if (id == 0x9773) type="83977TF / SMSC 97w33x/97w34x"; 1401 type = "83977F/AF";
1365 else if (id == 0x9774) type="83977ATF"; 1402 else if (id == 0x9773)
1366 else if ((id & ~0x0f) == 0x5270) type="83977CTF / SMSC 97w36x"; 1403 type = "83977TF / SMSC 97w33x/97w34x";
1367 else if ((id & ~0x0f) == 0x52f0) type="83977EF / SMSC 97w35x"; 1404 else if (id == 0x9774)
1368 else if ((id & ~0x0f) == 0x5210) type="83627"; 1405 type = "83977ATF";
1369 else if ((id & ~0x0f) == 0x6010) type="83697HF"; 1406 else if ((id & ~0x0f) == 0x5270)
1370 else if ((oldid &0x0f ) == 0x0a) { type="83877F"; progif=1;} 1407 type = "83977CTF / SMSC 97w36x";
1371 else if ((oldid &0x0f ) == 0x0b) { type="83877AF"; progif=1;} 1408 else if ((id & ~0x0f) == 0x52f0)
1372 else if ((oldid &0x0f ) == 0x0c) { type="83877TF"; progif=1;} 1409 type = "83977EF / SMSC 97w35x";
1373 else if ((oldid &0x0f ) == 0x0d) { type="83877ATF"; progif=1;} 1410 else if ((id & ~0x0f) == 0x5210)
1374 else progif=0; 1411 type = "83627";
1412 else if ((id & ~0x0f) == 0x6010)
1413 type = "83697HF";
1414 else if ((oldid & 0x0f) == 0x0a) {
1415 type = "83877F";
1416 progif = 1;
1417 } else if ((oldid & 0x0f) == 0x0b) {
1418 type = "83877AF";
1419 progif = 1;
1420 } else if ((oldid & 0x0f) == 0x0c) {
1421 type = "83877TF";
1422 progif = 1;
1423 } else if ((oldid & 0x0f) == 0x0d) {
1424 type = "83877ATF";
1425 progif = 1;
1426 } else
1427 progif = 0;
1375 1428
1376 if (verbose_probing) 1429 if (verbose_probing)
1377 printk(KERN_INFO "Winbond chip at EFER=0x%x key=0x%02x " 1430 printk(KERN_INFO "Winbond chip at EFER=0x%x key=0x%02x "
1378 "devid=%02x devrev=%02x oldid=%02x type=%s\n", 1431 "devid=%02x devrev=%02x oldid=%02x type=%s\n",
1379 efer, key, devid, devrev, oldid, type); 1432 efer, key, devid, devrev, oldid, type);
1380 1433
1381 if (progif == 2) 1434 if (progif == 2)
1382 show_parconfig_winbond(efer,key); 1435 show_parconfig_winbond(efer, key);
1383} 1436}
1384 1437
1385static void __devinit decode_smsc(int efer, int key, int devid, int devrev) 1438static void __devinit decode_smsc(int efer, int key, int devid, int devrev)
1386{ 1439{
1387 const char *type = "unknown"; 1440 const char *type = "unknown";
1388 void (*func)(int io, int key); 1441 void (*func)(int io, int key);
1389 int id; 1442 int id;
1390 1443
1391 if (devid == devrev) 1444 if (devid == devrev)
1392 /* simple heuristics, we happened to read some 1445 /* simple heuristics, we happened to read some
1393 non-smsc register */ 1446 non-smsc register */
1394 return; 1447 return;
1395 1448
1396 func=NULL; 1449 func = NULL;
1397 id=(devid<<8) | devrev; 1450 id = (devid << 8) | devrev;
1398 1451
1399 if (id==0x0302) {type="37c669"; func=show_parconfig_smsc37c669;} 1452 if (id == 0x0302) {
1400 else if (id==0x6582) type="37c665IR"; 1453 type = "37c669";
1401 else if (devid==0x65) type="37c665GT"; 1454 func = show_parconfig_smsc37c669;
1402 else if (devid==0x66) type="37c666GT"; 1455 } else if (id == 0x6582)
1456 type = "37c665IR";
1457 else if (devid == 0x65)
1458 type = "37c665GT";
1459 else if (devid == 0x66)
1460 type = "37c666GT";
1403 1461
1404 if (verbose_probing) 1462 if (verbose_probing)
1405 printk(KERN_INFO "SMSC chip at EFER=0x%x " 1463 printk(KERN_INFO "SMSC chip at EFER=0x%x "
@@ -1407,138 +1465,138 @@ static void __devinit decode_smsc(int efer, int key, int devid, int devrev)
1407 efer, key, devid, devrev, type); 1465 efer, key, devid, devrev, type);
1408 1466
1409 if (func) 1467 if (func)
1410 func(efer,key); 1468 func(efer, key);
1411} 1469}
1412 1470
1413 1471
1414static void __devinit winbond_check(int io, int key) 1472static void __devinit winbond_check(int io, int key)
1415{ 1473{
1416 int devid,devrev,oldid,x_devid,x_devrev,x_oldid; 1474 int devid, devrev, oldid, x_devid, x_devrev, x_oldid;
1417 1475
1418 if (!request_region(io, 3, __func__)) 1476 if (!request_region(io, 3, __func__))
1419 return; 1477 return;
1420 1478
1421 /* First probe without key */ 1479 /* First probe without key */
1422 outb(0x20,io); 1480 outb(0x20, io);
1423 x_devid=inb(io+1); 1481 x_devid = inb(io + 1);
1424 outb(0x21,io); 1482 outb(0x21, io);
1425 x_devrev=inb(io+1); 1483 x_devrev = inb(io + 1);
1426 outb(0x09,io); 1484 outb(0x09, io);
1427 x_oldid=inb(io+1); 1485 x_oldid = inb(io + 1);
1428 1486
1429 outb(key,io); 1487 outb(key, io);
1430 outb(key,io); /* Write Magic Sequence to EFER, extended 1488 outb(key, io); /* Write Magic Sequence to EFER, extended
1431 funtion enable register */ 1489 funtion enable register */
1432 outb(0x20,io); /* Write EFIR, extended function index register */ 1490 outb(0x20, io); /* Write EFIR, extended function index register */
1433 devid=inb(io+1); /* Read EFDR, extended function data register */ 1491 devid = inb(io + 1); /* Read EFDR, extended function data register */
1434 outb(0x21,io); 1492 outb(0x21, io);
1435 devrev=inb(io+1); 1493 devrev = inb(io + 1);
1436 outb(0x09,io); 1494 outb(0x09, io);
1437 oldid=inb(io+1); 1495 oldid = inb(io + 1);
1438 outb(0xaa,io); /* Magic Seal */ 1496 outb(0xaa, io); /* Magic Seal */
1439 1497
1440 if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid)) 1498 if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid))
1441 goto out; /* protection against false positives */ 1499 goto out; /* protection against false positives */
1442 1500
1443 decode_winbond(io,key,devid,devrev,oldid); 1501 decode_winbond(io, key, devid, devrev, oldid);
1444out: 1502out:
1445 release_region(io, 3); 1503 release_region(io, 3);
1446} 1504}
1447 1505
1448static void __devinit winbond_check2(int io,int key) 1506static void __devinit winbond_check2(int io, int key)
1449{ 1507{
1450 int devid,devrev,oldid,x_devid,x_devrev,x_oldid; 1508 int devid, devrev, oldid, x_devid, x_devrev, x_oldid;
1451 1509
1452 if (!request_region(io, 3, __func__)) 1510 if (!request_region(io, 3, __func__))
1453 return; 1511 return;
1454 1512
1455 /* First probe without the key */ 1513 /* First probe without the key */
1456 outb(0x20,io+2); 1514 outb(0x20, io + 2);
1457 x_devid=inb(io+2); 1515 x_devid = inb(io + 2);
1458 outb(0x21,io+1); 1516 outb(0x21, io + 1);
1459 x_devrev=inb(io+2); 1517 x_devrev = inb(io + 2);
1460 outb(0x09,io+1); 1518 outb(0x09, io + 1);
1461 x_oldid=inb(io+2); 1519 x_oldid = inb(io + 2);
1462 1520
1463 outb(key,io); /* Write Magic Byte to EFER, extended 1521 outb(key, io); /* Write Magic Byte to EFER, extended
1464 funtion enable register */ 1522 funtion enable register */
1465 outb(0x20,io+2); /* Write EFIR, extended function index register */ 1523 outb(0x20, io + 2); /* Write EFIR, extended function index register */
1466 devid=inb(io+2); /* Read EFDR, extended function data register */ 1524 devid = inb(io + 2); /* Read EFDR, extended function data register */
1467 outb(0x21,io+1); 1525 outb(0x21, io + 1);
1468 devrev=inb(io+2); 1526 devrev = inb(io + 2);
1469 outb(0x09,io+1); 1527 outb(0x09, io + 1);
1470 oldid=inb(io+2); 1528 oldid = inb(io + 2);
1471 outb(0xaa,io); /* Magic Seal */ 1529 outb(0xaa, io); /* Magic Seal */
1472 1530
1473 if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid)) 1531 if (x_devid == devid && x_devrev == devrev && x_oldid == oldid)
1474 goto out; /* protection against false positives */ 1532 goto out; /* protection against false positives */
1475 1533
1476 decode_winbond(io,key,devid,devrev,oldid); 1534 decode_winbond(io, key, devid, devrev, oldid);
1477out: 1535out:
1478 release_region(io, 3); 1536 release_region(io, 3);
1479} 1537}
1480 1538
1481static void __devinit smsc_check(int io, int key) 1539static void __devinit smsc_check(int io, int key)
1482{ 1540{
1483 int id,rev,oldid,oldrev,x_id,x_rev,x_oldid,x_oldrev; 1541 int id, rev, oldid, oldrev, x_id, x_rev, x_oldid, x_oldrev;
1484 1542
1485 if (!request_region(io, 3, __func__)) 1543 if (!request_region(io, 3, __func__))
1486 return; 1544 return;
1487 1545
1488 /* First probe without the key */ 1546 /* First probe without the key */
1489 outb(0x0d,io); 1547 outb(0x0d, io);
1490 x_oldid=inb(io+1); 1548 x_oldid = inb(io + 1);
1491 outb(0x0e,io); 1549 outb(0x0e, io);
1492 x_oldrev=inb(io+1); 1550 x_oldrev = inb(io + 1);
1493 outb(0x20,io); 1551 outb(0x20, io);
1494 x_id=inb(io+1); 1552 x_id = inb(io + 1);
1495 outb(0x21,io); 1553 outb(0x21, io);
1496 x_rev=inb(io+1); 1554 x_rev = inb(io + 1);
1497 1555
1498 outb(key,io); 1556 outb(key, io);
1499 outb(key,io); /* Write Magic Sequence to EFER, extended 1557 outb(key, io); /* Write Magic Sequence to EFER, extended
1500 funtion enable register */ 1558 funtion enable register */
1501 outb(0x0d,io); /* Write EFIR, extended function index register */ 1559 outb(0x0d, io); /* Write EFIR, extended function index register */
1502 oldid=inb(io+1); /* Read EFDR, extended function data register */ 1560 oldid = inb(io + 1); /* Read EFDR, extended function data register */
1503 outb(0x0e,io); 1561 outb(0x0e, io);
1504 oldrev=inb(io+1); 1562 oldrev = inb(io + 1);
1505 outb(0x20,io); 1563 outb(0x20, io);
1506 id=inb(io+1); 1564 id = inb(io + 1);
1507 outb(0x21,io); 1565 outb(0x21, io);
1508 rev=inb(io+1); 1566 rev = inb(io + 1);
1509 outb(0xaa,io); /* Magic Seal */ 1567 outb(0xaa, io); /* Magic Seal */
1510 1568
1511 if ((x_id == id) && (x_oldrev == oldrev) && 1569 if (x_id == id && x_oldrev == oldrev &&
1512 (x_oldid == oldid) && (x_rev == rev)) 1570 x_oldid == oldid && x_rev == rev)
1513 goto out; /* protection against false positives */ 1571 goto out; /* protection against false positives */
1514 1572
1515 decode_smsc(io,key,oldid,oldrev); 1573 decode_smsc(io, key, oldid, oldrev);
1516out: 1574out:
1517 release_region(io, 3); 1575 release_region(io, 3);
1518} 1576}
1519 1577
1520 1578
1521static void __devinit detect_and_report_winbond (void) 1579static void __devinit detect_and_report_winbond(void)
1522{ 1580{
1523 if (verbose_probing) 1581 if (verbose_probing)
1524 printk(KERN_DEBUG "Winbond Super-IO detection, now testing ports 3F0,370,250,4E,2E ...\n"); 1582 printk(KERN_DEBUG "Winbond Super-IO detection, now testing ports 3F0,370,250,4E,2E ...\n");
1525 winbond_check(0x3f0,0x87); 1583 winbond_check(0x3f0, 0x87);
1526 winbond_check(0x370,0x87); 1584 winbond_check(0x370, 0x87);
1527 winbond_check(0x2e ,0x87); 1585 winbond_check(0x2e , 0x87);
1528 winbond_check(0x4e ,0x87); 1586 winbond_check(0x4e , 0x87);
1529 winbond_check(0x3f0,0x86); 1587 winbond_check(0x3f0, 0x86);
1530 winbond_check2(0x250,0x88); 1588 winbond_check2(0x250, 0x88);
1531 winbond_check2(0x250,0x89); 1589 winbond_check2(0x250, 0x89);
1532} 1590}
1533 1591
1534static void __devinit detect_and_report_smsc (void) 1592static void __devinit detect_and_report_smsc(void)
1535{ 1593{
1536 if (verbose_probing) 1594 if (verbose_probing)
1537 printk(KERN_DEBUG "SMSC Super-IO detection, now testing Ports 2F0, 370 ...\n"); 1595 printk(KERN_DEBUG "SMSC Super-IO detection, now testing Ports 2F0, 370 ...\n");
1538 smsc_check(0x3f0,0x55); 1596 smsc_check(0x3f0, 0x55);
1539 smsc_check(0x370,0x55); 1597 smsc_check(0x370, 0x55);
1540 smsc_check(0x3f0,0x44); 1598 smsc_check(0x3f0, 0x44);
1541 smsc_check(0x370,0x44); 1599 smsc_check(0x370, 0x44);
1542} 1600}
1543 1601
1544static void __devinit detect_and_report_it87(void) 1602static void __devinit detect_and_report_it87(void)
@@ -1573,34 +1631,39 @@ static void __devinit detect_and_report_it87(void)
1573} 1631}
1574#endif /* CONFIG_PARPORT_PC_SUPERIO */ 1632#endif /* CONFIG_PARPORT_PC_SUPERIO */
1575 1633
1576static int get_superio_dma (struct parport *p) 1634static struct superio_struct *find_superio(struct parport *p)
1577{ 1635{
1578 int i=0; 1636 int i;
1579 while( (superios[i].io != p->base) && (i<NR_SUPERIOS)) 1637 for (i = 0; i < NR_SUPERIOS; i++)
1580 i++; 1638 if (superios[i].io != p->base)
1581 if (i!=NR_SUPERIOS) 1639 return &superios[i];
1582 return superios[i].dma; 1640 return NULL;
1641}
1642
1643static int get_superio_dma(struct parport *p)
1644{
1645 struct superio_struct *s = find_superio(p);
1646 if (s)
1647 return s->dma;
1583 return PARPORT_DMA_NONE; 1648 return PARPORT_DMA_NONE;
1584} 1649}
1585 1650
1586static int get_superio_irq (struct parport *p) 1651static int get_superio_irq(struct parport *p)
1587{ 1652{
1588 int i=0; 1653 struct superio_struct *s = find_superio(p);
1589 while( (superios[i].io != p->base) && (i<NR_SUPERIOS)) 1654 if (s)
1590 i++; 1655 return s->irq;
1591 if (i!=NR_SUPERIOS) 1656 return PARPORT_IRQ_NONE;
1592 return superios[i].irq;
1593 return PARPORT_IRQ_NONE;
1594} 1657}
1595 1658
1596 1659
1597/* --- Mode detection ------------------------------------- */ 1660/* --- Mode detection ------------------------------------- */
1598 1661
1599/* 1662/*
1600 * Checks for port existence, all ports support SPP MODE 1663 * Checks for port existence, all ports support SPP MODE
1601 * Returns: 1664 * Returns:
1602 * 0 : No parallel port at this address 1665 * 0 : No parallel port at this address
1603 * PARPORT_MODE_PCSPP : SPP port detected 1666 * PARPORT_MODE_PCSPP : SPP port detected
1604 * (if the user specified an ioport himself, 1667 * (if the user specified an ioport himself,
1605 * this shall always be the case!) 1668 * this shall always be the case!)
1606 * 1669 *
@@ -1610,7 +1673,7 @@ static int parport_SPP_supported(struct parport *pb)
1610 unsigned char r, w; 1673 unsigned char r, w;
1611 1674
1612 /* 1675 /*
1613 * first clear an eventually pending EPP timeout 1676 * first clear an eventually pending EPP timeout
1614 * I (sailer@ife.ee.ethz.ch) have an SMSC chipset 1677 * I (sailer@ife.ee.ethz.ch) have an SMSC chipset
1615 * that does not even respond to SPP cycles if an EPP 1678 * that does not even respond to SPP cycles if an EPP
1616 * timeout is pending 1679 * timeout is pending
@@ -1619,19 +1682,19 @@ static int parport_SPP_supported(struct parport *pb)
1619 1682
1620 /* Do a simple read-write test to make sure the port exists. */ 1683 /* Do a simple read-write test to make sure the port exists. */
1621 w = 0xc; 1684 w = 0xc;
1622 outb (w, CONTROL (pb)); 1685 outb(w, CONTROL(pb));
1623 1686
1624 /* Is there a control register that we can read from? Some 1687 /* Is there a control register that we can read from? Some
1625 * ports don't allow reads, so read_control just returns a 1688 * ports don't allow reads, so read_control just returns a
1626 * software copy. Some ports _do_ allow reads, so bypass the 1689 * software copy. Some ports _do_ allow reads, so bypass the
1627 * software copy here. In addition, some bits aren't 1690 * software copy here. In addition, some bits aren't
1628 * writable. */ 1691 * writable. */
1629 r = inb (CONTROL (pb)); 1692 r = inb(CONTROL(pb));
1630 if ((r & 0xf) == w) { 1693 if ((r & 0xf) == w) {
1631 w = 0xe; 1694 w = 0xe;
1632 outb (w, CONTROL (pb)); 1695 outb(w, CONTROL(pb));
1633 r = inb (CONTROL (pb)); 1696 r = inb(CONTROL(pb));
1634 outb (0xc, CONTROL (pb)); 1697 outb(0xc, CONTROL(pb));
1635 if ((r & 0xf) == w) 1698 if ((r & 0xf) == w)
1636 return PARPORT_MODE_PCSPP; 1699 return PARPORT_MODE_PCSPP;
1637 } 1700 }
@@ -1639,18 +1702,18 @@ static int parport_SPP_supported(struct parport *pb)
1639 if (user_specified) 1702 if (user_specified)
1640 /* That didn't work, but the user thinks there's a 1703 /* That didn't work, but the user thinks there's a
1641 * port here. */ 1704 * port here. */
1642 printk (KERN_INFO "parport 0x%lx (WARNING): CTR: " 1705 printk(KERN_INFO "parport 0x%lx (WARNING): CTR: "
1643 "wrote 0x%02x, read 0x%02x\n", pb->base, w, r); 1706 "wrote 0x%02x, read 0x%02x\n", pb->base, w, r);
1644 1707
1645 /* Try the data register. The data lines aren't tri-stated at 1708 /* Try the data register. The data lines aren't tri-stated at
1646 * this stage, so we expect back what we wrote. */ 1709 * this stage, so we expect back what we wrote. */
1647 w = 0xaa; 1710 w = 0xaa;
1648 parport_pc_write_data (pb, w); 1711 parport_pc_write_data(pb, w);
1649 r = parport_pc_read_data (pb); 1712 r = parport_pc_read_data(pb);
1650 if (r == w) { 1713 if (r == w) {
1651 w = 0x55; 1714 w = 0x55;
1652 parport_pc_write_data (pb, w); 1715 parport_pc_write_data(pb, w);
1653 r = parport_pc_read_data (pb); 1716 r = parport_pc_read_data(pb);
1654 if (r == w) 1717 if (r == w)
1655 return PARPORT_MODE_PCSPP; 1718 return PARPORT_MODE_PCSPP;
1656 } 1719 }
@@ -1658,9 +1721,9 @@ static int parport_SPP_supported(struct parport *pb)
1658 if (user_specified) { 1721 if (user_specified) {
1659 /* Didn't work, but the user is convinced this is the 1722 /* Didn't work, but the user is convinced this is the
1660 * place. */ 1723 * place. */
1661 printk (KERN_INFO "parport 0x%lx (WARNING): DATA: " 1724 printk(KERN_INFO "parport 0x%lx (WARNING): DATA: "
1662 "wrote 0x%02x, read 0x%02x\n", pb->base, w, r); 1725 "wrote 0x%02x, read 0x%02x\n", pb->base, w, r);
1663 printk (KERN_INFO "parport 0x%lx: You gave this address, " 1726 printk(KERN_INFO "parport 0x%lx: You gave this address, "
1664 "but there is probably no parallel port there!\n", 1727 "but there is probably no parallel port there!\n",
1665 pb->base); 1728 pb->base);
1666 } 1729 }
@@ -1691,33 +1754,33 @@ static int parport_ECR_present(struct parport *pb)
1691 struct parport_pc_private *priv = pb->private_data; 1754 struct parport_pc_private *priv = pb->private_data;
1692 unsigned char r = 0xc; 1755 unsigned char r = 0xc;
1693 1756
1694 outb (r, CONTROL (pb)); 1757 outb(r, CONTROL(pb));
1695 if ((inb (ECONTROL (pb)) & 0x3) == (r & 0x3)) { 1758 if ((inb(ECONTROL(pb)) & 0x3) == (r & 0x3)) {
1696 outb (r ^ 0x2, CONTROL (pb)); /* Toggle bit 1 */ 1759 outb(r ^ 0x2, CONTROL(pb)); /* Toggle bit 1 */
1697 1760
1698 r = inb (CONTROL (pb)); 1761 r = inb(CONTROL(pb));
1699 if ((inb (ECONTROL (pb)) & 0x2) == (r & 0x2)) 1762 if ((inb(ECONTROL(pb)) & 0x2) == (r & 0x2))
1700 goto no_reg; /* Sure that no ECR register exists */ 1763 goto no_reg; /* Sure that no ECR register exists */
1701 } 1764 }
1702 1765
1703 if ((inb (ECONTROL (pb)) & 0x3 ) != 0x1) 1766 if ((inb(ECONTROL(pb)) & 0x3) != 0x1)
1704 goto no_reg; 1767 goto no_reg;
1705 1768
1706 ECR_WRITE (pb, 0x34); 1769 ECR_WRITE(pb, 0x34);
1707 if (inb (ECONTROL (pb)) != 0x35) 1770 if (inb(ECONTROL(pb)) != 0x35)
1708 goto no_reg; 1771 goto no_reg;
1709 1772
1710 priv->ecr = 1; 1773 priv->ecr = 1;
1711 outb (0xc, CONTROL (pb)); 1774 outb(0xc, CONTROL(pb));
1712 1775
1713 /* Go to mode 000 */ 1776 /* Go to mode 000 */
1714 frob_set_mode (pb, ECR_SPP); 1777 frob_set_mode(pb, ECR_SPP);
1715 1778
1716 return 1; 1779 return 1;
1717 1780
1718 no_reg: 1781 no_reg:
1719 outb (0xc, CONTROL (pb)); 1782 outb(0xc, CONTROL(pb));
1720 return 0; 1783 return 0;
1721} 1784}
1722 1785
1723#ifdef CONFIG_PARPORT_1284 1786#ifdef CONFIG_PARPORT_1284
@@ -1727,7 +1790,7 @@ static int parport_ECR_present(struct parport *pb)
1727 * allows us to read data from the data lines. In theory we would get back 1790 * allows us to read data from the data lines. In theory we would get back
1728 * 0xff but any peripheral attached to the port may drag some or all of the 1791 * 0xff but any peripheral attached to the port may drag some or all of the
1729 * lines down to zero. So if we get back anything that isn't the contents 1792 * lines down to zero. So if we get back anything that isn't the contents
1730 * of the data register we deem PS/2 support to be present. 1793 * of the data register we deem PS/2 support to be present.
1731 * 1794 *
1732 * Some SPP ports have "half PS/2" ability - you can't turn off the line 1795 * Some SPP ports have "half PS/2" ability - you can't turn off the line
1733 * drivers, but an external peripheral with sufficiently beefy drivers of 1796 * drivers, but an external peripheral with sufficiently beefy drivers of
@@ -1735,26 +1798,28 @@ static int parport_ECR_present(struct parport *pb)
1735 * where they can then be read back as normal. Ports with this property 1798 * where they can then be read back as normal. Ports with this property
1736 * and the right type of device attached are likely to fail the SPP test, 1799 * and the right type of device attached are likely to fail the SPP test,
1737 * (as they will appear to have stuck bits) and so the fact that they might 1800 * (as they will appear to have stuck bits) and so the fact that they might
1738 * be misdetected here is rather academic. 1801 * be misdetected here is rather academic.
1739 */ 1802 */
1740 1803
1741static int parport_PS2_supported(struct parport *pb) 1804static int parport_PS2_supported(struct parport *pb)
1742{ 1805{
1743 int ok = 0; 1806 int ok = 0;
1744 1807
1745 clear_epp_timeout(pb); 1808 clear_epp_timeout(pb);
1746 1809
1747 /* try to tri-state the buffer */ 1810 /* try to tri-state the buffer */
1748 parport_pc_data_reverse (pb); 1811 parport_pc_data_reverse(pb);
1749 1812
1750 parport_pc_write_data(pb, 0x55); 1813 parport_pc_write_data(pb, 0x55);
1751 if (parport_pc_read_data(pb) != 0x55) ok++; 1814 if (parport_pc_read_data(pb) != 0x55)
1815 ok++;
1752 1816
1753 parport_pc_write_data(pb, 0xaa); 1817 parport_pc_write_data(pb, 0xaa);
1754 if (parport_pc_read_data(pb) != 0xaa) ok++; 1818 if (parport_pc_read_data(pb) != 0xaa)
1819 ok++;
1755 1820
1756 /* cancel input mode */ 1821 /* cancel input mode */
1757 parport_pc_data_forward (pb); 1822 parport_pc_data_forward(pb);
1758 1823
1759 if (ok) { 1824 if (ok) {
1760 pb->modes |= PARPORT_MODE_TRISTATE; 1825 pb->modes |= PARPORT_MODE_TRISTATE;
@@ -1773,68 +1838,68 @@ static int parport_ECP_supported(struct parport *pb)
1773 int config, configb; 1838 int config, configb;
1774 int pword; 1839 int pword;
1775 struct parport_pc_private *priv = pb->private_data; 1840 struct parport_pc_private *priv = pb->private_data;
1776 /* Translate ECP intrLine to ISA irq value */ 1841 /* Translate ECP intrLine to ISA irq value */
1777 static const int intrline[]= { 0, 7, 9, 10, 11, 14, 15, 5 }; 1842 static const int intrline[] = { 0, 7, 9, 10, 11, 14, 15, 5 };
1778 1843
1779 /* If there is no ECR, we have no hope of supporting ECP. */ 1844 /* If there is no ECR, we have no hope of supporting ECP. */
1780 if (!priv->ecr) 1845 if (!priv->ecr)
1781 return 0; 1846 return 0;
1782 1847
1783 /* Find out FIFO depth */ 1848 /* Find out FIFO depth */
1784 ECR_WRITE (pb, ECR_SPP << 5); /* Reset FIFO */ 1849 ECR_WRITE(pb, ECR_SPP << 5); /* Reset FIFO */
1785 ECR_WRITE (pb, ECR_TST << 5); /* TEST FIFO */ 1850 ECR_WRITE(pb, ECR_TST << 5); /* TEST FIFO */
1786 for (i=0; i < 1024 && !(inb (ECONTROL (pb)) & 0x02); i++) 1851 for (i = 0; i < 1024 && !(inb(ECONTROL(pb)) & 0x02); i++)
1787 outb (0xaa, FIFO (pb)); 1852 outb(0xaa, FIFO(pb));
1788 1853
1789 /* 1854 /*
1790 * Using LGS chipset it uses ECR register, but 1855 * Using LGS chipset it uses ECR register, but
1791 * it doesn't support ECP or FIFO MODE 1856 * it doesn't support ECP or FIFO MODE
1792 */ 1857 */
1793 if (i == 1024) { 1858 if (i == 1024) {
1794 ECR_WRITE (pb, ECR_SPP << 5); 1859 ECR_WRITE(pb, ECR_SPP << 5);
1795 return 0; 1860 return 0;
1796 } 1861 }
1797 1862
1798 priv->fifo_depth = i; 1863 priv->fifo_depth = i;
1799 if (verbose_probing) 1864 if (verbose_probing)
1800 printk (KERN_DEBUG "0x%lx: FIFO is %d bytes\n", pb->base, i); 1865 printk(KERN_DEBUG "0x%lx: FIFO is %d bytes\n", pb->base, i);
1801 1866
1802 /* Find out writeIntrThreshold */ 1867 /* Find out writeIntrThreshold */
1803 frob_econtrol (pb, 1<<2, 1<<2); 1868 frob_econtrol(pb, 1<<2, 1<<2);
1804 frob_econtrol (pb, 1<<2, 0); 1869 frob_econtrol(pb, 1<<2, 0);
1805 for (i = 1; i <= priv->fifo_depth; i++) { 1870 for (i = 1; i <= priv->fifo_depth; i++) {
1806 inb (FIFO (pb)); 1871 inb(FIFO(pb));
1807 udelay (50); 1872 udelay(50);
1808 if (inb (ECONTROL (pb)) & (1<<2)) 1873 if (inb(ECONTROL(pb)) & (1<<2))
1809 break; 1874 break;
1810 } 1875 }
1811 1876
1812 if (i <= priv->fifo_depth) { 1877 if (i <= priv->fifo_depth) {
1813 if (verbose_probing) 1878 if (verbose_probing)
1814 printk (KERN_DEBUG "0x%lx: writeIntrThreshold is %d\n", 1879 printk(KERN_DEBUG "0x%lx: writeIntrThreshold is %d\n",
1815 pb->base, i); 1880 pb->base, i);
1816 } else 1881 } else
1817 /* Number of bytes we know we can write if we get an 1882 /* Number of bytes we know we can write if we get an
1818 interrupt. */ 1883 interrupt. */
1819 i = 0; 1884 i = 0;
1820 1885
1821 priv->writeIntrThreshold = i; 1886 priv->writeIntrThreshold = i;
1822 1887
1823 /* Find out readIntrThreshold */ 1888 /* Find out readIntrThreshold */
1824 frob_set_mode (pb, ECR_PS2); /* Reset FIFO and enable PS2 */ 1889 frob_set_mode(pb, ECR_PS2); /* Reset FIFO and enable PS2 */
1825 parport_pc_data_reverse (pb); /* Must be in PS2 mode */ 1890 parport_pc_data_reverse(pb); /* Must be in PS2 mode */
1826 frob_set_mode (pb, ECR_TST); /* Test FIFO */ 1891 frob_set_mode(pb, ECR_TST); /* Test FIFO */
1827 frob_econtrol (pb, 1<<2, 1<<2); 1892 frob_econtrol(pb, 1<<2, 1<<2);
1828 frob_econtrol (pb, 1<<2, 0); 1893 frob_econtrol(pb, 1<<2, 0);
1829 for (i = 1; i <= priv->fifo_depth; i++) { 1894 for (i = 1; i <= priv->fifo_depth; i++) {
1830 outb (0xaa, FIFO (pb)); 1895 outb(0xaa, FIFO(pb));
1831 if (inb (ECONTROL (pb)) & (1<<2)) 1896 if (inb(ECONTROL(pb)) & (1<<2))
1832 break; 1897 break;
1833 } 1898 }
1834 1899
1835 if (i <= priv->fifo_depth) { 1900 if (i <= priv->fifo_depth) {
1836 if (verbose_probing) 1901 if (verbose_probing)
1837 printk (KERN_INFO "0x%lx: readIntrThreshold is %d\n", 1902 printk(KERN_INFO "0x%lx: readIntrThreshold is %d\n",
1838 pb->base, i); 1903 pb->base, i);
1839 } else 1904 } else
1840 /* Number of bytes we can read if we get an interrupt. */ 1905 /* Number of bytes we can read if we get an interrupt. */
@@ -1842,23 +1907,23 @@ static int parport_ECP_supported(struct parport *pb)
1842 1907
1843 priv->readIntrThreshold = i; 1908 priv->readIntrThreshold = i;
1844 1909
1845 ECR_WRITE (pb, ECR_SPP << 5); /* Reset FIFO */ 1910 ECR_WRITE(pb, ECR_SPP << 5); /* Reset FIFO */
1846 ECR_WRITE (pb, 0xf4); /* Configuration mode */ 1911 ECR_WRITE(pb, 0xf4); /* Configuration mode */
1847 config = inb (CONFIGA (pb)); 1912 config = inb(CONFIGA(pb));
1848 pword = (config >> 4) & 0x7; 1913 pword = (config >> 4) & 0x7;
1849 switch (pword) { 1914 switch (pword) {
1850 case 0: 1915 case 0:
1851 pword = 2; 1916 pword = 2;
1852 printk (KERN_WARNING "0x%lx: Unsupported pword size!\n", 1917 printk(KERN_WARNING "0x%lx: Unsupported pword size!\n",
1853 pb->base); 1918 pb->base);
1854 break; 1919 break;
1855 case 2: 1920 case 2:
1856 pword = 4; 1921 pword = 4;
1857 printk (KERN_WARNING "0x%lx: Unsupported pword size!\n", 1922 printk(KERN_WARNING "0x%lx: Unsupported pword size!\n",
1858 pb->base); 1923 pb->base);
1859 break; 1924 break;
1860 default: 1925 default:
1861 printk (KERN_WARNING "0x%lx: Unknown implementation ID\n", 1926 printk(KERN_WARNING "0x%lx: Unknown implementation ID\n",
1862 pb->base); 1927 pb->base);
1863 /* Assume 1 */ 1928 /* Assume 1 */
1864 case 1: 1929 case 1:
@@ -1867,28 +1932,29 @@ static int parport_ECP_supported(struct parport *pb)
1867 priv->pword = pword; 1932 priv->pword = pword;
1868 1933
1869 if (verbose_probing) { 1934 if (verbose_probing) {
1870 printk (KERN_DEBUG "0x%lx: PWord is %d bits\n", pb->base, 8 * pword); 1935 printk(KERN_DEBUG "0x%lx: PWord is %d bits\n",
1871 1936 pb->base, 8 * pword);
1872 printk (KERN_DEBUG "0x%lx: Interrupts are ISA-%s\n", pb->base, 1937
1938 printk(KERN_DEBUG "0x%lx: Interrupts are ISA-%s\n", pb->base,
1873 config & 0x80 ? "Level" : "Pulses"); 1939 config & 0x80 ? "Level" : "Pulses");
1874 1940
1875 configb = inb (CONFIGB (pb)); 1941 configb = inb(CONFIGB(pb));
1876 printk (KERN_DEBUG "0x%lx: ECP port cfgA=0x%02x cfgB=0x%02x\n", 1942 printk(KERN_DEBUG "0x%lx: ECP port cfgA=0x%02x cfgB=0x%02x\n",
1877 pb->base, config, configb); 1943 pb->base, config, configb);
1878 printk (KERN_DEBUG "0x%lx: ECP settings irq=", pb->base); 1944 printk(KERN_DEBUG "0x%lx: ECP settings irq=", pb->base);
1879 if ((configb >>3) & 0x07) 1945 if ((configb >> 3) & 0x07)
1880 printk("%d",intrline[(configb >>3) & 0x07]); 1946 printk("%d", intrline[(configb >> 3) & 0x07]);
1881 else 1947 else
1882 printk("<none or set by other means>"); 1948 printk("<none or set by other means>");
1883 printk (" dma="); 1949 printk(" dma=");
1884 if( (configb & 0x03 ) == 0x00) 1950 if ((configb & 0x03) == 0x00)
1885 printk("<none or set by other means>\n"); 1951 printk("<none or set by other means>\n");
1886 else 1952 else
1887 printk("%d\n",configb & 0x07); 1953 printk("%d\n", configb & 0x07);
1888 } 1954 }
1889 1955
1890 /* Go back to mode 000 */ 1956 /* Go back to mode 000 */
1891 frob_set_mode (pb, ECR_SPP); 1957 frob_set_mode(pb, ECR_SPP);
1892 1958
1893 return 1; 1959 return 1;
1894} 1960}
@@ -1903,10 +1969,10 @@ static int parport_ECPPS2_supported(struct parport *pb)
1903 if (!priv->ecr) 1969 if (!priv->ecr)
1904 return 0; 1970 return 0;
1905 1971
1906 oecr = inb (ECONTROL (pb)); 1972 oecr = inb(ECONTROL(pb));
1907 ECR_WRITE (pb, ECR_PS2 << 5); 1973 ECR_WRITE(pb, ECR_PS2 << 5);
1908 result = parport_PS2_supported(pb); 1974 result = parport_PS2_supported(pb);
1909 ECR_WRITE (pb, oecr); 1975 ECR_WRITE(pb, oecr);
1910 return result; 1976 return result;
1911} 1977}
1912 1978
@@ -1930,16 +1996,15 @@ static int parport_EPP_supported(struct parport *pb)
1930 */ 1996 */
1931 1997
1932 /* If EPP timeout bit clear then EPP available */ 1998 /* If EPP timeout bit clear then EPP available */
1933 if (!clear_epp_timeout(pb)) { 1999 if (!clear_epp_timeout(pb))
1934 return 0; /* No way to clear timeout */ 2000 return 0; /* No way to clear timeout */
1935 }
1936 2001
1937 /* Check for Intel bug. */ 2002 /* Check for Intel bug. */
1938 if (priv->ecr) { 2003 if (priv->ecr) {
1939 unsigned char i; 2004 unsigned char i;
1940 for (i = 0x00; i < 0x80; i += 0x20) { 2005 for (i = 0x00; i < 0x80; i += 0x20) {
1941 ECR_WRITE (pb, i); 2006 ECR_WRITE(pb, i);
1942 if (clear_epp_timeout (pb)) { 2007 if (clear_epp_timeout(pb)) {
1943 /* Phony EPP in ECP. */ 2008 /* Phony EPP in ECP. */
1944 return 0; 2009 return 0;
1945 } 2010 }
@@ -1963,17 +2028,16 @@ static int parport_ECPEPP_supported(struct parport *pb)
1963 int result; 2028 int result;
1964 unsigned char oecr; 2029 unsigned char oecr;
1965 2030
1966 if (!priv->ecr) { 2031 if (!priv->ecr)
1967 return 0; 2032 return 0;
1968 }
1969 2033
1970 oecr = inb (ECONTROL (pb)); 2034 oecr = inb(ECONTROL(pb));
1971 /* Search for SMC style EPP+ECP mode */ 2035 /* Search for SMC style EPP+ECP mode */
1972 ECR_WRITE (pb, 0x80); 2036 ECR_WRITE(pb, 0x80);
1973 outb (0x04, CONTROL (pb)); 2037 outb(0x04, CONTROL(pb));
1974 result = parport_EPP_supported(pb); 2038 result = parport_EPP_supported(pb);
1975 2039
1976 ECR_WRITE (pb, oecr); 2040 ECR_WRITE(pb, oecr);
1977 2041
1978 if (result) { 2042 if (result) {
1979 /* Set up access functions to use ECP+EPP hardware. */ 2043 /* Set up access functions to use ECP+EPP hardware. */
@@ -1991,11 +2055,25 @@ static int parport_ECPEPP_supported(struct parport *pb)
1991/* Don't bother probing for modes we know we won't use. */ 2055/* Don't bother probing for modes we know we won't use. */
1992static int __devinit parport_PS2_supported(struct parport *pb) { return 0; } 2056static int __devinit parport_PS2_supported(struct parport *pb) { return 0; }
1993#ifdef CONFIG_PARPORT_PC_FIFO 2057#ifdef CONFIG_PARPORT_PC_FIFO
1994static int parport_ECP_supported(struct parport *pb) { return 0; } 2058static int parport_ECP_supported(struct parport *pb)
2059{
2060 return 0;
2061}
1995#endif 2062#endif
1996static int __devinit parport_EPP_supported(struct parport *pb) { return 0; } 2063static int __devinit parport_EPP_supported(struct parport *pb)
1997static int __devinit parport_ECPEPP_supported(struct parport *pb){return 0;} 2064{
1998static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;} 2065 return 0;
2066}
2067
2068static int __devinit parport_ECPEPP_supported(struct parport *pb)
2069{
2070 return 0;
2071}
2072
2073static int __devinit parport_ECPPS2_supported(struct parport *pb)
2074{
2075 return 0;
2076}
1999 2077
2000#endif /* No IEEE 1284 support */ 2078#endif /* No IEEE 1284 support */
2001 2079
@@ -2005,17 +2083,17 @@ static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;}
2005static int programmable_irq_support(struct parport *pb) 2083static int programmable_irq_support(struct parport *pb)
2006{ 2084{
2007 int irq, intrLine; 2085 int irq, intrLine;
2008 unsigned char oecr = inb (ECONTROL (pb)); 2086 unsigned char oecr = inb(ECONTROL(pb));
2009 static const int lookup[8] = { 2087 static const int lookup[8] = {
2010 PARPORT_IRQ_NONE, 7, 9, 10, 11, 14, 15, 5 2088 PARPORT_IRQ_NONE, 7, 9, 10, 11, 14, 15, 5
2011 }; 2089 };
2012 2090
2013 ECR_WRITE (pb, ECR_CNF << 5); /* Configuration MODE */ 2091 ECR_WRITE(pb, ECR_CNF << 5); /* Configuration MODE */
2014 2092
2015 intrLine = (inb (CONFIGB (pb)) >> 3) & 0x07; 2093 intrLine = (inb(CONFIGB(pb)) >> 3) & 0x07;
2016 irq = lookup[intrLine]; 2094 irq = lookup[intrLine];
2017 2095
2018 ECR_WRITE (pb, oecr); 2096 ECR_WRITE(pb, oecr);
2019 return irq; 2097 return irq;
2020} 2098}
2021 2099
@@ -2025,17 +2103,17 @@ static int irq_probe_ECP(struct parport *pb)
2025 unsigned long irqs; 2103 unsigned long irqs;
2026 2104
2027 irqs = probe_irq_on(); 2105 irqs = probe_irq_on();
2028 2106
2029 ECR_WRITE (pb, ECR_SPP << 5); /* Reset FIFO */ 2107 ECR_WRITE(pb, ECR_SPP << 5); /* Reset FIFO */
2030 ECR_WRITE (pb, (ECR_TST << 5) | 0x04); 2108 ECR_WRITE(pb, (ECR_TST << 5) | 0x04);
2031 ECR_WRITE (pb, ECR_TST << 5); 2109 ECR_WRITE(pb, ECR_TST << 5);
2032 2110
2033 /* If Full FIFO sure that writeIntrThreshold is generated */ 2111 /* If Full FIFO sure that writeIntrThreshold is generated */
2034 for (i=0; i < 1024 && !(inb (ECONTROL (pb)) & 0x02) ; i++) 2112 for (i = 0; i < 1024 && !(inb(ECONTROL(pb)) & 0x02) ; i++)
2035 outb (0xaa, FIFO (pb)); 2113 outb(0xaa, FIFO(pb));
2036 2114
2037 pb->irq = probe_irq_off(irqs); 2115 pb->irq = probe_irq_off(irqs);
2038 ECR_WRITE (pb, ECR_SPP << 5); 2116 ECR_WRITE(pb, ECR_SPP << 5);
2039 2117
2040 if (pb->irq <= 0) 2118 if (pb->irq <= 0)
2041 pb->irq = PARPORT_IRQ_NONE; 2119 pb->irq = PARPORT_IRQ_NONE;
@@ -2045,7 +2123,7 @@ static int irq_probe_ECP(struct parport *pb)
2045 2123
2046/* 2124/*
2047 * This detection seems that only works in National Semiconductors 2125 * This detection seems that only works in National Semiconductors
2048 * This doesn't work in SMC, LGS, and Winbond 2126 * This doesn't work in SMC, LGS, and Winbond
2049 */ 2127 */
2050static int irq_probe_EPP(struct parport *pb) 2128static int irq_probe_EPP(struct parport *pb)
2051{ 2129{
@@ -2056,16 +2134,16 @@ static int irq_probe_EPP(struct parport *pb)
2056 unsigned char oecr; 2134 unsigned char oecr;
2057 2135
2058 if (pb->modes & PARPORT_MODE_PCECR) 2136 if (pb->modes & PARPORT_MODE_PCECR)
2059 oecr = inb (ECONTROL (pb)); 2137 oecr = inb(ECONTROL(pb));
2060 2138
2061 irqs = probe_irq_on(); 2139 irqs = probe_irq_on();
2062 2140
2063 if (pb->modes & PARPORT_MODE_PCECR) 2141 if (pb->modes & PARPORT_MODE_PCECR)
2064 frob_econtrol (pb, 0x10, 0x10); 2142 frob_econtrol(pb, 0x10, 0x10);
2065 2143
2066 clear_epp_timeout(pb); 2144 clear_epp_timeout(pb);
2067 parport_pc_frob_control (pb, 0x20, 0x20); 2145 parport_pc_frob_control(pb, 0x20, 0x20);
2068 parport_pc_frob_control (pb, 0x10, 0x10); 2146 parport_pc_frob_control(pb, 0x10, 0x10);
2069 clear_epp_timeout(pb); 2147 clear_epp_timeout(pb);
2070 2148
2071 /* Device isn't expecting an EPP read 2149 /* Device isn't expecting an EPP read
@@ -2074,9 +2152,9 @@ static int irq_probe_EPP(struct parport *pb)
2074 parport_pc_read_epp(pb); 2152 parport_pc_read_epp(pb);
2075 udelay(20); 2153 udelay(20);
2076 2154
2077 pb->irq = probe_irq_off (irqs); 2155 pb->irq = probe_irq_off(irqs);
2078 if (pb->modes & PARPORT_MODE_PCECR) 2156 if (pb->modes & PARPORT_MODE_PCECR)
2079 ECR_WRITE (pb, oecr); 2157 ECR_WRITE(pb, oecr);
2080 parport_pc_write_control(pb, 0xc); 2158 parport_pc_write_control(pb, 0xc);
2081 2159
2082 if (pb->irq <= 0) 2160 if (pb->irq <= 0)
@@ -2133,28 +2211,28 @@ static int parport_irq_probe(struct parport *pb)
2133/* --- DMA detection -------------------------------------- */ 2211/* --- DMA detection -------------------------------------- */
2134 2212
2135/* Only if chipset conforms to ECP ISA Interface Standard */ 2213/* Only if chipset conforms to ECP ISA Interface Standard */
2136static int programmable_dma_support (struct parport *p) 2214static int programmable_dma_support(struct parport *p)
2137{ 2215{
2138 unsigned char oecr = inb (ECONTROL (p)); 2216 unsigned char oecr = inb(ECONTROL(p));
2139 int dma; 2217 int dma;
2140 2218
2141 frob_set_mode (p, ECR_CNF); 2219 frob_set_mode(p, ECR_CNF);
2142 2220
2143 dma = inb (CONFIGB(p)) & 0x07; 2221 dma = inb(CONFIGB(p)) & 0x07;
2144 /* 000: Indicates jumpered 8-bit DMA if read-only. 2222 /* 000: Indicates jumpered 8-bit DMA if read-only.
2145 100: Indicates jumpered 16-bit DMA if read-only. */ 2223 100: Indicates jumpered 16-bit DMA if read-only. */
2146 if ((dma & 0x03) == 0) 2224 if ((dma & 0x03) == 0)
2147 dma = PARPORT_DMA_NONE; 2225 dma = PARPORT_DMA_NONE;
2148 2226
2149 ECR_WRITE (p, oecr); 2227 ECR_WRITE(p, oecr);
2150 return dma; 2228 return dma;
2151} 2229}
2152 2230
2153static int parport_dma_probe (struct parport *p) 2231static int parport_dma_probe(struct parport *p)
2154{ 2232{
2155 const struct parport_pc_private *priv = p->private_data; 2233 const struct parport_pc_private *priv = p->private_data;
2156 if (priv->ecr) 2234 if (priv->ecr) /* ask ECP chipset first */
2157 p->dma = programmable_dma_support(p); /* ask ECP chipset first */ 2235 p->dma = programmable_dma_support(p);
2158 if (p->dma == PARPORT_DMA_NONE) { 2236 if (p->dma == PARPORT_DMA_NONE) {
2159 /* ask known Super-IO chips proper, although these 2237 /* ask known Super-IO chips proper, although these
2160 claim ECP compatible, some don't report their DMA 2238 claim ECP compatible, some don't report their DMA
@@ -2212,7 +2290,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2212 if (!base_res) 2290 if (!base_res)
2213 goto out4; 2291 goto out4;
2214 2292
2215 memcpy(ops, &parport_pc_ops, sizeof (struct parport_operations)); 2293 memcpy(ops, &parport_pc_ops, sizeof(struct parport_operations));
2216 priv->ctr = 0xc; 2294 priv->ctr = 0xc;
2217 priv->ctr_writable = ~0x10; 2295 priv->ctr_writable = ~0x10;
2218 priv->ecr = 0; 2296 priv->ecr = 0;
@@ -2239,7 +2317,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2239 if (!parport_EPP_supported(p)) 2317 if (!parport_EPP_supported(p))
2240 parport_ECPEPP_supported(p); 2318 parport_ECPEPP_supported(p);
2241 } 2319 }
2242 if (!parport_SPP_supported (p)) 2320 if (!parport_SPP_supported(p))
2243 /* No port. */ 2321 /* No port. */
2244 goto out5; 2322 goto out5;
2245 if (priv->ecr) 2323 if (priv->ecr)
@@ -2247,7 +2325,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2247 else 2325 else
2248 parport_PS2_supported(p); 2326 parport_PS2_supported(p);
2249 2327
2250 p->size = (p->modes & PARPORT_MODE_EPP)?8:3; 2328 p->size = (p->modes & PARPORT_MODE_EPP) ? 8 : 3;
2251 2329
2252 printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base); 2330 printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base);
2253 if (p->base_hi && priv->ecr) 2331 if (p->base_hi && priv->ecr)
@@ -2271,7 +2349,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2271 } 2349 }
2272 } 2350 }
2273 if (p->dma == PARPORT_DMA_AUTO) /* To use DMA, giving the irq 2351 if (p->dma == PARPORT_DMA_AUTO) /* To use DMA, giving the irq
2274 is mandatory (see above) */ 2352 is mandatory (see above) */
2275 p->dma = PARPORT_DMA_NONE; 2353 p->dma = PARPORT_DMA_NONE;
2276 2354
2277#ifdef CONFIG_PARPORT_PC_FIFO 2355#ifdef CONFIG_PARPORT_PC_FIFO
@@ -2288,16 +2366,23 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2288 if (p->dma != PARPORT_DMA_NONE) { 2366 if (p->dma != PARPORT_DMA_NONE) {
2289 printk(", dma %d", p->dma); 2367 printk(", dma %d", p->dma);
2290 p->modes |= PARPORT_MODE_DMA; 2368 p->modes |= PARPORT_MODE_DMA;
2291 } 2369 } else
2292 else printk(", using FIFO"); 2370 printk(", using FIFO");
2293 } 2371 } else
2294 else
2295 /* We can't use the DMA channel after all. */ 2372 /* We can't use the DMA channel after all. */
2296 p->dma = PARPORT_DMA_NONE; 2373 p->dma = PARPORT_DMA_NONE;
2297#endif /* Allowed to use FIFO/DMA */ 2374#endif /* Allowed to use FIFO/DMA */
2298 2375
2299 printk(" ["); 2376 printk(" [");
2300#define printmode(x) {if(p->modes&PARPORT_MODE_##x){printk("%s%s",f?",":"",#x);f++;}} 2377
2378#define printmode(x) \
2379 {\
2380 if (p->modes & PARPORT_MODE_##x) {\
2381 printk("%s%s", f ? "," : "", #x);\
2382 f++;\
2383 } \
2384 }
2385
2301 { 2386 {
2302 int f = 0; 2387 int f = 0;
2303 printmode(PCSPP); 2388 printmode(PCSPP);
@@ -2309,10 +2394,10 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2309 } 2394 }
2310#undef printmode 2395#undef printmode
2311#ifndef CONFIG_PARPORT_1284 2396#ifndef CONFIG_PARPORT_1284
2312 printk ("(,...)"); 2397 printk("(,...)");
2313#endif /* CONFIG_PARPORT_1284 */ 2398#endif /* CONFIG_PARPORT_1284 */
2314 printk("]\n"); 2399 printk("]\n");
2315 if (probedirq != PARPORT_IRQ_NONE) 2400 if (probedirq != PARPORT_IRQ_NONE)
2316 printk(KERN_INFO "%s: irq %d detected\n", p->name, probedirq); 2401 printk(KERN_INFO "%s: irq %d detected\n", p->name, probedirq);
2317 2402
2318 /* If No ECP release the ports grabbed above. */ 2403 /* If No ECP release the ports grabbed above. */
@@ -2328,7 +2413,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2328 if (p->irq != PARPORT_IRQ_NONE) { 2413 if (p->irq != PARPORT_IRQ_NONE) {
2329 if (request_irq(p->irq, parport_irq_handler, 2414 if (request_irq(p->irq, parport_irq_handler,
2330 irqflags, p->name, p)) { 2415 irqflags, p->name, p)) {
2331 printk (KERN_WARNING "%s: irq %d in use, " 2416 printk(KERN_WARNING "%s: irq %d in use, "
2332 "resorting to polled operation\n", 2417 "resorting to polled operation\n",
2333 p->name, p->irq); 2418 p->name, p->irq);
2334 p->irq = PARPORT_IRQ_NONE; 2419 p->irq = PARPORT_IRQ_NONE;
@@ -2338,8 +2423,8 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2338#ifdef CONFIG_PARPORT_PC_FIFO 2423#ifdef CONFIG_PARPORT_PC_FIFO
2339#ifdef HAS_DMA 2424#ifdef HAS_DMA
2340 if (p->dma != PARPORT_DMA_NONE) { 2425 if (p->dma != PARPORT_DMA_NONE) {
2341 if (request_dma (p->dma, p->name)) { 2426 if (request_dma(p->dma, p->name)) {
2342 printk (KERN_WARNING "%s: dma %d in use, " 2427 printk(KERN_WARNING "%s: dma %d in use, "
2343 "resorting to PIO operation\n", 2428 "resorting to PIO operation\n",
2344 p->name, p->dma); 2429 p->name, p->dma);
2345 p->dma = PARPORT_DMA_NONE; 2430 p->dma = PARPORT_DMA_NONE;
@@ -2349,8 +2434,8 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2349 PAGE_SIZE, 2434 PAGE_SIZE,
2350 &priv->dma_handle, 2435 &priv->dma_handle,
2351 GFP_KERNEL); 2436 GFP_KERNEL);
2352 if (! priv->dma_buf) { 2437 if (!priv->dma_buf) {
2353 printk (KERN_WARNING "%s: " 2438 printk(KERN_WARNING "%s: "
2354 "cannot get buffer for DMA, " 2439 "cannot get buffer for DMA, "
2355 "resorting to PIO operation\n", 2440 "resorting to PIO operation\n",
2356 p->name); 2441 p->name);
@@ -2369,10 +2454,10 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2369 * Put the ECP detected port in PS2 mode. 2454 * Put the ECP detected port in PS2 mode.
2370 * Do this also for ports that have ECR but don't do ECP. 2455 * Do this also for ports that have ECR but don't do ECP.
2371 */ 2456 */
2372 ECR_WRITE (p, 0x34); 2457 ECR_WRITE(p, 0x34);
2373 2458
2374 parport_pc_write_data(p, 0); 2459 parport_pc_write_data(p, 0);
2375 parport_pc_data_forward (p); 2460 parport_pc_data_forward(p);
2376 2461
2377 /* Now that we've told the sharing engine about the port, and 2462 /* Now that we've told the sharing engine about the port, and
2378 found out its characteristics, let the high-level drivers 2463 found out its characteristics, let the high-level drivers
@@ -2380,7 +2465,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
2380 spin_lock(&ports_lock); 2465 spin_lock(&ports_lock);
2381 list_add(&priv->list, &ports_list); 2466 list_add(&priv->list, &ports_list);
2382 spin_unlock(&ports_lock); 2467 spin_unlock(&ports_lock);
2383 parport_announce_port (p); 2468 parport_announce_port(p);
2384 2469
2385 return p; 2470 return p;
2386 2471
@@ -2393,18 +2478,17 @@ out5:
2393out4: 2478out4:
2394 parport_put_port(p); 2479 parport_put_port(p);
2395out3: 2480out3:
2396 kfree (priv); 2481 kfree(priv);
2397out2: 2482out2:
2398 kfree (ops); 2483 kfree(ops);
2399out1: 2484out1:
2400 if (pdev) 2485 if (pdev)
2401 platform_device_unregister(pdev); 2486 platform_device_unregister(pdev);
2402 return NULL; 2487 return NULL;
2403} 2488}
2489EXPORT_SYMBOL(parport_pc_probe_port);
2404 2490
2405EXPORT_SYMBOL (parport_pc_probe_port); 2491void parport_pc_unregister_port(struct parport *p)
2406
2407void parport_pc_unregister_port (struct parport *p)
2408{ 2492{
2409 struct parport_pc_private *priv = p->private_data; 2493 struct parport_pc_private *priv = p->private_data;
2410 struct parport_operations *ops = p->ops; 2494 struct parport_operations *ops = p->ops;
@@ -2430,17 +2514,16 @@ void parport_pc_unregister_port (struct parport *p)
2430 priv->dma_buf, 2514 priv->dma_buf,
2431 priv->dma_handle); 2515 priv->dma_handle);
2432#endif 2516#endif
2433 kfree (p->private_data); 2517 kfree(p->private_data);
2434 parport_put_port(p); 2518 parport_put_port(p);
2435 kfree (ops); /* hope no-one cached it */ 2519 kfree(ops); /* hope no-one cached it */
2436} 2520}
2437 2521EXPORT_SYMBOL(parport_pc_unregister_port);
2438EXPORT_SYMBOL (parport_pc_unregister_port);
2439 2522
2440#ifdef CONFIG_PCI 2523#ifdef CONFIG_PCI
2441 2524
2442/* ITE support maintained by Rich Liu <richliu@poorman.org> */ 2525/* ITE support maintained by Rich Liu <richliu@poorman.org> */
2443static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq, 2526static int __devinit sio_ite_8872_probe(struct pci_dev *pdev, int autoirq,
2444 int autodma, 2527 int autodma,
2445 const struct parport_pc_via_data *via) 2528 const struct parport_pc_via_data *via)
2446{ 2529{
@@ -2452,73 +2535,74 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
2452 int irq; 2535 int irq;
2453 int i; 2536 int i;
2454 2537
2455 DPRINTK (KERN_DEBUG "sio_ite_8872_probe()\n"); 2538 DPRINTK(KERN_DEBUG "sio_ite_8872_probe()\n");
2456 2539
2457 // make sure which one chip 2540 /* make sure which one chip */
2458 for(i = 0; i < 5; i++) { 2541 for (i = 0; i < 5; i++) {
2459 base_res = request_region(inta_addr[i], 32, "it887x"); 2542 base_res = request_region(inta_addr[i], 32, "it887x");
2460 if (base_res) { 2543 if (base_res) {
2461 int test; 2544 int test;
2462 pci_write_config_dword (pdev, 0x60, 2545 pci_write_config_dword(pdev, 0x60,
2463 0xe5000000 | inta_addr[i]); 2546 0xe5000000 | inta_addr[i]);
2464 pci_write_config_dword (pdev, 0x78, 2547 pci_write_config_dword(pdev, 0x78,
2465 0x00000000 | inta_addr[i]); 2548 0x00000000 | inta_addr[i]);
2466 test = inb (inta_addr[i]); 2549 test = inb(inta_addr[i]);
2467 if (test != 0xff) break; 2550 if (test != 0xff)
2551 break;
2468 release_region(inta_addr[i], 0x8); 2552 release_region(inta_addr[i], 0x8);
2469 } 2553 }
2470 } 2554 }
2471 if(i >= 5) { 2555 if (i >= 5) {
2472 printk (KERN_INFO "parport_pc: cannot find ITE8872 INTA\n"); 2556 printk(KERN_INFO "parport_pc: cannot find ITE8872 INTA\n");
2473 return 0; 2557 return 0;
2474 } 2558 }
2475 2559
2476 type = inb (inta_addr[i] + 0x18); 2560 type = inb(inta_addr[i] + 0x18);
2477 type &= 0x0f; 2561 type &= 0x0f;
2478 2562
2479 switch (type) { 2563 switch (type) {
2480 case 0x2: 2564 case 0x2:
2481 printk (KERN_INFO "parport_pc: ITE8871 found (1P)\n"); 2565 printk(KERN_INFO "parport_pc: ITE8871 found (1P)\n");
2482 ite8872set = 0x64200000; 2566 ite8872set = 0x64200000;
2483 break; 2567 break;
2484 case 0xa: 2568 case 0xa:
2485 printk (KERN_INFO "parport_pc: ITE8875 found (1P)\n"); 2569 printk(KERN_INFO "parport_pc: ITE8875 found (1P)\n");
2486 ite8872set = 0x64200000; 2570 ite8872set = 0x64200000;
2487 break; 2571 break;
2488 case 0xe: 2572 case 0xe:
2489 printk (KERN_INFO "parport_pc: ITE8872 found (2S1P)\n"); 2573 printk(KERN_INFO "parport_pc: ITE8872 found (2S1P)\n");
2490 ite8872set = 0x64e00000; 2574 ite8872set = 0x64e00000;
2491 break; 2575 break;
2492 case 0x6: 2576 case 0x6:
2493 printk (KERN_INFO "parport_pc: ITE8873 found (1S)\n"); 2577 printk(KERN_INFO "parport_pc: ITE8873 found (1S)\n");
2494 return 0; 2578 return 0;
2495 case 0x8: 2579 case 0x8:
2496 DPRINTK (KERN_DEBUG "parport_pc: ITE8874 found (2S)\n"); 2580 DPRINTK(KERN_DEBUG "parport_pc: ITE8874 found (2S)\n");
2497 return 0; 2581 return 0;
2498 default: 2582 default:
2499 printk (KERN_INFO "parport_pc: unknown ITE887x\n"); 2583 printk(KERN_INFO "parport_pc: unknown ITE887x\n");
2500 printk (KERN_INFO "parport_pc: please mail 'lspci -nvv' " 2584 printk(KERN_INFO "parport_pc: please mail 'lspci -nvv' "
2501 "output to Rich.Liu@ite.com.tw\n"); 2585 "output to Rich.Liu@ite.com.tw\n");
2502 return 0; 2586 return 0;
2503 } 2587 }
2504 2588
2505 pci_read_config_byte (pdev, 0x3c, &ite8872_irq); 2589 pci_read_config_byte(pdev, 0x3c, &ite8872_irq);
2506 pci_read_config_dword (pdev, 0x1c, &ite8872_lpt); 2590 pci_read_config_dword(pdev, 0x1c, &ite8872_lpt);
2507 ite8872_lpt &= 0x0000ff00; 2591 ite8872_lpt &= 0x0000ff00;
2508 pci_read_config_dword (pdev, 0x20, &ite8872_lpthi); 2592 pci_read_config_dword(pdev, 0x20, &ite8872_lpthi);
2509 ite8872_lpthi &= 0x0000ff00; 2593 ite8872_lpthi &= 0x0000ff00;
2510 pci_write_config_dword (pdev, 0x6c, 0xe3000000 | ite8872_lpt); 2594 pci_write_config_dword(pdev, 0x6c, 0xe3000000 | ite8872_lpt);
2511 pci_write_config_dword (pdev, 0x70, 0xe3000000 | ite8872_lpthi); 2595 pci_write_config_dword(pdev, 0x70, 0xe3000000 | ite8872_lpthi);
2512 pci_write_config_dword (pdev, 0x80, (ite8872_lpthi<<16) | ite8872_lpt); 2596 pci_write_config_dword(pdev, 0x80, (ite8872_lpthi<<16) | ite8872_lpt);
2513 // SET SPP&EPP , Parallel Port NO DMA , Enable All Function 2597 /* SET SPP&EPP , Parallel Port NO DMA , Enable All Function */
2514 // SET Parallel IRQ 2598 /* SET Parallel IRQ */
2515 pci_write_config_dword (pdev, 0x9c, 2599 pci_write_config_dword(pdev, 0x9c,
2516 ite8872set | (ite8872_irq * 0x11111)); 2600 ite8872set | (ite8872_irq * 0x11111));
2517 2601
2518 DPRINTK (KERN_DEBUG "ITE887x: The IRQ is %d.\n", ite8872_irq); 2602 DPRINTK(KERN_DEBUG "ITE887x: The IRQ is %d.\n", ite8872_irq);
2519 DPRINTK (KERN_DEBUG "ITE887x: The PARALLEL I/O port is 0x%x.\n", 2603 DPRINTK(KERN_DEBUG "ITE887x: The PARALLEL I/O port is 0x%x.\n",
2520 ite8872_lpt); 2604 ite8872_lpt);
2521 DPRINTK (KERN_DEBUG "ITE887x: The PARALLEL I/O porthi is 0x%x.\n", 2605 DPRINTK(KERN_DEBUG "ITE887x: The PARALLEL I/O porthi is 0x%x.\n",
2522 ite8872_lpthi); 2606 ite8872_lpthi);
2523 2607
2524 /* Let the user (or defaults) steer us away from interrupts */ 2608 /* Let the user (or defaults) steer us away from interrupts */
@@ -2530,14 +2614,14 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
2530 * Release the resource so that parport_pc_probe_port can get it. 2614 * Release the resource so that parport_pc_probe_port can get it.
2531 */ 2615 */
2532 release_resource(base_res); 2616 release_resource(base_res);
2533 if (parport_pc_probe_port (ite8872_lpt, ite8872_lpthi, 2617 if (parport_pc_probe_port(ite8872_lpt, ite8872_lpthi,
2534 irq, PARPORT_DMA_NONE, &pdev->dev, 0)) { 2618 irq, PARPORT_DMA_NONE, &pdev->dev, 0)) {
2535 printk (KERN_INFO 2619 printk(KERN_INFO
2536 "parport_pc: ITE 8872 parallel port: io=0x%X", 2620 "parport_pc: ITE 8872 parallel port: io=0x%X",
2537 ite8872_lpt); 2621 ite8872_lpt);
2538 if (irq != PARPORT_IRQ_NONE) 2622 if (irq != PARPORT_IRQ_NONE)
2539 printk (", irq=%d", irq); 2623 printk(", irq=%d", irq);
2540 printk ("\n"); 2624 printk("\n");
2541 return 1; 2625 return 1;
2542 } 2626 }
2543 2627
@@ -2546,7 +2630,7 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
2546 2630
2547/* VIA 8231 support by Pavel Fedin <sonic_amiga@rambler.ru> 2631/* VIA 8231 support by Pavel Fedin <sonic_amiga@rambler.ru>
2548 based on VIA 686a support code by Jeff Garzik <jgarzik@pobox.com> */ 2632 based on VIA 686a support code by Jeff Garzik <jgarzik@pobox.com> */
2549static int __devinitdata parport_init_mode = 0; 2633static int __devinitdata parport_init_mode;
2550 2634
2551/* Data for two known VIA chips */ 2635/* Data for two known VIA chips */
2552static struct parport_pc_via_data via_686a_data __devinitdata = { 2636static struct parport_pc_via_data via_686a_data __devinitdata = {
@@ -2568,7 +2652,7 @@ static struct parport_pc_via_data via_8231_data __devinitdata = {
2568 0xF6 2652 0xF6
2569}; 2653};
2570 2654
2571static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, 2655static int __devinit sio_via_probe(struct pci_dev *pdev, int autoirq,
2572 int autodma, 2656 int autodma,
2573 const struct parport_pc_via_data *via) 2657 const struct parport_pc_via_data *via)
2574{ 2658{
@@ -2580,38 +2664,38 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
2580 2664
2581 printk(KERN_DEBUG "parport_pc: VIA 686A/8231 detected\n"); 2665 printk(KERN_DEBUG "parport_pc: VIA 686A/8231 detected\n");
2582 2666
2583 switch(parport_init_mode) 2667 switch (parport_init_mode) {
2584 {
2585 case 1: 2668 case 1:
2586 printk(KERN_DEBUG "parport_pc: setting SPP mode\n"); 2669 printk(KERN_DEBUG "parport_pc: setting SPP mode\n");
2587 siofunc = VIA_FUNCTION_PARPORT_SPP; 2670 siofunc = VIA_FUNCTION_PARPORT_SPP;
2588 break; 2671 break;
2589 case 2: 2672 case 2:
2590 printk(KERN_DEBUG "parport_pc: setting PS/2 mode\n"); 2673 printk(KERN_DEBUG "parport_pc: setting PS/2 mode\n");
2591 siofunc = VIA_FUNCTION_PARPORT_SPP; 2674 siofunc = VIA_FUNCTION_PARPORT_SPP;
2592 ppcontrol = VIA_PARPORT_BIDIR; 2675 ppcontrol = VIA_PARPORT_BIDIR;
2593 break; 2676 break;
2594 case 3: 2677 case 3:
2595 printk(KERN_DEBUG "parport_pc: setting EPP mode\n"); 2678 printk(KERN_DEBUG "parport_pc: setting EPP mode\n");
2596 siofunc = VIA_FUNCTION_PARPORT_EPP; 2679 siofunc = VIA_FUNCTION_PARPORT_EPP;
2597 ppcontrol = VIA_PARPORT_BIDIR; 2680 ppcontrol = VIA_PARPORT_BIDIR;
2598 have_epp = 1; 2681 have_epp = 1;
2599 break; 2682 break;
2600 case 4: 2683 case 4:
2601 printk(KERN_DEBUG "parport_pc: setting ECP mode\n"); 2684 printk(KERN_DEBUG "parport_pc: setting ECP mode\n");
2602 siofunc = VIA_FUNCTION_PARPORT_ECP; 2685 siofunc = VIA_FUNCTION_PARPORT_ECP;
2603 ppcontrol = VIA_PARPORT_BIDIR; 2686 ppcontrol = VIA_PARPORT_BIDIR;
2604 break; 2687 break;
2605 case 5: 2688 case 5:
2606 printk(KERN_DEBUG "parport_pc: setting EPP+ECP mode\n"); 2689 printk(KERN_DEBUG "parport_pc: setting EPP+ECP mode\n");
2607 siofunc = VIA_FUNCTION_PARPORT_ECP; 2690 siofunc = VIA_FUNCTION_PARPORT_ECP;
2608 ppcontrol = VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP; 2691 ppcontrol = VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP;
2609 have_epp = 1; 2692 have_epp = 1;
2610 break; 2693 break;
2611 default: 2694 default:
2612 printk(KERN_DEBUG "parport_pc: probing current configuration\n"); 2695 printk(KERN_DEBUG
2613 siofunc = VIA_FUNCTION_PROBE; 2696 "parport_pc: probing current configuration\n");
2614 break; 2697 siofunc = VIA_FUNCTION_PROBE;
2698 break;
2615 } 2699 }
2616 /* 2700 /*
2617 * unlock super i/o configuration 2701 * unlock super i/o configuration
@@ -2622,38 +2706,36 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
2622 2706
2623 /* Bits 1-0: Parallel Port Mode / Enable */ 2707 /* Bits 1-0: Parallel Port Mode / Enable */
2624 outb(via->viacfg_function, VIA_CONFIG_INDEX); 2708 outb(via->viacfg_function, VIA_CONFIG_INDEX);
2625 tmp = inb (VIA_CONFIG_DATA); 2709 tmp = inb(VIA_CONFIG_DATA);
2626 /* Bit 5: EPP+ECP enable; bit 7: PS/2 bidirectional port enable */ 2710 /* Bit 5: EPP+ECP enable; bit 7: PS/2 bidirectional port enable */
2627 outb(via->viacfg_parport_control, VIA_CONFIG_INDEX); 2711 outb(via->viacfg_parport_control, VIA_CONFIG_INDEX);
2628 tmp2 = inb (VIA_CONFIG_DATA); 2712 tmp2 = inb(VIA_CONFIG_DATA);
2629 if (siofunc == VIA_FUNCTION_PROBE) 2713 if (siofunc == VIA_FUNCTION_PROBE) {
2630 { 2714 siofunc = tmp & VIA_FUNCTION_PARPORT_DISABLE;
2631 siofunc = tmp & VIA_FUNCTION_PARPORT_DISABLE; 2715 ppcontrol = tmp2;
2632 ppcontrol = tmp2; 2716 } else {
2717 tmp &= ~VIA_FUNCTION_PARPORT_DISABLE;
2718 tmp |= siofunc;
2719 outb(via->viacfg_function, VIA_CONFIG_INDEX);
2720 outb(tmp, VIA_CONFIG_DATA);
2721 tmp2 &= ~(VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP);
2722 tmp2 |= ppcontrol;
2723 outb(via->viacfg_parport_control, VIA_CONFIG_INDEX);
2724 outb(tmp2, VIA_CONFIG_DATA);
2633 } 2725 }
2634 else 2726
2635 {
2636 tmp &= ~VIA_FUNCTION_PARPORT_DISABLE;
2637 tmp |= siofunc;
2638 outb(via->viacfg_function, VIA_CONFIG_INDEX);
2639 outb(tmp, VIA_CONFIG_DATA);
2640 tmp2 &= ~(VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP);
2641 tmp2 |= ppcontrol;
2642 outb(via->viacfg_parport_control, VIA_CONFIG_INDEX);
2643 outb(tmp2, VIA_CONFIG_DATA);
2644 }
2645
2646 /* Parallel Port I/O Base Address, bits 9-2 */ 2727 /* Parallel Port I/O Base Address, bits 9-2 */
2647 outb(via->viacfg_parport_base, VIA_CONFIG_INDEX); 2728 outb(via->viacfg_parport_base, VIA_CONFIG_INDEX);
2648 port1 = inb(VIA_CONFIG_DATA) << 2; 2729 port1 = inb(VIA_CONFIG_DATA) << 2;
2649 2730
2650 printk (KERN_DEBUG "parport_pc: Current parallel port base: 0x%X\n",port1); 2731 printk(KERN_DEBUG "parport_pc: Current parallel port base: 0x%X\n",
2651 if ((port1 == 0x3BC) && have_epp) 2732 port1);
2652 { 2733 if (port1 == 0x3BC && have_epp) {
2653 outb(via->viacfg_parport_base, VIA_CONFIG_INDEX); 2734 outb(via->viacfg_parport_base, VIA_CONFIG_INDEX);
2654 outb((0x378 >> 2), VIA_CONFIG_DATA); 2735 outb((0x378 >> 2), VIA_CONFIG_DATA);
2655 printk(KERN_DEBUG "parport_pc: Parallel port base changed to 0x378\n"); 2736 printk(KERN_DEBUG
2656 port1 = 0x378; 2737 "parport_pc: Parallel port base changed to 0x378\n");
2738 port1 = 0x378;
2657 } 2739 }
2658 2740
2659 /* 2741 /*
@@ -2667,36 +2749,39 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
2667 printk(KERN_INFO "parport_pc: VIA parallel port disabled in BIOS\n"); 2749 printk(KERN_INFO "parport_pc: VIA parallel port disabled in BIOS\n");
2668 return 0; 2750 return 0;
2669 } 2751 }
2670 2752
2671 /* Bits 7-4: PnP Routing for Parallel Port IRQ */ 2753 /* Bits 7-4: PnP Routing for Parallel Port IRQ */
2672 pci_read_config_byte(pdev, via->via_pci_parport_irq_reg, &tmp); 2754 pci_read_config_byte(pdev, via->via_pci_parport_irq_reg, &tmp);
2673 irq = ((tmp & VIA_IRQCONTROL_PARALLEL) >> 4); 2755 irq = ((tmp & VIA_IRQCONTROL_PARALLEL) >> 4);
2674 2756
2675 if (siofunc == VIA_FUNCTION_PARPORT_ECP) 2757 if (siofunc == VIA_FUNCTION_PARPORT_ECP) {
2676 { 2758 /* Bits 3-2: PnP Routing for Parallel Port DMA */
2677 /* Bits 3-2: PnP Routing for Parallel Port DMA */ 2759 pci_read_config_byte(pdev, via->via_pci_parport_dma_reg, &tmp);
2678 pci_read_config_byte(pdev, via->via_pci_parport_dma_reg, &tmp); 2760 dma = ((tmp & VIA_DMACONTROL_PARALLEL) >> 2);
2679 dma = ((tmp & VIA_DMACONTROL_PARALLEL) >> 2); 2761 } else
2680 } 2762 /* if ECP not enabled, DMA is not enabled, assumed
2681 else 2763 bogus 'dma' value */
2682 /* if ECP not enabled, DMA is not enabled, assumed bogus 'dma' value */ 2764 dma = PARPORT_DMA_NONE;
2683 dma = PARPORT_DMA_NONE;
2684 2765
2685 /* Let the user (or defaults) steer us away from interrupts and DMA */ 2766 /* Let the user (or defaults) steer us away from interrupts and DMA */
2686 if (autoirq == PARPORT_IRQ_NONE) { 2767 if (autoirq == PARPORT_IRQ_NONE) {
2687 irq = PARPORT_IRQ_NONE; 2768 irq = PARPORT_IRQ_NONE;
2688 dma = PARPORT_DMA_NONE; 2769 dma = PARPORT_DMA_NONE;
2689 } 2770 }
2690 if (autodma == PARPORT_DMA_NONE) 2771 if (autodma == PARPORT_DMA_NONE)
2691 dma = PARPORT_DMA_NONE; 2772 dma = PARPORT_DMA_NONE;
2692 2773
2693 switch (port1) { 2774 switch (port1) {
2694 case 0x3bc: port2 = 0x7bc; break; 2775 case 0x3bc:
2695 case 0x378: port2 = 0x778; break; 2776 port2 = 0x7bc; break;
2696 case 0x278: port2 = 0x678; break; 2777 case 0x378:
2778 port2 = 0x778; break;
2779 case 0x278:
2780 port2 = 0x678; break;
2697 default: 2781 default:
2698 printk(KERN_INFO "parport_pc: Weird VIA parport base 0x%X, ignoring\n", 2782 printk(KERN_INFO
2699 port1); 2783 "parport_pc: Weird VIA parport base 0x%X, ignoring\n",
2784 port1);
2700 return 0; 2785 return 0;
2701 } 2786 }
2702 2787
@@ -2714,17 +2799,17 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
2714 } 2799 }
2715 2800
2716 /* finally, do the probe with values obtained */ 2801 /* finally, do the probe with values obtained */
2717 if (parport_pc_probe_port (port1, port2, irq, dma, &pdev->dev, 0)) { 2802 if (parport_pc_probe_port(port1, port2, irq, dma, &pdev->dev, 0)) {
2718 printk (KERN_INFO 2803 printk(KERN_INFO
2719 "parport_pc: VIA parallel port: io=0x%X", port1); 2804 "parport_pc: VIA parallel port: io=0x%X", port1);
2720 if (irq != PARPORT_IRQ_NONE) 2805 if (irq != PARPORT_IRQ_NONE)
2721 printk (", irq=%d", irq); 2806 printk(", irq=%d", irq);
2722 if (dma != PARPORT_DMA_NONE) 2807 if (dma != PARPORT_DMA_NONE)
2723 printk (", dma=%d", dma); 2808 printk(", dma=%d", dma);
2724 printk ("\n"); 2809 printk("\n");
2725 return 1; 2810 return 1;
2726 } 2811 }
2727 2812
2728 printk(KERN_WARNING "parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n", 2813 printk(KERN_WARNING "parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n",
2729 port1, irq, dma); 2814 port1, irq, dma);
2730 return 0; 2815 return 0;
@@ -2732,8 +2817,8 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
2732 2817
2733 2818
2734enum parport_pc_sio_types { 2819enum parport_pc_sio_types {
2735 sio_via_686a = 0, /* Via VT82C686A motherboard Super I/O */ 2820 sio_via_686a = 0, /* Via VT82C686A motherboard Super I/O */
2736 sio_via_8231, /* Via VT8231 south bridge integrated Super IO */ 2821 sio_via_8231, /* Via VT8231 south bridge integrated Super IO */
2737 sio_ite_8872, 2822 sio_ite_8872,
2738 last_sio 2823 last_sio
2739}; 2824};
@@ -2804,15 +2889,15 @@ enum parport_pc_pci_cards {
2804}; 2889};
2805 2890
2806 2891
2807/* each element directly indexed from enum list, above 2892/* each element directly indexed from enum list, above
2808 * (but offset by last_sio) */ 2893 * (but offset by last_sio) */
2809static struct parport_pc_pci { 2894static struct parport_pc_pci {
2810 int numports; 2895 int numports;
2811 struct { /* BAR (base address registers) numbers in the config 2896 struct { /* BAR (base address registers) numbers in the config
2812 space header */ 2897 space header */
2813 int lo; 2898 int lo;
2814 int hi; /* -1 if not there, >6 for offset-method (max 2899 int hi;
2815 BAR is 6) */ 2900 /* -1 if not there, >6 for offset-method (max BAR is 6) */
2816 } addr[4]; 2901 } addr[4];
2817 2902
2818 /* If set, this is called immediately after pci_enable_device. 2903 /* If set, this is called immediately after pci_enable_device.
@@ -2857,7 +2942,7 @@ static struct parport_pc_pci {
2857 /* timedia_4018 */ { 2, { { 0, 1 }, { 2, 3 }, } }, 2942 /* timedia_4018 */ { 2, { { 0, 1 }, { 2, 3 }, } },
2858 /* timedia_9018a */ { 2, { { 0, 1 }, { 2, 3 }, } }, 2943 /* timedia_9018a */ { 2, { { 0, 1 }, { 2, 3 }, } },
2859 /* SYBA uses fixed offsets in 2944 /* SYBA uses fixed offsets in
2860 a 1K io window */ 2945 a 1K io window */
2861 /* syba_2p_epp AP138B */ { 2, { { 0, 0x078 }, { 0, 0x178 }, } }, 2946 /* syba_2p_epp AP138B */ { 2, { { 0, 0x078 }, { 0, 0x178 }, } },
2862 /* syba_1p_ecp W83787 */ { 1, { { 0, 0x078 }, } }, 2947 /* syba_1p_ecp W83787 */ { 1, { { 0, 0x078 }, } },
2863 /* titan_010l */ { 1, { { 3, -1 }, } }, 2948 /* titan_010l */ { 1, { { 3, -1 }, } },
@@ -2873,11 +2958,14 @@ static struct parport_pc_pci {
2873 /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, } }, 2958 /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, } },
2874 /* aks_0100 */ { 1, { { 0, -1 }, } }, 2959 /* aks_0100 */ { 1, { { 0, -1 }, } },
2875 /* mobility_pp */ { 1, { { 0, 1 }, } }, 2960 /* mobility_pp */ { 1, { { 0, 1 }, } },
2876 /* netmos_9705 */ { 1, { { 0, -1 }, } }, /* untested */ 2961
2877 /* netmos_9715 */ { 2, { { 0, 1 }, { 2, 3 },} }, /* untested */ 2962 /* The netmos entries below are untested */
2878 /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} }, /* untested */ 2963 /* netmos_9705 */ { 1, { { 0, -1 }, } },
2879 /* netmos_9805 */ { 1, { { 0, -1 }, } }, /* untested */ 2964 /* netmos_9715 */ { 2, { { 0, 1 }, { 2, 3 },} },
2880 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */ 2965 /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} },
2966 /* netmos_9805 */ { 1, { { 0, -1 }, } },
2967 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } },
2968
2881 /* quatech_sppxp100 */ { 1, { { 0, 1 }, } }, 2969 /* quatech_sppxp100 */ { 1, { { 0, 1 }, } },
2882}; 2970};
2883 2971
@@ -2906,7 +2994,7 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2906 { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_BOCA_IOPPAR, 2994 { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_BOCA_IOPPAR,
2907 PCI_ANY_ID, PCI_ANY_ID, 0, 0, boca_ioppar }, 2995 PCI_ANY_ID, PCI_ANY_ID, 0, 0, boca_ioppar },
2908 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, 2996 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
2909 PCI_SUBVENDOR_ID_EXSYS, PCI_SUBDEVICE_ID_EXSYS_4014, 0,0, plx_9050 }, 2997 PCI_SUBVENDOR_ID_EXSYS, PCI_SUBDEVICE_ID_EXSYS_4014, 0, 0, plx_9050 },
2910 /* PCI_VENDOR_ID_TIMEDIA/SUNIX has many differing cards ...*/ 2998 /* PCI_VENDOR_ID_TIMEDIA/SUNIX has many differing cards ...*/
2911 { 0x1409, 0x7168, 0x1409, 0x4078, 0, 0, timedia_4078a }, 2999 { 0x1409, 0x7168, 0x1409, 0x4078, 0, 0, timedia_4078a },
2912 { 0x1409, 0x7168, 0x1409, 0x4079, 0, 0, timedia_4079h }, 3000 { 0x1409, 0x7168, 0x1409, 0x4079, 0, 0, timedia_4079h },
@@ -2940,7 +3028,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2940 { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 }, 3028 { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 },
2941 { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 }, 3029 { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 },
2942 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ 3030 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
2943 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */ 3031 /* AFAVLAB_TK9902 */
3032 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p},
2944 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p}, 3033 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p},
2945 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP, 3034 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP,
2946 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 }, 3035 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 },
@@ -2983,14 +3072,14 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2983 PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 }, 3072 PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 },
2984 { 0, } /* terminate list */ 3073 { 0, } /* terminate list */
2985}; 3074};
2986MODULE_DEVICE_TABLE(pci,parport_pc_pci_tbl); 3075MODULE_DEVICE_TABLE(pci, parport_pc_pci_tbl);
2987 3076
2988struct pci_parport_data { 3077struct pci_parport_data {
2989 int num; 3078 int num;
2990 struct parport *ports[2]; 3079 struct parport *ports[2];
2991}; 3080};
2992 3081
2993static int parport_pc_pci_probe (struct pci_dev *dev, 3082static int parport_pc_pci_probe(struct pci_dev *dev,
2994 const struct pci_device_id *id) 3083 const struct pci_device_id *id)
2995{ 3084{
2996 int err, count, n, i = id->driver_data; 3085 int err, count, n, i = id->driver_data;
@@ -3003,7 +3092,8 @@ static int parport_pc_pci_probe (struct pci_dev *dev,
3003 /* This is a PCI card */ 3092 /* This is a PCI card */
3004 i -= last_sio; 3093 i -= last_sio;
3005 count = 0; 3094 count = 0;
3006 if ((err = pci_enable_device (dev)) != 0) 3095 err = pci_enable_device(dev);
3096 if (err)
3007 return err; 3097 return err;
3008 3098
3009 data = kmalloc(sizeof(struct pci_parport_data), GFP_KERNEL); 3099 data = kmalloc(sizeof(struct pci_parport_data), GFP_KERNEL);
@@ -3011,7 +3101,7 @@ static int parport_pc_pci_probe (struct pci_dev *dev,
3011 return -ENOMEM; 3101 return -ENOMEM;
3012 3102
3013 if (cards[i].preinit_hook && 3103 if (cards[i].preinit_hook &&
3014 cards[i].preinit_hook (dev, PARPORT_IRQ_NONE, PARPORT_DMA_NONE)) { 3104 cards[i].preinit_hook(dev, PARPORT_IRQ_NONE, PARPORT_DMA_NONE)) {
3015 kfree(data); 3105 kfree(data);
3016 return -ENODEV; 3106 return -ENODEV;
3017 } 3107 }
@@ -3021,25 +3111,25 @@ static int parport_pc_pci_probe (struct pci_dev *dev,
3021 int hi = cards[i].addr[n].hi; 3111 int hi = cards[i].addr[n].hi;
3022 int irq; 3112 int irq;
3023 unsigned long io_lo, io_hi; 3113 unsigned long io_lo, io_hi;
3024 io_lo = pci_resource_start (dev, lo); 3114 io_lo = pci_resource_start(dev, lo);
3025 io_hi = 0; 3115 io_hi = 0;
3026 if ((hi >= 0) && (hi <= 6)) 3116 if ((hi >= 0) && (hi <= 6))
3027 io_hi = pci_resource_start (dev, hi); 3117 io_hi = pci_resource_start(dev, hi);
3028 else if (hi > 6) 3118 else if (hi > 6)
3029 io_lo += hi; /* Reinterpret the meaning of 3119 io_lo += hi; /* Reinterpret the meaning of
3030 "hi" as an offset (see SYBA 3120 "hi" as an offset (see SYBA
3031 def.) */ 3121 def.) */
3032 /* TODO: test if sharing interrupts works */ 3122 /* TODO: test if sharing interrupts works */
3033 irq = dev->irq; 3123 irq = dev->irq;
3034 if (irq == IRQ_NONE) { 3124 if (irq == IRQ_NONE) {
3035 printk (KERN_DEBUG 3125 printk(KERN_DEBUG
3036 "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx)\n", 3126 "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx)\n",
3037 parport_pc_pci_tbl[i + last_sio].vendor, 3127 parport_pc_pci_tbl[i + last_sio].vendor,
3038 parport_pc_pci_tbl[i + last_sio].device, 3128 parport_pc_pci_tbl[i + last_sio].device,
3039 io_lo, io_hi); 3129 io_lo, io_hi);
3040 irq = PARPORT_IRQ_NONE; 3130 irq = PARPORT_IRQ_NONE;
3041 } else { 3131 } else {
3042 printk (KERN_DEBUG 3132 printk(KERN_DEBUG
3043 "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx), IRQ %d\n", 3133 "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx), IRQ %d\n",
3044 parport_pc_pci_tbl[i + last_sio].vendor, 3134 parport_pc_pci_tbl[i + last_sio].vendor,
3045 parport_pc_pci_tbl[i + last_sio].device, 3135 parport_pc_pci_tbl[i + last_sio].device,
@@ -3056,7 +3146,7 @@ static int parport_pc_pci_probe (struct pci_dev *dev,
3056 data->num = count; 3146 data->num = count;
3057 3147
3058 if (cards[i].postinit_hook) 3148 if (cards[i].postinit_hook)
3059 cards[i].postinit_hook (dev, count == 0); 3149 cards[i].postinit_hook(dev, count == 0);
3060 3150
3061 if (count) { 3151 if (count) {
3062 pci_set_drvdata(dev, data); 3152 pci_set_drvdata(dev, data);
@@ -3090,7 +3180,7 @@ static struct pci_driver parport_pc_pci_driver = {
3090 .remove = __devexit_p(parport_pc_pci_remove), 3180 .remove = __devexit_p(parport_pc_pci_remove),
3091}; 3181};
3092 3182
3093static int __init parport_pc_init_superio (int autoirq, int autodma) 3183static int __init parport_pc_init_superio(int autoirq, int autodma)
3094{ 3184{
3095 const struct pci_device_id *id; 3185 const struct pci_device_id *id;
3096 struct pci_dev *pdev = NULL; 3186 struct pci_dev *pdev = NULL;
@@ -3101,8 +3191,9 @@ static int __init parport_pc_init_superio (int autoirq, int autodma)
3101 if (id == NULL || id->driver_data >= last_sio) 3191 if (id == NULL || id->driver_data >= last_sio)
3102 continue; 3192 continue;
3103 3193
3104 if (parport_pc_superio_info[id->driver_data].probe 3194 if (parport_pc_superio_info[id->driver_data].probe(
3105 (pdev, autoirq, autodma,parport_pc_superio_info[id->driver_data].via)) { 3195 pdev, autoirq, autodma,
3196 parport_pc_superio_info[id->driver_data].via)) {
3106 ret++; 3197 ret++;
3107 } 3198 }
3108 } 3199 }
@@ -3111,7 +3202,10 @@ static int __init parport_pc_init_superio (int autoirq, int autodma)
3111} 3202}
3112#else 3203#else
3113static struct pci_driver parport_pc_pci_driver; 3204static struct pci_driver parport_pc_pci_driver;
3114static int __init parport_pc_init_superio(int autoirq, int autodma) {return 0;} 3205static int __init parport_pc_init_superio(int autoirq, int autodma)
3206{
3207 return 0;
3208}
3115#endif /* CONFIG_PCI */ 3209#endif /* CONFIG_PCI */
3116 3210
3117#ifdef CONFIG_PNP 3211#ifdef CONFIG_PNP
@@ -3124,44 +3218,45 @@ static const struct pnp_device_id parport_pc_pnp_tbl[] = {
3124 { } 3218 { }
3125}; 3219};
3126 3220
3127MODULE_DEVICE_TABLE(pnp,parport_pc_pnp_tbl); 3221MODULE_DEVICE_TABLE(pnp, parport_pc_pnp_tbl);
3128 3222
3129static int parport_pc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id) 3223static int parport_pc_pnp_probe(struct pnp_dev *dev,
3224 const struct pnp_device_id *id)
3130{ 3225{
3131 struct parport *pdata; 3226 struct parport *pdata;
3132 unsigned long io_lo, io_hi; 3227 unsigned long io_lo, io_hi;
3133 int dma, irq; 3228 int dma, irq;
3134 3229
3135 if (pnp_port_valid(dev,0) && 3230 if (pnp_port_valid(dev, 0) &&
3136 !(pnp_port_flags(dev,0) & IORESOURCE_DISABLED)) { 3231 !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) {
3137 io_lo = pnp_port_start(dev,0); 3232 io_lo = pnp_port_start(dev, 0);
3138 } else 3233 } else
3139 return -EINVAL; 3234 return -EINVAL;
3140 3235
3141 if (pnp_port_valid(dev,1) && 3236 if (pnp_port_valid(dev, 1) &&
3142 !(pnp_port_flags(dev,1) & IORESOURCE_DISABLED)) { 3237 !(pnp_port_flags(dev, 1) & IORESOURCE_DISABLED)) {
3143 io_hi = pnp_port_start(dev,1); 3238 io_hi = pnp_port_start(dev, 1);
3144 } else 3239 } else
3145 io_hi = 0; 3240 io_hi = 0;
3146 3241
3147 if (pnp_irq_valid(dev,0) && 3242 if (pnp_irq_valid(dev, 0) &&
3148 !(pnp_irq_flags(dev,0) & IORESOURCE_DISABLED)) { 3243 !(pnp_irq_flags(dev, 0) & IORESOURCE_DISABLED)) {
3149 irq = pnp_irq(dev,0); 3244 irq = pnp_irq(dev, 0);
3150 } else 3245 } else
3151 irq = PARPORT_IRQ_NONE; 3246 irq = PARPORT_IRQ_NONE;
3152 3247
3153 if (pnp_dma_valid(dev,0) && 3248 if (pnp_dma_valid(dev, 0) &&
3154 !(pnp_dma_flags(dev,0) & IORESOURCE_DISABLED)) { 3249 !(pnp_dma_flags(dev, 0) & IORESOURCE_DISABLED)) {
3155 dma = pnp_dma(dev,0); 3250 dma = pnp_dma(dev, 0);
3156 } else 3251 } else
3157 dma = PARPORT_DMA_NONE; 3252 dma = PARPORT_DMA_NONE;
3158 3253
3159 dev_info(&dev->dev, "reported by %s\n", dev->protocol->name); 3254 dev_info(&dev->dev, "reported by %s\n", dev->protocol->name);
3160 if (!(pdata = parport_pc_probe_port(io_lo, io_hi, 3255 pdata = parport_pc_probe_port(io_lo, io_hi, irq, dma, &dev->dev, 0);
3161 irq, dma, &dev->dev, 0))) 3256 if (pdata == NULL)
3162 return -ENODEV; 3257 return -ENODEV;
3163 3258
3164 pnp_set_drvdata(dev,pdata); 3259 pnp_set_drvdata(dev, pdata);
3165 return 0; 3260 return 0;
3166} 3261}
3167 3262
@@ -3203,7 +3298,7 @@ static struct platform_driver parport_pc_platform_driver = {
3203 3298
3204/* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */ 3299/* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */
3205static int __devinit __attribute__((unused)) 3300static int __devinit __attribute__((unused))
3206parport_pc_find_isa_ports (int autoirq, int autodma) 3301parport_pc_find_isa_ports(int autoirq, int autodma)
3207{ 3302{
3208 int count = 0; 3303 int count = 0;
3209 3304
@@ -3227,7 +3322,7 @@ parport_pc_find_isa_ports (int autoirq, int autodma)
3227 * autoirq is PARPORT_IRQ_NONE, PARPORT_IRQ_AUTO, or PARPORT_IRQ_PROBEONLY 3322 * autoirq is PARPORT_IRQ_NONE, PARPORT_IRQ_AUTO, or PARPORT_IRQ_PROBEONLY
3228 * autodma is PARPORT_DMA_NONE or PARPORT_DMA_AUTO 3323 * autodma is PARPORT_DMA_NONE or PARPORT_DMA_AUTO
3229 */ 3324 */
3230static void __init parport_pc_find_ports (int autoirq, int autodma) 3325static void __init parport_pc_find_ports(int autoirq, int autodma)
3231{ 3326{
3232 int count = 0, err; 3327 int count = 0, err;
3233 3328
@@ -3261,11 +3356,18 @@ static void __init parport_pc_find_ports (int autoirq, int autodma)
3261 * syntax and keep in mind that code below is a cleaned up version. 3356 * syntax and keep in mind that code below is a cleaned up version.
3262 */ 3357 */
3263 3358
3264static int __initdata io[PARPORT_PC_MAX_PORTS+1] = { [0 ... PARPORT_PC_MAX_PORTS] = 0 }; 3359static int __initdata io[PARPORT_PC_MAX_PORTS+1] = {
3265static int __initdata io_hi[PARPORT_PC_MAX_PORTS+1] = 3360 [0 ... PARPORT_PC_MAX_PORTS] = 0
3266 { [0 ... PARPORT_PC_MAX_PORTS] = PARPORT_IOHI_AUTO }; 3361};
3267static int __initdata dmaval[PARPORT_PC_MAX_PORTS] = { [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_DMA_NONE }; 3362static int __initdata io_hi[PARPORT_PC_MAX_PORTS+1] = {
3268static int __initdata irqval[PARPORT_PC_MAX_PORTS] = { [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_IRQ_PROBEONLY }; 3363 [0 ... PARPORT_PC_MAX_PORTS] = PARPORT_IOHI_AUTO
3364};
3365static int __initdata dmaval[PARPORT_PC_MAX_PORTS] = {
3366 [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_DMA_NONE
3367};
3368static int __initdata irqval[PARPORT_PC_MAX_PORTS] = {
3369 [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_IRQ_PROBEONLY
3370};
3269 3371
3270static int __init parport_parse_param(const char *s, int *val, 3372static int __init parport_parse_param(const char *s, int *val,
3271 int automatic, int none, int nofifo) 3373 int automatic, int none, int nofifo)
@@ -3306,18 +3408,19 @@ static int __init parport_parse_dma(const char *dmastr, int *val)
3306#ifdef CONFIG_PCI 3408#ifdef CONFIG_PCI
3307static int __init parport_init_mode_setup(char *str) 3409static int __init parport_init_mode_setup(char *str)
3308{ 3410{
3309 printk(KERN_DEBUG "parport_pc.c: Specified parameter parport_init_mode=%s\n", str); 3411 printk(KERN_DEBUG
3310 3412 "parport_pc.c: Specified parameter parport_init_mode=%s\n", str);
3311 if (!strcmp (str, "spp")) 3413
3312 parport_init_mode=1; 3414 if (!strcmp(str, "spp"))
3313 if (!strcmp (str, "ps2")) 3415 parport_init_mode = 1;
3314 parport_init_mode=2; 3416 if (!strcmp(str, "ps2"))
3315 if (!strcmp (str, "epp")) 3417 parport_init_mode = 2;
3316 parport_init_mode=3; 3418 if (!strcmp(str, "epp"))
3317 if (!strcmp (str, "ecp")) 3419 parport_init_mode = 3;
3318 parport_init_mode=4; 3420 if (!strcmp(str, "ecp"))
3319 if (!strcmp (str, "ecpepp")) 3421 parport_init_mode = 4;
3320 parport_init_mode=5; 3422 if (!strcmp(str, "ecpepp"))
3423 parport_init_mode = 5;
3321 return 1; 3424 return 1;
3322} 3425}
3323#endif 3426#endif
@@ -3341,7 +3444,8 @@ module_param(verbose_probing, int, 0644);
3341#endif 3444#endif
3342#ifdef CONFIG_PCI 3445#ifdef CONFIG_PCI
3343static char *init_mode; 3446static char *init_mode;
3344MODULE_PARM_DESC(init_mode, "Initialise mode for VIA VT8231 port (spp, ps2, epp, ecp or ecpepp)"); 3447MODULE_PARM_DESC(init_mode,
3448 "Initialise mode for VIA VT8231 port (spp, ps2, epp, ecp or ecpepp)");
3345module_param(init_mode, charp, 0); 3449module_param(init_mode, charp, 0);
3346#endif 3450#endif
3347 3451
@@ -3372,7 +3476,7 @@ static int __init parse_parport_params(void)
3372 irqval[0] = val; 3476 irqval[0] = val;
3373 break; 3477 break;
3374 default: 3478 default:
3375 printk (KERN_WARNING 3479 printk(KERN_WARNING
3376 "parport_pc: irq specified " 3480 "parport_pc: irq specified "
3377 "without base address. Use 'io=' " 3481 "without base address. Use 'io=' "
3378 "to specify one\n"); 3482 "to specify one\n");
@@ -3385,7 +3489,7 @@ static int __init parse_parport_params(void)
3385 dmaval[0] = val; 3489 dmaval[0] = val;
3386 break; 3490 break;
3387 default: 3491 default:
3388 printk (KERN_WARNING 3492 printk(KERN_WARNING
3389 "parport_pc: dma specified " 3493 "parport_pc: dma specified "
3390 "without base address. Use 'io=' " 3494 "without base address. Use 'io=' "
3391 "to specify one\n"); 3495 "to specify one\n");
@@ -3396,7 +3500,7 @@ static int __init parse_parport_params(void)
3396 3500
3397#else 3501#else
3398 3502
3399static int parport_setup_ptr __initdata = 0; 3503static int parport_setup_ptr __initdata;
3400 3504
3401/* 3505/*
3402 * Acceptable parameters: 3506 * Acceptable parameters:
@@ -3407,7 +3511,7 @@ static int parport_setup_ptr __initdata = 0;
3407 * 3511 *
3408 * IRQ/DMA may be numeric or 'auto' or 'none' 3512 * IRQ/DMA may be numeric or 'auto' or 'none'
3409 */ 3513 */
3410static int __init parport_setup (char *str) 3514static int __init parport_setup(char *str)
3411{ 3515{
3412 char *endptr; 3516 char *endptr;
3413 char *sep; 3517 char *sep;
@@ -3419,15 +3523,15 @@ static int __init parport_setup (char *str)
3419 return 1; 3523 return 1;
3420 } 3524 }
3421 3525
3422 if (!strncmp (str, "auto", 4)) { 3526 if (!strncmp(str, "auto", 4)) {
3423 irqval[0] = PARPORT_IRQ_AUTO; 3527 irqval[0] = PARPORT_IRQ_AUTO;
3424 dmaval[0] = PARPORT_DMA_AUTO; 3528 dmaval[0] = PARPORT_DMA_AUTO;
3425 return 1; 3529 return 1;
3426 } 3530 }
3427 3531
3428 val = simple_strtoul (str, &endptr, 0); 3532 val = simple_strtoul(str, &endptr, 0);
3429 if (endptr == str) { 3533 if (endptr == str) {
3430 printk (KERN_WARNING "parport=%s not understood\n", str); 3534 printk(KERN_WARNING "parport=%s not understood\n", str);
3431 return 1; 3535 return 1;
3432 } 3536 }
3433 3537
@@ -3461,7 +3565,7 @@ static int __init parse_parport_params(void)
3461 return io[0] == PARPORT_DISABLE; 3565 return io[0] == PARPORT_DISABLE;
3462} 3566}
3463 3567
3464__setup ("parport=", parport_setup); 3568__setup("parport=", parport_setup);
3465 3569
3466/* 3570/*
3467 * Acceptable parameters: 3571 * Acceptable parameters:
@@ -3469,7 +3573,7 @@ __setup ("parport=", parport_setup);
3469 * parport_init_mode=[spp|ps2|epp|ecp|ecpepp] 3573 * parport_init_mode=[spp|ps2|epp|ecp|ecpepp]
3470 */ 3574 */
3471#ifdef CONFIG_PCI 3575#ifdef CONFIG_PCI
3472__setup("parport_init_mode=",parport_init_mode_setup); 3576__setup("parport_init_mode=", parport_init_mode_setup);
3473#endif 3577#endif
3474#endif 3578#endif
3475 3579
@@ -3493,13 +3597,13 @@ static int __init parport_pc_init(void)
3493 for (i = 0; i < PARPORT_PC_MAX_PORTS; i++) { 3597 for (i = 0; i < PARPORT_PC_MAX_PORTS; i++) {
3494 if (!io[i]) 3598 if (!io[i])
3495 break; 3599 break;
3496 if ((io_hi[i]) == PARPORT_IOHI_AUTO) 3600 if (io_hi[i] == PARPORT_IOHI_AUTO)
3497 io_hi[i] = 0x400 + io[i]; 3601 io_hi[i] = 0x400 + io[i];
3498 parport_pc_probe_port(io[i], io_hi[i], 3602 parport_pc_probe_port(io[i], io_hi[i],
3499 irqval[i], dmaval[i], NULL, 0); 3603 irqval[i], dmaval[i], NULL, 0);
3500 } 3604 }
3501 } else 3605 } else
3502 parport_pc_find_ports (irqval[0], dmaval[0]); 3606 parport_pc_find_ports(irqval[0], dmaval[0]);
3503 3607
3504 return 0; 3608 return 0;
3505} 3609}
@@ -3507,9 +3611,9 @@ static int __init parport_pc_init(void)
3507static void __exit parport_pc_exit(void) 3611static void __exit parport_pc_exit(void)
3508{ 3612{
3509 if (pci_registered_parport) 3613 if (pci_registered_parport)
3510 pci_unregister_driver (&parport_pc_pci_driver); 3614 pci_unregister_driver(&parport_pc_pci_driver);
3511 if (pnp_registered_parport) 3615 if (pnp_registered_parport)
3512 pnp_unregister_driver (&parport_pc_pnp_driver); 3616 pnp_unregister_driver(&parport_pc_pnp_driver);
3513 platform_driver_unregister(&parport_pc_platform_driver); 3617 platform_driver_unregister(&parport_pc_platform_driver);
3514 3618
3515 while (!list_empty(&ports_list)) { 3619 while (!list_empty(&ports_list)) {