summaryrefslogtreecommitdiffstats
path: root/drivers/parport
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-02-18 00:24:27 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-02-18 00:24:27 +0000
commitb9558d5f86c471a125abf1fb3a3882fb053b1f8c (patch)
tree707b53ec64e740a7da87d5f36485e3cd9b1c794e /drivers/parport
parentb3ac367c7a3e6047abe74817db27e34e759f279f (diff)
Merge with Linux 2.3.41.
Diffstat (limited to 'drivers/parport')
-rw-r--r--drivers/parport/init.c2
-rw-r--r--drivers/parport/parport_amiga.c65
-rw-r--r--drivers/parport/parport_mfc3.c140
-rw-r--r--drivers/parport/parport_pc.c46
-rw-r--r--drivers/parport/procfs.c2
5 files changed, 156 insertions, 99 deletions
diff --git a/drivers/parport/init.c b/drivers/parport/init.c
index b2f4d4b06..a43d59dbe 100644
--- a/drivers/parport/init.c
+++ b/drivers/parport/init.c
@@ -26,6 +26,8 @@ static int dma[PARPORT_MAX] __initdata = { [0 ... PARPORT_MAX-1] = PARPORT_DMA_N
extern int parport_pc_init(int *io, int *io_hi, int *irq, int *dma);
extern int parport_sunbpp_init(void);
+extern int parport_amiga_init(void);
+extern int parport_mfc3_init(void);
static int parport_setup_ptr __initdata = 0;
diff --git a/drivers/parport/parport_amiga.c b/drivers/parport/parport_amiga.c
index 4405eea01..dc4fc6945 100644
--- a/drivers/parport/parport_amiga.c
+++ b/drivers/parport/parport_amiga.c
@@ -1,6 +1,6 @@
/* Low-level parallel port routines for the Amiga buildin port
*
- * Author: Joerg Dorchain <dorchain@wirbel.com>
+ * Author: Joerg Dorchain <joerg@dorchain.net>
*
* This is a complete rewrite of the code, but based heaviy upon the old
* lp_intern. code.
@@ -25,7 +25,7 @@
#ifdef DEBUG
#define DPRINTK printk
#else
-#define DPRINTK(format, args...)
+static inline void DPRINTK(void *nothing, ...) {}
#endif
static struct parport *this_port = NULL;
@@ -90,7 +90,7 @@ DPRINTK("frob_control mask %02x, value %02x\n",mask,val);
return old;
}
-
+#if 0 /* currently unused */
static unsigned char status_pc_to_amiga(unsigned char status)
{
unsigned char ret = 1;
@@ -107,6 +107,7 @@ static unsigned char status_pc_to_amiga(unsigned char status)
/* not connected */;
return ret;
}
+#endif
static unsigned char status_amiga_to_pc(unsigned char status)
{
@@ -138,6 +139,28 @@ static void amiga_interrupt(int irq, void *dev_id, struct pt_regs *regs)
parport_generic_irq(irq, (struct parport *) dev_id, regs);
}
+static void amiga_enable_irq(struct parport *p)
+{
+ enable_irq(IRQ_AMIGA_CIAA_FLG);
+}
+
+static void amiga_disable_irq(struct parport *p)
+{
+ disable_irq(IRQ_AMIGA_CIAA_FLG);
+}
+
+static void amiga_data_forward(struct parport *p)
+{
+ DPRINTK("forward\n");
+ ciaa.ddrb = 0xff; /* all pins output */
+}
+
+static void amiga_data_reverse(struct parport *p)
+{
+ DPRINTK("reverse\n");
+ ciaa.ddrb = 0; /* all pins input */
+}
+
static void amiga_init_state(struct pardevice *dev, struct parport_state *s)
{
s->u.amiga.data = 0;
@@ -162,16 +185,6 @@ static void amiga_restore_state(struct parport *p, struct parport_state *s)
ciab.ddra |= (ciab.ddra & 0xf8) | s->u.amiga.statusdir;
}
-static void amiga_enable_irq(struct parport *p)
-{
- enable_irq(IRQ_AMIGA_CIAA_FLG);
-}
-
-static void amiga_disable_irq(struct parport *p)
-{
- disable_irq(IRQ_AMIGA_CIAA_FLG);
-}
-
static void amiga_inc_use_count(void)
{
MOD_INC_USE_COUNT;
@@ -195,8 +208,8 @@ static struct parport_operations pp_amiga_ops = {
amiga_enable_irq,
amiga_disable_irq,
- NULL, /* data_forward */
- NULL, /* data_reverse */
+ amiga_data_forward,
+ amiga_data_reverse,
amiga_init_state,
amiga_save_state,
@@ -205,18 +218,18 @@ static struct parport_operations pp_amiga_ops = {
amiga_inc_use_count,
amiga_dec_use_count,
- NULL, /* epp_write_data */
- NULL, /* epp_read_data */
- NULL, /* epp_write_addr */
- NULL, /* epp_read_addr */
+ parport_ieee1284_epp_write_data,
+ parport_ieee1284_epp_read_data,
+ parport_ieee1284_epp_write_addr,
+ parport_ieee1284_epp_read_addr,
- NULL, /* ecp_write_data */
- NULL, /* ecp_read_data */
- NULL, /* ecp_write_addr */
+ parport_ieee1284_ecp_write_data,
+ parport_ieee1284_ecp_read_data,
+ parport_ieee1284_ecp_write_addr,
- NULL, /* compat_write_data */
- NULL, /* nibble_read_data */
- NULL, /* byte_read_data */
+ parport_ieee1284_write_compat,
+ parport_ieee1284_read_nibble,
+ parport_ieee1284_read_byte,
};
/* ----------- Initialisation code --------------------------------- */
@@ -252,7 +265,7 @@ int __init parport_amiga_init(void)
#ifdef MODULE
-MODULE_AUTHOR("Joerg Dorchain");
+MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
MODULE_DESCRIPTION("Parport Driver for Amiga builtin Port");
MODULE_SUPPORTED_DEVICE("Amiga builtin Parallel Port");
diff --git a/drivers/parport/parport_mfc3.c b/drivers/parport/parport_mfc3.c
index dfa3a1d93..054bb4d89 100644
--- a/drivers/parport/parport_mfc3.c
+++ b/drivers/parport/parport_mfc3.c
@@ -1,6 +1,6 @@
/* Low-level parallel port routines for the Multiface 3 card
*
- * Author: Joerg Dorchain <dorchain@wirbel.com>
+ * Author: Joerg Dorchain <joerg@dorchain.net>
*
* (C) The elitist m68k Users(TM)
*
@@ -46,6 +46,10 @@
* -------+-----+-----+---------------------------------------------------------
*
* Should be enough to understand some of the driver.
+ *
+ * Per convention for normal use the port registers are visible.
+ * If you need the data direction registers, restore the value in the
+ * control register.
*/
#include "multiface.h"
@@ -67,7 +71,7 @@
#ifdef DEBUG
#define DPRINTK printk
#else
-static inline int DPRINTK() {return 0;}
+static inline int DPRINTK(void *nothing, ...) {return 0;}
#endif
static struct parport *this_port[MAX_MFC] = {NULL, };
@@ -95,10 +99,6 @@ static unsigned char control_pc_to_mfc3(unsigned char control)
{
unsigned char ret = 32|64;
- if (control & PARPORT_CONTROL_DIRECTION) /* XXX: What is this? */
- ;
- if (control & PARPORT_CONTROL_INTEN) /* XXX: What is INTEN? */
- ;
if (control & PARPORT_CONTROL_SELECT) /* XXX: What is SELECP? */
ret &= ~32; /* /SELECT_IN */
if (control & PARPORT_CONTROL_INIT) /* INITP */
@@ -112,7 +112,7 @@ static unsigned char control_pc_to_mfc3(unsigned char control)
static unsigned char control_mfc3_to_pc(unsigned char control)
{
- unsigned char ret = PARPORT_CONTROL_INTEN | PARPORT_CONTROL_STROBE
+ unsigned char ret = PARPORT_CONTROL_STROBE
| PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_SELECT;
if (control & 128) /* /INITP */
@@ -146,7 +146,7 @@ DPRINTK("frob_control mask %02x, value %02x\n",mask,val);
return old;
}
-
+#if 0 /* currently unused */
static unsigned char status_pc_to_mfc3(unsigned char status)
{
unsigned char ret = 1;
@@ -163,6 +163,7 @@ static unsigned char status_pc_to_mfc3(unsigned char status)
ret |= 16;
return ret;
}
+#endif
static unsigned char status_mfc3_to_pc(unsigned char status)
{
@@ -182,11 +183,13 @@ static unsigned char status_mfc3_to_pc(unsigned char status)
return ret;
}
+#if 0 /* currently unused */
static void mfc3_write_status( struct parport *p, unsigned char status)
{
DPRINTK("write_status %02x\n",status);
pia(p)->ppra = (pia(p)->ppra & 0xe0) | status_pc_to_mfc3(status);
}
+#endif
static unsigned char mfc3_read_status(struct parport *p)
{
@@ -197,11 +200,13 @@ DPRINTK("read_status %02x\n", status);
return status;
}
+#if 0 /* currently unused */
static void mfc3_change_mode( struct parport *p, int m)
{
/* XXX: This port only has one mode, and I am
not sure about the corresponding PC-style mode*/
}
+#endif
static int use_cnt = 0;
@@ -217,12 +222,33 @@ static void mfc3_interrupt(int irq, void *dev_id, struct pt_regs *regs)
}
}
-static int mfc3_claim_resources(struct parport *p)
+static void mfc3_enable_irq(struct parport *p)
+{
+ pia(p)->crb |= PIA_C1_ENABLE_IRQ;
+}
+
+static void mfc3_disable_irq(struct parport *p)
+{
+ pia(p)->crb &= ~PIA_C1_ENABLE_IRQ;
+}
+
+static void mfc3_data_forward(struct parport *p)
+{
+ DPRINTK("forward\n");
+ pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
+ pia(p)->pddrb = 255; /* all pins output */
+ pia(p)->crb |= PIA_DDR; /* make data register visible - default */
+}
+
+static void mfc3_data_reverse(struct parport *p)
{
-DPRINTK("claim_resources\n");
+ DPRINTK("reverse\n");
+ pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
+ pia(p)->pddrb = 0; /* all pins input */
+ pia(p)->crb |= PIA_DDR; /* make data register visible - default */
}
-static void mfc3_init_state(struct parport_state *s)
+static void mfc3_init_state(struct pardevice *dev, struct parport_state *s)
{
s->u.amiga.data = 0;
s->u.amiga.datadir = 255;
@@ -254,16 +280,6 @@ static void mfc3_restore_state(struct parport *p, struct parport_state *s)
pia(p)->cra |= PIA_DDR;
}
-static void mfc3_enable_irq(struct parport *p)
-{
- pia(p)->crb |= PIA_C1_ENABLE_IRQ;
-}
-
-static void mfc3_disable_irq(struct parport *p)
-{
- pia(p)->crb &= ~PIA_C1_ENABLE_IRQ;
-}
-
static void mfc3_inc_use_count(void)
{
MOD_INC_USE_COUNT;
@@ -287,8 +303,8 @@ static struct parport_operations pp_mfc3_ops = {
mfc3_enable_irq,
mfc3_disable_irq,
- NULL, /* data_forward - FIXME */
- NULL, /* data_reverse - FIXME */
+ mfc3_data_forward,
+ mfc3_data_reverse,
mfc3_init_state,
mfc3_save_state,
@@ -318,43 +334,43 @@ int __init parport_mfc3_init(void)
struct parport *p;
int pias = 0;
struct pia *pp;
- unsigned int key = 0;
- const struct ConfigDev *cd;
-
- if (MACH_IS_AMIGA) {
- while ((key = zorro_find(ZORRO_PROD_BSC_MULTIFACE_III, 0, key))) {
- cd = zorro_get_board(key);
- pp = (struct pia *)ZTWO_VADDR((((u_char *)cd->cd_BoardAddr)+PIABASE));
- if (pias < MAX_MFC) {
- pp->crb = 0;
- pp->pddrb = 255; /* all data pins output */
- pp->crb = PIA_DDR|32|8;
- dummy = pp->pddrb; /* reading clears interrupt */
- pp->cra = 0;
- pp->pddra = 0xe0; /* /RESET, /DIR ,/AUTO-FEED output */
- pp->cra = PIA_DDR;
- pp->ppra = 0; /* reset printer */
- udelay(10);
- pp->ppra = 128;
- if ((p = parport_register_port((unsigned long)pp,
- IRQ_AMIGA_PORTS, PARPORT_DMA_NONE,
- &pp_mfc3_ops))) {
- this_port[pias++] = p;
- printk(KERN_INFO "%s: Multiface III port using irq\n", p->name);
- /* XXX: set operating mode */
- parport_proc_register(p);
-
- if (p->irq != PARPORT_IRQ_NONE)
- if (use_cnt++ == 0)
- if (request_irq(IRQ_AMIGA_PORTS, mfc3_interrupt, SA_SHIRQ, p->name, &pp_mfc3_ops))
- use_cnt--;
-
- if (parport_probe_hook)
- (*parport_probe_hook)(p);
- zorro_config_board(key, 0);
- p->private_data = (void *)key;
- parport_announce_port (p);
- }
+ struct zorro_dev *z = NULL;
+
+ if (!MACH_IS_AMIGA)
+ return 0;
+
+ while ((z = zorro_find_device(ZORRO_PROD_BSC_MULTIFACE_III, z))) {
+ unsigned long piabase = z->resource.start+PIABASE;
+ if (!request_mem_region(piabase, sizeof(struct pia), "PIA"))
+ continue;
+ strcpy(z->name, "MultiFace III MC6821 PIA");
+ pp = (struct pia *)ZTWO_VADDR(piabase);
+ if (pias < MAX_MFC) {
+ pp->crb = 0;
+ pp->pddrb = 255; /* all data pins output */
+ pp->crb = PIA_DDR|32|8;
+ dummy = pp->pddrb; /* reading clears interrupt */
+ pp->cra = 0;
+ pp->pddra = 0xe0; /* /RESET, /DIR ,/AUTO-FEED output */
+ pp->cra = PIA_DDR;
+ pp->ppra = 0; /* reset printer */
+ udelay(10);
+ pp->ppra = 128;
+ if ((p = parport_register_port((unsigned long)pp,
+ IRQ_AMIGA_PORTS, PARPORT_DMA_NONE,
+ &pp_mfc3_ops))) {
+ this_port[pias++] = p;
+ printk(KERN_INFO "%s: Multiface III port using irq\n", p->name);
+ /* XXX: set operating mode */
+ parport_proc_register(p);
+
+ if (p->irq != PARPORT_IRQ_NONE)
+ if (use_cnt++ == 0)
+ if (request_irq(IRQ_AMIGA_PORTS, mfc3_interrupt, SA_SHIRQ, p->name, &pp_mfc3_ops))
+ use_cnt--;
+
+ p->private_data = (void *)piabase;
+ parport_announce_port (p);
}
}
}
@@ -363,7 +379,7 @@ int __init parport_mfc3_init(void)
#ifdef MODULE
-MODULE_AUTHOR("Joerg Dorchain");
+MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
MODULE_DESCRIPTION("Parport Driver for Multiface 3 expansion cards Paralllel Port");
MODULE_SUPPORTED_DEVICE("Multiface 3 Parallel Port");
@@ -383,7 +399,7 @@ void cleanup_module(void)
free_irq(IRQ_AMIGA_PORTS, &pp_mfc3_ops);
parport_proc_unregister(this_port[i]);
parport_unregister_port(this_port[i]);
- zorro_unconfig_board((unsigned int)this_port[i]->private_data, 0);
+ release_mem_region(ZTWO_PADDR(this_port[i]->private_data), sizeof(struct pia));
}
}
#endif
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 57e6ac684..0524cf40a 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -549,8 +549,24 @@ static size_t parport_pc_fifo_write_block_dma (struct parport *port,
{
int ret = 0;
unsigned long dmaflag;
- size_t left = length;
+ size_t left = length;
const struct parport_pc_private *priv = port->physport->private_data;
+ unsigned long dma_addr;
+ size_t maxlen = 0x10000; /* max 64k per DMA transfer */
+ unsigned long start = (unsigned long) buf;
+ unsigned long end = (unsigned long) buf + length - 1;
+
+ /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */
+ if (end <= MAX_DMA_ADDRESS) {
+ /* If it would cross a 64k boundary, cap it at the end. */
+ if ((start ^ end) & ~0xffff)
+ maxlen = (0x10000 - start) & 0xffff;
+
+ dma_addr = virt_to_bus(buf);
+ } else {
+ dma_addr = priv->dma_handle;
+ maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */
+ }
port = port->physport;
@@ -566,16 +582,17 @@ static size_t parport_pc_fifo_write_block_dma (struct parport *port,
size_t count = left;
- if (count > PAGE_SIZE)
- count = PAGE_SIZE;
+ if (count > maxlen)
+ count = maxlen;
- memcpy(priv->dma_buf, buf, count);
+ if (maxlen == PAGE_SIZE) /* bounce buffer ! */
+ memcpy(priv->dma_buf, buf, count);
dmaflag = claim_dma_lock();
disable_dma(port->dma);
clear_dma_ff(port->dma);
set_dma_mode(port->dma, DMA_MODE_WRITE);
- set_dma_addr(port->dma, virt_to_bus((volatile char *) priv->dma_buf));
+ set_dma_addr(port->dma, dma_addr);
set_dma_count(port->dma, count);
/* Set DMA mode */
@@ -1499,7 +1516,8 @@ static int __maybe_init parport_dma_probe (struct parport *p)
struct parport *__maybe_init parport_pc_probe_port (unsigned long int base,
unsigned long int base_hi,
- int irq, int dma)
+ int irq, int dma,
+ struct pci_dev *dev)
{
struct parport_pc_private *priv;
struct parport_operations *ops;
@@ -1525,6 +1543,8 @@ struct parport *__maybe_init parport_pc_probe_port (unsigned long int base,
priv->ecr = 0;
priv->fifo_depth = 0;
priv->dma_buf = 0;
+ priv->dma_handle = 0;
+ priv->dev = dev;
p->base = base;
p->base_hi = base_hi;
p->irq = irq;
@@ -1649,7 +1669,9 @@ struct parport *__maybe_init parport_pc_probe_port (unsigned long int base,
p->dma = PARPORT_DMA_NONE;
} else {
priv->dma_buf =
- (char *)__get_dma_pages(GFP_KERNEL, 0);
+ pci_alloc_consistent(priv->dev,
+ PAGE_SIZE,
+ &priv->dma_handle);
if (! priv->dma_buf) {
printk (KERN_WARNING "%s: "
"cannot get buffer for DMA, "
@@ -1805,10 +1827,12 @@ static int __init parport_pc_init_pci (int irq, int dma)
if (parport_pc_probe_port (io_lo,
io_hi,
pcidev->irq,
- dma))
+ dma,
+ pcidev))
count++;
} else if (parport_pc_probe_port (io_lo, io_hi,
- irq, dma))
+ irq, dma,
+ pcidev))
count++;
}
}
@@ -1913,7 +1937,9 @@ void cleanup_module(void)
release_region(p->base_hi, 3);
parport_proc_unregister(p);
if (priv->dma_buf)
- free_page((unsigned long) priv->dma_buf);
+ pci_free_consistent(priv->dev, PAGE_SIZE,
+ priv->dma_buf,
+ priv->dma_handle);
kfree (p->private_data);
parport_unregister_port(p);
kfree (ops); /* hope no-one cached it */
diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
index 29a3a7e29..07b30b009 100644
--- a/drivers/parport/procfs.c
+++ b/drivers/parport/procfs.c
@@ -224,7 +224,7 @@ static const struct parport_sysctl_table parport_sysctl_template = {
#endif /* IEEE 1284 support */
{0}
},
- { {DEV_PARPORT_DEVICES_ACTIVE, "active", NULL, 0, 444, NULL,
+ { {DEV_PARPORT_DEVICES_ACTIVE, "active", NULL, 0, 0444, NULL,
&do_active_device }, {0}},
{ PARPORT_PORT_DIR(NULL), {0}},
{ PARPORT_PARPORT_DIR(NULL), {0}},