diff options
Diffstat (limited to 'drivers/parport')
-rw-r--r-- | drivers/parport/parport_gsc.c | 4 | ||||
-rw-r--r-- | drivers/parport/parport_pc.c | 1833 |
2 files changed, 983 insertions, 854 deletions
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c index ea31a452b153..5d6de380e42b 100644 --- a/drivers/parport/parport_gsc.c +++ b/drivers/parport/parport_gsc.c | |||
@@ -376,14 +376,14 @@ static int __devinit parport_init_chip(struct parisc_device *dev) | |||
376 | /* PARPORT_IRQ_NONE */ PARPORT_DMA_NONE, NULL); | 376 | /* PARPORT_IRQ_NONE */ PARPORT_DMA_NONE, NULL); |
377 | if (p) | 377 | if (p) |
378 | parport_count++; | 378 | parport_count++; |
379 | dev->dev.driver_data = p; | 379 | dev_set_drvdata(&dev->dev, p); |
380 | 380 | ||
381 | return 0; | 381 | return 0; |
382 | } | 382 | } |
383 | 383 | ||
384 | static int __devexit parport_remove_chip(struct parisc_device *dev) | 384 | static int __devexit parport_remove_chip(struct parisc_device *dev) |
385 | { | 385 | { |
386 | struct parport *p = dev->dev.driver_data; | 386 | struct parport *p = dev_get_drvdata(&dev->dev); |
387 | if (p) { | 387 | if (p) { |
388 | struct parport_gsc_private *priv = p->private_data; | 388 | struct parport_gsc_private *priv = p->private_data; |
389 | struct parport_operations *ops = p->ops; | 389 | struct parport_operations *ops = p->ops; |
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 4e63cc9e2778..2597145a066e 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; | |||
109 | static int pnp_registered_parport; | 109 | static int pnp_registered_parport; |
110 | 110 | ||
111 | /* frob_control, but for ECR */ | 111 | /* frob_control, but for ECR */ |
112 | static void frob_econtrol (struct parport *pb, unsigned char m, | 112 | static 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 | ||
126 | static __inline__ void frob_set_mode (struct parport *p, int mode) | 126 | static 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 |
201 | static int get_fifo_residue (struct parport *p) | 204 | static 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 | ||
275 | static void parport_pc_init_state(struct pardevice *dev, struct parport_state *s) | 280 | static 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 | ||
295 | static void parport_pc_restore_state(struct parport *p, struct parport_state *s) | 301 | static 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 |
306 | static size_t parport_pc_epp_read_data (struct parport *port, void *buf, | 313 | static 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 | ||
374 | static size_t parport_pc_epp_write_data (struct parport *port, const void *buf, | 379 | static 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 | ||
403 | static size_t parport_pc_epp_read_addr (struct parport *port, void *buf, | 407 | static 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 | ||
428 | static size_t parport_pc_epp_write_addr (struct parport *port, | 432 | static 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 | ||
454 | static size_t parport_pc_ecpepp_read_data (struct parport *port, void *buf, | 458 | static 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 | ||
468 | static size_t parport_pc_ecpepp_write_data (struct parport *port, | 472 | static 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 | ||
483 | static size_t parport_pc_ecpepp_read_addr (struct parport *port, void *buf, | 487 | static 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 | ||
497 | static size_t parport_pc_ecpepp_write_addr (struct parport *port, | 501 | static 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 |
514 | static size_t parport_pc_fifo_write_block_pio (struct parport *port, | 518 | static 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: | 560 | false_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: | 585 | poll: |
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); | |
606 | dump_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 |
611 | static size_t parport_pc_fifo_write_block_dma (struct parport *port, | 616 | static 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 | ||
624 | dump_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: | 689 | false_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 | ||
731 | dump_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) */ |
747 | static size_t parport_pc_compat_write_block_pio (struct parport *port, | 756 | static 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 |
821 | static size_t parport_pc_ecp_write_block_pio (struct parport *port, | 831 | static 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 |
934 | static size_t parport_pc_ecp_read_block_pio (struct parport *port, | 945 | static 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; |
947 | DPRINTK (KERN_DEBUG "parport_pc: parport_pc_ecp_read_block_pio\n"); | 958 | DPRINTK(KERN_DEBUG "parport_pc: parport_pc_ecp_read_block_pio\n"); |
948 | dump_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 */ |
1006 | dump_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--; |
1017 | dump_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); |
1022 | dump_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, |
1025 | dump_parport_state ("post 45", port); | 1038 | PARPORT_STATUS_ACK); */ |
1026 | r = 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 | ||
1040 | dump_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. */ |
1059 | dump_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: | 1083 | false_alarm: |
1070 | dump_parport_state ("waiting", port); | 1084 | dump_parport_state("waiting", port); |
1071 | ret = parport_wait_event (port, HZ); | 1085 | ret = parport_wait_event(port, HZ); |
1072 | DPRINTK (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. */ |
1078 | dump_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. */ |
1100 | dump_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 | ||
1107 | DPRINTK (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; |
1123 | dump_parport_state ("rev idle2", port); | 1139 | dump_parport_state("rev idle2", port); |
1124 | 1140 | ||
1125 | out_no_data: | 1141 | out_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 | ||
1151 | dump_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. */ |
1167 | static const struct parport_operations parport_pc_ops = | 1183 | static 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 | |||
1221 | static 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 */ |
1206 | static void __devinit show_parconfig_smsc37c669(int io, int key) | 1232 | static 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 | ||
1284 | static void __devinit show_parconfig_winbond(int io, int key) | 1317 | static 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 | ||
1349 | static void __devinit decode_winbond(int efer, int key, int devid, int devrev, int oldid) | 1385 | static 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 | ||
1385 | static void __devinit decode_smsc(int efer, int key, int devid, int devrev) | 1438 | static 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,148 +1465,165 @@ 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 | ||
1414 | static void __devinit winbond_check(int io, int key) | 1472 | static void __devinit winbond_check(int io, int key) |
1415 | { | 1473 | { |
1416 | int devid,devrev,oldid,x_devid,x_devrev,x_oldid; | 1474 | int origval, 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 | ||
1479 | origval = inb(io); /* Save original value */ | ||
1480 | |||
1421 | /* First probe without key */ | 1481 | /* First probe without key */ |
1422 | outb(0x20,io); | 1482 | outb(0x20, io); |
1423 | x_devid=inb(io+1); | 1483 | x_devid = inb(io + 1); |
1424 | outb(0x21,io); | 1484 | outb(0x21, io); |
1425 | x_devrev=inb(io+1); | 1485 | x_devrev = inb(io + 1); |
1426 | outb(0x09,io); | 1486 | outb(0x09, io); |
1427 | x_oldid=inb(io+1); | 1487 | x_oldid = inb(io + 1); |
1428 | 1488 | ||
1429 | outb(key,io); | 1489 | outb(key, io); |
1430 | outb(key,io); /* Write Magic Sequence to EFER, extended | 1490 | outb(key, io); /* Write Magic Sequence to EFER, extended |
1431 | funtion enable register */ | 1491 | funtion enable register */ |
1432 | outb(0x20,io); /* Write EFIR, extended function index register */ | 1492 | outb(0x20, io); /* Write EFIR, extended function index register */ |
1433 | devid=inb(io+1); /* Read EFDR, extended function data register */ | 1493 | devid = inb(io + 1); /* Read EFDR, extended function data register */ |
1434 | outb(0x21,io); | 1494 | outb(0x21, io); |
1435 | devrev=inb(io+1); | 1495 | devrev = inb(io + 1); |
1436 | outb(0x09,io); | 1496 | outb(0x09, io); |
1437 | oldid=inb(io+1); | 1497 | oldid = inb(io + 1); |
1438 | outb(0xaa,io); /* Magic Seal */ | 1498 | outb(0xaa, io); /* Magic Seal */ |
1499 | |||
1500 | outb(origval, io); /* in case we poked some entirely different hardware */ | ||
1439 | 1501 | ||
1440 | if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid)) | 1502 | if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid)) |
1441 | goto out; /* protection against false positives */ | 1503 | goto out; /* protection against false positives */ |
1442 | 1504 | ||
1443 | decode_winbond(io,key,devid,devrev,oldid); | 1505 | decode_winbond(io, key, devid, devrev, oldid); |
1444 | out: | 1506 | out: |
1445 | release_region(io, 3); | 1507 | release_region(io, 3); |
1446 | } | 1508 | } |
1447 | 1509 | ||
1448 | static void __devinit winbond_check2(int io,int key) | 1510 | static void __devinit winbond_check2(int io, int key) |
1449 | { | 1511 | { |
1450 | int devid,devrev,oldid,x_devid,x_devrev,x_oldid; | 1512 | int origval[3], devid, devrev, oldid, x_devid, x_devrev, x_oldid; |
1451 | 1513 | ||
1452 | if (!request_region(io, 3, __func__)) | 1514 | if (!request_region(io, 3, __func__)) |
1453 | return; | 1515 | return; |
1454 | 1516 | ||
1455 | /* First probe without the key */ | 1517 | origval[0] = inb(io); /* Save original values */ |
1456 | outb(0x20,io+2); | 1518 | origval[1] = inb(io + 1); |
1457 | x_devid=inb(io+2); | 1519 | origval[2] = inb(io + 2); |
1458 | outb(0x21,io+1); | ||
1459 | x_devrev=inb(io+2); | ||
1460 | outb(0x09,io+1); | ||
1461 | x_oldid=inb(io+2); | ||
1462 | |||
1463 | outb(key,io); /* Write Magic Byte to EFER, extended | ||
1464 | funtion enable register */ | ||
1465 | outb(0x20,io+2); /* Write EFIR, extended function index register */ | ||
1466 | devid=inb(io+2); /* Read EFDR, extended function data register */ | ||
1467 | outb(0x21,io+1); | ||
1468 | devrev=inb(io+2); | ||
1469 | outb(0x09,io+1); | ||
1470 | oldid=inb(io+2); | ||
1471 | outb(0xaa,io); /* Magic Seal */ | ||
1472 | 1520 | ||
1473 | if ((x_devid == devid) && (x_devrev == devrev) && (x_oldid == oldid)) | 1521 | /* First probe without the key */ |
1522 | outb(0x20, io + 2); | ||
1523 | x_devid = inb(io + 2); | ||
1524 | outb(0x21, io + 1); | ||
1525 | x_devrev = inb(io + 2); | ||
1526 | outb(0x09, io + 1); | ||
1527 | x_oldid = inb(io + 2); | ||
1528 | |||
1529 | outb(key, io); /* Write Magic Byte to EFER, extended | ||
1530 | funtion enable register */ | ||
1531 | outb(0x20, io + 2); /* Write EFIR, extended function index register */ | ||
1532 | devid = inb(io + 2); /* Read EFDR, extended function data register */ | ||
1533 | outb(0x21, io + 1); | ||
1534 | devrev = inb(io + 2); | ||
1535 | outb(0x09, io + 1); | ||
1536 | oldid = inb(io + 2); | ||
1537 | outb(0xaa, io); /* Magic Seal */ | ||
1538 | |||
1539 | outb(origval[0], io); /* in case we poked some entirely different hardware */ | ||
1540 | outb(origval[1], io + 1); | ||
1541 | outb(origval[2], io + 2); | ||
1542 | |||
1543 | if (x_devid == devid && x_devrev == devrev && x_oldid == oldid) | ||
1474 | goto out; /* protection against false positives */ | 1544 | goto out; /* protection against false positives */ |
1475 | 1545 | ||
1476 | decode_winbond(io,key,devid,devrev,oldid); | 1546 | decode_winbond(io, key, devid, devrev, oldid); |
1477 | out: | 1547 | out: |
1478 | release_region(io, 3); | 1548 | release_region(io, 3); |
1479 | } | 1549 | } |
1480 | 1550 | ||
1481 | static void __devinit smsc_check(int io, int key) | 1551 | static void __devinit smsc_check(int io, int key) |
1482 | { | 1552 | { |
1483 | int id,rev,oldid,oldrev,x_id,x_rev,x_oldid,x_oldrev; | 1553 | int origval, id, rev, oldid, oldrev, x_id, x_rev, x_oldid, x_oldrev; |
1484 | 1554 | ||
1485 | if (!request_region(io, 3, __func__)) | 1555 | if (!request_region(io, 3, __func__)) |
1486 | return; | 1556 | return; |
1487 | 1557 | ||
1558 | origval = inb(io); /* Save original value */ | ||
1559 | |||
1488 | /* First probe without the key */ | 1560 | /* First probe without the key */ |
1489 | outb(0x0d,io); | 1561 | outb(0x0d, io); |
1490 | x_oldid=inb(io+1); | 1562 | x_oldid = inb(io + 1); |
1491 | outb(0x0e,io); | 1563 | outb(0x0e, io); |
1492 | x_oldrev=inb(io+1); | 1564 | x_oldrev = inb(io + 1); |
1493 | outb(0x20,io); | 1565 | outb(0x20, io); |
1494 | x_id=inb(io+1); | 1566 | x_id = inb(io + 1); |
1495 | outb(0x21,io); | 1567 | outb(0x21, io); |
1496 | x_rev=inb(io+1); | 1568 | x_rev = inb(io + 1); |
1497 | 1569 | ||
1498 | outb(key,io); | 1570 | outb(key, io); |
1499 | outb(key,io); /* Write Magic Sequence to EFER, extended | 1571 | outb(key, io); /* Write Magic Sequence to EFER, extended |
1500 | funtion enable register */ | 1572 | funtion enable register */ |
1501 | outb(0x0d,io); /* Write EFIR, extended function index register */ | 1573 | outb(0x0d, io); /* Write EFIR, extended function index register */ |
1502 | oldid=inb(io+1); /* Read EFDR, extended function data register */ | 1574 | oldid = inb(io + 1); /* Read EFDR, extended function data register */ |
1503 | outb(0x0e,io); | 1575 | outb(0x0e, io); |
1504 | oldrev=inb(io+1); | 1576 | oldrev = inb(io + 1); |
1505 | outb(0x20,io); | 1577 | outb(0x20, io); |
1506 | id=inb(io+1); | 1578 | id = inb(io + 1); |
1507 | outb(0x21,io); | 1579 | outb(0x21, io); |
1508 | rev=inb(io+1); | 1580 | rev = inb(io + 1); |
1509 | outb(0xaa,io); /* Magic Seal */ | 1581 | outb(0xaa, io); /* Magic Seal */ |
1510 | 1582 | ||
1511 | if ((x_id == id) && (x_oldrev == oldrev) && | 1583 | outb(origval, io); /* in case we poked some entirely different hardware */ |
1512 | (x_oldid == oldid) && (x_rev == rev)) | 1584 | |
1585 | if (x_id == id && x_oldrev == oldrev && | ||
1586 | x_oldid == oldid && x_rev == rev) | ||
1513 | goto out; /* protection against false positives */ | 1587 | goto out; /* protection against false positives */ |
1514 | 1588 | ||
1515 | decode_smsc(io,key,oldid,oldrev); | 1589 | decode_smsc(io, key, oldid, oldrev); |
1516 | out: | 1590 | out: |
1517 | release_region(io, 3); | 1591 | release_region(io, 3); |
1518 | } | 1592 | } |
1519 | 1593 | ||
1520 | 1594 | ||
1521 | static void __devinit detect_and_report_winbond (void) | 1595 | static void __devinit detect_and_report_winbond(void) |
1522 | { | 1596 | { |
1523 | if (verbose_probing) | 1597 | if (verbose_probing) |
1524 | printk(KERN_DEBUG "Winbond Super-IO detection, now testing ports 3F0,370,250,4E,2E ...\n"); | 1598 | printk(KERN_DEBUG "Winbond Super-IO detection, now testing ports 3F0,370,250,4E,2E ...\n"); |
1525 | winbond_check(0x3f0,0x87); | 1599 | winbond_check(0x3f0, 0x87); |
1526 | winbond_check(0x370,0x87); | 1600 | winbond_check(0x370, 0x87); |
1527 | winbond_check(0x2e ,0x87); | 1601 | winbond_check(0x2e , 0x87); |
1528 | winbond_check(0x4e ,0x87); | 1602 | winbond_check(0x4e , 0x87); |
1529 | winbond_check(0x3f0,0x86); | 1603 | winbond_check(0x3f0, 0x86); |
1530 | winbond_check2(0x250,0x88); | 1604 | winbond_check2(0x250, 0x88); |
1531 | winbond_check2(0x250,0x89); | 1605 | winbond_check2(0x250, 0x89); |
1532 | } | 1606 | } |
1533 | 1607 | ||
1534 | static void __devinit detect_and_report_smsc (void) | 1608 | static void __devinit detect_and_report_smsc(void) |
1535 | { | 1609 | { |
1536 | if (verbose_probing) | 1610 | if (verbose_probing) |
1537 | printk(KERN_DEBUG "SMSC Super-IO detection, now testing Ports 2F0, 370 ...\n"); | 1611 | printk(KERN_DEBUG "SMSC Super-IO detection, now testing Ports 2F0, 370 ...\n"); |
1538 | smsc_check(0x3f0,0x55); | 1612 | smsc_check(0x3f0, 0x55); |
1539 | smsc_check(0x370,0x55); | 1613 | smsc_check(0x370, 0x55); |
1540 | smsc_check(0x3f0,0x44); | 1614 | smsc_check(0x3f0, 0x44); |
1541 | smsc_check(0x370,0x44); | 1615 | smsc_check(0x370, 0x44); |
1542 | } | 1616 | } |
1543 | 1617 | ||
1544 | static void __devinit detect_and_report_it87(void) | 1618 | static void __devinit detect_and_report_it87(void) |
1545 | { | 1619 | { |
1546 | u16 dev; | 1620 | u16 dev; |
1547 | u8 r; | 1621 | u8 origval, r; |
1548 | if (verbose_probing) | 1622 | if (verbose_probing) |
1549 | printk(KERN_DEBUG "IT8705 Super-IO detection, now testing port 2E ...\n"); | 1623 | printk(KERN_DEBUG "IT8705 Super-IO detection, now testing port 2E ...\n"); |
1550 | if (!request_region(0x2e, 1, __func__)) | 1624 | if (!request_region(0x2e, 2, __func__)) |
1551 | return; | 1625 | return; |
1626 | origval = inb(0x2e); /* Save original value */ | ||
1552 | outb(0x87, 0x2e); | 1627 | outb(0x87, 0x2e); |
1553 | outb(0x01, 0x2e); | 1628 | outb(0x01, 0x2e); |
1554 | outb(0x55, 0x2e); | 1629 | outb(0x55, 0x2e); |
@@ -1568,39 +1643,46 @@ static void __devinit detect_and_report_it87(void) | |||
1568 | outb(r | 8, 0x2F); | 1643 | outb(r | 8, 0x2F); |
1569 | outb(0x02, 0x2E); /* Lock */ | 1644 | outb(0x02, 0x2E); /* Lock */ |
1570 | outb(0x02, 0x2F); | 1645 | outb(0x02, 0x2F); |
1646 | } else { | ||
1647 | outb(origval, 0x2e); /* Oops, sorry to disturb */ | ||
1571 | } | 1648 | } |
1572 | release_region(0x2e, 1); | 1649 | release_region(0x2e, 2); |
1573 | } | 1650 | } |
1574 | #endif /* CONFIG_PARPORT_PC_SUPERIO */ | 1651 | #endif /* CONFIG_PARPORT_PC_SUPERIO */ |
1575 | 1652 | ||
1576 | static int get_superio_dma (struct parport *p) | 1653 | static struct superio_struct *find_superio(struct parport *p) |
1654 | { | ||
1655 | int i; | ||
1656 | for (i = 0; i < NR_SUPERIOS; i++) | ||
1657 | if (superios[i].io != p->base) | ||
1658 | return &superios[i]; | ||
1659 | return NULL; | ||
1660 | } | ||
1661 | |||
1662 | static int get_superio_dma(struct parport *p) | ||
1577 | { | 1663 | { |
1578 | int i=0; | 1664 | struct superio_struct *s = find_superio(p); |
1579 | while( (superios[i].io != p->base) && (i<NR_SUPERIOS)) | 1665 | if (s) |
1580 | i++; | 1666 | return s->dma; |
1581 | if (i!=NR_SUPERIOS) | ||
1582 | return superios[i].dma; | ||
1583 | return PARPORT_DMA_NONE; | 1667 | return PARPORT_DMA_NONE; |
1584 | } | 1668 | } |
1585 | 1669 | ||
1586 | static int get_superio_irq (struct parport *p) | 1670 | static int get_superio_irq(struct parport *p) |
1587 | { | 1671 | { |
1588 | int i=0; | 1672 | struct superio_struct *s = find_superio(p); |
1589 | while( (superios[i].io != p->base) && (i<NR_SUPERIOS)) | 1673 | if (s) |
1590 | i++; | 1674 | return s->irq; |
1591 | if (i!=NR_SUPERIOS) | 1675 | return PARPORT_IRQ_NONE; |
1592 | return superios[i].irq; | ||
1593 | return PARPORT_IRQ_NONE; | ||
1594 | } | 1676 | } |
1595 | 1677 | ||
1596 | 1678 | ||
1597 | /* --- Mode detection ------------------------------------- */ | 1679 | /* --- Mode detection ------------------------------------- */ |
1598 | 1680 | ||
1599 | /* | 1681 | /* |
1600 | * Checks for port existence, all ports support SPP MODE | 1682 | * Checks for port existence, all ports support SPP MODE |
1601 | * Returns: | 1683 | * Returns: |
1602 | * 0 : No parallel port at this address | 1684 | * 0 : No parallel port at this address |
1603 | * PARPORT_MODE_PCSPP : SPP port detected | 1685 | * PARPORT_MODE_PCSPP : SPP port detected |
1604 | * (if the user specified an ioport himself, | 1686 | * (if the user specified an ioport himself, |
1605 | * this shall always be the case!) | 1687 | * this shall always be the case!) |
1606 | * | 1688 | * |
@@ -1610,7 +1692,7 @@ static int parport_SPP_supported(struct parport *pb) | |||
1610 | unsigned char r, w; | 1692 | unsigned char r, w; |
1611 | 1693 | ||
1612 | /* | 1694 | /* |
1613 | * first clear an eventually pending EPP timeout | 1695 | * first clear an eventually pending EPP timeout |
1614 | * I (sailer@ife.ee.ethz.ch) have an SMSC chipset | 1696 | * I (sailer@ife.ee.ethz.ch) have an SMSC chipset |
1615 | * that does not even respond to SPP cycles if an EPP | 1697 | * that does not even respond to SPP cycles if an EPP |
1616 | * timeout is pending | 1698 | * timeout is pending |
@@ -1619,19 +1701,19 @@ static int parport_SPP_supported(struct parport *pb) | |||
1619 | 1701 | ||
1620 | /* Do a simple read-write test to make sure the port exists. */ | 1702 | /* Do a simple read-write test to make sure the port exists. */ |
1621 | w = 0xc; | 1703 | w = 0xc; |
1622 | outb (w, CONTROL (pb)); | 1704 | outb(w, CONTROL(pb)); |
1623 | 1705 | ||
1624 | /* Is there a control register that we can read from? Some | 1706 | /* Is there a control register that we can read from? Some |
1625 | * ports don't allow reads, so read_control just returns a | 1707 | * ports don't allow reads, so read_control just returns a |
1626 | * software copy. Some ports _do_ allow reads, so bypass the | 1708 | * software copy. Some ports _do_ allow reads, so bypass the |
1627 | * software copy here. In addition, some bits aren't | 1709 | * software copy here. In addition, some bits aren't |
1628 | * writable. */ | 1710 | * writable. */ |
1629 | r = inb (CONTROL (pb)); | 1711 | r = inb(CONTROL(pb)); |
1630 | if ((r & 0xf) == w) { | 1712 | if ((r & 0xf) == w) { |
1631 | w = 0xe; | 1713 | w = 0xe; |
1632 | outb (w, CONTROL (pb)); | 1714 | outb(w, CONTROL(pb)); |
1633 | r = inb (CONTROL (pb)); | 1715 | r = inb(CONTROL(pb)); |
1634 | outb (0xc, CONTROL (pb)); | 1716 | outb(0xc, CONTROL(pb)); |
1635 | if ((r & 0xf) == w) | 1717 | if ((r & 0xf) == w) |
1636 | return PARPORT_MODE_PCSPP; | 1718 | return PARPORT_MODE_PCSPP; |
1637 | } | 1719 | } |
@@ -1639,18 +1721,18 @@ static int parport_SPP_supported(struct parport *pb) | |||
1639 | if (user_specified) | 1721 | if (user_specified) |
1640 | /* That didn't work, but the user thinks there's a | 1722 | /* That didn't work, but the user thinks there's a |
1641 | * port here. */ | 1723 | * port here. */ |
1642 | printk (KERN_INFO "parport 0x%lx (WARNING): CTR: " | 1724 | printk(KERN_INFO "parport 0x%lx (WARNING): CTR: " |
1643 | "wrote 0x%02x, read 0x%02x\n", pb->base, w, r); | 1725 | "wrote 0x%02x, read 0x%02x\n", pb->base, w, r); |
1644 | 1726 | ||
1645 | /* Try the data register. The data lines aren't tri-stated at | 1727 | /* Try the data register. The data lines aren't tri-stated at |
1646 | * this stage, so we expect back what we wrote. */ | 1728 | * this stage, so we expect back what we wrote. */ |
1647 | w = 0xaa; | 1729 | w = 0xaa; |
1648 | parport_pc_write_data (pb, w); | 1730 | parport_pc_write_data(pb, w); |
1649 | r = parport_pc_read_data (pb); | 1731 | r = parport_pc_read_data(pb); |
1650 | if (r == w) { | 1732 | if (r == w) { |
1651 | w = 0x55; | 1733 | w = 0x55; |
1652 | parport_pc_write_data (pb, w); | 1734 | parport_pc_write_data(pb, w); |
1653 | r = parport_pc_read_data (pb); | 1735 | r = parport_pc_read_data(pb); |
1654 | if (r == w) | 1736 | if (r == w) |
1655 | return PARPORT_MODE_PCSPP; | 1737 | return PARPORT_MODE_PCSPP; |
1656 | } | 1738 | } |
@@ -1658,9 +1740,9 @@ static int parport_SPP_supported(struct parport *pb) | |||
1658 | if (user_specified) { | 1740 | if (user_specified) { |
1659 | /* Didn't work, but the user is convinced this is the | 1741 | /* Didn't work, but the user is convinced this is the |
1660 | * place. */ | 1742 | * place. */ |
1661 | printk (KERN_INFO "parport 0x%lx (WARNING): DATA: " | 1743 | printk(KERN_INFO "parport 0x%lx (WARNING): DATA: " |
1662 | "wrote 0x%02x, read 0x%02x\n", pb->base, w, r); | 1744 | "wrote 0x%02x, read 0x%02x\n", pb->base, w, r); |
1663 | printk (KERN_INFO "parport 0x%lx: You gave this address, " | 1745 | printk(KERN_INFO "parport 0x%lx: You gave this address, " |
1664 | "but there is probably no parallel port there!\n", | 1746 | "but there is probably no parallel port there!\n", |
1665 | pb->base); | 1747 | pb->base); |
1666 | } | 1748 | } |
@@ -1691,33 +1773,33 @@ static int parport_ECR_present(struct parport *pb) | |||
1691 | struct parport_pc_private *priv = pb->private_data; | 1773 | struct parport_pc_private *priv = pb->private_data; |
1692 | unsigned char r = 0xc; | 1774 | unsigned char r = 0xc; |
1693 | 1775 | ||
1694 | outb (r, CONTROL (pb)); | 1776 | outb(r, CONTROL(pb)); |
1695 | if ((inb (ECONTROL (pb)) & 0x3) == (r & 0x3)) { | 1777 | if ((inb(ECONTROL(pb)) & 0x3) == (r & 0x3)) { |
1696 | outb (r ^ 0x2, CONTROL (pb)); /* Toggle bit 1 */ | 1778 | outb(r ^ 0x2, CONTROL(pb)); /* Toggle bit 1 */ |
1697 | 1779 | ||
1698 | r = inb (CONTROL (pb)); | 1780 | r = inb(CONTROL(pb)); |
1699 | if ((inb (ECONTROL (pb)) & 0x2) == (r & 0x2)) | 1781 | if ((inb(ECONTROL(pb)) & 0x2) == (r & 0x2)) |
1700 | goto no_reg; /* Sure that no ECR register exists */ | 1782 | goto no_reg; /* Sure that no ECR register exists */ |
1701 | } | 1783 | } |
1702 | 1784 | ||
1703 | if ((inb (ECONTROL (pb)) & 0x3 ) != 0x1) | 1785 | if ((inb(ECONTROL(pb)) & 0x3) != 0x1) |
1704 | goto no_reg; | 1786 | goto no_reg; |
1705 | 1787 | ||
1706 | ECR_WRITE (pb, 0x34); | 1788 | ECR_WRITE(pb, 0x34); |
1707 | if (inb (ECONTROL (pb)) != 0x35) | 1789 | if (inb(ECONTROL(pb)) != 0x35) |
1708 | goto no_reg; | 1790 | goto no_reg; |
1709 | 1791 | ||
1710 | priv->ecr = 1; | 1792 | priv->ecr = 1; |
1711 | outb (0xc, CONTROL (pb)); | 1793 | outb(0xc, CONTROL(pb)); |
1712 | 1794 | ||
1713 | /* Go to mode 000 */ | 1795 | /* Go to mode 000 */ |
1714 | frob_set_mode (pb, ECR_SPP); | 1796 | frob_set_mode(pb, ECR_SPP); |
1715 | 1797 | ||
1716 | return 1; | 1798 | return 1; |
1717 | 1799 | ||
1718 | no_reg: | 1800 | no_reg: |
1719 | outb (0xc, CONTROL (pb)); | 1801 | outb(0xc, CONTROL(pb)); |
1720 | return 0; | 1802 | return 0; |
1721 | } | 1803 | } |
1722 | 1804 | ||
1723 | #ifdef CONFIG_PARPORT_1284 | 1805 | #ifdef CONFIG_PARPORT_1284 |
@@ -1727,7 +1809,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 | 1809 | * 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 | 1810 | * 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 | 1811 | * 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. | 1812 | * of the data register we deem PS/2 support to be present. |
1731 | * | 1813 | * |
1732 | * Some SPP ports have "half PS/2" ability - you can't turn off the line | 1814 | * 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 | 1815 | * drivers, but an external peripheral with sufficiently beefy drivers of |
@@ -1735,26 +1817,28 @@ static int parport_ECR_present(struct parport *pb) | |||
1735 | * where they can then be read back as normal. Ports with this property | 1817 | * 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, | 1818 | * 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 | 1819 | * (as they will appear to have stuck bits) and so the fact that they might |
1738 | * be misdetected here is rather academic. | 1820 | * be misdetected here is rather academic. |
1739 | */ | 1821 | */ |
1740 | 1822 | ||
1741 | static int parport_PS2_supported(struct parport *pb) | 1823 | static int parport_PS2_supported(struct parport *pb) |
1742 | { | 1824 | { |
1743 | int ok = 0; | 1825 | int ok = 0; |
1744 | 1826 | ||
1745 | clear_epp_timeout(pb); | 1827 | clear_epp_timeout(pb); |
1746 | 1828 | ||
1747 | /* try to tri-state the buffer */ | 1829 | /* try to tri-state the buffer */ |
1748 | parport_pc_data_reverse (pb); | 1830 | parport_pc_data_reverse(pb); |
1749 | 1831 | ||
1750 | parport_pc_write_data(pb, 0x55); | 1832 | parport_pc_write_data(pb, 0x55); |
1751 | if (parport_pc_read_data(pb) != 0x55) ok++; | 1833 | if (parport_pc_read_data(pb) != 0x55) |
1834 | ok++; | ||
1752 | 1835 | ||
1753 | parport_pc_write_data(pb, 0xaa); | 1836 | parport_pc_write_data(pb, 0xaa); |
1754 | if (parport_pc_read_data(pb) != 0xaa) ok++; | 1837 | if (parport_pc_read_data(pb) != 0xaa) |
1838 | ok++; | ||
1755 | 1839 | ||
1756 | /* cancel input mode */ | 1840 | /* cancel input mode */ |
1757 | parport_pc_data_forward (pb); | 1841 | parport_pc_data_forward(pb); |
1758 | 1842 | ||
1759 | if (ok) { | 1843 | if (ok) { |
1760 | pb->modes |= PARPORT_MODE_TRISTATE; | 1844 | pb->modes |= PARPORT_MODE_TRISTATE; |
@@ -1773,68 +1857,68 @@ static int parport_ECP_supported(struct parport *pb) | |||
1773 | int config, configb; | 1857 | int config, configb; |
1774 | int pword; | 1858 | int pword; |
1775 | struct parport_pc_private *priv = pb->private_data; | 1859 | struct parport_pc_private *priv = pb->private_data; |
1776 | /* Translate ECP intrLine to ISA irq value */ | 1860 | /* Translate ECP intrLine to ISA irq value */ |
1777 | static const int intrline[]= { 0, 7, 9, 10, 11, 14, 15, 5 }; | 1861 | static const int intrline[] = { 0, 7, 9, 10, 11, 14, 15, 5 }; |
1778 | 1862 | ||
1779 | /* If there is no ECR, we have no hope of supporting ECP. */ | 1863 | /* If there is no ECR, we have no hope of supporting ECP. */ |
1780 | if (!priv->ecr) | 1864 | if (!priv->ecr) |
1781 | return 0; | 1865 | return 0; |
1782 | 1866 | ||
1783 | /* Find out FIFO depth */ | 1867 | /* Find out FIFO depth */ |
1784 | ECR_WRITE (pb, ECR_SPP << 5); /* Reset FIFO */ | 1868 | ECR_WRITE(pb, ECR_SPP << 5); /* Reset FIFO */ |
1785 | ECR_WRITE (pb, ECR_TST << 5); /* TEST FIFO */ | 1869 | ECR_WRITE(pb, ECR_TST << 5); /* TEST FIFO */ |
1786 | for (i=0; i < 1024 && !(inb (ECONTROL (pb)) & 0x02); i++) | 1870 | for (i = 0; i < 1024 && !(inb(ECONTROL(pb)) & 0x02); i++) |
1787 | outb (0xaa, FIFO (pb)); | 1871 | outb(0xaa, FIFO(pb)); |
1788 | 1872 | ||
1789 | /* | 1873 | /* |
1790 | * Using LGS chipset it uses ECR register, but | 1874 | * Using LGS chipset it uses ECR register, but |
1791 | * it doesn't support ECP or FIFO MODE | 1875 | * it doesn't support ECP or FIFO MODE |
1792 | */ | 1876 | */ |
1793 | if (i == 1024) { | 1877 | if (i == 1024) { |
1794 | ECR_WRITE (pb, ECR_SPP << 5); | 1878 | ECR_WRITE(pb, ECR_SPP << 5); |
1795 | return 0; | 1879 | return 0; |
1796 | } | 1880 | } |
1797 | 1881 | ||
1798 | priv->fifo_depth = i; | 1882 | priv->fifo_depth = i; |
1799 | if (verbose_probing) | 1883 | if (verbose_probing) |
1800 | printk (KERN_DEBUG "0x%lx: FIFO is %d bytes\n", pb->base, i); | 1884 | printk(KERN_DEBUG "0x%lx: FIFO is %d bytes\n", pb->base, i); |
1801 | 1885 | ||
1802 | /* Find out writeIntrThreshold */ | 1886 | /* Find out writeIntrThreshold */ |
1803 | frob_econtrol (pb, 1<<2, 1<<2); | 1887 | frob_econtrol(pb, 1<<2, 1<<2); |
1804 | frob_econtrol (pb, 1<<2, 0); | 1888 | frob_econtrol(pb, 1<<2, 0); |
1805 | for (i = 1; i <= priv->fifo_depth; i++) { | 1889 | for (i = 1; i <= priv->fifo_depth; i++) { |
1806 | inb (FIFO (pb)); | 1890 | inb(FIFO(pb)); |
1807 | udelay (50); | 1891 | udelay(50); |
1808 | if (inb (ECONTROL (pb)) & (1<<2)) | 1892 | if (inb(ECONTROL(pb)) & (1<<2)) |
1809 | break; | 1893 | break; |
1810 | } | 1894 | } |
1811 | 1895 | ||
1812 | if (i <= priv->fifo_depth) { | 1896 | if (i <= priv->fifo_depth) { |
1813 | if (verbose_probing) | 1897 | if (verbose_probing) |
1814 | printk (KERN_DEBUG "0x%lx: writeIntrThreshold is %d\n", | 1898 | printk(KERN_DEBUG "0x%lx: writeIntrThreshold is %d\n", |
1815 | pb->base, i); | 1899 | pb->base, i); |
1816 | } else | 1900 | } else |
1817 | /* Number of bytes we know we can write if we get an | 1901 | /* Number of bytes we know we can write if we get an |
1818 | interrupt. */ | 1902 | interrupt. */ |
1819 | i = 0; | 1903 | i = 0; |
1820 | 1904 | ||
1821 | priv->writeIntrThreshold = i; | 1905 | priv->writeIntrThreshold = i; |
1822 | 1906 | ||
1823 | /* Find out readIntrThreshold */ | 1907 | /* Find out readIntrThreshold */ |
1824 | frob_set_mode (pb, ECR_PS2); /* Reset FIFO and enable PS2 */ | 1908 | frob_set_mode(pb, ECR_PS2); /* Reset FIFO and enable PS2 */ |
1825 | parport_pc_data_reverse (pb); /* Must be in PS2 mode */ | 1909 | parport_pc_data_reverse(pb); /* Must be in PS2 mode */ |
1826 | frob_set_mode (pb, ECR_TST); /* Test FIFO */ | 1910 | frob_set_mode(pb, ECR_TST); /* Test FIFO */ |
1827 | frob_econtrol (pb, 1<<2, 1<<2); | 1911 | frob_econtrol(pb, 1<<2, 1<<2); |
1828 | frob_econtrol (pb, 1<<2, 0); | 1912 | frob_econtrol(pb, 1<<2, 0); |
1829 | for (i = 1; i <= priv->fifo_depth; i++) { | 1913 | for (i = 1; i <= priv->fifo_depth; i++) { |
1830 | outb (0xaa, FIFO (pb)); | 1914 | outb(0xaa, FIFO(pb)); |
1831 | if (inb (ECONTROL (pb)) & (1<<2)) | 1915 | if (inb(ECONTROL(pb)) & (1<<2)) |
1832 | break; | 1916 | break; |
1833 | } | 1917 | } |
1834 | 1918 | ||
1835 | if (i <= priv->fifo_depth) { | 1919 | if (i <= priv->fifo_depth) { |
1836 | if (verbose_probing) | 1920 | if (verbose_probing) |
1837 | printk (KERN_INFO "0x%lx: readIntrThreshold is %d\n", | 1921 | printk(KERN_INFO "0x%lx: readIntrThreshold is %d\n", |
1838 | pb->base, i); | 1922 | pb->base, i); |
1839 | } else | 1923 | } else |
1840 | /* Number of bytes we can read if we get an interrupt. */ | 1924 | /* Number of bytes we can read if we get an interrupt. */ |
@@ -1842,23 +1926,23 @@ static int parport_ECP_supported(struct parport *pb) | |||
1842 | 1926 | ||
1843 | priv->readIntrThreshold = i; | 1927 | priv->readIntrThreshold = i; |
1844 | 1928 | ||
1845 | ECR_WRITE (pb, ECR_SPP << 5); /* Reset FIFO */ | 1929 | ECR_WRITE(pb, ECR_SPP << 5); /* Reset FIFO */ |
1846 | ECR_WRITE (pb, 0xf4); /* Configuration mode */ | 1930 | ECR_WRITE(pb, 0xf4); /* Configuration mode */ |
1847 | config = inb (CONFIGA (pb)); | 1931 | config = inb(CONFIGA(pb)); |
1848 | pword = (config >> 4) & 0x7; | 1932 | pword = (config >> 4) & 0x7; |
1849 | switch (pword) { | 1933 | switch (pword) { |
1850 | case 0: | 1934 | case 0: |
1851 | pword = 2; | 1935 | pword = 2; |
1852 | printk (KERN_WARNING "0x%lx: Unsupported pword size!\n", | 1936 | printk(KERN_WARNING "0x%lx: Unsupported pword size!\n", |
1853 | pb->base); | 1937 | pb->base); |
1854 | break; | 1938 | break; |
1855 | case 2: | 1939 | case 2: |
1856 | pword = 4; | 1940 | pword = 4; |
1857 | printk (KERN_WARNING "0x%lx: Unsupported pword size!\n", | 1941 | printk(KERN_WARNING "0x%lx: Unsupported pword size!\n", |
1858 | pb->base); | 1942 | pb->base); |
1859 | break; | 1943 | break; |
1860 | default: | 1944 | default: |
1861 | printk (KERN_WARNING "0x%lx: Unknown implementation ID\n", | 1945 | printk(KERN_WARNING "0x%lx: Unknown implementation ID\n", |
1862 | pb->base); | 1946 | pb->base); |
1863 | /* Assume 1 */ | 1947 | /* Assume 1 */ |
1864 | case 1: | 1948 | case 1: |
@@ -1867,28 +1951,29 @@ static int parport_ECP_supported(struct parport *pb) | |||
1867 | priv->pword = pword; | 1951 | priv->pword = pword; |
1868 | 1952 | ||
1869 | if (verbose_probing) { | 1953 | if (verbose_probing) { |
1870 | printk (KERN_DEBUG "0x%lx: PWord is %d bits\n", pb->base, 8 * pword); | 1954 | printk(KERN_DEBUG "0x%lx: PWord is %d bits\n", |
1871 | 1955 | pb->base, 8 * pword); | |
1872 | printk (KERN_DEBUG "0x%lx: Interrupts are ISA-%s\n", pb->base, | 1956 | |
1957 | printk(KERN_DEBUG "0x%lx: Interrupts are ISA-%s\n", pb->base, | ||
1873 | config & 0x80 ? "Level" : "Pulses"); | 1958 | config & 0x80 ? "Level" : "Pulses"); |
1874 | 1959 | ||
1875 | configb = inb (CONFIGB (pb)); | 1960 | configb = inb(CONFIGB(pb)); |
1876 | printk (KERN_DEBUG "0x%lx: ECP port cfgA=0x%02x cfgB=0x%02x\n", | 1961 | printk(KERN_DEBUG "0x%lx: ECP port cfgA=0x%02x cfgB=0x%02x\n", |
1877 | pb->base, config, configb); | 1962 | pb->base, config, configb); |
1878 | printk (KERN_DEBUG "0x%lx: ECP settings irq=", pb->base); | 1963 | printk(KERN_DEBUG "0x%lx: ECP settings irq=", pb->base); |
1879 | if ((configb >>3) & 0x07) | 1964 | if ((configb >> 3) & 0x07) |
1880 | printk("%d",intrline[(configb >>3) & 0x07]); | 1965 | printk("%d", intrline[(configb >> 3) & 0x07]); |
1881 | else | 1966 | else |
1882 | printk("<none or set by other means>"); | 1967 | printk("<none or set by other means>"); |
1883 | printk (" dma="); | 1968 | printk(" dma="); |
1884 | if( (configb & 0x03 ) == 0x00) | 1969 | if ((configb & 0x03) == 0x00) |
1885 | printk("<none or set by other means>\n"); | 1970 | printk("<none or set by other means>\n"); |
1886 | else | 1971 | else |
1887 | printk("%d\n",configb & 0x07); | 1972 | printk("%d\n", configb & 0x07); |
1888 | } | 1973 | } |
1889 | 1974 | ||
1890 | /* Go back to mode 000 */ | 1975 | /* Go back to mode 000 */ |
1891 | frob_set_mode (pb, ECR_SPP); | 1976 | frob_set_mode(pb, ECR_SPP); |
1892 | 1977 | ||
1893 | return 1; | 1978 | return 1; |
1894 | } | 1979 | } |
@@ -1903,10 +1988,10 @@ static int parport_ECPPS2_supported(struct parport *pb) | |||
1903 | if (!priv->ecr) | 1988 | if (!priv->ecr) |
1904 | return 0; | 1989 | return 0; |
1905 | 1990 | ||
1906 | oecr = inb (ECONTROL (pb)); | 1991 | oecr = inb(ECONTROL(pb)); |
1907 | ECR_WRITE (pb, ECR_PS2 << 5); | 1992 | ECR_WRITE(pb, ECR_PS2 << 5); |
1908 | result = parport_PS2_supported(pb); | 1993 | result = parport_PS2_supported(pb); |
1909 | ECR_WRITE (pb, oecr); | 1994 | ECR_WRITE(pb, oecr); |
1910 | return result; | 1995 | return result; |
1911 | } | 1996 | } |
1912 | 1997 | ||
@@ -1930,16 +2015,15 @@ static int parport_EPP_supported(struct parport *pb) | |||
1930 | */ | 2015 | */ |
1931 | 2016 | ||
1932 | /* If EPP timeout bit clear then EPP available */ | 2017 | /* If EPP timeout bit clear then EPP available */ |
1933 | if (!clear_epp_timeout(pb)) { | 2018 | if (!clear_epp_timeout(pb)) |
1934 | return 0; /* No way to clear timeout */ | 2019 | return 0; /* No way to clear timeout */ |
1935 | } | ||
1936 | 2020 | ||
1937 | /* Check for Intel bug. */ | 2021 | /* Check for Intel bug. */ |
1938 | if (priv->ecr) { | 2022 | if (priv->ecr) { |
1939 | unsigned char i; | 2023 | unsigned char i; |
1940 | for (i = 0x00; i < 0x80; i += 0x20) { | 2024 | for (i = 0x00; i < 0x80; i += 0x20) { |
1941 | ECR_WRITE (pb, i); | 2025 | ECR_WRITE(pb, i); |
1942 | if (clear_epp_timeout (pb)) { | 2026 | if (clear_epp_timeout(pb)) { |
1943 | /* Phony EPP in ECP. */ | 2027 | /* Phony EPP in ECP. */ |
1944 | return 0; | 2028 | return 0; |
1945 | } | 2029 | } |
@@ -1963,17 +2047,16 @@ static int parport_ECPEPP_supported(struct parport *pb) | |||
1963 | int result; | 2047 | int result; |
1964 | unsigned char oecr; | 2048 | unsigned char oecr; |
1965 | 2049 | ||
1966 | if (!priv->ecr) { | 2050 | if (!priv->ecr) |
1967 | return 0; | 2051 | return 0; |
1968 | } | ||
1969 | 2052 | ||
1970 | oecr = inb (ECONTROL (pb)); | 2053 | oecr = inb(ECONTROL(pb)); |
1971 | /* Search for SMC style EPP+ECP mode */ | 2054 | /* Search for SMC style EPP+ECP mode */ |
1972 | ECR_WRITE (pb, 0x80); | 2055 | ECR_WRITE(pb, 0x80); |
1973 | outb (0x04, CONTROL (pb)); | 2056 | outb(0x04, CONTROL(pb)); |
1974 | result = parport_EPP_supported(pb); | 2057 | result = parport_EPP_supported(pb); |
1975 | 2058 | ||
1976 | ECR_WRITE (pb, oecr); | 2059 | ECR_WRITE(pb, oecr); |
1977 | 2060 | ||
1978 | if (result) { | 2061 | if (result) { |
1979 | /* Set up access functions to use ECP+EPP hardware. */ | 2062 | /* Set up access functions to use ECP+EPP hardware. */ |
@@ -1991,11 +2074,25 @@ static int parport_ECPEPP_supported(struct parport *pb) | |||
1991 | /* Don't bother probing for modes we know we won't use. */ | 2074 | /* Don't bother probing for modes we know we won't use. */ |
1992 | static int __devinit parport_PS2_supported(struct parport *pb) { return 0; } | 2075 | static int __devinit parport_PS2_supported(struct parport *pb) { return 0; } |
1993 | #ifdef CONFIG_PARPORT_PC_FIFO | 2076 | #ifdef CONFIG_PARPORT_PC_FIFO |
1994 | static int parport_ECP_supported(struct parport *pb) { return 0; } | 2077 | static int parport_ECP_supported(struct parport *pb) |
2078 | { | ||
2079 | return 0; | ||
2080 | } | ||
1995 | #endif | 2081 | #endif |
1996 | static int __devinit parport_EPP_supported(struct parport *pb) { return 0; } | 2082 | static int __devinit parport_EPP_supported(struct parport *pb) |
1997 | static int __devinit parport_ECPEPP_supported(struct parport *pb){return 0;} | 2083 | { |
1998 | static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;} | 2084 | return 0; |
2085 | } | ||
2086 | |||
2087 | static int __devinit parport_ECPEPP_supported(struct parport *pb) | ||
2088 | { | ||
2089 | return 0; | ||
2090 | } | ||
2091 | |||
2092 | static int __devinit parport_ECPPS2_supported(struct parport *pb) | ||
2093 | { | ||
2094 | return 0; | ||
2095 | } | ||
1999 | 2096 | ||
2000 | #endif /* No IEEE 1284 support */ | 2097 | #endif /* No IEEE 1284 support */ |
2001 | 2098 | ||
@@ -2005,17 +2102,17 @@ static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;} | |||
2005 | static int programmable_irq_support(struct parport *pb) | 2102 | static int programmable_irq_support(struct parport *pb) |
2006 | { | 2103 | { |
2007 | int irq, intrLine; | 2104 | int irq, intrLine; |
2008 | unsigned char oecr = inb (ECONTROL (pb)); | 2105 | unsigned char oecr = inb(ECONTROL(pb)); |
2009 | static const int lookup[8] = { | 2106 | static const int lookup[8] = { |
2010 | PARPORT_IRQ_NONE, 7, 9, 10, 11, 14, 15, 5 | 2107 | PARPORT_IRQ_NONE, 7, 9, 10, 11, 14, 15, 5 |
2011 | }; | 2108 | }; |
2012 | 2109 | ||
2013 | ECR_WRITE (pb, ECR_CNF << 5); /* Configuration MODE */ | 2110 | ECR_WRITE(pb, ECR_CNF << 5); /* Configuration MODE */ |
2014 | 2111 | ||
2015 | intrLine = (inb (CONFIGB (pb)) >> 3) & 0x07; | 2112 | intrLine = (inb(CONFIGB(pb)) >> 3) & 0x07; |
2016 | irq = lookup[intrLine]; | 2113 | irq = lookup[intrLine]; |
2017 | 2114 | ||
2018 | ECR_WRITE (pb, oecr); | 2115 | ECR_WRITE(pb, oecr); |
2019 | return irq; | 2116 | return irq; |
2020 | } | 2117 | } |
2021 | 2118 | ||
@@ -2025,17 +2122,17 @@ static int irq_probe_ECP(struct parport *pb) | |||
2025 | unsigned long irqs; | 2122 | unsigned long irqs; |
2026 | 2123 | ||
2027 | irqs = probe_irq_on(); | 2124 | irqs = probe_irq_on(); |
2028 | 2125 | ||
2029 | ECR_WRITE (pb, ECR_SPP << 5); /* Reset FIFO */ | 2126 | ECR_WRITE(pb, ECR_SPP << 5); /* Reset FIFO */ |
2030 | ECR_WRITE (pb, (ECR_TST << 5) | 0x04); | 2127 | ECR_WRITE(pb, (ECR_TST << 5) | 0x04); |
2031 | ECR_WRITE (pb, ECR_TST << 5); | 2128 | ECR_WRITE(pb, ECR_TST << 5); |
2032 | 2129 | ||
2033 | /* If Full FIFO sure that writeIntrThreshold is generated */ | 2130 | /* If Full FIFO sure that writeIntrThreshold is generated */ |
2034 | for (i=0; i < 1024 && !(inb (ECONTROL (pb)) & 0x02) ; i++) | 2131 | for (i = 0; i < 1024 && !(inb(ECONTROL(pb)) & 0x02) ; i++) |
2035 | outb (0xaa, FIFO (pb)); | 2132 | outb(0xaa, FIFO(pb)); |
2036 | 2133 | ||
2037 | pb->irq = probe_irq_off(irqs); | 2134 | pb->irq = probe_irq_off(irqs); |
2038 | ECR_WRITE (pb, ECR_SPP << 5); | 2135 | ECR_WRITE(pb, ECR_SPP << 5); |
2039 | 2136 | ||
2040 | if (pb->irq <= 0) | 2137 | if (pb->irq <= 0) |
2041 | pb->irq = PARPORT_IRQ_NONE; | 2138 | pb->irq = PARPORT_IRQ_NONE; |
@@ -2045,7 +2142,7 @@ static int irq_probe_ECP(struct parport *pb) | |||
2045 | 2142 | ||
2046 | /* | 2143 | /* |
2047 | * This detection seems that only works in National Semiconductors | 2144 | * This detection seems that only works in National Semiconductors |
2048 | * This doesn't work in SMC, LGS, and Winbond | 2145 | * This doesn't work in SMC, LGS, and Winbond |
2049 | */ | 2146 | */ |
2050 | static int irq_probe_EPP(struct parport *pb) | 2147 | static int irq_probe_EPP(struct parport *pb) |
2051 | { | 2148 | { |
@@ -2056,16 +2153,16 @@ static int irq_probe_EPP(struct parport *pb) | |||
2056 | unsigned char oecr; | 2153 | unsigned char oecr; |
2057 | 2154 | ||
2058 | if (pb->modes & PARPORT_MODE_PCECR) | 2155 | if (pb->modes & PARPORT_MODE_PCECR) |
2059 | oecr = inb (ECONTROL (pb)); | 2156 | oecr = inb(ECONTROL(pb)); |
2060 | 2157 | ||
2061 | irqs = probe_irq_on(); | 2158 | irqs = probe_irq_on(); |
2062 | 2159 | ||
2063 | if (pb->modes & PARPORT_MODE_PCECR) | 2160 | if (pb->modes & PARPORT_MODE_PCECR) |
2064 | frob_econtrol (pb, 0x10, 0x10); | 2161 | frob_econtrol(pb, 0x10, 0x10); |
2065 | 2162 | ||
2066 | clear_epp_timeout(pb); | 2163 | clear_epp_timeout(pb); |
2067 | parport_pc_frob_control (pb, 0x20, 0x20); | 2164 | parport_pc_frob_control(pb, 0x20, 0x20); |
2068 | parport_pc_frob_control (pb, 0x10, 0x10); | 2165 | parport_pc_frob_control(pb, 0x10, 0x10); |
2069 | clear_epp_timeout(pb); | 2166 | clear_epp_timeout(pb); |
2070 | 2167 | ||
2071 | /* Device isn't expecting an EPP read | 2168 | /* Device isn't expecting an EPP read |
@@ -2074,9 +2171,9 @@ static int irq_probe_EPP(struct parport *pb) | |||
2074 | parport_pc_read_epp(pb); | 2171 | parport_pc_read_epp(pb); |
2075 | udelay(20); | 2172 | udelay(20); |
2076 | 2173 | ||
2077 | pb->irq = probe_irq_off (irqs); | 2174 | pb->irq = probe_irq_off(irqs); |
2078 | if (pb->modes & PARPORT_MODE_PCECR) | 2175 | if (pb->modes & PARPORT_MODE_PCECR) |
2079 | ECR_WRITE (pb, oecr); | 2176 | ECR_WRITE(pb, oecr); |
2080 | parport_pc_write_control(pb, 0xc); | 2177 | parport_pc_write_control(pb, 0xc); |
2081 | 2178 | ||
2082 | if (pb->irq <= 0) | 2179 | if (pb->irq <= 0) |
@@ -2133,28 +2230,28 @@ static int parport_irq_probe(struct parport *pb) | |||
2133 | /* --- DMA detection -------------------------------------- */ | 2230 | /* --- DMA detection -------------------------------------- */ |
2134 | 2231 | ||
2135 | /* Only if chipset conforms to ECP ISA Interface Standard */ | 2232 | /* Only if chipset conforms to ECP ISA Interface Standard */ |
2136 | static int programmable_dma_support (struct parport *p) | 2233 | static int programmable_dma_support(struct parport *p) |
2137 | { | 2234 | { |
2138 | unsigned char oecr = inb (ECONTROL (p)); | 2235 | unsigned char oecr = inb(ECONTROL(p)); |
2139 | int dma; | 2236 | int dma; |
2140 | 2237 | ||
2141 | frob_set_mode (p, ECR_CNF); | 2238 | frob_set_mode(p, ECR_CNF); |
2142 | 2239 | ||
2143 | dma = inb (CONFIGB(p)) & 0x07; | 2240 | dma = inb(CONFIGB(p)) & 0x07; |
2144 | /* 000: Indicates jumpered 8-bit DMA if read-only. | 2241 | /* 000: Indicates jumpered 8-bit DMA if read-only. |
2145 | 100: Indicates jumpered 16-bit DMA if read-only. */ | 2242 | 100: Indicates jumpered 16-bit DMA if read-only. */ |
2146 | if ((dma & 0x03) == 0) | 2243 | if ((dma & 0x03) == 0) |
2147 | dma = PARPORT_DMA_NONE; | 2244 | dma = PARPORT_DMA_NONE; |
2148 | 2245 | ||
2149 | ECR_WRITE (p, oecr); | 2246 | ECR_WRITE(p, oecr); |
2150 | return dma; | 2247 | return dma; |
2151 | } | 2248 | } |
2152 | 2249 | ||
2153 | static int parport_dma_probe (struct parport *p) | 2250 | static int parport_dma_probe(struct parport *p) |
2154 | { | 2251 | { |
2155 | const struct parport_pc_private *priv = p->private_data; | 2252 | const struct parport_pc_private *priv = p->private_data; |
2156 | if (priv->ecr) | 2253 | if (priv->ecr) /* ask ECP chipset first */ |
2157 | p->dma = programmable_dma_support(p); /* ask ECP chipset first */ | 2254 | p->dma = programmable_dma_support(p); |
2158 | if (p->dma == PARPORT_DMA_NONE) { | 2255 | if (p->dma == PARPORT_DMA_NONE) { |
2159 | /* ask known Super-IO chips proper, although these | 2256 | /* ask known Super-IO chips proper, although these |
2160 | claim ECP compatible, some don't report their DMA | 2257 | claim ECP compatible, some don't report their DMA |
@@ -2193,6 +2290,9 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2193 | if (IS_ERR(pdev)) | 2290 | if (IS_ERR(pdev)) |
2194 | return NULL; | 2291 | return NULL; |
2195 | dev = &pdev->dev; | 2292 | dev = &pdev->dev; |
2293 | |||
2294 | dev->coherent_dma_mask = DMA_BIT_MASK(24); | ||
2295 | dev->dma_mask = &dev->coherent_dma_mask; | ||
2196 | } | 2296 | } |
2197 | 2297 | ||
2198 | ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL); | 2298 | ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL); |
@@ -2212,7 +2312,7 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2212 | if (!base_res) | 2312 | if (!base_res) |
2213 | goto out4; | 2313 | goto out4; |
2214 | 2314 | ||
2215 | memcpy(ops, &parport_pc_ops, sizeof (struct parport_operations)); | 2315 | memcpy(ops, &parport_pc_ops, sizeof(struct parport_operations)); |
2216 | priv->ctr = 0xc; | 2316 | priv->ctr = 0xc; |
2217 | priv->ctr_writable = ~0x10; | 2317 | priv->ctr_writable = ~0x10; |
2218 | priv->ecr = 0; | 2318 | priv->ecr = 0; |
@@ -2239,7 +2339,7 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2239 | if (!parport_EPP_supported(p)) | 2339 | if (!parport_EPP_supported(p)) |
2240 | parport_ECPEPP_supported(p); | 2340 | parport_ECPEPP_supported(p); |
2241 | } | 2341 | } |
2242 | if (!parport_SPP_supported (p)) | 2342 | if (!parport_SPP_supported(p)) |
2243 | /* No port. */ | 2343 | /* No port. */ |
2244 | goto out5; | 2344 | goto out5; |
2245 | if (priv->ecr) | 2345 | if (priv->ecr) |
@@ -2247,7 +2347,7 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2247 | else | 2347 | else |
2248 | parport_PS2_supported(p); | 2348 | parport_PS2_supported(p); |
2249 | 2349 | ||
2250 | p->size = (p->modes & PARPORT_MODE_EPP)?8:3; | 2350 | p->size = (p->modes & PARPORT_MODE_EPP) ? 8 : 3; |
2251 | 2351 | ||
2252 | printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base); | 2352 | printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base); |
2253 | if (p->base_hi && priv->ecr) | 2353 | if (p->base_hi && priv->ecr) |
@@ -2271,7 +2371,7 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2271 | } | 2371 | } |
2272 | } | 2372 | } |
2273 | if (p->dma == PARPORT_DMA_AUTO) /* To use DMA, giving the irq | 2373 | if (p->dma == PARPORT_DMA_AUTO) /* To use DMA, giving the irq |
2274 | is mandatory (see above) */ | 2374 | is mandatory (see above) */ |
2275 | p->dma = PARPORT_DMA_NONE; | 2375 | p->dma = PARPORT_DMA_NONE; |
2276 | 2376 | ||
2277 | #ifdef CONFIG_PARPORT_PC_FIFO | 2377 | #ifdef CONFIG_PARPORT_PC_FIFO |
@@ -2288,16 +2388,23 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2288 | if (p->dma != PARPORT_DMA_NONE) { | 2388 | if (p->dma != PARPORT_DMA_NONE) { |
2289 | printk(", dma %d", p->dma); | 2389 | printk(", dma %d", p->dma); |
2290 | p->modes |= PARPORT_MODE_DMA; | 2390 | p->modes |= PARPORT_MODE_DMA; |
2291 | } | 2391 | } else |
2292 | else printk(", using FIFO"); | 2392 | printk(", using FIFO"); |
2293 | } | 2393 | } else |
2294 | else | ||
2295 | /* We can't use the DMA channel after all. */ | 2394 | /* We can't use the DMA channel after all. */ |
2296 | p->dma = PARPORT_DMA_NONE; | 2395 | p->dma = PARPORT_DMA_NONE; |
2297 | #endif /* Allowed to use FIFO/DMA */ | 2396 | #endif /* Allowed to use FIFO/DMA */ |
2298 | 2397 | ||
2299 | printk(" ["); | 2398 | printk(" ["); |
2300 | #define printmode(x) {if(p->modes&PARPORT_MODE_##x){printk("%s%s",f?",":"",#x);f++;}} | 2399 | |
2400 | #define printmode(x) \ | ||
2401 | {\ | ||
2402 | if (p->modes & PARPORT_MODE_##x) {\ | ||
2403 | printk("%s%s", f ? "," : "", #x);\ | ||
2404 | f++;\ | ||
2405 | } \ | ||
2406 | } | ||
2407 | |||
2301 | { | 2408 | { |
2302 | int f = 0; | 2409 | int f = 0; |
2303 | printmode(PCSPP); | 2410 | printmode(PCSPP); |
@@ -2309,10 +2416,10 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2309 | } | 2416 | } |
2310 | #undef printmode | 2417 | #undef printmode |
2311 | #ifndef CONFIG_PARPORT_1284 | 2418 | #ifndef CONFIG_PARPORT_1284 |
2312 | printk ("(,...)"); | 2419 | printk("(,...)"); |
2313 | #endif /* CONFIG_PARPORT_1284 */ | 2420 | #endif /* CONFIG_PARPORT_1284 */ |
2314 | printk("]\n"); | 2421 | printk("]\n"); |
2315 | if (probedirq != PARPORT_IRQ_NONE) | 2422 | if (probedirq != PARPORT_IRQ_NONE) |
2316 | printk(KERN_INFO "%s: irq %d detected\n", p->name, probedirq); | 2423 | printk(KERN_INFO "%s: irq %d detected\n", p->name, probedirq); |
2317 | 2424 | ||
2318 | /* If No ECP release the ports grabbed above. */ | 2425 | /* If No ECP release the ports grabbed above. */ |
@@ -2328,7 +2435,7 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2328 | if (p->irq != PARPORT_IRQ_NONE) { | 2435 | if (p->irq != PARPORT_IRQ_NONE) { |
2329 | if (request_irq(p->irq, parport_irq_handler, | 2436 | if (request_irq(p->irq, parport_irq_handler, |
2330 | irqflags, p->name, p)) { | 2437 | irqflags, p->name, p)) { |
2331 | printk (KERN_WARNING "%s: irq %d in use, " | 2438 | printk(KERN_WARNING "%s: irq %d in use, " |
2332 | "resorting to polled operation\n", | 2439 | "resorting to polled operation\n", |
2333 | p->name, p->irq); | 2440 | p->name, p->irq); |
2334 | p->irq = PARPORT_IRQ_NONE; | 2441 | p->irq = PARPORT_IRQ_NONE; |
@@ -2338,8 +2445,8 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2338 | #ifdef CONFIG_PARPORT_PC_FIFO | 2445 | #ifdef CONFIG_PARPORT_PC_FIFO |
2339 | #ifdef HAS_DMA | 2446 | #ifdef HAS_DMA |
2340 | if (p->dma != PARPORT_DMA_NONE) { | 2447 | if (p->dma != PARPORT_DMA_NONE) { |
2341 | if (request_dma (p->dma, p->name)) { | 2448 | if (request_dma(p->dma, p->name)) { |
2342 | printk (KERN_WARNING "%s: dma %d in use, " | 2449 | printk(KERN_WARNING "%s: dma %d in use, " |
2343 | "resorting to PIO operation\n", | 2450 | "resorting to PIO operation\n", |
2344 | p->name, p->dma); | 2451 | p->name, p->dma); |
2345 | p->dma = PARPORT_DMA_NONE; | 2452 | p->dma = PARPORT_DMA_NONE; |
@@ -2349,8 +2456,8 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2349 | PAGE_SIZE, | 2456 | PAGE_SIZE, |
2350 | &priv->dma_handle, | 2457 | &priv->dma_handle, |
2351 | GFP_KERNEL); | 2458 | GFP_KERNEL); |
2352 | if (! priv->dma_buf) { | 2459 | if (!priv->dma_buf) { |
2353 | printk (KERN_WARNING "%s: " | 2460 | printk(KERN_WARNING "%s: " |
2354 | "cannot get buffer for DMA, " | 2461 | "cannot get buffer for DMA, " |
2355 | "resorting to PIO operation\n", | 2462 | "resorting to PIO operation\n", |
2356 | p->name); | 2463 | p->name); |
@@ -2369,10 +2476,10 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2369 | * Put the ECP detected port in PS2 mode. | 2476 | * Put the ECP detected port in PS2 mode. |
2370 | * Do this also for ports that have ECR but don't do ECP. | 2477 | * Do this also for ports that have ECR but don't do ECP. |
2371 | */ | 2478 | */ |
2372 | ECR_WRITE (p, 0x34); | 2479 | ECR_WRITE(p, 0x34); |
2373 | 2480 | ||
2374 | parport_pc_write_data(p, 0); | 2481 | parport_pc_write_data(p, 0); |
2375 | parport_pc_data_forward (p); | 2482 | parport_pc_data_forward(p); |
2376 | 2483 | ||
2377 | /* Now that we've told the sharing engine about the port, and | 2484 | /* Now that we've told the sharing engine about the port, and |
2378 | found out its characteristics, let the high-level drivers | 2485 | found out its characteristics, let the high-level drivers |
@@ -2380,7 +2487,7 @@ struct parport *parport_pc_probe_port(unsigned long int base, | |||
2380 | spin_lock(&ports_lock); | 2487 | spin_lock(&ports_lock); |
2381 | list_add(&priv->list, &ports_list); | 2488 | list_add(&priv->list, &ports_list); |
2382 | spin_unlock(&ports_lock); | 2489 | spin_unlock(&ports_lock); |
2383 | parport_announce_port (p); | 2490 | parport_announce_port(p); |
2384 | 2491 | ||
2385 | return p; | 2492 | return p; |
2386 | 2493 | ||
@@ -2393,18 +2500,17 @@ out5: | |||
2393 | out4: | 2500 | out4: |
2394 | parport_put_port(p); | 2501 | parport_put_port(p); |
2395 | out3: | 2502 | out3: |
2396 | kfree (priv); | 2503 | kfree(priv); |
2397 | out2: | 2504 | out2: |
2398 | kfree (ops); | 2505 | kfree(ops); |
2399 | out1: | 2506 | out1: |
2400 | if (pdev) | 2507 | if (pdev) |
2401 | platform_device_unregister(pdev); | 2508 | platform_device_unregister(pdev); |
2402 | return NULL; | 2509 | return NULL; |
2403 | } | 2510 | } |
2511 | EXPORT_SYMBOL(parport_pc_probe_port); | ||
2404 | 2512 | ||
2405 | EXPORT_SYMBOL (parport_pc_probe_port); | 2513 | void parport_pc_unregister_port(struct parport *p) |
2406 | |||
2407 | void parport_pc_unregister_port (struct parport *p) | ||
2408 | { | 2514 | { |
2409 | struct parport_pc_private *priv = p->private_data; | 2515 | struct parport_pc_private *priv = p->private_data; |
2410 | struct parport_operations *ops = p->ops; | 2516 | struct parport_operations *ops = p->ops; |
@@ -2430,17 +2536,16 @@ void parport_pc_unregister_port (struct parport *p) | |||
2430 | priv->dma_buf, | 2536 | priv->dma_buf, |
2431 | priv->dma_handle); | 2537 | priv->dma_handle); |
2432 | #endif | 2538 | #endif |
2433 | kfree (p->private_data); | 2539 | kfree(p->private_data); |
2434 | parport_put_port(p); | 2540 | parport_put_port(p); |
2435 | kfree (ops); /* hope no-one cached it */ | 2541 | kfree(ops); /* hope no-one cached it */ |
2436 | } | 2542 | } |
2437 | 2543 | EXPORT_SYMBOL(parport_pc_unregister_port); | |
2438 | EXPORT_SYMBOL (parport_pc_unregister_port); | ||
2439 | 2544 | ||
2440 | #ifdef CONFIG_PCI | 2545 | #ifdef CONFIG_PCI |
2441 | 2546 | ||
2442 | /* ITE support maintained by Rich Liu <richliu@poorman.org> */ | 2547 | /* ITE support maintained by Rich Liu <richliu@poorman.org> */ |
2443 | static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq, | 2548 | static int __devinit sio_ite_8872_probe(struct pci_dev *pdev, int autoirq, |
2444 | int autodma, | 2549 | int autodma, |
2445 | const struct parport_pc_via_data *via) | 2550 | const struct parport_pc_via_data *via) |
2446 | { | 2551 | { |
@@ -2452,73 +2557,74 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq, | |||
2452 | int irq; | 2557 | int irq; |
2453 | int i; | 2558 | int i; |
2454 | 2559 | ||
2455 | DPRINTK (KERN_DEBUG "sio_ite_8872_probe()\n"); | 2560 | DPRINTK(KERN_DEBUG "sio_ite_8872_probe()\n"); |
2456 | 2561 | ||
2457 | // make sure which one chip | 2562 | /* make sure which one chip */ |
2458 | for(i = 0; i < 5; i++) { | 2563 | for (i = 0; i < 5; i++) { |
2459 | base_res = request_region(inta_addr[i], 32, "it887x"); | 2564 | base_res = request_region(inta_addr[i], 32, "it887x"); |
2460 | if (base_res) { | 2565 | if (base_res) { |
2461 | int test; | 2566 | int test; |
2462 | pci_write_config_dword (pdev, 0x60, | 2567 | pci_write_config_dword(pdev, 0x60, |
2463 | 0xe5000000 | inta_addr[i]); | 2568 | 0xe5000000 | inta_addr[i]); |
2464 | pci_write_config_dword (pdev, 0x78, | 2569 | pci_write_config_dword(pdev, 0x78, |
2465 | 0x00000000 | inta_addr[i]); | 2570 | 0x00000000 | inta_addr[i]); |
2466 | test = inb (inta_addr[i]); | 2571 | test = inb(inta_addr[i]); |
2467 | if (test != 0xff) break; | 2572 | if (test != 0xff) |
2573 | break; | ||
2468 | release_region(inta_addr[i], 0x8); | 2574 | release_region(inta_addr[i], 0x8); |
2469 | } | 2575 | } |
2470 | } | 2576 | } |
2471 | if(i >= 5) { | 2577 | if (i >= 5) { |
2472 | printk (KERN_INFO "parport_pc: cannot find ITE8872 INTA\n"); | 2578 | printk(KERN_INFO "parport_pc: cannot find ITE8872 INTA\n"); |
2473 | return 0; | 2579 | return 0; |
2474 | } | 2580 | } |
2475 | 2581 | ||
2476 | type = inb (inta_addr[i] + 0x18); | 2582 | type = inb(inta_addr[i] + 0x18); |
2477 | type &= 0x0f; | 2583 | type &= 0x0f; |
2478 | 2584 | ||
2479 | switch (type) { | 2585 | switch (type) { |
2480 | case 0x2: | 2586 | case 0x2: |
2481 | printk (KERN_INFO "parport_pc: ITE8871 found (1P)\n"); | 2587 | printk(KERN_INFO "parport_pc: ITE8871 found (1P)\n"); |
2482 | ite8872set = 0x64200000; | 2588 | ite8872set = 0x64200000; |
2483 | break; | 2589 | break; |
2484 | case 0xa: | 2590 | case 0xa: |
2485 | printk (KERN_INFO "parport_pc: ITE8875 found (1P)\n"); | 2591 | printk(KERN_INFO "parport_pc: ITE8875 found (1P)\n"); |
2486 | ite8872set = 0x64200000; | 2592 | ite8872set = 0x64200000; |
2487 | break; | 2593 | break; |
2488 | case 0xe: | 2594 | case 0xe: |
2489 | printk (KERN_INFO "parport_pc: ITE8872 found (2S1P)\n"); | 2595 | printk(KERN_INFO "parport_pc: ITE8872 found (2S1P)\n"); |
2490 | ite8872set = 0x64e00000; | 2596 | ite8872set = 0x64e00000; |
2491 | break; | 2597 | break; |
2492 | case 0x6: | 2598 | case 0x6: |
2493 | printk (KERN_INFO "parport_pc: ITE8873 found (1S)\n"); | 2599 | printk(KERN_INFO "parport_pc: ITE8873 found (1S)\n"); |
2494 | return 0; | 2600 | return 0; |
2495 | case 0x8: | 2601 | case 0x8: |
2496 | DPRINTK (KERN_DEBUG "parport_pc: ITE8874 found (2S)\n"); | 2602 | DPRINTK(KERN_DEBUG "parport_pc: ITE8874 found (2S)\n"); |
2497 | return 0; | 2603 | return 0; |
2498 | default: | 2604 | default: |
2499 | printk (KERN_INFO "parport_pc: unknown ITE887x\n"); | 2605 | printk(KERN_INFO "parport_pc: unknown ITE887x\n"); |
2500 | printk (KERN_INFO "parport_pc: please mail 'lspci -nvv' " | 2606 | printk(KERN_INFO "parport_pc: please mail 'lspci -nvv' " |
2501 | "output to Rich.Liu@ite.com.tw\n"); | 2607 | "output to Rich.Liu@ite.com.tw\n"); |
2502 | return 0; | 2608 | return 0; |
2503 | } | 2609 | } |
2504 | 2610 | ||
2505 | pci_read_config_byte (pdev, 0x3c, &ite8872_irq); | 2611 | pci_read_config_byte(pdev, 0x3c, &ite8872_irq); |
2506 | pci_read_config_dword (pdev, 0x1c, &ite8872_lpt); | 2612 | pci_read_config_dword(pdev, 0x1c, &ite8872_lpt); |
2507 | ite8872_lpt &= 0x0000ff00; | 2613 | ite8872_lpt &= 0x0000ff00; |
2508 | pci_read_config_dword (pdev, 0x20, &ite8872_lpthi); | 2614 | pci_read_config_dword(pdev, 0x20, &ite8872_lpthi); |
2509 | ite8872_lpthi &= 0x0000ff00; | 2615 | ite8872_lpthi &= 0x0000ff00; |
2510 | pci_write_config_dword (pdev, 0x6c, 0xe3000000 | ite8872_lpt); | 2616 | pci_write_config_dword(pdev, 0x6c, 0xe3000000 | ite8872_lpt); |
2511 | pci_write_config_dword (pdev, 0x70, 0xe3000000 | ite8872_lpthi); | 2617 | pci_write_config_dword(pdev, 0x70, 0xe3000000 | ite8872_lpthi); |
2512 | pci_write_config_dword (pdev, 0x80, (ite8872_lpthi<<16) | ite8872_lpt); | 2618 | pci_write_config_dword(pdev, 0x80, (ite8872_lpthi<<16) | ite8872_lpt); |
2513 | // SET SPP&EPP , Parallel Port NO DMA , Enable All Function | 2619 | /* SET SPP&EPP , Parallel Port NO DMA , Enable All Function */ |
2514 | // SET Parallel IRQ | 2620 | /* SET Parallel IRQ */ |
2515 | pci_write_config_dword (pdev, 0x9c, | 2621 | pci_write_config_dword(pdev, 0x9c, |
2516 | ite8872set | (ite8872_irq * 0x11111)); | 2622 | ite8872set | (ite8872_irq * 0x11111)); |
2517 | 2623 | ||
2518 | DPRINTK (KERN_DEBUG "ITE887x: The IRQ is %d.\n", ite8872_irq); | 2624 | 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", | 2625 | DPRINTK(KERN_DEBUG "ITE887x: The PARALLEL I/O port is 0x%x.\n", |
2520 | ite8872_lpt); | 2626 | ite8872_lpt); |
2521 | DPRINTK (KERN_DEBUG "ITE887x: The PARALLEL I/O porthi is 0x%x.\n", | 2627 | DPRINTK(KERN_DEBUG "ITE887x: The PARALLEL I/O porthi is 0x%x.\n", |
2522 | ite8872_lpthi); | 2628 | ite8872_lpthi); |
2523 | 2629 | ||
2524 | /* Let the user (or defaults) steer us away from interrupts */ | 2630 | /* Let the user (or defaults) steer us away from interrupts */ |
@@ -2530,14 +2636,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. | 2636 | * Release the resource so that parport_pc_probe_port can get it. |
2531 | */ | 2637 | */ |
2532 | release_resource(base_res); | 2638 | release_resource(base_res); |
2533 | if (parport_pc_probe_port (ite8872_lpt, ite8872_lpthi, | 2639 | if (parport_pc_probe_port(ite8872_lpt, ite8872_lpthi, |
2534 | irq, PARPORT_DMA_NONE, &pdev->dev, 0)) { | 2640 | irq, PARPORT_DMA_NONE, &pdev->dev, 0)) { |
2535 | printk (KERN_INFO | 2641 | printk(KERN_INFO |
2536 | "parport_pc: ITE 8872 parallel port: io=0x%X", | 2642 | "parport_pc: ITE 8872 parallel port: io=0x%X", |
2537 | ite8872_lpt); | 2643 | ite8872_lpt); |
2538 | if (irq != PARPORT_IRQ_NONE) | 2644 | if (irq != PARPORT_IRQ_NONE) |
2539 | printk (", irq=%d", irq); | 2645 | printk(", irq=%d", irq); |
2540 | printk ("\n"); | 2646 | printk("\n"); |
2541 | return 1; | 2647 | return 1; |
2542 | } | 2648 | } |
2543 | 2649 | ||
@@ -2546,7 +2652,7 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq, | |||
2546 | 2652 | ||
2547 | /* VIA 8231 support by Pavel Fedin <sonic_amiga@rambler.ru> | 2653 | /* VIA 8231 support by Pavel Fedin <sonic_amiga@rambler.ru> |
2548 | based on VIA 686a support code by Jeff Garzik <jgarzik@pobox.com> */ | 2654 | based on VIA 686a support code by Jeff Garzik <jgarzik@pobox.com> */ |
2549 | static int __devinitdata parport_init_mode = 0; | 2655 | static int __devinitdata parport_init_mode; |
2550 | 2656 | ||
2551 | /* Data for two known VIA chips */ | 2657 | /* Data for two known VIA chips */ |
2552 | static struct parport_pc_via_data via_686a_data __devinitdata = { | 2658 | static struct parport_pc_via_data via_686a_data __devinitdata = { |
@@ -2568,7 +2674,7 @@ static struct parport_pc_via_data via_8231_data __devinitdata = { | |||
2568 | 0xF6 | 2674 | 0xF6 |
2569 | }; | 2675 | }; |
2570 | 2676 | ||
2571 | static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, | 2677 | static int __devinit sio_via_probe(struct pci_dev *pdev, int autoirq, |
2572 | int autodma, | 2678 | int autodma, |
2573 | const struct parport_pc_via_data *via) | 2679 | const struct parport_pc_via_data *via) |
2574 | { | 2680 | { |
@@ -2580,38 +2686,38 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, | |||
2580 | 2686 | ||
2581 | printk(KERN_DEBUG "parport_pc: VIA 686A/8231 detected\n"); | 2687 | printk(KERN_DEBUG "parport_pc: VIA 686A/8231 detected\n"); |
2582 | 2688 | ||
2583 | switch(parport_init_mode) | 2689 | switch (parport_init_mode) { |
2584 | { | ||
2585 | case 1: | 2690 | case 1: |
2586 | printk(KERN_DEBUG "parport_pc: setting SPP mode\n"); | 2691 | printk(KERN_DEBUG "parport_pc: setting SPP mode\n"); |
2587 | siofunc = VIA_FUNCTION_PARPORT_SPP; | 2692 | siofunc = VIA_FUNCTION_PARPORT_SPP; |
2588 | break; | 2693 | break; |
2589 | case 2: | 2694 | case 2: |
2590 | printk(KERN_DEBUG "parport_pc: setting PS/2 mode\n"); | 2695 | printk(KERN_DEBUG "parport_pc: setting PS/2 mode\n"); |
2591 | siofunc = VIA_FUNCTION_PARPORT_SPP; | 2696 | siofunc = VIA_FUNCTION_PARPORT_SPP; |
2592 | ppcontrol = VIA_PARPORT_BIDIR; | 2697 | ppcontrol = VIA_PARPORT_BIDIR; |
2593 | break; | 2698 | break; |
2594 | case 3: | 2699 | case 3: |
2595 | printk(KERN_DEBUG "parport_pc: setting EPP mode\n"); | 2700 | printk(KERN_DEBUG "parport_pc: setting EPP mode\n"); |
2596 | siofunc = VIA_FUNCTION_PARPORT_EPP; | 2701 | siofunc = VIA_FUNCTION_PARPORT_EPP; |
2597 | ppcontrol = VIA_PARPORT_BIDIR; | 2702 | ppcontrol = VIA_PARPORT_BIDIR; |
2598 | have_epp = 1; | 2703 | have_epp = 1; |
2599 | break; | 2704 | break; |
2600 | case 4: | 2705 | case 4: |
2601 | printk(KERN_DEBUG "parport_pc: setting ECP mode\n"); | 2706 | printk(KERN_DEBUG "parport_pc: setting ECP mode\n"); |
2602 | siofunc = VIA_FUNCTION_PARPORT_ECP; | 2707 | siofunc = VIA_FUNCTION_PARPORT_ECP; |
2603 | ppcontrol = VIA_PARPORT_BIDIR; | 2708 | ppcontrol = VIA_PARPORT_BIDIR; |
2604 | break; | 2709 | break; |
2605 | case 5: | 2710 | case 5: |
2606 | printk(KERN_DEBUG "parport_pc: setting EPP+ECP mode\n"); | 2711 | printk(KERN_DEBUG "parport_pc: setting EPP+ECP mode\n"); |
2607 | siofunc = VIA_FUNCTION_PARPORT_ECP; | 2712 | siofunc = VIA_FUNCTION_PARPORT_ECP; |
2608 | ppcontrol = VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP; | 2713 | ppcontrol = VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP; |
2609 | have_epp = 1; | 2714 | have_epp = 1; |
2610 | break; | 2715 | break; |
2611 | default: | 2716 | default: |
2612 | printk(KERN_DEBUG "parport_pc: probing current configuration\n"); | 2717 | printk(KERN_DEBUG |
2613 | siofunc = VIA_FUNCTION_PROBE; | 2718 | "parport_pc: probing current configuration\n"); |
2614 | break; | 2719 | siofunc = VIA_FUNCTION_PROBE; |
2720 | break; | ||
2615 | } | 2721 | } |
2616 | /* | 2722 | /* |
2617 | * unlock super i/o configuration | 2723 | * unlock super i/o configuration |
@@ -2622,38 +2728,36 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, | |||
2622 | 2728 | ||
2623 | /* Bits 1-0: Parallel Port Mode / Enable */ | 2729 | /* Bits 1-0: Parallel Port Mode / Enable */ |
2624 | outb(via->viacfg_function, VIA_CONFIG_INDEX); | 2730 | outb(via->viacfg_function, VIA_CONFIG_INDEX); |
2625 | tmp = inb (VIA_CONFIG_DATA); | 2731 | tmp = inb(VIA_CONFIG_DATA); |
2626 | /* Bit 5: EPP+ECP enable; bit 7: PS/2 bidirectional port enable */ | 2732 | /* Bit 5: EPP+ECP enable; bit 7: PS/2 bidirectional port enable */ |
2627 | outb(via->viacfg_parport_control, VIA_CONFIG_INDEX); | 2733 | outb(via->viacfg_parport_control, VIA_CONFIG_INDEX); |
2628 | tmp2 = inb (VIA_CONFIG_DATA); | 2734 | tmp2 = inb(VIA_CONFIG_DATA); |
2629 | if (siofunc == VIA_FUNCTION_PROBE) | 2735 | if (siofunc == VIA_FUNCTION_PROBE) { |
2630 | { | 2736 | siofunc = tmp & VIA_FUNCTION_PARPORT_DISABLE; |
2631 | siofunc = tmp & VIA_FUNCTION_PARPORT_DISABLE; | 2737 | ppcontrol = tmp2; |
2632 | ppcontrol = tmp2; | 2738 | } else { |
2739 | tmp &= ~VIA_FUNCTION_PARPORT_DISABLE; | ||
2740 | tmp |= siofunc; | ||
2741 | outb(via->viacfg_function, VIA_CONFIG_INDEX); | ||
2742 | outb(tmp, VIA_CONFIG_DATA); | ||
2743 | tmp2 &= ~(VIA_PARPORT_BIDIR|VIA_PARPORT_ECPEPP); | ||
2744 | tmp2 |= ppcontrol; | ||
2745 | outb(via->viacfg_parport_control, VIA_CONFIG_INDEX); | ||
2746 | outb(tmp2, VIA_CONFIG_DATA); | ||
2633 | } | 2747 | } |
2634 | else | 2748 | |
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 */ | 2749 | /* Parallel Port I/O Base Address, bits 9-2 */ |
2647 | outb(via->viacfg_parport_base, VIA_CONFIG_INDEX); | 2750 | outb(via->viacfg_parport_base, VIA_CONFIG_INDEX); |
2648 | port1 = inb(VIA_CONFIG_DATA) << 2; | 2751 | port1 = inb(VIA_CONFIG_DATA) << 2; |
2649 | 2752 | ||
2650 | printk (KERN_DEBUG "parport_pc: Current parallel port base: 0x%X\n",port1); | 2753 | printk(KERN_DEBUG "parport_pc: Current parallel port base: 0x%X\n", |
2651 | if ((port1 == 0x3BC) && have_epp) | 2754 | port1); |
2652 | { | 2755 | if (port1 == 0x3BC && have_epp) { |
2653 | outb(via->viacfg_parport_base, VIA_CONFIG_INDEX); | 2756 | outb(via->viacfg_parport_base, VIA_CONFIG_INDEX); |
2654 | outb((0x378 >> 2), VIA_CONFIG_DATA); | 2757 | outb((0x378 >> 2), VIA_CONFIG_DATA); |
2655 | printk(KERN_DEBUG "parport_pc: Parallel port base changed to 0x378\n"); | 2758 | printk(KERN_DEBUG |
2656 | port1 = 0x378; | 2759 | "parport_pc: Parallel port base changed to 0x378\n"); |
2760 | port1 = 0x378; | ||
2657 | } | 2761 | } |
2658 | 2762 | ||
2659 | /* | 2763 | /* |
@@ -2667,36 +2771,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"); | 2771 | printk(KERN_INFO "parport_pc: VIA parallel port disabled in BIOS\n"); |
2668 | return 0; | 2772 | return 0; |
2669 | } | 2773 | } |
2670 | 2774 | ||
2671 | /* Bits 7-4: PnP Routing for Parallel Port IRQ */ | 2775 | /* Bits 7-4: PnP Routing for Parallel Port IRQ */ |
2672 | pci_read_config_byte(pdev, via->via_pci_parport_irq_reg, &tmp); | 2776 | pci_read_config_byte(pdev, via->via_pci_parport_irq_reg, &tmp); |
2673 | irq = ((tmp & VIA_IRQCONTROL_PARALLEL) >> 4); | 2777 | irq = ((tmp & VIA_IRQCONTROL_PARALLEL) >> 4); |
2674 | 2778 | ||
2675 | if (siofunc == VIA_FUNCTION_PARPORT_ECP) | 2779 | if (siofunc == VIA_FUNCTION_PARPORT_ECP) { |
2676 | { | 2780 | /* Bits 3-2: PnP Routing for Parallel Port DMA */ |
2677 | /* Bits 3-2: PnP Routing for Parallel Port DMA */ | 2781 | 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); | 2782 | dma = ((tmp & VIA_DMACONTROL_PARALLEL) >> 2); |
2679 | dma = ((tmp & VIA_DMACONTROL_PARALLEL) >> 2); | 2783 | } else |
2680 | } | 2784 | /* if ECP not enabled, DMA is not enabled, assumed |
2681 | else | 2785 | bogus 'dma' value */ |
2682 | /* if ECP not enabled, DMA is not enabled, assumed bogus 'dma' value */ | 2786 | dma = PARPORT_DMA_NONE; |
2683 | dma = PARPORT_DMA_NONE; | ||
2684 | 2787 | ||
2685 | /* Let the user (or defaults) steer us away from interrupts and DMA */ | 2788 | /* Let the user (or defaults) steer us away from interrupts and DMA */ |
2686 | if (autoirq == PARPORT_IRQ_NONE) { | 2789 | if (autoirq == PARPORT_IRQ_NONE) { |
2687 | irq = PARPORT_IRQ_NONE; | 2790 | irq = PARPORT_IRQ_NONE; |
2688 | dma = PARPORT_DMA_NONE; | 2791 | dma = PARPORT_DMA_NONE; |
2689 | } | 2792 | } |
2690 | if (autodma == PARPORT_DMA_NONE) | 2793 | if (autodma == PARPORT_DMA_NONE) |
2691 | dma = PARPORT_DMA_NONE; | 2794 | dma = PARPORT_DMA_NONE; |
2692 | 2795 | ||
2693 | switch (port1) { | 2796 | switch (port1) { |
2694 | case 0x3bc: port2 = 0x7bc; break; | 2797 | case 0x3bc: |
2695 | case 0x378: port2 = 0x778; break; | 2798 | port2 = 0x7bc; break; |
2696 | case 0x278: port2 = 0x678; break; | 2799 | case 0x378: |
2800 | port2 = 0x778; break; | ||
2801 | case 0x278: | ||
2802 | port2 = 0x678; break; | ||
2697 | default: | 2803 | default: |
2698 | printk(KERN_INFO "parport_pc: Weird VIA parport base 0x%X, ignoring\n", | 2804 | printk(KERN_INFO |
2699 | port1); | 2805 | "parport_pc: Weird VIA parport base 0x%X, ignoring\n", |
2806 | port1); | ||
2700 | return 0; | 2807 | return 0; |
2701 | } | 2808 | } |
2702 | 2809 | ||
@@ -2714,17 +2821,17 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, | |||
2714 | } | 2821 | } |
2715 | 2822 | ||
2716 | /* finally, do the probe with values obtained */ | 2823 | /* finally, do the probe with values obtained */ |
2717 | if (parport_pc_probe_port (port1, port2, irq, dma, &pdev->dev, 0)) { | 2824 | if (parport_pc_probe_port(port1, port2, irq, dma, &pdev->dev, 0)) { |
2718 | printk (KERN_INFO | 2825 | printk(KERN_INFO |
2719 | "parport_pc: VIA parallel port: io=0x%X", port1); | 2826 | "parport_pc: VIA parallel port: io=0x%X", port1); |
2720 | if (irq != PARPORT_IRQ_NONE) | 2827 | if (irq != PARPORT_IRQ_NONE) |
2721 | printk (", irq=%d", irq); | 2828 | printk(", irq=%d", irq); |
2722 | if (dma != PARPORT_DMA_NONE) | 2829 | if (dma != PARPORT_DMA_NONE) |
2723 | printk (", dma=%d", dma); | 2830 | printk(", dma=%d", dma); |
2724 | printk ("\n"); | 2831 | printk("\n"); |
2725 | return 1; | 2832 | return 1; |
2726 | } | 2833 | } |
2727 | 2834 | ||
2728 | printk(KERN_WARNING "parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n", | 2835 | printk(KERN_WARNING "parport_pc: Strange, can't probe VIA parallel port: io=0x%X, irq=%d, dma=%d\n", |
2729 | port1, irq, dma); | 2836 | port1, irq, dma); |
2730 | return 0; | 2837 | return 0; |
@@ -2732,8 +2839,8 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, | |||
2732 | 2839 | ||
2733 | 2840 | ||
2734 | enum parport_pc_sio_types { | 2841 | enum parport_pc_sio_types { |
2735 | sio_via_686a = 0, /* Via VT82C686A motherboard Super I/O */ | 2842 | sio_via_686a = 0, /* Via VT82C686A motherboard Super I/O */ |
2736 | sio_via_8231, /* Via VT8231 south bridge integrated Super IO */ | 2843 | sio_via_8231, /* Via VT8231 south bridge integrated Super IO */ |
2737 | sio_ite_8872, | 2844 | sio_ite_8872, |
2738 | last_sio | 2845 | last_sio |
2739 | }; | 2846 | }; |
@@ -2800,19 +2907,20 @@ enum parport_pc_pci_cards { | |||
2800 | netmos_9755, | 2907 | netmos_9755, |
2801 | netmos_9805, | 2908 | netmos_9805, |
2802 | netmos_9815, | 2909 | netmos_9815, |
2910 | netmos_9901, | ||
2803 | quatech_sppxp100, | 2911 | quatech_sppxp100, |
2804 | }; | 2912 | }; |
2805 | 2913 | ||
2806 | 2914 | ||
2807 | /* each element directly indexed from enum list, above | 2915 | /* each element directly indexed from enum list, above |
2808 | * (but offset by last_sio) */ | 2916 | * (but offset by last_sio) */ |
2809 | static struct parport_pc_pci { | 2917 | static struct parport_pc_pci { |
2810 | int numports; | 2918 | int numports; |
2811 | struct { /* BAR (base address registers) numbers in the config | 2919 | struct { /* BAR (base address registers) numbers in the config |
2812 | space header */ | 2920 | space header */ |
2813 | int lo; | 2921 | int lo; |
2814 | int hi; /* -1 if not there, >6 for offset-method (max | 2922 | int hi; |
2815 | BAR is 6) */ | 2923 | /* -1 if not there, >6 for offset-method (max BAR is 6) */ |
2816 | } addr[4]; | 2924 | } addr[4]; |
2817 | 2925 | ||
2818 | /* If set, this is called immediately after pci_enable_device. | 2926 | /* If set, this is called immediately after pci_enable_device. |
@@ -2857,7 +2965,7 @@ static struct parport_pc_pci { | |||
2857 | /* timedia_4018 */ { 2, { { 0, 1 }, { 2, 3 }, } }, | 2965 | /* timedia_4018 */ { 2, { { 0, 1 }, { 2, 3 }, } }, |
2858 | /* timedia_9018a */ { 2, { { 0, 1 }, { 2, 3 }, } }, | 2966 | /* timedia_9018a */ { 2, { { 0, 1 }, { 2, 3 }, } }, |
2859 | /* SYBA uses fixed offsets in | 2967 | /* SYBA uses fixed offsets in |
2860 | a 1K io window */ | 2968 | a 1K io window */ |
2861 | /* syba_2p_epp AP138B */ { 2, { { 0, 0x078 }, { 0, 0x178 }, } }, | 2969 | /* syba_2p_epp AP138B */ { 2, { { 0, 0x078 }, { 0, 0x178 }, } }, |
2862 | /* syba_1p_ecp W83787 */ { 1, { { 0, 0x078 }, } }, | 2970 | /* syba_1p_ecp W83787 */ { 1, { { 0, 0x078 }, } }, |
2863 | /* titan_010l */ { 1, { { 3, -1 }, } }, | 2971 | /* titan_010l */ { 1, { { 3, -1 }, } }, |
@@ -2873,11 +2981,14 @@ static struct parport_pc_pci { | |||
2873 | /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, } }, | 2981 | /* oxsemi_pcie_pport */ { 1, { { 0, 1 }, } }, |
2874 | /* aks_0100 */ { 1, { { 0, -1 }, } }, | 2982 | /* aks_0100 */ { 1, { { 0, -1 }, } }, |
2875 | /* mobility_pp */ { 1, { { 0, 1 }, } }, | 2983 | /* mobility_pp */ { 1, { { 0, 1 }, } }, |
2876 | /* netmos_9705 */ { 1, { { 0, -1 }, } }, /* untested */ | 2984 | |
2877 | /* netmos_9715 */ { 2, { { 0, 1 }, { 2, 3 },} }, /* untested */ | 2985 | /* The netmos entries below are untested */ |
2878 | /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} }, /* untested */ | 2986 | /* netmos_9705 */ { 1, { { 0, -1 }, } }, |
2879 | /* netmos_9805 */ { 1, { { 0, -1 }, } }, /* untested */ | 2987 | /* netmos_9715 */ { 2, { { 0, 1 }, { 2, 3 },} }, |
2880 | /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */ | 2988 | /* netmos_9755 */ { 2, { { 0, 1 }, { 2, 3 },} }, |
2989 | /* netmos_9805 */ { 1, { { 0, -1 }, } }, | ||
2990 | /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, | ||
2991 | /* netmos_9901 */ { 1, { { 0, -1 }, } }, | ||
2881 | /* quatech_sppxp100 */ { 1, { { 0, 1 }, } }, | 2992 | /* quatech_sppxp100 */ { 1, { { 0, 1 }, } }, |
2882 | }; | 2993 | }; |
2883 | 2994 | ||
@@ -2906,7 +3017,7 @@ static const struct pci_device_id parport_pc_pci_tbl[] = { | |||
2906 | { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_BOCA_IOPPAR, | 3017 | { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_BOCA_IOPPAR, |
2907 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, boca_ioppar }, | 3018 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, boca_ioppar }, |
2908 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, | 3019 | { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, |
2909 | PCI_SUBVENDOR_ID_EXSYS, PCI_SUBDEVICE_ID_EXSYS_4014, 0,0, plx_9050 }, | 3020 | PCI_SUBVENDOR_ID_EXSYS, PCI_SUBDEVICE_ID_EXSYS_4014, 0, 0, plx_9050 }, |
2910 | /* PCI_VENDOR_ID_TIMEDIA/SUNIX has many differing cards ...*/ | 3021 | /* PCI_VENDOR_ID_TIMEDIA/SUNIX has many differing cards ...*/ |
2911 | { 0x1409, 0x7168, 0x1409, 0x4078, 0, 0, timedia_4078a }, | 3022 | { 0x1409, 0x7168, 0x1409, 0x4078, 0, 0, timedia_4078a }, |
2912 | { 0x1409, 0x7168, 0x1409, 0x4079, 0, 0, timedia_4079h }, | 3023 | { 0x1409, 0x7168, 0x1409, 0x4079, 0, 0, timedia_4079h }, |
@@ -2940,7 +3051,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = { | |||
2940 | { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 }, | 3051 | { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 }, |
2941 | { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 }, | 3052 | { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 }, |
2942 | /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ | 3053 | /* 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 */ | 3054 | /* AFAVLAB_TK9902 */ |
3055 | { 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}, | 3056 | { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p}, |
2945 | { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP, | 3057 | { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP, |
2946 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 }, | 3058 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 }, |
@@ -2978,19 +3090,21 @@ static const struct pci_device_id parport_pc_pci_tbl[] = { | |||
2978 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9805 }, | 3090 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9805 }, |
2979 | { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9815, | 3091 | { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9815, |
2980 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9815 }, | 3092 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9815 }, |
3093 | { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9901, | ||
3094 | 0xA000, 0x2000, 0, 0, netmos_9901 }, | ||
2981 | /* Quatech SPPXP-100 Parallel port PCI ExpressCard */ | 3095 | /* Quatech SPPXP-100 Parallel port PCI ExpressCard */ |
2982 | { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SPPXP_100, | 3096 | { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SPPXP_100, |
2983 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 }, | 3097 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 }, |
2984 | { 0, } /* terminate list */ | 3098 | { 0, } /* terminate list */ |
2985 | }; | 3099 | }; |
2986 | MODULE_DEVICE_TABLE(pci,parport_pc_pci_tbl); | 3100 | MODULE_DEVICE_TABLE(pci, parport_pc_pci_tbl); |
2987 | 3101 | ||
2988 | struct pci_parport_data { | 3102 | struct pci_parport_data { |
2989 | int num; | 3103 | int num; |
2990 | struct parport *ports[2]; | 3104 | struct parport *ports[2]; |
2991 | }; | 3105 | }; |
2992 | 3106 | ||
2993 | static int parport_pc_pci_probe (struct pci_dev *dev, | 3107 | static int parport_pc_pci_probe(struct pci_dev *dev, |
2994 | const struct pci_device_id *id) | 3108 | const struct pci_device_id *id) |
2995 | { | 3109 | { |
2996 | int err, count, n, i = id->driver_data; | 3110 | int err, count, n, i = id->driver_data; |
@@ -3003,7 +3117,8 @@ static int parport_pc_pci_probe (struct pci_dev *dev, | |||
3003 | /* This is a PCI card */ | 3117 | /* This is a PCI card */ |
3004 | i -= last_sio; | 3118 | i -= last_sio; |
3005 | count = 0; | 3119 | count = 0; |
3006 | if ((err = pci_enable_device (dev)) != 0) | 3120 | err = pci_enable_device(dev); |
3121 | if (err) | ||
3007 | return err; | 3122 | return err; |
3008 | 3123 | ||
3009 | data = kmalloc(sizeof(struct pci_parport_data), GFP_KERNEL); | 3124 | data = kmalloc(sizeof(struct pci_parport_data), GFP_KERNEL); |
@@ -3011,7 +3126,7 @@ static int parport_pc_pci_probe (struct pci_dev *dev, | |||
3011 | return -ENOMEM; | 3126 | return -ENOMEM; |
3012 | 3127 | ||
3013 | if (cards[i].preinit_hook && | 3128 | if (cards[i].preinit_hook && |
3014 | cards[i].preinit_hook (dev, PARPORT_IRQ_NONE, PARPORT_DMA_NONE)) { | 3129 | cards[i].preinit_hook(dev, PARPORT_IRQ_NONE, PARPORT_DMA_NONE)) { |
3015 | kfree(data); | 3130 | kfree(data); |
3016 | return -ENODEV; | 3131 | return -ENODEV; |
3017 | } | 3132 | } |
@@ -3021,25 +3136,25 @@ static int parport_pc_pci_probe (struct pci_dev *dev, | |||
3021 | int hi = cards[i].addr[n].hi; | 3136 | int hi = cards[i].addr[n].hi; |
3022 | int irq; | 3137 | int irq; |
3023 | unsigned long io_lo, io_hi; | 3138 | unsigned long io_lo, io_hi; |
3024 | io_lo = pci_resource_start (dev, lo); | 3139 | io_lo = pci_resource_start(dev, lo); |
3025 | io_hi = 0; | 3140 | io_hi = 0; |
3026 | if ((hi >= 0) && (hi <= 6)) | 3141 | if ((hi >= 0) && (hi <= 6)) |
3027 | io_hi = pci_resource_start (dev, hi); | 3142 | io_hi = pci_resource_start(dev, hi); |
3028 | else if (hi > 6) | 3143 | else if (hi > 6) |
3029 | io_lo += hi; /* Reinterpret the meaning of | 3144 | io_lo += hi; /* Reinterpret the meaning of |
3030 | "hi" as an offset (see SYBA | 3145 | "hi" as an offset (see SYBA |
3031 | def.) */ | 3146 | def.) */ |
3032 | /* TODO: test if sharing interrupts works */ | 3147 | /* TODO: test if sharing interrupts works */ |
3033 | irq = dev->irq; | 3148 | irq = dev->irq; |
3034 | if (irq == IRQ_NONE) { | 3149 | if (irq == IRQ_NONE) { |
3035 | printk (KERN_DEBUG | 3150 | printk(KERN_DEBUG |
3036 | "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx)\n", | 3151 | "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx)\n", |
3037 | parport_pc_pci_tbl[i + last_sio].vendor, | 3152 | parport_pc_pci_tbl[i + last_sio].vendor, |
3038 | parport_pc_pci_tbl[i + last_sio].device, | 3153 | parport_pc_pci_tbl[i + last_sio].device, |
3039 | io_lo, io_hi); | 3154 | io_lo, io_hi); |
3040 | irq = PARPORT_IRQ_NONE; | 3155 | irq = PARPORT_IRQ_NONE; |
3041 | } else { | 3156 | } else { |
3042 | printk (KERN_DEBUG | 3157 | printk(KERN_DEBUG |
3043 | "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx), IRQ %d\n", | 3158 | "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx), IRQ %d\n", |
3044 | parport_pc_pci_tbl[i + last_sio].vendor, | 3159 | parport_pc_pci_tbl[i + last_sio].vendor, |
3045 | parport_pc_pci_tbl[i + last_sio].device, | 3160 | parport_pc_pci_tbl[i + last_sio].device, |
@@ -3056,7 +3171,7 @@ static int parport_pc_pci_probe (struct pci_dev *dev, | |||
3056 | data->num = count; | 3171 | data->num = count; |
3057 | 3172 | ||
3058 | if (cards[i].postinit_hook) | 3173 | if (cards[i].postinit_hook) |
3059 | cards[i].postinit_hook (dev, count == 0); | 3174 | cards[i].postinit_hook(dev, count == 0); |
3060 | 3175 | ||
3061 | if (count) { | 3176 | if (count) { |
3062 | pci_set_drvdata(dev, data); | 3177 | pci_set_drvdata(dev, data); |
@@ -3090,7 +3205,7 @@ static struct pci_driver parport_pc_pci_driver = { | |||
3090 | .remove = __devexit_p(parport_pc_pci_remove), | 3205 | .remove = __devexit_p(parport_pc_pci_remove), |
3091 | }; | 3206 | }; |
3092 | 3207 | ||
3093 | static int __init parport_pc_init_superio (int autoirq, int autodma) | 3208 | static int __init parport_pc_init_superio(int autoirq, int autodma) |
3094 | { | 3209 | { |
3095 | const struct pci_device_id *id; | 3210 | const struct pci_device_id *id; |
3096 | struct pci_dev *pdev = NULL; | 3211 | struct pci_dev *pdev = NULL; |
@@ -3101,8 +3216,9 @@ static int __init parport_pc_init_superio (int autoirq, int autodma) | |||
3101 | if (id == NULL || id->driver_data >= last_sio) | 3216 | if (id == NULL || id->driver_data >= last_sio) |
3102 | continue; | 3217 | continue; |
3103 | 3218 | ||
3104 | if (parport_pc_superio_info[id->driver_data].probe | 3219 | if (parport_pc_superio_info[id->driver_data].probe( |
3105 | (pdev, autoirq, autodma,parport_pc_superio_info[id->driver_data].via)) { | 3220 | pdev, autoirq, autodma, |
3221 | parport_pc_superio_info[id->driver_data].via)) { | ||
3106 | ret++; | 3222 | ret++; |
3107 | } | 3223 | } |
3108 | } | 3224 | } |
@@ -3111,7 +3227,10 @@ static int __init parport_pc_init_superio (int autoirq, int autodma) | |||
3111 | } | 3227 | } |
3112 | #else | 3228 | #else |
3113 | static struct pci_driver parport_pc_pci_driver; | 3229 | static struct pci_driver parport_pc_pci_driver; |
3114 | static int __init parport_pc_init_superio(int autoirq, int autodma) {return 0;} | 3230 | static int __init parport_pc_init_superio(int autoirq, int autodma) |
3231 | { | ||
3232 | return 0; | ||
3233 | } | ||
3115 | #endif /* CONFIG_PCI */ | 3234 | #endif /* CONFIG_PCI */ |
3116 | 3235 | ||
3117 | #ifdef CONFIG_PNP | 3236 | #ifdef CONFIG_PNP |
@@ -3124,44 +3243,45 @@ static const struct pnp_device_id parport_pc_pnp_tbl[] = { | |||
3124 | { } | 3243 | { } |
3125 | }; | 3244 | }; |
3126 | 3245 | ||
3127 | MODULE_DEVICE_TABLE(pnp,parport_pc_pnp_tbl); | 3246 | MODULE_DEVICE_TABLE(pnp, parport_pc_pnp_tbl); |
3128 | 3247 | ||
3129 | static int parport_pc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id) | 3248 | static int parport_pc_pnp_probe(struct pnp_dev *dev, |
3249 | const struct pnp_device_id *id) | ||
3130 | { | 3250 | { |
3131 | struct parport *pdata; | 3251 | struct parport *pdata; |
3132 | unsigned long io_lo, io_hi; | 3252 | unsigned long io_lo, io_hi; |
3133 | int dma, irq; | 3253 | int dma, irq; |
3134 | 3254 | ||
3135 | if (pnp_port_valid(dev,0) && | 3255 | if (pnp_port_valid(dev, 0) && |
3136 | !(pnp_port_flags(dev,0) & IORESOURCE_DISABLED)) { | 3256 | !(pnp_port_flags(dev, 0) & IORESOURCE_DISABLED)) { |
3137 | io_lo = pnp_port_start(dev,0); | 3257 | io_lo = pnp_port_start(dev, 0); |
3138 | } else | 3258 | } else |
3139 | return -EINVAL; | 3259 | return -EINVAL; |
3140 | 3260 | ||
3141 | if (pnp_port_valid(dev,1) && | 3261 | if (pnp_port_valid(dev, 1) && |
3142 | !(pnp_port_flags(dev,1) & IORESOURCE_DISABLED)) { | 3262 | !(pnp_port_flags(dev, 1) & IORESOURCE_DISABLED)) { |
3143 | io_hi = pnp_port_start(dev,1); | 3263 | io_hi = pnp_port_start(dev, 1); |
3144 | } else | 3264 | } else |
3145 | io_hi = 0; | 3265 | io_hi = 0; |
3146 | 3266 | ||
3147 | if (pnp_irq_valid(dev,0) && | 3267 | if (pnp_irq_valid(dev, 0) && |
3148 | !(pnp_irq_flags(dev,0) & IORESOURCE_DISABLED)) { | 3268 | !(pnp_irq_flags(dev, 0) & IORESOURCE_DISABLED)) { |
3149 | irq = pnp_irq(dev,0); | 3269 | irq = pnp_irq(dev, 0); |
3150 | } else | 3270 | } else |
3151 | irq = PARPORT_IRQ_NONE; | 3271 | irq = PARPORT_IRQ_NONE; |
3152 | 3272 | ||
3153 | if (pnp_dma_valid(dev,0) && | 3273 | if (pnp_dma_valid(dev, 0) && |
3154 | !(pnp_dma_flags(dev,0) & IORESOURCE_DISABLED)) { | 3274 | !(pnp_dma_flags(dev, 0) & IORESOURCE_DISABLED)) { |
3155 | dma = pnp_dma(dev,0); | 3275 | dma = pnp_dma(dev, 0); |
3156 | } else | 3276 | } else |
3157 | dma = PARPORT_DMA_NONE; | 3277 | dma = PARPORT_DMA_NONE; |
3158 | 3278 | ||
3159 | dev_info(&dev->dev, "reported by %s\n", dev->protocol->name); | 3279 | dev_info(&dev->dev, "reported by %s\n", dev->protocol->name); |
3160 | if (!(pdata = parport_pc_probe_port(io_lo, io_hi, | 3280 | pdata = parport_pc_probe_port(io_lo, io_hi, irq, dma, &dev->dev, 0); |
3161 | irq, dma, &dev->dev, 0))) | 3281 | if (pdata == NULL) |
3162 | return -ENODEV; | 3282 | return -ENODEV; |
3163 | 3283 | ||
3164 | pnp_set_drvdata(dev,pdata); | 3284 | pnp_set_drvdata(dev, pdata); |
3165 | return 0; | 3285 | return 0; |
3166 | } | 3286 | } |
3167 | 3287 | ||
@@ -3203,7 +3323,7 @@ static struct platform_driver parport_pc_platform_driver = { | |||
3203 | 3323 | ||
3204 | /* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */ | 3324 | /* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */ |
3205 | static int __devinit __attribute__((unused)) | 3325 | static int __devinit __attribute__((unused)) |
3206 | parport_pc_find_isa_ports (int autoirq, int autodma) | 3326 | parport_pc_find_isa_ports(int autoirq, int autodma) |
3207 | { | 3327 | { |
3208 | int count = 0; | 3328 | int count = 0; |
3209 | 3329 | ||
@@ -3227,7 +3347,7 @@ parport_pc_find_isa_ports (int autoirq, int autodma) | |||
3227 | * autoirq is PARPORT_IRQ_NONE, PARPORT_IRQ_AUTO, or PARPORT_IRQ_PROBEONLY | 3347 | * autoirq is PARPORT_IRQ_NONE, PARPORT_IRQ_AUTO, or PARPORT_IRQ_PROBEONLY |
3228 | * autodma is PARPORT_DMA_NONE or PARPORT_DMA_AUTO | 3348 | * autodma is PARPORT_DMA_NONE or PARPORT_DMA_AUTO |
3229 | */ | 3349 | */ |
3230 | static void __init parport_pc_find_ports (int autoirq, int autodma) | 3350 | static void __init parport_pc_find_ports(int autoirq, int autodma) |
3231 | { | 3351 | { |
3232 | int count = 0, err; | 3352 | int count = 0, err; |
3233 | 3353 | ||
@@ -3261,11 +3381,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. | 3381 | * syntax and keep in mind that code below is a cleaned up version. |
3262 | */ | 3382 | */ |
3263 | 3383 | ||
3264 | static int __initdata io[PARPORT_PC_MAX_PORTS+1] = { [0 ... PARPORT_PC_MAX_PORTS] = 0 }; | 3384 | static int __initdata io[PARPORT_PC_MAX_PORTS+1] = { |
3265 | static int __initdata io_hi[PARPORT_PC_MAX_PORTS+1] = | 3385 | [0 ... PARPORT_PC_MAX_PORTS] = 0 |
3266 | { [0 ... PARPORT_PC_MAX_PORTS] = PARPORT_IOHI_AUTO }; | 3386 | }; |
3267 | static int __initdata dmaval[PARPORT_PC_MAX_PORTS] = { [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_DMA_NONE }; | 3387 | static int __initdata io_hi[PARPORT_PC_MAX_PORTS+1] = { |
3268 | static int __initdata irqval[PARPORT_PC_MAX_PORTS] = { [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_IRQ_PROBEONLY }; | 3388 | [0 ... PARPORT_PC_MAX_PORTS] = PARPORT_IOHI_AUTO |
3389 | }; | ||
3390 | static int __initdata dmaval[PARPORT_PC_MAX_PORTS] = { | ||
3391 | [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_DMA_NONE | ||
3392 | }; | ||
3393 | static int __initdata irqval[PARPORT_PC_MAX_PORTS] = { | ||
3394 | [0 ... PARPORT_PC_MAX_PORTS-1] = PARPORT_IRQ_PROBEONLY | ||
3395 | }; | ||
3269 | 3396 | ||
3270 | static int __init parport_parse_param(const char *s, int *val, | 3397 | static int __init parport_parse_param(const char *s, int *val, |
3271 | int automatic, int none, int nofifo) | 3398 | int automatic, int none, int nofifo) |
@@ -3306,18 +3433,19 @@ static int __init parport_parse_dma(const char *dmastr, int *val) | |||
3306 | #ifdef CONFIG_PCI | 3433 | #ifdef CONFIG_PCI |
3307 | static int __init parport_init_mode_setup(char *str) | 3434 | static int __init parport_init_mode_setup(char *str) |
3308 | { | 3435 | { |
3309 | printk(KERN_DEBUG "parport_pc.c: Specified parameter parport_init_mode=%s\n", str); | 3436 | printk(KERN_DEBUG |
3310 | 3437 | "parport_pc.c: Specified parameter parport_init_mode=%s\n", str); | |
3311 | if (!strcmp (str, "spp")) | 3438 | |
3312 | parport_init_mode=1; | 3439 | if (!strcmp(str, "spp")) |
3313 | if (!strcmp (str, "ps2")) | 3440 | parport_init_mode = 1; |
3314 | parport_init_mode=2; | 3441 | if (!strcmp(str, "ps2")) |
3315 | if (!strcmp (str, "epp")) | 3442 | parport_init_mode = 2; |
3316 | parport_init_mode=3; | 3443 | if (!strcmp(str, "epp")) |
3317 | if (!strcmp (str, "ecp")) | 3444 | parport_init_mode = 3; |
3318 | parport_init_mode=4; | 3445 | if (!strcmp(str, "ecp")) |
3319 | if (!strcmp (str, "ecpepp")) | 3446 | parport_init_mode = 4; |
3320 | parport_init_mode=5; | 3447 | if (!strcmp(str, "ecpepp")) |
3448 | parport_init_mode = 5; | ||
3321 | return 1; | 3449 | return 1; |
3322 | } | 3450 | } |
3323 | #endif | 3451 | #endif |
@@ -3341,7 +3469,8 @@ module_param(verbose_probing, int, 0644); | |||
3341 | #endif | 3469 | #endif |
3342 | #ifdef CONFIG_PCI | 3470 | #ifdef CONFIG_PCI |
3343 | static char *init_mode; | 3471 | static char *init_mode; |
3344 | MODULE_PARM_DESC(init_mode, "Initialise mode for VIA VT8231 port (spp, ps2, epp, ecp or ecpepp)"); | 3472 | MODULE_PARM_DESC(init_mode, |
3473 | "Initialise mode for VIA VT8231 port (spp, ps2, epp, ecp or ecpepp)"); | ||
3345 | module_param(init_mode, charp, 0); | 3474 | module_param(init_mode, charp, 0); |
3346 | #endif | 3475 | #endif |
3347 | 3476 | ||
@@ -3372,7 +3501,7 @@ static int __init parse_parport_params(void) | |||
3372 | irqval[0] = val; | 3501 | irqval[0] = val; |
3373 | break; | 3502 | break; |
3374 | default: | 3503 | default: |
3375 | printk (KERN_WARNING | 3504 | printk(KERN_WARNING |
3376 | "parport_pc: irq specified " | 3505 | "parport_pc: irq specified " |
3377 | "without base address. Use 'io=' " | 3506 | "without base address. Use 'io=' " |
3378 | "to specify one\n"); | 3507 | "to specify one\n"); |
@@ -3385,7 +3514,7 @@ static int __init parse_parport_params(void) | |||
3385 | dmaval[0] = val; | 3514 | dmaval[0] = val; |
3386 | break; | 3515 | break; |
3387 | default: | 3516 | default: |
3388 | printk (KERN_WARNING | 3517 | printk(KERN_WARNING |
3389 | "parport_pc: dma specified " | 3518 | "parport_pc: dma specified " |
3390 | "without base address. Use 'io=' " | 3519 | "without base address. Use 'io=' " |
3391 | "to specify one\n"); | 3520 | "to specify one\n"); |
@@ -3396,7 +3525,7 @@ static int __init parse_parport_params(void) | |||
3396 | 3525 | ||
3397 | #else | 3526 | #else |
3398 | 3527 | ||
3399 | static int parport_setup_ptr __initdata = 0; | 3528 | static int parport_setup_ptr __initdata; |
3400 | 3529 | ||
3401 | /* | 3530 | /* |
3402 | * Acceptable parameters: | 3531 | * Acceptable parameters: |
@@ -3407,7 +3536,7 @@ static int parport_setup_ptr __initdata = 0; | |||
3407 | * | 3536 | * |
3408 | * IRQ/DMA may be numeric or 'auto' or 'none' | 3537 | * IRQ/DMA may be numeric or 'auto' or 'none' |
3409 | */ | 3538 | */ |
3410 | static int __init parport_setup (char *str) | 3539 | static int __init parport_setup(char *str) |
3411 | { | 3540 | { |
3412 | char *endptr; | 3541 | char *endptr; |
3413 | char *sep; | 3542 | char *sep; |
@@ -3419,15 +3548,15 @@ static int __init parport_setup (char *str) | |||
3419 | return 1; | 3548 | return 1; |
3420 | } | 3549 | } |
3421 | 3550 | ||
3422 | if (!strncmp (str, "auto", 4)) { | 3551 | if (!strncmp(str, "auto", 4)) { |
3423 | irqval[0] = PARPORT_IRQ_AUTO; | 3552 | irqval[0] = PARPORT_IRQ_AUTO; |
3424 | dmaval[0] = PARPORT_DMA_AUTO; | 3553 | dmaval[0] = PARPORT_DMA_AUTO; |
3425 | return 1; | 3554 | return 1; |
3426 | } | 3555 | } |
3427 | 3556 | ||
3428 | val = simple_strtoul (str, &endptr, 0); | 3557 | val = simple_strtoul(str, &endptr, 0); |
3429 | if (endptr == str) { | 3558 | if (endptr == str) { |
3430 | printk (KERN_WARNING "parport=%s not understood\n", str); | 3559 | printk(KERN_WARNING "parport=%s not understood\n", str); |
3431 | return 1; | 3560 | return 1; |
3432 | } | 3561 | } |
3433 | 3562 | ||
@@ -3461,7 +3590,7 @@ static int __init parse_parport_params(void) | |||
3461 | return io[0] == PARPORT_DISABLE; | 3590 | return io[0] == PARPORT_DISABLE; |
3462 | } | 3591 | } |
3463 | 3592 | ||
3464 | __setup ("parport=", parport_setup); | 3593 | __setup("parport=", parport_setup); |
3465 | 3594 | ||
3466 | /* | 3595 | /* |
3467 | * Acceptable parameters: | 3596 | * Acceptable parameters: |
@@ -3469,7 +3598,7 @@ __setup ("parport=", parport_setup); | |||
3469 | * parport_init_mode=[spp|ps2|epp|ecp|ecpepp] | 3598 | * parport_init_mode=[spp|ps2|epp|ecp|ecpepp] |
3470 | */ | 3599 | */ |
3471 | #ifdef CONFIG_PCI | 3600 | #ifdef CONFIG_PCI |
3472 | __setup("parport_init_mode=",parport_init_mode_setup); | 3601 | __setup("parport_init_mode=", parport_init_mode_setup); |
3473 | #endif | 3602 | #endif |
3474 | #endif | 3603 | #endif |
3475 | 3604 | ||
@@ -3493,13 +3622,13 @@ static int __init parport_pc_init(void) | |||
3493 | for (i = 0; i < PARPORT_PC_MAX_PORTS; i++) { | 3622 | for (i = 0; i < PARPORT_PC_MAX_PORTS; i++) { |
3494 | if (!io[i]) | 3623 | if (!io[i]) |
3495 | break; | 3624 | break; |
3496 | if ((io_hi[i]) == PARPORT_IOHI_AUTO) | 3625 | if (io_hi[i] == PARPORT_IOHI_AUTO) |
3497 | io_hi[i] = 0x400 + io[i]; | 3626 | io_hi[i] = 0x400 + io[i]; |
3498 | parport_pc_probe_port(io[i], io_hi[i], | 3627 | parport_pc_probe_port(io[i], io_hi[i], |
3499 | irqval[i], dmaval[i], NULL, 0); | 3628 | irqval[i], dmaval[i], NULL, 0); |
3500 | } | 3629 | } |
3501 | } else | 3630 | } else |
3502 | parport_pc_find_ports (irqval[0], dmaval[0]); | 3631 | parport_pc_find_ports(irqval[0], dmaval[0]); |
3503 | 3632 | ||
3504 | return 0; | 3633 | return 0; |
3505 | } | 3634 | } |
@@ -3507,9 +3636,9 @@ static int __init parport_pc_init(void) | |||
3507 | static void __exit parport_pc_exit(void) | 3636 | static void __exit parport_pc_exit(void) |
3508 | { | 3637 | { |
3509 | if (pci_registered_parport) | 3638 | if (pci_registered_parport) |
3510 | pci_unregister_driver (&parport_pc_pci_driver); | 3639 | pci_unregister_driver(&parport_pc_pci_driver); |
3511 | if (pnp_registered_parport) | 3640 | if (pnp_registered_parport) |
3512 | pnp_unregister_driver (&parport_pc_pnp_driver); | 3641 | pnp_unregister_driver(&parport_pc_pnp_driver); |
3513 | platform_driver_unregister(&parport_pc_platform_driver); | 3642 | platform_driver_unregister(&parport_pc_platform_driver); |
3514 | 3643 | ||
3515 | while (!list_empty(&ports_list)) { | 3644 | while (!list_empty(&ports_list)) { |