xref: /linux/arch/arm/mach-clps711x/board-dt.c (revision 0db943ec029a1ced48c71617706a1e8d782c9676)
1*0db943ecSAlexander Shiyan /*
2*0db943ecSAlexander Shiyan  *  Author: Alexander Shiyan <shc_work@mail.ru>, 2016
3*0db943ecSAlexander Shiyan  *
4*0db943ecSAlexander Shiyan  * This program is free software; you can redistribute it and/or modify
5*0db943ecSAlexander Shiyan  * it under the terms of the GNU General Public License as published by
6*0db943ecSAlexander Shiyan  * the Free Software Foundation; either version 2 of the License, or
7*0db943ecSAlexander Shiyan  * (at your option) any later version.
8*0db943ecSAlexander Shiyan  */
9*0db943ecSAlexander Shiyan 
10*0db943ecSAlexander Shiyan #include <linux/io.h>
11*0db943ecSAlexander Shiyan #include <linux/of_fdt.h>
12*0db943ecSAlexander Shiyan #include <linux/platform_device.h>
13*0db943ecSAlexander Shiyan #include <linux/random.h>
14*0db943ecSAlexander Shiyan #include <linux/sizes.h>
15*0db943ecSAlexander Shiyan 
16*0db943ecSAlexander Shiyan #include <linux/mfd/syscon/clps711x.h>
17*0db943ecSAlexander Shiyan 
18*0db943ecSAlexander Shiyan #include <asm/system_info.h>
19*0db943ecSAlexander Shiyan #include <asm/system_misc.h>
20*0db943ecSAlexander Shiyan #include <asm/mach/arch.h>
21*0db943ecSAlexander Shiyan #include <asm/mach/map.h>
22*0db943ecSAlexander Shiyan 
23*0db943ecSAlexander Shiyan #define CLPS711X_VIRT_BASE	IOMEM(0xfeff4000)
24*0db943ecSAlexander Shiyan #define CLPS711X_PHYS_BASE	(0x80000000)
25*0db943ecSAlexander Shiyan # define SYSFLG1		(0x0140)
26*0db943ecSAlexander Shiyan # define HALT			(0x0800)
27*0db943ecSAlexander Shiyan # define UNIQID			(0x2440)
28*0db943ecSAlexander Shiyan # define RANDID0		(0x2700)
29*0db943ecSAlexander Shiyan # define RANDID1		(0x2704)
30*0db943ecSAlexander Shiyan # define RANDID2		(0x2708)
31*0db943ecSAlexander Shiyan # define RANDID3		(0x270c)
32*0db943ecSAlexander Shiyan 
33*0db943ecSAlexander Shiyan static struct map_desc clps711x_io_desc __initdata = {
34*0db943ecSAlexander Shiyan 	.virtual	= (unsigned long)CLPS711X_VIRT_BASE,
35*0db943ecSAlexander Shiyan 	.pfn		= __phys_to_pfn(CLPS711X_PHYS_BASE),
36*0db943ecSAlexander Shiyan 	.length		= 48 * SZ_1K,
37*0db943ecSAlexander Shiyan 	.type		= MT_DEVICE,
38*0db943ecSAlexander Shiyan };
39*0db943ecSAlexander Shiyan 
40*0db943ecSAlexander Shiyan static void __init clps711x_map_io(void)
41*0db943ecSAlexander Shiyan {
42*0db943ecSAlexander Shiyan 	iotable_init(&clps711x_io_desc, 1);
43*0db943ecSAlexander Shiyan }
44*0db943ecSAlexander Shiyan 
45*0db943ecSAlexander Shiyan static const struct resource clps711x_cpuidle_res =
46*0db943ecSAlexander Shiyan 	DEFINE_RES_MEM(CLPS711X_PHYS_BASE + HALT, SZ_128);
47*0db943ecSAlexander Shiyan 
48*0db943ecSAlexander Shiyan static void __init clps711x_init(void)
49*0db943ecSAlexander Shiyan {
50*0db943ecSAlexander Shiyan 	u32 id[5];
51*0db943ecSAlexander Shiyan 
52*0db943ecSAlexander Shiyan 	id[0] = readl(CLPS711X_VIRT_BASE + UNIQID);
53*0db943ecSAlexander Shiyan 	id[1] = readl(CLPS711X_VIRT_BASE + RANDID0);
54*0db943ecSAlexander Shiyan 	id[2] = readl(CLPS711X_VIRT_BASE + RANDID1);
55*0db943ecSAlexander Shiyan 	id[3] = readl(CLPS711X_VIRT_BASE + RANDID2);
56*0db943ecSAlexander Shiyan 	id[4] = readl(CLPS711X_VIRT_BASE + RANDID3);
57*0db943ecSAlexander Shiyan 	system_rev = SYSFLG1_VERID(readl(CLPS711X_VIRT_BASE + SYSFLG1));
58*0db943ecSAlexander Shiyan 
59*0db943ecSAlexander Shiyan 	add_device_randomness(id, sizeof(id));
60*0db943ecSAlexander Shiyan 
61*0db943ecSAlexander Shiyan 	system_serial_low = id[0];
62*0db943ecSAlexander Shiyan 
63*0db943ecSAlexander Shiyan 	platform_device_register_simple("clps711x-cpuidle", PLATFORM_DEVID_NONE,
64*0db943ecSAlexander Shiyan 					&clps711x_cpuidle_res, 1);
65*0db943ecSAlexander Shiyan }
66*0db943ecSAlexander Shiyan 
67*0db943ecSAlexander Shiyan static void clps711x_restart(enum reboot_mode mode, const char *cmd)
68*0db943ecSAlexander Shiyan {
69*0db943ecSAlexander Shiyan 	soft_restart(0);
70*0db943ecSAlexander Shiyan }
71*0db943ecSAlexander Shiyan 
72*0db943ecSAlexander Shiyan static const char *clps711x_compat[] __initconst = {
73*0db943ecSAlexander Shiyan 	"cirrus,ep7209",
74*0db943ecSAlexander Shiyan 	NULL
75*0db943ecSAlexander Shiyan };
76*0db943ecSAlexander Shiyan 
77*0db943ecSAlexander Shiyan DT_MACHINE_START(CLPS711X_DT, "Cirrus Logic CLPS711X (Device Tree Support)")
78*0db943ecSAlexander Shiyan 	.dt_compat	= clps711x_compat,
79*0db943ecSAlexander Shiyan 	.map_io		= clps711x_map_io,
80*0db943ecSAlexander Shiyan 	.init_late	= clps711x_init,
81*0db943ecSAlexander Shiyan 	.restart	= clps711x_restart,
82*0db943ecSAlexander Shiyan MACHINE_END
83