1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef _LINUX_DIO_H
15#define _LINUX_DIO_H
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#include <linux/device.h>
33
34#ifdef __KERNEL__
35
36#include <asm/hp300hw.h>
37
38typedef __u16 dio_id;
39
40
41
42
43
44struct dio_dev {
45 struct dio_bus *bus;
46 dio_id id;
47 int scode;
48 struct dio_driver *driver;
49 struct device dev;
50 u8 ipl;
51 char name[64];
52 struct resource resource;
53};
54
55#define to_dio_dev(n) container_of(n, struct dio_dev, dev)
56
57
58
59
60
61struct dio_bus {
62 struct list_head devices;
63 unsigned int num_resources;
64 struct resource resources[2];
65 struct device dev;
66 char name[10];
67};
68
69extern struct dio_bus dio_bus;
70extern struct bus_type dio_bus_type;
71
72
73
74
75
76struct dio_device_id {
77 dio_id id;
78 unsigned long driver_data;
79};
80
81
82
83
84
85struct dio_driver {
86 struct list_head node;
87 char *name;
88 const struct dio_device_id *id_table;
89 int (*probe)(struct dio_dev *z, const struct dio_device_id *id);
90
91 void (*remove)(struct dio_dev *z);
92 struct device_driver driver;
93};
94
95#define to_dio_driver(drv) container_of(drv, struct dio_driver, driver)
96
97
98
99
100#define DIO_IDOFF 0x01
101#define DIO_IPLOFF 0x03
102#define DIO_SECIDOFF 0x15
103#define DIOII_SIZEOFF 0x101
104#define DIO_VIRADDRBASE 0xf0000000UL
105
106#define DIO_BASE 0x600000
107#define DIO_END 0x1000000
108#define DIO_DEVSIZE 0x10000
109
110#define DIOII_BASE 0x01000000
111#define DIOII_END 0x20000000
112#define DIOII_DEVSIZE 0x00400000
113
114
115
116
117#define DIO_SCMAX (hp300_model == HP_320 ? 32 : 256)
118#define DIOII_SCBASE 132
119#define DIO_SCINHOLE(scode) (((scode) >= 32) && ((scode) < DIOII_SCBASE))
120#define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
121
122
123#define DIO_ID(baseaddr) in_8((baseaddr) + DIO_IDOFF)
124#define DIO_SECID(baseaddr) in_8((baseaddr) + DIO_SECIDOFF)
125
126
127#define DIO_IPL(baseaddr) (((in_8((baseaddr) + DIO_IPLOFF) >> 4) & 0x03) + 3)
128
129
130
131
132#define DIOII_SIZE(baseaddr) ((in_8((baseaddr) + DIOII_SIZEOFF) + 1) * 0x100000)
133
134
135#define DIO_SIZE(scode, base) (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
136
137
138
139
140
141
142#define DIO_ENCODE_ID(pr,sec) ((((int)sec & 0xff) << 8) | ((int)pr & 0xff))
143
144#define DIO_NEEDSSECID(id) ((id) == DIO_ID_FBUFFER)
145#define DIO_WILDCARD 0xff
146
147
148#define DIO_ID_DCA0 0x02
149#define DIO_DESC_DCA0 "98644A DCA0 serial"
150#define DIO_ID_DCA0REM 0x82
151#define DIO_DESC_DCA0REM "98644A DCA0REM serial"
152#define DIO_ID_DCA1 0x42
153#define DIO_DESC_DCA1 "98644A DCA1 serial"
154#define DIO_ID_DCA1REM 0xc2
155#define DIO_DESC_DCA1REM "98644A DCA1REM serial"
156#define DIO_ID_DCM 0x05
157#define DIO_DESC_DCM "98642A DCM serial MUX"
158#define DIO_ID_DCMREM 0x85
159#define DIO_DESC_DCMREM "98642A DCMREM serial MUX"
160#define DIO_ID_LAN 0x15
161#define DIO_DESC_LAN "98643A LANCE ethernet"
162#define DIO_ID_FHPIB 0x08
163#define DIO_DESC_FHPIB "98625A/98625B fast HPIB"
164#define DIO_ID_NHPIB 0x01
165#define DIO_DESC_NHPIB "98624A HPIB"
166#define DIO_ID_SCSI0 0x07
167#define DIO_DESC_SCSI0 "98265A SCSI0"
168#define DIO_ID_SCSI1 0x27
169#define DIO_DESC_SCSI1 "98265A SCSI1"
170#define DIO_ID_SCSI2 0x47
171#define DIO_DESC_SCSI2 "98265A SCSI2"
172#define DIO_ID_SCSI3 0x67
173#define DIO_DESC_SCSI3 "98265A SCSI3"
174#define DIO_ID_FBUFFER 0x39
175#define DIO_DESC_FBUFFER "bitmapped display"
176
177#define DIO_ID_MISC0 0x03
178#define DIO_DESC_MISC0 "98622A"
179#define DIO_ID_MISC1 0x04
180#define DIO_DESC_MISC1 "98623A"
181#define DIO_ID_PARALLEL 0x06
182#define DIO_DESC_PARALLEL "internal parallel"
183#define DIO_ID_MISC2 0x09
184#define DIO_DESC_MISC2 "98287A keyboard"
185#define DIO_ID_MISC3 0x0a
186#define DIO_DESC_MISC3 "HP98635A FP accelerator"
187#define DIO_ID_MISC4 0x0b
188#define DIO_DESC_MISC4 "timer"
189#define DIO_ID_MISC5 0x12
190#define DIO_DESC_MISC5 "98640A"
191#define DIO_ID_MISC6 0x16
192#define DIO_DESC_MISC6 "98659A"
193#define DIO_ID_MISC7 0x19
194#define DIO_DESC_MISC7 "237 display"
195#define DIO_ID_MISC8 0x1a
196#define DIO_DESC_MISC8 "quad-wide card"
197#define DIO_ID_MISC9 0x1b
198#define DIO_DESC_MISC9 "98253A"
199#define DIO_ID_MISC10 0x1c
200#define DIO_DESC_MISC10 "98253A"
201#define DIO_ID_MISC11 0x1d
202#define DIO_DESC_MISC11 "98633A"
203#define DIO_ID_MISC12 0x1e
204#define DIO_DESC_MISC12 "98259A"
205#define DIO_ID_MISC13 0x1f
206#define DIO_DESC_MISC13 "8741"
207#define DIO_ID_VME 0x31
208#define DIO_DESC_VME "98577A VME adapter"
209#define DIO_ID_DCL 0x34
210#define DIO_DESC_DCL "98628A DCL serial"
211#define DIO_ID_DCLREM 0xb4
212#define DIO_DESC_DCLREM "98628A DCLREM serial"
213
214#define DIO_ID2_GATORBOX 0x01
215#define DIO_DESC2_GATORBOX "98700/98710 \"gatorbox\" display"
216#define DIO_ID2_TOPCAT 0x02
217#define DIO_DESC2_TOPCAT "98544/98545/98547 \"topcat\" display"
218#define DIO_ID2_RENAISSANCE 0x04
219#define DIO_DESC2_RENAISSANCE "98720/98721 \"renaissance\" display"
220#define DIO_ID2_LRCATSEYE 0x05
221#define DIO_DESC2_LRCATSEYE "low-res catseye display"
222#define DIO_ID2_HRCCATSEYE 0x06
223#define DIO_DESC2_HRCCATSEYE "high-res color catseye display"
224#define DIO_ID2_HRMCATSEYE 0x07
225#define DIO_DESC2_HRMCATSEYE "high-res mono catseye display"
226#define DIO_ID2_DAVINCI 0x08
227#define DIO_DESC2_DAVINCI "98730/98731 \"davinci\" display"
228#define DIO_ID2_XXXCATSEYE 0x09
229#define DIO_DESC2_XXXCATSEYE "catseye display"
230#define DIO_ID2_HYPERION 0x0e
231#define DIO_DESC2_HYPERION "A1096A \"hyperion\" display"
232#define DIO_ID2_XGENESIS 0x0b
233#define DIO_DESC2_XGENESIS "\"x-genesis\" display"
234#define DIO_ID2_TIGER 0x0c
235#define DIO_DESC2_TIGER "\"tiger\" display"
236#define DIO_ID2_YGENESIS 0x0d
237#define DIO_DESC2_YGENESIS "\"y-genesis\" display"
238
239
240
241
242extern int dio_find(int deviceid);
243extern unsigned long dio_scodetophysaddr(int scode);
244extern void dio_create_sysfs_dev_files(struct dio_dev *);
245
246
247extern int dio_register_driver(struct dio_driver *);
248extern void dio_unregister_driver(struct dio_driver *);
249extern const struct dio_device_id *dio_match_device(const struct dio_device_id *ids, const struct dio_dev *z);
250static inline struct dio_driver *dio_dev_driver(const struct dio_dev *d)
251{
252 return d->driver;
253}
254
255#define dio_resource_start(d) ((d)->resource.start)
256#define dio_resource_end(d) ((d)->resource.end)
257#define dio_resource_len(d) ((d)->resource.end-(d)->resource.start+1)
258#define dio_resource_flags(d) ((d)->resource.flags)
259
260#define dio_request_device(d, name) \
261 request_mem_region(dio_resource_start(d), dio_resource_len(d), name)
262#define dio_release_device(d) \
263 release_mem_region(dio_resource_start(d), dio_resource_len(d))
264
265
266
267
268
269static inline void *dio_get_drvdata (struct dio_dev *d)
270{
271 return dev_get_drvdata(&d->dev);
272}
273
274static inline void dio_set_drvdata (struct dio_dev *d, void *data)
275{
276 dev_set_drvdata(&d->dev, data);
277}
278
279#endif
280#endif
281