xref: /linux/arch/arm/mach-zynq/common.c (revision 3e8ceca6c76ec2d5ee47ece0420cf10d041cf58f)
1b85a3ef4SJohn Linn /*
2b85a3ef4SJohn Linn  * This file contains common code that is intended to be used across
3b85a3ef4SJohn Linn  * boards so that it's not replicated.
4b85a3ef4SJohn Linn  *
5b85a3ef4SJohn Linn  *  Copyright (C) 2011 Xilinx
6b85a3ef4SJohn Linn  *
7b85a3ef4SJohn Linn  * This software is licensed under the terms of the GNU General Public
8b85a3ef4SJohn Linn  * License version 2, as published by the Free Software Foundation, and
9b85a3ef4SJohn Linn  * may be copied, distributed, and modified under those terms.
10b85a3ef4SJohn Linn  *
11b85a3ef4SJohn Linn  * This program is distributed in the hope that it will be useful,
12b85a3ef4SJohn Linn  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13b85a3ef4SJohn Linn  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14b85a3ef4SJohn Linn  * GNU General Public License for more details.
15b85a3ef4SJohn Linn  */
16b85a3ef4SJohn Linn 
17b85a3ef4SJohn Linn #include <linux/init.h>
18b85a3ef4SJohn Linn #include <linux/kernel.h>
19b85a3ef4SJohn Linn #include <linux/cpumask.h>
20b85a3ef4SJohn Linn #include <linux/platform_device.h>
21b85a3ef4SJohn Linn #include <linux/clk.h>
220f586fbfSJosh Cartwright #include <linux/clk/zynq.h>
23e932900aSMichal Simek #include <linux/clocksource.h>
240f586fbfSJosh Cartwright #include <linux/of_address.h>
25b85a3ef4SJohn Linn #include <linux/of_irq.h>
26b85a3ef4SJohn Linn #include <linux/of_platform.h>
273d64b449SArnd Bergmann #include <linux/of.h>
28b85a3ef4SJohn Linn 
293d64b449SArnd Bergmann #include <asm/mach/arch.h>
30b85a3ef4SJohn Linn #include <asm/mach/map.h>
3103e07595SJosh Cartwright #include <asm/mach/time.h>
323d64b449SArnd Bergmann #include <asm/mach-types.h>
33b85a3ef4SJohn Linn #include <asm/page.h>
349a45eb69SJosh Cartwright #include <asm/pgtable.h>
35732078c3SMichal Simek #include <asm/smp_scu.h>
36b85a3ef4SJohn Linn #include <asm/hardware/cache-l2x0.h>
37b85a3ef4SJohn Linn 
38b85a3ef4SJohn Linn #include "common.h"
39b85a3ef4SJohn Linn 
40732078c3SMichal Simek void __iomem *zynq_scu_base;
41732078c3SMichal Simek 
42b85a3ef4SJohn Linn static struct of_device_id zynq_of_bus_ids[] __initdata = {
43b85a3ef4SJohn Linn 	{ .compatible = "simple-bus", },
44b85a3ef4SJohn Linn 	{}
45b85a3ef4SJohn Linn };
46b85a3ef4SJohn Linn 
47*3e8ceca6SDaniel Lezcano static struct platform_device zynq_cpuidle_device = {
48*3e8ceca6SDaniel Lezcano 	.name = "cpuidle-zynq",
49*3e8ceca6SDaniel Lezcano };
50*3e8ceca6SDaniel Lezcano 
51b85a3ef4SJohn Linn /**
52889faa88SMichal Simek  * zynq_init_machine - System specific initialization, intended to be
53b85a3ef4SJohn Linn  *		       called from board specific initialization.
54b85a3ef4SJohn Linn  */
55889faa88SMichal Simek static void __init zynq_init_machine(void)
56b85a3ef4SJohn Linn {
57b85a3ef4SJohn Linn 	/*
58b85a3ef4SJohn Linn 	 * 64KB way size, 8-way associativity, parity disabled
59b85a3ef4SJohn Linn 	 */
600fcfdbcaSJosh Cartwright 	l2x0_of_init(0x02060000, 0xF0F0FFFF);
61b85a3ef4SJohn Linn 
62b85a3ef4SJohn Linn 	of_platform_bus_probe(NULL, zynq_of_bus_ids, NULL);
63*3e8ceca6SDaniel Lezcano 
64*3e8ceca6SDaniel Lezcano 	platform_device_register(&zynq_cpuidle_device);
65b85a3ef4SJohn Linn }
66b85a3ef4SJohn Linn 
67889faa88SMichal Simek static void __init zynq_timer_init(void)
6803e07595SJosh Cartwright {
6964b889b3SMichal Simek 	zynq_slcr_init();
70c5263bb8SMichal Simek 	clocksource_of_init();
7103e07595SJosh Cartwright }
7203e07595SJosh Cartwright 
73732078c3SMichal Simek static struct map_desc zynq_cortex_a9_scu_map __initdata = {
74732078c3SMichal Simek 	.length	= SZ_256,
75732078c3SMichal Simek 	.type	= MT_DEVICE,
76732078c3SMichal Simek };
77732078c3SMichal Simek 
78732078c3SMichal Simek static void __init zynq_scu_map_io(void)
79732078c3SMichal Simek {
80732078c3SMichal Simek 	unsigned long base;
81732078c3SMichal Simek 
82732078c3SMichal Simek 	base = scu_a9_get_base();
83732078c3SMichal Simek 	zynq_cortex_a9_scu_map.pfn = __phys_to_pfn(base);
84732078c3SMichal Simek 	/* Expected address is in vmalloc area that's why simple assign here */
85732078c3SMichal Simek 	zynq_cortex_a9_scu_map.virtual = base;
86732078c3SMichal Simek 	iotable_init(&zynq_cortex_a9_scu_map, 1);
87732078c3SMichal Simek 	zynq_scu_base = (void __iomem *)base;
88732078c3SMichal Simek 	BUG_ON(!zynq_scu_base);
89732078c3SMichal Simek }
90732078c3SMichal Simek 
91b85a3ef4SJohn Linn /**
92889faa88SMichal Simek  * zynq_map_io - Create memory mappings needed for early I/O.
93b85a3ef4SJohn Linn  */
94889faa88SMichal Simek static void __init zynq_map_io(void)
95b85a3ef4SJohn Linn {
96385f02b1SJosh Cartwright 	debug_ll_io_init();
97732078c3SMichal Simek 	zynq_scu_map_io();
98b85a3ef4SJohn Linn }
993d64b449SArnd Bergmann 
100fe08bf9fSVincent Stehlé static void zynq_system_reset(enum reboot_mode mode, const char *cmd)
10196790f0aSMichal Simek {
10296790f0aSMichal Simek 	zynq_slcr_system_reset();
10396790f0aSMichal Simek }
10496790f0aSMichal Simek 
105889faa88SMichal Simek static const char * const zynq_dt_match[] = {
106e06f1a9eSJosh Cartwright 	"xlnx,zynq-7000",
1073d64b449SArnd Bergmann 	NULL
1083d64b449SArnd Bergmann };
1093d64b449SArnd Bergmann 
110514a5908SArnd Bergmann DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
111aa7eb2bbSMichal Simek 	.smp		= smp_ops(zynq_smp_ops),
112889faa88SMichal Simek 	.map_io		= zynq_map_io,
113889faa88SMichal Simek 	.init_machine	= zynq_init_machine,
114889faa88SMichal Simek 	.init_time	= zynq_timer_init,
115889faa88SMichal Simek 	.dt_compat	= zynq_dt_match,
11696790f0aSMichal Simek 	.restart	= zynq_system_reset,
1173d64b449SArnd Bergmann MACHINE_END
118