diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2013-08-13 02:59:43 -0400 |
---|---|---|
committer | Shawn Guo <shawn.guo@linaro.org> | 2013-10-20 21:13:12 -0400 |
commit | f1c6f314727c7595e249c7da3933ba2bc6219e58 (patch) | |
tree | 8e2550fbc365162f7914cb4410118207118005c7 | |
parent | 3f75978b3742157853618c5c6dd4a5f49aa950b1 (diff) |
ARM: imx: add a common function to initialize revision from anatop
The patch creates a common function imx_init_revision_from_anatop() by
merging imx6q_init_revision() and imx_anatop_get_digprog(), so that any
SoC that encodes revision info in anatop can use it to initialize
revision.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
-rw-r--r-- | arch/arm/mach-imx/anatop.c | 27 | ||||
-rw-r--r-- | arch/arm/mach-imx/common.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-imx/mach-imx6q.c | 25 |
3 files changed, 23 insertions, 31 deletions
diff --git a/arch/arm/mach-imx/anatop.c b/arch/arm/mach-imx/anatop.c index ad3b755abb78..b2d600f14937 100644 --- a/arch/arm/mach-imx/anatop.c +++ b/arch/arm/mach-imx/anatop.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/mfd/syscon.h> | 16 | #include <linux/mfd/syscon.h> |
17 | #include <linux/regmap.h> | 17 | #include <linux/regmap.h> |
18 | #include "common.h" | 18 | #include "common.h" |
19 | #include "hardware.h" | ||
19 | 20 | ||
20 | #define REG_SET 0x4 | 21 | #define REG_SET 0x4 |
21 | #define REG_CLR 0x8 | 22 | #define REG_CLR 0x8 |
@@ -76,21 +77,35 @@ static void imx_anatop_usb_chrg_detect_disable(void) | |||
76 | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); | 77 | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); |
77 | } | 78 | } |
78 | 79 | ||
79 | u32 imx_anatop_get_digprog(void) | 80 | void __init imx_init_revision_from_anatop(void) |
80 | { | 81 | { |
81 | struct device_node *np; | 82 | struct device_node *np; |
82 | void __iomem *anatop_base; | 83 | void __iomem *anatop_base; |
83 | static u32 digprog; | 84 | unsigned int revision; |
84 | 85 | u32 digprog; | |
85 | if (digprog) | ||
86 | return digprog; | ||
87 | 86 | ||
88 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop"); | 87 | np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop"); |
89 | anatop_base = of_iomap(np, 0); | 88 | anatop_base = of_iomap(np, 0); |
90 | WARN_ON(!anatop_base); | 89 | WARN_ON(!anatop_base); |
91 | digprog = readl_relaxed(anatop_base + ANADIG_DIGPROG); | 90 | digprog = readl_relaxed(anatop_base + ANADIG_DIGPROG); |
91 | iounmap(anatop_base); | ||
92 | |||
93 | switch (digprog & 0xff) { | ||
94 | case 0: | ||
95 | revision = IMX_CHIP_REVISION_1_0; | ||
96 | break; | ||
97 | case 1: | ||
98 | revision = IMX_CHIP_REVISION_1_1; | ||
99 | break; | ||
100 | case 2: | ||
101 | revision = IMX_CHIP_REVISION_1_2; | ||
102 | break; | ||
103 | default: | ||
104 | revision = IMX_CHIP_REVISION_UNKNOWN; | ||
105 | } | ||
92 | 106 | ||
93 | return digprog; | 107 | mxc_set_cpu_type(digprog >> 16 & 0xff); |
108 | imx_set_soc_revision(revision); | ||
94 | } | 109 | } |
95 | 110 | ||
96 | void __init imx_anatop_init(void) | 111 | void __init imx_anatop_init(void) |
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h index cac12870efb3..d0191152807d 100644 --- a/arch/arm/mach-imx/common.h +++ b/arch/arm/mach-imx/common.h | |||
@@ -78,6 +78,7 @@ extern void imx_set_aips(void __iomem *); | |||
78 | extern int mxc_device_init(void); | 78 | extern int mxc_device_init(void); |
79 | void imx_set_soc_revision(unsigned int rev); | 79 | void imx_set_soc_revision(unsigned int rev); |
80 | unsigned int imx_get_soc_revision(void); | 80 | unsigned int imx_get_soc_revision(void); |
81 | void imx_init_revision_from_anatop(void); | ||
81 | 82 | ||
82 | enum mxc_cpu_pwr_mode { | 83 | enum mxc_cpu_pwr_mode { |
83 | WAIT_CLOCKED, /* wfi only */ | 84 | WAIT_CLOCKED, /* wfi only */ |
@@ -134,7 +135,6 @@ extern void imx_gpc_restore_all(void); | |||
134 | extern void imx_anatop_init(void); | 135 | extern void imx_anatop_init(void); |
135 | extern void imx_anatop_pre_suspend(void); | 136 | extern void imx_anatop_pre_suspend(void); |
136 | extern void imx_anatop_post_resume(void); | 137 | extern void imx_anatop_post_resume(void); |
137 | extern u32 imx_anatop_get_digprog(void); | ||
138 | extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode); | 138 | extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode); |
139 | extern void imx6q_set_chicken_bit(void); | 139 | extern void imx6q_set_chicken_bit(void); |
140 | 140 | ||
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index f260aad9850b..1bdd0be429b9 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c | |||
@@ -38,29 +38,6 @@ | |||
38 | #include "cpuidle.h" | 38 | #include "cpuidle.h" |
39 | #include "hardware.h" | 39 | #include "hardware.h" |
40 | 40 | ||
41 | static void __init imx6q_init_revision(void) | ||
42 | { | ||
43 | u32 rev = imx_anatop_get_digprog(); | ||
44 | u32 chip_revision; | ||
45 | |||
46 | switch (rev & 0xff) { | ||
47 | case 0: | ||
48 | chip_revision = IMX_CHIP_REVISION_1_0; | ||
49 | break; | ||
50 | case 1: | ||
51 | chip_revision = IMX_CHIP_REVISION_1_1; | ||
52 | break; | ||
53 | case 2: | ||
54 | chip_revision = IMX_CHIP_REVISION_1_2; | ||
55 | break; | ||
56 | default: | ||
57 | chip_revision = IMX_CHIP_REVISION_UNKNOWN; | ||
58 | } | ||
59 | |||
60 | mxc_set_cpu_type(rev >> 16 & 0xff); | ||
61 | imx_set_soc_revision(chip_revision); | ||
62 | } | ||
63 | |||
64 | static void imx6q_restart(enum reboot_mode mode, const char *cmd) | 41 | static void imx6q_restart(enum reboot_mode mode, const char *cmd) |
65 | { | 42 | { |
66 | struct device_node *np; | 43 | struct device_node *np; |
@@ -282,7 +259,7 @@ static void __init imx6q_map_io(void) | |||
282 | 259 | ||
283 | static void __init imx6q_init_irq(void) | 260 | static void __init imx6q_init_irq(void) |
284 | { | 261 | { |
285 | imx6q_init_revision(); | 262 | imx_init_revision_from_anatop(); |
286 | imx_init_l2cache(); | 263 | imx_init_l2cache(); |
287 | imx_src_init(); | 264 | imx_src_init(); |
288 | imx_gpc_init(); | 265 | imx_gpc_init(); |