From de0bf33fc2b0b1d4b1419adf645fb36e9e52781a Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Mon, 19 Nov 2012 12:09:40 +0100 Subject: [PATCH 1/4] ARM: sunxi: Restructure sunxi dts/dtsi files For the new sun4i/Cubieboard (A10) support, lets re-strucure the sun5i dts files to make it more generic. Those are the new dts/dtsi files: sunxi.dtsi - Devices common to all Allwinner sunXi SoC's sun4i.dtsi - sun4i Devices, will include sunxi.dtsi sun5i.dtsi - sun5i Devices, will include sunxi.dtsi board.dts - will include either sun4i.dtsi or sun5i.dtsi Additionally the "duart" label in the olinuxino.dts is changed to "uart1". Signed-off-by: Stefan Roese Acked-by: Arnd Bergmann Signed-off-by: Maxime Ripard --- arch/arm/boot/dts/sun5i-olinuxino.dts | 6 ++- arch/arm/boot/dts/sun5i.dtsi | 56 +---------------------- arch/arm/boot/dts/sunxi.dtsi | 66 +++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 56 deletions(-) create mode 100644 arch/arm/boot/dts/sunxi.dtsi diff --git a/arch/arm/boot/dts/sun5i-olinuxino.dts b/arch/arm/boot/dts/sun5i-olinuxino.dts index 3b1cce3af7cb..d6ff889a5d87 100644 --- a/arch/arm/boot/dts/sun5i-olinuxino.dts +++ b/arch/arm/boot/dts/sun5i-olinuxino.dts @@ -18,8 +18,12 @@ model = "Olimex A13-Olinuxino"; compatible = "olimex,a13-olinuxino", "allwinner,sun5i"; + chosen { + bootargs = "earlyprintk console=ttyS0,115200"; + }; + soc { - duart: uart@01c28400 { + uart1: uart@01c28400 { status = "okay"; }; }; diff --git a/arch/arm/boot/dts/sun5i.dtsi b/arch/arm/boot/dts/sun5i.dtsi index 4bedf3e826e8..59a2d265a98e 100644 --- a/arch/arm/boot/dts/sun5i.dtsi +++ b/arch/arm/boot/dts/sun5i.dtsi @@ -11,64 +11,10 @@ * http://www.gnu.org/copyleft/gpl.html */ -/include/ "skeleton.dtsi" +/include/ "sunxi.dtsi" / { - interrupt-parent = <&intc>; - - cpus { - cpu@0 { - compatible = "arm,cortex-a8"; - }; - }; - - chosen { - bootargs = "earlyprintk console=ttyS0,115200"; - }; - memory { reg = <0x40000000 0x20000000>; }; - - clocks { - #address-cells = <1>; - #size-cells = <0>; - - osc: oscillator { - #clock-cells = <0>; - compatible = "fixed-clock"; - clock-frequency = <24000000>; - }; - }; - - soc { - compatible = "simple-bus"; - #address-cells = <1>; - #size-cells = <1>; - reg = <0x01c20000 0x300000>; - ranges; - - timer@01c20c00 { - compatible = "allwinner,sunxi-timer"; - reg = <0x01c20c00 0x400>; - interrupts = <22>; - clocks = <&osc>; - }; - - intc: interrupt-controller@01c20400 { - compatible = "allwinner,sunxi-ic"; - reg = <0x01c20400 0x400>; - interrupt-controller; - #interrupt-cells = <1>; - }; - - uart1: uart@01c28400 { - compatible = "ns8250"; - reg = <0x01c28400 0x400>; - interrupts = <2>; - reg-shift = <2>; - clock-frequency = <24000000>; - status = "disabled"; - }; - }; }; diff --git a/arch/arm/boot/dts/sunxi.dtsi b/arch/arm/boot/dts/sunxi.dtsi new file mode 100644 index 000000000000..9e476deb8809 --- /dev/null +++ b/arch/arm/boot/dts/sunxi.dtsi @@ -0,0 +1,66 @@ +/* + * Copyright 2012 Maxime Ripard + * + * Maxime Ripard + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +/include/ "skeleton.dtsi" + +/ { + interrupt-parent = <&intc>; + + cpus { + cpu@0 { + compatible = "arm,cortex-a8"; + }; + }; + + clocks { + #address-cells = <1>; + #size-cells = <0>; + + osc: oscillator { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <24000000>; + }; + }; + + soc { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x01c20000 0x300000>; + ranges; + + timer@01c20c00 { + compatible = "allwinner,sunxi-timer"; + reg = <0x01c20c00 0x400>; + interrupts = <22>; + clocks = <&osc>; + }; + + intc: interrupt-controller@01c20400 { + compatible = "allwinner,sunxi-ic"; + reg = <0x01c20400 0x400>; + interrupt-controller; + #interrupt-cells = <1>; + }; + + uart1: uart@01c28400 { + compatible = "ns8250"; + reg = <0x01c28400 0x400>; + interrupts = <2>; + reg-shift = <2>; + clock-frequency = <24000000>; + status = "disabled"; + }; + }; +}; From aa25115aff14a149a6b611fe54776c142e483781 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Mon, 19 Nov 2012 12:09:41 +0100 Subject: [PATCH 2/4] ARM: sunxi: Add earlyprintk support for UART0 (sun4i) Signed-off-by: Stefan Roese Acked-by: Arnd Bergmann Signed-off-by: Maxime Ripard --- arch/arm/Kconfig.debug | 9 ++++++++- arch/arm/include/debug/sunxi.S | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug index f12bc3a2c3c0..cc1ed35179a5 100644 --- a/arch/arm/Kconfig.debug +++ b/arch/arm/Kconfig.debug @@ -345,6 +345,13 @@ choice Say Y here if you want kernel low-level debugging support on SOCFPGA based platforms. + config DEBUG_SUNXI_UART0 + bool "Kernel low-level debugging messages via sunXi UART0" + depends on ARCH_SUNXI + help + Say Y here if you want kernel low-level debugging support + on Allwinner A1X based platforms on the UART0. + config DEBUG_SUNXI_UART1 bool "Kernel low-level debugging messages via sunXi UART1" depends on ARCH_SUNXI @@ -423,7 +430,7 @@ config DEBUG_LL_INCLUDE default "debug/mvebu.S" if DEBUG_MVEBU_UART default "debug/picoxcell.S" if DEBUG_PICOXCELL_UART default "debug/socfpga.S" if DEBUG_SOCFPGA_UART - default "debug/sunxi.S" if DEBUG_SUNXI_UART1 + default "debug/sunxi.S" if DEBUG_SUNXI_UART0 || DEBUG_SUNXI_UART1 default "debug/vexpress.S" if DEBUG_VEXPRESS_UART0_DETECT || \ DEBUG_VEXPRESS_UART0_CA9 || DEBUG_VEXPRESS_UART0_RS1 default "mach/debug-macro.S" diff --git a/arch/arm/include/debug/sunxi.S b/arch/arm/include/debug/sunxi.S index 3bf61ca0df75..04eb56d5db2c 100644 --- a/arch/arm/include/debug/sunxi.S +++ b/arch/arm/include/debug/sunxi.S @@ -10,7 +10,10 @@ * published by the Free Software Foundation. */ -#ifdef CONFIG_DEBUG_SUNXI_UART1 +#if defined(CONFIG_DEBUG_SUNXI_UART0) +#define SUNXI_UART_DEBUG_PHYS_BASE 0x01c28000 +#define SUNXI_UART_DEBUG_VIRT_BASE 0xf1c28000 +#elif defined(CONFIG_DEBUG_SUNXI_UART1) #define SUNXI_UART_DEBUG_PHYS_BASE 0x01c28400 #define SUNXI_UART_DEBUG_VIRT_BASE 0xf1c28400 #endif From f055f1f682b84b3b785813f5c11efacab6001253 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Mon, 19 Nov 2012 12:09:42 +0100 Subject: [PATCH 3/4] ARM: sunxi: Add sun4i and cubieboard support This patch adds support for the Cubieboard based on the Allwinner A10/sun4i SoC. Currently only UART is supported. Other devices will eventually follow. Signed-off-by: Stefan Roese Acked-by: Arnd Bergmann Signed-off-by: Maxime Ripard --- arch/arm/boot/dts/Makefile | 3 +- arch/arm/boot/dts/sun4i-cubieboard.dts | 38 ++++++++++++++++++++++++++ arch/arm/boot/dts/sunxi.dtsi | 9 ++++++ arch/arm/mach-sunxi/sunxi.c | 1 + 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 arch/arm/boot/dts/sun4i-cubieboard.dts diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 9b2d3f061f13..4dd567b62d2a 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -84,7 +84,8 @@ dtb-$(CONFIG_ARCH_SPEAR3XX)+= spear300-evb.dtb \ spear310-evb.dtb \ spear320-evb.dtb dtb-$(CONFIG_ARCH_SPEAR6XX)+= spear600-evb.dtb -dtb-$(CONFIG_ARCH_SUNXI) += sun5i-olinuxino.dtb +dtb-$(CONFIG_ARCH_SUNXI) += sun4i-cubieboard.dtb \ + sun5i-olinuxino.dtb dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \ tegra20-medcom-wide.dtb \ tegra20-paz00.dtb \ diff --git a/arch/arm/boot/dts/sun4i-cubieboard.dts b/arch/arm/boot/dts/sun4i-cubieboard.dts new file mode 100644 index 000000000000..f4ca126ad994 --- /dev/null +++ b/arch/arm/boot/dts/sun4i-cubieboard.dts @@ -0,0 +1,38 @@ +/* + * Copyright 2012 Stefan Roese + * Stefan Roese + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +/dts-v1/; +/include/ "sun4i.dtsi" + +/ { + model = "Cubietech Cubieboard"; + compatible = "cubietech,cubieboard", "allwinner,sun4i"; + + aliases { + serial0 = &uart0; + serial1 = &uart1; + }; + + chosen { + bootargs = "earlyprintk console=ttyS0,115200"; + }; + + soc { + uart0: uart@01c28000 { + status = "okay"; + }; + + uart1: uart@01c28400 { + status = "okay"; + }; + }; +}; diff --git a/arch/arm/boot/dts/sunxi.dtsi b/arch/arm/boot/dts/sunxi.dtsi index 9e476deb8809..8284fbd7ddab 100644 --- a/arch/arm/boot/dts/sunxi.dtsi +++ b/arch/arm/boot/dts/sunxi.dtsi @@ -54,6 +54,15 @@ #interrupt-cells = <1>; }; + uart0: uart@01c28000 { + compatible = "ns8250"; + reg = <0x01c28000 0x400>; + interrupts = <1>; + reg-shift = <2>; + clock-frequency = <24000000>; + status = "disabled"; + }; + uart1: uart@01c28400 { compatible = "ns8250"; reg = <0x01c28400 0x400>; diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c index 8f42df8af1da..13d4d96cbc85 100644 --- a/arch/arm/mach-sunxi/sunxi.c +++ b/arch/arm/mach-sunxi/sunxi.c @@ -46,6 +46,7 @@ static void __init sunxi_dt_init(void) } static const char * const sunxi_board_dt_compat[] = { + "allwinner,sun4i", "allwinner,sun5i", NULL, }; From 67bea88dd842deb3ed8327ad101970dbd615ddcb Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Mon, 19 Nov 2012 18:57:08 +0100 Subject: [PATCH 4/4] ARM: sunxi: Add sunxi restart function via onchip watchdog Signed-off-by: Stefan Roese Signed-off-by: Maxime Ripard --- .../bindings/watchdog/sunxi-wdt.txt | 13 +++++++ arch/arm/boot/dts/sunxi.dtsi | 7 +++- arch/arm/mach-sunxi/sunxi.c | 34 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/watchdog/sunxi-wdt.txt diff --git a/Documentation/devicetree/bindings/watchdog/sunxi-wdt.txt b/Documentation/devicetree/bindings/watchdog/sunxi-wdt.txt new file mode 100644 index 000000000000..0b2717775600 --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/sunxi-wdt.txt @@ -0,0 +1,13 @@ +Allwinner sunXi Watchdog timer + +Required properties: + +- compatible : should be "allwinner,sunxi-wdt" +- reg : Specifies base physical address and size of the registers. + +Example: + +wdt: watchdog@01c20c90 { + compatible = "allwinner,sunxi-wdt"; + reg = <0x01c20c90 0x10>; +}; diff --git a/arch/arm/boot/dts/sunxi.dtsi b/arch/arm/boot/dts/sunxi.dtsi index 8284fbd7ddab..8bbc2bfef221 100644 --- a/arch/arm/boot/dts/sunxi.dtsi +++ b/arch/arm/boot/dts/sunxi.dtsi @@ -42,11 +42,16 @@ timer@01c20c00 { compatible = "allwinner,sunxi-timer"; - reg = <0x01c20c00 0x400>; + reg = <0x01c20c00 0x90>; interrupts = <22>; clocks = <&osc>; }; + wdt: watchdog@01c20c90 { + compatible = "allwinner,sunxi-wdt"; + reg = <0x01c20c90 0x10>; + }; + intc: interrupt-controller@01c20400 { compatible = "allwinner,sunxi-ic"; reg = <0x01c20400 0x400>; diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c index 13d4d96cbc85..dc634ae2081f 100644 --- a/arch/arm/mach-sunxi/sunxi.c +++ b/arch/arm/mach-sunxi/sunxi.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,36 @@ #include "sunxi.h" +#define WATCHDOG_CTRL_REG 0x00 +#define WATCHDOG_MODE_REG 0x04 + +static void __iomem *wdt_base; + +static void sunxi_setup_restart(void) +{ + struct device_node *np = of_find_compatible_node(NULL, NULL, + "allwinner,sunxi-wdt"); + if (WARN(!np, "unable to setup watchdog restart")) + return; + + wdt_base = of_iomap(np, 0); + WARN(!wdt_base, "failed to map watchdog base address"); +} + +static void sunxi_restart(char mode, const char *cmd) +{ + if (!wdt_base) + return; + + /* Enable timer and set reset bit in the watchdog */ + writel(3, wdt_base + WATCHDOG_MODE_REG); + writel(0xa57 << 1 | 1, wdt_base + WATCHDOG_CTRL_REG); + while(1) { + mdelay(5); + writel(3, wdt_base + WATCHDOG_MODE_REG); + } +} + static struct map_desc sunxi_io_desc[] __initdata = { { .virtual = (unsigned long) SUNXI_REGS_VIRT_BASE, @@ -42,6 +73,8 @@ void __init sunxi_map_io(void) static void __init sunxi_dt_init(void) { + sunxi_setup_restart(); + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } @@ -56,6 +89,7 @@ DT_MACHINE_START(SUNXI_DT, "Allwinner A1X (Device Tree)") .map_io = sunxi_map_io, .init_irq = sunxi_init_irq, .handle_irq = sunxi_handle_irq, + .restart = sunxi_restart, .timer = &sunxi_timer, .dt_compat = sunxi_board_dt_compat, MACHINE_END