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 | |
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>
-rw-r--r-- | arch/arm/mach-mxs/Makefile | 4 | ||||
-rw-r--r-- | arch/arm/mach-mxs/include/mach/common.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-mxs/mach-mxs.c | 76 | ||||
-rw-r--r-- | arch/arm/mach-mxs/ocotp.c | 100 |
4 files changed, 76 insertions, 105 deletions
diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile index 2568d24358ef..80db7269760e 100644 --- a/arch/arm/mach-mxs/Makefile +++ b/arch/arm/mach-mxs/Makefile | |||
@@ -1,6 +1,2 @@ | |||
1 | # Common support | ||
2 | obj-y := ocotp.o | ||
3 | |||
4 | obj-$(CONFIG_PM) += pm.o | 1 | obj-$(CONFIG_PM) += pm.o |
5 | |||
6 | obj-$(CONFIG_MACH_MXS_DT) += mach-mxs.o | 2 | obj-$(CONFIG_MACH_MXS_DT) += mach-mxs.o |
diff --git a/arch/arm/mach-mxs/include/mach/common.h b/arch/arm/mach-mxs/include/mach/common.h index 79cb572c092d..aca982c6d43f 100644 --- a/arch/arm/mach-mxs/include/mach/common.h +++ b/arch/arm/mach-mxs/include/mach/common.h | |||
@@ -11,7 +11,6 @@ | |||
11 | #ifndef __MACH_MXS_COMMON_H__ | 11 | #ifndef __MACH_MXS_COMMON_H__ |
12 | #define __MACH_MXS_COMMON_H__ | 12 | #define __MACH_MXS_COMMON_H__ |
13 | 13 | ||
14 | extern const u32 *mxs_get_ocotp(void); | ||
15 | extern int mxs_saif_clkmux_select(unsigned int clkmux); | 14 | extern int mxs_saif_clkmux_select(unsigned int clkmux); |
16 | 15 | ||
17 | extern int mx23_clocks_init(void); | 16 | extern int mx23_clocks_init(void); |
diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c index 069049200eb4..f346c432cda2 100644 --- a/arch/arm/mach-mxs/mach-mxs.c +++ b/arch/arm/mach-mxs/mach-mxs.c | |||
@@ -183,6 +183,82 @@ static void __init imx28_timer_init(void) | |||
183 | clocksource_of_init(); | 183 | clocksource_of_init(); |
184 | } | 184 | } |
185 | 185 | ||
186 | #define OCOTP_WORD_OFFSET 0x20 | ||
187 | #define OCOTP_WORD_COUNT 0x20 | ||
188 | |||
189 | #define BM_OCOTP_CTRL_BUSY (1 << 8) | ||
190 | #define BM_OCOTP_CTRL_ERROR (1 << 9) | ||
191 | #define BM_OCOTP_CTRL_RD_BANK_OPEN (1 << 12) | ||
192 | |||
193 | static DEFINE_MUTEX(ocotp_mutex); | ||
194 | static u32 ocotp_words[OCOTP_WORD_COUNT]; | ||
195 | |||
196 | static const u32 *mxs_get_ocotp(void) | ||
197 | { | ||
198 | struct device_node *np; | ||
199 | void __iomem *ocotp_base; | ||
200 | int timeout = 0x400; | ||
201 | size_t i; | ||
202 | static int once; | ||
203 | |||
204 | if (once) | ||
205 | return ocotp_words; | ||
206 | |||
207 | np = of_find_compatible_node(NULL, NULL, "fsl,ocotp"); | ||
208 | ocotp_base = of_iomap(np, 0); | ||
209 | WARN_ON(!ocotp_base); | ||
210 | |||
211 | mutex_lock(&ocotp_mutex); | ||
212 | |||
213 | /* | ||
214 | * clk_enable(hbus_clk) for ocotp can be skipped | ||
215 | * as it must be on when system is running. | ||
216 | */ | ||
217 | |||
218 | /* try to clear ERROR bit */ | ||
219 | __mxs_clrl(BM_OCOTP_CTRL_ERROR, ocotp_base); | ||
220 | |||
221 | /* check both BUSY and ERROR cleared */ | ||
222 | while ((__raw_readl(ocotp_base) & | ||
223 | (BM_OCOTP_CTRL_BUSY | BM_OCOTP_CTRL_ERROR)) && --timeout) | ||
224 | cpu_relax(); | ||
225 | |||
226 | if (unlikely(!timeout)) | ||
227 | goto error_unlock; | ||
228 | |||
229 | /* open OCOTP banks for read */ | ||
230 | __mxs_setl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base); | ||
231 | |||
232 | /* approximately wait 32 hclk cycles */ | ||
233 | udelay(1); | ||
234 | |||
235 | /* poll BUSY bit becoming cleared */ | ||
236 | timeout = 0x400; | ||
237 | while ((__raw_readl(ocotp_base) & BM_OCOTP_CTRL_BUSY) && --timeout) | ||
238 | cpu_relax(); | ||
239 | |||
240 | if (unlikely(!timeout)) | ||
241 | goto error_unlock; | ||
242 | |||
243 | for (i = 0; i < OCOTP_WORD_COUNT; i++) | ||
244 | ocotp_words[i] = __raw_readl(ocotp_base + OCOTP_WORD_OFFSET + | ||
245 | i * 0x10); | ||
246 | |||
247 | /* close banks for power saving */ | ||
248 | __mxs_clrl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base); | ||
249 | |||
250 | once = 1; | ||
251 | |||
252 | mutex_unlock(&ocotp_mutex); | ||
253 | |||
254 | return ocotp_words; | ||
255 | |||
256 | error_unlock: | ||
257 | mutex_unlock(&ocotp_mutex); | ||
258 | pr_err("%s: timeout in reading OCOTP\n", __func__); | ||
259 | return NULL; | ||
260 | } | ||
261 | |||
186 | enum mac_oui { | 262 | enum mac_oui { |
187 | OUI_FSL, | 263 | OUI_FSL, |
188 | OUI_DENX, | 264 | OUI_DENX, |
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 | } | ||