Import 2.3.25pre1
[davej-history.git] / include / linux / parport_pc.h
blob6898c4e5f194032094b8c75428a2323a38aa75a7
1 #ifndef __LINUX_PARPORT_PC_H
2 #define __LINUX_PARPORT_PC_H
4 #include <asm/io.h>
6 /* --- register definitions ------------------------------- */
8 #define ECONTROL(p) ((p)->base_hi + 0x2)
9 #define CONFIGB(p) ((p)->base_hi + 0x1)
10 #define CONFIGA(p) ((p)->base_hi + 0x0)
11 #define FIFO(p) ((p)->base_hi + 0x0)
12 #define EPPDATA(p) ((p)->base + 0x4)
13 #define EPPADDR(p) ((p)->base + 0x3)
14 #define CONTROL(p) ((p)->base + 0x2)
15 #define STATUS(p) ((p)->base + 0x1)
16 #define DATA(p) ((p)->base + 0x0)
18 struct parport_pc_private {
19 /* Contents of CTR. */
20 unsigned char ctr;
22 /* Bitmask of writable CTR bits. */
23 unsigned char ctr_writable;
25 /* Whether or not there's an ECR. */
26 int ecr;
28 /* Number of PWords that FIFO will hold. */
29 int fifo_depth;
31 /* Number of bytes per portword. */
32 int pword;
34 /* Not used yet. */
35 int readIntrThreshold;
36 int writeIntrThreshold;
38 /* buffer suitable for DMA, if DMA enabled */
39 char *dma_buf;
42 extern __inline__ void parport_pc_write_data(struct parport *p, unsigned char d)
44 #ifdef DEBUG_PARPORT
45 printk (KERN_DEBUG "parport_pc_write_data(%p,0x%02x)\n", p, d);
46 #endif
47 outb(d, DATA(p));
50 extern __inline__ unsigned char parport_pc_read_data(struct parport *p)
52 unsigned char val = inb (DATA (p));
53 #ifdef DEBUG_PARPORT
54 printk (KERN_DEBUG "parport_pc_read_data(%p) = 0x%02x\n",
55 p, val);
56 #endif
57 return val;
60 /* __parport_pc_frob_control differs from parport_pc_frob_control in that
61 * it doesn't do any extra masking. */
62 static __inline__ unsigned char __parport_pc_frob_control (struct parport *p,
63 unsigned char mask,
64 unsigned char val)
66 struct parport_pc_private *priv = p->physport->private_data;
67 unsigned char ctr = priv->ctr;
68 #ifdef DEBUG_PARPORT
69 printk (KERN_DEBUG
70 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
71 mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
72 #endif
73 ctr = (ctr & ~mask) ^ val;
74 ctr &= priv->ctr_writable; /* only write writable bits. */
75 outb (ctr, CONTROL (p));
76 priv->ctr = ctr; /* Update soft copy */
77 return ctr;
80 extern __inline__ void parport_pc_data_reverse (struct parport *p)
82 __parport_pc_frob_control (p, 0x20, 0x20);
85 extern __inline__ void parport_pc_data_forward (struct parport *p)
87 __parport_pc_frob_control (p, 0x20, 0x00);
90 extern __inline__ void parport_pc_write_control (struct parport *p,
91 unsigned char d)
93 const unsigned char wm = (PARPORT_CONTROL_STROBE |
94 PARPORT_CONTROL_AUTOFD |
95 PARPORT_CONTROL_INIT |
96 PARPORT_CONTROL_SELECT);
98 /* Take this out when drivers have adapted to newer interface. */
99 if (d & 0x20) {
100 printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
101 p->name, p->cad->name);
102 parport_pc_data_reverse (p);
105 __parport_pc_frob_control (p, wm, d & wm);
108 extern __inline__ unsigned char parport_pc_read_control(struct parport *p)
110 const unsigned char rm = (PARPORT_CONTROL_STROBE |
111 PARPORT_CONTROL_AUTOFD |
112 PARPORT_CONTROL_INIT |
113 PARPORT_CONTROL_SELECT);
114 const struct parport_pc_private *priv = p->physport->private_data;
115 return priv->ctr & rm; /* Use soft copy */
118 extern __inline__ unsigned char parport_pc_frob_control (struct parport *p,
119 unsigned char mask,
120 unsigned char val)
122 const unsigned char wm = (PARPORT_CONTROL_STROBE |
123 PARPORT_CONTROL_AUTOFD |
124 PARPORT_CONTROL_INIT |
125 PARPORT_CONTROL_SELECT);
127 /* Take this out when drivers have adapted to newer interface. */
128 if (mask & 0x20) {
129 printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
130 p->name, p->cad->name,
131 (val & 0x20) ? "reverse" : "forward");
132 if (val & 0x20)
133 parport_pc_data_reverse (p);
134 else
135 parport_pc_data_forward (p);
138 /* Restrict mask and val to control lines. */
139 mask &= wm;
140 val &= wm;
142 return __parport_pc_frob_control (p, mask, val);
145 extern __inline__ unsigned char parport_pc_read_status(struct parport *p)
147 return inb(STATUS(p));
151 extern __inline__ void parport_pc_disable_irq(struct parport *p)
153 __parport_pc_frob_control (p, 0x10, 0x00);
156 extern __inline__ void parport_pc_enable_irq(struct parport *p)
158 __parport_pc_frob_control (p, 0x10, 0x10);
161 extern void parport_pc_release_resources(struct parport *p);
163 extern int parport_pc_claim_resources(struct parport *p);
165 extern void parport_pc_init_state(struct pardevice *, struct parport_state *s);
167 extern void parport_pc_save_state(struct parport *p, struct parport_state *s);
169 extern void parport_pc_restore_state(struct parport *p, struct parport_state *s);
171 extern void parport_pc_inc_use_count(void);
173 extern void parport_pc_dec_use_count(void);
175 /* PCMCIA code will want to get us to look at a port. Provide a mechanism. */
176 extern struct parport *parport_pc_probe_port (unsigned long base,
177 unsigned long base_hi,
178 int irq, int dma);
180 #endif