Updated binary toolchain for kernel 2.4 target (gcc 4.2.4, binutils 2.20.1)
[tomato.git] / tools / brcm / K24 / hndtools-mipsel-uclibc-4.2.4 / include / linux / parport_pc.h
blob6a3c032df1c7d5627ac31497b616f3bcd1016f0e
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;
40 dma_addr_t dma_handle;
41 struct pci_dev *dev;
44 static __inline__ void parport_pc_write_data(struct parport *p, unsigned char d)
46 #ifdef DEBUG_PARPORT
47 printk (KERN_DEBUG "parport_pc_write_data(%p,0x%02x)\n", p, d);
48 #endif
49 outb(d, DATA(p));
52 static __inline__ unsigned char parport_pc_read_data(struct parport *p)
54 unsigned char val = inb (DATA (p));
55 #ifdef DEBUG_PARPORT
56 printk (KERN_DEBUG "parport_pc_read_data(%p) = 0x%02x\n",
57 p, val);
58 #endif
59 return val;
62 #ifdef DEBUG_PARPORT
63 extern __inline__ void dump_parport_state (char *str, struct parport *p)
65 /* here's hoping that reading these ports won't side-effect anything underneath */
66 unsigned char ecr = inb (ECONTROL (p));
67 unsigned char dcr = inb (CONTROL (p));
68 unsigned char dsr = inb (STATUS (p));
69 static char *ecr_modes[] = {"SPP", "PS2", "PPFIFO", "ECP", "xXx", "yYy", "TST", "CFG"};
70 const struct parport_pc_private *priv = (parport_pc_private *)p->physport->private_data;
71 int i;
73 printk (KERN_DEBUG "*** parport state (%s): ecr=[%s", str, ecr_modes[(ecr & 0xe0) >> 5]);
74 if (ecr & 0x10) printk (",nErrIntrEn");
75 if (ecr & 0x08) printk (",dmaEn");
76 if (ecr & 0x04) printk (",serviceIntr");
77 if (ecr & 0x02) printk (",f_full");
78 if (ecr & 0x01) printk (",f_empty");
79 for (i=0; i<2; i++) {
80 printk ("] dcr(%s)=[", i ? "soft" : "hard");
81 dcr = i ? priv->ctr : inb (CONTROL (p));
83 if (dcr & 0x20) {
84 printk ("rev");
85 } else {
86 printk ("fwd");
88 if (dcr & 0x10) printk (",ackIntEn");
89 if (!(dcr & 0x08)) printk (",N-SELECT-IN");
90 if (dcr & 0x04) printk (",N-INIT");
91 if (!(dcr & 0x02)) printk (",N-AUTOFD");
92 if (!(dcr & 0x01)) printk (",N-STROBE");
94 printk ("] dsr=[");
95 if (!(dsr & 0x80)) printk ("BUSY");
96 if (dsr & 0x40) printk (",N-ACK");
97 if (dsr & 0x20) printk (",PERROR");
98 if (dsr & 0x10) printk (",SELECT");
99 if (dsr & 0x08) printk (",N-FAULT");
100 printk ("]\n");
101 return;
103 #else /* !DEBUG_PARPORT */
104 #define dump_parport_state(args...)
105 #endif /* !DEBUG_PARPORT */
107 /* __parport_pc_frob_control differs from parport_pc_frob_control in that
108 * it doesn't do any extra masking. */
109 static __inline__ unsigned char __parport_pc_frob_control (struct parport *p,
110 unsigned char mask,
111 unsigned char val)
113 struct parport_pc_private *priv = p->physport->private_data;
114 unsigned char ctr = priv->ctr;
115 #ifdef DEBUG_PARPORT
116 printk (KERN_DEBUG
117 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
118 mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
119 #endif
120 ctr = (ctr & ~mask) ^ val;
121 ctr &= priv->ctr_writable; /* only write writable bits. */
122 outb (ctr, CONTROL (p));
123 priv->ctr = ctr; /* Update soft copy */
124 return ctr;
127 static __inline__ void parport_pc_data_reverse (struct parport *p)
129 __parport_pc_frob_control (p, 0x20, 0x20);
132 static __inline__ void parport_pc_data_forward (struct parport *p)
134 __parport_pc_frob_control (p, 0x20, 0x00);
137 static __inline__ void parport_pc_write_control (struct parport *p,
138 unsigned char d)
140 const unsigned char wm = (PARPORT_CONTROL_STROBE |
141 PARPORT_CONTROL_AUTOFD |
142 PARPORT_CONTROL_INIT |
143 PARPORT_CONTROL_SELECT);
145 /* Take this out when drivers have adapted to newer interface. */
146 if (d & 0x20) {
147 printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
148 p->name, p->cad->name);
149 parport_pc_data_reverse (p);
152 __parport_pc_frob_control (p, wm, d & wm);
155 static __inline__ unsigned char parport_pc_read_control(struct parport *p)
157 const unsigned char rm = (PARPORT_CONTROL_STROBE |
158 PARPORT_CONTROL_AUTOFD |
159 PARPORT_CONTROL_INIT |
160 PARPORT_CONTROL_SELECT);
161 const struct parport_pc_private *priv = p->physport->private_data;
162 return priv->ctr & rm; /* Use soft copy */
165 static __inline__ unsigned char parport_pc_frob_control (struct parport *p,
166 unsigned char mask,
167 unsigned char val)
169 const unsigned char wm = (PARPORT_CONTROL_STROBE |
170 PARPORT_CONTROL_AUTOFD |
171 PARPORT_CONTROL_INIT |
172 PARPORT_CONTROL_SELECT);
174 /* Take this out when drivers have adapted to newer interface. */
175 if (mask & 0x20) {
176 printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
177 p->name, p->cad->name,
178 (val & 0x20) ? "reverse" : "forward");
179 if (val & 0x20)
180 parport_pc_data_reverse (p);
181 else
182 parport_pc_data_forward (p);
185 /* Restrict mask and val to control lines. */
186 mask &= wm;
187 val &= wm;
189 return __parport_pc_frob_control (p, mask, val);
192 static __inline__ unsigned char parport_pc_read_status(struct parport *p)
194 return inb(STATUS(p));
198 static __inline__ void parport_pc_disable_irq(struct parport *p)
200 __parport_pc_frob_control (p, 0x10, 0x00);
203 static __inline__ void parport_pc_enable_irq(struct parport *p)
205 __parport_pc_frob_control (p, 0x10, 0x10);
208 extern void parport_pc_release_resources(struct parport *p);
210 extern int parport_pc_claim_resources(struct parport *p);
212 extern void parport_pc_init_state(struct pardevice *, struct parport_state *s);
214 extern void parport_pc_save_state(struct parport *p, struct parport_state *s);
216 extern void parport_pc_restore_state(struct parport *p, struct parport_state *s);
218 extern void parport_pc_inc_use_count(void);
220 extern void parport_pc_dec_use_count(void);
222 /* PCMCIA code will want to get us to look at a port. Provide a mechanism. */
223 extern struct parport *parport_pc_probe_port (unsigned long base,
224 unsigned long base_hi,
225 int irq, int dma,
226 struct pci_dev *dev);
227 extern void parport_pc_unregister_port (struct parport *p);
229 #endif