drx_dap_fasi.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. Copyright (c), 2004-2005,2007-2010 Trident Microsystems, Inc.
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. * Neither the name of Trident Microsystems nor Hauppauge Computer Works
  12. nor the names of its contributors may be used to endorse or promote
  13. products derived from this software without specific prior written
  14. permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  19. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. /*******************************************************************************
  28. * FILENAME: $Id: drx_dap_fasi.h,v 1.5 2009/07/07 14:21:40 justin Exp $
  29. *
  30. * DESCRIPTION:
  31. * Part of DRX driver.
  32. * Data access protocol: Fast Access Sequential Interface (fasi)
  33. * Fast access, because of short addressing format (16 instead of 32 bits addr)
  34. * Sequential, because of I2C.
  35. *
  36. * USAGE:
  37. * Include.
  38. *
  39. * NOTES:
  40. *
  41. *
  42. *******************************************************************************/
  43. /*-------- compilation control switches --------------------------------------*/
  44. #ifndef __DRX_DAP_FASI_H__
  45. #define __DRX_DAP_FASI_H__
  46. /*-------- Required includes -------------------------------------------------*/
  47. #include "drx_driver.h"
  48. /*-------- Defines, configuring the API --------------------------------------*/
  49. /********************************************
  50. * Allowed address formats
  51. ********************************************/
  52. /*
  53. * Comments about short/long addressing format:
  54. *
  55. * The DAP FASI offers long address format (4 bytes) and short address format
  56. * (2 bytes). The DAP can operate in 3 modes:
  57. * (1) only short
  58. * (2) only long
  59. * (3) both long and short but short preferred and long only when necesarry
  60. *
  61. * These modes must be selected compile time via compile switches.
  62. * Compile switch settings for the diffrent modes:
  63. * (1) DRXDAPFASI_LONG_ADDR_ALLOWED=0, DRXDAPFASI_SHORT_ADDR_ALLOWED=1
  64. * (2) DRXDAPFASI_LONG_ADDR_ALLOWED=1, DRXDAPFASI_SHORT_ADDR_ALLOWED=0
  65. * (3) DRXDAPFASI_LONG_ADDR_ALLOWED=1, DRXDAPFASI_SHORT_ADDR_ALLOWED=1
  66. *
  67. * The default setting will be (3) both long and short.
  68. * The default setting will need no compile switches.
  69. * The default setting must be overridden if compile switches are already
  70. * defined.
  71. *
  72. */
  73. /* set default */
  74. #if !defined(DRXDAPFASI_LONG_ADDR_ALLOWED)
  75. #define DRXDAPFASI_LONG_ADDR_ALLOWED 1
  76. #endif
  77. /* set default */
  78. #if !defined(DRXDAPFASI_SHORT_ADDR_ALLOWED)
  79. #define DRXDAPFASI_SHORT_ADDR_ALLOWED 1
  80. #endif
  81. /* check */
  82. #if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && \
  83. (DRXDAPFASI_SHORT_ADDR_ALLOWED == 0))
  84. #error At least one of short- or long-addressing format must be allowed.
  85. *; /* illegal statement to force compiler error */
  86. #endif
  87. /********************************************
  88. * Single/master multi master setting
  89. ********************************************/
  90. /*
  91. * Comments about SINGLE MASTER/MULTI MASTER modes:
  92. *
  93. * Consider the two sides:1) the master and 2)the slave.
  94. *
  95. * Master:
  96. * Single/multimaster operation set via DRXDAP_SINGLE_MASTER compile switch
  97. * + single master mode means no use of repeated starts
  98. * + multi master mode means use of repeated starts
  99. * Default is single master.
  100. * Default can be overriden by setting the compile switch DRXDAP_SINGLE_MASTER.
  101. *
  102. * Slave:
  103. * Single/multi master selected via the flags in the FASI protocol.
  104. * + single master means remember memory address between i2c packets
  105. * + multimaster means flush memory address between i2c packets
  106. * Default is single master, DAP FASI changes multi-master setting silently
  107. * into single master setting. This cannot be overrriden.
  108. *
  109. */
  110. /* set default */
  111. #ifndef DRXDAP_SINGLE_MASTER
  112. #define DRXDAP_SINGLE_MASTER 0
  113. #endif
  114. /********************************************
  115. * Chunk/mode checking
  116. ********************************************/
  117. /*
  118. * Comments about DRXDAP_MAX_WCHUNKSIZE in single or multi master mode and
  119. * in combination with short and long addressing format. All text below
  120. * assumes long addressing format. The table also includes information
  121. * for short ADDRessing format.
  122. *
  123. * In single master mode, data can be written by sending the register address
  124. * first, then two or four bytes of data in the next packet.
  125. * Because the device address plus a register address equals five bytes,
  126. * the mimimum chunk size must be five.
  127. * If ten-bit I2C device addresses are used, the minimum chunk size must be six,
  128. * because the I2C device address will then occupy two bytes when writing.
  129. *
  130. * Data in single master mode is transferred as follows:
  131. * <S> <devW> a0 a1 a2 a3 <P>
  132. * <S> <devW> d0 d1 [d2 d3] <P>
  133. * ..
  134. * or
  135. * ..
  136. * <S> <devW> a0 a1 a2 a3 <P>
  137. * <S> <devR> --- <P>
  138. *
  139. * In multi-master mode, the data must immediately follow the address (an I2C
  140. * stop resets the internal address), and hence the minimum chunk size is
  141. * 1 <I2C address> + 4 (register address) + 2 (data to send) = 7 bytes (8 if
  142. * 10-bit I2C device addresses are used).
  143. *
  144. * The 7-bit or 10-bit i2c address parameters is a runtime parameter.
  145. * The other parameters can be limited via compile time switches.
  146. *
  147. *-------------------------------------------------------------------------------
  148. *
  149. * Minimum chunk size table (in bytes):
  150. *
  151. * +----------------+----------------+
  152. * | 7b i2c addr | 10b i2c addr |
  153. * +----------------+----------------+
  154. * | single | multi | single | multi |
  155. * ------+--------+-------+--------+-------+
  156. * short | 3 | 5 | 4 | 6 |
  157. * long | 5 | 7 | 6 | 8 |
  158. * ------+--------+-------+--------+-------+
  159. *
  160. */
  161. /* set default */
  162. #if !defined(DRXDAP_MAX_WCHUNKSIZE)
  163. #define DRXDAP_MAX_WCHUNKSIZE 254
  164. #endif
  165. /* check */
  166. #if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1))
  167. #if DRXDAP_SINGLE_MASTER
  168. #define DRXDAP_MAX_WCHUNKSIZE_MIN 3
  169. #else
  170. #define DRXDAP_MAX_WCHUNKSIZE_MIN 5
  171. #endif
  172. #else
  173. #if DRXDAP_SINGLE_MASTER
  174. #define DRXDAP_MAX_WCHUNKSIZE_MIN 5
  175. #else
  176. #define DRXDAP_MAX_WCHUNKSIZE_MIN 7
  177. #endif
  178. #endif
  179. #if DRXDAP_MAX_WCHUNKSIZE < DRXDAP_MAX_WCHUNKSIZE_MIN
  180. #if ((DRXDAPFASI_LONG_ADDR_ALLOWED == 0) && (DRXDAPFASI_SHORT_ADDR_ALLOWED == 1))
  181. #if DRXDAP_SINGLE_MASTER
  182. #error DRXDAP_MAX_WCHUNKSIZE must be at least 3 in single master mode
  183. *; /* illegal statement to force compiler error */
  184. #else
  185. #error DRXDAP_MAX_WCHUNKSIZE must be at least 5 in multi master mode
  186. *; /* illegal statement to force compiler error */
  187. #endif
  188. #else
  189. #if DRXDAP_SINGLE_MASTER
  190. #error DRXDAP_MAX_WCHUNKSIZE must be at least 5 in single master mode
  191. *; /* illegal statement to force compiler error */
  192. #else
  193. #error DRXDAP_MAX_WCHUNKSIZE must be at least 7 in multi master mode
  194. *; /* illegal statement to force compiler error */
  195. #endif
  196. #endif
  197. #endif
  198. /* set default */
  199. #if !defined(DRXDAP_MAX_RCHUNKSIZE)
  200. #define DRXDAP_MAX_RCHUNKSIZE 254
  201. #endif
  202. /* check */
  203. #if DRXDAP_MAX_RCHUNKSIZE < 2
  204. #error DRXDAP_MAX_RCHUNKSIZE must be at least 2
  205. *; /* illegal statement to force compiler error */
  206. #endif
  207. /* check */
  208. #if DRXDAP_MAX_RCHUNKSIZE & 1
  209. #error DRXDAP_MAX_RCHUNKSIZE must be even
  210. *; /* illegal statement to force compiler error */
  211. #endif
  212. /*-------- Public API functions ----------------------------------------------*/
  213. extern struct drx_access_func drx_dap_fasi_funct_g;
  214. #define DRXDAP_FASI_RMW 0x10000000
  215. #define DRXDAP_FASI_BROADCAST 0x20000000
  216. #define DRXDAP_FASI_CLEARCRC 0x80000000
  217. #define DRXDAP_FASI_SINGLE_MASTER 0xC0000000
  218. #define DRXDAP_FASI_MULTI_MASTER 0x40000000
  219. #define DRXDAP_FASI_SMM_SWITCH 0x40000000 /* single/multi master switch */
  220. #define DRXDAP_FASI_MODEFLAGS 0xC0000000
  221. #define DRXDAP_FASI_FLAGS 0xF0000000
  222. #define DRXDAP_FASI_ADDR2BLOCK(addr) (((addr)>>22)&0x3F)
  223. #define DRXDAP_FASI_ADDR2BANK(addr) (((addr)>>16)&0x3F)
  224. #define DRXDAP_FASI_ADDR2OFFSET(addr) ((addr)&0x7FFF)
  225. #define DRXDAP_FASI_SHORT_FORMAT(addr) (((addr) & 0xFC30FF80) == 0)
  226. #define DRXDAP_FASI_LONG_FORMAT(addr) (((addr) & 0xFC30FF80) != 0)
  227. #define DRXDAP_FASI_OFFSET_TOO_LARGE(addr) (((addr) & 0x00008000) != 0)
  228. #endif /* __DRX_DAP_FASI_H__ */