0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef LINUX_NUBUS_H
0011 #define LINUX_NUBUS_H
0012
0013 #include <linux/device.h>
0014 #include <asm/nubus.h>
0015 #include <uapi/linux/nubus.h>
0016
0017 struct proc_dir_entry;
0018 struct seq_file;
0019
0020 struct nubus_dir {
0021 unsigned char *base;
0022 unsigned char *ptr;
0023 int done;
0024 int mask;
0025 struct proc_dir_entry *procdir;
0026 };
0027
0028 struct nubus_dirent {
0029 unsigned char *base;
0030 unsigned char type;
0031 __u32 data;
0032 int mask;
0033 };
0034
0035 struct nubus_board {
0036 struct device dev;
0037
0038
0039
0040
0041 int slot;
0042
0043 char name[64];
0044
0045
0046 unsigned char *fblock;
0047
0048 unsigned char *directory;
0049
0050 unsigned long slot_addr;
0051
0052 unsigned long doffset;
0053
0054 unsigned long rom_length;
0055
0056 unsigned long crc;
0057 unsigned char rev;
0058 unsigned char format;
0059 unsigned char lanes;
0060
0061
0062 struct proc_dir_entry *procdir;
0063 };
0064
0065 struct nubus_rsrc {
0066 struct list_head list;
0067
0068
0069 unsigned char resid;
0070
0071
0072 unsigned short category;
0073 unsigned short type;
0074 unsigned short dr_sw;
0075 unsigned short dr_hw;
0076
0077
0078 unsigned char *directory;
0079
0080 struct nubus_board *board;
0081 };
0082
0083
0084 extern struct list_head nubus_func_rsrcs;
0085
0086 struct nubus_driver {
0087 struct device_driver driver;
0088 int (*probe)(struct nubus_board *board);
0089 void (*remove)(struct nubus_board *board);
0090 };
0091
0092 extern struct bus_type nubus_bus_type;
0093
0094
0095 #ifdef CONFIG_PROC_FS
0096 void nubus_proc_init(void);
0097 struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board);
0098 struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,
0099 const struct nubus_dirent *ent,
0100 struct nubus_board *board);
0101 void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
0102 const struct nubus_dirent *ent,
0103 unsigned int size);
0104 void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
0105 const struct nubus_dirent *ent);
0106 #else
0107 static inline void nubus_proc_init(void) {}
0108 static inline
0109 struct proc_dir_entry *nubus_proc_add_board(struct nubus_board *board)
0110 { return NULL; }
0111 static inline
0112 struct proc_dir_entry *nubus_proc_add_rsrc_dir(struct proc_dir_entry *procdir,
0113 const struct nubus_dirent *ent,
0114 struct nubus_board *board)
0115 { return NULL; }
0116 static inline void nubus_proc_add_rsrc_mem(struct proc_dir_entry *procdir,
0117 const struct nubus_dirent *ent,
0118 unsigned int size) {}
0119 static inline void nubus_proc_add_rsrc(struct proc_dir_entry *procdir,
0120 const struct nubus_dirent *ent) {}
0121 #endif
0122
0123 struct nubus_rsrc *nubus_first_rsrc_or_null(void);
0124 struct nubus_rsrc *nubus_next_rsrc_or_null(struct nubus_rsrc *from);
0125
0126 #define for_each_func_rsrc(f) \
0127 for (f = nubus_first_rsrc_or_null(); f; f = nubus_next_rsrc_or_null(f))
0128
0129 #define for_each_board_func_rsrc(b, f) \
0130 for_each_func_rsrc(f) if (f->board != b) {} else
0131
0132
0133
0134
0135
0136
0137 int nubus_get_root_dir(const struct nubus_board *board,
0138 struct nubus_dir *dir);
0139
0140 int nubus_get_board_dir(const struct nubus_board *board,
0141 struct nubus_dir *dir);
0142
0143 int nubus_get_func_dir(const struct nubus_rsrc *fres, struct nubus_dir *dir);
0144
0145
0146 int nubus_readdir(struct nubus_dir *dir,
0147 struct nubus_dirent *ent);
0148 int nubus_find_rsrc(struct nubus_dir *dir,
0149 unsigned char rsrc_type,
0150 struct nubus_dirent *ent);
0151 int nubus_rewinddir(struct nubus_dir *dir);
0152
0153
0154 int nubus_get_subdir(const struct nubus_dirent *ent,
0155 struct nubus_dir *dir);
0156 void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent,
0157 unsigned int len);
0158 unsigned int nubus_get_rsrc_str(char *dest, const struct nubus_dirent *dirent,
0159 unsigned int len);
0160 void nubus_seq_write_rsrc_mem(struct seq_file *m,
0161 const struct nubus_dirent *dirent,
0162 unsigned int len);
0163 unsigned char *nubus_dirptr(const struct nubus_dirent *nd);
0164
0165
0166 int nubus_parent_device_register(void);
0167 int nubus_device_register(struct nubus_board *board);
0168 int nubus_driver_register(struct nubus_driver *ndrv);
0169 void nubus_driver_unregister(struct nubus_driver *ndrv);
0170 int nubus_proc_show(struct seq_file *m, void *data);
0171
0172 static inline void nubus_set_drvdata(struct nubus_board *board, void *data)
0173 {
0174 dev_set_drvdata(&board->dev, data);
0175 }
0176
0177 static inline void *nubus_get_drvdata(struct nubus_board *board)
0178 {
0179 return dev_get_drvdata(&board->dev);
0180 }
0181
0182
0183 static inline void *nubus_slot_addr(int slot)
0184 {
0185 return (void *)(0xF0000000 | (slot << 24));
0186 }
0187
0188 #endif