xref: /rk3399_ARM-atf/include/drivers/st/bsec2_reg.h (revision 072d7532d2cd3d004a7cc09fd15e9543d0a3bbb7)
1*072d7532SNicolas Le Bayon /*
2*072d7532SNicolas Le Bayon  * Copyright (c) 2022, STMicroelectronics - All Rights Reserved
3*072d7532SNicolas Le Bayon  *
4*072d7532SNicolas Le Bayon  * SPDX-License-Identifier: BSD-3-Clause
5*072d7532SNicolas Le Bayon  */
6*072d7532SNicolas Le Bayon 
7*072d7532SNicolas Le Bayon #ifndef BSEC2_REG_H
8*072d7532SNicolas Le Bayon #define BSEC2_REG_H
9*072d7532SNicolas Le Bayon 
10*072d7532SNicolas Le Bayon #include <lib/utils_def.h>
11*072d7532SNicolas Le Bayon 
12*072d7532SNicolas Le Bayon /* IP configuration */
13*072d7532SNicolas Le Bayon #define ADDR_LOWER_OTP_PERLOCK_SHIFT	0x03
14*072d7532SNicolas Le Bayon #define DATA_LOWER_OTP_PERLOCK_BIT	0x03U /* 2 significants bits are used */
15*072d7532SNicolas Le Bayon #define DATA_LOWER_OTP_PERLOCK_MASK	GENMASK(2, 0)
16*072d7532SNicolas Le Bayon #define ADDR_UPPER_OTP_PERLOCK_SHIFT	0x04
17*072d7532SNicolas Le Bayon #define DATA_UPPER_OTP_PERLOCK_BIT	0x01U /* 1 significants bits are used */
18*072d7532SNicolas Le Bayon #define DATA_UPPER_OTP_PERLOCK_MASK	GENMASK(3, 0)
19*072d7532SNicolas Le Bayon 
20*072d7532SNicolas Le Bayon /* BSEC REGISTER OFFSET (base relative) */
21*072d7532SNicolas Le Bayon #define BSEC_OTP_CONF_OFF		U(0x000)
22*072d7532SNicolas Le Bayon #define BSEC_OTP_CTRL_OFF		U(0x004)
23*072d7532SNicolas Le Bayon #define BSEC_OTP_WRDATA_OFF		U(0x008)
24*072d7532SNicolas Le Bayon #define BSEC_OTP_STATUS_OFF		U(0x00C)
25*072d7532SNicolas Le Bayon #define BSEC_OTP_LOCK_OFF		U(0x010)
26*072d7532SNicolas Le Bayon #define BSEC_DEN_OFF			U(0x014)
27*072d7532SNicolas Le Bayon #define BSEC_DISTURBED_OFF		U(0x01C)
28*072d7532SNicolas Le Bayon #define BSEC_DISTURBED1_OFF		U(0x020)
29*072d7532SNicolas Le Bayon #define BSEC_DISTURBED2_OFF		U(0x024)
30*072d7532SNicolas Le Bayon #define BSEC_ERROR_OFF			U(0x034)
31*072d7532SNicolas Le Bayon #define BSEC_ERROR1_OFF			U(0x038)
32*072d7532SNicolas Le Bayon #define BSEC_ERROR2_OFF			U(0x03C)
33*072d7532SNicolas Le Bayon #define BSEC_WRLOCK_OFF			U(0x04C) /* Safmem permanent lock */
34*072d7532SNicolas Le Bayon #define BSEC_WRLOCK1_OFF		U(0x050)
35*072d7532SNicolas Le Bayon #define BSEC_WRLOCK2_OFF		U(0x054)
36*072d7532SNicolas Le Bayon #define BSEC_SPLOCK_OFF			U(0x064) /* Program safmem sticky lock */
37*072d7532SNicolas Le Bayon #define BSEC_SPLOCK1_OFF		U(0x068)
38*072d7532SNicolas Le Bayon #define BSEC_SPLOCK2_OFF		U(0x06C)
39*072d7532SNicolas Le Bayon #define BSEC_SWLOCK_OFF			U(0x07C) /* Write in OTP sticky lock */
40*072d7532SNicolas Le Bayon #define BSEC_SWLOCK1_OFF		U(0x080)
41*072d7532SNicolas Le Bayon #define BSEC_SWLOCK2_OFF		U(0x084)
42*072d7532SNicolas Le Bayon #define BSEC_SRLOCK_OFF			U(0x094) /* Shadowing sticky lock */
43*072d7532SNicolas Le Bayon #define BSEC_SRLOCK1_OFF		U(0x098)
44*072d7532SNicolas Le Bayon #define BSEC_SRLOCK2_OFF		U(0x09C)
45*072d7532SNicolas Le Bayon #define BSEC_JTAG_IN_OFF		U(0x0AC)
46*072d7532SNicolas Le Bayon #define BSEC_JTAG_OUT_OFF		U(0x0B0)
47*072d7532SNicolas Le Bayon #define BSEC_SCRATCH_OFF		U(0x0B4)
48*072d7532SNicolas Le Bayon #define BSEC_OTP_DATA_OFF		U(0x200)
49*072d7532SNicolas Le Bayon #define BSEC_IPHW_CFG_OFF		U(0xFF0)
50*072d7532SNicolas Le Bayon #define BSEC_IPVR_OFF			U(0xFF4)
51*072d7532SNicolas Le Bayon #define BSEC_IP_ID_OFF			U(0xFF8)
52*072d7532SNicolas Le Bayon #define BSEC_IP_MAGIC_ID_OFF		U(0xFFC)
53*072d7532SNicolas Le Bayon 
54*072d7532SNicolas Le Bayon #define BSEC_WRLOCK(n)			(BSEC_WRLOCK_OFF + U(0x04) * (n))
55*072d7532SNicolas Le Bayon #define BSEC_SPLOCK(n)			(BSEC_SPLOCK_OFF + U(0x04) * (n))
56*072d7532SNicolas Le Bayon #define BSEC_SWLOCK(n)			(BSEC_SWLOCK_OFF + U(0x04) * (n))
57*072d7532SNicolas Le Bayon #define BSEC_SRLOCK(n)			(BSEC_SRLOCK_OFF + U(0x04) * (n))
58*072d7532SNicolas Le Bayon 
59*072d7532SNicolas Le Bayon /* BSEC_CONFIGURATION Register */
60*072d7532SNicolas Le Bayon #define BSEC_CONF_POWER_UP_MASK		BIT(0)
61*072d7532SNicolas Le Bayon #define BSEC_CONF_POWER_UP_SHIFT	0
62*072d7532SNicolas Le Bayon #define BSEC_CONF_FRQ_MASK		GENMASK(2, 1)
63*072d7532SNicolas Le Bayon #define BSEC_CONF_FRQ_SHIFT		1
64*072d7532SNicolas Le Bayon #define BSEC_CONF_PRG_WIDTH_MASK	GENMASK(6, 3)
65*072d7532SNicolas Le Bayon #define BSEC_CONF_PRG_WIDTH_SHIFT	3
66*072d7532SNicolas Le Bayon #define BSEC_CONF_TREAD_MASK		GENMASK(8, 7)
67*072d7532SNicolas Le Bayon #define BSEC_CONF_TREAD_SHIFT		7
68*072d7532SNicolas Le Bayon 
69*072d7532SNicolas Le Bayon /* BSEC_CONTROL Register */
70*072d7532SNicolas Le Bayon #define BSEC_READ			0U
71*072d7532SNicolas Le Bayon #define BSEC_WRITE			BIT(8)
72*072d7532SNicolas Le Bayon #define BSEC_LOCK			BIT(9)
73*072d7532SNicolas Le Bayon 
74*072d7532SNicolas Le Bayon /* BSEC_OTP_LOCK register */
75*072d7532SNicolas Le Bayon #define UPPER_OTP_LOCK_MASK		BIT(0)
76*072d7532SNicolas Le Bayon #define UPPER_OTP_LOCK_SHIFT		0
77*072d7532SNicolas Le Bayon #define DENREG_LOCK_MASK		BIT(2)
78*072d7532SNicolas Le Bayon #define DENREG_LOCK_SHIFT		2
79*072d7532SNicolas Le Bayon #define GPLOCK_LOCK_MASK		BIT(4)
80*072d7532SNicolas Le Bayon #define GPLOCK_LOCK_SHIFT		4
81*072d7532SNicolas Le Bayon 
82*072d7532SNicolas Le Bayon /* BSEC_OTP_STATUS Register */
83*072d7532SNicolas Le Bayon #define BSEC_MODE_STATUS_MASK		GENMASK(2, 0)
84*072d7532SNicolas Le Bayon #define BSEC_MODE_SECURE_MASK		BIT(0)
85*072d7532SNicolas Le Bayon #define BSEC_MODE_FULLDBG_MASK		BIT(1)
86*072d7532SNicolas Le Bayon #define BSEC_MODE_INVALID_MASK		BIT(2)
87*072d7532SNicolas Le Bayon #define BSEC_MODE_BUSY_MASK		BIT(3)
88*072d7532SNicolas Le Bayon #define BSEC_MODE_PROGFAIL_MASK		BIT(4)
89*072d7532SNicolas Le Bayon #define BSEC_MODE_PWR_MASK		BIT(5)
90*072d7532SNicolas Le Bayon #define BSEC_MODE_BIST1_LOCK_MASK	BIT(6)
91*072d7532SNicolas Le Bayon #define BSEC_MODE_BIST2_LOCK_MASK	BIT(7)
92*072d7532SNicolas Le Bayon 
93*072d7532SNicolas Le Bayon /* BSEC_DENABLE Register */
94*072d7532SNicolas Le Bayon #define BSEC_HDPEN			BIT(4)
95*072d7532SNicolas Le Bayon #define BSEC_SPIDEN			BIT(5)
96*072d7532SNicolas Le Bayon #define BSEC_SPINDEN			BIT(6)
97*072d7532SNicolas Le Bayon #define BSEC_DBGSWGEN			BIT(10)
98*072d7532SNicolas Le Bayon #define BSEC_DEN_ALL_MSK		GENMASK(10, 0)
99*072d7532SNicolas Le Bayon 
100*072d7532SNicolas Le Bayon /* BSEC_FENABLE Register */
101*072d7532SNicolas Le Bayon #define BSEC_FEN_ALL_MSK		GENMASK(14, 0)
102*072d7532SNicolas Le Bayon 
103*072d7532SNicolas Le Bayon /* BSEC_IPVR Register */
104*072d7532SNicolas Le Bayon #define BSEC_IPVR_MSK			GENMASK(7, 0)
105*072d7532SNicolas Le Bayon 
106*072d7532SNicolas Le Bayon #endif /* BSEC2_REG_H */
107