xref: /linux/arch/arm/mach-clps711x/board-dt.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
20db943ecSAlexander Shiyan /*
30db943ecSAlexander Shiyan  *  Author: Alexander Shiyan <shc_work@mail.ru>, 2016
40db943ecSAlexander Shiyan  */
50db943ecSAlexander Shiyan 
60db943ecSAlexander Shiyan #include <linux/io.h>
70db943ecSAlexander Shiyan #include <linux/of_fdt.h>
80db943ecSAlexander Shiyan #include <linux/platform_device.h>
90db943ecSAlexander Shiyan #include <linux/random.h>
100db943ecSAlexander Shiyan #include <linux/sizes.h>
110db943ecSAlexander Shiyan 
120db943ecSAlexander Shiyan #include <linux/mfd/syscon/clps711x.h>
130db943ecSAlexander Shiyan 
140db943ecSAlexander Shiyan #include <asm/system_info.h>
150db943ecSAlexander Shiyan #include <asm/system_misc.h>
160db943ecSAlexander Shiyan #include <asm/mach/arch.h>
170db943ecSAlexander Shiyan #include <asm/mach/map.h>
180db943ecSAlexander Shiyan 
190db943ecSAlexander Shiyan #define CLPS711X_VIRT_BASE	IOMEM(0xfeff4000)
200db943ecSAlexander Shiyan #define CLPS711X_PHYS_BASE	(0x80000000)
210db943ecSAlexander Shiyan # define SYSFLG1		(0x0140)
220db943ecSAlexander Shiyan # define HALT			(0x0800)
230db943ecSAlexander Shiyan # define UNIQID			(0x2440)
240db943ecSAlexander Shiyan # define RANDID0		(0x2700)
250db943ecSAlexander Shiyan # define RANDID1		(0x2704)
260db943ecSAlexander Shiyan # define RANDID2		(0x2708)
270db943ecSAlexander Shiyan # define RANDID3		(0x270c)
280db943ecSAlexander Shiyan 
290db943ecSAlexander Shiyan static struct map_desc clps711x_io_desc __initdata = {
300db943ecSAlexander Shiyan 	.virtual	= (unsigned long)CLPS711X_VIRT_BASE,
310db943ecSAlexander Shiyan 	.pfn		= __phys_to_pfn(CLPS711X_PHYS_BASE),
320db943ecSAlexander Shiyan 	.length		= 48 * SZ_1K,
330db943ecSAlexander Shiyan 	.type		= MT_DEVICE,
340db943ecSAlexander Shiyan };
350db943ecSAlexander Shiyan 
clps711x_map_io(void)360db943ecSAlexander Shiyan static void __init clps711x_map_io(void)
370db943ecSAlexander Shiyan {
380db943ecSAlexander Shiyan 	iotable_init(&clps711x_io_desc, 1);
390db943ecSAlexander Shiyan }
400db943ecSAlexander Shiyan 
410db943ecSAlexander Shiyan static const struct resource clps711x_cpuidle_res =
420db943ecSAlexander Shiyan 	DEFINE_RES_MEM(CLPS711X_PHYS_BASE + HALT, SZ_128);
430db943ecSAlexander Shiyan 
clps711x_init(void)440db943ecSAlexander Shiyan static void __init clps711x_init(void)
450db943ecSAlexander Shiyan {
460db943ecSAlexander Shiyan 	u32 id[5];
470db943ecSAlexander Shiyan 
480db943ecSAlexander Shiyan 	id[0] = readl(CLPS711X_VIRT_BASE + UNIQID);
490db943ecSAlexander Shiyan 	id[1] = readl(CLPS711X_VIRT_BASE + RANDID0);
500db943ecSAlexander Shiyan 	id[2] = readl(CLPS711X_VIRT_BASE + RANDID1);
510db943ecSAlexander Shiyan 	id[3] = readl(CLPS711X_VIRT_BASE + RANDID2);
520db943ecSAlexander Shiyan 	id[4] = readl(CLPS711X_VIRT_BASE + RANDID3);
530db943ecSAlexander Shiyan 	system_rev = SYSFLG1_VERID(readl(CLPS711X_VIRT_BASE + SYSFLG1));
540db943ecSAlexander Shiyan 
550db943ecSAlexander Shiyan 	add_device_randomness(id, sizeof(id));
560db943ecSAlexander Shiyan 
570db943ecSAlexander Shiyan 	system_serial_low = id[0];
580db943ecSAlexander Shiyan 
590db943ecSAlexander Shiyan 	platform_device_register_simple("clps711x-cpuidle", PLATFORM_DEVID_NONE,
600db943ecSAlexander Shiyan 					&clps711x_cpuidle_res, 1);
610db943ecSAlexander Shiyan }
620db943ecSAlexander Shiyan 
clps711x_restart(enum reboot_mode mode,const char * cmd)630db943ecSAlexander Shiyan static void clps711x_restart(enum reboot_mode mode, const char *cmd)
640db943ecSAlexander Shiyan {
650db943ecSAlexander Shiyan 	soft_restart(0);
660db943ecSAlexander Shiyan }
670db943ecSAlexander Shiyan 
6801a6e126SArnd Bergmann static const char *const clps711x_compat[] __initconst = {
690db943ecSAlexander Shiyan 	"cirrus,ep7209",
700db943ecSAlexander Shiyan 	NULL
710db943ecSAlexander Shiyan };
720db943ecSAlexander Shiyan 
730db943ecSAlexander Shiyan DT_MACHINE_START(CLPS711X_DT, "Cirrus Logic CLPS711X (Device Tree Support)")
740db943ecSAlexander Shiyan 	.dt_compat	= clps711x_compat,
750db943ecSAlexander Shiyan 	.map_io		= clps711x_map_io,
760db943ecSAlexander Shiyan 	.init_late	= clps711x_init,
770db943ecSAlexander Shiyan 	.restart	= clps711x_restart,
780db943ecSAlexander Shiyan MACHINE_END
79