Home | History | Annotate | Download | only in linux
      1 /*
      2   nubus.h: various definitions and prototypes for NuBus drivers to use.
      3 
      4   Originally written by Alan Cox.
      5 
      6   Hacked to death by C. Scott Ananian and David Huggins-Daines.
      7 
      8   Some of the constants in here are from the corresponding
      9   NetBSD/OpenBSD header file, by Allen Briggs.  We figured out the
     10   rest of them on our own. */
     11 
     12 #ifndef LINUX_NUBUS_H
     13 #define LINUX_NUBUS_H
     14 
     15 
     16 enum nubus_category {
     17 	NUBUS_CAT_BOARD          = 0x0001,
     18 	NUBUS_CAT_DISPLAY        = 0x0003,
     19 	NUBUS_CAT_NETWORK        = 0x0004,
     20 	NUBUS_CAT_COMMUNICATIONS = 0x0006,
     21 	NUBUS_CAT_FONT           = 0x0009,
     22 	NUBUS_CAT_CPU            = 0x000A,
     23 	/* For lack of a better name */
     24 	NUBUS_CAT_DUODOCK        = 0x0020
     25 };
     26 
     27 enum nubus_type_network {
     28 	NUBUS_TYPE_ETHERNET      = 0x0001,
     29 	NUBUS_TYPE_RS232         = 0x0002
     30 };
     31 
     32 enum nubus_type_display {
     33 	NUBUS_TYPE_VIDEO         = 0x0001
     34 };
     35 
     36 enum nubus_type_cpu {
     37 	NUBUS_TYPE_68020         = 0x0003,
     38 	NUBUS_TYPE_68030         = 0x0004,
     39 	NUBUS_TYPE_68040         = 0x0005
     40 };
     41 
     42 /* Known <Cat,Type,SW,HW> tuples: (according to TattleTech and Slots)
     43  *  68030 motherboards: <10,4,0,24>
     44  *  68040 motherboards: <10,5,0,24>
     45  *  DuoDock Plus: <32,1,1,2>
     46  *
     47  *  Toby Frame Buffer card: <3,1,1,1>
     48  *  RBV built-in video (IIci): <3,1,1,24>
     49  *  Valkyrie built-in video (Q630): <3,1,1,46>
     50  *  Macintosh Display Card: <3,1,1,25>
     51  *  Sonora built-in video (P460): <3,1,1,34>
     52  *  Jet framebuffer (DuoDock Plus): <3,1,1,41>
     53  *
     54  *  SONIC comm-slot/on-board and DuoDock Ethernet: <4,1,1,272>
     55  *  SONIC LC-PDS Ethernet (Dayna, but like Apple 16-bit, sort of): <4,1,1,271>
     56  *  Apple SONIC LC-PDS Ethernet ("Apple Ethernet LC Twisted-Pair Card"): <4,1,0,281>
     57  *  Sonic Systems Ethernet A-Series Card: <4,1,268,256>
     58  *  Asante MacCon NuBus-A: <4,1,260,256> (alpha-1.0,1.1 revision)
     59  *   ROM on the above card: <2,1,0,0>
     60  *  Cabletron ethernet card: <4,1,1,265>
     61  *  Farallon ethernet card: <4,1,268,256> (identical to Sonic Systems card)
     62  *  Kinetics EtherPort IIN: <4,1,259,262>
     63  *  API Engineering EtherRun_LCa PDS enet card: <4,1,282,256>
     64  *
     65  *  Add your devices to the list!  You can obtain the "Slots" utility
     66  *  from Apple's FTP site at:
     67  *  ftp://dev.apple.com/devworld/Tool_Chest/Devices_-_Hardware/NuBus_Slot_Manager/
     68  *
     69  *  Alternately, TattleTech can be found at any Info-Mac mirror site.
     70  *  or from its distribution site: ftp://ftp.decismkr.com/dms
     71  */
     72 
     73 /* DrSW: Uniquely identifies the software interface to a board.  This
     74    is usually the one you want to look at when writing a driver.  It's
     75    not as useful as you think, though, because as we should know by
     76    now (duh), "Apple Compatible" can mean a lot of things... */
     77 
     78 /* Add known DrSW values here */
     79 enum nubus_drsw {
     80 	/* NUBUS_CAT_DISPLAY */
     81 	NUBUS_DRSW_APPLE        = 0x0001,
     82 	NUBUS_DRSW_APPLE_HIRES  = 0x0013, /* MacII HiRes card driver */
     83 
     84 	/* NUBUS_CAT_NETWORK */
     85 	NUBUS_DRSW_3COM         = 0x0000,
     86 	NUBUS_DRSW_CABLETRON    = 0x0001,
     87 	NUBUS_DRSW_SONIC_LC     = 0x0001,
     88 	NUBUS_DRSW_KINETICS     = 0x0103,
     89 	NUBUS_DRSW_ASANTE       = 0x0104,
     90 	NUBUS_DRSW_TECHWORKS    = 0x0109,
     91 	NUBUS_DRSW_DAYNA        = 0x010b,
     92 	NUBUS_DRSW_FARALLON     = 0x010c,
     93 	NUBUS_DRSW_APPLE_SN     = 0x010f,
     94 	NUBUS_DRSW_DAYNA2       = 0x0115,
     95 	NUBUS_DRSW_FOCUS        = 0x011a,
     96 	NUBUS_DRSW_ASANTE_CS    = 0x011d, /* use asante SMC9194 driver */
     97 	NUBUS_DRSW_DAYNA_LC     = 0x011e,
     98 
     99 	/* NUBUS_CAT_CPU */
    100 	NUBUS_DRSW_NONE         = 0x0000,
    101 };
    102 
    103 /* DrHW: Uniquely identifies the hardware interface to a board (or at
    104    least, it should...  some video cards are known to incorrectly
    105    identify themselves as Toby cards) */
    106 
    107 /* Add known DrHW values here */
    108 enum nubus_drhw {
    109 	/* NUBUS_CAT_DISPLAY */
    110 	NUBUS_DRHW_APPLE_TFB      = 0x0001, /* Toby frame buffer card */
    111 	NUBUS_DRHW_APPLE_WVC      = 0x0006, /* Apple Workstation Video Card */
    112 	NUBUS_DRHW_SIGMA_CLRMAX   = 0x0007, /* Sigma Design ColorMax */
    113 	NUBUS_DRHW_APPLE_SE30     = 0x0009, /* Apple SE/30 video */
    114 	NUBUS_DRHW_APPLE_HRVC     = 0x0013, /* Mac II High-Res Video Card */
    115 	NUBUS_DRHW_APPLE_PVC      = 0x0017, /* Mac II Portrait Video Card */
    116 	NUBUS_DRHW_APPLE_RBV1     = 0x0018, /* IIci RBV video */
    117 	NUBUS_DRHW_APPLE_MDC      = 0x0019, /* Macintosh Display Card */
    118 	NUBUS_DRHW_APPLE_SONORA   = 0x0022, /* Sonora built-in video */
    119 	NUBUS_DRHW_APPLE_24AC     = 0x002b, /* Mac 24AC Video Card */
    120 	NUBUS_DRHW_APPLE_VALKYRIE = 0x002e,
    121 	NUBUS_DRHW_APPLE_JET      = 0x0029, /* Jet framebuffer (DuoDock) */
    122 	NUBUS_DRHW_SMAC_GFX       = 0x0105, /* SuperMac GFX */
    123 	NUBUS_DRHW_RASTER_CB264   = 0x013B, /* RasterOps ColorBoard 264 */
    124 	NUBUS_DRHW_MICRON_XCEED   = 0x0146, /* Micron Exceed color */
    125 	NUBUS_DRHW_RDIUS_GSC      = 0x0153, /* Radius GS/C */
    126 	NUBUS_DRHW_SMAC_SPEC8     = 0x017B, /* SuperMac Spectrum/8 */
    127 	NUBUS_DRHW_SMAC_SPEC24    = 0x017C, /* SuperMac Spectrum/24 */
    128 	NUBUS_DRHW_RASTER_CB364   = 0x026F, /* RasterOps ColorBoard 364 */
    129 	NUBUS_DRHW_RDIUS_DCGX     = 0x027C, /* Radius DirectColor/GX */
    130 	NUBUS_DRHW_RDIUS_PC8      = 0x0291, /* Radius PrecisionColor 8 */
    131 	NUBUS_DRHW_LAPIS_PCS8     = 0x0292, /* Lapis ProColorServer 8 */
    132 	NUBUS_DRHW_RASTER_24LXI   = 0x02A0, /* RasterOps 8/24 XLi */
    133 	NUBUS_DRHW_RASTER_PBPGT   = 0x02A5, /* RasterOps PaintBoard Prism GT */
    134 	NUBUS_DRHW_EMACH_FSX      = 0x02AE, /* E-Machines Futura SX */
    135 	NUBUS_DRHW_SMAC_THUND24   = 0x02CB, /* SuperMac Thunder/24 */
    136 	NUBUS_DRHW_RDIUS_PC24XP   = 0x0406, /* Radius PrecisionColor 24Xp */
    137 	NUBUS_DRHW_RDIUS_PC24X    = 0x040A, /* Radius PrecisionColor 24X */
    138 	NUBUS_DRHW_RDIUS_PC8XJ    = 0x040B, /* Radius PrecisionColor 8XJ */
    139 
    140 	/* NUBUS_CAT_NETWORK */
    141 	NUBUS_DRHW_INTERLAN       = 0x0100,
    142 	NUBUS_DRHW_SMC9194        = 0x0101,
    143 	NUBUS_DRHW_KINETICS       = 0x0106,
    144 	NUBUS_DRHW_CABLETRON      = 0x0109,
    145 	NUBUS_DRHW_ASANTE_LC      = 0x010f,
    146 	NUBUS_DRHW_SONIC          = 0x0110,
    147 	NUBUS_DRHW_TECHWORKS      = 0x0112,
    148 	NUBUS_DRHW_APPLE_SONIC_NB = 0x0118,
    149 	NUBUS_DRHW_APPLE_SONIC_LC = 0x0119,
    150 	NUBUS_DRHW_FOCUS          = 0x011c,
    151 	NUBUS_DRHW_SONNET         = 0x011d,
    152 };
    153 
    154 /* Resource IDs: These are the identifiers for the various weird and
    155    wonderful tidbits of information that may or may not reside in the
    156    NuBus ROM directory. */
    157 enum nubus_res_id {
    158 	NUBUS_RESID_TYPE         = 0x0001,
    159 	NUBUS_RESID_NAME         = 0x0002,
    160 	NUBUS_RESID_ICON         = 0x0003,
    161 	NUBUS_RESID_DRVRDIR      = 0x0004,
    162 	NUBUS_RESID_LOADREC      = 0x0005,
    163 	NUBUS_RESID_BOOTREC      = 0x0006,
    164 	NUBUS_RESID_FLAGS        = 0x0007,
    165 	NUBUS_RESID_HWDEVID      = 0x0008,
    166 	NUBUS_RESID_MINOR_BASEOS = 0x000a,
    167 	NUBUS_RESID_MINOR_LENGTH = 0x000b,
    168 	NUBUS_RESID_MAJOR_BASEOS = 0x000c,
    169 	NUBUS_RESID_MAJOR_LENGTH = 0x000d,
    170 	NUBUS_RESID_CICN         = 0x000f,
    171 	NUBUS_RESID_ICL8         = 0x0010,
    172 	NUBUS_RESID_ICL4         = 0x0011,
    173 };
    174 
    175 /* Category-specific resources. */
    176 enum nubus_board_res_id {
    177 	NUBUS_RESID_BOARDID      = 0x0020,
    178 	NUBUS_RESID_PRAMINITDATA = 0x0021,
    179 	NUBUS_RESID_PRIMARYINIT  = 0x0022,
    180 	NUBUS_RESID_TIMEOUTCONST = 0x0023,
    181 	NUBUS_RESID_VENDORINFO   = 0x0024,
    182 	NUBUS_RESID_BOARDFLAGS   = 0x0025,
    183 	NUBUS_RESID_SECONDINIT   = 0x0026,
    184 
    185 	/* Not sure why Apple put these next two in here */
    186 	NUBUS_RESID_VIDNAMES     = 0x0041,
    187 	NUBUS_RESID_VIDMODES     = 0x007e
    188 };
    189 
    190 /* Fields within the vendor info directory */
    191 enum nubus_vendor_res_id {
    192 	NUBUS_RESID_VEND_ID     = 0x0001,
    193 	NUBUS_RESID_VEND_SERIAL = 0x0002,
    194 	NUBUS_RESID_VEND_REV    = 0x0003,
    195 	NUBUS_RESID_VEND_PART   = 0x0004,
    196 	NUBUS_RESID_VEND_DATE   = 0x0005
    197 };
    198 
    199 enum nubus_net_res_id {
    200 	NUBUS_RESID_MAC_ADDRESS  = 0x0080
    201 };
    202 
    203 enum nubus_cpu_res_id {
    204 	NUBUS_RESID_MEMINFO      = 0x0081,
    205 	NUBUS_RESID_ROMINFO      = 0x0082
    206 };
    207 
    208 enum nubus_display_res_id {
    209 	NUBUS_RESID_GAMMADIR    = 0x0040,
    210 	NUBUS_RESID_FIRSTMODE   = 0x0080,
    211 	NUBUS_RESID_SECONDMODE  = 0x0081,
    212 	NUBUS_RESID_THIRDMODE   = 0x0082,
    213 	NUBUS_RESID_FOURTHMODE  = 0x0083,
    214 	NUBUS_RESID_FIFTHMODE   = 0x0084,
    215 	NUBUS_RESID_SIXTHMODE   = 0x0085
    216 };
    217 
    218 struct nubus_dir
    219 {
    220 	unsigned char *base;
    221 	unsigned char *ptr;
    222 	int done;
    223 	int mask;
    224 };
    225 
    226 struct nubus_dirent
    227 {
    228 	unsigned char *base;
    229 	unsigned char type;
    230 	__u32 data;	/* Actually 24bits used */
    231 	int mask;
    232 };
    233 
    234 struct nubus_board {
    235 	struct nubus_board* next;
    236 	struct nubus_dev* first_dev;
    237 
    238 	/* Only 9-E actually exist, though 0-8 are also theoretically
    239 	   possible, and 0 is a special case which represents the
    240 	   motherboard and onboard peripherals (Ethernet, video) */
    241 	int slot;
    242 	/* For slot 0, this is bogus. */
    243 	char name[64];
    244 
    245 	/* Format block */
    246 	unsigned char* fblock;
    247 	/* Root directory (does *not* always equal fblock + doffset!) */
    248 	unsigned char* directory;
    249 
    250 	unsigned long slot_addr;
    251 	/* Offset to root directory (sometimes) */
    252 	unsigned long doffset;
    253 	/* Length over which to compute the crc */
    254 	unsigned long rom_length;
    255 	/* Completely useless most of the time */
    256 	unsigned long crc;
    257 	unsigned char rev;
    258 	unsigned char format;
    259 	unsigned char lanes;
    260 };
    261 
    262 struct nubus_dev {
    263 	/* Next link in device list */
    264 	struct nubus_dev* next;
    265 	/* Directory entry in /proc/bus/nubus */
    266 	struct proc_dir_entry* procdir;
    267 
    268 	/* The functional resource ID of this device */
    269 	unsigned char resid;
    270 	/* These are mostly here for convenience; we could always read
    271 	   them from the ROMs if we wanted to */
    272 	unsigned short category;
    273 	unsigned short type;
    274 	unsigned short dr_sw;
    275 	unsigned short dr_hw;
    276 	/* This is the device's name rather than the board's.
    277 	   Sometimes they are different.  Usually the board name is
    278 	   more correct. */
    279 	char name[64];
    280 	/* MacOS driver (I kid you not) */
    281 	unsigned char* driver;
    282 	/* Actually this is an offset */
    283 	unsigned long iobase;
    284 	unsigned long iosize;
    285 	unsigned char flags, hwdevid;
    286 
    287 	/* Functional directory */
    288 	unsigned char* directory;
    289 	/* Much of our info comes from here */
    290 	struct nubus_board* board;
    291 };
    292 
    293 /* This is all NuBus devices (used to find devices later on) */
    294 extern struct nubus_dev* nubus_devices;
    295 /* This is all NuBus cards */
    296 extern struct nubus_board* nubus_boards;
    297 
    298 /* Generic NuBus interface functions, modelled after the PCI interface */
    299 void nubus_scan_bus(void);
    300 extern void nubus_proc_init(void);
    301 int get_nubus_list(char *buf);
    302 int nubus_proc_attach_device(struct nubus_dev *dev);
    303 int nubus_proc_detach_device(struct nubus_dev *dev);
    304 /* If we need more precision we can add some more of these */
    305 struct nubus_dev* nubus_find_device(unsigned short category,
    306 				    unsigned short type,
    307 				    unsigned short dr_hw,
    308 				    unsigned short dr_sw,
    309 				    const struct nubus_dev* from);
    310 struct nubus_dev* nubus_find_type(unsigned short category,
    311 				  unsigned short type,
    312 				  const struct nubus_dev* from);
    313 /* Might have more than one device in a slot, you know... */
    314 struct nubus_dev* nubus_find_slot(unsigned int slot,
    315 				  const struct nubus_dev* from);
    316 
    317 /* These are somewhat more NuBus-specific.  They all return 0 for
    318    success and -1 for failure, as you'd expect. */
    319 
    320 /* The root directory which contains the board and functional
    321    directories */
    322 int nubus_get_root_dir(const struct nubus_board* board,
    323 		       struct nubus_dir* dir);
    324 /* The board directory */
    325 int nubus_get_board_dir(const struct nubus_board* board,
    326 			struct nubus_dir* dir);
    327 /* The functional directory */
    328 int nubus_get_func_dir(const struct nubus_dev* dev,
    329 		       struct nubus_dir* dir);
    330 
    331 /* These work on any directory gotten via the above */
    332 int nubus_readdir(struct nubus_dir* dir,
    333 		  struct nubus_dirent* ent);
    334 int nubus_find_rsrc(struct nubus_dir* dir,
    335 		    unsigned char rsrc_type,
    336 		    struct nubus_dirent* ent);
    337 int nubus_rewinddir(struct nubus_dir* dir);
    338 
    339 /* Things to do with directory entries */
    340 int nubus_get_subdir(const struct nubus_dirent* ent,
    341 		     struct nubus_dir* dir);
    342 void nubus_get_rsrc_mem(void* dest,
    343 			const struct nubus_dirent *dirent,
    344 			int len);
    345 void nubus_get_rsrc_str(void* dest,
    346 			const struct nubus_dirent *dirent,
    347 			int maxlen);
    348 
    349 /* We'd like to get rid of this eventually.  Only daynaport.c uses it now. */
    350 static __inline__ void *nubus_slot_addr(int slot)
    351 {
    352 	return (void *)(0xF0000000|(slot<<24));
    353 }
    354 
    355 #endif /* LINUX_NUBUS_H */
    356