blob: 66691939c3c11da5d28c21f83681840ac8556da8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/include/asm-arm26/ecard.h
3 *
4 * definitions for expansion cards
5 *
6 * This is a new system as from Linux 1.2.3
7 *
8 * Changelog:
9 * 11-12-1996 RMK Further minor improvements
10 * 12-09-1997 RMK Added interrupt enable/disable for card level
11 * 18-05-2003 IM Adjusted for ARM26
12 *
13 * Reference: Acorns Risc OS 3 Programmers Reference Manuals.
14 */
15
16#ifndef __ASM_ECARD_H
17#define __ASM_ECARD_H
18
19/*
20 * Currently understood cards (but not necessarily
21 * supported):
22 * Manufacturer Product ID
23 */
24#define MANU_ACORN 0x0000
25#define PROD_ACORN_SCSI 0x0002
26#define PROD_ACORN_ETHER1 0x0003
27#define PROD_ACORN_MFM 0x000b
28
29#define MANU_CCONCEPTS 0x0009
30#define PROD_CCONCEPTS_COLOURCARD 0x0050
31
32#define MANU_ANT2 0x0011
33#define PROD_ANT_ETHER3 0x00a4
34
35#define MANU_ATOMWIDE 0x0017
36#define PROD_ATOMWIDE_3PSERIAL 0x0090
37
38#define MANU_IRLAM_INSTRUMENTS 0x001f
39#define MANU_IRLAM_INSTRUMENTS_ETHERN 0x5678
40
41#define MANU_OAK 0x0021
42#define PROD_OAK_SCSI 0x0058
43
44#define MANU_MORLEY 0x002b
45#define PROD_MORLEY_SCSI_UNCACHED 0x0067
46
47#define MANU_CUMANA 0x003a
48#define PROD_CUMANA_SCSI_2 0x003a
49#define PROD_CUMANA_SCSI_1 0x00a0
50
51#define MANU_ICS 0x003c
52#define PROD_ICS_IDE 0x00ae
53
54#define MANU_ICS2 0x003d
55#define PROD_ICS2_IDE 0x00ae
56
57#define MANU_SERPORT 0x003f
58#define PROD_SERPORT_DSPORT 0x00b9
59
60#define MANU_ARXE 0x0041
61#define PROD_ARXE_SCSI 0x00be
62
63#define MANU_I3 0x0046
64#define PROD_I3_ETHERLAN500 0x00d4
65#define PROD_I3_ETHERLAN600 0x00ec
66#define PROD_I3_ETHERLAN600A 0x011e
67
68#define MANU_ANT 0x0053
69#define PROD_ANT_ETHERM 0x00d8
70#define PROD_ANT_ETHERB 0x00e4
71
72#define MANU_ALSYSTEMS 0x005b
73#define PROD_ALSYS_SCSIATAPI 0x0107
74
75#define MANU_MCS 0x0063
76#define PROD_MCS_CONNECT32 0x0125
77
78#define MANU_EESOX 0x0064
79#define PROD_EESOX_SCSI2 0x008c
80
81#define MANU_YELLOWSTONE 0x0096
82#define PROD_YELLOWSTONE_RAPIDE32 0x0120
83
84#define MANU_SIMTEC 0x005f
85#define PROD_SIMTEC_IDE8 0x0130
86#define PROD_SIMTEC_IDE16 0x0131
87
88
89#ifdef ECARD_C
90#define CONST
91#else
92#define CONST const
93#endif
94
95#define MAX_ECARDS 4
96
97typedef enum { /* Cards address space */
98 ECARD_IOC,
99 ECARD_MEMC,
100 ECARD_EASI
101} card_type_t;
102
103typedef enum { /* Speed for ECARD_IOC space */
104 ECARD_SLOW = 0,
105 ECARD_MEDIUM = 1,
106 ECARD_FAST = 2,
107 ECARD_SYNC = 3
108} card_speed_t;
109
110struct ecard_id { /* Card ID structure */
111 unsigned short manufacturer;
112 unsigned short product;
113 void *data;
114};
115
116struct in_ecid { /* Packed card ID information */
117 unsigned short product; /* Product code */
118 unsigned short manufacturer; /* Manufacturer code */
119 unsigned char id:4; /* Simple ID */
120 unsigned char cd:1; /* Chunk dir present */
121 unsigned char is:1; /* Interrupt status pointers */
122 unsigned char w:2; /* Width */
123 unsigned char country; /* Country */
124 unsigned char irqmask; /* IRQ mask */
125 unsigned char fiqmask; /* FIQ mask */
126 unsigned long irqoff; /* IRQ offset */
127 unsigned long fiqoff; /* FIQ offset */
128};
129
130typedef struct expansion_card ecard_t;
131typedef unsigned long *loader_t;
132
133typedef struct { /* Card handler routines */
134 void (*irqenable)(ecard_t *ec, int irqnr);
135 void (*irqdisable)(ecard_t *ec, int irqnr);
136 int (*irqpending)(ecard_t *ec);
137 void (*fiqenable)(ecard_t *ec, int fiqnr);
138 void (*fiqdisable)(ecard_t *ec, int fiqnr);
139 int (*fiqpending)(ecard_t *ec);
140} expansioncard_ops_t;
141
142#define ECARD_NUM_RESOURCES (6)
143
144#define ECARD_RES_IOCSLOW (0)
145#define ECARD_RES_IOCMEDIUM (1)
146#define ECARD_RES_IOCFAST (2)
147#define ECARD_RES_IOCSYNC (3)
148#define ECARD_RES_MEMC (4)
149#define ECARD_RES_EASI (5)
150
151#define ecard_resource_start(ec,nr) ((ec)->resource[nr].start)
152#define ecard_resource_end(ec,nr) ((ec)->resource[nr].end)
153#define ecard_resource_len(ec,nr) ((ec)->resource[nr].end - \
154 (ec)->resource[nr].start + 1)
155
156/*
157 * This contains all the info needed on an expansion card
158 */
159struct expansion_card {
160 struct expansion_card *next;
161
162 struct device dev;
163 struct resource resource[ECARD_NUM_RESOURCES];
164
165 /* Public data */
166 volatile unsigned char *irqaddr; /* address of IRQ register */
167 volatile unsigned char *fiqaddr; /* address of FIQ register */
168 unsigned char irqmask; /* IRQ mask */
169 unsigned char fiqmask; /* FIQ mask */
170 unsigned char claimed; /* Card claimed? */
171
172 void *irq_data; /* Data for use for IRQ by card */
173 void *fiq_data; /* Data for use for FIQ by card */
174 const expansioncard_ops_t *ops; /* Enable/Disable Ops for card */
175
176 CONST unsigned int slot_no; /* Slot number */
177 CONST unsigned int dma; /* DMA number (for request_dma) */
178 CONST unsigned int irq; /* IRQ number (for request_irq) */
179 CONST unsigned int fiq; /* FIQ number (for request_irq) */
180 CONST card_type_t type; /* Type of card */
181 CONST struct in_ecid cid; /* Card Identification */
182
183 /* Private internal data */
184 const char *card_desc; /* Card description */
185 CONST unsigned int podaddr; /* Base Linux address for card */
186 CONST loader_t loader; /* loader program */
187 u64 dma_mask;
188};
189
190struct in_chunk_dir {
191 unsigned int start_offset;
192 union {
193 unsigned char string[256];
194 unsigned char data[1];
195 } d;
196};
197
198/*
199 * ecard_claim: claim an expansion card entry
200 * FIXME - are these atomic / called with interrupts off ?
201 */
202#define ecard_claim(ec) ((ec)->claimed = 1)
203
204/*
205 * ecard_release: release an expansion card entry
206 */
207#define ecard_release(ec) ((ec)->claimed = 0)
208
209/*
210 * Read a chunk from an expansion card
211 * cd : where to put read data
212 * ec : expansion card info struct
213 * id : id number to find
214 * num: (n+1)'th id to find.
215 */
216extern int ecard_readchunk (struct in_chunk_dir *cd, struct expansion_card *ec, int id, int num);
217
218/*
219 * Obtain the address of a card
220 */
221extern unsigned int ecard_address (struct expansion_card *ec, card_type_t card_type, card_speed_t speed);
222
223#ifdef ECARD_C
224/* Definitions internal to ecard.c - for it's use only!!
225 *
226 * External expansion card header as read from the card
227 */
228struct ex_ecid {
229 unsigned char r_irq:1;
230 unsigned char r_zero:1;
231 unsigned char r_fiq:1;
232 unsigned char r_id:4;
233 unsigned char r_a:1;
234
235 unsigned char r_cd:1;
236 unsigned char r_is:1;
237 unsigned char r_w:2;
238 unsigned char r_r1:4;
239
240 unsigned char r_r2:8;
241
242 unsigned char r_prod[2];
243
244 unsigned char r_manu[2];
245
246 unsigned char r_country;
247
248 unsigned char r_irqmask;
249 unsigned char r_irqoff[3];
250
251 unsigned char r_fiqmask;
252 unsigned char r_fiqoff[3];
253};
254
255/*
256 * Chunk directory entry as read from the card
257 */
258struct ex_chunk_dir {
259 unsigned char r_id;
260 unsigned char r_len[3];
261 unsigned long r_start;
262 union {
263 char string[256];
264 char data[1];
265 } d;
266#define c_id(x) ((x)->r_id)
267#define c_len(x) ((x)->r_len[0]|((x)->r_len[1]<<8)|((x)->r_len[2]<<16))
268#define c_start(x) ((x)->r_start)
269};
270
271#endif
272
273extern struct bus_type ecard_bus_type;
274
275#define ECARD_DEV(_d) container_of((_d), struct expansion_card, dev)
276
277struct ecard_driver {
278 int (*probe)(struct expansion_card *, const struct ecard_id *id);
279 void (*remove)(struct expansion_card *);
280 void (*shutdown)(struct expansion_card *);
281 const struct ecard_id *id_table;
282 unsigned int id;
283 struct device_driver drv;
284};
285
286#define ECARD_DRV(_d) container_of((_d), struct ecard_driver, drv)
287
288#define ecard_set_drvdata(ec,data) dev_set_drvdata(&(ec)->dev, (data))
289#define ecard_get_drvdata(ec) dev_get_drvdata(&(ec)->dev)
290
291int ecard_register_driver(struct ecard_driver *);
292void ecard_remove_driver(struct ecard_driver *);
293
294#endif