diff options
Diffstat (limited to 'include/linux/nubus.h')
-rw-r--r-- | include/linux/nubus.h | 189 |
1 files changed, 121 insertions, 68 deletions
diff --git a/include/linux/nubus.h b/include/linux/nubus.h index 11ce6b1117a8..6e8200215321 100644 --- a/include/linux/nubus.h +++ b/include/linux/nubus.h | |||
@@ -5,20 +5,36 @@ | |||
5 | Originally written by Alan Cox. | 5 | Originally written by Alan Cox. |
6 | 6 | ||
7 | Hacked to death by C. Scott Ananian and David Huggins-Daines. | 7 | Hacked to death by C. Scott Ananian and David Huggins-Daines. |
8 | 8 | */ | |
9 | Some of the constants in here are from the corresponding | 9 | |
10 | NetBSD/OpenBSD header file, by Allen Briggs. We figured out the | ||
11 | rest of them on our own. */ | ||
12 | #ifndef LINUX_NUBUS_H | 10 | #ifndef LINUX_NUBUS_H |
13 | #define LINUX_NUBUS_H | 11 | #define LINUX_NUBUS_H |
14 | 12 | ||
13 | #include <linux/device.h> | ||
15 | #include <asm/nubus.h> | 14 | #include <asm/nubus.h> |
16 | #include <uapi/linux/nubus.h> | 15 | #include <uapi/linux/nubus.h> |
17 | 16 | ||
17 | struct proc_dir_entry; | ||
18 | struct seq_file; | ||
19 | |||
20 | struct nubus_dir { | ||
21 | unsigned char *base; | ||
22 | unsigned char *ptr; | ||
23 | int done; | ||
24 | int mask; | ||
25 | struct proc_dir_entry *procdir; | ||
26 | }; | ||
27 | |||
28 | struct nubus_dirent { | ||
29 | unsigned char *base; | ||
30 | unsigned char type; | ||
31 | __u32 data; /* Actually 24 bits used */ | ||
32 | int mask; | ||
33 | }; | ||
34 | |||
18 | struct nubus_board { | 35 | struct nubus_board { |
19 | struct nubus_board* next; | 36 | struct device dev; |
20 | struct nubus_dev* first_dev; | 37 | |
21 | |||
22 | /* Only 9-E actually exist, though 0-8 are also theoretically | 38 | /* Only 9-E actually exist, though 0-8 are also theoretically |
23 | possible, and 0 is a special case which represents the | 39 | possible, and 0 is a special case which represents the |
24 | motherboard and onboard peripherals (Ethernet, video) */ | 40 | motherboard and onboard peripherals (Ethernet, video) */ |
@@ -27,10 +43,10 @@ struct nubus_board { | |||
27 | char name[64]; | 43 | char name[64]; |
28 | 44 | ||
29 | /* Format block */ | 45 | /* Format block */ |
30 | unsigned char* fblock; | 46 | unsigned char *fblock; |
31 | /* Root directory (does *not* always equal fblock + doffset!) */ | 47 | /* Root directory (does *not* always equal fblock + doffset!) */ |
32 | unsigned char* directory; | 48 | unsigned char *directory; |
33 | 49 | ||
34 | unsigned long slot_addr; | 50 | unsigned long slot_addr; |
35 | /* Offset to root directory (sometimes) */ | 51 | /* Offset to root directory (sometimes) */ |
36 | unsigned long doffset; | 52 | unsigned long doffset; |
@@ -41,15 +57,15 @@ struct nubus_board { | |||
41 | unsigned char rev; | 57 | unsigned char rev; |
42 | unsigned char format; | 58 | unsigned char format; |
43 | unsigned char lanes; | 59 | unsigned char lanes; |
44 | }; | ||
45 | 60 | ||
46 | struct nubus_dev { | ||
47 | /* Next link in device list */ | ||
48 | struct nubus_dev* next; | ||
49 | /* Directory entry in /proc/bus/nubus */ | 61 | /* Directory entry in /proc/bus/nubus */ |
50 | struct proc_dir_entry* procdir; | 62 | struct proc_dir_entry *procdir; |
63 | }; | ||
64 | |||
65 | struct nubus_rsrc { | ||
66 | struct list_head list; | ||
51 | 67 | ||
52 | /* The functional resource ID of this device */ | 68 | /* The functional resource ID */ |
53 | unsigned char resid; | 69 | unsigned char resid; |
54 | /* These are mostly here for convenience; we could always read | 70 | /* These are mostly here for convenience; we could always read |
55 | them from the ROMs if we wanted to */ | 71 | them from the ROMs if we wanted to */ |
@@ -57,79 +73,116 @@ struct nubus_dev { | |||
57 | unsigned short type; | 73 | unsigned short type; |
58 | unsigned short dr_sw; | 74 | unsigned short dr_sw; |
59 | unsigned short dr_hw; | 75 | unsigned short dr_hw; |
60 | /* This is the device's name rather than the board's. | 76 | |
61 | Sometimes they are different. Usually the board name is | ||
62 | more correct. */ | ||
63 | char name[64]; | ||
64 | /* MacOS driver (I kid you not) */ | ||
65 | unsigned char* driver; | ||
66 | /* Actually this is an offset */ | ||
67 | unsigned long iobase; | ||
68 | unsigned long iosize; | ||
69 | unsigned char flags, hwdevid; | ||
70 | |||
71 | /* Functional directory */ | 77 | /* Functional directory */ |
72 | unsigned char* directory; | 78 | unsigned char *directory; |
73 | /* Much of our info comes from here */ | 79 | /* Much of our info comes from here */ |
74 | struct nubus_board* board; | 80 | struct nubus_board *board; |
81 | }; | ||
82 | |||
83 | /* This is all NuBus functional resources (used to find devices later on) */ | ||
84 | extern struct list_head nubus_func_rsrcs; | ||
85 | |||
86 | struct nubus_driver { | ||
87 | struct device_driver driver; | ||
88 | int (*probe)(struct nubus_board *board); | ||
89 | int (*remove)(struct nubus_board *board); | ||
75 | }; | 90 | }; |
76 | 91 | ||
77 | /* This is all NuBus devices (used to find devices later on) */ | 92 | extern struct bus_type nubus_bus_type; |
78 | extern struct nubus_dev* nubus_devices; | ||
79 | /* This is all NuBus cards */ | ||
80 | extern struct nubus_board* nubus_boards; | ||
81 | 93 | ||
82 | /* Generic NuBus interface functions, modelled after the PCI interface */ | 94 | /* Generic NuBus interface functions, modelled after the PCI interface */ |
83 | void nubus_scan_bus(void); | ||
84 | #ifdef CONFIG_PROC_FS | 95 | #ifdef CONFIG_PROC_FS |
85 | extern void nubus_proc_init(void); | 96 | void nubus_proc_init(void); |
97 | struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board); | ||
98 | struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir, | ||
99 | const struct nubus_dirent *ent, | ||
100 | struct nubus_board *board); | ||
101 | void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir, | ||
102 | const struct nubus_dirent *ent, | ||
103 | unsigned int size); | ||
104 | void nubus_proc_add_rsrc(struct proc_dir_entry *procdir, | ||
105 | const struct nubus_dirent *ent); | ||
86 | #else | 106 | #else |
87 | static inline void nubus_proc_init(void) {} | 107 | static inline void nubus_proc_init(void) {} |
108 | static inline | ||
109 | struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board) | ||
110 | { return NULL; } | ||
111 | static inline | ||
112 | struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir, | ||
113 | const struct nubus_dirent *ent, | ||
114 | struct nubus_board *board) | ||
115 | { return NULL; } | ||
116 | static inline void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir, | ||
117 | const struct nubus_dirent *ent, | ||
118 | unsigned int size) {} | ||
119 | static inline void nubus_proc_add_rsrc(struct proc_dir_entry *procdir, | ||
120 | const struct nubus_dirent *ent) {} | ||
88 | #endif | 121 | #endif |
89 | int get_nubus_list(char *buf); | 122 | |
90 | int nubus_proc_attach_device(struct nubus_dev *dev); | 123 | struct nubus_rsrc *nubus_first_rsrc_or_null(void); |
91 | /* If we need more precision we can add some more of these */ | 124 | struct nubus_rsrc *nubus_next_rsrc_or_null(struct nubus_rsrc *from); |
92 | struct nubus_dev* nubus_find_device(unsigned short category, | 125 | |
93 | unsigned short type, | 126 | #define for_each_func_rsrc(f) \ |
94 | unsigned short dr_hw, | 127 | for (f = nubus_first_rsrc_or_null(); f; f = nubus_next_rsrc_or_null(f)) |
95 | unsigned short dr_sw, | 128 | |
96 | const struct nubus_dev* from); | 129 | #define for_each_board_func_rsrc(b, f) \ |
97 | struct nubus_dev* nubus_find_type(unsigned short category, | 130 | for_each_func_rsrc(f) if (f->board != b) {} else |
98 | unsigned short type, | ||
99 | const struct nubus_dev* from); | ||
100 | /* Might have more than one device in a slot, you know... */ | ||
101 | struct nubus_dev* nubus_find_slot(unsigned int slot, | ||
102 | const struct nubus_dev* from); | ||
103 | 131 | ||
104 | /* These are somewhat more NuBus-specific. They all return 0 for | 132 | /* These are somewhat more NuBus-specific. They all return 0 for |
105 | success and -1 for failure, as you'd expect. */ | 133 | success and -1 for failure, as you'd expect. */ |
106 | 134 | ||
107 | /* The root directory which contains the board and functional | 135 | /* The root directory which contains the board and functional |
108 | directories */ | 136 | directories */ |
109 | int nubus_get_root_dir(const struct nubus_board* board, | 137 | int nubus_get_root_dir(const struct nubus_board *board, |
110 | struct nubus_dir* dir); | 138 | struct nubus_dir *dir); |
111 | /* The board directory */ | 139 | /* The board directory */ |
112 | int nubus_get_board_dir(const struct nubus_board* board, | 140 | int nubus_get_board_dir(const struct nubus_board *board, |
113 | struct nubus_dir* dir); | 141 | struct nubus_dir *dir); |
114 | /* The functional directory */ | 142 | /* The functional directory */ |
115 | int nubus_get_func_dir(const struct nubus_dev* dev, | 143 | int nubus_get_func_dir(const struct nubus_rsrc *fres, struct nubus_dir *dir); |
116 | struct nubus_dir* dir); | ||
117 | 144 | ||
118 | /* These work on any directory gotten via the above */ | 145 | /* These work on any directory gotten via the above */ |
119 | int nubus_readdir(struct nubus_dir* dir, | 146 | int nubus_readdir(struct nubus_dir *dir, |
120 | struct nubus_dirent* ent); | 147 | struct nubus_dirent *ent); |
121 | int nubus_find_rsrc(struct nubus_dir* dir, | 148 | int nubus_find_rsrc(struct nubus_dir *dir, |
122 | unsigned char rsrc_type, | 149 | unsigned char rsrc_type, |
123 | struct nubus_dirent* ent); | 150 | struct nubus_dirent *ent); |
124 | int nubus_rewinddir(struct nubus_dir* dir); | 151 | int nubus_rewinddir(struct nubus_dir *dir); |
125 | 152 | ||
126 | /* Things to do with directory entries */ | 153 | /* Things to do with directory entries */ |
127 | int nubus_get_subdir(const struct nubus_dirent* ent, | 154 | int nubus_get_subdir(const struct nubus_dirent *ent, |
128 | struct nubus_dir* dir); | 155 | struct nubus_dir *dir); |
129 | void nubus_get_rsrc_mem(void* dest, | 156 | void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent, |
130 | const struct nubus_dirent *dirent, | 157 | unsigned int len); |
131 | int len); | 158 | unsigned int nubus_get_rsrc_str(char *dest, const struct nubus_dirent *dirent, |
132 | void nubus_get_rsrc_str(void* dest, | 159 | unsigned int len); |
133 | const struct nubus_dirent *dirent, | 160 | void nubus_seq_write_rsrc_mem(struct seq_file *m, |
134 | int maxlen); | 161 | const struct nubus_dirent *dirent, |
162 | unsigned int len); | ||
163 | unsigned char *nubus_dirptr(const struct nubus_dirent *nd); | ||
164 | |||
165 | /* Declarations relating to driver model objects */ | ||
166 | int nubus_bus_register(void); | ||
167 | int nubus_device_register(struct nubus_board *board); | ||
168 | int nubus_driver_register(struct nubus_driver *ndrv); | ||
169 | void nubus_driver_unregister(struct nubus_driver *ndrv); | ||
170 | int nubus_proc_show(struct seq_file *m, void *data); | ||
171 | |||
172 | static inline void nubus_set_drvdata(struct nubus_board *board, void *data) | ||
173 | { | ||
174 | dev_set_drvdata(&board->dev, data); | ||
175 | } | ||
176 | |||
177 | static inline void *nubus_get_drvdata(struct nubus_board *board) | ||
178 | { | ||
179 | return dev_get_drvdata(&board->dev); | ||
180 | } | ||
181 | |||
182 | /* Returns a pointer to the "standard" slot space. */ | ||
183 | static inline void *nubus_slot_addr(int slot) | ||
184 | { | ||
185 | return (void *)(0xF0000000 | (slot << 24)); | ||
186 | } | ||
187 | |||
135 | #endif /* LINUX_NUBUS_H */ | 188 | #endif /* LINUX_NUBUS_H */ |