~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/dio.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /* header file for DIO boards for the HP300 architecture.
  3  * Maybe this should handle DIO-II later?
  4  * The general structure of this is vaguely based on how
  5  * the Amiga port handles Zorro boards.
  6  * Copyright (C) Peter Maydell 05/1998 <pmaydell@chiark.greenend.org.uk>
  7  * Converted to driver model Jochen Friedrich <jochen@scram.de>
  8  *
  9  * The board IDs are from the NetBSD kernel, which for once provided
 10  * helpful comments...
 11  *
 12  * This goes with drivers/dio/dio.c
 13  */
 14 
 15 #ifndef _LINUX_DIO_H
 16 #define _LINUX_DIO_H
 17 
 18 /* The DIO boards in a system are distinguished by 'select codes' which 
 19  * range from 0-63 (DIO) and 132-255 (DIO-II). 
 20  * The DIO board with select code sc is located at physical address 
 21  *     0x600000 + sc * 0x10000
 22  * So DIO cards cover [0x600000-0x800000); the areas [0x200000-0x400000) and
 23  * [0x800000-0x1000000) are for additional space required by things
 24  * like framebuffers. [0x400000-0x600000) is for miscellaneous internal I/O.
 25  * On Linux, this is currently all mapped into the virtual address space
 26  * at 0xf0000000 on bootup.
 27  * DIO-II boards are at 0x1000000 + (sc - 132) * 0x400000
 28  * which is address range [0x1000000-0x20000000) -- too big to map completely,
 29  * so currently we just don't handle DIO-II boards.  It wouldn't be hard to 
 30  * do with ioremap() though.
 31  */
 32 
 33 #include <linux/device.h>
 34 
 35 #ifdef __KERNEL__
 36 
 37 #include <asm/hp300hw.h>
 38 
 39 typedef __u16 dio_id;
 40 
 41     /*
 42      *  DIO devices
 43      */
 44 
 45 struct dio_dev {
 46         struct dio_bus *bus;
 47         dio_id id;
 48         int scode;
 49         struct dio_driver *driver;      /* which driver has allocated this device */
 50         struct device dev;              /* Generic device interface */
 51         u8 ipl;
 52         char name[64];
 53         struct resource resource;
 54 };
 55 
 56 #define to_dio_dev(n) container_of(n, struct dio_dev, dev)
 57 
 58     /*
 59      *  DIO bus
 60      */
 61 
 62 struct dio_bus {
 63         struct list_head devices;           /* list of devices on this bus */
 64         unsigned int num_resources;         /* number of resources */
 65         struct resource resources[2];       /* address space routed to this bus */
 66         struct device dev;
 67         char name[10];
 68 };
 69 
 70 extern struct dio_bus dio_bus;      /* Single DIO bus */
 71 extern const struct bus_type dio_bus_type;
 72 
 73     /*
 74      *  DIO device IDs
 75      */
 76 
 77 struct dio_device_id {
 78         dio_id id;                    /* Device ID or DIO_WILDCARD */
 79         unsigned long driver_data;    /* Data private to the driver */
 80 };
 81 
 82     /*
 83      *  DIO device drivers
 84      */
 85 
 86 struct dio_driver {
 87         struct list_head node;
 88         char *name;
 89         const struct dio_device_id *id_table;     /* NULL if wants all devices */
 90         int (*probe)(struct dio_dev *z, const struct dio_device_id *id);
 91 /* New device inserted */
 92         void (*remove)(struct dio_dev *z);        /* Device removed (NULL if not a hot-plug capable driver) */
 93         struct device_driver driver;
 94 };
 95 
 96 #define to_dio_driver(drv)    container_of_const(drv, struct dio_driver, driver)
 97 
 98 /* DIO/DIO-II boards all have the following 8bit registers.
 99  * These are offsets from the base of the device.
100  */
101 #define DIO_IDOFF     0x01             /* primary device ID */
102 #define DIO_IPLOFF    0x03             /* interrupt priority level */
103 #define DIO_SECIDOFF  0x15             /* secondary device ID */
104 #define DIOII_SIZEOFF 0x101            /* device size, DIO-II only */
105 #define DIO_VIRADDRBASE 0xf0000000UL   /* vir addr where IOspace is mapped */
106 
107 #define DIO_BASE                0x600000        /* start of DIO space */
108 #define DIO_END                 0x1000000       /* end of DIO space */
109 #define DIO_DEVSIZE             0x10000         /* size of a DIO device */
110 
111 #define DIOII_BASE              0x01000000      /* start of DIO-II space */
112 #define DIOII_END               0x20000000      /* end of DIO-II space */
113 #define DIOII_DEVSIZE           0x00400000      /* size of a DIO-II device */
114 
115 /* Highest valid select code. If we add DIO-II support this should become
116  * 256 for everything except HP320, which only has DIO.
117  */
118 #define DIO_SCMAX (hp300_model == HP_320 ? 32 : 256)
119 #define DIOII_SCBASE 132 /* lowest DIO-II select code */
120 #define DIO_SCINHOLE(scode) (((scode) >= 32) && ((scode) < DIOII_SCBASE))
121 #define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
122 
123 /* macros to read device IDs, given base address */
124 #define DIO_ID(baseaddr) in_8((baseaddr) + DIO_IDOFF)
125 #define DIO_SECID(baseaddr) in_8((baseaddr) + DIO_SECIDOFF)
126 
127 /* extract the interrupt level */
128 #define DIO_IPL(baseaddr) (((in_8((baseaddr) + DIO_IPLOFF) >> 4) & 0x03) + 3)
129 
130 /* find the size of a DIO-II board's address space.
131  * DIO boards are all fixed length.
132  */
133 #define DIOII_SIZE(baseaddr) ((in_8((baseaddr) + DIOII_SIZEOFF) + 1) * 0x100000)
134 
135 /* general purpose macro for both DIO and DIO-II */
136 #define DIO_SIZE(scode, base) (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
137 
138 /* The hardware has primary and secondary IDs; we encode these in a single
139  * int as PRIMARY ID & (SECONDARY ID << 8).
140  * In practice this is only important for framebuffers,
141  * and everybody else just sets ID fields equal to the DIO_ID_FOO value.
142  */
143 #define DIO_ENCODE_ID(pr,sec) ((((int)sec & 0xff) << 8) | ((int)pr & 0xff))
144 /* macro to determine whether a given primary ID requires a secondary ID byte */
145 #define DIO_NEEDSSECID(id) ((id) == DIO_ID_FBUFFER)
146 #define DIO_WILDCARD 0xff
147 
148 /* Now a whole slew of macros giving device IDs and descriptive strings: */
149 #define DIO_ID_DCA0     0x02 /* 98644A serial */
150 #define DIO_DESC_DCA0 "98644A DCA0 serial"
151 #define DIO_ID_DCA0REM  0x82 /* 98644A serial */
152 #define DIO_DESC_DCA0REM "98644A DCA0REM serial"
153 #define DIO_ID_DCA1     0x42 /* 98644A serial */
154 #define DIO_DESC_DCA1 "98644A DCA1 serial"
155 #define DIO_ID_DCA1REM  0xc2 /* 98644A serial */
156 #define DIO_DESC_DCA1REM "98644A DCA1REM serial"
157 #define DIO_ID_DCM      0x05 /* 98642A serial MUX */
158 #define DIO_DESC_DCM "98642A DCM serial MUX"
159 #define DIO_ID_DCMREM   0x85 /* 98642A serial MUX */
160 #define DIO_DESC_DCMREM "98642A DCMREM serial MUX"
161 #define DIO_ID_LAN      0x15 /* 98643A LAN */
162 #define DIO_DESC_LAN "98643A LANCE ethernet"
163 #define DIO_ID_FHPIB    0x08 /* 98625A/98625B fast HP-IB */
164 #define DIO_DESC_FHPIB "98625A/98625B fast HPIB"
165 #define DIO_ID_NHPIB    0x01 /* 98624A HP-IB (normal ie slow) */
166 #define DIO_DESC_NHPIB "98624A HPIB"
167 #define DIO_ID_SCSI0    0x07 /* 98265A SCSI */
168 #define DIO_DESC_SCSI0 "98265A SCSI0"
169 #define DIO_ID_SCSI1    0x27 /* ditto */
170 #define DIO_DESC_SCSI1 "98265A SCSI1"
171 #define DIO_ID_SCSI2    0x47 /* ditto */
172 #define DIO_DESC_SCSI2 "98265A SCSI2"
173 #define DIO_ID_SCSI3    0x67 /* ditto */
174 #define DIO_DESC_SCSI3 "98265A SCSI3"
175 #define DIO_ID_FBUFFER  0x39 /* framebuffer: flavour is distinguished by secondary ID */
176 #define DIO_DESC_FBUFFER "bitmapped display"
177 /* the NetBSD kernel source is a bit unsure as to what these next IDs actually do :-> */
178 #define DIO_ID_MISC0    0x03 /* 98622A */
179 #define DIO_DESC_MISC0 "98622A"
180 #define DIO_ID_MISC1    0x04 /* 98623A */
181 #define DIO_DESC_MISC1 "98623A"
182 #define DIO_ID_PARALLEL 0x06 /* internal parallel */
183 #define DIO_DESC_PARALLEL "internal parallel"
184 #define DIO_ID_MISC2    0x09 /* 98287A keyboard */
185 #define DIO_DESC_MISC2 "98287A keyboard"
186 #define DIO_ID_MISC3    0x0a /* HP98635A FP accelerator */
187 #define DIO_DESC_MISC3 "HP98635A FP accelerator"
188 #define DIO_ID_MISC4    0x0b /* timer */
189 #define DIO_DESC_MISC4 "timer"
190 #define DIO_ID_MISC5    0x12 /* 98640A */
191 #define DIO_DESC_MISC5 "98640A"
192 #define DIO_ID_MISC6    0x16 /* 98659A */
193 #define DIO_DESC_MISC6 "98659A"
194 #define DIO_ID_MISC7    0x19 /* 237 display */
195 #define DIO_DESC_MISC7 "237 display"
196 #define DIO_ID_MISC8    0x1a /* quad-wide card */
197 #define DIO_DESC_MISC8 "quad-wide card"
198 #define DIO_ID_MISC9    0x1b /* 98253A */
199 #define DIO_DESC_MISC9 "98253A"
200 #define DIO_ID_MISC10   0x1c /* 98627A */
201 #define DIO_DESC_MISC10 "98253A"
202 #define DIO_ID_MISC11   0x1d /* 98633A */
203 #define DIO_DESC_MISC11 "98633A"
204 #define DIO_ID_MISC12   0x1e /* 98259A */
205 #define DIO_DESC_MISC12 "98259A"
206 #define DIO_ID_MISC13   0x1f /* 8741 */
207 #define DIO_DESC_MISC13 "8741"
208 #define DIO_ID_VME      0x31 /* 98577A VME adapter */
209 #define DIO_DESC_VME "98577A VME adapter"
210 #define DIO_ID_DCL      0x34 /* 98628A serial */
211 #define DIO_DESC_DCL "98628A DCL serial"
212 #define DIO_ID_DCLREM   0xb4 /* 98628A serial */
213 #define DIO_DESC_DCLREM "98628A DCLREM serial"
214 /* These are the secondary IDs for the framebuffers */
215 #define DIO_ID2_GATORBOX    0x01 /* 98700/98710 "gatorbox" */
216 #define DIO_DESC2_GATORBOX       "98700/98710 \"gatorbox\" display"
217 #define DIO_ID2_TOPCAT      0x02 /* 98544/98545/98547 "topcat" */
218 #define DIO_DESC2_TOPCAT         "98544/98545/98547 \"topcat\" display"
219 #define DIO_ID2_RENAISSANCE 0x04 /* 98720/98721 "renaissance" */
220 #define DIO_DESC2_RENAISSANCE    "98720/98721 \"renaissance\" display"
221 #define DIO_ID2_LRCATSEYE   0x05 /* lowres "catseye" */
222 #define DIO_DESC2_LRCATSEYE      "low-res catseye display"
223 #define DIO_ID2_HRCCATSEYE  0x06 /* highres colour "catseye" */
224 #define DIO_DESC2_HRCCATSEYE     "high-res color catseye display"
225 #define DIO_ID2_HRMCATSEYE  0x07 /* highres mono "catseye" */
226 #define DIO_DESC2_HRMCATSEYE     "high-res mono catseye display"
227 #define DIO_ID2_DAVINCI     0x08 /* 98730/98731 "davinci" */
228 #define DIO_DESC2_DAVINCI        "98730/98731 \"davinci\" display"
229 #define DIO_ID2_XXXCATSEYE  0x09 /* "catseye" */
230 #define DIO_DESC2_XXXCATSEYE     "catseye display"
231 #define DIO_ID2_HYPERION    0x0e /* A1096A "hyperion" */
232 #define DIO_DESC2_HYPERION       "A1096A \"hyperion\" display"
233 #define DIO_ID2_XGENESIS    0x0b /* "x-genesis"; no NetBSD support */
234 #define DIO_DESC2_XGENESIS       "\"x-genesis\" display"
235 #define DIO_ID2_TIGER       0x0c /* "tiger"; no NetBSD support */
236 #define DIO_DESC2_TIGER          "\"tiger\" display"
237 #define DIO_ID2_YGENESIS    0x0d /* "y-genesis"; no NetBSD support */
238 #define DIO_DESC2_YGENESIS       "\"y-genesis\" display"
239 /* if you add new IDs then you should tell dio.c about them so it can
240  * identify them...
241  */
242 
243 extern int dio_find(int deviceid);
244 extern unsigned long dio_scodetophysaddr(int scode);
245 extern int dio_create_sysfs_dev_files(struct dio_dev *);
246 
247 /* New-style probing */
248 extern int dio_register_driver(struct dio_driver *);
249 extern void dio_unregister_driver(struct dio_driver *);
250 
251 #define dio_resource_start(d) ((d)->resource.start)
252 #define dio_resource_end(d)   ((d)->resource.end)
253 #define dio_resource_len(d)   (resource_size(&(d)->resource))
254 #define dio_resource_flags(d) ((d)->resource.flags)
255 
256 #define dio_request_device(d, name) \
257     request_mem_region(dio_resource_start(d), dio_resource_len(d), name)
258 #define dio_release_device(d) \
259     release_mem_region(dio_resource_start(d), dio_resource_len(d))
260 
261 /* Similar to the helpers above, these manipulate per-dio_dev
262  * driver-specific data.  They are really just a wrapper around
263  * the generic device structure functions of these calls.
264  */
265 static inline void *dio_get_drvdata (struct dio_dev *d)
266 {
267         return dev_get_drvdata(&d->dev);
268 }
269 
270 static inline void dio_set_drvdata (struct dio_dev *d, void *data)
271 {
272         dev_set_drvdata(&d->dev, data);
273 }
274 
275 #endif /* __KERNEL__ */
276 #endif /* ndef _LINUX_DIO_H */
277 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php