diff options
author | Michal Simek <michal.simek@xilinx.com> | 2013-07-31 03:19:59 -0400 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2014-05-20 10:13:48 -0400 |
commit | 00f7dc636366f72474b1896f4990b3c086cd2c6d (patch) | |
tree | 34e49e11098aa4f38d220f583d2e3028804348cd /arch/arm | |
parent | c9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (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')
-rw-r--r-- | arch/arm/boot/dts/zynq-7000.dtsi | 5 | ||||
-rw-r--r-- | arch/arm/mach-zynq/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-zynq/common.c | 71 | ||||
-rw-r--r-- | arch/arm/mach-zynq/common.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-zynq/slcr.c | 19 |
5 files changed, 96 insertions, 1 deletions
diff --git a/arch/arm/boot/dts/zynq-7000.dtsi b/arch/arm/boot/dts/zynq-7000.dtsi index 511180769af5..f55bf53da7d1 100644 --- a/arch/arm/boot/dts/zynq-7000.dtsi +++ b/arch/arm/boot/dts/zynq-7000.dtsi | |||
@@ -154,6 +154,11 @@ | |||
154 | }; | 154 | }; |
155 | }; | 155 | }; |
156 | 156 | ||
157 | devcfg: devcfg@f8007000 { | ||
158 | compatible = "xlnx,zynq-devcfg-1.0"; | ||
159 | reg = <0xf8007000 0x100>; | ||
160 | } ; | ||
161 | |||
157 | global_timer: timer@f8f00200 { | 162 | global_timer: timer@f8f00200 { |
158 | compatible = "arm,cortex-a9-global-timer"; | 163 | compatible = "arm,cortex-a9-global-timer"; |
159 | reg = <0xf8f00200 0x20>; | 164 | reg = <0xf8f00200 0x20>; |
diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig index 58c2b844e0a3..77cb52ed4b16 100644 --- a/arch/arm/mach-zynq/Kconfig +++ b/arch/arm/mach-zynq/Kconfig | |||
@@ -10,5 +10,6 @@ config ARCH_ZYNQ | |||
10 | select CADENCE_TTC_TIMER | 10 | select CADENCE_TTC_TIMER |
11 | select ARM_GLOBAL_TIMER if !CPU_FREQ | 11 | select ARM_GLOBAL_TIMER if !CPU_FREQ |
12 | select MFD_SYSCON | 12 | select MFD_SYSCON |
13 | select SOC_BUS | ||
13 | help | 14 | help |
14 | Support for Xilinx Zynq ARM Cortex A9 Platform | 15 | Support for Xilinx Zynq ARM Cortex A9 Platform |
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 | |||
44 | void __iomem *zynq_scu_base; | 51 | void __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 | */ | ||
74 | static 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 | */ |
66 | static void __init zynq_init_machine(void) | 105 | static 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 | |||
139 | out: | ||
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); |
diff --git a/arch/arm/mach-zynq/common.h b/arch/arm/mach-zynq/common.h index b097844d3175..f652f0a884a6 100644 --- a/arch/arm/mach-zynq/common.h +++ b/arch/arm/mach-zynq/common.h | |||
@@ -24,6 +24,7 @@ extern int zynq_early_slcr_init(void); | |||
24 | extern void zynq_slcr_system_reset(void); | 24 | extern void zynq_slcr_system_reset(void); |
25 | extern void zynq_slcr_cpu_stop(int cpu); | 25 | extern void zynq_slcr_cpu_stop(int cpu); |
26 | extern void zynq_slcr_cpu_start(int cpu); | 26 | extern void zynq_slcr_cpu_start(int cpu); |
27 | extern u32 zynq_slcr_get_device_id(void); | ||
27 | 28 | ||
28 | #ifdef CONFIG_SMP | 29 | #ifdef CONFIG_SMP |
29 | extern void secondary_startup(void); | 30 | extern void secondary_startup(void); |
diff --git a/arch/arm/mach-zynq/slcr.c b/arch/arm/mach-zynq/slcr.c index a37d49a6e657..c43a2d16e223 100644 --- a/arch/arm/mach-zynq/slcr.c +++ b/arch/arm/mach-zynq/slcr.c | |||
@@ -26,10 +26,13 @@ | |||
26 | #define SLCR_PS_RST_CTRL_OFFSET 0x200 /* PS Software Reset Control */ | 26 | #define SLCR_PS_RST_CTRL_OFFSET 0x200 /* PS Software Reset Control */ |
27 | #define SLCR_A9_CPU_RST_CTRL_OFFSET 0x244 /* CPU Software Reset Control */ | 27 | #define SLCR_A9_CPU_RST_CTRL_OFFSET 0x244 /* CPU Software Reset Control */ |
28 | #define SLCR_REBOOT_STATUS_OFFSET 0x258 /* PS Reboot Status */ | 28 | #define SLCR_REBOOT_STATUS_OFFSET 0x258 /* PS Reboot Status */ |
29 | #define SLCR_PSS_IDCODE 0x530 /* PS IDCODE */ | ||
29 | 30 | ||
30 | #define SLCR_UNLOCK_MAGIC 0xDF0D | 31 | #define SLCR_UNLOCK_MAGIC 0xDF0D |
31 | #define SLCR_A9_CPU_CLKSTOP 0x10 | 32 | #define SLCR_A9_CPU_CLKSTOP 0x10 |
32 | #define SLCR_A9_CPU_RST 0x1 | 33 | #define SLCR_A9_CPU_RST 0x1 |
34 | #define SLCR_PSS_IDCODE_DEVICE_SHIFT 12 | ||
35 | #define SLCR_PSS_IDCODE_DEVICE_MASK 0x1F | ||
33 | 36 | ||
34 | static void __iomem *zynq_slcr_base; | 37 | static void __iomem *zynq_slcr_base; |
35 | static struct regmap *zynq_slcr_regmap; | 38 | static struct regmap *zynq_slcr_regmap; |
@@ -83,6 +86,22 @@ static inline int zynq_slcr_unlock(void) | |||
83 | } | 86 | } |
84 | 87 | ||
85 | /** | 88 | /** |
89 | * zynq_slcr_get_device_id - Read device code id | ||
90 | * | ||
91 | * Return: Device code id | ||
92 | */ | ||
93 | u32 zynq_slcr_get_device_id(void) | ||
94 | { | ||
95 | u32 val; | ||
96 | |||
97 | zynq_slcr_read(&val, SLCR_PSS_IDCODE); | ||
98 | val >>= SLCR_PSS_IDCODE_DEVICE_SHIFT; | ||
99 | val &= SLCR_PSS_IDCODE_DEVICE_MASK; | ||
100 | |||
101 | return val; | ||
102 | } | ||
103 | |||
104 | /** | ||
86 | * zynq_slcr_system_reset - Reset the entire system. | 105 | * zynq_slcr_system_reset - Reset the entire system. |
87 | */ | 106 | */ |
88 | void zynq_slcr_system_reset(void) | 107 | void zynq_slcr_system_reset(void) |