pruss.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * PRU-ICSS sub-system specific definitions
  3. *
  4. * Copyright (C) 2014-2017 Texas Instruments Incorporated - http://www.ti.com/
  5. * Suman Anna <s-anna@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * version 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. */
  16. #ifndef _PRUSS_H_
  17. #define _PRUSS_H_
  18. /* number of PRUs within a PRUSS */
  19. #ifndef PRUSS_NUM_PRUS
  20. #define PRUSS_NUM_PRUS 2
  21. #endif
  22. /* maximum number of system events */
  23. #define MAX_PRU_SYS_EVENTS 64
  24. /* maximum number of interrupt channels */
  25. #define MAX_PRU_CHANNELS 10
  26. /* minimum starting host interrupt number for MPU */
  27. #define MIN_PRU_HOST_INT 2
  28. /* maximum number of host interrupts */
  29. #define MAX_PRU_HOST_INT 10
  30. /* PRU_ICSS_INTC registers */
  31. #define PRU_INTC_REVID 0x0000
  32. #define PRU_INTC_CR 0x0004
  33. #define PRU_INTC_GER 0x0010
  34. #define PRU_INTC_GNLR 0x001C
  35. #define PRU_INTC_SISR 0x0020
  36. #define PRU_INTC_SICR 0x0024
  37. #define PRU_INTC_EISR 0x0028
  38. #define PRU_INTC_EICR 0x002C
  39. #define PRU_INTC_HIEISR 0x0034
  40. #define PRU_INTC_HIDISR 0x0038
  41. #define PRU_INTC_GPIR 0x0080
  42. #define PRU_INTC_SRSR0 0x0200
  43. #define PRU_INTC_SRSR1 0x0204
  44. #define PRU_INTC_SECR0 0x0280
  45. #define PRU_INTC_SECR1 0x0284
  46. #define PRU_INTC_ESR0 0x0300
  47. #define PRU_INTC_ESR1 0x0304
  48. #define PRU_INTC_ECR0 0x0380
  49. #define PRU_INTC_ECR1 0x0384
  50. #define PRU_INTC_CMR(x) (0x0400 + (x) * 4)
  51. #define PRU_INTC_HMR(x) (0x0800 + (x) * 4)
  52. #define PRU_INTC_HIPIR(x) (0x0900 + (x) * 4)
  53. #define PRU_INTC_SIPR0 0x0D00
  54. #define PRU_INTC_SIPR1 0x0D04
  55. #define PRU_INTC_SITR0 0x0D80
  56. #define PRU_INTC_SITR1 0x0D84
  57. #define PRU_INTC_HINLR(x) (0x1100 + (x) * 4)
  58. #define PRU_INTC_HIER 0x1500
  59. /* HIPIR register bit-fields */
  60. #define INTC_HIPIR_NONE_HINT 0x80000000
  61. /*
  62. * PRU_ICSS_CFG registers
  63. * SYSCFG, ISRP, ISP, IESP, IECP, SCRP applicable on AMxxxx devices only
  64. */
  65. #define PRUSS_CFG_REVID 0x00
  66. #define PRUSS_CFG_SYSCFG 0x04
  67. #define PRUSS_CFG_GPCFG0 0x08
  68. #define PRUSS_CFG_GPCFG1 0x0C
  69. #define PRUSS_CFG_CGR 0x10
  70. #define PRUSS_CFG_ISRP 0x14
  71. #define PRUSS_CFG_ISP 0x18
  72. #define PRUSS_CFG_IESP 0x1C
  73. #define PRUSS_CFG_IECP 0x20
  74. #define PRUSS_CFG_SCRP 0x24
  75. #define PRUSS_CFG_PMAO 0x28
  76. #define PRUSS_CFG_MII_RT 0x2C
  77. #define PRUSS_CFG_IEPCLK 0x30
  78. #define PRUSS_CFG_SPP 0x34
  79. #define PRUSS_CFG_PIN_MX 0x40
  80. /* PRUSS_GPCFG register bits */
  81. #define PRUSS_GPCFG_PRU_GPO_SH_SEL BIT(25)
  82. #define PRUSS_GPCFG_PRU_DIV1_SHIFT 20
  83. #define PRUSS_GPCFG_PRU_DIV1_MASK GENMASK(24, 20)
  84. #define PRUSS_GPCFG_PRU_DIV0_SHIFT 15
  85. #define PRUSS_GPCFG_PRU_DIV0_MASK GENMASK(15, 19)
  86. #define PRUSS_GPCFG_PRU_GPO_MODE BIT(14)
  87. #define PRUSS_GPCFG_PRU_GPO_MODE_DIRECT 0
  88. #define PRUSS_GPCFG_PRU_GPO_MODE_SERIAL BIT(14)
  89. #define PRUSS_GPCFG_PRU_GPI_SB BIT(13)
  90. #define PRUSS_GPCFG_PRU_GPI_DIV1_SHIFT 8
  91. #define PRUSS_GPCFG_PRU_GPI_DIV1_MASK GENMASK(12, 8)
  92. #define PRUSS_GPCFG_PRU_GPI_DIV0_SHIFT 3
  93. #define PRUSS_GPCFG_PRU_GPI_DIV0_MASK GENMASK(7, 3)
  94. #define PRUSS_GPCFG_PRU_GPI_CLK_MODE_POSITIVE 0
  95. #define PRUSS_GPCFG_PRU_GPI_CLK_MODE_NEGATIVE BIT(2)
  96. #define PRUSS_GPCFG_PRU_GPI_CLK_MODE BIT(2)
  97. #define PRUSS_GPCFG_PRU_GPI_MODE_MASK GENMASK(1, 0)
  98. #define PRUSS_GPCFG_PRU_GPI_MODE_SHIFT 0
  99. #define PRUSS_GPCFG_PRU_MUX_SEL_SHIFT 26
  100. #define PRUSS_GPCFG_PRU_MUX_SEL_MASK GENMASK(29, 26)
  101. /* PRUSS_MII_RT register bits */
  102. #define PRUSS_MII_RT_EVENT_EN BIT(0)
  103. /* PRUSS_SPP register bits */
  104. #define PRUSS_SPP_XFER_SHIFT_EN BIT(1)
  105. #define PRUSS_SPP_PRU1_PAD_HP_EN BIT(0)
  106. /**
  107. * enum pruss_gp_mux_sel - PRUSS GPI/O Mux modes for the
  108. * PRUSS_GPCFG0/1 registers
  109. */
  110. enum pruss_gp_mux_sel {
  111. PRUSS_GP_MUX_SEL_GP = 0,
  112. PRUSS_GP_MUX_SEL_ENDAT,
  113. PRUSS_GP_MUX_SEL_RESERVED,
  114. PRUSS_GP_MUX_SEL_SD,
  115. PRUSS_GP_MUX_SEL_MII2,
  116. PRUSS_GP_MUX_MAX,
  117. };
  118. /**
  119. * struct pruss_intc_config - INTC configuration info
  120. * @sysev_to_ch: system events to channel mapping information
  121. * @ch_to_host: interrupt channel to host interrupt information
  122. */
  123. struct pruss_intc_config {
  124. int sysev_to_ch[MAX_PRU_SYS_EVENTS];
  125. int ch_to_host[MAX_PRU_CHANNELS];
  126. };
  127. /**
  128. * struct pruss - PRUSS parent structure
  129. * @node: list node of this object
  130. * @dev: pruss device pointer
  131. * @mem_regions: data for each of the PRUSS memory regions
  132. * @mem_in_use: to indicate if memory resource is in use
  133. * @host_mask: indicate which HOST IRQs are enabled
  134. * @id: pruss instance id
  135. * @pru_running: flag to indicate if PRU is running
  136. * @pru_in_use: flag to indicate if PRU is used
  137. * @lock: mutex to serialize access to resources
  138. * @cfg_lock: mutex to serialize access to CFG
  139. */
  140. struct pruss {
  141. struct list_head node;
  142. struct device *dev;
  143. struct pruss_mem_region mem_regions[PRUSS_MEM_MAX];
  144. struct pruss_mem_region *mem_in_use[PRUSS_MEM_MAX];
  145. u32 host_mask;
  146. u32 id;
  147. bool pru_running[PRUSS_NUM_PRUS];
  148. struct rproc *pru_in_use[PRUSS_NUM_PRUS];
  149. struct mutex lock; /* PRU resource lock */
  150. struct mutex cfg_lock; /* PRUSS CFG register access lock */
  151. };
  152. int pruss_intc_configure(struct pruss *pruss,
  153. struct pruss_intc_config *intc_config);
  154. int pruss_intc_unconfigure(struct pruss *pruss,
  155. struct pruss_intc_config *intc_config);
  156. int pruss_cfg_set_gpmux(struct pruss *pruss, enum pruss_pru_id pru_id,
  157. enum pruss_gp_mux_sel mux_sel);
  158. #endif /* _PRUSS_H_ */