aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2013-08-13 04:59:28 -0400
committerShawn Guo <shawn.guo@linaro.org>2013-10-20 21:14:54 -0400
commita28875462bd493fc1bb041c21f811b4a0577a497 (patch)
treec35823e0705c4e173f38aad2b4e5764e18692f94 /arch
parentd8ce823fb34e6b50b1d9cb804c1067546eab9cee (diff)
ARM: imx6: report soc info via soc device
The patch enables soc bus infrastructure and adds a function imx_soc_device_init() to report soc info via soc device interface for imx6qdl and imx6sl. With the support, user space can get soc related info by looking at sysfs like below. $ cat /sys/devices/soc0/machine Freescale i.MX6 Quad SABRE Smart Device Board $ cat /sys/devices/soc0/family Freescale i.MX $ cat /sys/devices/soc0/soc_id i.MX6Q $ cat /sys/devices/soc0/revision 1.2 Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-imx/Kconfig1
-rw-r--r--arch/arm/mach-imx/common.h1
-rw-r--r--arch/arm/mach-imx/cpu.c81
-rw-r--r--arch/arm/mach-imx/mach-imx6q.c8
-rw-r--r--arch/arm/mach-imx/mach-imx6sl.c8
-rw-r--r--arch/arm/mach-imx/mxc.h1
6 files changed, 98 insertions, 2 deletions
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 9f67338ac2ee..e0179158aec6 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -11,6 +11,7 @@ config ARCH_MXC
11 select GENERIC_IRQ_CHIP 11 select GENERIC_IRQ_CHIP
12 select MIGHT_HAVE_CACHE_L2X0 if ARCH_MULTI_V6_V7 12 select MIGHT_HAVE_CACHE_L2X0 if ARCH_MULTI_V6_V7
13 select MULTI_IRQ_HANDLER 13 select MULTI_IRQ_HANDLER
14 select SOC_BUS
14 select SPARSE_IRQ 15 select SPARSE_IRQ
15 select USE_OF 16 select USE_OF
16 help 17 help
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index d0191152807d..f9d01142a4f6 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -79,6 +79,7 @@ extern int mxc_device_init(void);
79void imx_set_soc_revision(unsigned int rev); 79void imx_set_soc_revision(unsigned int rev);
80unsigned int imx_get_soc_revision(void); 80unsigned int imx_get_soc_revision(void);
81void imx_init_revision_from_anatop(void); 81void imx_init_revision_from_anatop(void);
82struct device *imx_soc_device_init(void);
82 83
83enum mxc_cpu_pwr_mode { 84enum mxc_cpu_pwr_mode {
84 WAIT_CLOCKED, /* wfi only */ 85 WAIT_CLOCKED, /* wfi only */
diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c
index 51f6c51ca878..fae2c9a78744 100644
--- a/arch/arm/mach-imx/cpu.c
+++ b/arch/arm/mach-imx/cpu.c
@@ -1,6 +1,9 @@
1 1
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/io.h> 3#include <linux/io.h>
4#include <linux/of.h>
5#include <linux/slab.h>
6#include <linux/sys_soc.h>
4 7
5#include "hardware.h" 8#include "hardware.h"
6#include "common.h" 9#include "common.h"
@@ -56,3 +59,81 @@ void __init imx_set_aips(void __iomem *base)
56 reg = __raw_readl(base + 0x50) & 0x00FFFFFF; 59 reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
57 __raw_writel(reg, base + 0x50); 60 __raw_writel(reg, base + 0x50);
58} 61}
62
63struct device * __init imx_soc_device_init(void)
64{
65 struct soc_device_attribute *soc_dev_attr;
66 struct soc_device *soc_dev;
67 struct device_node *root;
68 const char *soc_id;
69 int ret;
70
71 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
72 if (!soc_dev_attr)
73 return NULL;
74
75 soc_dev_attr->family = "Freescale i.MX";
76
77 root = of_find_node_by_path("/");
78 ret = of_property_read_string(root, "model", &soc_dev_attr->machine);
79 of_node_put(root);
80 if (ret)
81 goto free_soc;
82
83 switch (__mxc_cpu_type) {
84 case MXC_CPU_MX1:
85 soc_id = "i.MX1";
86 break;
87 case MXC_CPU_MX21:
88 soc_id = "i.MX21";
89 break;
90 case MXC_CPU_MX25:
91 soc_id = "i.MX25";
92 break;
93 case MXC_CPU_MX27:
94 soc_id = "i.MX27";
95 break;
96 case MXC_CPU_MX31:
97 soc_id = "i.MX31";
98 break;
99 case MXC_CPU_MX35:
100 soc_id = "i.MX35";
101 break;
102 case MXC_CPU_MX51:
103 soc_id = "i.MX51";
104 break;
105 case MXC_CPU_MX53:
106 soc_id = "i.MX53";
107 break;
108 case MXC_CPU_IMX6SL:
109 soc_id = "i.MX6SL";
110 break;
111 case MXC_CPU_IMX6DL:
112 soc_id = "i.MX6DL";
113 break;
114 case MXC_CPU_IMX6Q:
115 soc_id = "i.MX6Q";
116 break;
117 default:
118 soc_id = "Unknown";
119 }
120 soc_dev_attr->soc_id = soc_id;
121
122 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d.%d",
123 (imx_soc_revision >> 4) & 0xf,
124 imx_soc_revision & 0xf);
125 if (!soc_dev_attr->revision)
126 goto free_soc;
127
128 soc_dev = soc_device_register(soc_dev_attr);
129 if (IS_ERR(soc_dev))
130 goto free_rev;
131
132 return soc_device_to_device(soc_dev);
133
134free_rev:
135 kfree(soc_dev_attr->revision);
136free_soc:
137 kfree(soc_dev_attr);
138 return NULL;
139}
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 1bdd0be429b9..049e36edc143 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -162,12 +162,18 @@ static void __init imx6q_1588_init(void)
162 162
163static void __init imx6q_init_machine(void) 163static void __init imx6q_init_machine(void)
164{ 164{
165 struct device *parent;
166
165 imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q", 167 imx_print_silicon_rev(cpu_is_imx6dl() ? "i.MX6DL" : "i.MX6Q",
166 imx_get_soc_revision()); 168 imx_get_soc_revision());
167 169
170 parent = imx_soc_device_init();
171 if (parent == NULL)
172 pr_warn("failed to initialize soc device\n");
173
168 imx6q_enet_phy_init(); 174 imx6q_enet_phy_init();
169 175
170 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 176 of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
171 177
172 imx_anatop_init(); 178 imx_anatop_init();
173 imx6q_pm_init(); 179 imx6q_pm_init();
diff --git a/arch/arm/mach-imx/mach-imx6sl.c b/arch/arm/mach-imx/mach-imx6sl.c
index 4ce9ae58ed0c..f01aaabd3254 100644
--- a/arch/arm/mach-imx/mach-imx6sl.c
+++ b/arch/arm/mach-imx/mach-imx6sl.c
@@ -36,9 +36,15 @@ static void __init imx6sl_fec_init(void)
36 36
37static void __init imx6sl_init_machine(void) 37static void __init imx6sl_init_machine(void)
38{ 38{
39 struct device *parent;
40
39 mxc_arch_reset_init_dt(); 41 mxc_arch_reset_init_dt();
40 42
41 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 43 parent = imx_soc_device_init();
44 if (parent == NULL)
45 pr_warn("failed to initialize soc device\n");
46
47 of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
42 48
43 imx6sl_fec_init(); 49 imx6sl_fec_init();
44} 50}
diff --git a/arch/arm/mach-imx/mxc.h b/arch/arm/mach-imx/mxc.h
index 8629e5be7ecd..99e03ea9bf79 100644
--- a/arch/arm/mach-imx/mxc.h
+++ b/arch/arm/mach-imx/mxc.h
@@ -34,6 +34,7 @@
34#define MXC_CPU_MX35 35 34#define MXC_CPU_MX35 35
35#define MXC_CPU_MX51 51 35#define MXC_CPU_MX51 51
36#define MXC_CPU_MX53 53 36#define MXC_CPU_MX53 53
37#define MXC_CPU_IMX6SL 0x60
37#define MXC_CPU_IMX6DL 0x61 38#define MXC_CPU_IMX6DL 0x61
38#define MXC_CPU_IMX6Q 0x63 39#define MXC_CPU_IMX6Q 0x63
39 40