1 #ifndef __LINUX_PARPORT_PC_H
2 #define __LINUX_PARPORT_PC_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. */
22 /* Bitmask of writable CTR bits. */
23 unsigned char ctr_writable
;
25 /* Whether or not there's an ECR. */
28 /* Number of PWords that FIFO will hold. */
31 /* Number of bytes per portword. */
35 int readIntrThreshold
;
36 int writeIntrThreshold
;
38 /* buffer suitable for DMA, if DMA enabled */
40 dma_addr_t dma_handle
;
41 struct list_head list
;
45 struct parport_pc_via_data
47 /* ISA PnP IRQ routing register 1 */
48 u8 via_pci_parport_irq_reg
;
49 /* ISA PnP DMA request routing register */
50 u8 via_pci_parport_dma_reg
;
51 /* Register and value to enable SuperIO configuration access */
52 u8 via_pci_superio_config_reg
;
53 u8 via_pci_superio_config_data
;
54 /* SuperIO function register number */
56 /* parallel port control register number */
57 u8 viacfg_parport_control
;
58 /* Parallel port base address register */
59 u8 viacfg_parport_base
;
62 static __inline__
void parport_pc_write_data(struct parport
*p
, unsigned char d
)
65 printk (KERN_DEBUG
"parport_pc_write_data(%p,0x%02x)\n", p
, d
);
70 static __inline__
unsigned char parport_pc_read_data(struct parport
*p
)
72 unsigned char val
= inb (DATA (p
));
74 printk (KERN_DEBUG
"parport_pc_read_data(%p) = 0x%02x\n",
81 static inline void dump_parport_state (char *str
, struct parport
*p
)
83 /* here's hoping that reading these ports won't side-effect anything underneath */
84 unsigned char ecr
= inb (ECONTROL (p
));
85 unsigned char dcr
= inb (CONTROL (p
));
86 unsigned char dsr
= inb (STATUS (p
));
87 static const char *const ecr_modes
[] = {"SPP", "PS2", "PPFIFO", "ECP", "xXx", "yYy", "TST", "CFG"};
88 const struct parport_pc_private
*priv
= p
->physport
->private_data
;
91 printk (KERN_DEBUG
"*** parport state (%s): ecr=[%s", str
, ecr_modes
[(ecr
& 0xe0) >> 5]);
92 if (ecr
& 0x10) printk (",nErrIntrEn");
93 if (ecr
& 0x08) printk (",dmaEn");
94 if (ecr
& 0x04) printk (",serviceIntr");
95 if (ecr
& 0x02) printk (",f_full");
96 if (ecr
& 0x01) printk (",f_empty");
98 printk ("] dcr(%s)=[", i
? "soft" : "hard");
99 dcr
= i
? priv
->ctr
: inb (CONTROL (p
));
106 if (dcr
& 0x10) printk (",ackIntEn");
107 if (!(dcr
& 0x08)) printk (",N-SELECT-IN");
108 if (dcr
& 0x04) printk (",N-INIT");
109 if (!(dcr
& 0x02)) printk (",N-AUTOFD");
110 if (!(dcr
& 0x01)) printk (",N-STROBE");
113 if (!(dsr
& 0x80)) printk ("BUSY");
114 if (dsr
& 0x40) printk (",N-ACK");
115 if (dsr
& 0x20) printk (",PERROR");
116 if (dsr
& 0x10) printk (",SELECT");
117 if (dsr
& 0x08) printk (",N-FAULT");
121 #else /* !DEBUG_PARPORT */
122 #define dump_parport_state(args...)
123 #endif /* !DEBUG_PARPORT */
125 /* __parport_pc_frob_control differs from parport_pc_frob_control in that
126 * it doesn't do any extra masking. */
127 static __inline__
unsigned char __parport_pc_frob_control (struct parport
*p
,
131 struct parport_pc_private
*priv
= p
->physport
->private_data
;
132 unsigned char ctr
= priv
->ctr
;
135 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
136 mask
, val
, ctr
, ((ctr
& ~mask
) ^ val
) & priv
->ctr_writable
);
138 ctr
= (ctr
& ~mask
) ^ val
;
139 ctr
&= priv
->ctr_writable
; /* only write writable bits. */
140 outb (ctr
, CONTROL (p
));
141 priv
->ctr
= ctr
; /* Update soft copy */
145 static __inline__
void parport_pc_data_reverse (struct parport
*p
)
147 __parport_pc_frob_control (p
, 0x20, 0x20);
150 static __inline__
void parport_pc_data_forward (struct parport
*p
)
152 __parport_pc_frob_control (p
, 0x20, 0x00);
155 static __inline__
void parport_pc_write_control (struct parport
*p
,
158 const unsigned char wm
= (PARPORT_CONTROL_STROBE
|
159 PARPORT_CONTROL_AUTOFD
|
160 PARPORT_CONTROL_INIT
|
161 PARPORT_CONTROL_SELECT
);
163 /* Take this out when drivers have adapted to newer interface. */
165 printk (KERN_DEBUG
"%s (%s): use data_reverse for this!\n",
166 p
->name
, p
->cad
->name
);
167 parport_pc_data_reverse (p
);
170 __parport_pc_frob_control (p
, wm
, d
& wm
);
173 static __inline__
unsigned char parport_pc_read_control(struct parport
*p
)
175 const unsigned char rm
= (PARPORT_CONTROL_STROBE
|
176 PARPORT_CONTROL_AUTOFD
|
177 PARPORT_CONTROL_INIT
|
178 PARPORT_CONTROL_SELECT
);
179 const struct parport_pc_private
*priv
= p
->physport
->private_data
;
180 return priv
->ctr
& rm
; /* Use soft copy */
183 static __inline__
unsigned char parport_pc_frob_control (struct parport
*p
,
187 const unsigned char wm
= (PARPORT_CONTROL_STROBE
|
188 PARPORT_CONTROL_AUTOFD
|
189 PARPORT_CONTROL_INIT
|
190 PARPORT_CONTROL_SELECT
);
192 /* Take this out when drivers have adapted to newer interface. */
194 printk (KERN_DEBUG
"%s (%s): use data_%s for this!\n",
195 p
->name
, p
->cad
->name
,
196 (val
& 0x20) ? "reverse" : "forward");
198 parport_pc_data_reverse (p
);
200 parport_pc_data_forward (p
);
203 /* Restrict mask and val to control lines. */
207 return __parport_pc_frob_control (p
, mask
, val
);
210 static __inline__
unsigned char parport_pc_read_status(struct parport
*p
)
212 return inb(STATUS(p
));
216 static __inline__
void parport_pc_disable_irq(struct parport
*p
)
218 __parport_pc_frob_control (p
, 0x10, 0x00);
221 static __inline__
void parport_pc_enable_irq(struct parport
*p
)
223 __parport_pc_frob_control (p
, 0x10, 0x10);
226 extern void parport_pc_release_resources(struct parport
*p
);
228 extern int parport_pc_claim_resources(struct parport
*p
);
230 /* PCMCIA code will want to get us to look at a port. Provide a mechanism. */
231 extern struct parport
*parport_pc_probe_port (unsigned long base
,
232 unsigned long base_hi
,
235 extern void parport_pc_unregister_port (struct parport
*p
);