From patchwork Mon Jul 21 21:07:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 4598351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CD07AC0514 for ; Mon, 21 Jul 2014 21:13:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D279620123 for ; Mon, 21 Jul 2014 21:13:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 DF4AE20109 for ; Mon, 21 Jul 2014 21:13:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9Kqh-0004fM-AA; Mon, 21 Jul 2014 21:10:19 +0000 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X9Kq8-0002b5-86 for linux-arm-kernel@lists.infradead.org; Mon, 21 Jul 2014 21:09:45 +0000 Received: by mail-pd0-f174.google.com with SMTP id fp1so9765906pdb.5 for ; Mon, 21 Jul 2014 14:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p8FjC3PrfuoztAmxLYhNtT7mdantYXod4AC9NsLVZiA=; b=xMwO95JkLAw+Ygd7GS7CfhPTHNjzDmOpbb3L1V1lHmup+su/NfpV/yCL5X0mR/TZAu /dPXJP1hyGScCMOhXCcefnezXGIaUqhN52hS/ID4OfYPLPs6AMYteHTIMsyLDnJ7m479 uVfp2irhlYimwsRLsiRiw4kYC/12VYV0QUDZCDAQtmbEj/Vmf42gbNpN/pp0wn3kIZUf gUR/zajzxy5/HOvmcJZIzrsM+8Gt7LR5GKde9ipXKpU8L6CA48eF59cYcNpoZ50ISz7s jNx5u3Wmy5rSrVo2ENxcrMeLAb6iw2fyndKUCfDlp26fj/Htob/94k46wquPB++GjaAl eUAQ== X-Received: by 10.70.102.66 with SMTP id fm2mr28312309pdb.102.1405976961935; Mon, 21 Jul 2014 14:09:21 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id c17sm20387643pdm.33.2014.07.21.14.09.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jul 2014 14:09:21 -0700 (PDT) From: Brian Norris To: Arnd Bergmann , Olof Johansson Subject: [PATCH v8 02/11] power: reset: Add reboot driver for brcmstb Date: Mon, 21 Jul 2014 14:07:57 -0700 Message-Id: <1405976886-27807-3-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405976886-27807-1-git-send-email-computersforpeace@gmail.com> References: <1405976886-27807-1-git-send-email-computersforpeace@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140721_140944_330779_D802B122 X-CRM114-Status: GOOD ( 18.99 ) X-Spam-Score: -0.8 (/) Cc: devicetree@vger.kernel.org, Florian Fainelli , Russell King , Dmitry Eremin-Solenikov , Christian Daudt , Linux Kernel , Matt Porter , Marc Carino , Gregory Fong , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Carino Add support for reboot functionality on boards with ARM-based Broadcom STB chipsets. Signed-off-by: Marc Carino Signed-off-by: Brian Norris Cc: Dmitry Eremin-Solenikov Cc: David Woodhouse --- 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(+) create mode 100644 drivers/power/reset/brcmstb-reboot.c diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig index 0073633e7699..9782e8d80647 100644 --- a/arch/arm/mach-bcm/Kconfig +++ b/arch/arm/mach-bcm/Kconfig @@ -94,6 +94,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 bdcf5173e377..fcb9825debe5 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -20,6 +20,16 @@ config POWER_RESET_AXXIA Say Y if you have an Axxia family SoC. +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 dde2e8bbac53..7379818ca69d 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o +obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o diff --git a/drivers/power/reset/brcmstb-reboot.c b/drivers/power/reset/brcmstb-reboot.c new file mode 100644 index 000000000000..3f236924742a --- /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);