From patchwork Tue Mar 4 16:17:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 3764411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 18FBB9F35F for ; Tue, 4 Mar 2014 17:45:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B388D20382 for ; Tue, 4 Mar 2014 17:45:31 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 16E9020374 for ; Tue, 4 Mar 2014 17:45:30 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKs8i-0004ol-Gz; Tue, 04 Mar 2014 16:24:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKs8A-0001YD-7f; Tue, 04 Mar 2014 16:23:46 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WKs5b-0001A3-5P for linux-arm-kernel@lists.infradead.org; Tue, 04 Mar 2014 16:21:19 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 908D88A0; Tue, 4 Mar 2014 17:20:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id 7A32F8A0; Tue, 4 Mar 2014 17:20:04 +0100 (CET) From: Maxime Ripard To: Emilio Lopez , Dan Williams , Vinod Koul Subject: [PATCH v3 2/7] ARM: sunxi: Split out the various machines into separate files Date: Tue, 4 Mar 2014 17:17:59 +0100 Message-Id: <1393949884-892-3-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393949884-892-1-git-send-email-maxime.ripard@free-electrons.com> References: <1393949884-892-1-git-send-email-maxime.ripard@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140304_112108_034451_97BCFD1D X-CRM114-Status: GOOD ( 19.97 ) X-Spam-Score: 1.8 (+) Cc: devicetree@vger.kernel.org, Mike Turquette , andriy.shevchenko@intel.com, linux-kernel@vger.kernel.org, zhuzhenhua@allwinnertech.com, shuge@allwinnertech.com, linux-sunxi@googlegroups.com, kevin.z.m.zh@gmail.com, sunny@allwinnertech.com, dmaengine@vger.kernel.org, Maxime Ripard , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Level: * X-Virus-Scanned: ClamAV using ClamSMTP This will allow to add per-SoC hooks more easily. Signed-off-by: Maxime Ripard --- arch/arm/mach-sunxi/Makefile | 6 +- arch/arm/mach-sunxi/restart.c | 104 +++++++++++++++++++++++++++ arch/arm/mach-sunxi/restart.h | 20 ++++++ arch/arm/mach-sunxi/sun4i.c | 36 ++++++++++ arch/arm/mach-sunxi/sun5i.c | 37 ++++++++++ arch/arm/mach-sunxi/sun6i.c | 49 +++++++++++++ arch/arm/mach-sunxi/sun7i.c | 36 ++++++++++ arch/arm/mach-sunxi/sunxi.c | 164 ------------------------------------------ 8 files changed, 287 insertions(+), 165 deletions(-) create mode 100644 arch/arm/mach-sunxi/restart.c create mode 100644 arch/arm/mach-sunxi/restart.h create mode 100644 arch/arm/mach-sunxi/sun4i.c create mode 100644 arch/arm/mach-sunxi/sun5i.c create mode 100644 arch/arm/mach-sunxi/sun6i.c create mode 100644 arch/arm/mach-sunxi/sun7i.c delete mode 100644 arch/arm/mach-sunxi/sunxi.c diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile index d939720..6b3d36f 100644 --- a/arch/arm/mach-sunxi/Makefile +++ b/arch/arm/mach-sunxi/Makefile @@ -1,2 +1,6 @@ -obj-$(CONFIG_ARCH_SUNXI) += sunxi.o +obj-$(CONFIG_ARCH_SUNXI) += restart.o +obj-$(CONFIG_ARCH_SUNXI) += sun4i.o +obj-$(CONFIG_ARCH_SUNXI) += sun5i.o +obj-$(CONFIG_ARCH_SUNXI) += sun6i.o +obj-$(CONFIG_ARCH_SUNXI) += sun7i.o obj-$(CONFIG_SMP) += platsmp.o headsmp.o diff --git a/arch/arm/mach-sunxi/restart.c b/arch/arm/mach-sunxi/restart.c new file mode 100644 index 0000000..60c2d5c --- /dev/null +++ b/arch/arm/mach-sunxi/restart.c @@ -0,0 +1,104 @@ +/* + * Restart code for Allwinner SoCs + * + * Copyright (C) 2012-2014 Maxime Ripard + * + * Maxime Ripard + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include + +#include "restart.h" + +#define SUN4I_WATCHDOG_CTRL_REG 0x00 +#define SUN4I_WATCHDOG_CTRL_RESTART BIT(0) +#define SUN4I_WATCHDOG_MODE_REG 0x04 +#define SUN4I_WATCHDOG_MODE_ENABLE BIT(0) +#define SUN4I_WATCHDOG_MODE_RESET_ENABLE BIT(1) + +#define SUN6I_WATCHDOG1_IRQ_REG 0x00 +#define SUN6I_WATCHDOG1_CTRL_REG 0x10 +#define SUN6I_WATCHDOG1_CTRL_RESTART BIT(0) +#define SUN6I_WATCHDOG1_CONFIG_REG 0x14 +#define SUN6I_WATCHDOG1_CONFIG_RESTART BIT(0) +#define SUN6I_WATCHDOG1_CONFIG_IRQ BIT(1) +#define SUN6I_WATCHDOG1_MODE_REG 0x18 +#define SUN6I_WATCHDOG1_MODE_ENABLE BIT(0) + +static void __iomem *wdt_base; + +void sun4i_restart(enum reboot_mode mode, const char *cmd) +{ + if (!wdt_base) + return; + + /* Enable timer and set reset bit in the watchdog */ + writel(SUN4I_WATCHDOG_MODE_ENABLE | SUN4I_WATCHDOG_MODE_RESET_ENABLE, + wdt_base + SUN4I_WATCHDOG_MODE_REG); + + /* + * Restart the watchdog. The default (and lowest) interval + * value for the watchdog is 0.5s. + */ + writel(SUN4I_WATCHDOG_CTRL_RESTART, wdt_base + SUN4I_WATCHDOG_CTRL_REG); + + while (1) { + mdelay(5); + writel(SUN4I_WATCHDOG_MODE_ENABLE | SUN4I_WATCHDOG_MODE_RESET_ENABLE, + wdt_base + SUN4I_WATCHDOG_MODE_REG); + } +} + +void sun6i_restart(enum reboot_mode mode, const char *cmd) +{ + if (!wdt_base) + return; + + /* Disable interrupts */ + writel(0, wdt_base + SUN6I_WATCHDOG1_IRQ_REG); + + /* We want to disable the IRQ and just reset the whole system */ + writel(SUN6I_WATCHDOG1_CONFIG_RESTART, + wdt_base + SUN6I_WATCHDOG1_CONFIG_REG); + + /* Enable timer. The default and lowest interval value is 0.5s */ + writel(SUN6I_WATCHDOG1_MODE_ENABLE, + wdt_base + SUN6I_WATCHDOG1_MODE_REG); + + /* Restart the watchdog. */ + writel(SUN6I_WATCHDOG1_CTRL_RESTART, + wdt_base + SUN6I_WATCHDOG1_CTRL_REG); + + while (1) { + mdelay(5); + writel(SUN6I_WATCHDOG1_MODE_ENABLE, + wdt_base + SUN6I_WATCHDOG1_MODE_REG); + } +} + +static struct of_device_id sunxi_restart_ids[] = { + { .compatible = "allwinner,sun4i-wdt" }, + { .compatible = "allwinner,sun6i-wdt" }, + { /*sentinel*/ } +}; + +void sunxi_setup_restart(void) +{ + struct device_node *np; + + np = of_find_matching_node(NULL, sunxi_restart_ids); + if (WARN(!np, "unable to setup watchdog restart")) + return; + + wdt_base = of_iomap(np, 0); + WARN(!wdt_base, "failed to map watchdog base address"); +} diff --git a/arch/arm/mach-sunxi/restart.h b/arch/arm/mach-sunxi/restart.h new file mode 100644 index 0000000..ef039db --- /dev/null +++ b/arch/arm/mach-sunxi/restart.h @@ -0,0 +1,20 @@ +/* + * Restart code for Allwinner SoCs + * + * Copyright (C) 2012-2014 Maxime Ripard + * + * Maxime Ripard + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#ifndef _SUNXI_RESTART_H_ +#define _SUNXI_RESTART_H_ + +void sun4i_restart(enum reboot_mode mode, const char *cmd); +void sun6i_restart(enum reboot_mode mode, const char *cmd); +void sunxi_setup_restart(void); + +#endif diff --git a/arch/arm/mach-sunxi/sun4i.c b/arch/arm/mach-sunxi/sun4i.c new file mode 100644 index 0000000..fc28b89 --- /dev/null +++ b/arch/arm/mach-sunxi/sun4i.c @@ -0,0 +1,36 @@ +/* + * Device Tree support for Allwinner A10 SoCs + * + * Copyright (C) 2012-2014 Maxime Ripard + * + * Maxime Ripard + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include + +#include + +#include "restart.h" + +static void __init sun4i_dt_init(void) +{ + sunxi_setup_restart(); + + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); +} + +static const char * const sun4i_board_dt_compat[] = { + "allwinner,sun4i-a10", + NULL, +}; + +DT_MACHINE_START(SUN4I_DT, "Allwinner sun4i (A10) Family") + .init_machine = sun4i_dt_init, + .dt_compat = sun4i_board_dt_compat, + .restart = sun4i_restart, +MACHINE_END diff --git a/arch/arm/mach-sunxi/sun5i.c b/arch/arm/mach-sunxi/sun5i.c new file mode 100644 index 0000000..623a95a --- /dev/null +++ b/arch/arm/mach-sunxi/sun5i.c @@ -0,0 +1,37 @@ +/* + * Device Tree support for Allwinner A20 SoCs + * + * Copyright (C) 2013-2014 Maxime Ripard + * + * Maxime Ripard + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include + +#include + +#include "restart.h" + +static void __init sun5i_dt_init(void) +{ + sunxi_setup_restart(); + + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); +} + +static const char * const sun5i_board_dt_compat[] = { + "allwinner,sun5i-a10s", + "allwinner,sun5i-a13", + NULL, +}; + +DT_MACHINE_START(SUN5I_DT, "Allwinner sun5i (A13/A10s) Family") + .init_machine = sun5i_dt_init, + .dt_compat = sun5i_board_dt_compat, + .restart = sun4i_restart, +MACHINE_END diff --git a/arch/arm/mach-sunxi/sun6i.c b/arch/arm/mach-sunxi/sun6i.c new file mode 100644 index 0000000..c5dc819 --- /dev/null +++ b/arch/arm/mach-sunxi/sun6i.c @@ -0,0 +1,49 @@ +/* + * Device Tree support for Allwinner A31 SoCs + * + * Copyright (C) 2013-2014 Maxime Ripard + * + * Maxime Ripard + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include + +#include + +#include "common.h" +#include "restart.h" + +static void __init sun6i_dt_init(void) +{ + sunxi_setup_restart(); + + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); +} + +extern void __init sun6i_reset_init(void); +static void __init sun6i_timer_init(void) +{ + of_clk_init(NULL); + sun6i_reset_init(); + clocksource_of_init(); +} + +static const char * const sun6i_board_dt_compat[] = { + "allwinner,sun6i-a31", + NULL, +}; + +DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family") + .init_machine = sun6i_dt_init, + .init_time = sun6i_timer_init, + .dt_compat = sun6i_board_dt_compat, + .restart = sun6i_restart, + .smp = smp_ops(sun6i_smp_ops), +MACHINE_END diff --git a/arch/arm/mach-sunxi/sun7i.c b/arch/arm/mach-sunxi/sun7i.c new file mode 100644 index 0000000..2e6a8ee --- /dev/null +++ b/arch/arm/mach-sunxi/sun7i.c @@ -0,0 +1,36 @@ +/* + * Device Tree support for Allwinner A20 SoCs + * + * Copyright (C) 2013-2014 Maxime Ripard + * + * Maxime Ripard + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include + +#include + +#include "restart.h" + +static void __init sun7i_dt_init(void) +{ + sunxi_setup_restart(); + + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); +} + +static const char * const sun7i_board_dt_compat[] = { + "allwinner,sun7i-a20", + NULL, +}; + +DT_MACHINE_START(SUN7I_DT, "Allwinner sun7i (A20) Family") + .init_machine = sun7i_dt_init, + .dt_compat = sun7i_board_dt_compat, + .restart = sun4i_restart, +MACHINE_END diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c deleted file mode 100644 index aeea6ce..0000000 --- a/arch/arm/mach-sunxi/sunxi.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Device Tree support for Allwinner A1X SoCs - * - * Copyright (C) 2012 Maxime Ripard - * - * Maxime Ripard - * - * This file is licensed under the terms of the GNU General Public - * License version 2. This program is licensed "as is" without any - * warranty of any kind, whether express or implied. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "common.h" - -#define SUN4I_WATCHDOG_CTRL_REG 0x00 -#define SUN4I_WATCHDOG_CTRL_RESTART BIT(0) -#define SUN4I_WATCHDOG_MODE_REG 0x04 -#define SUN4I_WATCHDOG_MODE_ENABLE BIT(0) -#define SUN4I_WATCHDOG_MODE_RESET_ENABLE BIT(1) - -#define SUN6I_WATCHDOG1_IRQ_REG 0x00 -#define SUN6I_WATCHDOG1_CTRL_REG 0x10 -#define SUN6I_WATCHDOG1_CTRL_RESTART BIT(0) -#define SUN6I_WATCHDOG1_CONFIG_REG 0x14 -#define SUN6I_WATCHDOG1_CONFIG_RESTART BIT(0) -#define SUN6I_WATCHDOG1_CONFIG_IRQ BIT(1) -#define SUN6I_WATCHDOG1_MODE_REG 0x18 -#define SUN6I_WATCHDOG1_MODE_ENABLE BIT(0) - -static void __iomem *wdt_base; - -static void sun4i_restart(enum reboot_mode mode, const char *cmd) -{ - if (!wdt_base) - return; - - /* Enable timer and set reset bit in the watchdog */ - writel(SUN4I_WATCHDOG_MODE_ENABLE | SUN4I_WATCHDOG_MODE_RESET_ENABLE, - wdt_base + SUN4I_WATCHDOG_MODE_REG); - - /* - * Restart the watchdog. The default (and lowest) interval - * value for the watchdog is 0.5s. - */ - writel(SUN4I_WATCHDOG_CTRL_RESTART, wdt_base + SUN4I_WATCHDOG_CTRL_REG); - - while (1) { - mdelay(5); - writel(SUN4I_WATCHDOG_MODE_ENABLE | SUN4I_WATCHDOG_MODE_RESET_ENABLE, - wdt_base + SUN4I_WATCHDOG_MODE_REG); - } -} - -static void sun6i_restart(enum reboot_mode mode, const char *cmd) -{ - if (!wdt_base) - return; - - /* Disable interrupts */ - writel(0, wdt_base + SUN6I_WATCHDOG1_IRQ_REG); - - /* We want to disable the IRQ and just reset the whole system */ - writel(SUN6I_WATCHDOG1_CONFIG_RESTART, - wdt_base + SUN6I_WATCHDOG1_CONFIG_REG); - - /* Enable timer. The default and lowest interval value is 0.5s */ - writel(SUN6I_WATCHDOG1_MODE_ENABLE, - wdt_base + SUN6I_WATCHDOG1_MODE_REG); - - /* Restart the watchdog. */ - writel(SUN6I_WATCHDOG1_CTRL_RESTART, - wdt_base + SUN6I_WATCHDOG1_CTRL_REG); - - while (1) { - mdelay(5); - writel(SUN6I_WATCHDOG1_MODE_ENABLE, - wdt_base + SUN6I_WATCHDOG1_MODE_REG); - } -} - -static struct of_device_id sunxi_restart_ids[] = { - { .compatible = "allwinner,sun4i-wdt" }, - { .compatible = "allwinner,sun6i-wdt" }, - { /*sentinel*/ } -}; - -static void sunxi_setup_restart(void) -{ - struct device_node *np; - - np = of_find_matching_node(NULL, sunxi_restart_ids); - 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 __init sunxi_dt_init(void) -{ - sunxi_setup_restart(); - - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -} - -static const char * const sunxi_board_dt_compat[] = { - "allwinner,sun4i-a10", - "allwinner,sun5i-a10s", - "allwinner,sun5i-a13", - NULL, -}; - -DT_MACHINE_START(SUNXI_DT, "Allwinner A1X (Device Tree)") - .init_machine = sunxi_dt_init, - .dt_compat = sunxi_board_dt_compat, - .restart = sun4i_restart, -MACHINE_END - -static const char * const sun6i_board_dt_compat[] = { - "allwinner,sun6i-a31", - NULL, -}; - -extern void __init sun6i_reset_init(void); -static void __init sun6i_timer_init(void) -{ - of_clk_init(NULL); - sun6i_reset_init(); - clocksource_of_init(); -} - -DT_MACHINE_START(SUN6I_DT, "Allwinner sun6i (A31) Family") - .init_machine = sunxi_dt_init, - .init_time = sun6i_timer_init, - .dt_compat = sun6i_board_dt_compat, - .restart = sun6i_restart, - .smp = smp_ops(sun6i_smp_ops), -MACHINE_END - -static const char * const sun7i_board_dt_compat[] = { - "allwinner,sun7i-a20", - NULL, -}; - -DT_MACHINE_START(SUN7I_DT, "Allwinner sun7i (A20) Family") - .init_machine = sunxi_dt_init, - .dt_compat = sun7i_board_dt_compat, - .restart = sun4i_restart, -MACHINE_END