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