Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0-only
  2/* Low-level parallel port routines for the Multiface 3 card
  3 *
  4 * Author: Joerg Dorchain <joerg@dorchain.net>
  5 *
  6 * (C) The elitist m68k Users(TM)
  7 *
  8 * based on the existing parport_amiga and lp_mfc
  9 *
 10 *
 11 * From the MFC3 documentation:
 12 * 
 13 * Miscellaneous PIA Details
 14 * -------------------------
 15 * 
 16 * 	The two open-drain interrupt outputs /IRQA and /IRQB are routed to
 17 * /INT2 of the Z2 bus.
 18 * 
 19 * 	The CPU data bus of the PIA (D0-D7) is connected to D8-D15 on the Z2
 20 * bus. This means that any PIA registers are accessed at even addresses.
 21 * 
 22 * Centronics Pin Connections for the PIA
 23 * --------------------------------------
 24 * 
 25 * 	The following table shows the connections between the PIA and the
 26 * Centronics interface connector. These connections implement a single, but
 27 * very complete, Centronics type interface. The Pin column gives the pin
 28 * numbers of the PIA. The Centronics pin numbers can be found in the section
 29 * "Parallel Connectors".
 30 * 
 31 * 
 32 *    Pin | PIA | Dir | Centronics Names
 33 * -------+-----+-----+---------------------------------------------------------
 34 *     19 | CB2 | --> | /STROBE (aka /DRDY)
 35 *  10-17 | PBx | <-> | DATA0 - DATA7
 36 *     18 | CB1 | <-- | /ACK
 37 *     40 | CA1 | <-- | BUSY
 38 *      3 | PA1 | <-- | PAPER-OUT (aka POUT)
 39 *      4 | PA2 | <-- | SELECTED (aka SEL)
 40 *      9 | PA7 | --> | /INIT (aka /RESET or /INPUT-PRIME)
 41 *      6 | PA4 | <-- | /ERROR (aka /FAULT)
 42 *      7 | PA5 | --> | DIR (aka /SELECT-IN)
 43 *      8 | PA6 | --> | /AUTO-FEED-XT
 44 *     39 | CA2 | --> | open
 45 *      5 | PA3 | <-- | /ACK (same as CB1!)
 46 *      2 | PA0 | <-- | BUSY (same as CA1!)
 47 * -------+-----+-----+---------------------------------------------------------
 48 * 
 49 * Should be enough to understand some of the driver.
 50 *
 51 * Per convention for normal use the port registers are visible.
 52 * If you need the data direction registers, restore the value in the
 53 * control register.
 54 */
 55
 56#include "multiface.h"
 57#include <linux/module.h>
 58#include <linux/init.h>
 59#include <linux/parport.h>
 60#include <linux/delay.h>
 61#include <linux/mc6821.h>
 62#include <linux/zorro.h>
 63#include <linux/interrupt.h>
 64#include <asm/setup.h>
 65#include <asm/amigahw.h>
 66#include <asm/irq.h>
 67#include <asm/amigaints.h>
 68
 69/* Maximum Number of Cards supported */
 70#define MAX_MFC 5
 71
 72#undef DEBUG
 
 
 
 
 
 73
 74static struct parport *this_port[MAX_MFC] = {NULL, };
 75static volatile int dummy; /* for trigger readds */
 76
 77#define pia(dev) ((struct pia *)(dev->base))
 78static struct parport_operations pp_mfc3_ops;
 79
 80static void mfc3_write_data(struct parport *p, unsigned char data)
 81{
 82	pr_debug("write_data %c\n", data);
 83
 84	dummy = pia(p)->pprb; /* clears irq bit */
 85	/* Triggers also /STROBE.*/
 86	pia(p)->pprb = data;
 87}
 88
 89static unsigned char mfc3_read_data(struct parport *p)
 90{
 91	/* clears interrupt bit. Triggers also /STROBE. */
 92	return pia(p)->pprb;
 93}
 94
 95static unsigned char control_pc_to_mfc3(unsigned char control)
 96{
 97	unsigned char ret = 32|64;
 98
 99	if (control & PARPORT_CONTROL_SELECT) /* XXX: What is SELECP? */
100		ret &= ~32; /* /SELECT_IN */
101	if (control & PARPORT_CONTROL_INIT) /* INITP */
102		ret |= 128;
103	if (control & PARPORT_CONTROL_AUTOFD) /* AUTOLF */
104		ret &= ~64;
105	if (control & PARPORT_CONTROL_STROBE) /* Strobe */
106		/* Handled directly by hardware */;
107	return ret;
108}
109
110static unsigned char control_mfc3_to_pc(unsigned char control)
111{
112	unsigned char ret = PARPORT_CONTROL_STROBE 
113			  | PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_SELECT;
114
115	if (control & 128) /* /INITP */
116		ret |= PARPORT_CONTROL_INIT;
117	if (control & 64) /* /AUTOLF */
118		ret &= ~PARPORT_CONTROL_AUTOFD;
119	if (control & 32) /* /SELECT_IN */
120		ret &= ~PARPORT_CONTROL_SELECT;
121	return ret;
122}
123
124static void mfc3_write_control(struct parport *p, unsigned char control)
125{
126	pr_debug("write_control %02x\n", control);
127	pia(p)->ppra = (pia(p)->ppra & 0x1f) | control_pc_to_mfc3(control);
128}
129	
130static unsigned char mfc3_read_control( struct parport *p)
131{
132	pr_debug("read_control\n");
133	return control_mfc3_to_pc(pia(p)->ppra & 0xe0);
134}
135
136static unsigned char mfc3_frob_control( struct parport *p, unsigned char mask, unsigned char val)
137{
138	unsigned char old;
139
140	pr_debug("frob_control mask %02x, value %02x\n", mask, val);
141	old = mfc3_read_control(p);
142	mfc3_write_control(p, (old & ~mask) ^ val);
143	return old;
144}
145
146static unsigned char status_mfc3_to_pc(unsigned char status)
147{
148	unsigned char ret = PARPORT_STATUS_BUSY;
149
150	if (status & 1) /* Busy */
151		ret &= ~PARPORT_STATUS_BUSY;
152	if (status & 2) /* PaperOut */
153		ret |= PARPORT_STATUS_PAPEROUT;
154	if (status & 4) /* Selected */
155		ret |= PARPORT_STATUS_SELECT;
156	if (status & 8) /* Ack */
157		ret |= PARPORT_STATUS_ACK;
158	if (status & 16) /* /ERROR */
159		ret |= PARPORT_STATUS_ERROR;
160
161	return ret;
162}
163
164static unsigned char mfc3_read_status(struct parport *p)
165{
166	unsigned char status;
167
168	status = status_mfc3_to_pc(pia(p)->ppra & 0x1f);
169	pr_debug("read_status %02x\n", status);
170	return status;
171}
172
173static int use_cnt;
174
175static irqreturn_t mfc3_interrupt(int irq, void *dev_id)
176{
177	int i;
178
179	for( i = 0; i < MAX_MFC; i++)
180		if (this_port[i] != NULL)
181			if (pia(this_port[i])->crb & 128) { /* Board caused interrupt */
182				dummy = pia(this_port[i])->pprb; /* clear irq bit */
183				parport_generic_irq(this_port[i]);
184			}
185	return IRQ_HANDLED;
186}
187
188static void mfc3_enable_irq(struct parport *p)
189{
190	pia(p)->crb |= PIA_C1_ENABLE_IRQ;
191}
192
193static void mfc3_disable_irq(struct parport *p)
194{
195	pia(p)->crb &= ~PIA_C1_ENABLE_IRQ;
196}
197
198static void mfc3_data_forward(struct parport *p)
199{
200	pr_debug("forward\n");
201	pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
202	pia(p)->pddrb = 255; /* all pins output */
203	pia(p)->crb |= PIA_DDR; /* make data register visible - default */
204}
205
206static void mfc3_data_reverse(struct parport *p)
207{
208	pr_debug("reverse\n");
209	pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
210	pia(p)->pddrb = 0; /* all pins input */
211	pia(p)->crb |= PIA_DDR; /* make data register visible - default */
212}
213
214static void mfc3_init_state(struct pardevice *dev, struct parport_state *s)
215{
216	s->u.amiga.data = 0;
217	s->u.amiga.datadir = 255;
218	s->u.amiga.status = 0;
219	s->u.amiga.statusdir = 0xe0;
220}
221
222static void mfc3_save_state(struct parport *p, struct parport_state *s)
223{
224	s->u.amiga.data = pia(p)->pprb;
225	pia(p)->crb &= ~PIA_DDR;
226	s->u.amiga.datadir = pia(p)->pddrb;
227	pia(p)->crb |= PIA_DDR;
228	s->u.amiga.status = pia(p)->ppra;
229	pia(p)->cra &= ~PIA_DDR;
230	s->u.amiga.statusdir = pia(p)->pddrb;
231	pia(p)->cra |= PIA_DDR;
232}
233
234static void mfc3_restore_state(struct parport *p, struct parport_state *s)
235{
236	pia(p)->pprb = s->u.amiga.data;
237	pia(p)->crb &= ~PIA_DDR;
238	pia(p)->pddrb = s->u.amiga.datadir;
239	pia(p)->crb |= PIA_DDR;
240	pia(p)->ppra = s->u.amiga.status;
241	pia(p)->cra &= ~PIA_DDR;
242	pia(p)->pddrb = s->u.amiga.statusdir;
243	pia(p)->cra |= PIA_DDR;
244}
245
246static struct parport_operations pp_mfc3_ops = {
247	.write_data	= mfc3_write_data,
248	.read_data	= mfc3_read_data,
249
250	.write_control	= mfc3_write_control,
251	.read_control	= mfc3_read_control,
252	.frob_control	= mfc3_frob_control,
253
254	.read_status	= mfc3_read_status,
255
256	.enable_irq	= mfc3_enable_irq,
257	.disable_irq	= mfc3_disable_irq,
258
259	.data_forward	= mfc3_data_forward, 
260	.data_reverse	= mfc3_data_reverse, 
261
262	.init_state	= mfc3_init_state,
263	.save_state	= mfc3_save_state,
264	.restore_state	= mfc3_restore_state,
265
266	.epp_write_data	= parport_ieee1284_epp_write_data,
267	.epp_read_data	= parport_ieee1284_epp_read_data,
268	.epp_write_addr	= parport_ieee1284_epp_write_addr,
269	.epp_read_addr	= parport_ieee1284_epp_read_addr,
270
271	.ecp_write_data	= parport_ieee1284_ecp_write_data,
272	.ecp_read_data	= parport_ieee1284_ecp_read_data,
273	.ecp_write_addr	= parport_ieee1284_ecp_write_addr,
274
275	.compat_write_data	= parport_ieee1284_write_compat,
276	.nibble_read_data	= parport_ieee1284_read_nibble,
277	.byte_read_data		= parport_ieee1284_read_byte,
278
279	.owner		= THIS_MODULE,
280};
281
282/* ----------- Initialisation code --------------------------------- */
283
284static int __init parport_mfc3_init(void)
285{
286	struct parport *p;
287	int pias = 0;
288	struct pia *pp;
289	struct zorro_dev *z = NULL;
290
291	if (!MACH_IS_AMIGA)
292		return -ENODEV;
293
294	while ((z = zorro_find_device(ZORRO_PROD_BSC_MULTIFACE_III, z))) {
295		unsigned long piabase = z->resource.start+PIABASE;
296		if (!request_mem_region(piabase, sizeof(struct pia), "PIA"))
297			continue;
298
299		pp = ZTWO_VADDR(piabase);
300		pp->crb = 0;
301		pp->pddrb = 255; /* all data pins output */
302		pp->crb = PIA_DDR|32|8;
303		dummy = pp->pddrb; /* reading clears interrupt */
304		pp->cra = 0;
305		pp->pddra = 0xe0; /* /RESET,  /DIR ,/AUTO-FEED output */
306		pp->cra = PIA_DDR;
307		pp->ppra = 0; /* reset printer */
308		udelay(10);
309		pp->ppra = 128;
310		p = parport_register_port((unsigned long)pp, IRQ_AMIGA_PORTS,
311					  PARPORT_DMA_NONE, &pp_mfc3_ops);
312		if (!p)
313			goto out_port;
314
315		if (p->irq != PARPORT_IRQ_NONE) {
316			if (use_cnt++ == 0)
317				if (request_irq(IRQ_AMIGA_PORTS, mfc3_interrupt, IRQF_SHARED, p->name, &pp_mfc3_ops))
318					goto out_irq;
319		}
320		p->dev = &z->dev;
321
322		this_port[pias++] = p;
323		pr_info("%s: Multiface III port using irq\n", p->name);
324		/* XXX: set operating mode */
325
326		p->private_data = (void *)piabase;
327		parport_announce_port (p);
328
329		if (pias >= MAX_MFC)
330			break;
331		continue;
332
333	out_irq:
334		parport_put_port(p);
335	out_port:
336		release_mem_region(piabase, sizeof(struct pia));
337	}
338
339	return pias ? 0 : -ENODEV;
340}
341
342static void __exit parport_mfc3_exit(void)
343{
344	int i;
345
346	for (i = 0; i < MAX_MFC; i++) {
347		if (!this_port[i])
348			continue;
349		parport_remove_port(this_port[i]);
350		if (this_port[i]->irq != PARPORT_IRQ_NONE) {
351			if (--use_cnt == 0) 
352				free_irq(IRQ_AMIGA_PORTS, &pp_mfc3_ops);
353		}
354		release_mem_region(ZTWO_PADDR(this_port[i]->private_data), sizeof(struct pia));
355		parport_put_port(this_port[i]);
356	}
357}
358
359
360MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
361MODULE_DESCRIPTION("Parport Driver for Multiface 3 expansion cards Parallel Port");
 
