aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sunxi
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sunxi')
-rw-r--r--arch/arm/mach-sunxi/Kconfig3
-rw-r--r--arch/arm/mach-sunxi/Makefile1
-rw-r--r--arch/arm/mach-sunxi/common.h19
-rw-r--r--arch/arm/mach-sunxi/headsmp.S9
-rw-r--r--arch/arm/mach-sunxi/platsmp.c124
-rw-r--r--arch/arm/mach-sunxi/sunxi.c14
6 files changed, 170 insertions, 0 deletions
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index bce0d4277f71..b9d6cad8669b 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -1,7 +1,9 @@
1config ARCH_SUNXI 1config ARCH_SUNXI
2 bool "Allwinner A1X SOCs" if ARCH_MULTI_V7 2 bool "Allwinner A1X SOCs" if ARCH_MULTI_V7
3 select ARCH_HAS_RESET_CONTROLLER
3 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
4 select ARM_GIC 5 select ARM_GIC
6 select ARM_PSCI
5 select CLKSRC_MMIO 7 select CLKSRC_MMIO
6 select CLKSRC_OF 8 select CLKSRC_OF
7 select COMMON_CLK 9 select COMMON_CLK
@@ -10,6 +12,7 @@ config ARCH_SUNXI
10 select HAVE_SMP 12 select HAVE_SMP
11 select PINCTRL 13 select PINCTRL
12 select PINCTRL_SUNXI 14 select PINCTRL_SUNXI
15 select RESET_CONTROLLER
13 select SPARSE_IRQ 16 select SPARSE_IRQ
14 select SUN4I_TIMER 17 select SUN4I_TIMER
15 select SUN5I_HSTIMER 18 select SUN5I_HSTIMER
diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
index 93bebfc3ff9f..d9397202d6ec 100644
--- a/arch/arm/mach-sunxi/Makefile
+++ b/arch/arm/mach-sunxi/Makefile
@@ -1 +1,2 @@
1obj-$(CONFIG_ARCH_SUNXI) += sunxi.o 1obj-$(CONFIG_ARCH_SUNXI) += sunxi.o
2obj-$(CONFIG_SMP) += platsmp.o headsmp.o
diff --git a/arch/arm/mach-sunxi/common.h b/arch/arm/mach-sunxi/common.h
new file mode 100644
index 000000000000..9e5ac4756cbb
--- /dev/null
+++ b/arch/arm/mach-sunxi/common.h
@@ -0,0 +1,19 @@
1/*
2 * Core functions for Allwinner SoCs
3 *
4 * Copyright (C) 2013 Maxime Ripard
5 *
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
7 *
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
11 */
12
13#ifndef __ARCH_SUNXI_COMMON_H_
14#define __ARCH_SUNXI_COMMON_H_
15
16void sun6i_secondary_startup(void);
17extern struct smp_operations sun6i_smp_ops;
18
19#endif /* __ARCH_SUNXI_COMMON_H_ */
diff --git a/arch/arm/mach-sunxi/headsmp.S b/arch/arm/mach-sunxi/headsmp.S
new file mode 100644
index 000000000000..a10d494fb37b
--- /dev/null
+++ b/arch/arm/mach-sunxi/headsmp.S
@@ -0,0 +1,9 @@
1#include <linux/linkage.h>
2#include <linux/init.h>
3
4 .section ".text.head", "ax"
5
6ENTRY(sun6i_secondary_startup)
7 msr cpsr_fsxc, #0xd3
8 b secondary_startup
9ENDPROC(sun6i_secondary_startup)
diff --git a/arch/arm/mach-sunxi/platsmp.c b/arch/arm/mach-sunxi/platsmp.c
new file mode 100644
index 000000000000..7b141d8342a1
--- /dev/null
+++ b/arch/arm/mach-sunxi/platsmp.c
@@ -0,0 +1,124 @@
1/*
2 * SMP support for Allwinner SoCs
3 *
4 * Copyright (C) 2013 Maxime Ripard
5 *
6 * Maxime Ripard <maxime.ripard@free-electrons.com>
7 *
8 * Based on code
9 * Copyright (C) 2012-2013 Allwinner Ltd.
10 *
11 * This file is licensed under the terms of the GNU General Public
12 * License version 2. This program is licensed "as is" without any
13 * warranty of any kind, whether express or implied.
14 */
15
16#include <linux/delay.h>
17#include <linux/init.h>
18#include <linux/io.h>
19#include <linux/memory.h>
20#include <linux/of.h>
21#include <linux/of_address.h>
22#include <linux/smp.h>
23
24#include "common.h"
25
26#define CPUCFG_CPU_PWR_CLAMP_STATUS_REG(cpu) ((cpu) * 0x40 + 0x64)
27#define CPUCFG_CPU_RST_CTRL_REG(cpu) (((cpu) + 1) * 0x40)
28#define CPUCFG_CPU_CTRL_REG(cpu) (((cpu) + 1) * 0x40 + 0x04)
29#define CPUCFG_CPU_STATUS_REG(cpu) (((cpu) + 1) * 0x40 + 0x08)
30#define CPUCFG_GEN_CTRL_REG 0x184
31#define CPUCFG_PRIVATE0_REG 0x1a4
32#define CPUCFG_PRIVATE1_REG 0x1a8
33#define CPUCFG_DBG_CTL0_REG 0x1e0
34#define CPUCFG_DBG_CTL1_REG 0x1e4
35
36#define PRCM_CPU_PWROFF_REG 0x100
37#define PRCM_CPU_PWR_CLAMP_REG(cpu) (((cpu) * 4) + 0x140)
38
39static void __iomem *cpucfg_membase;
40static void __iomem *prcm_membase;
41
42static DEFINE_SPINLOCK(cpu_lock);
43
44static void __init sun6i_smp_prepare_cpus(unsigned int max_cpus)
45{
46 struct device_node *node;
47
48 node = of_find_compatible_node(NULL, NULL, "allwinner,sun6i-a31-prcm");
49 if (!node) {
50 pr_err("Missing A31 PRCM node in the device tree\n");
51 return;
52 }
53
54 prcm_membase = of_iomap(node, 0);
55 if (!prcm_membase) {
56 pr_err("Couldn't map A31 PRCM registers\n");
57 return;
58 }
59
60 node = of_find_compatible_node(NULL, NULL,
61 "allwinner,sun6i-a31-cpuconfig");
62 if (!node) {
63 pr_err("Missing A31 CPU config node in the device tree\n");
64 return;
65 }
66
67 cpucfg_membase = of_iomap(node, 0);
68 if (!cpucfg_membase)
69 pr_err("Couldn't map A31 CPU config registers\n");
70
71}
72
73static int sun6i_smp_boot_secondary(unsigned int cpu,
74 struct task_struct *idle)
75{
76 u32 reg;
77 int i;
78
79 if (!(prcm_membase && cpucfg_membase))
80 return -EFAULT;
81
82 spin_lock(&cpu_lock);
83
84 /* Set CPU boot address */
85 writel(virt_to_phys(sun6i_secondary_startup),
86 cpucfg_membase + CPUCFG_PRIVATE0_REG);
87
88 /* Assert the CPU core in reset */
89 writel(0, cpucfg_membase + CPUCFG_CPU_RST_CTRL_REG(cpu));
90
91 /* Assert the L1 cache in reset */
92 reg = readl(cpucfg_membase + CPUCFG_GEN_CTRL_REG);
93 writel(reg & ~BIT(cpu), cpucfg_membase + CPUCFG_GEN_CTRL_REG);
94
95 /* Disable external debug access */
96 reg = readl(cpucfg_membase + CPUCFG_DBG_CTL1_REG);
97 writel(reg & ~BIT(cpu), cpucfg_membase + CPUCFG_DBG_CTL1_REG);
98
99 /* Power up the CPU */
100 for (i = 0; i <= 8; i++)
101 writel(0xff >> i, prcm_membase + PRCM_CPU_PWR_CLAMP_REG(cpu));
102 mdelay(10);
103
104 /* Clear CPU power-off gating */
105 reg = readl(prcm_membase + PRCM_CPU_PWROFF_REG);
106 writel(reg & ~BIT(cpu), prcm_membase + PRCM_CPU_PWROFF_REG);
107 mdelay(1);
108
109 /* Deassert the CPU core reset */
110 writel(3, cpucfg_membase + CPUCFG_CPU_RST_CTRL_REG(cpu));
111
112 /* Enable back the external debug accesses */
113 reg = readl(cpucfg_membase + CPUCFG_DBG_CTL1_REG);
114 writel(reg | BIT(cpu), cpucfg_membase + CPUCFG_DBG_CTL1_REG);
115
116 spin_unlock(&cpu_lock);
117
118 return 0;
119}
120
121struct smp_operations sun6i_smp_ops __initdata = {
122 .smp_prepare_cpus = sun6i_smp_prepare_cpus,
123 .smp_boot_secondary = sun6i_smp_boot_secondary,
124};
diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c
index 61d3a387f01c..aeea6ceea725 100644
--- a/arch/arm/mach-sunxi/sunxi.c
+++ b/arch/arm/mach-sunxi/sunxi.c
@@ -10,6 +10,8 @@
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12 12
13#include <linux/clk-provider.h>
14#include <linux/clocksource.h>
13#include <linux/delay.h> 15#include <linux/delay.h>
14#include <linux/kernel.h> 16#include <linux/kernel.h>
15#include <linux/init.h> 17#include <linux/init.h>
@@ -23,6 +25,8 @@
23#include <asm/mach/map.h> 25#include <asm/mach/map.h>
24#include <asm/system_misc.h> 26#include <asm/system_misc.h>
25 27
28#include "common.h"
29
26#define SUN4I_WATCHDOG_CTRL_REG 0x00 30#define SUN4I_WATCHDOG_CTRL_REG 0x00
27#define SUN4I_WATCHDOG_CTRL_RESTART BIT(0) 31#define SUN4I_WATCHDOG_CTRL_RESTART BIT(0)
28#define SUN4I_WATCHDOG_MODE_REG 0x04 32#define SUN4I_WATCHDOG_MODE_REG 0x04
@@ -132,10 +136,20 @@ static const char * const sun6i_board_dt_compat[] = {
132 NULL, 136 NULL,
133}; 137};
134 138
139extern void __init sun6i_reset_init(void);
140static void __init sun6i_timer_init(void)
141{
142 of_clk_init(NULL);
143 sun6i_reset_init();
144 clocksource_of_init();
145}
146
135DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family") 147DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family")
136 .init_machine = sunxi_dt_init, 148 .init_machine = sunxi_dt_init,
149 .init_time = sun6i_timer_init,
137 .dt_compat = sun6i_board_dt_compat, 150 .dt_compat = sun6i_board_dt_compat,
138 .restart = sun6i_restart, 151 .restart = sun6i_restart,
152 .smp = smp_ops(sun6i_smp_ops),
139MACHINE_END 153MACHINE_END
140 154
141static const char * const sun7i_board_dt_compat[] = { 155static const char * const sun7i_board_dt_compat[] = {