Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* header file for DIO boards for the HP300 architecture.
0003  * Maybe this should handle DIO-II later?
0004  * The general structure of this is vaguely based on how
0005  * the Amiga port handles Zorro boards.
0006  * Copyright (C) Peter Maydell 05/1998 <pmaydell@chiark.greenend.org.uk>
0007  * Converted to driver model Jochen Friedrich <jochen@scram.de>
0008  *
0009  * The board IDs are from the NetBSD kernel, which for once provided
0010  * helpful comments...
0011  *
0012  * This goes with drivers/dio/dio.c
0013  */
0014 
0015 #ifndef _LINUX_DIO_H
0016 #define _LINUX_DIO_H
0017 
0018 /* The DIO boards in a system are distinguished by 'select codes' which 
0019  * range from 0-63 (DIO) and 132-255 (DIO-II). 
0020  * The DIO board with select code sc is located at physical address 
0021  *     0x600000 + sc * 0x10000
0022  * So DIO cards cover [0x600000-0x800000); the areas [0x200000-0x400000) and
0023  * [0x800000-0x1000000) are for additional space required by things
0024  * like framebuffers. [0x400000-0x600000) is for miscellaneous internal I/O.
0025  * On Linux, this is currently all mapped into the virtual address space
0026  * at 0xf0000000 on bootup.
0027  * DIO-II boards are at 0x1000000 + (sc - 132) * 0x400000
0028  * which is address range [0x1000000-0x20000000) -- too big to map completely,
0029  * so currently we just don't handle DIO-II boards.  It wouldn't be hard to 
0030  * do with ioremap() though.
0031  */
0032 
0033 #include <linux/device.h>
0034 
0035 #ifdef __KERNEL__
0036 
0037 #include <asm/hp300hw.h>
0038 
0039 typedef __u16 dio_id;
0040 
0041     /*
0042      *  DIO devices
0043      */
0044 
0045 struct dio_dev {
0046     struct dio_bus *bus;
0047     dio_id id;
0048     int scode;
0049     struct dio_driver *driver;  /* which driver has allocated this device */
0050     struct device dev;      /* Generic device interface */
0051     u8 ipl;
0052     char name[64];
0053     struct resource resource;
0054 };
0055 
0056 #define to_dio_dev(n) container_of(n, struct dio_dev, dev)
0057 
0058     /*
0059      *  DIO bus
0060      */
0061 
0062 struct dio_bus {
0063     struct list_head devices;           /* list of devices on this bus */
0064     unsigned int num_resources;         /* number of resources */
0065     struct resource resources[2];       /* address space routed to this bus */
0066     struct device dev;
0067     char name[10];
0068 };
0069 
0070 extern struct dio_bus dio_bus;      /* Single DIO bus */
0071 extern struct bus_type dio_bus_type;
0072 
0073     /*
0074      *  DIO device IDs
0075      */
0076 
0077 struct dio_device_id {
0078     dio_id id;                    /* Device ID or DIO_WILDCARD */
0079     unsigned long driver_data;    /* Data private to the driver */
0080 };
0081 
0082     /*
0083      *  DIO device drivers
0084      */
0085 
0086 struct dio_driver {
0087     struct list_head node;
0088     char *name;
0089     const struct dio_device_id *id_table;     /* NULL if wants all devices */
0090     int (*probe)(struct dio_dev *z, const struct dio_device_id *id);
0091 /* New device inserted */
0092     void (*remove)(struct dio_dev *z);        /* Device removed (NULL if not a hot-plug capable driver) */
0093     struct device_driver driver;
0094 };
0095 
0096 #define to_dio_driver(drv)    container_of(drv, struct dio_driver, driver)
0097 
0098 /* DIO/DIO-II boards all have the following 8bit registers.
0099  * These are offsets from the base of the device.
0100  */
0101 #define DIO_IDOFF     0x01             /* primary device ID */
0102 #define DIO_IPLOFF    0x03             /* interrupt priority level */
0103 #define DIO_SECIDOFF  0x15             /* secondary device ID */
0104 #define DIOII_SIZEOFF 0x101            /* device size, DIO-II only */
0105 #define DIO_VIRADDRBASE 0xf0000000UL   /* vir addr where IOspace is mapped */
0106 
0107 #define DIO_BASE                0x600000        /* start of DIO space */
0108 #define DIO_END                 0x1000000       /* end of DIO space */
0109 #define DIO_DEVSIZE             0x10000         /* size of a DIO device */
0110 
0111 #define DIOII_BASE              0x01000000      /* start of DIO-II space */
0112 #define DIOII_END               0x20000000      /* end of DIO-II space */
0113 #define DIOII_DEVSIZE           0x00400000      /* size of a DIO-II device */
0114 
0115 /* Highest valid select code. If we add DIO-II support this should become
0116  * 256 for everything except HP320, which only has DIO.
0117  */
0118 #define DIO_SCMAX (hp300_model == HP_320 ? 32 : 256)
0119 #define DIOII_SCBASE 132 /* lowest DIO-II select code */
0120 #define DIO_SCINHOLE(scode) (((scode) >= 32) && ((scode) < DIOII_SCBASE))
0121 #define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256)
0122 
0123 /* macros to read device IDs, given base address */
0124 #define DIO_ID(baseaddr) in_8((baseaddr) + DIO_IDOFF)
0125 #define DIO_SECID(baseaddr) in_8((baseaddr) + DIO_SECIDOFF)
0126 
0127 /* extract the interrupt level */
0128 #define DIO_IPL(baseaddr) (((in_8((baseaddr) + DIO_IPLOFF) >> 4) & 0x03) + 3)
0129 
0130 /* find the size of a DIO-II board's address space.
0131  * DIO boards are all fixed length.
0132  */
0133 #define DIOII_SIZE(baseaddr) ((in_8((baseaddr) + DIOII_SIZEOFF) + 1) * 0x100000)
0134 
0135 /* general purpose macro for both DIO and DIO-II */
0136 #define DIO_SIZE(scode, base) (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE)
0137 
0138 /* The hardware has primary and secondary IDs; we encode these in a single
0139  * int as PRIMARY ID & (SECONDARY ID << 8).
0140  * In practice this is only important for framebuffers,
0141  * and everybody else just sets ID fields equal to the DIO_ID_FOO value.
0142  */
0143 #define DIO_ENCODE_ID(pr,sec) ((((int)sec & 0xff) << 8) | ((int)pr & 0xff))
0144 /* macro to determine whether a given primary ID requires a secondary ID byte */
0145 #define DIO_NEEDSSECID(id) ((id) == DIO_ID_FBUFFER)
0146 #define DIO_WILDCARD 0xff
0147 
0148 /* Now a whole slew of macros giving device IDs and descriptive strings: */
0149 #define DIO_ID_DCA0     0x02 /* 98644A serial */
0150 #define DIO_DESC_DCA0 "98644A DCA0 serial"
0151 #define DIO_ID_DCA0REM  0x82 /* 98644A serial */
0152 #define DIO_DESC_DCA0REM "98644A DCA0REM serial"
0153 #define DIO_ID_DCA1     0x42 /* 98644A serial */
0154 #define DIO_DESC_DCA1 "98644A DCA1 serial"
0155 #define DIO_ID_DCA1REM  0xc2 /* 98644A serial */
0156 #define DIO_DESC_DCA1REM "98644A DCA1REM serial"
0157 #define DIO_ID_DCM      0x05 /* 98642A serial MUX */
0158 #define DIO_DESC_DCM "98642A DCM serial MUX"
0159 #define DIO_ID_DCMREM   0x85 /* 98642A serial MUX */
0160 #define DIO_DESC_DCMREM "98642A DCMREM serial MUX"
0161 #define DIO_ID_LAN      0x15 /* 98643A LAN */
0162 #define DIO_DESC_LAN "98643A LANCE ethernet"
0163 #define DIO_ID_FHPIB    0x08 /* 98625A/98625B fast HP-IB */
0164 #define DIO_DESC_FHPIB "98625A/98625B fast HPIB"
0165 #define DIO_ID_NHPIB    0x01 /* 98624A HP-IB (normal ie slow) */
0166 #define DIO_DESC_NHPIB "98624A HPIB"
0167 #define DIO_ID_SCSI0    0x07 /* 98265A SCSI */
0168 #define DIO_DESC_SCSI0 "98265A SCSI0"
0169 #define DIO_ID_SCSI1    0x27 /* ditto */
0170 #define DIO_DESC_SCSI1 "98265A SCSI1"
0171 #define DIO_ID_SCSI2    0x47 /* ditto */
0172 #define DIO_DESC_SCSI2 "98265A SCSI2"
0173 #define DIO_ID_SCSI3    0x67 /* ditto */
0174 #define DIO_DESC_SCSI3 "98265A SCSI3"
0175 #define DIO_ID_FBUFFER  0x39 /* framebuffer: flavour is distinguished by secondary ID */
0176 #define DIO_DESC_FBUFFER "bitmapped display"
0177 /* the NetBSD kernel source is a bit unsure as to what these next IDs actually do :-> */
0178 #define DIO_ID_MISC0    0x03 /* 98622A */
0179 #define DIO_DESC_MISC0 "98622A"
0180 #define DIO_ID_MISC1    0x04 /* 98623A */
0181 #define DIO_DESC_MISC1 "98623A"
0182 #define DIO_ID_PARALLEL 0x06 /* internal parallel */
0183 #define DIO_DESC_PARALLEL "internal parallel"
0184 #define DIO_ID_MISC2    0x09 /* 98287A keyboard */
0185 #define DIO_DESC_MISC2 "98287A keyboard"
0186 #define DIO_ID_MISC3    0x0a /* HP98635A FP accelerator */
0187 #define DIO_DESC_MISC3 "HP98635A FP accelerator"
0188 #define DIO_ID_MISC4    0x0b /* timer */
0189 #define DIO_DESC_MISC4 "timer"
0190 #define DIO_ID_MISC5    0x12 /* 98640A */
0191 #define DIO_DESC_MISC5 "98640A"
0192 #define DIO_ID_MISC6    0x16 /* 98659A */
0193 #define DIO_DESC_MISC6 "98659A"
0194 #define DIO_ID_MISC7    0x19 /* 237 display */
0195 #define DIO_DESC_MISC7 "237 display"
0196 #define DIO_ID_MISC8    0x1a /* quad-wide card */
0197 #define DIO_DESC_MISC8 "quad-wide card"
0198 #define DIO_ID_MISC9    0x1b /* 98253A */
0199 #define DIO_DESC_MISC9 "98253A"
0200 #define DIO_ID_MISC10   0x1c /* 98627A */
0201 #define DIO_DESC_MISC10 "98253A"
0202 #define DIO_ID_MISC11   0x1d /* 98633A */
0203 #define DIO_DESC_MISC11 "98633A"
0204 #define DIO_ID_MISC12   0x1e /* 98259A */
0205 #define DIO_DESC_MISC12 "98259A"
0206 #define DIO_ID_MISC13   0x1f /* 8741 */
0207 #define DIO_DESC_MISC13 "8741"
0208 #define DIO_ID_VME      0x31 /* 98577A VME adapter */
0209 #define DIO_DESC_VME "98577A VME adapter"
0210 #define DIO_ID_DCL      0x34 /* 98628A serial */
0211 #define DIO_DESC_DCL "98628A DCL serial"
0212 #define DIO_ID_DCLREM   0xb4 /* 98628A serial */
0213 #define DIO_DESC_DCLREM "98628A DCLREM serial"
0214 /* These are the secondary IDs for the framebuffers */
0215 #define DIO_ID2_GATORBOX    0x01 /* 98700/98710 "gatorbox" */
0216 #define DIO_DESC2_GATORBOX       "98700/98710 \"gatorbox\" display"
0217 #define DIO_ID2_TOPCAT      0x02 /* 98544/98545/98547 "topcat" */
0218 #define DIO_DESC2_TOPCAT         "98544/98545/98547 \"topcat\" display"
0219 #define DIO_ID2_RENAISSANCE 0x04 /* 98720/98721 "renaissance" */
0220 #define DIO_DESC2_RENAISSANCE    "98720/98721 \"renaissance\" display"
0221 #define DIO_ID2_LRCATSEYE   0x05 /* lowres "catseye" */
0222 #define DIO_DESC2_LRCATSEYE      "low-res catseye display"
0223 #define DIO_ID2_HRCCATSEYE  0x06 /* highres colour "catseye" */
0224 #define DIO_DESC2_HRCCATSEYE     "high-res color catseye display"
0225 #define DIO_ID2_HRMCATSEYE  0x07 /* highres mono "catseye" */
0226 #define DIO_DESC2_HRMCATSEYE     "high-res mono catseye display"
0227 #define DIO_ID2_DAVINCI     0x08 /* 98730/98731 "davinci" */
0228 #define DIO_DESC2_DAVINCI        "98730/98731 \"davinci\" display"
0229 #define DIO_ID2_XXXCATSEYE  0x09 /* "catseye" */
0230 #define DIO_DESC2_XXXCATSEYE     "catseye display"
0231 #define DIO_ID2_HYPERION    0x0e /* A1096A "hyperion" */
0232 #define DIO_DESC2_HYPERION       "A1096A \"hyperion\" display"
0233 #define DIO_ID2_XGENESIS    0x0b /* "x-genesis"; no NetBSD support */
0234 #define DIO_DESC2_XGENESIS       "\"x-genesis\" display"
0235 #define DIO_ID2_TIGER       0x0c /* "tiger"; no NetBSD support */
0236 #define DIO_DESC2_TIGER          "\"tiger\" display"
0237 #define DIO_ID2_YGENESIS    0x0d /* "y-genesis"; no NetBSD support */
0238 #define DIO_DESC2_YGENESIS       "\"y-genesis\" display"
0239 /* if you add new IDs then you should tell dio.c about them so it can
0240  * identify them...
0241  */
0242 
0243 extern int dio_find(int deviceid);
0244 extern unsigned long dio_scodetophysaddr(int scode);
0245 extern int dio_create_sysfs_dev_files(struct dio_dev *);
0246 
0247 /* New-style probing */
0248 extern int dio_register_driver(struct dio_driver *);
0249 extern void dio_unregister_driver(struct dio_driver *);
0250 
0251 #define dio_resource_start(d) ((d)->resource.start)
0252 #define dio_resource_end(d)   ((d)->resource.end)
0253 #define dio_resource_len(d)   (resource_size(&(d)->resource))
0254 #define dio_resource_flags(d) ((d)->resource.flags)
0255 
0256 #define dio_request_device(d, name) \
0257     request_mem_region(dio_resource_start(d), dio_resource_len(d), name)
0258 #define dio_release_device(d) \
0259     release_mem_region(dio_resource_start(d), dio_resource_len(d))
0260 
0261 /* Similar to the helpers above, these manipulate per-dio_dev
0262  * driver-specific data.  They are really just a wrapper around
0263  * the generic device structure functions of these calls.
0264  */
0265 static inline void *dio_get_drvdata (struct dio_dev *d)
0266 {
0267     return dev_get_drvdata(&d->dev);
0268 }
0269 
0270 static inline void dio_set_drvdata (struct dio_dev *d, void *data)
0271 {
0272     dev_set_drvdata(&d->dev, data);
0273 }
0274 
0275 #endif /* __KERNEL__ */
0276 #endif /* ndef _LINUX_DIO_H */