Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753715AbaBCVbZ (ORCPT ); Mon, 3 Feb 2014 16:31:25 -0500 Received: from mail-qc0-f169.google.com ([209.85.216.169]:47739 "EHLO mail-qc0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753484AbaBCVbU (ORCPT ); Mon, 3 Feb 2014 16:31:20 -0500 From: Marc Carino To: Christian Daudt , Arnd Bergmann , Olof Johansson Cc: Florian Fainelli , Matt Porter , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Marc Carino Subject: [PATCH v6 2/8] power: reset: Add reboot driver for brcmstb Date: Mon, 3 Feb 2014 13:30:35 -0800 Message-Id: <1391463041-15241-3-git-send-email-marc.ceeeee@gmail.com> X-Mailer: git-send-email 1.8.4.4 In-Reply-To: <1391463041-15241-1-git-send-email-marc.ceeeee@gmail.com> References: <1391463041-15241-1-git-send-email-marc.ceeeee@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for reboot functionality on boards with ARM-based Broadcom STB chipsets. Signed-off-by: Marc Carino --- arch/arm/mach-bcm/Kconfig | 1 + drivers/power/reset/Kconfig | 10 +++ drivers/power/reset/Makefile | 1 + drivers/power/reset/brcmstb-reboot.c | 120 ++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 0 deletions(-) create mode 100644 drivers/power/reset/brcmstb-reboot.c diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig index f85e7bc..d8f6d7a 100644 --- a/arch/arm/mach-bcm/Kconfig +++ b/arch/arm/mach-bcm/Kconfig @@ -39,6 +39,7 @@ config ARCH_BRCMSTB select MIGHT_HAVE_PCI select HAVE_SMP select HAVE_ARM_ARCH_TIMER + select POWER_RESET_BRCMSTB help Say Y if you intend to run the kernel on a Broadcom ARM-based STB chipset. diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 6d452a7..c886505 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -12,6 +12,16 @@ config POWER_RESET_AS3722 help This driver supports turning off board via a ams AS3722 power-off. +config POWER_RESET_BRCMSTB + bool "Broadcom STB reset driver" + depends on POWER_RESET && ARCH_BRCMSTB + help + This driver provides restart support for ARM-based Broadcom STB + boards. + + Say Y here if you have an ARM-based Broadcom STB board and you wish + to have restart support. + config POWER_RESET_GPIO bool "GPIO power-off driver" depends on OF_GPIO && POWER_RESET diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index a5b4a77..72bb94f 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o +obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c new file mode 100644 index 0000000..3f23692 --- /dev/null +++ b/drivers/power/reset/brcmstb-reboot.c @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2013 Broadcom Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define RESET_SOURCE_ENABLE_REG 1 +#define SW_MASTER_RESET_REG 2 + +static struct regmap *regmap; +static u32 rst_src_en; +static u32 sw_mstr_rst; + +static void brcmstb_reboot(enum reboot_mode mode, const char *cmd) +{ + int rc; + u32 tmp; + + rc = regmap_write(regmap, rst_src_en, 1); + if (rc) { + pr_err("failed to write rst_src_en (%d)\n", rc); + return; + } + + rc = regmap_read(regmap, rst_src_en, &tmp); + if (rc) { + pr_err("failed to read rst_src_en (%d)\n", rc); + return; + } + + rc = regmap_write(regmap, sw_mstr_rst, 1); + if (rc) { + pr_err("failed to write sw_mstr_rst (%d)\n", rc); + return; + } + + rc = regmap_read(regmap, sw_mstr_rst, &tmp); + if (rc) { + pr_err("failed to read sw_mstr_rst (%d)\n", rc); + return; + } + + while (1) + ; +} + +static int brcmstb_reboot_probe(struct platform_device *pdev) +{ + int rc; + struct device_node *np = pdev->dev.of_node; + + regmap = syscon_regmap_lookup_by_phandle(np, "syscon"); + if (IS_ERR(regmap)) { + pr_err("failed to get syscon phandle\n"); + return -EINVAL; + } + + rc = of_property_read_u32_index(np, "syscon", RESET_SOURCE_ENABLE_REG, + &rst_src_en); + if (rc) { + pr_err("can't get rst_src_en offset (%d)\n", rc); + return -EINVAL; + } + + rc = of_property_read_u32_index(np, "syscon", SW_MASTER_RESET_REG, + &sw_mstr_rst); + if (rc) { + pr_err("can't get sw_mstr_rst offset (%d)\n", rc); + return -EINVAL; + } + + arm_pm_restart = brcmstb_reboot; + + return 0; +} + +static const struct of_device_id of_match[] = { + { .compatible = "brcm,brcmstb-reboot", }, + {}, +}; + +static struct platform_driver brcmstb_reboot_driver = { + .probe = brcmstb_reboot_probe, + .driver = { + .name = "brcmstb-reboot", + .owner = THIS_MODULE, + .of_match_table = of_match, + }, +}; + +static int __init brcmstb_reboot_init(void) +{ + return platform_driver_probe(&brcmstb_reboot_driver, + brcmstb_reboot_probe); +} +subsys_initcall(brcmstb_reboot_init); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/