From patchwork Tue Jul 22 23:48:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 4607321 Return-Path: X-Original-To: patchwork-linux-pm@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 B0DD8C0514 for ; Tue, 22 Jul 2014 23:48:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C3DB201B4 for ; Tue, 22 Jul 2014 23:48:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A56920173 for ; Tue, 22 Jul 2014 23:48:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754022AbaGVXsP (ORCPT ); Tue, 22 Jul 2014 19:48:15 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:39442 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753341AbaGVXsO (ORCPT ); Tue, 22 Jul 2014 19:48:14 -0400 Received: by mail-pa0-f47.google.com with SMTP id kx10so491892pab.34 for ; Tue, 22 Jul 2014 16:48:14 -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; bh=5K12ozsOXP63XoyxcIDNUWHlLTC7EMEKfRzJ7W+NFUo=; b=rwqgjfhbyqrYc87h9CWfUGKu4kofyGj2tragwL5+nT+wuZ1pVWghV4rcRx2dptEoii 7MoMpULx+7HamS9BEuOmUrfnmc0OYQIYoHzqA8goO+6rrBQWwfJvHL9pfX1y8lta90yb zqcAtdQloEB6H4GNZQXd4IsVVfYU5yUeCElj9NplpEchw3W+7uTHbmZILqsTVHfEdWWX WkPnldvKxDRUG6WfIv5mKYL0Plafz0LIxu2n92RuA8LpNzGP8SEzUoxwiAHkBwjG1i62 QWoGZJGVAYDWVRvZfaAhOfNqybCge38dvFUDgUNg4T4zsGLPSajOz0hJzt3umu2eyUK4 PLdQ== X-Received: by 10.70.54.162 with SMTP id k2mr5496426pdp.138.1406072893965; Tue, 22 Jul 2014 16:48:13 -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 y4sm368082pbt.60.2014.07.22.16.48.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Jul 2014 16:48:13 -0700 (PDT) From: Brian Norris To: Sebastian Reichel Cc: Brian Norris , Gregory Fong , Linux Kernel , Marc Carino , Matt Porter , Dmitry Eremin-Solenikov , David Woodhouse , linux-pm@vger.kernel.org Subject: [PATCH v9] power: reset: Add reboot driver for brcmstb Date: Tue, 22 Jul 2014 16:48:03 -0700 Message-Id: <1406072883-16035-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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. Make it built-in by default for ARCH_BRCMSTB, but allow it to be configurable under COMPILE_TEST. Signed-off-by: Marc Carino Signed-off-by: Brian Norris Cc: Sebastian Reichel Cc: Dmitry Eremin-Solenikov Cc: David Woodhouse Cc: linux-pm@vger.kernel.org Signed-off-by: Brian Norris --- Hi Sebastian, can you merge this, or else defer this to Matt? This driver is mostly unchanged for a while, but it hasn't gotten an Ack from any PM guys. It is now separated from the rest of its accompanying series: https://lkml.org/lkml/2014/7/21/647 https://lkml.org/lkml/2014/7/21/801 The DT bindings have gotten review somewhere in the course of 8 versions. drivers/power/reset/Kconfig | 11 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/brcmstb-reboot.c | 120 +++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 drivers/power/reset/brcmstb-reboot.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index bdcf5173e377..f2ac54df496f 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -20,6 +20,17 @@ config POWER_RESET_AXXIA Say Y if you have an Axxia family SoC. +config POWER_RESET_BRCMSTB + bool "Broadcom STB reset driver" if COMPILE_TEST + depends on POWER_RESET && ARM + default 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);