github.com/f-secure-foundry/tamago@v0.0.0-20220307101044-d73fcdd7f11b/soc/imx6/csu/const.go (about)

     1  // i.MX Central Security Unit (CSU) driver
     2  // https://github.com/f-secure-foundry/tamago
     3  //
     4  // Copyright (c) F-Secure Corporation
     5  // https://foundry.f-secure.com
     6  //
     7  // Use of this source code is governed by the license
     8  // that can be found in the LICENSE file.
     9  
    10  package csu
    11  
    12  // p383, 11.2.3.1 CSU Peripheral Access Policy, IMX6ULLRM
    13  const (
    14  	// NonSecure User: RW, NonSecure Supervisor: RW, Secure User: RW, Secure Supervisor: RW
    15  	SEC_LEVEL_0 = 0b11111111
    16  	// NonSecure User: NA, NonSecure Supervisor: RW, Secure User: RW, Secure Supervisor: RW
    17  	SEC_LEVEL_1 = 0b10111011
    18  	// NonSecure User: RO, NonSecure Supervisor: RO, Secure User: RW, Secure Supervisor: RW
    19  	SEC_LEVEL_2 = 0b00111111
    20  	// NonSecure User: NA, NonSecure Supervisor: RO, Secure User: RW, Secure Supervisor: RW
    21  	SEC_LEVEL_3 = 0b00111011
    22  	// NonSecure User: NA, NonSecure Supervisor: NA, Secure User: RW, Secure Supervisor: RW
    23  	SEC_LEVEL_4 = 0b00110011
    24  	// NonSecure User: NA, NonSecure Supervisor: NA, Secure User: NA, Secure Supervisor: RW
    25  	SEC_LEVEL_5 = 0b00100010
    26  	// NonSecure User: NA, NonSecure Supervisor: NA, Secure User: RO, Secure Supervisor: RO
    27  	SEC_LEVEL_6 = 0b00000011
    28  	// NonSecure User: NA, NonSecure Supervisor: NA, Secure User: NA, Secure Supervisor: NA
    29  	SEC_LEVEL_7 = 0b00000000
    30  
    31  	// NonSecure Supervisor Write Access bit
    32  	CSL_NW_SUP_WR = 7
    33  	// NonSecure User Write Access bit
    34  	CSL_NW_USR_WR = 6
    35  	// Secure Supervisor Write Access bit
    36  	CSL_SW_SUP_WR = 5
    37  	// Secure User Write Access bit
    38  	CSL_SW_USR_WR = 4
    39  	// NonSecure Supervisor Read Access bit
    40  	CSL_NW_SUP_RD = 3
    41  	// NonSecure User Read Access bit
    42  	CSL_NW_USR_RD = 2
    43  	// Secure Supervisor Read Access bit
    44  	CSL_SW_SUP_RD = 1
    45  	// Secure User Read Access bit
    46  	CSL_SW_USR_RD = 0
    47  )
    48  
    49  // The following peripheral, slave identifiers can be used to set the CSL using
    50  // SetSecurityLevel on i.MX6 P/Ns. Note that peripherals presence depends on
    51  // the specific P/Ns:
    52  //   |    ID | Blocks (¹UL/ULL/ULZ, ²SX, ³SL, ⁴S/D/DL/Q)                               |
    53  //   |-------|-------------------------------------------------------------------------|
    54  //   |  0, 0 | PWM                                                                     |
    55  //   |  0, 1 | CAN1¹²⁴, DBGMON³                                                        |
    56  //   |  1, 0 | CAN2¹²⁴, QOS³                                                           |
    57  //   |  1, 1 | GPT1, EPIT                                                              |
    58  //   |  2, 0 | GPIO1, GPIO2                                                            |
    59  //   |  2, 1 | GPIO3, GPIO4                                                            |
    60  //   |  3, 0 | GPIO5, GPIO6²⁴                                                          |
    61  //   |  3, 1 | GPIO7²⁴, SNVS_LP¹                                                       |
    62  //   |  4, 0 | KPP                                                                     |
    63  //   |  4, 1 | WDOG1                                                                   |
    64  //   |  5, 0 | WDOG2                                                                   |
    65  //   |  5, 1 | CCM, SNVS_HP, SRC, GPC                                                  |
    66  //   |  6, 0 | ANATOP                                                                  |
    67  //   |  6, 1 | IOMUXC                                                                  |
    68  //   |  7, 0 | IOMUXC_GPR¹², CSI³, TCON³, DCIC⁴                                        |
    69  //   |  7, 1 | SDMA, EPDC⁴⁽ˢ⁄ᴰᴸ⁾,  LCDIF⁴⁽ˢ⁄ᴰᴸ⁾, PXP⁴⁽ˢ⁄ᴰᴸ⁾                            |
    70  //   |  8, 0 | USB                                                                     |
    71  //   |  8, 1 | ENET¹²⁴, FEC³                                                           |
    72  //   |  9, 0 | GPT2¹, MLB²⁴, MSHC³                                                     |
    73  //   |  9, 1 | USDHC1                                                                  |
    74  //   | 10, 0 | USDHC2                                                                  |
    75  //   | 10, 1 | USDHC3²³⁴, SIM1¹⁽ᵁᴸ⁾                                                    |
    76  //   | 11, 0 | USDHC4²³⁴, SIM2¹⁽ᵁᴸ⁾                                                    |
    77  //   | 11, 1 | I2C1                                                                    |
    78  //   | 12, 0 | I2C2                                                                    |
    79  //   | 12, 1 | I2C3                                                                    |
    80  //   | 13, 0 | ROMCP                                                                   |
    81  //   | 13, 1 | MMDC, DCP³, VPU⁴                                                        |
    82  //   | 14, 0 | WEIM¹², EIM³⁴                                                           |
    83  //   | 14, 1 | OCOTP_CTRL                                                              |
    84  //   | 15, 0 | SCTR¹, RDC²                                                             |
    85  //   | 15, 1 | SCTR¹, PERFMON²³⁴                                                       |
    86  //   | 16, 0 | SCTR¹, DBGMON², TZASC1³⁴                                                |
    87  //   | 16, 1 | TZASC1¹, TZASC2²⁴, RNGB³                                                |
    88  //   | 17, 0 | AUDMUX²³⁴, SAI¹²                                                        |
    89  //   | 17, 1 | QSPI¹², ASRC¹, CAAM⁴                                                    |
    90  //   | 18, 0 | SPDIF                                                                   |
    91  //   | 18, 1 | eCSPI1                                                                  |
    92  //   | 19, 0 | eCSPI2                                                                  |
    93  //   | 19, 1 | eCSPI3                                                                  |
    94  //   | 20, 0 | eCSPI4, I2C4¹²                                                          |
    95  //   | 20, 1 | ecSPI5²⁴⁽ˢ⁄ᴰᴸ⁾, IPS_1TO4_MUX¹, UART5³                                   |
    96  //   | 21, 0 | UART1                                                                   |
    97  //   | 21, 1 | UART7¹, UART2³, ESAI²⁴                                                  |
    98  //   | 22, 0 | UART8¹, ESAI¹⁽ᵁᴸᴸ⁄ᵁᴸᶻ⁾, SSI1²³⁴                                         |
    99  //   | 22, 1 | SSI2²³⁴                                                                 |
   100  //   | 23, 0 | SSI3²³⁴                                                                 |
   101  //   | 23, 1 | ASRC²⁴, UART3³                                                          |
   102  //   | 24, 0 | CANFD²                                                                  |
   103  //   | 24, 1 | RDC_SEMA4², ROMCP³⁴                                                     |
   104  //   | 25, 0 | WDOG3¹²                                                                 |
   105  //   | 25, 1 | ADC1¹²                                                                  |
   106  //   | 26, 0 | ADC2¹², OCRAM³                                                          |
   107  //   | 27, 0 | APBH_DMA⁴                                                               |
   108  //   | 27, 1 | SEMA4², HDMI⁴                                                           |
   109  //   | 28, 0 | IOMUXC_SNVS¹⁽ᵁᴸᴸ⁄ᵁᴸᶻ⁾, MU(A9)², GPU3D⁴                                  |
   110  //   | 28, 1 | IOMUXC_SNVS_GPR¹⁽ᵁᴸᴸ⁄ᵁᴸᶻ⁾, CANFD_MEM², PXP³, SATA⁴⁽ˢ⁄ᴰᴸ⁾                |
   111  //   | 29, 0 | UART8¹, MU(M4)², OPENVG³⁴⁽ˢ⁄ᴰᴸ⁾                                         |
   112  //   | 29, 1 | UART6¹², ARM³⁴                                                          |
   113  //   | 30, 0 | UART2¹², EPDC³, HSI⁴                                                    |
   114  //   | 30, 1 | UART3¹², IPU1⁴                                                          |
   115  //   | 31, 0 | UART4¹², LCDIF³, IPU2⁴⁽ˢ⁄ᴰᴸ⁾                                            |
   116  //   | 31, 1 | UART5¹², EIM³, WEIM⁴                                                    |
   117  //   | 32, 0 | LCDIF¹², CSI¹², PXP¹², EPDC¹⁽ᵁᴸᴸ⁄ᵁᴸᶻ⁾, VDEC², VADC², DCIC², GIS², PCIE⁴ |
   118  //   | 32, 1 | SPBA², GPU2D⁴                                                           |
   119  //   | 33, 0 | SPBA¹², MIPI_CORE_CSI⁴                                                  |
   120  //   | 33, 1 | TSC¹⁽ᵁᴸᴸ⁄ᵁᴸᶻ⁾, MIPI_CORE_HIS⁴                                           |
   121  //   | 34, 0 | DCP¹⁽ᵁᴸᴸ⁄ᵁᴸᶻ⁾, VDOA⁴                                                    |
   122  //   | 34, 1 | RNGB¹⁽ᵁᴸᴸ⁄ᵁᴸᶻ⁾, OCRAM², UART2⁴                                          |
   123  //   | 35, 0 | UART3⁴                                                                  |
   124  //   | 35, 1 | UART4⁴                                                                  |
   125  //   | 36, 0 | UART5⁴⁽ˢ⁄ᴰᴸ⁾, I2C4⁴                                                     |
   126  //   | 36, 1 | DTCP⁴                                                                   |
   127  //   | 38, 1 | UART4³                                                                  |
   128  //   | 39, 0 | SPBA³                                                                   |
   129  //   | 39, 1 | OCRAM¹                                                                  |
   130  //
   131  //   ¹UL/ULL/ULZ, ²SX, ³SL, ⁴S/D/DL/Q
   132  const (
   133  	CSL_MIN = 0
   134  	CSL_MAX = 39
   135  
   136  	// Second slave
   137  	CSL_S2_LOCK = 24
   138  	CSL_S2      = 16
   139  	// First slave
   140  	CSL_S1_LOCK = 8
   141  	CSL_S1      = 0
   142  )
   143  
   144  // The following master identifiers can be used to set the SA using
   145  // SetAccess on i.MX6 P/Ns. Note that peripherals presence depends on
   146  // the specific P/Ns:
   147  //   |  ID | Blocks (¹UL/ULL/ULZ, ²SX, ³SL, ⁴S/D/DL/Q)                      |
   148  //   |-----|----------------------------------------------------------------|
   149  //   |   0 | CA7¹, CP15⁴                                                    |
   150  //   |   1 | M4², DCP³, SATA⁴                                               |
   151  //   |   2 | SDMA                                                           |
   152  //   |   3 | PXP, CSI²,  LCDIF²³⁴, GPU²³⁴, EPDC³⁴, TCON³, VDOA⁴, IPU⁴, VPU⁴ |
   153  //   |   4 | USB, MLB⁴                                                      |
   154  //   |   5 | TEST, PCIE²⁴                                                   |
   155  //   |   6 | MLB², CSI³                                                     |
   156  //   |   7 | RAWNAND_DMA¹²⁴, MSHC³                                          |
   157  //   |   8 | RAWNAND_APBH_DMA¹², FEC³, ENET⁴                                |
   158  //   |   9 | ENET¹², DAP³⁴                                                  |
   159  //   |  10 | USDHC1                                                         |
   160  //   |  11 | USDHC2                                                         |
   161  //   |  12 | USDHC3²³⁴                                                      |
   162  //   |  13 | USDHC4²³⁴                                                      |
   163  //   |  14 | DCP¹^, DAP¹, HDMI⁴, HSI⁴                                       |
   164  //
   165  // ^ULL/ULZ only, undocumented and found through testing, confirmed by NXP R&D.
   166  const (
   167  	SA_MIN = 0
   168  	SA_MAX = 15
   169  )