m68k: amiga - Zorro bus modalias support
[linux-2.6-block.git] / include / linux / zorro.h
CommitLineData
1da177e4
LT
1/*
2 * linux/zorro.h -- Amiga AutoConfig (Zorro) Bus Definitions
3 *
4 * Copyright (C) 1995--2003 Geert Uytterhoeven
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _LINUX_ZORRO_H
12#define _LINUX_ZORRO_H
13
1da177e4
LT
14#include <linux/device.h>
15
16
17 /*
18 * Each Zorro board has a 32-bit ID of the form
19 *
20 * mmmmmmmmmmmmmmmmppppppppeeeeeeee
21 *
22 * with
23 *
24 * mmmmmmmmmmmmmmmm 16-bit Manufacturer ID (assigned by CBM (sigh))
25 * pppppppp 8-bit Product ID (assigned by manufacturer)
26 * eeeeeeee 8-bit Extended Product ID (currently only used
27 * for some GVP boards)
28 */
29
30
31#define ZORRO_MANUF(id) ((id) >> 16)
32#define ZORRO_PROD(id) (((id) >> 8) & 0xff)
33#define ZORRO_EPC(id) ((id) & 0xff)
34
35#define ZORRO_ID(manuf, prod, epc) \
36 ((ZORRO_MANUF_##manuf << 16) | ((prod) << 8) | (epc))
37
38typedef __u32 zorro_id;
39
40
1da177e4
LT
41/* Include the ID list */
42#include <linux/zorro_ids.h>
43
44
45 /*
46 * GVP identifies most of its products through the 'extended product code'
47 * (epc). The epc has to be ANDed with the GVP_PRODMASK before the
48 * identification.
49 */
50
51#define GVP_PRODMASK (0xf8)
52#define GVP_SCSICLKMASK (0x01)
53
54enum GVP_flags {
55 GVP_IO = 0x01,
56 GVP_ACCEL = 0x02,
57 GVP_SCSI = 0x04,
58 GVP_24BITDMA = 0x08,
59 GVP_25BITDMA = 0x10,
60 GVP_NOBANK = 0x20,
61 GVP_14MHZ = 0x40,
62};
63
64
65struct Node {
66 struct Node *ln_Succ; /* Pointer to next (successor) */
67 struct Node *ln_Pred; /* Pointer to previous (predecessor) */
68 __u8 ln_Type;
69 __s8 ln_Pri; /* Priority, for sorting */
70 __s8 *ln_Name; /* ID string, null terminated */
71} __attribute__ ((packed));
72
73struct ExpansionRom {
74 /* -First 16 bytes of the expansion ROM */
75 __u8 er_Type; /* Board type, size and flags */
76 __u8 er_Product; /* Product number, assigned by manufacturer */
77 __u8 er_Flags; /* Flags */
78 __u8 er_Reserved03; /* Must be zero ($ff inverted) */
79 __u16 er_Manufacturer; /* Unique ID, ASSIGNED BY COMMODORE-AMIGA! */
80 __u32 er_SerialNumber; /* Available for use by manufacturer */
81 __u16 er_InitDiagVec; /* Offset to optional "DiagArea" structure */
82 __u8 er_Reserved0c;
83 __u8 er_Reserved0d;
84 __u8 er_Reserved0e;
85 __u8 er_Reserved0f;
86} __attribute__ ((packed));
87
88/* er_Type board type bits */
89#define ERT_TYPEMASK 0xc0
90#define ERT_ZORROII 0xc0
91#define ERT_ZORROIII 0x80
92
93/* other bits defined in er_Type */
94#define ERTB_MEMLIST 5 /* Link RAM into free memory list */
95#define ERTF_MEMLIST (1<<5)
96
97struct ConfigDev {
98 struct Node cd_Node;
99 __u8 cd_Flags; /* (read/write) */
100 __u8 cd_Pad; /* reserved */
101 struct ExpansionRom cd_Rom; /* copy of board's expansion ROM */
102 void *cd_BoardAddr; /* where in memory the board was placed */
103 __u32 cd_BoardSize; /* size of board in bytes */
104 __u16 cd_SlotAddr; /* which slot number (PRIVATE) */
105 __u16 cd_SlotSize; /* number of slots (PRIVATE) */
106 void *cd_Driver; /* pointer to node of driver */
107 struct ConfigDev *cd_NextCD; /* linked list of drivers to config */
108 __u32 cd_Unused[4]; /* for whatever the driver wants */
109} __attribute__ ((packed));
110
1da177e4
LT
111#define ZORRO_NUM_AUTO 16
112
113#ifdef __KERNEL__
114
115#include <linux/init.h>
116#include <linux/ioport.h>
bf54a2b3 117#include <linux/mod_devicetable.h>
1da177e4
LT
118
119#include <asm/zorro.h>
120
121
122 /*
123 * Zorro devices
124 */
125
126struct zorro_dev {
127 struct ExpansionRom rom;
128 zorro_id id;
129 struct zorro_driver *driver; /* which driver has allocated this device */
130 struct device dev; /* Generic device interface */
131 u16 slotaddr;
132 u16 slotsize;
133 char name[64];
134 struct resource resource;
135};
136
137#define to_zorro_dev(n) container_of(n, struct zorro_dev, dev)
138
139
140 /*
141 * Zorro bus
142 */
143
144struct zorro_bus {
145 struct list_head devices; /* list of devices on this bus */
146 unsigned int num_resources; /* number of resources */
147 struct resource resources[4]; /* address space routed to this bus */
148 struct device dev;
149 char name[10];
150};
151
152extern struct zorro_bus zorro_bus; /* single Zorro bus */
153extern struct bus_type zorro_bus_type;
154
155
1da177e4
LT
156 /*
157 * Zorro device drivers
158 */
159
160struct zorro_driver {
161 struct list_head node;
162 char *name;
163 const struct zorro_device_id *id_table; /* NULL if wants all devices */
164 int (*probe)(struct zorro_dev *z, const struct zorro_device_id *id); /* New device inserted */
165 void (*remove)(struct zorro_dev *z); /* Device removed (NULL if not a hot-plug capable driver) */
166 struct device_driver driver;
167};
168
169#define to_zorro_driver(drv) container_of(drv, struct zorro_driver, driver)
170
171
172#define zorro_for_each_dev(dev) \
173 for (dev = &zorro_autocon[0]; dev < zorro_autocon+zorro_num_autocon; dev++)
174
175
176/* New-style probing */
177extern int zorro_register_driver(struct zorro_driver *);
178extern void zorro_unregister_driver(struct zorro_driver *);
179extern const struct zorro_device_id *zorro_match_device(const struct zorro_device_id *ids, const struct zorro_dev *z);
180static inline struct zorro_driver *zorro_dev_driver(const struct zorro_dev *z)
181{
182 return z->driver;
183}
184
185
186extern unsigned int zorro_num_autocon; /* # of autoconfig devices found */
187extern struct zorro_dev zorro_autocon[ZORRO_NUM_AUTO];
188
189
190 /*
191 * Zorro Functions
192 */
193
194extern struct zorro_dev *zorro_find_device(zorro_id id,
195 struct zorro_dev *from);
196
197#define zorro_resource_start(z) ((z)->resource.start)
198#define zorro_resource_end(z) ((z)->resource.end)
199#define zorro_resource_len(z) ((z)->resource.end-(z)->resource.start+1)
200#define zorro_resource_flags(z) ((z)->resource.flags)
201
202#define zorro_request_device(z, name) \
203 request_mem_region(zorro_resource_start(z), zorro_resource_len(z), name)
204#define zorro_release_device(z) \
205 release_mem_region(zorro_resource_start(z), zorro_resource_len(z))
206
207/* Similar to the helpers above, these manipulate per-zorro_dev
208 * driver-specific data. They are really just a wrapper around
209 * the generic device structure functions of these calls.
210 */
211static inline void *zorro_get_drvdata (struct zorro_dev *z)
212{
213 return dev_get_drvdata(&z->dev);
214}
215
216static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
217{
218 dev_set_drvdata(&z->dev, data);
219}
220
221
1da177e4
LT
222 /*
223 * Bitmask indicating portions of available Zorro II RAM that are unused
224 * by the system. Every bit represents a 64K chunk, for a maximum of 8MB
225 * (128 chunks, physical 0x00200000-0x009fffff).
226 *
227 * If you want to use (= allocate) portions of this RAM, you should clear
228 * the corresponding bits.
229 */
230
231extern DECLARE_BITMAP(zorro_unused_z2ram, 128);
232
233#define Z2RAM_START (0x00200000)
234#define Z2RAM_END (0x00a00000)
235#define Z2RAM_SIZE (0x00800000)
236#define Z2RAM_CHUNKSIZE (0x00010000)
237#define Z2RAM_CHUNKMASK (0x0000ffff)
238#define Z2RAM_CHUNKSHIFT (16)
239
240
1da177e4
LT
241#endif /* __KERNEL__ */
242
243#endif /* _LINUX_ZORRO_H */