diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/imx233/ocotp-imx233.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/ocotp-imx233.h b/firmware/target/arm/imx233/ocotp-imx233.h new file mode 100644 index 0000000000..476ed1f73c --- /dev/null +++ b/firmware/target/arm/imx233/ocotp-imx233.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2012 by Amaury Pouly | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef OCOTP_IMX233_H | ||
22 | #define OCOTP_IMX233_H | ||
23 | |||
24 | #include "config.h" | ||
25 | #include "system.h" | ||
26 | |||
27 | #define HW_OCOTP_BASE 0x8002c000 | ||
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 | |||
50 | #define IMX233_NUM_OCOTP_CUST 4 | ||
51 | #define IMX233_NUM_OCOTP_CRYPTO 4 | ||
52 | #define IMX233_NUM_OCOTP_HWCAP 6 | ||
53 | #define IMX233_NUM_OCOTP_OPS 4 | ||
54 | #define IMX233_NUM_OCOTP_UN 3 | ||
55 | #define IMX233_NUM_OCOTP_ROM 8 | ||
56 | |||
57 | static void imx233_ocotp_open_banks(bool open) | ||
58 | { | ||
59 | if(open) | ||
60 | { | ||
61 | __REG_CLR(HW_OCOTP_CTRL) = HW_OCOTP_CTRL__ERROR; | ||
62 | __REG_SET(HW_OCOTP_CTRL) = HW_OCOTP_CTRL__RD_BANK_OPEN; | ||
63 | while(HW_OCOTP_CTRL & HW_OCOTP_CTRL__BUSY); | ||
64 | } | ||
65 | else | ||
66 | __REG_CLR(HW_OCOTP_CTRL) = HW_OCOTP_CTRL__RD_BANK_OPEN; | ||
67 | } | ||
68 | |||
69 | static uint32_t imx233_ocotp_read(volatile uint32_t *reg) | ||
70 | { | ||
71 | imx233_ocotp_open_banks(true); | ||
72 | uint32_t val = *reg; | ||
73 | imx233_ocotp_open_banks(false); | ||
74 | return val; | ||
75 | } | ||
76 | |||
77 | #endif /* OCOTP_IMX233_H */ | ||