summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-05-31 13:54:43 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2012-05-31 13:57:25 +0200
commit64b8d1ed7c68e1805c2e35dbf5be42ff10c3e2a5 (patch)
tree452eeb92518d77ee9b849c62aa58e82ae68a5e42
parenta87a9ef37372b4380808ec2efa7c762e137668f1 (diff)
downloadrockbox-64b8d1ed7c68e1805c2e35dbf5be42ff10c3e2a5.tar.gz
rockbox-64b8d1ed7c68e1805c2e35dbf5be42ff10c3e2a5.zip
imx233: add ocotp driver
Change-Id: If4ed62ece056e81665a00af39eb1c57bb2c42b22
-rw-r--r--firmware/target/arm/imx233/ocotp-imx233.h77
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
57static 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
69static 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 */