aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-zynq/common.c
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2013-07-31 03:19:59 -0400
committerMichal Simek <michal.simek@xilinx.com>2014-05-20 10:13:48 -0400
commit00f7dc636366f72474b1896f4990b3c086cd2c6d (patch)
tree34e49e11098aa4f38d220f583d2e3028804348cd /arch/arm/mach-zynq/common.c
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
ARM: zynq: Add support for SOC_BUS
Provide information through SOC_BUS to user space. Silicon revision is provided through devcfg device. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'arch/arm/mach-zynq/common.c')
-rw-r--r--arch/arm/mach-zynq/common.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 6fcc584c1a11..edbd9d83f407 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -29,6 +29,8 @@
29#include <linux/memblock.h> 29#include <linux/memblock.h>
30#include <linux/irqchip.h> 30#include <linux/irqchip.h>
31#include <linux/irqchip/arm-gic.h> 31#include <linux/irqchip/arm-gic.h>
32#include <linux/slab.h>
33#include <linux/sys_soc.h>
32 34
33#include <asm/mach/arch.h> 35#include <asm/mach/arch.h>
34#include <asm/mach/map.h> 36#include <asm/mach/map.h>
@@ -37,10 +39,15 @@
37#include <asm/page.h> 39#include <asm/page.h>
38#include <asm/pgtable.h> 40#include <asm/pgtable.h>
39#include <asm/smp_scu.h> 41#include <asm/smp_scu.h>
42#include <asm/system_info.h>
40#include <asm/hardware/cache-l2x0.h> 43#include <asm/hardware/cache-l2x0.h>
41 44
42#include "common.h" 45#include "common.h"
43 46
47#define ZYNQ_DEVCFG_MCTRL 0x80
48#define ZYNQ_DEVCFG_PS_VERSION_SHIFT 28
49#define ZYNQ_DEVCFG_PS_VERSION_MASK 0xF
50
44void __iomem *zynq_scu_base; 51void __iomem *zynq_scu_base;
45 52
46/** 53/**
@@ -60,19 +67,81 @@ static struct platform_device zynq_cpuidle_device = {
60}; 67};
61 68
62/** 69/**
70 * zynq_get_revision - Get Zynq silicon revision
71 *
72 * Return: Silicon version or -1 otherwise
73 */
74static int __init zynq_get_revision(void)
75{
76 struct device_node *np;
77 void __iomem *zynq_devcfg_base;
78 u32 revision;
79
80 np = of_find_compatible_node(NULL, NULL, "xlnx,zynq-devcfg-1.0");
81 if (!np) {
82 pr_err("%s: no devcfg node found\n", __func__);
83 return -1;
84 }
85
86 zynq_devcfg_base = of_iomap(np, 0);
87 if (!zynq_devcfg_base) {
88 pr_err("%s: Unable to map I/O memory\n", __func__);
89 return -1;
90 }
91
92 revision = readl(zynq_devcfg_base + ZYNQ_DEVCFG_MCTRL);
93 revision >>= ZYNQ_DEVCFG_PS_VERSION_SHIFT;
94 revision &= ZYNQ_DEVCFG_PS_VERSION_MASK;
95
96 iounmap(zynq_devcfg_base);
97
98 return revision;
99}
100
101/**
63 * zynq_init_machine - System specific initialization, intended to be 102 * zynq_init_machine - System specific initialization, intended to be
64 * called from board specific initialization. 103 * called from board specific initialization.
65 */ 104 */
66static void __init zynq_init_machine(void) 105static void __init zynq_init_machine(void)
67{ 106{
68 struct platform_device_info devinfo = { .name = "cpufreq-cpu0", }; 107 struct platform_device_info devinfo = { .name = "cpufreq-cpu0", };
108 struct soc_device_attribute *soc_dev_attr;
109 struct soc_device *soc_dev;
110 struct device *parent = NULL;
69 111
70 /* 112 /*
71 * 64KB way size, 8-way associativity, parity disabled 113 * 64KB way size, 8-way associativity, parity disabled
72 */ 114 */
73 l2x0_of_init(0x02060000, 0xF0F0FFFF); 115 l2x0_of_init(0x02060000, 0xF0F0FFFF);
74 116
75 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 117 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
118 if (!soc_dev_attr)
119 goto out;
120
121 system_rev = zynq_get_revision();
122
123 soc_dev_attr->family = kasprintf(GFP_KERNEL, "Xilinx Zynq");
124 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "0x%x", system_rev);
125 soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "0x%x",
126 zynq_slcr_get_device_id());
127
128 soc_dev = soc_device_register(soc_dev_attr);
129 if (IS_ERR(soc_dev)) {
130 kfree(soc_dev_attr->family);
131 kfree(soc_dev_attr->revision);
132 kfree(soc_dev_attr->soc_id);
133 kfree(soc_dev_attr);
134 goto out;
135 }
136
137 parent = soc_device_to_device(soc_dev);
138
139out:
140 /*
141 * Finished with the static registrations now; fill in the missing
142 * devices
143 */
144 of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
76 145
77 platform_device_register(&zynq_cpuidle_device); 146 platform_device_register(&zynq_cpuidle_device);
78 platform_device_register_full(&devinfo); 147 platform_device_register_full(&devinfo);