Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | nubus.h: various definitions and prototypes for NuBus drivers to use. |
| 4 | |
| 5 | Originally written by Alan Cox. |
| 6 | |
| 7 | Hacked to death by C. Scott Ananian and David Huggins-Daines. |
Finn Thain | 1ff2775 | 2018-01-13 17:37:13 -0500 | [diff] [blame^] | 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #ifndef LINUX_NUBUS_H |
| 11 | #define LINUX_NUBUS_H |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/nubus.h> |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 14 | #include <uapi/linux/nubus.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Finn Thain | 1ff2775 | 2018-01-13 17:37:13 -0500 | [diff] [blame^] | 16 | struct nubus_dir { |
| 17 | unsigned char *base; |
| 18 | unsigned char *ptr; |
| 19 | int done; |
| 20 | int mask; |
| 21 | }; |
| 22 | |
| 23 | struct nubus_dirent { |
| 24 | unsigned char *base; |
| 25 | unsigned char type; |
| 26 | __u32 data; /* Actually 24 bits used */ |
| 27 | int mask; |
| 28 | }; |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | struct nubus_board { |
| 31 | struct nubus_board* next; |
| 32 | struct nubus_dev* first_dev; |
| 33 | |
Finn Thain | f877958 | 2007-05-01 22:32:53 +0200 | [diff] [blame] | 34 | /* Only 9-E actually exist, though 0-8 are also theoretically |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | possible, and 0 is a special case which represents the |
| 36 | motherboard and onboard peripherals (Ethernet, video) */ |
| 37 | int slot; |
| 38 | /* For slot 0, this is bogus. */ |
| 39 | char name[64]; |
| 40 | |
| 41 | /* Format block */ |
| 42 | unsigned char* fblock; |
| 43 | /* Root directory (does *not* always equal fblock + doffset!) */ |
| 44 | unsigned char* directory; |
| 45 | |
| 46 | unsigned long slot_addr; |
| 47 | /* Offset to root directory (sometimes) */ |
| 48 | unsigned long doffset; |
| 49 | /* Length over which to compute the crc */ |
| 50 | unsigned long rom_length; |
| 51 | /* Completely useless most of the time */ |
| 52 | unsigned long crc; |
| 53 | unsigned char rev; |
| 54 | unsigned char format; |
| 55 | unsigned char lanes; |
| 56 | }; |
| 57 | |
| 58 | struct nubus_dev { |
| 59 | /* Next link in device list */ |
| 60 | struct nubus_dev* next; |
| 61 | /* Directory entry in /proc/bus/nubus */ |
| 62 | struct proc_dir_entry* procdir; |
| 63 | |
| 64 | /* The functional resource ID of this device */ |
| 65 | unsigned char resid; |
| 66 | /* These are mostly here for convenience; we could always read |
| 67 | them from the ROMs if we wanted to */ |
| 68 | unsigned short category; |
| 69 | unsigned short type; |
| 70 | unsigned short dr_sw; |
| 71 | unsigned short dr_hw; |
| 72 | /* This is the device's name rather than the board's. |
| 73 | Sometimes they are different. Usually the board name is |
| 74 | more correct. */ |
| 75 | char name[64]; |
| 76 | /* MacOS driver (I kid you not) */ |
| 77 | unsigned char* driver; |
| 78 | /* Actually this is an offset */ |
| 79 | unsigned long iobase; |
| 80 | unsigned long iosize; |
| 81 | unsigned char flags, hwdevid; |
| 82 | |
| 83 | /* Functional directory */ |
| 84 | unsigned char* directory; |
| 85 | /* Much of our info comes from here */ |
| 86 | struct nubus_board* board; |
| 87 | }; |
| 88 | |
| 89 | /* This is all NuBus devices (used to find devices later on) */ |
| 90 | extern struct nubus_dev* nubus_devices; |
| 91 | /* This is all NuBus cards */ |
| 92 | extern struct nubus_board* nubus_boards; |
| 93 | |
| 94 | /* Generic NuBus interface functions, modelled after the PCI interface */ |
| 95 | void nubus_scan_bus(void); |
David Howells | 11db656 | 2013-04-10 15:05:38 +0100 | [diff] [blame] | 96 | #ifdef CONFIG_PROC_FS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | extern void nubus_proc_init(void); |
David Howells | 11db656 | 2013-04-10 15:05:38 +0100 | [diff] [blame] | 98 | #else |
| 99 | static inline void nubus_proc_init(void) {} |
| 100 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | int get_nubus_list(char *buf); |
| 102 | int nubus_proc_attach_device(struct nubus_dev *dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | /* If we need more precision we can add some more of these */ |
| 104 | struct nubus_dev* nubus_find_device(unsigned short category, |
| 105 | unsigned short type, |
| 106 | unsigned short dr_hw, |
| 107 | unsigned short dr_sw, |
| 108 | const struct nubus_dev* from); |
| 109 | struct nubus_dev* nubus_find_type(unsigned short category, |
| 110 | unsigned short type, |
| 111 | const struct nubus_dev* from); |
| 112 | /* Might have more than one device in a slot, you know... */ |
| 113 | struct nubus_dev* nubus_find_slot(unsigned int slot, |
| 114 | const struct nubus_dev* from); |
| 115 | |
| 116 | /* These are somewhat more NuBus-specific. They all return 0 for |
| 117 | success and -1 for failure, as you'd expect. */ |
| 118 | |
| 119 | /* The root directory which contains the board and functional |
| 120 | directories */ |
| 121 | int nubus_get_root_dir(const struct nubus_board* board, |
| 122 | struct nubus_dir* dir); |
| 123 | /* The board directory */ |
| 124 | int nubus_get_board_dir(const struct nubus_board* board, |
| 125 | struct nubus_dir* dir); |
| 126 | /* The functional directory */ |
| 127 | int nubus_get_func_dir(const struct nubus_dev* dev, |
| 128 | struct nubus_dir* dir); |
| 129 | |
| 130 | /* These work on any directory gotten via the above */ |
| 131 | int nubus_readdir(struct nubus_dir* dir, |
| 132 | struct nubus_dirent* ent); |
| 133 | int nubus_find_rsrc(struct nubus_dir* dir, |
| 134 | unsigned char rsrc_type, |
| 135 | struct nubus_dirent* ent); |
| 136 | int nubus_rewinddir(struct nubus_dir* dir); |
| 137 | |
| 138 | /* Things to do with directory entries */ |
| 139 | int nubus_get_subdir(const struct nubus_dirent* ent, |
| 140 | struct nubus_dir* dir); |
Finn Thain | 2f828fb | 2018-01-13 17:37:13 -0500 | [diff] [blame] | 141 | void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent, |
| 142 | unsigned int len); |
| 143 | void nubus_get_rsrc_str(char *dest, const struct nubus_dirent *dirent, |
| 144 | unsigned int maxlen); |
Finn Thain | 1ff2775 | 2018-01-13 17:37:13 -0500 | [diff] [blame^] | 145 | |
| 146 | /* Returns a pointer to the "standard" slot space. */ |
| 147 | static inline void *nubus_slot_addr(int slot) |
| 148 | { |
| 149 | return (void *)(0xF0000000 | (slot << 24)); |
| 150 | } |
| 151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | #endif /* LINUX_NUBUS_H */ |