diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-03-29 01:27:55 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2013-04-01 08:42:19 -0400 |
commit | 1bff2d76ac88d59e45d2ba0d1103be210a9eca11 (patch) | |
tree | 389d44f15c36acd86cdb3ab74eb977d47166bfd4 /arch/arm/mach-mxs/ocotp.c | |
parent | 0265b6cbfe77f0064989852a2b52d6572957525c (diff) |
ARM: mxs: move mxs_get_ocotp() into mach-mxs.c
All the users of mxs_get_ocotp() are in mach-mxs.c. Move the function
into mach-mxs.c, make it a static function, and then remove ocotp.c.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'arch/arm/mach-mxs/ocotp.c')
-rw-r--r-- | arch/arm/mach-mxs/ocotp.c | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/arch/arm/mach-mxs/ocotp.c b/arch/arm/mach-mxs/ocotp.c deleted file mode 100644 index c2002eb2655e..000000000000 --- a/arch/arm/mach-mxs/ocotp.c +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/delay.h> | ||
16 | #include <linux/err.h> | ||
17 | #include <linux/mutex.h> | ||
18 | #include <linux/of.h> | ||
19 | #include <linux/of_address.h> | ||
20 | |||
21 | #include <asm/processor.h> /* for cpu_relax() */ | ||
22 | |||
23 | #include <mach/mxs.h> | ||
24 | #include <mach/common.h> | ||
25 | |||
26 | #define OCOTP_WORD_OFFSET 0x20 | ||
27 | #define OCOTP_WORD_COUNT 0x20 | ||
28 | |||
29 | #define BM_OCOTP_CTRL_BUSY (1 << 8) | ||
30 | #define BM_OCOTP_CTRL_ERROR (1 << 9) | ||
31 | #define BM_OCOTP_CTRL_RD_BANK_OPEN (1 << 12) | ||
32 | |||
33 | static DEFINE_MUTEX(ocotp_mutex); | ||
34 | static u32 ocotp_words[OCOTP_WORD_COUNT]; | ||
35 | |||
36 | const u32 *mxs_get_ocotp(void) | ||
37 | { | ||
38 | struct device_node *np; | ||
39 | void __iomem *ocotp_base; | ||
40 | int timeout = 0x400; | ||
41 | size_t i; | ||
42 | static int once = 0; | ||
43 | |||
44 | if (once) | ||
45 | return ocotp_words; | ||
46 | |||
47 | np = of_find_compatible_node(NULL, NULL, "fsl,ocotp"); | ||
48 | ocotp_base = of_iomap(np, 0); | ||
49 | WARN_ON(!ocotp_base); | ||
50 | |||
51 | mutex_lock(&ocotp_mutex); | ||
52 | |||
53 | /* | ||
54 | * clk_enable(hbus_clk) for ocotp can be skipped | ||
55 | * as it must be on when system is running. | ||
56 | */ | ||
57 | |||
58 | /* try to clear ERROR bit */ | ||
59 | __mxs_clrl(BM_OCOTP_CTRL_ERROR, ocotp_base); | ||
60 | |||
61 | /* check both BUSY and ERROR cleared */ | ||
62 | while ((__raw_readl(ocotp_base) & | ||
63 | (BM_OCOTP_CTRL_BUSY | BM_OCOTP_CTRL_ERROR)) && --timeout) | ||
64 | cpu_relax(); | ||
65 | |||
66 | if (unlikely(!timeout)) | ||
67 | goto error_unlock; | ||
68 | |||
69 | /* open OCOTP banks for read */ | ||
70 | __mxs_setl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base); | ||
71 | |||
72 | /* approximately wait 32 hclk cycles */ | ||
73 | udelay(1); | ||
74 | |||
75 | /* poll BUSY bit becoming cleared */ | ||
76 | timeout = 0x400; | ||
77 | while ((__raw_readl(ocotp_base) & BM_OCOTP_CTRL_BUSY) && --timeout) | ||
78 | cpu_relax(); | ||
79 | |||
80 | if (unlikely(!timeout)) | ||
81 | goto error_unlock; | ||
82 | |||
83 | for (i = 0; i < OCOTP_WORD_COUNT; i++) | ||
84 | ocotp_words[i] = __raw_readl(ocotp_base + OCOTP_WORD_OFFSET + | ||
85 | i * 0x10); | ||
86 | |||
87 | /* close banks for power saving */ | ||
88 | __mxs_clrl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base); | ||
89 | |||
90 | once = 1; | ||
91 | |||
92 | mutex_unlock(&ocotp_mutex); | ||
93 | |||
94 | return ocotp_words; | ||
95 | |||
96 | error_unlock: | ||
97 | mutex_unlock(&ocotp_mutex); | ||
98 | pr_err("%s: timeout in reading OCOTP\n", __func__); | ||
99 | return NULL; | ||
100 | } | ||