File: /usr/src/linux/include/asm-ia64/sn/xtalk/xwidget.h

1     /* $Id$
2      *
3      * This file is subject to the terms and conditions of the GNU General Public
4      * License.  See the file "COPYING" in the main directory of this archive
5      * for more details.
6      *
7      * Copyright (C) 1992 - 1997, 2000 Silicon Graphics, Inc.
8      * Copyright (C) 2000 by Colin Ngam
9      */
10     #ifndef __ASM_SN_XTALK_XWIDGET_H__
11     #define __ASM_SN_XTALK_XWIDGET_H__
12     
13     /*
14      * xwidget.h - generic crosstalk widget header file
15      */
16     
17     #include <asm/sn/xtalk/xtalk.h>
18     #if LANGUAGE_C
19     #include <asm/sn/cdl.h>
20     #endif /* LANGUAGE_C */
21     
22     #ifdef LITTLE_ENDIAN
23     #define WIDGET_ID			0x00
24     #define WIDGET_STATUS			0x08
25     #define WIDGET_ERR_UPPER_ADDR		0x10
26     #define WIDGET_ERR_LOWER_ADDR		0x18
27     #define WIDGET_CONTROL			0x20
28     #define WIDGET_REQ_TIMEOUT		0x28
29     #define WIDGET_INTDEST_UPPER_ADDR	0x30
30     #define WIDGET_INTDEST_LOWER_ADDR	0x38
31     #define WIDGET_ERR_CMD_WORD		0x40
32     #define WIDGET_LLP_CFG			0x48
33     #define WIDGET_TFLUSH			0x50
34     #else	/* !LITTLE_ENDIAN */
35     #define WIDGET_ID                       0x04
36     #define WIDGET_STATUS                   0x0c
37     #define WIDGET_ERR_UPPER_ADDR           0x14
38     #define WIDGET_ERR_LOWER_ADDR           0x1c
39     #define WIDGET_CONTROL                  0x24
40     #define WIDGET_REQ_TIMEOUT              0x2c
41     #define WIDGET_INTDEST_UPPER_ADDR       0x34
42     #define WIDGET_INTDEST_LOWER_ADDR       0x3c
43     #define WIDGET_ERR_CMD_WORD             0x44
44     #define WIDGET_LLP_CFG                  0x4c
45     #define WIDGET_TFLUSH                   0x54
46     #endif
47     
48     /* WIDGET_ID */
49     #define WIDGET_REV_NUM			0xf0000000
50     #define WIDGET_PART_NUM			0x0ffff000
51     #define WIDGET_MFG_NUM			0x00000ffe
52     #define WIDGET_REV_NUM_SHFT		28
53     #define WIDGET_PART_NUM_SHFT		12
54     #define WIDGET_MFG_NUM_SHFT		1
55     
56     #define XWIDGET_PART_NUM(widgetid) (((widgetid) & WIDGET_PART_NUM) >> WIDGET_PART_NUM_SHFT)
57     #define XWIDGET_REV_NUM(widgetid) (((widgetid) & WIDGET_REV_NUM) >> WIDGET_REV_NUM_SHFT)
58     #define XWIDGET_MFG_NUM(widgetid) (((widgetid) & WIDGET_MFG_NUM) >> WIDGET_MFG_NUM_SHFT)
59     #define XWIDGET_PART_REV_NUM(widgetid) ((XWIDGET_PART_NUM(widgetid) << 4) | \
60     					XWIDGET_REV_NUM(widgetid))
61     
62     /* WIDGET_STATUS */
63     #define WIDGET_LLP_REC_CNT		0xff000000
64     #define WIDGET_LLP_TX_CNT		0x00ff0000
65     #define WIDGET_PENDING			0x0000001f
66     
67     /* WIDGET_ERR_UPPER_ADDR */
68     #define	WIDGET_ERR_UPPER_ADDR_ONLY	0x0000ffff
69     
70     /* WIDGET_CONTROL */
71     #define WIDGET_F_BAD_PKT		0x00010000
72     #define WIDGET_LLP_XBAR_CRD		0x0000f000
73     #define	WIDGET_LLP_XBAR_CRD_SHFT	12
74     #define WIDGET_CLR_RLLP_CNT		0x00000800
75     #define WIDGET_CLR_TLLP_CNT		0x00000400
76     #define WIDGET_SYS_END			0x00000200
77     #define WIDGET_MAX_TRANS		0x000001f0
78     #define WIDGET_PCI_SPEED		0x00000030
79     #define WIDGET_PCI_SPEED_SHFT		4
80     #define WIDGET_PCI_SPEED_33MHZ 0
81     #define WIDGET_PCI_SPEED_66MHZ 1
82     #define WIDGET_WIDGET_ID		0x0000000f
83     
84     /* WIDGET_INTDEST_UPPER_ADDR */
85     #define WIDGET_INT_VECTOR		0xff000000
86     #define WIDGET_INT_VECTOR_SHFT		24
87     #define WIDGET_TARGET_ID		0x000f0000
88     #define WIDGET_TARGET_ID_SHFT		16
89     #define WIDGET_UPP_ADDR			0x0000ffff
90     
91     /* WIDGET_ERR_CMD_WORD */
92     #define WIDGET_DIDN			0xf0000000
93     #define WIDGET_SIDN			0x0f000000
94     #define WIDGET_PACTYP			0x00f00000
95     #define WIDGET_TNUM			0x000f8000
96     #define WIDGET_COHERENT			0x00004000
97     #define WIDGET_DS			0x00003000
98     #define WIDGET_GBR			0x00000800
99     #define WIDGET_VBPM			0x00000400
100     #define WIDGET_ERROR			0x00000200
101     #define WIDGET_BARRIER			0x00000100
102     
103     /* WIDGET_LLP_CFG */
104     #define WIDGET_LLP_MAXRETRY		0x03ff0000
105     #define WIDGET_LLP_MAXRETRY_SHFT	16
106     #define WIDGET_LLP_NULLTIMEOUT		0x0000fc00
107     #define WIDGET_LLP_NULLTIMEOUT_SHFT	10
108     #define WIDGET_LLP_MAXBURST		0x000003ff
109     #define WIDGET_LLP_MAXBURST_SHFT	0
110     
111     /*
112      * according to the crosstalk spec, only 32-bits access to the widget
113      * configuration registers is allowed.  some widgets may allow 64-bits
114      * access but software should not depend on it.  registers beyond the
115      * widget target flush register are widget dependent thus will not be
116      * defined here
117      */
118     #if _LANGUAGE_C
119     typedef uint32_t      widgetreg_t;
120     
121     /* widget configuration registers */
122     typedef volatile struct widget_cfg {
123     #ifdef LITTLE_ENDIAN
124     /*
125      * we access these through synergy unswizzled space, so the address
126      * gets twiddled (i.e. references to 0x4 actually go to 0x0 and vv.)
127      * That's why we put the register first and filler second.
128      */
129         widgetreg_t		    w_id;	/* 0x04 */
130         widgetreg_t		    w_pad_0;	/* 0x00 */
131         widgetreg_t		    w_status;	/* 0x0c */
132         widgetreg_t		    w_pad_1;	/* 0x08 */
133         widgetreg_t		    w_err_upper_addr;	/* 0x14 */
134         widgetreg_t		    w_pad_2;	/* 0x10 */
135         widgetreg_t		    w_err_lower_addr;	/* 0x1c */
136         widgetreg_t		    w_pad_3;	/* 0x18 */
137         widgetreg_t		    w_control;	/* 0x24 */
138         widgetreg_t		    w_pad_4;	/* 0x20 */
139         widgetreg_t		    w_req_timeout;	/* 0x2c */
140         widgetreg_t		    w_pad_5;	/* 0x28 */
141         widgetreg_t		    w_intdest_upper_addr;	/* 0x34 */
142         widgetreg_t		    w_pad_6;	/* 0x30 */
143         widgetreg_t		    w_intdest_lower_addr;	/* 0x3c */
144         widgetreg_t		    w_pad_7;	/* 0x38 */
145         widgetreg_t		    w_err_cmd_word;	/* 0x44 */
146         widgetreg_t		    w_pad_8;	/* 0x40 */
147         widgetreg_t		    w_llp_cfg;	/* 0x4c */
148         widgetreg_t		    w_pad_9;	/* 0x48 */
149         widgetreg_t		    w_tflush;	/* 0x54 */
150         widgetreg_t		    w_pad_10;	/* 0x50 */
151     #else
152         widgetreg_t		    w_pad_0;	/* 0x00 */
153         widgetreg_t		    w_id;	/* 0x04 */
154         widgetreg_t		    w_pad_1;	/* 0x08 */
155         widgetreg_t		    w_status;	/* 0x0c */
156         widgetreg_t		    w_pad_2;	/* 0x10 */
157         widgetreg_t		    w_err_upper_addr;	/* 0x14 */
158         widgetreg_t		    w_pad_3;	/* 0x18 */
159         widgetreg_t		    w_err_lower_addr;	/* 0x1c */
160         widgetreg_t		    w_pad_4;	/* 0x20 */
161         widgetreg_t		    w_control;	/* 0x24 */
162         widgetreg_t		    w_pad_5;	/* 0x28 */
163         widgetreg_t		    w_req_timeout;	/* 0x2c */
164         widgetreg_t		    w_pad_6;	/* 0x30 */
165         widgetreg_t		    w_intdest_upper_addr;	/* 0x34 */
166         widgetreg_t		    w_pad_7;	/* 0x38 */
167         widgetreg_t		    w_intdest_lower_addr;	/* 0x3c */
168         widgetreg_t		    w_pad_8;	/* 0x40 */
169         widgetreg_t		    w_err_cmd_word;	/* 0x44 */
170         widgetreg_t		    w_pad_9;	/* 0x48 */
171         widgetreg_t		    w_llp_cfg;	/* 0x4c */
172         widgetreg_t		    w_pad_10;	/* 0x50 */
173         widgetreg_t		    w_tflush;	/* 0x54 */
174     #endif /* LITTLE_ENDIAN */
175     } widget_cfg_t;
176     
177     #ifdef LITTLE_ENDIAN
178     typedef struct {
179         unsigned                other:8;
180         unsigned                bo:1;
181         unsigned                error:1;
182         unsigned                vbpm:1;
183         unsigned                gbr:1;
184         unsigned                ds:2;
185         unsigned                ct:1;
186         unsigned                tnum:5;
187         unsigned                pactyp:4;
188         unsigned                sidn:4;
189         unsigned                didn:4;
190     } w_err_cmd_word_f;
191     #else
192     typedef struct {
193         unsigned                didn:4;
194         unsigned                sidn:4;
195         unsigned                pactyp:4;
196         unsigned                tnum:5;
197         unsigned                ct:1;
198         unsigned                ds:2;
199         unsigned                gbr:1;
200         unsigned                vbpm:1;
201         unsigned                error:1;
202         unsigned                bo:1;
203         unsigned                other:8;
204     } w_err_cmd_word_f;
205     #endif
206     
207     #ifdef LITTLE_ENDIAN
208     typedef union {
209         w_err_cmd_word_f        f;
210         widgetreg_t             r;
211     } w_err_cmd_word_u;
212     #else
213     typedef union {
214         widgetreg_t             r;
215         w_err_cmd_word_f        f;
216     } w_err_cmd_word_u;
217     #endif
218     
219     /* IO widget initialization function */
220     typedef struct xwidget_info_s *xwidget_info_t;
221     
222     /*
223      * Crosstalk Widget Hardware Identification, as defined in the Crosstalk spec.
224      */
225     #ifdef LITTLE_ENDIAN
226     typedef struct xwidget_hwid_s {
227         xwidget_mfg_num_t       mfg_num;
228         xwidget_rev_num_t       rev_num;
229         xwidget_part_num_t      part_num;
230     }                      *xwidget_hwid_t;
231     #else
232     typedef struct xwidget_hwid_s {
233         xwidget_part_num_t      part_num;
234         xwidget_rev_num_t       rev_num;
235         xwidget_mfg_num_t       mfg_num;
236     }                      *xwidget_hwid_t;
237     #endif
238     
239     
240     /*
241      * Returns 1 if a driver that handles devices described by hwid1 is able
242      * to manage a device with hardwareid hwid2.  NOTE: We don't check rev
243      * numbers at all.
244      */
245     #define XWIDGET_HARDWARE_ID_MATCH(hwid1, hwid2) \
246     	(((hwid1)->part_num == (hwid2)->part_num) && \
247     	(((hwid1)->mfg_num == XWIDGET_MFG_NUM_NONE) || \
248     	((hwid2)->mfg_num == XWIDGET_MFG_NUM_NONE) || \
249     	((hwid1)->mfg_num == (hwid2)->mfg_num)))
250     
251     
252     /* Generic crosstalk widget initialization interface */
253     #if __KERNEL__
254     
255     extern int              xwidget_driver_register(xwidget_part_num_t part_num,
256     						xwidget_mfg_num_t mfg_num,
257     						char *driver_prefix,
258     						unsigned flags);
259     
260     extern void             xwidget_driver_unregister(char *driver_prefix);
261     
262     extern int              xwidget_register(struct xwidget_hwid_s *hwid,
263     					 devfs_handle_t dev,
264     					 xwidgetnum_t id,
265     					 devfs_handle_t master,
266     					 xwidgetnum_t targetid,
267     					 async_attach_t aa);
268     
269     extern int		xwidget_unregister(devfs_handle_t);
270     extern void	        xwidget_error_register(devfs_handle_t xwidget,
271     						error_handler_f * efunc,
272     						error_handler_arg_t einfo);
273     
274     extern void             xwidget_reset(devfs_handle_t xwidget);
275     extern void             xwidget_gfx_reset(devfs_handle_t xwidget);
276     extern char		*xwidget_name_get(devfs_handle_t xwidget);	
277     
278     /* Generic crosstalk widget information access interface */
279     extern xwidget_info_t   xwidget_info_chk(devfs_handle_t widget);
280     extern xwidget_info_t   xwidget_info_get(devfs_handle_t widget);
281     extern void             xwidget_info_set(devfs_handle_t widget, xwidget_info_t widget_info);
282     extern devfs_handle_t     xwidget_info_dev_get(xwidget_info_t xwidget_info);
283     extern xwidgetnum_t     xwidget_info_id_get(xwidget_info_t xwidget_info);
284     extern int              xwidget_info_type_get(xwidget_info_t xwidget_info);
285     extern int              xwidget_info_state_get(xwidget_info_t xwidget_info);
286     extern devfs_handle_t     xwidget_info_master_get(xwidget_info_t xwidget_info);
287     extern xwidgetnum_t     xwidget_info_masterid_get(xwidget_info_t xwidget_info);
288     extern xwidget_part_num_t xwidget_info_part_num_get(xwidget_info_t xwidget_info);
289     extern xwidget_rev_num_t xwidget_info_rev_num_get(xwidget_info_t xwidget_info);
290     extern xwidget_mfg_num_t xwidget_info_mfg_num_get(xwidget_info_t xwidget_info);
291     
292     
293     /*
294      * TBD: DELETE THIS ENTIRE STRUCTURE!  Equivalent is now in
295      * xtalk_private.h: xwidget_info_s
296      * This is just here for now because we still have a lot of
297      * junk referencing it.
298      * However, since nobody looks inside ...
299      */
300     typedef struct v_widget_s {
301         unsigned                v_widget_s_is_really_empty;
302     #define	v_widget_s_is_really_empty	and using this would be a syntax error.
303     } v_widget_t;
304     #endif				/* _KERNEL */
305     
306     #endif				/* _LANGUAGE_C */
307     
308     #endif				/* __ASM_SN_XTALK_XWIDGET_H__ */
309