1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * arch/arm/mach-vt8500/vt8500.c
5 * Copyright (C) 2012 Tony Prisk <linux@prisktech.co.nz>
10 #include <linux/reboot.h>
12 #include <asm/mach-types.h>
13 #include <asm/mach/arch.h>
14 #include <asm/mach/time.h>
15 #include <asm/mach/map.h>
18 #include <linux/of_address.h>
19 #include <linux/of_irq.h>
21 #define LEGACY_GPIO_BASE 0xD8110000
22 #define LEGACY_PMC_BASE 0xD8130000
24 /* Registers in GPIO Controller */
25 #define VT8500_GPIO_MUX_REG 0x200
27 /* Registers in Power Management Controller */
28 #define VT8500_HCR_REG 0x12
29 #define VT8500_PMSR_REG 0x60
31 static void __iomem
*pmc_base
;
33 static void vt8500_restart(enum reboot_mode mode
, const char *cmd
)
36 writel(1, pmc_base
+ VT8500_PMSR_REG
);
39 static struct map_desc vt8500_io_desc
[] __initdata
= {
40 /* SoC MMIO registers */
42 .virtual = 0xf8000000,
43 .pfn
= __phys_to_pfn(0xd8000000),
44 .length
= 0x00390000, /* max of all chip variants */
49 static void __init
vt8500_map_io(void)
51 iotable_init(vt8500_io_desc
, ARRAY_SIZE(vt8500_io_desc
));
54 static void vt8500_power_off(void)
57 writew(5, pmc_base
+ VT8500_HCR_REG
);
58 asm("mcr p15, 0, %0, c7, c0, 4" : : "r" (0));
61 static void __init
vt8500_init(void)
63 struct device_node
*np
;
64 #if defined(CONFIG_FB_VT8500) || defined(CONFIG_FB_WM8505)
65 struct device_node
*fb
;
66 void __iomem
*gpio_base
;
69 #ifdef CONFIG_FB_VT8500
70 fb
= of_find_compatible_node(NULL
, NULL
, "via,vt8500-fb");
72 np
= of_find_compatible_node(NULL
, NULL
, "via,vt8500-gpio");
74 gpio_base
= of_iomap(np
, 0);
77 pr_err("%s: of_iomap(gpio_mux) failed\n",
82 gpio_base
= ioremap(LEGACY_GPIO_BASE
, 0x1000);
84 pr_err("%s: ioremap(legacy_gpio_mux) failed\n",
88 writel(readl(gpio_base
+ VT8500_GPIO_MUX_REG
) | 1,
89 gpio_base
+ VT8500_GPIO_MUX_REG
);
92 pr_err("%s: Could not remap GPIO mux\n", __func__
);
98 #ifdef CONFIG_FB_WM8505
99 fb
= of_find_compatible_node(NULL
, NULL
, "wm,wm8505-fb");
101 np
= of_find_compatible_node(NULL
, NULL
, "wm,wm8505-gpio");
103 np
= of_find_compatible_node(NULL
, NULL
,
106 gpio_base
= of_iomap(np
, 0);
109 pr_err("%s: of_iomap(gpio_mux) failed\n",
114 gpio_base
= ioremap(LEGACY_GPIO_BASE
, 0x1000);
116 pr_err("%s: ioremap(legacy_gpio_mux) failed\n",
120 writel(readl(gpio_base
+ VT8500_GPIO_MUX_REG
) |
121 0x80000000, gpio_base
+ VT8500_GPIO_MUX_REG
);
124 pr_err("%s: Could not remap GPIO mux\n", __func__
);
130 np
= of_find_compatible_node(NULL
, NULL
, "via,vt8500-pmc");
132 pmc_base
= of_iomap(np
, 0);
135 pr_err("%s:of_iomap(pmc) failed\n", __func__
);
139 pmc_base
= ioremap(LEGACY_PMC_BASE
, 0x1000);
141 pr_err("%s:ioremap(power_off) failed\n", __func__
);
144 pm_power_off
= &vt8500_power_off
;
146 pr_err("%s: PMC Hibernation register could not be remapped, not enabling power off!\n", __func__
);
149 static const char * const vt8500_dt_compat
[] = {
158 DT_MACHINE_START(WMT_DT
, "VIA/Wondermedia SoC (Device Tree Support)")
159 .dt_compat
= vt8500_dt_compat
,
160 .map_io
= vt8500_map_io
,
161 .init_machine
= vt8500_init
,
162 .restart
= vt8500_restart
,