blob: 6165b2c620408a7ee5d956d703f714275740e255 [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. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#ifndef LINUX_NUBUS_H
12#define LINUX_NUBUS_H
13
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/nubus.h>
David Howells607ca462012-10-13 10:46:48 +010015#include <uapi/linux/nubus.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Linus Torvalds1da177e2005-04-16 15:20:36 -070017struct nubus_board {
18 struct nubus_board* next;
19 struct nubus_dev* first_dev;
20
Finn Thainf8779582007-05-01 22:32:53 +020021 /* Only 9-E actually exist, though 0-8 are also theoretically
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 possible, and 0 is a special case which represents the
23 motherboard and onboard peripherals (Ethernet, video) */
24 int slot;
25 /* For slot 0, this is bogus. */
26 char name[64];
27
28 /* Format block */
29 unsigned char* fblock;
30 /* Root directory (does *not* always equal fblock + doffset!) */
31 unsigned char* directory;
32
33 unsigned long slot_addr;
34 /* Offset to root directory (sometimes) */
35 unsigned long doffset;
36 /* Length over which to compute the crc */
37 unsigned long rom_length;
38 /* Completely useless most of the time */
39 unsigned long crc;
40 unsigned char rev;
41 unsigned char format;
42 unsigned char lanes;
43};
44
45struct nubus_dev {
46 /* Next link in device list */
47 struct nubus_dev* next;
48 /* Directory entry in /proc/bus/nubus */
49 struct proc_dir_entry* procdir;
50
51 /* The functional resource ID of this device */
52 unsigned char resid;
53 /* These are mostly here for convenience; we could always read
54 them from the ROMs if we wanted to */
55 unsigned short category;
56 unsigned short type;
57 unsigned short dr_sw;
58 unsigned short dr_hw;
59 /* This is the device's name rather than the board's.
60 Sometimes they are different. Usually the board name is
61 more correct. */
62 char name[64];
63 /* MacOS driver (I kid you not) */
64 unsigned char* driver;
65 /* Actually this is an offset */
66 unsigned long iobase;
67 unsigned long iosize;
68 unsigned char flags, hwdevid;
69
70 /* Functional directory */
71 unsigned char* directory;
72 /* Much of our info comes from here */
73 struct nubus_board* board;
74};
75
76/* This is all NuBus devices (used to find devices later on) */
77extern struct nubus_dev* nubus_devices;
78/* This is all NuBus cards */
79extern struct nubus_board* nubus_boards;
80
81/* Generic NuBus interface functions, modelled after the PCI interface */
82void nubus_scan_bus(void);
David Howells11db6562013-04-10 15:05:38 +010083#ifdef CONFIG_PROC_FS
Linus Torvalds1da177e2005-04-16 15:20:36 -070084extern void nubus_proc_init(void);
David Howells11db6562013-04-10 15:05:38 +010085#else
86static inline void nubus_proc_init(void) {}
87#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070088int get_nubus_list(char *buf);
89int nubus_proc_attach_device(struct nubus_dev *dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090/* If we need more precision we can add some more of these */
91struct nubus_dev* nubus_find_device(unsigned short category,
92 unsigned short type,
93 unsigned short dr_hw,
94 unsigned short dr_sw,
95 const struct nubus_dev* from);
96struct nubus_dev* nubus_find_type(unsigned short category,
97 unsigned short type,
98 const struct nubus_dev* from);
99/* Might have more than one device in a slot, you know... */
100struct nubus_dev* nubus_find_slot(unsigned int slot,
101 const struct nubus_dev* from);
102
103/* These are somewhat more NuBus-specific. They all return 0 for
104 success and -1 for failure, as you'd expect. */
105
106/* The root directory which contains the board and functional
107 directories */
108int nubus_get_root_dir(const struct nubus_board* board,
109 struct nubus_dir* dir);
110/* The board directory */
111int nubus_get_board_dir(const struct nubus_board* board,
112 struct nubus_dir* dir);
113/* The functional directory */
114int nubus_get_func_dir(const struct nubus_dev* dev,
115 struct nubus_dir* dir);
116
117/* These work on any directory gotten via the above */
118int nubus_readdir(struct nubus_dir* dir,
119 struct nubus_dirent* ent);
120int nubus_find_rsrc(struct nubus_dir* dir,
121 unsigned char rsrc_type,
122 struct nubus_dirent* ent);
123int nubus_rewinddir(struct nubus_dir* dir);
124
125/* Things to do with directory entries */
126int nubus_get_subdir(const struct nubus_dirent* ent,
127 struct nubus_dir* dir);
128void nubus_get_rsrc_mem(void* dest,
129 const struct nubus_dirent *dirent,
130 int len);
131void nubus_get_rsrc_str(void* dest,
132 const struct nubus_dirent *dirent,
133 int maxlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#endif /* LINUX_NUBUS_H */