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
;
44 static __inline__
void parport_pc_write_data(struct parport
*p
, unsigned char d
)
47 printk (KERN_DEBUG
"parport_pc_write_data(%p,0x%02x)\n", p
, d
);
52 static __inline__
unsigned char parport_pc_read_data(struct parport
*p
)
54 unsigned char val
= inb (DATA (p
));
56 printk (KERN_DEBUG
"parport_pc_read_data(%p) = 0x%02x\n",
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
;
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");
80 printk ("] dcr(%s)=[", i
? "soft" : "hard");
81 dcr
= i
? priv
->ctr
: inb (CONTROL (p
));
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");
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");
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
,
113 struct parport_pc_private
*priv
= p
->physport
->private_data
;
114 unsigned char ctr
= priv
->ctr
;
117 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
118 mask
, val
, ctr
, ((ctr
& ~mask
) ^ val
) & priv
->ctr_writable
);
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 */
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
,
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. */
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
,
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. */
176 printk (KERN_DEBUG
"%s (%s): use data_%s for this!\n",
177 p
->name
, p
->cad
->name
,
178 (val
& 0x20) ? "reverse" : "forward");
180 parport_pc_data_reverse (p
);
182 parport_pc_data_forward (p
);
185 /* Restrict mask and val to control lines. */
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
,
226 struct pci_dev
*dev
);
227 extern void parport_pc_unregister_port (struct parport
*p
);