Linux Audio

Check our new training course

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