Import 2.2.0pre6
[davej-history.git] / drivers / misc / parport_arc.c
blob37c1e4e9ae856aa79e448ff17804fc8ad3aad383
1 /* Low-level parallel port routines for Archimedes onboard hardware
3 * Author: Phil Blundell <Philip.Blundell@pobox.com>
4 */
6 /* This driver is for the parallel port hardware found on Acorn's old
7 * range of Archimedes machines. The A5000 and newer systems have PC-style
8 * I/O hardware and should use the parport_pc driver instead.
10 * The Acorn printer port hardware is very simple. There is a single 8-bit
11 * write-only latch for the data port and control/status bits are handled
12 * with various auxilliary input and output lines. The port is not
13 * bidirectional, does not support any modes other than SPP, and has only
14 * a subset of the standard printer control lines connected.
17 #include <linux/tasks.h>
18 #include <linux/delay.h>
19 #include <linux/errno.h>
20 #include <linux/interrupt.h>
21 #include <linux/ioport.h>
22 #include <linux/kernel.h>
23 #include <linux/malloc.h>
24 #include <linux/parport.h>
26 #include <asm/ptrace.h>
27 #include <asm/io.h>
28 #include <asm/arch/oldlatches.h>
29 #include <asm/arch/irqs.h>
31 #define DATA_LATCH 0x3350010
33 /* ARC can't read from the data latch, so we must use a soft copy. */
34 static unsigned char data_copy;
36 static void arc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
38 parport_generic_irq(irq, (struct parport *) dev_id, regs);
41 static void arc_write_data(struct parport *p, unsigned char data)
43 data_copy = data;
44 outb(data, DATA_LATCH);
47 static unsigned char arc_read_data(struct parport *p)
49 return data_copy;
52 static void arc_inc_use_count(void)
54 #ifdef MODULE
55 MOD_INC_USE_COUNT;
56 #endif
59 static void arc_dec_use_count(void)
61 #ifdef MODULE
62 MOD_DEC_USE_COUNT;
63 #endif
66 static void arc_fill_inode(struct inode *inode, int fill)
68 #ifdef MODULE
69 if (fill)
70 MOD_INC_USE_COUNT;
71 else
72 MOD_DEC_USE_COUNT;
73 #endif
76 static struct parport_operations parport_arc_ops =
78 arc_write_data,
79 arc_read_data,
81 arc_write_control,
82 arc_read_control,
83 arc_frob_control,
85 NULL, /* write_econtrol */
86 NULL, /* read_econtrol */
87 NULL, /* frob_econtrol */
89 arc_write_status,
90 arc_read_status,
92 NULL, /* write_fifo */
93 NULL, /* read_fifo */
95 NULL, /* change_mode */
97 arc_release_resources,
98 arc_claim_resources,
100 NULL, /* epp_write_data */
101 NULL, /* epp_read_data */
102 NULL, /* epp_write_addr */
103 NULL, /* epp_read_addr */
104 NULL, /* epp_check_timeout */
106 NULL, /* epp_write_block */
107 NULL, /* epp_read_block */
109 NULL, /* ecp_write_block */
110 NULL, /* epp_write_block */
112 arc_init_state,
113 arc_save_state,
114 arc_restore_state,
116 arc_enable_irq,
117 arc_disable_irq,
118 arc_interrupt,
120 arc_inc_use_count,
121 arc_dec_use_count,
122 arc_fill_inode
125 /* --- Initialisation code -------------------------------- */
127 int parport_arc_init(void)
129 /* Archimedes hardware provides only one port, at a fixed address */
130 struct parport *p;
132 if (check_region(DATA_LATCH, 4))
133 return 0;
135 if (!(p = parport_register_port(base, IRQ_PRINTERACK,
136 PARPORT_DMA_NONE, &parport_arc_ops)))
137 return 0;
139 p->modes = PARPORT_MODE_ARCSPP;
140 p->size = 4;
142 printk(KERN_INFO "%s: Archimedes on-board port, using irq %d\n",
143 p->irq);
144 parport_proc_register(p);
145 p->flags |= PARPORT_FLAG_COMA;
147 if (parport_probe_hook)
148 (*parport_probe_hook)(p);
150 return 1;