diff options
| author | Olof Johansson <olof@lixom.net> | 2014-01-04 00:43:05 -0500 |
|---|---|---|
| committer | Olof Johansson <olof@lixom.net> | 2014-01-04 00:43:05 -0500 |
| commit | 7bfc397fe76de447ca645edd7453d8ef6ab18279 (patch) | |
| tree | 1f3f7b5ca66ca76d46a4ad8b86fd279b7fd3b8d3 | |
| parent | a7dedb4fead89f88255862a9bc46f4c7ec094c2e (diff) | |
| parent | 73346794b48237b7b4c2a5c02b12e3c4f1da7551 (diff) | |
Merge tag 'sunxi-core-for-3.14' of https://github.com/mripard/linux into next/drivers
From Maxime Ripard:
Allwinner core changes for 3.14
This mostly adds the reset controller initialisation for the A31 and the SMP
operations for this SoC.
* tag 'sunxi-core-for-3.14' of https://github.com/mripard/linux:
ARM: sun6i: Add SMP support for the Allwinner A31
dt-bindings: fix example of allwinner interrupt controller
ARM: sunxi: Register the A31 reset IP in init_time
ARM: sunxi: Select ARCH_HAS_RESET_CONTROLLER
Signed-off-by: Olof Johansson <olof@lixom.net>
| -rw-r--r-- | Documentation/devicetree/bindings/interrupt-controller/allwinner,sun4i-ic.txt | 2 | ||||
| -rw-r--r-- | arch/arm/mach-sunxi/Kconfig | 1 | ||||
| -rw-r--r-- | arch/arm/mach-sunxi/Makefile | 1 | ||||
| -rw-r--r-- | arch/arm/mach-sunxi/common.h | 19 | ||||
| -rw-r--r-- | arch/arm/mach-sunxi/headsmp.S | 9 | ||||
| -rw-r--r-- | arch/arm/mach-sunxi/platsmp.c | 124 | ||||
| -rw-r--r-- | arch/arm/mach-sunxi/sunxi.c | 14 |
7 files changed, 169 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun4i-ic.txt b/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun4i-ic.txt index 3d3b2b91e333..32cec4b26cd0 100644 --- a/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun4i-ic.txt +++ b/Documentation/devicetree/bindings/interrupt-controller/allwinner,sun4i-ic.txt | |||
| @@ -14,5 +14,5 @@ intc: interrupt-controller { | |||
| 14 | compatible = "allwinner,sun4i-ic"; | 14 | compatible = "allwinner,sun4i-ic"; |
| 15 | reg = <0x01c20400 0x400>; | 15 | reg = <0x01c20400 0x400>; |
| 16 | interrupt-controller; | 16 | interrupt-controller; |
| 17 | #interrupt-cells = <2>; | 17 | #interrupt-cells = <1>; |
| 18 | }; | 18 | }; |
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig index c9e72c89066a..e3457b94b024 100644 --- a/arch/arm/mach-sunxi/Kconfig +++ b/arch/arm/mach-sunxi/Kconfig | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | config ARCH_SUNXI | 1 | config 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 |
| 5 | select CLKSRC_MMIO | 6 | select CLKSRC_MMIO |
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 @@ | |||
| 1 | obj-$(CONFIG_ARCH_SUNXI) += sunxi.o | 1 | obj-$(CONFIG_ARCH_SUNXI) += sunxi.o |
| 2 | obj-$(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 | |||
| 16 | void sun6i_secondary_startup(void); | ||
| 17 | extern 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 | |||
| 6 | ENTRY(sun6i_secondary_startup) | ||
| 7 | msr cpsr_fsxc, #0xd3 | ||
| 8 | b secondary_startup | ||
| 9 | ENDPROC(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 | |||
| 39 | static void __iomem *cpucfg_membase; | ||
| 40 | static void __iomem *prcm_membase; | ||
| 41 | |||
| 42 | static DEFINE_SPINLOCK(cpu_lock); | ||
| 43 | |||
| 44 | static 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 | |||
| 73 | static 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 | |||
| 121 | struct 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 | ||
| 139 | extern void __init sun6i_reset_init(void); | ||
| 140 | static void __init sun6i_timer_init(void) | ||
| 141 | { | ||
| 142 | of_clk_init(NULL); | ||
| 143 | sun6i_reset_init(); | ||
| 144 | clocksource_of_init(); | ||
| 145 | } | ||
| 146 | |||
| 135 | DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family") | 147 | DT_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), | ||
| 139 | MACHINE_END | 153 | MACHINE_END |
| 140 | 154 | ||
| 141 | static const char * const sun7i_board_dt_compat[] = { | 155 | static const char * const sun7i_board_dt_compat[] = { |
