]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00269945: ARM: imx6qdl: add a common function to initialize revision from anatop
authorShawn Guo <shawn.guo@freescale.com>
Tue, 13 Aug 2013 06:59:43 +0000 (14:59 +0800)
committerJason Liu <r64343@freescale.com>
Wed, 30 Oct 2013 01:54:32 +0000 (09:54 +0800)
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@freescale.com>
arch/arm/mach-imx/anatop.c
arch/arm/mach-imx/common.h
arch/arm/mach-imx/mach-imx6q.c

index f7efabee5ccbde5871b1fda6b3466569dbdfcf85..03d3d803ab1f0e929e817ffde5f9454bd0cc9915 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 #include "common.h"
+#include "hardware.h"
 
 #define REG_SET                0x4
 #define REG_CLR                0x8
@@ -125,21 +126,35 @@ void imx_anatop_usb_chrg_detect_disable(void)
                BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B);
 }
 
-u32 imx_anatop_get_digprog(void)
+void __init imx_init_revision_from_anatop(void)
 {
        struct device_node *np;
        void __iomem *anatop_base;
-       static u32 digprog;
-
-       if (digprog)
-               return digprog;
+       unsigned int revision;
+       u32 digprog;
 
        np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop");
        anatop_base = of_iomap(np, 0);
        WARN_ON(!anatop_base);
        digprog = readl_relaxed(anatop_base + ANADIG_DIGPROG);
+       iounmap(anatop_base);
+
+       switch (digprog & 0xff) {
+       case 0:
+               revision = IMX_CHIP_REVISION_1_0;
+               break;
+       case 1:
+               revision = IMX_CHIP_REVISION_1_1;
+               break;
+       case 2:
+               revision = IMX_CHIP_REVISION_1_2;
+               break;
+       default:
+               revision = IMX_CHIP_REVISION_UNKNOWN;
+       }
 
-       return digprog;
+       mxc_set_cpu_type(digprog >> 16 & 0xff);
+       imx_set_soc_revision(revision);
 }
 
 void __init imx_anatop_init(void)
index fe91d95eec4585b4a537ee133137898aa6f02a99..550e97adc00fbd7e588bda43f83639b27ff95219 100644 (file)
@@ -81,6 +81,7 @@ extern void imx_set_aips(void __iomem *);
 extern int mxc_device_init(void);
 extern void imx_set_soc_revision(unsigned int rev);
 extern unsigned int imx_get_soc_revision(void);
+extern void imx_init_revision_from_anatop(void);
 
 enum mxc_cpu_pwr_mode {
        WAIT_CLOCKED,           /* wfi only */
@@ -143,7 +144,6 @@ extern void imx_anatop_init(void);
 extern void imx_anatop_pre_suspend(void);
 extern void imx_anatop_post_resume(void);
 extern void imx_anatop_usb_chrg_detect_disable(void);
-extern u32 imx_anatop_get_digprog(void);
 extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
 extern void imx6q_set_chicken_bit(void);
 
index fc836c6daa61aff7052e27a1b7d581873b0b23a3..4dfb488bd9fbb659ec8cbf25299b06883f7d2849 100644 (file)
 #include "cpuidle.h"
 #include "hardware.h"
 
-static void __init imx6q_init_revision(void)
-{
-       u32 rev = imx_anatop_get_digprog();
-       u32 chip_revision;
-
-       switch (rev & 0xff) {
-       case 0:
-               chip_revision = IMX_CHIP_REVISION_1_0;
-               break;
-       case 1:
-               chip_revision = IMX_CHIP_REVISION_1_1;
-               break;
-       case 2:
-               chip_revision = IMX_CHIP_REVISION_1_2;
-               break;
-       default:
-               chip_revision = IMX_CHIP_REVISION_UNKNOWN;
-       }
-
-       mxc_set_cpu_type(rev >> 16 & 0xff);
-       imx_set_soc_revision(chip_revision);
-}
-
 static void imx6q_restart(char mode, const char *cmd)
 {
        struct device_node *np;
@@ -328,7 +305,7 @@ static void __init imx6q_map_io(void)
 
 static void __init imx6q_init_irq(void)
 {
-       imx6q_init_revision();
+       imx_init_revision_from_anatop();
        imx_init_l2cache();
        imx_src_init();
        imx_gpc_init();