362MODULE_LICENSE("GPL");
363
364module_init(parport_mfc3_init)
365module_exit(parport_mfc3_exit)
v5.4
  1// SPDX-License-Identifier: GPL-2.0-only
  2/* Low-level parallel port routines for the Multiface 3 card
  3 *
  4 * Author: Joerg Dorchain <joerg@dorchain.net>
  5 *
  6 * (C) The elitist m68k Users(TM)
  7 *
  8 * based on the existing parport_amiga and lp_mfc
  9 *
 10 *
 11 * From the MFC3 documentation:
 12 * 
 13 * Miscellaneous PIA Details
 14 * -------------------------
 15 * 
 16 * 	The two open-drain interrupt outputs /IRQA and /IRQB are routed to
 17 * /INT2 of the Z2 bus.
 18 * 
 19 * 	The CPU data bus of the PIA (D0-D7) is connected to D8-D15 on the Z2
 20 * bus. This means that any PIA registers are accessed at even addresses.
 21 * 
 22 * Centronics Pin Connections for the PIA
 23 * --------------------------------------
 24 * 
 25 * 	The following table shows the connections between the PIA and the
 26 * Centronics interface connector. These connections implement a single, but
 27 * very complete, Centronics type interface. The Pin column gives the pin
 28 * numbers of the PIA. The Centronics pin numbers can be found in the section
 29 * "Parallel Connectors".
 30 * 
 31 * 
 32 *    Pin | PIA | Dir | Centronics Names
 33 * -------+-----+-----+---------------------------------------------------------
 34 *     19 | CB2 | --> | /STROBE (aka /DRDY)
 35 *  10-17 | PBx | <-> | DATA0 - DATA7
 36 *     18 | CB1 | <-- | /ACK
 37 *     40 | CA1 | <-- | BUSY
 38 *      3 | PA1 | <-- | PAPER-OUT (aka POUT)
 39 *      4 | PA2 | <-- | SELECTED (aka SEL)
 40 *      9 | PA7 | --> | /INIT (aka /RESET or /INPUT-PRIME)
 41 *      6 | PA4 | <-- | /ERROR (aka /FAULT)
 42 *      7 | PA5 | --> | DIR (aka /SELECT-IN)
 43 *      8 | PA6 | --> | /AUTO-FEED-XT
 44 *     39 | CA2 | --> | open
 45 *      5 | PA3 | <-- | /ACK (same as CB1!)
 46 *      2 | PA0 | <-- | BUSY (same as CA1!)
 47 * -------+-----+-----+---------------------------------------------------------
 48 * 
 49 * Should be enough to understand some of the driver.
 50 *
 51 * Per convention for normal use the port registers are visible.
 52 * If you need the data direction registers, restore the value in the
 53 * control register.
 54 */
 55
 56#include "multiface.h"
 57#include <linux/module.h>
 58#include <linux/init.h>
 59#include <linux/parport.h>
 60#include <linux/delay.h>
 61#include <linux/mc6821.h>
 62#include <linux/zorro.h>
 63#include <linux/interrupt.h>
 64#include <asm/setup.h>
 65#include <asm/amigahw.h>
 66#include <asm/irq.h>
 67#include <asm/amigaints.h>
 68
 69/* Maximum Number of Cards supported */
 70#define MAX_MFC 5
 71
 72#undef DEBUG
 73#ifdef DEBUG
 74#define DPRINTK printk
 75#else
 76static inline int DPRINTK(void *nothing, ...) {return 0;}
 77#endif
 78
 79static struct parport *this_port[MAX_MFC] = {NULL, };
 80static volatile int dummy; /* for trigger readds */
 81
 82#define pia(dev) ((struct pia *)(dev->base))
 83static struct parport_operations pp_mfc3_ops;
 84
 85static void mfc3_write_data(struct parport *p, unsigned char data)
 86{
 87DPRINTK(KERN_DEBUG "write_data %c\n",data);
 88
 89	dummy = pia(p)->pprb; /* clears irq bit */
 90	/* Triggers also /STROBE.*/
 91	pia(p)->pprb = data;
 92}
 93
 94static unsigned char mfc3_read_data(struct parport *p)
 95{
 96	/* clears interrupt bit. Triggers also /STROBE. */
 97	return pia(p)->pprb;
 98}
 99
