summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/Makefile10
-rw-r--r--drivers/misc/parport_ieee1284.c83
-rw-r--r--drivers/misc/parport_init.c19
-rw-r--r--drivers/misc/parport_pc.c10
-rw-r--r--drivers/misc/parport_procfs.c2
-rw-r--r--drivers/misc/parport_share.c17
6 files changed, 75 insertions, 66 deletions
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 795df5697..1137f6e80 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -30,6 +30,13 @@ ifeq ($(CONFIG_PARPORT),y)
M_OBJS += parport_pc.o
endif
endif
+ ifeq ($(CONFIG_PARPORT_AX),y)
+ LX_OBJS += parport_ax.o
+ else
+ ifeq ($(CONFIG_PARPORT_AX),m)
+ M_OBJS += parport_ax.o
+ endif
+ endif
LX_OBJS += parport_init.o
else
ifeq ($(CONFIG_PARPORT),m)
@@ -43,6 +50,9 @@ else
ifeq ($(CONFIG_PARPORT_PC),m)
MX_OBJS += parport_pc.o
endif
+ ifeq ($(CONFIG_PARPORT_AX),m)
+ MX_OBJS += parport_ax.o
+ endif
endif
include $(TOPDIR)/Rules.make
diff --git a/drivers/misc/parport_ieee1284.c b/drivers/misc/parport_ieee1284.c
index 6fad49911..23152fa41 100644
--- a/drivers/misc/parport_ieee1284.c
+++ b/drivers/misc/parport_ieee1284.c
@@ -1,4 +1,5 @@
-/* IEEE-1284 implementation for parport.
+/* $Id: parport_ieee1284.c,v 1.4 1997/12/15 10:37:47 ralf Exp $
+ * IEEE-1284 implementation for parport.
*
* Authors: Phil Blundell <Philip.Blundell@pobox.com>
* Carsten Gross <carsten@sol.wohnheim.uni-ulm.de>
@@ -6,83 +7,63 @@
*/
#include <linux/tasks.h>
-
#include <linux/parport.h>
#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/ioport.h>
#include <linux/kernel.h>
-#include <linux/malloc.h>
-
-/* The following read functions are an implementation of a status readback
- * and device id request confirming to IEEE1284-1994.
- *
- * These probably ought to go in some seperate file, so people like the SPARC
- * don't have to pull them in.
- */
/* Wait for Status line(s) to change in 35 ms - see IEEE1284-1994 page 24 to
* 25 for this. After this time we can create a timeout because the
- * peripheral doesn't conform to IEEE1284. We want to save CPU time: we are
- * waiting a maximum time of 500 us busy (this is for speed). If there is
+ * peripheral doesn't conform to IEEE1284. We want to save CPU time: we are
+ * waiting a maximum time of 500 us busy (this is for speed). If there is
* not the right answer in this time, we call schedule and other processes
- * are able "to eat" the time up to 30ms. So the maximum load avarage can't
- * get above 5% for a read even if the peripheral is really slow. (but your
- * read gets very slow then - only about 10 characters per second. This
- * should be tuneable). Thanks to Andreas who pointed me to this and ordered
- * the documentation.
+ * are able to eat the time up to 40ms.
*/
int parport_wait_peripheral(struct parport *port, unsigned char mask,
unsigned char result)
{
- int counter=0;
+ int counter;
unsigned char status;
- do {
+ for (counter = 0; counter < 20; counter++) {
status = parport_read_status(port);
+ if ((status & mask) == result)
+ return 0;
udelay(25);
- counter++;
if (need_resched)
schedule();
- } while ( ((status & mask) != result) && (counter < 20) );
- if ( (counter == 20) && ((status & mask) != result) ) {
- current->state=TASK_INTERRUPTIBLE;
- current->timeout=jiffies+4;
- schedule(); /* wait for 4 scheduler runs (40ms) */
- status = parport_read_status(port);
- if ((status & mask) != result) return 1; /* timeout */
}
- return 0; /* okay right response from device */
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies+4;
+ schedule(); /* wait for 40ms */
+ status = parport_read_status(port);
+ return ((status & mask) == result)?0:1;
}
-/* Test if nibble mode for status readback is okay. Returns the value false
- * if the printer doesn't support readback at all. If it supports readbacks
- * and printer data is available the function returns 1, otherwise 2. The
- * only valid values for "mode" are 0 and 4. 0 requests normal nibble mode,
- * 4 is for "request device id using nibble mode". The request for the
- * device id is best done in an ioctl (or at bootup time). There is no
- * check for an invalid value, the only function using this call at the
- * moment is lp_read and the ioctl LPGETDEVICEID both fixed calls from
- * trusted kernel.
+/* Test if the peripheral is IEEE 1284 compliant.
+ * return values are:
+ * 0 - handshake failed; peripheral is not compliant (or none present)
+ * 1 - handshake OK; IEEE1284 peripheral present but no data available
+ * 2 - handshake OK; IEEE1284 peripheral and data available
*/
int parport_ieee1284_nibble_mode_ok(struct parport *port, unsigned char mode)
{
parport_write_data(port, mode);
- udelay(5);
- parport_write_control(port, parport_read_control(port) & ~8); /* SelectIN low */
- parport_write_control(port, parport_read_control(port) | 2); /* AutoFeed high */
- if (parport_wait_peripheral(port, 0x78, 0x38)) { /* timeout? */
- parport_write_control(port, (parport_read_control(port) & ~2) | 8);
- return 0; /* first stage of negotiation failed,
- * no IEEE1284 compliant device on this port
- */
+ udelay(500);
+ /* nSelectIn high, nAutoFd low */
+ parport_write_control(port, (parport_read_control(port) & ~8) | 2);
+ if (parport_wait_peripheral(port, 0x78, 0x38)) {
+ parport_write_control(port,
+ (parport_read_control(port) & ~2) | 8);
+ return 0;
}
- parport_write_control(port, parport_read_control(port) | 1); /* Strobe high */
+ /* nStrobe low */
+ parport_write_control(port, parport_read_control(port) | 1);
udelay(5); /* Strobe wait */
- parport_write_control(port, parport_read_control(port) & ~1); /* Strobe low */
+ /* nStrobe high */
+ parport_write_control(port, parport_read_control(port) & ~1);
udelay(5);
- parport_write_control(port, parport_read_control(port) & ~2); /* AutoFeed low */
+ /* nAutoFd low */
+ parport_write_control(port, parport_read_control(port) & ~2);
return (parport_wait_peripheral(port, 0x20, 0))?2:1;
}
diff --git a/drivers/misc/parport_init.c b/drivers/misc/parport_init.c
index c6daf72cf..dbe4dd354 100644
--- a/drivers/misc/parport_init.c
+++ b/drivers/misc/parport_init.c
@@ -17,13 +17,15 @@
#include <linux/kernel.h>
#include <linux/malloc.h>
#include <linux/init.h>
+#include <linux/kerneld.h>
#ifndef MODULE
-static int io[PARPORT_MAX+1] __initdata = { 0, };
-static int irq[PARPORT_MAX] __initdata = { PARPORT_IRQ_NONE, };
-static int dma[PARPORT_MAX] __initdata = { PARPORT_DMA_NONE, };
+static int io[PARPORT_MAX+1] __initdata = { [0 ... PARPORT_MAX] = 0 };
+static int irq[PARPORT_MAX] __initdata = { [0 ... PARPORT_MAX-1] = PARPORT_IRQ_NONE };
+static int dma[PARPORT_MAX] __initdata = { [0 ... PARPORT_MAX-1] = PARPORT_DMA_NONE };
extern int parport_pc_init(int *io, int *irq, int *dma);
+extern int parport_ax_init(void);
static int parport_setup_ptr __initdata = 0;
@@ -68,11 +70,19 @@ __initfunc(int parport_init(void))
{
struct parport *pb;
- if (io[0] == PARPORT_DISABLE) return 1;
+ if (io[0] == PARPORT_DISABLE)
+ return 1;
+
+#ifdef CONFIG_PNP_PARPORT
+ parport_probe_hook = &parport_probe_one;
+#endif
parport_proc_init();
#ifdef CONFIG_PARPORT_PC
parport_pc_init(io, irq, dma);
#endif
+#ifdef CONFIG_PARPORT_AX
+ parport_ax_init();
+#endif
return 0;
}
#endif
@@ -91,6 +101,7 @@ EXPORT_SYMBOL(parport_ieee1284_nibble_mode_ok);
EXPORT_SYMBOL(parport_wait_peripheral);
EXPORT_SYMBOL(parport_proc_register);
EXPORT_SYMBOL(parport_proc_unregister);
+EXPORT_SYMBOL(parport_probe_hook);
void inc_parport_count(void)
{
diff --git a/drivers/misc/parport_pc.c b/drivers/misc/parport_pc.c
index c5a7a2a11..71eb184ac 100644
--- a/drivers/misc/parport_pc.c
+++ b/drivers/misc/parport_pc.c
@@ -141,7 +141,7 @@ static void pc_enable_irq(struct parport *p)
static void pc_release_resources(struct parport *p)
{
if (p->irq != PARPORT_IRQ_NONE)
- free_irq(p->irq, p);
+ free_irq(p->irq, NULL);
release_region(p->base, p->size);
if (p->modes & PARPORT_MODE_PCECR)
release_region(p->base+0x400, 3);
@@ -151,7 +151,7 @@ static int pc_claim_resources(struct parport *p)
{
/* FIXME check that resources are free */
if (p->irq != PARPORT_IRQ_NONE)
- request_irq(p->irq, pc_null_intr_func, 0, p->name, p);
+ request_irq(p->irq, pc_null_intr_func, 0, p->name, NULL);
request_region(p->base, p->size, p->name);
if (p->modes & PARPORT_MODE_PCECR)
request_region(p->base+0x400, 3, p->name);
@@ -837,7 +837,7 @@ static int probe_one_port(unsigned long int base, int irq, int dma)
}
p->size = (p->modes & (PARPORT_MODE_PCEPP
| PARPORT_MODE_PCECPEPP))?8:3;
- printk(KERN_INFO "%s: PC-style at 0x%x", p->name, p->base);
+ printk(KERN_INFO "%s: PC-style at 0x%lx", p->name, p->base);
if (p->irq == PARPORT_IRQ_AUTO) {
p->irq = PARPORT_IRQ_NONE;
parport_irq_probe(p);
@@ -868,6 +868,10 @@ static int probe_one_port(unsigned long int base, int irq, int dma)
/* Done probing. Now put the port into a sensible start-up state. */
pc_write_control(p, 0xc);
pc_write_data(p, 0);
+
+ if (parport_probe_hook)
+ (*parport_probe_hook)(p);
+
return 1;
}
diff --git a/drivers/misc/parport_procfs.c b/drivers/misc/parport_procfs.c
index f50754829..e75fba335 100644
--- a/drivers/misc/parport_procfs.c
+++ b/drivers/misc/parport_procfs.c
@@ -125,7 +125,7 @@ static int hardware_read_proc(char *page, char **start, off_t off,
struct parport *pp = (struct parport *)data;
int len=0;
- len += sprintf(page+len, "base:\t0x%x\n",pp->base);
+ len += sprintf(page+len, "base:\t0x%lx\n",pp->base);
if (pp->irq == PARPORT_IRQ_NONE)
len += sprintf(page+len, "irq:\tnone\n");
else
diff --git a/drivers/misc/parport_share.c b/drivers/misc/parport_share.c
index 6d518d284..2a8931957 100644
--- a/drivers/misc/parport_share.c
+++ b/drivers/misc/parport_share.c
@@ -1,4 +1,5 @@
-/* Parallel-port resource manager code.
+/* $Id: parport_share.c,v 1.7 1997/12/15 11:12:05 ralf Exp $
+ * Parallel-port resource manager code.
*
* Authors: David Campbell <campbell@tirian.che.curtin.edu.au>
* Tim Waugh <tim@cyberelk.demon.co.uk>
@@ -29,6 +30,8 @@
static struct parport *portlist = NULL, *portlist_tail = NULL;
static int portcount = 0;
+void (*parport_probe_hook)(struct parport *port) = NULL;
+
/* Return a list of all the ports we know about. */
struct parport *parport_enumerate(void)
{
@@ -275,11 +278,11 @@ int parport_claim(struct pardevice *dev)
dev->port->cad = dev;
/* Swap the IRQ handlers. */
- if (dev->port->irq >= 0) {
- free_irq(dev->port->irq, dev->port);
+ if (dev->port->irq != PARPORT_IRQ_NONE) {
+ free_irq(dev->port->irq, pd1?pd1->private:NULL);
request_irq(dev->port->irq, dev->irq_func ? dev->irq_func :
parport_null_intr_func, SA_INTERRUPT, dev->name,
- dev->port);
+ dev->private);
}
/* Restore control registers */
@@ -303,10 +306,10 @@ void parport_release(struct pardevice *dev)
dev->port->ops->save_state(dev->port, dev->state);
/* Point IRQs somewhere harmless. */
- if (dev->port->irq >= 0) {
- free_irq(dev->port->irq, dev->port);
+ if (dev->port->irq != PARPORT_IRQ_NONE) {
+ free_irq(dev->port->irq, dev->private);
request_irq(dev->port->irq, parport_null_intr_func,
- SA_INTERRUPT, dev->port->name, dev->port);
+ SA_INTERRUPT, dev->port->name, NULL);
}
/* Walk the list, offering a wakeup callback to everybody other