xwidget.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:10k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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