[PATCH] w1: Adds a sysfs entry (w1_master_search) that allows you to disable/enable...
[linux-2.6/verdex.git] / include / linux / parport_pc.h
blob7825c76cbd00df635afb5bcef50775651b07e0cf
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;
42 struct list_head list;
43 struct parport *port;
46 struct parport_pc_via_data
48 /* ISA PnP IRQ routing register 1 */
49 u8 via_pci_parport_irq_reg;
50 /* ISA PnP DMA request routing register */
51 u8 via_pci_parport_dma_reg;
52 /* Register and value to enable SuperIO configuration access */
53 u8 via_pci_superio_config_reg;
54 u8 via_pci_superio_config_data;
55 /* SuperIO function register number */
56 u8 viacfg_function;
57 /* parallel port control register number */
58 u8 viacfg_parport_control;
59 /* Parallel port base address register */
60 u8 viacfg_parport_base;
63 static __inline__ void parport_pc_write_data(struct parport *p, unsigned char d)
65 #ifdef DEBUG_PARPORT
66 printk (KERN_DEBUG "parport_pc_write_data(%p,0x%02x)\n", p, d);
67 #endif
68 outb(d, DATA(p));
71 static __inline__ unsigned char parport_pc_read_data(struct parport *p)
73 unsigned char val = inb (DATA (p));
74 #ifdef DEBUG_PARPORT
75 printk (KERN_DEBUG "parport_pc_read_data(%p) = 0x%02x\n",
76 p, val);
77 #endif
78 return val;
81 #ifdef DEBUG_PARPORT
82 extern __inline__ void dump_parport_state (char *str, struct parport *p)
84 /* here's hoping that reading these ports won't side-effect anything underneath */
85 unsigned char ecr = inb (ECONTROL (p));
86 unsigned char dcr = inb (CONTROL (p));
87 unsigned char dsr = inb (STATUS (p));
88 static char *ecr_modes[] = {"SPP", "PS2", "PPFIFO", "ECP", "xXx", "yYy", "TST", "CFG"};
89 const struct parport_pc_private *priv = (parport_pc_private *)p->physport->private_data;
90 int i;
92 printk (KERN_DEBUG "*** parport state (%s): ecr=[%s", str, ecr_modes[(ecr & 0xe0) >> 5]);
93 if (ecr & 0x10) printk (",nErrIntrEn");
94 if (ecr & 0x08) printk (",dmaEn");
95 if (ecr & 0x04) printk (",serviceIntr");
96 if (ecr & 0x02) printk (",f_full");
97 if (ecr & 0x01) printk (",f_empty");
98 for (i=0; i<2; i++) {
99 printk ("] dcr(%s)=[", i ? "soft" : "hard");
100 dcr = i ? priv->ctr : inb (CONTROL (p));
102 if (dcr & 0x20) {
103 printk ("rev");
104 } else {
105 printk ("fwd");
107 if (dcr & 0x10) printk (",ackIntEn");
108 if (!(dcr & 0x08)) printk (",N-SELECT-IN");
109 if (dcr & 0x04) printk (",N-INIT");
110 if (!(dcr & 0x02)) printk (",N-AUTOFD");
111 if (!(dcr & 0x01)) printk (",N-STROBE");
113 printk ("] dsr=[");
114 if (!(dsr & 0x80)) printk ("BUSY");
115 if (dsr & 0x40) printk (",N-ACK");
116 if (dsr & 0x20) printk (",PERROR");
117 if (dsr & 0x10) printk (",SELECT");
118 if (dsr & 0x08) printk (",N-FAULT");
119 printk ("]\n");
120 return;
122 #else /* !DEBUG_PARPORT */
123 #define dump_parport_state(args...)
124 #endif /* !DEBUG_PARPORT */
126 /* __parport_pc_frob_control differs from parport_pc_frob_control in that
127 * it doesn't do any extra masking. */
128 static __inline__ unsigned char __parport_pc_frob_control (struct parport *p,
129 unsigned char mask,
130 unsigned char val)
132 struct parport_pc_private *priv = p->physport->private_data;
133 unsigned char ctr = priv->ctr;
134 #ifdef DEBUG_PARPORT
135 printk (KERN_DEBUG
136 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
137 mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
138 #endif
139 ctr = (ctr & ~mask) ^ val;
140 ctr &= priv->ctr_writable; /* only write writable bits. */
141 outb (ctr, CONTROL (p));
142 priv->ctr = ctr; /* Update soft copy */
143 return ctr;
146 static __inline__ void parport_pc_data_reverse (struct parport *p)
148 __parport_pc_frob_control (p, 0x20, 0x20);
151 static __inline__ void parport_pc_data_forward (struct parport *p)
153 __parport_pc_frob_control (p, 0x20, 0x00);
156 static __inline__ void parport_pc_write_control (struct parport *p,
157 unsigned char d)
159 const unsigned char wm = (PARPORT_CONTROL_STROBE |
160 PARPORT_CONTROL_AUTOFD |
161 PARPORT_CONTROL_INIT |
162 PARPORT_CONTROL_SELECT);
164 /* Take this out when drivers have adapted to newer interface. */
165 if (d & 0x20) {
166 printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
167 p->name, p->cad->name);
168 parport_pc_data_reverse (p);
171 __parport_pc_frob_control (p, wm, d & wm);
174 static __inline__ unsigned char parport_pc_read_control(struct parport *p)
176 const unsigned char rm = (PARPORT_CONTROL_STROBE |
177 PARPORT_CONTROL_AUTOFD |
178 PARPORT_CONTROL_INIT |
179 PARPORT_CONTROL_SELECT);
180 const struct parport_pc_private *priv = p->physport->private_data;
181 return priv->ctr & rm; /* Use soft copy */
184 static __inline__ unsigned char parport_pc_frob_control (struct parport *p,
185 unsigned char mask,
186 unsigned char val)
188 const unsigned char wm = (PARPORT_CONTROL_STROBE |
189 PARPORT_CONTROL_AUTOFD |
190 PARPORT_CONTROL_INIT |
191 PARPORT_CONTROL_SELECT);
193 /* Take this out when drivers have adapted to newer interface. */
194 if (mask & 0x20) {
195 printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
196 p->name, p->cad->name,
197 (val & 0x20) ? "reverse" : "forward");
198 if (val & 0x20)
199 parport_pc_data_reverse (p);
200 else
201 parport_pc_data_forward (p);
204 /* Restrict mask and val to control lines. */
205 mask &= wm;
206 val &= wm;
208 return __parport_pc_frob_control (p, mask, val);
211 static __inline__ unsigned char parport_pc_read_status(struct parport *p)
213 return inb(STATUS(p));
217 static __inline__ void parport_pc_disable_irq(struct parport *p)
219 __parport_pc_frob_control (p, 0x10, 0x00);
222 static __inline__ void parport_pc_enable_irq(struct parport *p)
224 __parport_pc_frob_control (p, 0x10, 0x10);
227 extern void parport_pc_release_resources(struct parport *p);
229 extern int parport_pc_claim_resources(struct parport *p);
231 /* PCMCIA code will want to get us to look at a port. Provide a mechanism. */
232 extern struct parport *parport_pc_probe_port (unsigned long base,
233 unsigned long base_hi,
234 int irq, int dma,
235 struct pci_dev *dev);
236 extern void parport_pc_unregister_port (struct parport *p);
238 #endif