pruss.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /**
  2. * \file pruss_drv.h
  3. *
  4. * \brief This file contains the function prototypes for the device
  5. * abstraction layer for PRUSS. It also contains some
  6. * related macro definitions and some files to be included.
  7. */
  8. /*
  9. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  10. *
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. *
  16. * Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the
  22. * distribution.
  23. *
  24. * Neither the name of Texas Instruments Incorporated nor the names of
  25. * its contributors may be used to endorse or promote products derived
  26. * from this software without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. */
  41. #ifndef __PRUSS_DRV_H__
  42. #define __PRUSS_DRV_H__
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. #define AM33XX
  47. //***********************************************************************
  48. // PRUSS Register Offsets for AM33X SOC
  49. //***********************************************************************/
  50. #ifdef AM33XX
  51. #define PRUSS_IRAM_SIZE 8192
  52. #define PRUSS_MMAP_SIZE 0x40000
  53. #define DATARAM0_PHYS_BASE 0x4a300000
  54. #define DATARAM1_PHYS_BASE 0x4a302000
  55. #define INTC_PHYS_BASE 0x4a320000
  56. #define PRU0CONTROL_PHYS_BASE 0x4a322000
  57. #define PRU0DEBUG_PHYS_BASE 0x4a322400
  58. #define PRU1CONTROL_PHYS_BASE 0x4a324000
  59. #define PRU1DEBUG_PHYS_BASE 0x4a324400
  60. #define PRU0IRAM_PHYS_BASE 0x4a334000
  61. #define PRU1IRAM_PHYS_BASE 0x4a338000
  62. #define PRUSS_SHAREDRAM_BASE 0x4a310000
  63. #define PRUSS_CFG_BASE 0x4a326000
  64. #define PRUSS_UART_BASE 0x4a328000
  65. #define PRUSS_IEP_BASE 0x4a32e000
  66. #define PRUSS_ECAP_BASE 0x4a330000
  67. #define PRUSS_MIIRT_BASE 0x4a332000
  68. #define PRUSS_MDIO_BASE 0x4a332400
  69. #else
  70. //***********************************************************************
  71. // PRUSS Register Offsets for AM18X SOC
  72. //***********************************************************************/
  73. #define PRUSS_IRAM_SIZE 4096
  74. #define PRUSS_MMAP_SIZE 0x7C00
  75. #define PRUSS_DATARAM_SIZE 512
  76. #define DATARAM0_PHYS_BASE 0x01C30000
  77. #define DATARAM1_PHYS_BASE 0x01C32000
  78. #define INTC_PHYS_BASE 0x01C34000
  79. #define PRU0CONTROL_PHYS_BASE 0x01C37000
  80. #define PRU0DEBUG_PHYS_BASE 0x01C37400
  81. #define PRU1CONTROL_PHYS_BASE 0x01C37800
  82. #define PRU1DEBUG_PHYS_BASE 0x01C37C00
  83. #define PRU0IRAM_PHYS_BASE 0x01C38000
  84. #define PRU1IRAM_PHYS_BASE 0x01C3C000
  85. #endif
  86. #define PRU_EVTOUT_0 0
  87. #define PRU_EVTOUT_1 1
  88. #define PRU_EVTOUT_2 2
  89. #define PRU_EVTOUT_3 3
  90. #define PRU_EVTOUT_4 4
  91. #define PRU_EVTOUT_5 5
  92. #define PRU_EVTOUT_6 6
  93. #define PRU_EVTOUT_7 7
  94. /*
  95. * PRUSS Interrupt Controller (PRUSS INTC) Registers Offsets
  96. */
  97. #define PRU_INTC_REVID_REG 0x000
  98. #define PRU_INTC_CR_REG 0x004
  99. #define PRU_INTC_HCR_REG 0x00C
  100. #define PRU_INTC_GER_REG 0x010
  101. #define PRU_INTC_GNLR_REG 0x01C
  102. #define PRU_INTC_SISR_REG 0x020
  103. #define PRU_INTC_SICR_REG 0x024
  104. #define PRU_INTC_EISR_REG 0x028
  105. #define PRU_INTC_EICR_REG 0x02C
  106. #define PRU_INTC_HIEISR_REG 0x034
  107. #define PRU_INTC_HIDISR_REG 0x038
  108. #define PRU_INTC_GPIR_REG 0x080
  109. #define PRU_INTC_SRSR1_REG 0x200
  110. #define PRU_INTC_SRSR2_REG 0x204
  111. #define PRU_INTC_SECR1_REG 0x280
  112. #define PRU_INTC_SECR2_REG 0x284
  113. #define PRU_INTC_ESR1_REG 0x300
  114. #define PRU_INTC_ESR2_REG 0x304
  115. #define PRU_INTC_ECR1_REG 0x380
  116. #define PRU_INTC_ECR2_REG 0x384
  117. #define PRU_INTC_CMR1_REG 0x400
  118. #define PRU_INTC_CMR2_REG 0x404
  119. #define PRU_INTC_CMR3_REG 0x408
  120. #define PRU_INTC_CMR4_REG 0x40C
  121. #define PRU_INTC_CMR5_REG 0x410
  122. #define PRU_INTC_CMR6_REG 0x414
  123. #define PRU_INTC_CMR7_REG 0x418
  124. #define PRU_INTC_CMR8_REG 0x41C
  125. #define PRU_INTC_CMR9_REG 0x420
  126. #define PRU_INTC_CMR10_REG 0x424
  127. #define PRU_INTC_CMR11_REG 0x428
  128. #define PRU_INTC_CMR12_REG 0x42C
  129. #define PRU_INTC_CMR13_REG 0x430
  130. #define PRU_INTC_CMR14_REG 0x434
  131. #define PRU_INTC_CMR15_REG 0x438
  132. #define PRU_INTC_CMR16_REG 0x43C
  133. #define PRU_INTC_HMR1_REG 0x800
  134. #define PRU_INTC_HMR2_REG 0x804
  135. #define PRU_INTC_HMR3_REG 0x808
  136. #define PRU_INTC_SIPR1_REG 0xD00
  137. #define PRU_INTC_SIPR2_REG 0xD04
  138. #define PRU_INTC_SITR1_REG 0xD80
  139. #define PRU_INTC_SITR2_REG 0xD84
  140. #define PRU_INTC_HIER_REG 0x1500
  141. //***********************************************************************
  142. // Macros representing PRU Memory locations
  143. //***********************************************************************/
  144. #define PRUSS0_PRU0_DATARAM 0
  145. #define PRUSS0_PRU1_DATARAM 1
  146. #define PRUSS0_PRU0_IRAM 2
  147. #define PRUSS0_PRU1_IRAM 3
  148. #define PRUSS0_SHARED_DATARAM 4
  149. #define PRUSS0_CFG 5
  150. #define PRUSS0_UART 6
  151. #define PRUSS0_IEP 7
  152. #define PRUSS0_ECAP 8
  153. #define PRUSS0_MII_RT 9
  154. #define PRUSS0_MDIO 10
  155. //***********************************************************************
  156. // Macros representing Interrupt-Channel-Host sizes
  157. //***********************************************************************/
  158. #define MAX_HOSTS_SUPPORTED 10
  159. #define NUM_PRU_HOSTS 10
  160. #define NUM_PRU_CHANNELS 10
  161. #define NUM_PRU_SYS_EVTS 64
  162. //***********************************************************************
  163. // Macros to support dynamic chip detecting feature
  164. //***********************************************************************/
  165. #define AM18XX_INTC_PHYS_BASE 0x01C34000
  166. #define AM18XX_DATARAM0_PHYS_BASE 0x01C30000
  167. #define AM18XX_PRUSS_INTC_REV 0x4E825900
  168. #define AM33XX_INTC_PHYS_BASE 0x4a320000
  169. #define AM33XX_DATARAM0_PHYS_BASE 0x4a300000
  170. #define AM33XX_PRUSS_INTC_REV 0x4E82A900
  171. #define PRUSS_V1 1
  172. #define PRUSS_V2 2
  173. typedef struct __sysevt_to_channel_map
  174. {
  175. short sysevt;
  176. short channel;
  177. }tsysevt_to_channel_map;
  178. typedef struct __channel_to_host_map
  179. {
  180. short channel;
  181. short host;
  182. }tchannel_to_host_map;
  183. typedef struct __pruss_intc_initdata
  184. {
  185. //Enabled SYSEVTs - Range:0..63
  186. //{-1} indicates end of list
  187. char sysevts_enabled[NUM_PRU_SYS_EVTS];
  188. //SysEvt to Channel map. SYSEVTs - Range:0..63 Channels -Range: 0..9
  189. //{-1, -1} indicates end of list
  190. tsysevt_to_channel_map sysevt_to_channel_map[NUM_PRU_SYS_EVTS];
  191. //Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9
  192. //{-1, -1} indicates end of list
  193. tchannel_to_host_map channel_to_host_map[NUM_PRU_CHANNELS];
  194. //10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7)
  195. unsigned int host_enable_bitmask;
  196. }tpruss_intc_initdata;
  197. //typedef void *(*PRUSSDRV_IRQ_HANDLER) (void *);
  198. typedef void (*PRUSSDRV_IRQ_HANDLER)(void);
  199. //**********************************************************************
  200. // API FUNCTION PROTOTYPES
  201. //**********************************************************************/
  202. int PRUSSDRVPruReset(unsigned int pruNum);
  203. int PRUSSDRVPruDisable(unsigned char pruNum);
  204. int PRUSSDRVPruEnable(unsigned char pruNum);
  205. int PRUSSDRVPruWriteMemory(unsigned int pruMem,
  206. unsigned int wordoffset,
  207. unsigned int *source_mem,
  208. unsigned int bytelength);
  209. int PRUSSDRVPruExecProgram(int prunum, char *filename);
  210. int PRUSSDRVPruSendEvent(unsigned int eventnum);
  211. int PRUSSDRVPruClearEvent(unsigned int eventnum);
  212. int PRUSSDRVPruWaitEvent(unsigned int pruEvtoutNum);
  213. int PRUSSDRVPruSendWaitCearEvent(unsigned int sendEventNum,
  214. unsigned int pruEvtoutNum,
  215. unsigned int ackEventNum);
  216. int PRUSSDRVRegisterIrqHandler(unsigned int pruEvtoutNum,
  217. unsigned char channel,
  218. PRUSSDRV_IRQ_HANDLER irqHandler);
  219. int PRUSSDRVSetPRUBuffer(unsigned int pruNum,
  220. void *buffer,
  221. unsigned int numBytes);
  222. int PRUSSDRVMapL3Mem(void **address);
  223. int PRUSSDRVMapExtMem(void **address);
  224. int PRUSSDRVMapPruMem(unsigned int pru_ram_id, void **address);
  225. void PRUSSDRVIntcSetCmr(unsigned short sysevt,
  226. unsigned short channel);
  227. void PRUSSDRVIntcSetHmr(unsigned short channel,
  228. unsigned short host);
  229. void ICSS_Init(void);
  230. // #ifdef AM33XX
  231. // //int PRUSSDRVMapPeripheralIO(unsigned int per_id, void **address);
  232. // #endif
  233. #ifdef __cplusplus
  234. }
  235. #endif
  236. #endif