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
;
42 struct list_head list
;
46 static __inline__
void parport_pc_write_data(struct parport
*p
, unsigned char d
)
49 printk (KERN_DEBUG
"parport_pc_write_data(%p,0x%02x)\n", p
, d
);
54 static __inline__
unsigned char parport_pc_read_data(struct parport
*p
)
56 unsigned char val
= inb (DATA (p
));
58 printk (KERN_DEBUG
"parport_pc_read_data(%p) = 0x%02x\n",
65 extern __inline__
void dump_parport_state (char *str
, struct parport
*p
)
67 /* here's hoping that reading these ports won't side-effect anything underneath */
68 unsigned char ecr
= inb (ECONTROL (p
));
69 unsigned char dcr
= inb (CONTROL (p
));
70 unsigned char dsr
= inb (STATUS (p
));
71 static char *ecr_modes
[] = {"SPP", "PS2", "PPFIFO", "ECP", "xXx", "yYy", "TST", "CFG"};
72 const struct parport_pc_private
*priv
= (parport_pc_private
*)p
->physport
->private_data
;
75 printk (KERN_DEBUG
"*** parport state (%s): ecr=[%s", str
, ecr_modes
[(ecr
& 0xe0) >> 5]);
76 if (ecr
& 0x10) printk (",nErrIntrEn");
77 if (ecr
& 0x08) printk (",dmaEn");
78 if (ecr
& 0x04) printk (",serviceIntr");
79 if (ecr
& 0x02) printk (",f_full");
80 if (ecr
& 0x01) printk (",f_empty");
82 printk ("] dcr(%s)=[", i
? "soft" : "hard");
83 dcr
= i
? priv
->ctr
: inb (CONTROL (p
));
90 if (dcr
& 0x10) printk (",ackIntEn");
91 if (!(dcr
& 0x08)) printk (",N-SELECT-IN");
92 if (dcr
& 0x04) printk (",N-INIT");
93 if (!(dcr
& 0x02)) printk (",N-AUTOFD");
94 if (!(dcr
& 0x01)) printk (",N-STROBE");
97 if (!(dsr
& 0x80)) printk ("BUSY");
98 if (dsr
& 0x40) printk (",N-ACK");
99 if (dsr
& 0x20) printk (",PERROR");
100 if (dsr
& 0x10) printk (",SELECT");
101 if (dsr
& 0x08) printk (",N-FAULT");
105 #else /* !DEBUG_PARPORT */
106 #define dump_parport_state(args...)
107 #endif /* !DEBUG_PARPORT */
109 /* __parport_pc_frob_control differs from parport_pc_frob_control in that
110 * it doesn't do any extra masking. */
111 static __inline__
unsigned char __parport_pc_frob_control (struct parport
*p
,
115 struct parport_pc_private
*priv
= p
->physport
->private_data
;
116 unsigned char ctr
= priv
->ctr
;
119 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
120 mask
, val
, ctr
, ((ctr
& ~mask
) ^ val
) & priv
->ctr_writable
);
122 ctr
= (ctr
& ~mask
) ^ val
;
123 ctr
&= priv
->ctr_writable
; /* only write writable bits. */
124 outb (ctr
, CONTROL (p
));
125 priv
->ctr
= ctr
; /* Update soft copy */
129 static __inline__
void parport_pc_data_reverse (struct parport
*p
)
131 __parport_pc_frob_control (p
, 0x20, 0x20);
134 static __inline__
void parport_pc_data_forward (struct parport
*p
)
136 __parport_pc_frob_control (p
, 0x20, 0x00);
139 static __inline__
void parport_pc_write_control (struct parport
*p
,
142 const unsigned char wm
= (PARPORT_CONTROL_STROBE
|
143 PARPORT_CONTROL_AUTOFD
|
144 PARPORT_CONTROL_INIT
|
145 PARPORT_CONTROL_SELECT
);
147 /* Take this out when drivers have adapted to newer interface. */
149 printk (KERN_DEBUG
"%s (%s): use data_reverse for this!\n",
150 p
->name
, p
->cad
->name
);
151 parport_pc_data_reverse (p
);
154 __parport_pc_frob_control (p
, wm
, d
& wm
);
157 static __inline__
unsigned char parport_pc_read_control(struct parport
*p
)
159 const unsigned char rm
= (PARPORT_CONTROL_STROBE
|
160 PARPORT_CONTROL_AUTOFD
|
161 PARPORT_CONTROL_INIT
|
162 PARPORT_CONTROL_SELECT
);
163 const struct parport_pc_private
*priv
= p
->physport
->private_data
;
164 return priv
->ctr
& rm
; /* Use soft copy */
167 static __inline__
unsigned char parport_pc_frob_control (struct parport
*p
,
171 const unsigned char wm
= (PARPORT_CONTROL_STROBE
|
172 PARPORT_CONTROL_AUTOFD
|
173 PARPORT_CONTROL_INIT
|
174 PARPORT_CONTROL_SELECT
);
176 /* Take this out when drivers have adapted to newer interface. */
178 printk (KERN_DEBUG
"%s (%s): use data_%s for this!\n",
179 p
->name
, p
->cad
->name
,
180 (val
& 0x20) ? "reverse" : "forward");
182 parport_pc_data_reverse (p
);
184 parport_pc_data_forward (p
);
187 /* Restrict mask and val to control lines. */
191 return __parport_pc_frob_control (p
, mask
, val
);
194 static __inline__
unsigned char parport_pc_read_status(struct parport
*p
)
196 return inb(STATUS(p
));
200 static __inline__
void parport_pc_disable_irq(struct parport
*p
)
202 __parport_pc_frob_control (p
, 0x10, 0x00);
205 static __inline__
void parport_pc_enable_irq(struct parport
*p
)
207 __parport_pc_frob_control (p
, 0x10, 0x10);
210 extern void parport_pc_release_resources(struct parport
*p
);
212 extern int parport_pc_claim_resources(struct parport
*p
);
214 extern void parport_pc_init_state(struct pardevice
*, struct parport_state
*s
);
216 extern void parport_pc_save_state(struct parport
*p
, struct parport_state
*s
);
218 extern void parport_pc_restore_state(struct parport
*p
, struct parport_state
*s
);
220 /* PCMCIA code will want to get us to look at a port. Provide a mechanism. */
221 extern struct parport
*parport_pc_probe_port (unsigned long base
,
222 unsigned long base_hi
,
224 struct pci_dev
*dev
);
225 extern void parport_pc_unregister_port (struct parport
*p
);