xref: /rk3399_ARM-atf/include/drivers/st/bsec2_reg.h (revision e6a0994c02f8b93cc98d0f72f673209ff0e2634b)
1072d7532SNicolas Le Bayon /*
2*c7061045SPatrick Delaunay  * Copyright (c) 2022-2024, STMicroelectronics - All Rights Reserved
3072d7532SNicolas Le Bayon  *
4072d7532SNicolas Le Bayon  * SPDX-License-Identifier: BSD-3-Clause
5072d7532SNicolas Le Bayon  */
6072d7532SNicolas Le Bayon 
7072d7532SNicolas Le Bayon #ifndef BSEC2_REG_H
8072d7532SNicolas Le Bayon #define BSEC2_REG_H
9072d7532SNicolas Le Bayon 
10072d7532SNicolas Le Bayon #include <lib/utils_def.h>
11072d7532SNicolas Le Bayon 
12072d7532SNicolas Le Bayon /* IP configuration */
13072d7532SNicolas Le Bayon #define ADDR_LOWER_OTP_PERLOCK_SHIFT	0x03
14072d7532SNicolas Le Bayon #define DATA_LOWER_OTP_PERLOCK_BIT	0x03U /* 2 significants bits are used */
15072d7532SNicolas Le Bayon #define DATA_LOWER_OTP_PERLOCK_MASK	GENMASK(2, 0)
16072d7532SNicolas Le Bayon #define ADDR_UPPER_OTP_PERLOCK_SHIFT	0x04
17072d7532SNicolas Le Bayon #define DATA_UPPER_OTP_PERLOCK_BIT	0x01U /* 1 significants bits are used */
18072d7532SNicolas Le Bayon #define DATA_UPPER_OTP_PERLOCK_MASK	GENMASK(3, 0)
19072d7532SNicolas Le Bayon 
20072d7532SNicolas Le Bayon /* BSEC REGISTER OFFSET (base relative) */
21072d7532SNicolas Le Bayon #define BSEC_OTP_CONF_OFF		U(0x000)
22072d7532SNicolas Le Bayon #define BSEC_OTP_CTRL_OFF		U(0x004)
23072d7532SNicolas Le Bayon #define BSEC_OTP_WRDATA_OFF		U(0x008)
24072d7532SNicolas Le Bayon #define BSEC_OTP_STATUS_OFF		U(0x00C)
25072d7532SNicolas Le Bayon #define BSEC_OTP_LOCK_OFF		U(0x010)
26072d7532SNicolas Le Bayon #define BSEC_DEN_OFF			U(0x014)
27072d7532SNicolas Le Bayon #define BSEC_DISTURBED_OFF		U(0x01C)
28072d7532SNicolas Le Bayon #define BSEC_DISTURBED1_OFF		U(0x020)
29072d7532SNicolas Le Bayon #define BSEC_DISTURBED2_OFF		U(0x024)
30072d7532SNicolas Le Bayon #define BSEC_ERROR_OFF			U(0x034)
31072d7532SNicolas Le Bayon #define BSEC_ERROR1_OFF			U(0x038)
32072d7532SNicolas Le Bayon #define BSEC_ERROR2_OFF			U(0x03C)
33072d7532SNicolas Le Bayon #define BSEC_WRLOCK_OFF			U(0x04C) /* Safmem permanent lock */
34072d7532SNicolas Le Bayon #define BSEC_WRLOCK1_OFF		U(0x050)
35072d7532SNicolas Le Bayon #define BSEC_WRLOCK2_OFF		U(0x054)
36072d7532SNicolas Le Bayon #define BSEC_SPLOCK_OFF			U(0x064) /* Program safmem sticky lock */
37072d7532SNicolas Le Bayon #define BSEC_SPLOCK1_OFF		U(0x068)
38072d7532SNicolas Le Bayon #define BSEC_SPLOCK2_OFF		U(0x06C)
39072d7532SNicolas Le Bayon #define BSEC_SWLOCK_OFF			U(0x07C) /* Write in OTP sticky lock */
40072d7532SNicolas Le Bayon #define BSEC_SWLOCK1_OFF		U(0x080)
41072d7532SNicolas Le Bayon #define BSEC_SWLOCK2_OFF		U(0x084)
42072d7532SNicolas Le Bayon #define BSEC_SRLOCK_OFF			U(0x094) /* Shadowing sticky lock */
43072d7532SNicolas Le Bayon #define BSEC_SRLOCK1_OFF		U(0x098)
44072d7532SNicolas Le Bayon #define BSEC_SRLOCK2_OFF		U(0x09C)
45072d7532SNicolas Le Bayon #define BSEC_JTAG_IN_OFF		U(0x0AC)
46072d7532SNicolas Le Bayon #define BSEC_JTAG_OUT_OFF		U(0x0B0)
47072d7532SNicolas Le Bayon #define BSEC_SCRATCH_OFF		U(0x0B4)
48072d7532SNicolas Le Bayon #define BSEC_OTP_DATA_OFF		U(0x200)
49072d7532SNicolas Le Bayon #define BSEC_IPHW_CFG_OFF		U(0xFF0)
50072d7532SNicolas Le Bayon #define BSEC_IPVR_OFF			U(0xFF4)
51072d7532SNicolas Le Bayon #define BSEC_IP_ID_OFF			U(0xFF8)
52072d7532SNicolas Le Bayon #define BSEC_IP_MAGIC_ID_OFF		U(0xFFC)
53072d7532SNicolas Le Bayon 
54072d7532SNicolas Le Bayon #define BSEC_WRLOCK(n)			(BSEC_WRLOCK_OFF + U(0x04) * (n))
55072d7532SNicolas Le Bayon #define BSEC_SPLOCK(n)			(BSEC_SPLOCK_OFF + U(0x04) * (n))
56072d7532SNicolas Le Bayon #define BSEC_SWLOCK(n)			(BSEC_SWLOCK_OFF + U(0x04) * (n))
57072d7532SNicolas Le Bayon #define BSEC_SRLOCK(n)			(BSEC_SRLOCK_OFF + U(0x04) * (n))
58072d7532SNicolas Le Bayon 
59072d7532SNicolas Le Bayon /* BSEC_CONFIGURATION Register */
60072d7532SNicolas Le Bayon #define BSEC_CONF_POWER_UP_MASK		BIT(0)
61072d7532SNicolas Le Bayon #define BSEC_CONF_POWER_UP_SHIFT	0
62072d7532SNicolas Le Bayon #define BSEC_CONF_FRQ_MASK		GENMASK(2, 1)
63072d7532SNicolas Le Bayon #define BSEC_CONF_FRQ_SHIFT		1
64072d7532SNicolas Le Bayon #define BSEC_CONF_PRG_WIDTH_MASK	GENMASK(6, 3)
65072d7532SNicolas Le Bayon #define BSEC_CONF_PRG_WIDTH_SHIFT	3
66072d7532SNicolas Le Bayon #define BSEC_CONF_TREAD_MASK		GENMASK(8, 7)
67072d7532SNicolas Le Bayon #define BSEC_CONF_TREAD_SHIFT		7
68072d7532SNicolas Le Bayon 
69072d7532SNicolas Le Bayon /* BSEC_CONTROL Register */
70072d7532SNicolas Le Bayon #define BSEC_READ			0U
71072d7532SNicolas Le Bayon #define BSEC_WRITE			BIT(8)
72072d7532SNicolas Le Bayon #define BSEC_LOCK			BIT(9)
73072d7532SNicolas Le Bayon 
74072d7532SNicolas Le Bayon /* BSEC_OTP_LOCK register */
75072d7532SNicolas Le Bayon #define UPPER_OTP_LOCK_MASK		BIT(0)
76072d7532SNicolas Le Bayon #define UPPER_OTP_LOCK_SHIFT		0
77072d7532SNicolas Le Bayon #define DENREG_LOCK_MASK		BIT(2)
78072d7532SNicolas Le Bayon #define DENREG_LOCK_SHIFT		2
79072d7532SNicolas Le Bayon #define GPLOCK_LOCK_MASK		BIT(4)
80072d7532SNicolas Le Bayon #define GPLOCK_LOCK_SHIFT		4
81072d7532SNicolas Le Bayon 
82072d7532SNicolas Le Bayon /* BSEC_OTP_STATUS Register */
83*c7061045SPatrick Delaunay #define BSEC_OTP_STATUS_SECURE		BIT(0)
84*c7061045SPatrick Delaunay #define BSEC_OTP_STATUS_INVALID		BIT(2)
85*c7061045SPatrick Delaunay #define BSEC_OTP_STATUS_BUSY		BIT(3)
86*c7061045SPatrick Delaunay #define BSEC_OTP_STATUS_PROGFAIL	BIT(4)
87*c7061045SPatrick Delaunay #define BSEC_OTP_STATUS_PWRON		BIT(5)
88072d7532SNicolas Le Bayon 
89072d7532SNicolas Le Bayon /* BSEC_DENABLE Register */
90072d7532SNicolas Le Bayon #define BSEC_HDPEN			BIT(4)
91072d7532SNicolas Le Bayon #define BSEC_SPIDEN			BIT(5)
92072d7532SNicolas Le Bayon #define BSEC_SPINDEN			BIT(6)
93072d7532SNicolas Le Bayon #define BSEC_DBGSWGEN			BIT(10)
94072d7532SNicolas Le Bayon 
95072d7532SNicolas Le Bayon /* BSEC_FENABLE Register */
96072d7532SNicolas Le Bayon #define BSEC_FEN_ALL_MSK		GENMASK(14, 0)
97072d7532SNicolas Le Bayon 
98072d7532SNicolas Le Bayon /* BSEC_IPVR Register */
99072d7532SNicolas Le Bayon #define BSEC_IPVR_MSK			GENMASK(7, 0)
100072d7532SNicolas Le Bayon 
101072d7532SNicolas Le Bayon #endif /* BSEC2_REG_H */
102