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