100static unsigned char control_pc_to_mfc3(unsigned char control)
101{
102	unsigned char ret = 32|64;
103
104	if (control & PARPORT_CONTROL_SELECT) /* XXX: What is SELECP? */
105		ret &= ~32; /* /SELECT_IN */
106	if (control & PARPORT_CONTROL_INIT) /* INITP */
107		ret |= 128;
108	if (control & PARPORT_CONTROL_AUTOFD) /* AUTOLF */
109		ret &= ~64;
110	if (control & PARPORT_CONTROL_STROBE) /* Strobe */
111		/* Handled directly by hardware */;
112	return ret;
113}
114
115static unsigned char control_mfc3_to_pc(unsigned char control)
116{
117	unsigned char ret = PARPORT_CONTROL_STROBE 
118			  | PARPORT_CONTROL_AUTOFD | PARPORT_CONTROL_SELECT;
119
120	if (control & 128) /* /INITP */
121		ret |= PARPORT_CONTROL_INIT;
122	if (control & 64) /* /AUTOLF */
123		ret &= ~PARPORT_CONTROL_AUTOFD;
124	if (control & 32) /* /SELECT_IN */
125		ret &= ~PARPORT_CONTROL_SELECT;
126	return ret;
127}
128
129static void mfc3_write_control(struct parport *p, unsigned char control)
130{
131DPRINTK(KERN_DEBUG "write_control %02x\n",control);
132	pia(p)->ppra = (pia(p)->ppra & 0x1f) | control_pc_to_mfc3(control);
133}
134	
135static unsigned char mfc3_read_control( struct parport *p)
136{
137DPRINTK(KERN_DEBUG "read_control \n");
138	return control_mfc3_to_pc(pia(p)->ppra & 0xe0);
139}
140
141static unsigned char mfc3_frob_control( struct parport *p, unsigned char mask, unsigned char val)
142{
143	unsigned char old;
144
145DPRINTK(KERN_DEBUG "frob_control mask %02x, value %02x\n",mask,val);
146	old = mfc3_read_control(p);
147	mfc3_write_control(p, (old & ~mask) ^ val);
148	return old;
149}
150
151static unsigned char status_mfc3_to_pc(unsigned char status)
152{
153	unsigned char ret = PARPORT_STATUS_BUSY;
154
155	if (status & 1) /* Busy */
156		ret &= ~PARPORT_STATUS_BUSY;
157	if (status & 2) /* PaperOut */
158		ret |= PARPORT_STATUS_PAPEROUT;
159	if (status & 4) /* Selected */
160		ret |= PARPORT_STATUS_SELECT;
161	if (status & 8) /* Ack */
162		ret |= PARPORT_STATUS_ACK;
163	if (status & 16) /* /ERROR */
164		ret |= PARPORT_STATUS_ERROR;
165
166	return ret;
167}
168
169static unsigned char mfc3_read_status(struct parport *p)
170{
171	unsigned char status;
172
173	status = status_mfc3_to_pc(pia(p)->ppra & 0x1f);
174DPRINTK(KERN_DEBUG "read_status %02x\n", status);
175	return status;
176}
177
178static int use_cnt;
179
180static irqreturn_t mfc3_interrupt(int irq, void *dev_id)
181{
182	int i;
183
184	for( i = 0; i < MAX_MFC; i++)
185		if (this_port[i] != NULL)
186			if (pia(this_port[i])->crb & 128) { /* Board caused interrupt */
187				dummy = pia(this_port[i])->pprb; /* clear irq bit */
188				parport_generic_irq(this_port[i]);
189			}
190	return IRQ_HANDLED;
191}
192
193static void mfc3_enable_irq(struct parport *p)
194{
195	pia(p)->crb |= PIA_C1_ENABLE_IRQ;
196}
197
198static void mfc3_disable_irq(struct parport *p)
199{
200	pia(p)->crb &= ~PIA_C1_ENABLE_IRQ;
201}
202
203static void mfc3_data_forward(struct parport *p)
204{
205	DPRINTK(KERN_DEBUG "forward\n");
206	pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
207	pia(p)->pddrb = 255; /* all pins output */
208	pia(p)->crb |= PIA_DDR; /* make data register visible - default */
209}
210
211static void mfc3_data_reverse(struct parport *p)
212{
213	DPRINTK(KERN_DEBUG "reverse\n");
214	pia(p)->crb &= ~PIA_DDR; /* make data direction register visible */
215	pia(p)->pddrb = 0; /* all pins input */
216	pia(p)->crb |= PIA_DDR; /* make data register visible - default */
217}
218
219static void mfc3_init_state(struct pardevice *dev, struct parport_state *s)
220{
221	s->u.amiga.data = 0;
222	s->u.amiga.datadir = 255;
223	s->u.amiga.status = 0;
224	s->u.amiga.statusdir = 0xe0;
225}
226
227static void mfc3_save_state(struct parport *p, struct parport_state *s)
228{
229	s->u.amiga.data = pia(p)->pprb;
230	pia(p)->crb &= ~PIA_DDR;
231	s->u.amiga.datadir = pia(p)->pddrb;
232	pia(p)->crb |= PIA_DDR;
233	s->u.amiga.status = pia(p)->ppra;
234	pia(p)->cra &= ~PIA_DDR;
235	s->u.amiga.statusdir = pia(p)->pddrb;
236	pia(p)->cra |= PIA_DDR;
237}
238
239static void mfc3_restore_state(struct parport *p, struct parport_state *s)
240{
241	pia(p)->pprb = s->u.amiga.data;
242	pia(p)->crb &= ~PIA_DDR;
243	pia(p)->pddrb = s->u.amiga.datadir;
244	pia(p)->crb |= PIA_DDR;
245	pia(p)->ppra = s->u.amiga.status;
246	pia(p)->cra &= ~PIA_DDR;
247	pia(p)->pddrb = s->u.amiga.statusdir;
248	pia(p)->cra |= PIA_DDR;
249}
250
251static struct parport_operations pp_mfc3_ops = {
252	.write_data	= mfc3_write_data,
253	.read_data	= mfc3_read_data,
254
255	.write_control	= mfc3_write_control,
256	.read_control	= mfc3_read_control,
257	.frob_control	= mfc3_frob_control,
258
259	.read_status	= mfc3_read_status,
260
261	.enable_irq	= mfc3_enable_irq,
262	.disable_irq	= mfc3_disable_irq,
263
264	.data_forward	= mfc3_data_forward, 
265	.data_reverse	= mfc3_data_reverse, 
266
267	.init_state	= mfc3_init_state,
268	.save_state	= mfc3_save_state,
269	.restore_state	= mfc3_restore_state,
270
271	.epp_write_data	= parport_ieee1284_epp_write_data,
272	.epp_read_data	= parport_ieee1284_epp_read_data,
273	.epp_write_addr	= parport_ieee1284_epp_write_addr,
274	.epp_read_addr	= parport_ieee1284_epp_read_addr,
275
276	.ecp_write_data	= parport_ieee1284_ecp_write_data,
277	.ecp_read_data	= parport_ieee1284_ecp_read_data,
278	.ecp_write_addr	= parport_ieee1284_ecp_write_addr,
279
280	.compat_write_data	= parport_ieee1284_write_compat,
281	.nibble_read_data	= parport_ieee1284_read_nibble,
282	.byte_read_data		= parport_ieee1284_read_byte,
283
284	.owner		= THIS_MODULE,
285};
286
287/* ----------- Initialisation code --------------------------------- */
288
289static int __init parport_mfc3_init(void)
290{
291	struct parport *p;
292	int pias = 0;
293	struct pia *pp;
294	struct zorro_dev *z = NULL;
295
296	if (!MACH_IS_AMIGA)
297		return -ENODEV;
298
299	while ((z = zorro_find_device(ZORRO_PROD_BSC_MULTIFACE_III, z))) {
300		unsigned long piabase = z->resource.start+PIABASE;
301		if (!request_mem_region(piabase, sizeof(struct pia), "PIA"))
302			continue;
303
304		pp = ZTWO_VADDR(piabase);
305		pp->crb = 0;
306		pp->pddrb = 255; /* all data pins output */
307		pp->crb = PIA_DDR|32|8;
308		dummy = pp->pddrb; /* reading clears interrupt */
309		pp->cra = 0;
310		pp->pddra = 0xe0; /* /RESET,  /DIR ,/AUTO-FEED output */
311		pp->cra = PIA_DDR;
312		pp->ppra = 0; /* reset printer */
313		udelay(10);
314		pp->ppra = 128;
315		p = parport_register_port((unsigned long)pp, IRQ_AMIGA_PORTS,
316					  PARPORT_DMA_NONE, &pp_mfc3_ops);
317		if (!p)
318			goto out_port;
319
320		if (p->irq != PARPORT_IRQ_NONE) {
321			if (use_cnt++ == 0)
322				if (request_irq(IRQ_AMIGA_PORTS, mfc3_interrupt, IRQF_SHARED, p->name, &pp_mfc3_ops))
323					goto out_irq;
324		}
325		p->dev = &z->dev;
326
327		this_port[pias++] = p;
328		printk(KERN_INFO "%s: Multiface III port using irq\n", p->name);
329		/* XXX: set operating mode */
330
331		p->private_data = (void *)piabase;
332		parport_announce_port (p);
333
334		if (pias >= MAX_MFC)
335			break;
336		continue;
337
338	out_irq:
339		parport_put_port(p);
340	out_port:
341		release_mem_region(piabase, sizeof(struct pia));
342	}
343
344	return pias ? 0 : -ENODEV;
345}
346
347static void __exit parport_mfc3_exit(void)
348{
349	int i;
350
351	for (i = 0; i < MAX_MFC; i++) {
352		if (!this_port[i])
353			continue;
354		parport_remove_port(this_port[i]);
355		if (this_port[i]->irq != PARPORT_IRQ_NONE) {
356			if (--use_cnt == 0) 
357				free_irq(IRQ_AMIGA_PORTS, &pp_mfc3_ops);
358		}
359		release_mem_region(ZTWO_PADDR(this_port[i]->private_data), sizeof(struct pia));
360		parport_put_port(this_port[i]);
361	}
362}
363
364
365MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
366MODULE_DESCRIPTION("Parport Driver for Multiface 3 expansion cards Parallel Port");
367MODULE_SUPPORTED_DEVICE("Multiface 3 Parallel Port");
368MODULE_LICENSE("GPL");
369
370module_init(parport_mfc3_init)
371module_exit(parport_mfc3_exit)