Merge with Linux 2.4.0-test5-pre3.
[linux-2.6/linux-mips.git] / include / linux / nubus.h
blob5f46ddd93a408d615e23dd6cd747875580106d1f
1 /*
2 nubus.h: various definitions and prototypes for NuBus drivers to use.
4 Originally written by Alan Cox.
6 Hacked to death by C. Scott Ananian and David Huggins-Daines.
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. */
12 #ifndef LINUX_NUBUS_H
13 #define LINUX_NUBUS_H
15 enum nubus_category {
16 NUBUS_CAT_BOARD = 0x0001,
17 NUBUS_CAT_DISPLAY = 0x0003,
18 NUBUS_CAT_NETWORK = 0x0004,
19 NUBUS_CAT_COMMUNICATIONS = 0x0006,
20 NUBUS_CAT_FONT = 0x0009,
21 NUBUS_CAT_CPU = 0x000A,
22 /* For lack of a better name */
23 NUBUS_CAT_DUODOCK = 0x0020
26 enum nubus_type_network {
27 NUBUS_TYPE_ETHERNET = 0x0001,
28 NUBUS_TYPE_RS232 = 0x0002
31 enum nubus_type_display {
32 NUBUS_TYPE_VIDEO = 0x0001
35 enum nubus_type_cpu {
36 NUBUS_TYPE_68020 = 0x0003,
37 NUBUS_TYPE_68030 = 0x0004,
38 NUBUS_TYPE_68040 = 0x0005
41 /* Known <Cat,Type,SW,HW> tuples: (according to TattleTech and Slots)
42 * 68030 motherboards: <10,4,0,24>
43 * 68040 motherboards: <10,5,0,24>
44 * DuoDock Plus: <32,1,1,2>
46 * Toby Frame Buffer card: <3,1,1,1>
47 * RBV built-in video (IIci): <3,1,1,24>
48 * Valkyrie built-in video (Q630): <3,1,1,46>
49 * Macintosh Display Card: <3,1,1,25>
50 * Sonora built-in video (P460): <3,1,1,34>
51 * Jet framebuffer (DuoDock Plus): <3,1,1,41>
53 * SONIC comm-slot/on-board and DuoDock Ethernet: <4,1,1,272>
54 * SONIC LC-PDS Ethernet (Dayna, but like Apple 16-bit, sort of): <4,1,1,271>
55 * Sonic Systems Ethernet A-Series Card: <4,1,268,256>
56 * Asante MacCon NuBus-A: <4,1,260,256> (alpha-1.0,1.1 revision)
57 * ROM on the above card: <2,1,0,0>
58 * Cabletron ethernet card: <4,1,1,265>
59 * Farallon ethernet card: <4,1,268,256> (identical to Sonic Systems card)
60 * Kinetics EtherPort IIN: <4,1,259,262>
61 * API Engineering EtherRun_LCa PDS enet card: <4,1,282,256>
63 * Add your devices to the list! You can obtain the "Slots" utility
64 * from Apple's FTP site at:
65 * ftp://dev.apple.com/devworld/Tool_Chest/Devices_-_Hardware/NuBus_Slot_Manager/
67 * Alternately, TattleTech can be found at any Info-Mac mirror site.
68 * or from its distribution site: ftp://ftp.decismkr.com/dms
71 /* DrSW: Uniquely identifies the software interface to a board. This
72 is usually the one you want to look at when writing a driver. It's
73 not as useful as you think, though, because as we should know by
74 now (duh), "Apple Compatible" can mean a lot of things... */
76 /* Add known DrSW values here */
77 enum nubus_drsw {
78 /* NUBUS_CAT_DISPLAY */
79 NUBUS_DRSW_APPLE = 0x0001,
80 NUBUS_DRSW_APPLE_HIRES = 0x0013, /* MacII HiRes card driver */
82 /* NUBUS_CAT_NETWORK */
83 NUBUS_DRSW_CABLETRON = 0x0001,
84 NUBUS_DRSW_SONIC_LC = 0x0001,
85 NUBUS_DRSW_KINETICS = 0x0103,
86 NUBUS_DRSW_ASANTE = 0x0104,
87 NUBUS_DRSW_DAYNA = 0x010b,
88 NUBUS_DRSW_FARALLON = 0x010c,
89 NUBUS_DRSW_APPLE_SN = 0x010f,
90 NUBUS_DRSW_FOCUS = 0x011a,
91 NUBUS_DRSW_ASANTE_CS = 0x011d, /* use asante SMC9194 driver */
93 /* NUBUS_CAT_CPU */
94 NUBUS_DRSW_NONE = 0x0000,
97 /* DrHW: Uniquely identifies the hardware interface to a board (or at
98 least, it should... some video cards are known to incorrectly
99 identify themselves as Toby cards) */
101 /* Add known DrHW values here */
102 enum nubus_drhw {
103 /* NUBUS_CAT_DISPLAY */
104 NUBUS_DRHW_APPLE_TFB = 0x0001, /* Toby frame buffer card */
105 NUBUS_DRHW_APPLE_RBV1 = 0x0018, /* IIci RBV video */
106 NUBUS_DRHW_APPLE_MDC = 0x0019, /* Macintosh Display Card */
107 NUBUS_DRHW_APPLE_SONORA = 0x0022, /* Sonora built-in video */
108 NUBUS_DRHW_APPLE_VALKYRIE = 0x002e,
109 NUBUS_DRHW_APPLE_JET = 0x0029, /* Jet framebuffer (DuoDock) */
111 /* NUBUS_CAT_NETWORK */
112 NUBUS_DRHW_INTERLAN = 0x0100,
113 NUBUS_DRHW_SMC9194 = 0x0101,
114 NUBUS_DRHW_KINETICS = 0x0106,
115 NUBUS_DRHW_CABLETRON = 0x0109,
116 NUBUS_DRHW_ASANTE_LC = 0x010f,
117 NUBUS_DRHW_SONIC = 0x0110,
120 /* Resource IDs: These are the identifiers for the various weird and
121 wonderful tidbits of information that may or may not reside in the
122 NuBus ROM directory. */
123 enum nubus_res_id {
124 NUBUS_RESID_TYPE = 0x0001,
125 NUBUS_RESID_NAME = 0x0002,
126 NUBUS_RESID_ICON = 0x0003,
127 NUBUS_RESID_DRVRDIR = 0x0004,
128 NUBUS_RESID_LOADREC = 0x0005,
129 NUBUS_RESID_BOOTREC = 0x0006,
130 NUBUS_RESID_FLAGS = 0x0007,
131 NUBUS_RESID_HWDEVID = 0x0008,
132 NUBUS_RESID_MINOR_BASEOS = 0x000a,
133 NUBUS_RESID_MINOR_LENGTH = 0x000b,
134 NUBUS_RESID_MAJOR_BASEOS = 0x000c,
135 NUBUS_RESID_MAJOR_LENGTH = 0x000d,
136 NUBUS_RESID_CICN = 0x000f,
137 NUBUS_RESID_ICL8 = 0x0010,
138 NUBUS_RESID_ICL4 = 0x0011,
141 /* Category-specific resources. */
142 enum nubus_board_res_id {
143 NUBUS_RESID_BOARDID = 0x0020,
144 NUBUS_RESID_PRAMINITDATA = 0x0021,
145 NUBUS_RESID_PRIMARYINIT = 0x0022,
146 NUBUS_RESID_TIMEOUTCONST = 0x0023,
147 NUBUS_RESID_VENDORINFO = 0x0024,
148 NUBUS_RESID_BOARDFLAGS = 0x0025,
149 NUBUS_RESID_SECONDINIT = 0x0026,
151 /* Not sure why Apple put these next two in here */
152 NUBUS_RESID_VIDNAMES = 0x0041,
153 NUBUS_RESID_VIDMODES = 0x007e
156 /* Fields within the vendor info directory */
157 enum nubus_vendor_res_id {
158 NUBUS_RESID_VEND_ID = 0x0001,
159 NUBUS_RESID_VEND_SERIAL = 0x0002,
160 NUBUS_RESID_VEND_REV = 0x0003,
161 NUBUS_RESID_VEND_PART = 0x0004,
162 NUBUS_RESID_VEND_DATE = 0x0005
165 enum nubus_net_res_id {
166 NUBUS_RESID_MAC_ADDRESS = 0x0080
169 enum nubus_cpu_res_id {
170 NUBUS_RESID_MEMINFO = 0x0081,
171 NUBUS_RESID_ROMINFO = 0x0082
174 enum nubus_display_res_id {
175 NUBUS_RESID_GAMMADIR = 0x0040,
176 NUBUS_RESID_FIRSTMODE = 0x0080,
177 NUBUS_RESID_SECONDMODE = 0x0081,
178 NUBUS_RESID_THIRDMODE = 0x0082,
179 NUBUS_RESID_FOURTHMODE = 0x0083,
180 NUBUS_RESID_FIFTHMODE = 0x0084,
181 NUBUS_RESID_SIXTHMODE = 0x0085
184 struct nubus_dir
186 unsigned char *base;
187 unsigned char *ptr;
188 int done;
189 int mask;
192 struct nubus_dirent
194 unsigned char *base;
195 unsigned char type;
196 __u32 data; /* Actually 24bits used */
197 int mask;
200 struct nubus_board {
201 struct nubus_board* next;
202 struct nubus_dev* first_dev;
204 /* Only 9-E actually exist, though 0-8 are also theoretically
205 possible, and 0 is a special case which represents the
206 motherboard and onboard peripherals (Ethernet, video) */
207 int slot;
208 /* For slot 0, this is bogus. */
209 char name[64];
211 /* Format block */
212 unsigned char* fblock;
213 /* Root directory (does *not* always equal fblock + doffset!) */
214 unsigned char* directory;
216 unsigned long slot_addr;
217 /* Offset to root directory (sometimes) */
218 unsigned long doffset;
219 /* Length over which to compute the crc */
220 unsigned long rom_length;
221 /* Completely useless most of the time */
222 unsigned long crc;
223 unsigned char rev;
224 unsigned char format;
225 unsigned char lanes;
228 struct nubus_dev {
229 /* Next link in device list */
230 struct nubus_dev* next;
231 /* Directory entry in /proc/bus/nubus */
232 struct proc_dir_entry* procdir;
234 /* The functional resource ID of this device */
235 unsigned char resid;
236 /* These are mostly here for convenience; we could always read
237 them from the ROMs if we wanted to */
238 unsigned short category;
239 unsigned short type;
240 unsigned short dr_sw;
241 unsigned short dr_hw;
242 /* This is the device's name rather than the board's.
243 Sometimes they are different. Usually the board name is
244 more correct. */
245 char name[64];
246 /* MacOS driver (I kid you not) */
247 unsigned char* driver;
248 /* Actually this is an offset */
249 unsigned long iobase;
250 unsigned long iosize;
251 unsigned char flags, hwdevid;
253 /* Functional directory */
254 unsigned char* directory;
255 /* Much of our info comes from here */
256 struct nubus_board* board;
259 /* This is all NuBus devices (used to find devices later on) */
260 extern struct nubus_dev* nubus_devices;
261 /* This is all NuBus cards */
262 extern struct nubus_board* nubus_boards;
264 /* Generic NuBus interface functions, modelled after the PCI interface */
265 extern void nubus_init(void);
266 void nubus_scan_bus(void);
267 extern void nubus_proc_init(void);
268 int get_nubus_list(char *buf);
269 int nubus_proc_attach_device(struct nubus_dev *dev);
270 int nubus_proc_detach_device(struct nubus_dev *dev);
271 /* If we need more precision we can add some more of these */
272 struct nubus_dev* nubus_find_device(unsigned short category,
273 unsigned short type,
274 unsigned short dr_hw,
275 unsigned short dr_sw,
276 const struct nubus_dev* from);
277 struct nubus_dev* nubus_find_type(unsigned short category,
278 unsigned short type,
279 const struct nubus_dev* from);
280 /* Might have more than one device in a slot, you know... */
281 struct nubus_dev* nubus_find_slot(unsigned int slot,
282 const struct nubus_dev* from);
284 /* These are somewhat more NuBus-specific. They all return 0 for
285 success and -1 for failure, as you'd expect. */
287 /* The root directory which contains the board and functional
288 directories */
289 int nubus_get_root_dir(const struct nubus_board* board,
290 struct nubus_dir* dir);
291 /* The board directory */
292 int nubus_get_board_dir(const struct nubus_board* board,
293 struct nubus_dir* dir);
294 /* The functional directory */
295 int nubus_get_func_dir(const struct nubus_dev* dev,
296 struct nubus_dir* dir);
298 /* These work on any directory gotten via the above */
299 int nubus_readdir(struct nubus_dir* dir,
300 struct nubus_dirent* ent);
301 int nubus_find_rsrc(struct nubus_dir* dir,
302 unsigned char rsrc_type,
303 struct nubus_dirent* ent);
304 int nubus_rewinddir(struct nubus_dir* dir);
306 /* Things to do with directory entries */
307 int nubus_get_subdir(const struct nubus_dirent* ent,
308 struct nubus_dir* dir);
309 void nubus_get_rsrc_mem(void* dest,
310 const struct nubus_dirent *dirent,
311 int len);
312 void nubus_get_rsrc_str(void* dest,
313 const struct nubus_dirent *dirent,
314 int maxlen);
316 /* We'd like to get rid of this eventually. Only daynaport.c uses it now. */
317 extern inline void *nubus_slot_addr(int slot)
319 return (void *)(0xF0000000|(slot<<24));
322 #endif LINUX_NUBUS_H