xtalk.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:14k
源码类别:

嵌入式Linux

开发平台:

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 Silicon Graphics, Inc.
  8.  * Copyright (C) 2000 by Colin Ngam
  9.  */
  10. #ifndef _ASM_SN_XTALK_XTALK_H
  11. #define _ASM_SN_XTALK_XTALK_H
  12. /*
  13.  * xtalk.h -- platform-independent crosstalk interface
  14.  */
  15. /*
  16.  * User-level device driver visible types
  17.  */
  18. typedef char            xwidgetnum_t; /* xtalk widget number  (0..15) */
  19. #define XWIDGET_NONE -1
  20. typedef int xwidget_part_num_t; /* xtalk widget part number */
  21. #define XWIDGET_PART_NUM_NONE -1
  22. typedef int             xwidget_rev_num_t; /* xtalk widget revision number */
  23. #define XWIDGET_REV_NUM_NONE -1
  24. typedef int xwidget_mfg_num_t; /* xtalk widget manufacturing ID */
  25. #define XWIDGET_MFG_NUM_NONE -1
  26. typedef struct xtalk_piomap_s *xtalk_piomap_t;
  27. /* It is often convenient to fold the XIO target port
  28.  * number into the XIO address.
  29.  */
  30. #define XIO_NOWHERE (0xFFFFFFFFFFFFFFFFull)
  31. #define XIO_ADDR_BITS (0x0000FFFFFFFFFFFFull)
  32. #define XIO_PORT_BITS (0xF000000000000000ull)
  33. #define XIO_PORT_SHIFT (60)
  34. #define XIO_PACKED(x) (((x)&XIO_PORT_BITS) != 0)
  35. #define XIO_ADDR(x) ((x)&XIO_ADDR_BITS)
  36. #define XIO_PORT(x) ((xwidgetnum_t)(((x)&XIO_PORT_BITS) >> XIO_PORT_SHIFT))
  37. #define XIO_PACK(p,o) ((((uint64_t)(p))<<XIO_PORT_SHIFT) | ((o)&XIO_ADDR_BITS))
  38. /*
  39.  * Kernel/driver only definitions
  40.  */
  41. #if __KERNEL__
  42. #include <asm/types.h>
  43. #include <asm/sn/types.h>
  44. #include <asm/sn/alenlist.h>
  45. #include <asm/sn/ioerror.h>
  46. #include <asm/sn/iobus.h>
  47. #include <asm/sn/dmamap.h>
  48. struct xwidget_hwid_s;
  49. /*
  50.  *    Acceptable flag bits for xtalk service calls
  51.  *
  52.  * XTALK_FIXED: require that mappings be established
  53.  * using fixed sharable resources; address
  54.  * translation results will be permanently
  55.  * available. (PIOMAP_FIXED and DMAMAP_FIXED are
  56.  * the same numeric value and are acceptable).
  57.  * XTALK_NOSLEEP: if any part of the operation would
  58.  * sleep waiting for resoruces, return an error
  59.  * instead. (PIOMAP_NOSLEEP and DMAMAP_NOSLEEP are
  60.  * the same numeric value and are acceptable).
  61.  * XTALK_INPLACE: when operating on alenlist structures,
  62.  * reuse the source alenlist rather than creating a
  63.  * new one. (PIOMAP_INPLACE and DMAMAP_INPLACE are
  64.  * the same numeric value and are acceptable).
  65.  */
  66. #define XTALK_FIXED DMAMAP_FIXED
  67. #define XTALK_NOSLEEP DMAMAP_NOSLEEP
  68. #define XTALK_INPLACE DMAMAP_INPLACE
  69. /* PIO MANAGEMENT */
  70. typedef xtalk_piomap_t
  71. xtalk_piomap_alloc_f    (devfs_handle_t dev, /* set up mapping for this device */
  72.  device_desc_t dev_desc, /* device descriptor */
  73.  iopaddr_t xtalk_addr, /* map for this xtalk_addr range */
  74.  size_t byte_count,
  75.  size_t byte_count_max, /* maximum size of a mapping */
  76.  unsigned flags); /* defined in sys/pio.h */
  77. typedef void
  78. xtalk_piomap_free_f     (xtalk_piomap_t xtalk_piomap);
  79. typedef caddr_t
  80. xtalk_piomap_addr_f     (xtalk_piomap_t xtalk_piomap, /* mapping resources */
  81.  iopaddr_t xtalk_addr, /* map for this xtalk address */
  82.  size_t byte_count); /* map this many bytes */
  83. typedef void
  84. xtalk_piomap_done_f     (xtalk_piomap_t xtalk_piomap);
  85. typedef caddr_t
  86. xtalk_piotrans_addr_f   (devfs_handle_t dev, /* translate for this device */
  87.  device_desc_t dev_desc, /* device descriptor */
  88.  iopaddr_t xtalk_addr, /* Crosstalk address */
  89.  size_t byte_count, /* map this many bytes */
  90.  unsigned flags); /* (currently unused) */
  91. extern caddr_t
  92. xtalk_pio_addr (devfs_handle_t dev, /* translate for this device */
  93.  device_desc_t dev_desc, /* device descriptor */
  94.  iopaddr_t xtalk_addr, /* Crosstalk address */
  95.  size_t byte_count, /* map this many bytes */
  96.  xtalk_piomap_t *xtalk_piomapp, /* RETURNS mapping resources */
  97.  unsigned flags); /* (currently unused) */
  98. /* DMA MANAGEMENT */
  99. typedef struct xtalk_dmamap_s *xtalk_dmamap_t;
  100. typedef xtalk_dmamap_t
  101. xtalk_dmamap_alloc_f    (devfs_handle_t dev, /* set up mappings for this device */
  102.  device_desc_t dev_desc, /* device descriptor */
  103.  size_t byte_count_max, /* max size of a mapping */
  104.  unsigned flags); /* defined in dma.h */
  105. typedef void
  106. xtalk_dmamap_free_f     (xtalk_dmamap_t dmamap);
  107. typedef iopaddr_t
  108. xtalk_dmamap_addr_f     (xtalk_dmamap_t dmamap, /* use these mapping resources */
  109.  paddr_t paddr, /* map for this address */
  110.  size_t byte_count); /* map this many bytes */
  111. typedef alenlist_t
  112. xtalk_dmamap_list_f     (xtalk_dmamap_t dmamap, /* use these mapping resources */
  113.  alenlist_t alenlist, /* map this address/length list */
  114.  unsigned flags);
  115. typedef void
  116. xtalk_dmamap_done_f     (xtalk_dmamap_t dmamap);
  117. typedef iopaddr_t
  118. xtalk_dmatrans_addr_f   (devfs_handle_t dev, /* translate for this device */
  119.  device_desc_t dev_desc, /* device descriptor */
  120.  paddr_t paddr, /* system physical address */
  121.  size_t byte_count, /* length */
  122.  unsigned flags);
  123. typedef alenlist_t
  124. xtalk_dmatrans_list_f   (devfs_handle_t dev, /* translate for this device */
  125.  device_desc_t dev_desc, /* device descriptor */
  126.  alenlist_t palenlist, /* system address/length list */
  127.  unsigned flags);
  128. typedef void
  129. xtalk_dmamap_drain_f (xtalk_dmamap_t map); /* drain this map's channel */
  130. typedef void
  131. xtalk_dmaaddr_drain_f (devfs_handle_t vhdl, /* drain channel from this device */
  132.  paddr_t addr, /* to this physical address */
  133.  size_t bytes); /* for this many bytes */
  134. typedef void
  135. xtalk_dmalist_drain_f (devfs_handle_t vhdl, /* drain channel from this device */
  136.  alenlist_t list); /* for this set of physical blocks */
  137. /* INTERRUPT MANAGEMENT */
  138. /*
  139.  * A xtalk interrupt resource handle.  When resources are allocated
  140.  * in order to satisfy a xtalk_intr_alloc request, a xtalk_intr handle
  141.  * is returned.  xtalk_intr_connect associates a software handler with
  142.  * these system resources.
  143.  */
  144. typedef struct xtalk_intr_s *xtalk_intr_t;
  145. /*
  146.  * When a crosstalk device connects an interrupt, it passes in a function
  147.  * that knows how to set its xtalk interrupt register appropriately.  The
  148.  * low-level interrupt code may invoke this function later in order to
  149.  * migrate an interrupt transparently to the device driver(s) that use this
  150.  * interrupt.
  151.  *
  152.  * The argument passed to this function contains enough information for a
  153.  * crosstalk device to (re-)target an interrupt.  A function of this type
  154.  * must be supplied by every crosstalk driver.
  155.  */
  156. typedef int
  157. xtalk_intr_setfunc_f    (xtalk_intr_t intr_hdl); /* interrupt handle */
  158. typedef xtalk_intr_t
  159. xtalk_intr_alloc_f      (devfs_handle_t dev, /* which crosstalk device */
  160.  device_desc_t dev_desc, /* device descriptor */
  161.  devfs_handle_t owner_dev); /* owner of this intr */
  162. typedef void
  163. xtalk_intr_free_f       (xtalk_intr_t intr_hdl);
  164. typedef int
  165. xtalk_intr_connect_f    (xtalk_intr_t intr_hdl, /* xtalk intr resource handle */
  166.  intr_func_t intr_func, /* xtalk intr handler */
  167.  void *intr_arg, /* arg to intr handler */
  168.  xtalk_intr_setfunc_f *setfunc, /* func to set intr hw */
  169.  void *setfunc_arg, /* arg to setfunc. This must be */
  170. /* sufficient to determine which */
  171. /* interrupt on which board needs */
  172. /* to be set. */
  173.  void *thread); /* which intr thread to use */
  174. typedef void
  175. xtalk_intr_disconnect_f (xtalk_intr_t intr_hdl);
  176. typedef devfs_handle_t
  177. xtalk_intr_cpu_get_f    (xtalk_intr_t intr_hdl); /* xtalk intr resource handle */
  178. /* CONFIGURATION MANAGEMENT */
  179. typedef void
  180. xtalk_provider_startup_f (devfs_handle_t xtalk_provider);
  181. typedef void
  182. xtalk_provider_shutdown_f (devfs_handle_t xtalk_provider);
  183. typedef void
  184. xtalk_widgetdev_enable_f (devfs_handle_t, int);
  185. typedef void
  186. xtalk_widgetdev_shutdown_f (devfs_handle_t, int);
  187. typedef int
  188. xtalk_dma_enabled_f (devfs_handle_t);
  189. /* Error Management */
  190. typedef int
  191. xtalk_error_devenable_f (devfs_handle_t xconn_vhdl,
  192.  int devnum,
  193.  int error_code);
  194. /* Early Action Support */
  195. typedef caddr_t
  196. xtalk_early_piotrans_addr_f (xwidget_part_num_t part_num,
  197.      xwidget_mfg_num_t mfg_num,
  198.      int which,
  199.      iopaddr_t xtalk_addr,
  200.      size_t byte_count,
  201.      unsigned flags);
  202. /*
  203.  * Adapters that provide a crosstalk interface adhere to this software interface.
  204.  */
  205. typedef struct xtalk_provider_s {
  206.     /* PIO MANAGEMENT */
  207.     xtalk_piomap_alloc_f   *piomap_alloc;
  208.     xtalk_piomap_free_f    *piomap_free;
  209.     xtalk_piomap_addr_f    *piomap_addr;
  210.     xtalk_piomap_done_f    *piomap_done;
  211.     xtalk_piotrans_addr_f  *piotrans_addr;
  212.     /* DMA MANAGEMENT */
  213.     xtalk_dmamap_alloc_f   *dmamap_alloc;
  214.     xtalk_dmamap_free_f    *dmamap_free;
  215.     xtalk_dmamap_addr_f    *dmamap_addr;
  216.     xtalk_dmamap_list_f    *dmamap_list;
  217.     xtalk_dmamap_done_f    *dmamap_done;
  218.     xtalk_dmatrans_addr_f  *dmatrans_addr;
  219.     xtalk_dmatrans_list_f  *dmatrans_list;
  220.     xtalk_dmamap_drain_f   *dmamap_drain;
  221.     xtalk_dmaaddr_drain_f  *dmaaddr_drain;
  222.     xtalk_dmalist_drain_f  *dmalist_drain;
  223.     /* INTERRUPT MANAGEMENT */
  224.     xtalk_intr_alloc_f     *intr_alloc;
  225.     xtalk_intr_alloc_f     *intr_alloc_nothd;
  226.     xtalk_intr_free_f      *intr_free;
  227.     xtalk_intr_connect_f   *intr_connect;
  228.     xtalk_intr_disconnect_f *intr_disconnect;
  229.     xtalk_intr_cpu_get_f   *intr_cpu_get;
  230.     /* CONFIGURATION MANAGEMENT */
  231.     xtalk_provider_startup_f *provider_startup;
  232.     xtalk_provider_shutdown_f *provider_shutdown;
  233.     /* Error Management     */
  234.     xtalk_error_devenable_f *error_devenable;
  235. } xtalk_provider_t;
  236. /* Crosstalk devices use these standard Crosstalk provider interfaces */
  237. extern xtalk_piomap_alloc_f xtalk_piomap_alloc;
  238. extern xtalk_piomap_free_f xtalk_piomap_free;
  239. extern xtalk_piomap_addr_f xtalk_piomap_addr;
  240. extern xtalk_piomap_done_f xtalk_piomap_done;
  241. extern xtalk_piotrans_addr_f xtalk_piotrans_addr;
  242. extern xtalk_dmamap_alloc_f xtalk_dmamap_alloc;
  243. extern xtalk_dmamap_free_f xtalk_dmamap_free;
  244. extern xtalk_dmamap_addr_f xtalk_dmamap_addr;
  245. extern xtalk_dmamap_list_f xtalk_dmamap_list;
  246. extern xtalk_dmamap_done_f xtalk_dmamap_done;
  247. extern xtalk_dmatrans_addr_f xtalk_dmatrans_addr;
  248. extern xtalk_dmatrans_list_f xtalk_dmatrans_list;
  249. extern xtalk_dmamap_drain_f xtalk_dmamap_drain;
  250. extern xtalk_dmaaddr_drain_f xtalk_dmaaddr_drain;
  251. extern xtalk_dmalist_drain_f xtalk_dmalist_drain;
  252. extern xtalk_intr_alloc_f xtalk_intr_alloc;
  253. extern xtalk_intr_alloc_f xtalk_intr_alloc_nothd;
  254. extern xtalk_intr_free_f xtalk_intr_free;
  255. extern xtalk_intr_connect_f xtalk_intr_connect;
  256. extern xtalk_intr_disconnect_f xtalk_intr_disconnect;
  257. extern xtalk_intr_cpu_get_f xtalk_intr_cpu_get;
  258. extern xtalk_provider_startup_f xtalk_provider_startup;
  259. extern xtalk_provider_shutdown_f xtalk_provider_shutdown;
  260. extern xtalk_widgetdev_enable_f xtalk_widgetdev_enable;
  261. extern xtalk_widgetdev_shutdown_f xtalk_widgetdev_shutdown;
  262. extern xtalk_dma_enabled_f xtalk_dma_enabled;
  263. extern xtalk_error_devenable_f xtalk_error_devenable;
  264. extern xtalk_early_piotrans_addr_f xtalk_early_piotrans_addr;
  265. /* error management */
  266. extern int              xtalk_error_handler(devfs_handle_t,
  267.     int,
  268.     ioerror_mode_t,
  269.     ioerror_t *);
  270. /*
  271.  * Generic crosstalk interface, for use with all crosstalk providers
  272.  * and all crosstalk devices.
  273.  */
  274. typedef unchar xtalk_intr_vector_t; /* crosstalk interrupt vector (0..255) */
  275. #define XTALK_INTR_VECTOR_NONE (xtalk_intr_vector_t)0
  276. /* Generic crosstalk interrupt interfaces */
  277. extern devfs_handle_t     xtalk_intr_dev_get(xtalk_intr_t xtalk_intr);
  278. extern xwidgetnum_t     xtalk_intr_target_get(xtalk_intr_t xtalk_intr);
  279. extern xtalk_intr_vector_t xtalk_intr_vector_get(xtalk_intr_t xtalk_intr);
  280. extern iopaddr_t        xtalk_intr_addr_get(xtalk_intr_t xtalk_intr);
  281. extern devfs_handle_t     xtalk_intr_cpu_get(xtalk_intr_t xtalk_intr);
  282. extern void            *xtalk_intr_sfarg_get(xtalk_intr_t xtalk_intr);
  283. /* Generic crosstalk pio interfaces */
  284. extern devfs_handle_t     xtalk_pio_dev_get(xtalk_piomap_t xtalk_piomap);
  285. extern xwidgetnum_t     xtalk_pio_target_get(xtalk_piomap_t xtalk_piomap);
  286. extern iopaddr_t        xtalk_pio_xtalk_addr_get(xtalk_piomap_t xtalk_piomap);
  287. extern size_t           xtalk_pio_mapsz_get(xtalk_piomap_t xtalk_piomap);
  288. extern caddr_t          xtalk_pio_kvaddr_get(xtalk_piomap_t xtalk_piomap);
  289. /* Generic crosstalk dma interfaces */
  290. extern devfs_handle_t     xtalk_dma_dev_get(xtalk_dmamap_t xtalk_dmamap);
  291. extern xwidgetnum_t     xtalk_dma_target_get(xtalk_dmamap_t xtalk_dmamap);
  292. /* Register/unregister Crosstalk providers and get implementation handle */
  293. extern void             xtalk_set_early_piotrans_addr(xtalk_early_piotrans_addr_f *);
  294. extern void             xtalk_provider_register(devfs_handle_t provider, xtalk_provider_t *xtalk_fns);
  295. extern void             xtalk_provider_unregister(devfs_handle_t provider);
  296. extern xtalk_provider_t *xtalk_provider_fns_get(devfs_handle_t provider);
  297. /* Crosstalk Switch generic layer, for use by initialization code */
  298. extern void             xswitch_census(devfs_handle_t xswitchv);
  299. extern void             xswitch_init_widgets(devfs_handle_t xswitchv);
  300. /* early init interrupt management */
  301. typedef void
  302. xwidget_intr_preset_f   (void *which_widget,
  303.  int which_widget_intr,
  304.  xwidgetnum_t targ,
  305.  iopaddr_t addr,
  306.  xtalk_intr_vector_t vect);
  307. typedef void
  308. xtalk_intr_prealloc_f   (void *which_xtalk,
  309.  xtalk_intr_vector_t xtalk_vector,
  310.  xwidget_intr_preset_f *preset_func,
  311.  void *which_widget,
  312.  int which_widget_intr);
  313. typedef void
  314. xtalk_intr_preconn_f    (void *which_xtalk,
  315.  xtalk_intr_vector_t xtalk_vector,
  316.  intr_func_t intr_func,
  317.  intr_arg_t intr_arg);
  318. #define XTALK_ADDR_TO_UPPER(xtalk_addr) (((iopaddr_t)(xtalk_addr) >> 32) & 0xffff)
  319. #define XTALK_ADDR_TO_LOWER(xtalk_addr) ((iopaddr_t)(xtalk_addr) & 0xffffffff)
  320. typedef xtalk_intr_setfunc_f *xtalk_intr_setfunc_t;
  321. typedef void xtalk_iter_f(devfs_handle_t vhdl);
  322. extern void xtalk_iterate(char *prefix, xtalk_iter_f *func);
  323. extern int xtalk_device_powerup(devfs_handle_t, xwidgetnum_t);
  324. extern int xtalk_device_shutdown(devfs_handle_t, xwidgetnum_t);
  325. extern int xtalk_device_inquiry(devfs_handle_t, xwidgetnum_t);
  326. #endif /* __KERNEL__ */
  327. #endif /* _ASM_SN_XTALK_XTALK_H */