1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Low-level parallel-support for PC-style hardware integrated in the
4 * LASI-Controller (on GSC-Bus) for HP-PARISC Workstations
8 * based on parport_pc.c by
17 #ifndef __DRIVERS_PARPORT_PARPORT_GSC_H
18 #define __DRIVERS_PARPORT_PARPORT_GSC_H
21 #include <linux/delay.h>
23 #undef DEBUG_PARPORT /* undefine for production */
27 #define parport_readb gsc_readb
28 #define parport_writeb gsc_writeb
30 static __inline__ unsigned char parport_readb( unsigned long port )
33 return gsc_readb(port);
36 static __inline__ void parport_writeb( unsigned char value, unsigned long port )
38 gsc_writeb(value,port);
43 /* --- register definitions ------------------------------- */
45 #define EPPDATA(p) ((p)->base + 0x4)
46 #define EPPADDR(p) ((p)->base + 0x3)
47 #define CONTROL(p) ((p)->base + 0x2)
48 #define STATUS(p) ((p)->base + 0x1)
49 #define DATA(p) ((p)->base + 0x0)
51 struct parport_gsc_private {
52 /* Contents of CTR. */
55 /* Bitmask of writable CTR bits. */
56 unsigned char ctr_writable;
58 /* Number of bytes per portword. */
62 int readIntrThreshold;
63 int writeIntrThreshold;
65 /* buffer suitable for DMA, if DMA enabled */
67 dma_addr_t dma_handle;
71 static inline void parport_gsc_write_data(struct parport *p, unsigned char d)
74 printk (KERN_DEBUG "parport_gsc_write_data(%p,0x%02x)\n", p, d);
76 parport_writeb(d, DATA(p));
79 static inline unsigned char parport_gsc_read_data(struct parport *p)
81 unsigned char val = parport_readb (DATA (p));
83 printk (KERN_DEBUG "parport_gsc_read_data(%p) = 0x%02x\n",
89 /* __parport_gsc_frob_control differs from parport_gsc_frob_control in that
90 * it doesn't do any extra masking. */
91 static inline unsigned char __parport_gsc_frob_control(struct parport *p,
95 struct parport_gsc_private *priv = p->physport->private_data;
96 unsigned char ctr = priv->ctr;
99 "__parport_gsc_frob_control(%02x,%02x): %02x -> %02x\n",
100 mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
102 ctr = (ctr & ~mask) ^ val;
103 ctr &= priv->ctr_writable; /* only write writable bits. */
104 parport_writeb (ctr, CONTROL (p));
105 priv->ctr = ctr; /* Update soft copy */
109 static inline void parport_gsc_data_reverse(struct parport *p)
111 __parport_gsc_frob_control (p, 0x20, 0x20);
114 static inline void parport_gsc_data_forward(struct parport *p)
116 __parport_gsc_frob_control (p, 0x20, 0x00);
119 static inline void parport_gsc_write_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_reverse for this!\n",
130 p->name, p->cad->name);
131 parport_gsc_data_reverse (p);
134 __parport_gsc_frob_control (p, wm, d & wm);
137 static inline unsigned char parport_gsc_read_control(struct parport *p)
139 const unsigned char rm = (PARPORT_CONTROL_STROBE |
140 PARPORT_CONTROL_AUTOFD |
141 PARPORT_CONTROL_INIT |
142 PARPORT_CONTROL_SELECT);
143 const struct parport_gsc_private *priv = p->physport->private_data;
144 return priv->ctr & rm; /* Use soft copy */
147 static inline unsigned char parport_gsc_frob_control(struct parport *p,
151 const unsigned char wm = (PARPORT_CONTROL_STROBE |
152 PARPORT_CONTROL_AUTOFD |
153 PARPORT_CONTROL_INIT |
154 PARPORT_CONTROL_SELECT);
156 /* Take this out when drivers have adapted to newer interface. */
158 printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
159 p->name, p->cad->name,
160 (val & 0x20) ? "reverse" : "forward");
162 parport_gsc_data_reverse (p);
164 parport_gsc_data_forward (p);
167 /* Restrict mask and val to control lines. */
171 return __parport_gsc_frob_control (p, mask, val);
174 static inline unsigned char parport_gsc_read_status(struct parport *p)
176 return parport_readb (STATUS(p));
179 static inline void parport_gsc_disable_irq(struct parport *p)
181 __parport_gsc_frob_control (p, 0x10, 0x00);
184 static inline void parport_gsc_enable_irq(struct parport *p)
186 __parport_gsc_frob_control (p, 0x10, 0x10);
189 extern void parport_gsc_release_resources(struct parport *p);
191 extern int parport_gsc_claim_resources(struct parport *p);
193 extern void parport_gsc_init_state(struct pardevice *, struct parport_state *s);
195 extern void parport_gsc_save_state(struct parport *p, struct parport_state *s);
197 extern void parport_gsc_restore_state(struct parport *p, struct parport_state *s);
199 extern void parport_gsc_inc_use_count(void);
201 extern void parport_gsc_dec_use_count(void);
203 extern struct parport *parport_gsc_probe_port(unsigned long base,
204 unsigned long base_hi,
206 struct parisc_device *padev);
208 #endif /* __DRIVERS_PARPORT_PARPORT_GSC_H */