OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-parisc/] [parport_gsc.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
#ifndef __LINUX_PARPORT_GSC_H
2
#define __LINUX_PARPORT_GSC_H
3
 
4
#include <asm/io.h>
5
#include <linux/delay.h>
6
 
7
#undef  DEBUG_PARPORT   /* undefine for production */
8
#define DELAY_TIME      0
9
 
10
#if DELAY_TIME == 0
11
#define parport_readb   gsc_readb
12
#define parport_writeb  gsc_writeb
13
#else
14
static __inline__ unsigned char parport_readb( unsigned long port )
15
{
16
    udelay(DELAY_TIME);
17
    return gsc_readb(port);
18
}
19
 
20
static __inline__ void parport_writeb( unsigned char value, unsigned long port )
21
{
22
    gsc_writeb(value,port);
23
    udelay(DELAY_TIME);
24
}
25
#endif
26
 
27
/* --- register definitions ------------------------------- */
28
 
29
#define EPPDATA(p)  ((p)->base    + 0x4)
30
#define EPPADDR(p)  ((p)->base    + 0x3)
31
#define CONTROL(p)  ((p)->base    + 0x2)
32
#define STATUS(p)   ((p)->base    + 0x1)
33
#define DATA(p)     ((p)->base    + 0x0)
34
 
35
struct parport_gsc_private {
36
        /* Contents of CTR. */
37
        unsigned char ctr;
38
 
39
        /* Bitmask of writable CTR bits. */
40
        unsigned char ctr_writable;
41
 
42
        /* Number of bytes per portword. */
43
        int pword;
44
 
45
        /* Not used yet. */
46
        int readIntrThreshold;
47
        int writeIntrThreshold;
48
 
49
        /* buffer suitable for DMA, if DMA enabled */
50
        char *dma_buf;
51
        dma_addr_t dma_handle;
52
        struct pci_dev *dev;
53
};
54
 
55
extern __inline__ void parport_gsc_write_data(struct parport *p, unsigned char d)
56
{
57
#ifdef DEBUG_PARPORT
58
        printk (KERN_DEBUG "parport_gsc_write_data(%p,0x%02x)\n", p, d);
59
#endif
60
        parport_writeb(d, DATA(p));
61
}
62
 
63
extern __inline__ unsigned char parport_gsc_read_data(struct parport *p)
64
{
65
        unsigned char val = parport_readb (DATA (p));
66
#ifdef DEBUG_PARPORT
67
        printk (KERN_DEBUG "parport_gsc_read_data(%p) = 0x%02x\n",
68
                p, val);
69
#endif
70
        return val;
71
}
72
 
73
/* __parport_gsc_frob_control differs from parport_gsc_frob_control in that
74
 * it doesn't do any extra masking. */
75
static __inline__ unsigned char __parport_gsc_frob_control (struct parport *p,
76
                                                           unsigned char mask,
77
                                                           unsigned char val)
78
{
79
        struct parport_gsc_private *priv = p->physport->private_data;
80
        unsigned char ctr = priv->ctr;
81
#ifdef DEBUG_PARPORT
82
        printk (KERN_DEBUG
83
                "__parport_gsc_frob_control(%02x,%02x): %02x -> %02x\n",
84
                mask, val, ctr, ((ctr & ~mask) ^ val) & priv->ctr_writable);
85
#endif
86
        ctr = (ctr & ~mask) ^ val;
87
        ctr &= priv->ctr_writable; /* only write writable bits. */
88
        parport_writeb (ctr, CONTROL (p));
89
        priv->ctr = ctr;        /* Update soft copy */
90
        return ctr;
91
}
92
 
93
extern __inline__ void parport_gsc_data_reverse (struct parport *p)
94
{
95
        __parport_gsc_frob_control (p, 0x20, 0x20);
96
}
97
 
98
extern __inline__ void parport_gsc_data_forward (struct parport *p)
99
{
100
        __parport_gsc_frob_control (p, 0x20, 0x00);
101
}
102
 
103
extern __inline__ void parport_gsc_write_control (struct parport *p,
104
                                                 unsigned char d)
105
{
106
        const unsigned char wm = (PARPORT_CONTROL_STROBE |
107
                                  PARPORT_CONTROL_AUTOFD |
108
                                  PARPORT_CONTROL_INIT |
109
                                  PARPORT_CONTROL_SELECT);
110
 
111
        /* Take this out when drivers have adapted to newer interface. */
112
        if (d & 0x20) {
113
                printk (KERN_DEBUG "%s (%s): use data_reverse for this!\n",
114
                        p->name, p->cad->name);
115
                parport_gsc_data_reverse (p);
116
        }
117
 
118
        __parport_gsc_frob_control (p, wm, d & wm);
119
}
120
 
121
extern __inline__ unsigned char parport_gsc_read_control(struct parport *p)
122
{
123
        const unsigned char rm = (PARPORT_CONTROL_STROBE |
124
                                  PARPORT_CONTROL_AUTOFD |
125
                                  PARPORT_CONTROL_INIT |
126
                                  PARPORT_CONTROL_SELECT);
127
        const struct parport_gsc_private *priv = p->physport->private_data;
128
        return priv->ctr & rm; /* Use soft copy */
129
}
130
 
131
extern __inline__ unsigned char parport_gsc_frob_control (struct parport *p,
132
                                                         unsigned char mask,
133
                                                         unsigned char val)
134
{
135
        const unsigned char wm = (PARPORT_CONTROL_STROBE |
136
                                  PARPORT_CONTROL_AUTOFD |
137
                                  PARPORT_CONTROL_INIT |
138
                                  PARPORT_CONTROL_SELECT);
139
 
140
        /* Take this out when drivers have adapted to newer interface. */
141
        if (mask & 0x20) {
142
                printk (KERN_DEBUG "%s (%s): use data_%s for this!\n",
143
                        p->name, p->cad->name,
144
                        (val & 0x20) ? "reverse" : "forward");
145
                if (val & 0x20)
146
                        parport_gsc_data_reverse (p);
147
                else
148
                        parport_gsc_data_forward (p);
149
        }
150
 
151
        /* Restrict mask and val to control lines. */
152
        mask &= wm;
153
        val &= wm;
154
 
155
        return __parport_gsc_frob_control (p, mask, val);
156
}
157
 
158
extern __inline__ unsigned char parport_gsc_read_status(struct parport *p)
159
{
160
        return parport_readb (STATUS(p));
161
}
162
 
163
 
164
extern __inline__ void parport_gsc_disable_irq(struct parport *p)
165
{
166
        __parport_gsc_frob_control (p, 0x10, 0x00);
167
}
168
 
169
extern __inline__ void parport_gsc_enable_irq(struct parport *p)
170
{
171
        __parport_gsc_frob_control (p, 0x10, 0x10);
172
}
173
 
174
extern void parport_gsc_release_resources(struct parport *p);
175
 
176
extern int parport_gsc_claim_resources(struct parport *p);
177
 
178
extern void parport_gsc_init_state(struct pardevice *, struct parport_state *s);
179
 
180
extern void parport_gsc_save_state(struct parport *p, struct parport_state *s);
181
 
182
extern void parport_gsc_restore_state(struct parport *p, struct parport_state *s);
183
 
184
extern void parport_gsc_inc_use_count(void);
185
 
186
extern void parport_gsc_dec_use_count(void);
187
 
188
extern struct parport *parport_gsc_probe_port (unsigned long base,
189
                                              unsigned long base_hi,
190
                                              int irq, int dma,
191
                                              struct pci_dev *dev);
192
 
193
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.