3 * split into mid and low-level for better support of different hardware
4 * by Joerg Dorchain (dorchain@mpi-sb.mpg.de)
6 * Amiga printer device by Michael Rausch (linux@uni-koblenz.de);
7 * Atari support added by Andreas Schwab (schwab@ls5.informatik.uni-dortmund.de);
10 * Copyright (C) 1992 by Jim Weigand and Linus Torvalds
11 * Copyright (C) 1992,1993 by Michael K. Johnson
12 * - Thanks much to Gunter Windau for pointing out to me where the error
13 * checking ought to be.
14 * Copyright (C) 1993 by Nigel Gamble (added interrupt code)
17 #include <linux/module.h>
18 #include <linux/config.h>
19 #include <linux/kernel.h>
20 #include <linux/types.h>
21 #include <linux/sched.h>
22 #include <linux/init.h>
24 #include <asm/setup.h>
26 #include <asm/amigahw.h>
27 #include <asm/amigaints.h>
30 #include <linux/delay.h>
31 #include <linux/sched.h>
32 #include <asm/atarihw.h>
33 #include <asm/atariints.h>
36 #include <asm/mvme16xhw.h>
38 #ifdef CONFIG_BVME6000
39 #include<asm/bvme6000hw.h>
41 #include <linux/lp_intern.h>
43 static int minor
= -1;
44 MODULE_PARM(minor
,"i");
46 static void lp_int_out(int, int);
47 static int lp_int_busy(int);
48 static int lp_int_pout(int);
49 static int lp_int_online(int);
53 lp_int_out (int c
, int dev
)
55 switch (m68k_machtype
)
61 while (wait
!= lp_table
[dev
]->wait
) wait
++;
70 sound_ym
.rd_data_reg_sel
= 15;
72 sound_ym
.rd_data_reg_sel
= 14;
73 while (wait
!= lp_table
[dev
]->wait
) wait
++;
74 sound_ym
.wd_data
= sound_ym
.rd_data_reg_sel
& ~(1 << 5);
76 sound_ym
.wd_data
= sound_ym
.rd_data_reg_sel
| (1 << 5);
84 while (wait
!= lp_table
[dev
]->wait
) wait
++;
89 #ifdef CONFIG_BVME6000
93 while (wait
!= lp_table
[dev
]->wait
) wait
++;
103 lp_int_busy (int dev
)
105 switch (m68k_machtype
)
113 return mfp
.par_dt_reg
& 1;
115 #ifdef CONFIG_MVME16x
117 return mvmelp
.isr
& 1;
119 #ifdef CONFIG_BVME6000
121 return 0 /* !(bvmepit.psr & 0x40) */ ;
129 lp_int_pout (int dev
)
131 switch (m68k_machtype
)
141 #ifdef CONFIG_MVME16x
143 return mvmelp
.isr
& 2;
145 #ifdef CONFIG_BVME6000
155 lp_int_online (int dev
)
157 switch (m68k_machtype
)
165 return !(mfp
.par_dt_reg
& 1);
167 #ifdef CONFIG_MVME16x
169 return mvmelp
.isr
& 4;
171 #ifdef CONFIG_BVME6000
180 static void lp_int_interrupt(int irq
, void *data
, struct pt_regs
*fp
)
182 #ifdef CONFIG_MVME16x
184 mvmelp
.ack_icr
|= 0x08;
186 #ifdef CONFIG_BVME6000
187 if (MACH_IS_BVME6000
)
188 bvmepit
.pacr
&= ~0x02;
193 static int lp_int_open(int dev
)
199 static void lp_int_release(int dev
)
204 static struct lp_struct tab
= {
205 "Builtin parallel port", /* name */
223 __initfunc(int lp_internal_init(void))
226 if (MACH_IS_AMIGA
&& AMIGAHW_PRESENT(AMI_PARALLEL
))
231 tab
.irq
= request_irq(IRQ_AMIGA_CIAA_FLG
, lp_int_interrupt
,
232 0, "builtin printer port", lp_int_interrupt
);
233 tab
.base
= (void *) &ciaa
.prb
; /* dummy, not used */
244 sound_ym
.rd_data_reg_sel
= 7;
245 sound_ym
.wd_data
= (sound_ym
.rd_data_reg_sel
& 0x3f) | 0xc0;
246 restore_flags(flags
);
248 tab
.irq
= request_irq(IRQ_MFP_BUSY
, lp_int_interrupt
,
249 IRQ_TYPE_SLOW
, "builtin printer port", lp_int_interrupt
);
250 tab
.base
= (void *) &sound_ym
.wd_data
; /* dummy, not used */
258 #ifdef CONFIG_MVME16x
263 if (!(mvme16x_config
& MVME16x_CONFIG_GOT_LP
))
268 mvmelp
.ack_icr
= 0x08;
269 mvmelp
.flt_icr
= 0x08;
270 mvmelp
.sel_icr
= 0x08;
271 mvmelp
.pe_icr
= 0x08;
272 mvmelp
.bsy_icr
= 0x08;
274 mvmelp
.ack_icr
= 0xd9; /* Int on trailing edge of ACK */
275 restore_flags(flags
);
278 tab
.irq
= request_irq(MVME167_IRQ_PRN
, lp_int_interrupt
,
279 0, "builtin printer port", lp_int_interrupt
);
280 tab
.base
= (void *)&mvmelp
; /* dummy, not used */
281 tab
.type
= LP_MVME167
;
284 #ifdef CONFIG_BVME6000
285 if (MACH_IS_BVME6000
)
293 bvmepit
.paddr
= 0xff;
294 bvmepit
.pcdr
= (bvmepit
.pcdr
& 0xfc) | 0x02;
295 bvmepit
.pcddr
|= 0x03;
298 bvmepit
.pivr
= BVME_IRQ_PRN
;
300 restore_flags(flags
);
303 tab
.irq
= request_irq(BVME_IRQ_PRN
, lp_int_interrupt
,
304 0, "builtin printer port", lp_int_interrupt
);
305 tab
.base
= (void *)&bvmepit
; /* dummy, not used */
306 tab
.type
= LP_BVME6000
;
311 if ((minor
= register_parallel(&tab
, minor
)) < 0) {
312 printk("builtin lp init: cant get a minor\n");
316 free_irq(IRQ_AMIGA_CIAA_FLG
, lp_int_interrupt
);
320 free_irq(IRQ_MFP_BUSY
, lp_int_interrupt
);
322 #ifdef CONFIG_MVME16x
324 free_irq(MVME167_IRQ_PRN
, lp_int_interrupt
);
326 #ifdef CONFIG_BVME6000
327 if (MACH_IS_BVME6000
)
328 free_irq(BVME_IRQ_PRN
, lp_int_interrupt
);
338 int init_module(void)
340 return lp_internal_init();
343 void cleanup_module(void)
348 free_irq(IRQ_AMIGA_CIAA_FLG
, lp_int_interrupt
);
352 free_irq(IRQ_MFP_BUSY
, lp_int_interrupt
);
354 #ifdef CONFIG_MVME16x
356 free_irq(MVME167_IRQ_PRN
, lp_int_interrupt
);
358 #ifdef CONFIG_BVME6000
359 if (MACH_IS_BVME6000
)
360 free_irq(BVME_IRQ_PRN
, lp_int_interrupt
);
363 unregister_parallel(minor
);