summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/ocotp-imx233.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx233/ocotp-imx233.h')
-rw-r--r--firmware/target/arm/imx233/ocotp-imx233.h37
1 files changed, 8 insertions, 29 deletions
diff --git a/firmware/target/arm/imx233/ocotp-imx233.h b/firmware/target/arm/imx233/ocotp-imx233.h
index 476ed1f73c..9406f98530 100644
--- a/firmware/target/arm/imx233/ocotp-imx233.h
+++ b/firmware/target/arm/imx233/ocotp-imx233.h
@@ -24,28 +24,7 @@
24#include "config.h" 24#include "config.h"
25#include "system.h" 25#include "system.h"
26 26
27#define HW_OCOTP_BASE 0x8002c000 27#include "regs/regs-ocotp.h"
28
29#define HW_OCOTP_CTRL (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x0))
30#define HW_OCOTP_CTRL__RD_BANK_OPEN (1 << 12)
31#define HW_OCOTP_CTRL__ERROR (1 << 9)
32#define HW_OCOTP_CTRL__BUSY (1 << 8)
33
34#define HW_OCOTP_CUSTx(x) (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x20 + 0x10 * (x)))
35
36#define HW_OCOTP_CRYPTOx(x) (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x60 + 0x10 * (x)))
37
38#define HW_OCOTP_HWCAPx(x) (*(volatile uint32_t *)(HW_OCOTP_BASE + 0xa0 + 0x10 * (x)))
39
40#define HW_OCOTP_SWCAP (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x100))
41
42#define HW_OCOTP_CUSTCAP (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x110))
43
44#define HW_OCOTP_OPSx(x) (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x130 + 0x10 * (x)))
45
46#define HW_OCOTP_UNx(x) (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x170 + 0x10 * (x)))
47
48#define HW_OCOTP_ROMx(x) (*(volatile uint32_t *)(HW_OCOTP_BASE + 0x1a0 + 0x10 * (x)))
49 28
50#define IMX233_NUM_OCOTP_CUST 4 29#define IMX233_NUM_OCOTP_CUST 4
51#define IMX233_NUM_OCOTP_CRYPTO 4 30#define IMX233_NUM_OCOTP_CRYPTO 4
@@ -54,19 +33,19 @@
54#define IMX233_NUM_OCOTP_UN 3 33#define IMX233_NUM_OCOTP_UN 3
55#define IMX233_NUM_OCOTP_ROM 8 34#define IMX233_NUM_OCOTP_ROM 8
56 35
57static void imx233_ocotp_open_banks(bool open) 36static inline void imx233_ocotp_open_banks(bool open)
58{ 37{
59 if(open) 38 if(open)
60 { 39 {
61 __REG_CLR(HW_OCOTP_CTRL) = HW_OCOTP_CTRL__ERROR; 40 BF_CLR(OCOTP_CTRL, ERROR);
62 __REG_SET(HW_OCOTP_CTRL) = HW_OCOTP_CTRL__RD_BANK_OPEN; 41 BF_SET(OCOTP_CTRL, RD_BANK_OPEN);
63 while(HW_OCOTP_CTRL & HW_OCOTP_CTRL__BUSY); 42 while(BF_RD(OCOTP_CTRL, BUSY));
64 } 43 }
65 else 44 else
66 __REG_CLR(HW_OCOTP_CTRL) = HW_OCOTP_CTRL__RD_BANK_OPEN; 45 BF_CLR(OCOTP_CTRL, RD_BANK_OPEN);
67} 46}
68 47
69static uint32_t imx233_ocotp_read(volatile uint32_t *reg) 48static inline uint32_t imx233_ocotp_read(volatile uint32_t *reg)
70{ 49{
71 imx233_ocotp_open_banks(true); 50 imx233_ocotp_open_banks(true);
72 uint32_t val = *reg; 51 uint32_t val = *reg;
@@ -74,4 +53,4 @@ static uint32_t imx233_ocotp_read(volatile uint32_t *reg)
74 return val; 53 return val;
75} 54}
76 55
77#endif /* OCOTP_IMX233_H */ 56#endif /* OCOTP_IMX233_H */ \ No newline at end of file