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 */
42 extern __inline__
void parport_pc_write_data(struct parport
*p
, unsigned char d
)
45 printk (KERN_DEBUG
"parport_pc_write_data(%p,0x%02x)\n", p
, d
);
50 extern __inline__
unsigned char parport_pc_read_data(struct parport
*p
)
52 unsigned char val
= inb (DATA (p
));
54 printk (KERN_DEBUG
"parport_pc_read_data(%p) = 0x%02x\n",
60 /* __parport_pc_frob_control differs from parport_pc_frob_control in that
61 * it doesn't do any extra masking. */
62 static __inline__
unsigned char __parport_pc_frob_control (struct parport
*p
,
66 struct parport_pc_private
*priv
= p
->physport
->private_data
;
67 unsigned char ctr
= priv
->ctr
;
70 "__parport_pc_frob_control(%02x,%02x): %02x -> %02x\n",
71 mask
, val
, ctr
, ((ctr
& ~mask
) ^ val
) & priv
->ctr_writable
);
73 ctr
= (ctr
& ~mask
) ^ val
;
74 ctr
&= priv
->ctr_writable
; /* only write writable bits. */
75 outb (ctr
, CONTROL (p
));
76 priv
->ctr
= ctr
; /* Update soft copy */
80 extern __inline__
void parport_pc_data_reverse (struct parport
*p
)
82 __parport_pc_frob_control (p
, 0x20, 0x20);
85 extern __inline__
void parport_pc_data_forward (struct parport
*p
)
87 __parport_pc_frob_control (p
, 0x20, 0x00);
90 extern __inline__
void parport_pc_write_control (struct parport
*p
,
93 const unsigned char wm
= (PARPORT_CONTROL_STROBE
|
94 PARPORT_CONTROL_AUTOFD
|
95 PARPORT_CONTROL_INIT
|
96 PARPORT_CONTROL_SELECT
);
98 /* Take this out when drivers have adapted to newer interface. */
100 printk (KERN_DEBUG
"%s (%s): use data_reverse for this!\n",
101 p
->name
, p
->cad
->name
);
102 parport_pc_data_reverse (p
);
105 __parport_pc_frob_control (p
, wm
, d
& wm
);
108 extern __inline__
unsigned char parport_pc_read_control(struct parport
*p
)
110 const unsigned char rm
= (PARPORT_CONTROL_STROBE
|
111 PARPORT_CONTROL_AUTOFD
|
112 PARPORT_CONTROL_INIT
|
113 PARPORT_CONTROL_SELECT
);
114 const struct parport_pc_private
*priv
= p
->physport
->private_data
;
115 return priv
->ctr
& rm
; /* Use soft copy */
118 extern __inline__
unsigned char parport_pc_frob_control (struct parport
*p
,
122 const unsigned char wm
= (PARPORT_CONTROL_STROBE
|
123 PARPORT_CONTROL_AUTOFD
|
124 PARPORT_CONTROL_INIT
|
125 PARPORT_CONTROL_SELECT
);
127 /* Take this out when drivers have adapted to newer interface. */
129 printk (KERN_DEBUG
"%s (%s): use data_%s for this!\n",
130 p
->name
, p
->cad
->name
,
131 (val
& 0x20) ? "reverse" : "forward");
133 parport_pc_data_reverse (p
);
135 parport_pc_data_forward (p
);
138 /* Restrict mask and val to control lines. */
142 return __parport_pc_frob_control (p
, mask
, val
);
145 extern __inline__
unsigned char parport_pc_read_status(struct parport
*p
)
147 return inb(STATUS(p
));
151 extern __inline__
void parport_pc_disable_irq(struct parport
*p
)
153 __parport_pc_frob_control (p
, 0x10, 0x00);
156 extern __inline__
void parport_pc_enable_irq(struct parport
*p
)
158 __parport_pc_frob_control (p
, 0x10, 0x10);
161 extern void parport_pc_release_resources(struct parport
*p
);
163 extern int parport_pc_claim_resources(struct parport
*p
);
165 extern void parport_pc_init_state(struct pardevice
*, struct parport_state
*s
);
167 extern void parport_pc_save_state(struct parport
*p
, struct parport_state
*s
);
169 extern void parport_pc_restore_state(struct parport
*p
, struct parport_state
*s
);
171 extern void parport_pc_inc_use_count(void);
173 extern void parport_pc_dec_use_count(void);
175 /* PCMCIA code will want to get us to look at a port. Provide a mechanism. */
176 extern struct parport
*parport_pc_probe_port (unsigned long base
,
177 unsigned long base_hi
,