From patchwork Wed Mar 25 00:17:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 6087001 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C07CC9F318 for ; Wed, 25 Mar 2015 00:21:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDCCC202A1 for ; Wed, 25 Mar 2015 00:21:22 +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 EA7082027D for ; Wed, 25 Mar 2015 00:21:21 +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 1YaZ2p-0003IU-Uk; Wed, 25 Mar 2015 00:19:39 +0000 Received: from mail-pd0-x234.google.com ([2607:f8b0:400e:c02::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YaZ1q-0002pv-Cq for linux-arm-kernel@lists.infradead.org; Wed, 25 Mar 2015 00:18:40 +0000 Received: by pdbni2 with SMTP id ni2so9602171pdb.1 for ; Tue, 24 Mar 2015 17:18:15 -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=zQ4mxsTVfAKpPa8IQSYW8/M35UzXzvfaOfbjlpj+wbo=; b=ZnhFIvMSvDVLO3KvsJ37COl9AFn3HcqnWyX1Q0yQCo9EmoMSIPKWjUU7zvTjHflp2u aTYK7lzwOqYBHPcW0ltyCo2DXhcNk7kcePDDqCNqLxxRj+rvb2djrOEtrWG6j0D+jPxQ dEKFZH59zwSVbaVUGLdANNteW+1jFJvuPkxGAr4rIN2RotAYNUWr65S8wnwGGkm16+Y0 dn6kyRHi91mJXkJEqwdi3ceWck/w0HiPPczF9gWXAZc73N/DKbMQ7QENHfy2i/xfuM9d Of2++9+BnhHgJPvg8VOqnnEgURN+FYC6UPkxHgn/NUCY5K4IHt4XZp6tHQMST0rSrgIn kH7w== X-Received: by 10.68.87.35 with SMTP id u3mr11775029pbz.127.1427242695772; Tue, 24 Mar 2015 17:18:15 -0700 (PDT) Received: from fainelli-desktop.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id nj5sm478428pdb.35.2015.03.24.17.18.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Mar 2015 17:18:15 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Subject: [PATCH 2/3] power: reset: add Broadcom BCM63xx software reset driver Date: Tue, 24 Mar 2015 17:17:11 -0700 Message-Id: <1427242632-7971-3-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1427242632-7971-1-git-send-email-f.fainelli@gmail.com> References: <1427242632-7971-1-git-send-email-f.fainelli@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150324_171838_522293_6B8E5CF8 X-CRM114-Status: GOOD ( 17.56 ) X-Spam-Score: -0.8 (/) Cc: Florian Fainelli , linux-pm@vger.kernel.org, Dmitry Eremin-Solenikov , cernekee@gmail.com, Sebastian Reichel , jogo@openwrt.org, bcm-kernel-feedback-list@broadcom.com, gregory.0xf0@gmail.com, computersforpeace@gmail.com, 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=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Add a sofware reset driver for the Broadcom BCM63xx DSL SoCs, starting with 6328 all the way through newer chips such as 63138. Signed-off-by: Florian Fainelli --- drivers/power/reset/Kconfig | 7 ++++ drivers/power/reset/Makefile | 1 + drivers/power/reset/bcm63xx-reboot.c | 80 ++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 drivers/power/reset/bcm63xx-reboot.c diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig index 27f6646731b0..c20c76870f42 100644 --- a/drivers/power/reset/Kconfig +++ b/drivers/power/reset/Kconfig @@ -38,6 +38,13 @@ config POWER_RESET_AXXIA Say Y if you have an Axxia family SoC. +config POWER_RESET_BCM63XX + bool "Broadcom BCM63xx reset driver" + depends on ARM || MIPS || COMPILE_TEST + default ARCH_BCM_63XX + help + This driver provides restart support for the Broadcom DSL SoCs. + config POWER_RESET_BRCMSTB bool "Broadcom STB reset driver" depends on ARM || MIPS || COMPILE_TEST diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile index 11de15bae52e..7d28eaff4cd1 100644 --- a/drivers/power/reset/Makefile +++ b/drivers/power/reset/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o obj-$(CONFIG_POWER_RESET_AT91_POWEROFF) += at91-poweroff.o obj-$(CONFIG_POWER_RESET_AT91_RESET) += at91-reset.o obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o +obj-$(CONFIG_POWER_RESET_BCM63XX) += bcm63xx-reboot.o obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o diff --git a/drivers/power/reset/bcm63xx-reboot.c b/drivers/power/reset/bcm63xx-reboot.c new file mode 100644 index 000000000000..1e3a93c38784 --- /dev/null +++ b/drivers/power/reset/bcm63xx-reboot.c @@ -0,0 +1,80 @@ +/* + * Broadcom BCM63xx DSL SoCs reboot handler + * + * Copyright (C) 2015, 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 + +static void __iomem *rst_base; + +#define SOFT_RESET BIT(0) + +static int bcm63xx_restart_handler(struct notifier_block *this, + unsigned long mdoe, void *cmd) +{ + u32 reg; + + reg = __raw_readl(rst_base); + reg |= SOFT_RESET; + __raw_writel(reg, rst_base); + + while (1) + ; + + return NOTIFY_DONE; +} + +static struct notifier_block bcm63xx_restart_nb = { + .notifier_call = bcm63xx_restart_handler, + .priority = 128, +}; + +#ifdef CONFIG_OF +static const struct of_device_id bcm63xx_reboot_of_match[] = { + { .compatible = "brcm,bcm6328-soft-reset", }, + { /* sentinel */ }, +}; +#endif + +static int bcm63xx_reboot_probe(struct platform_device *pdev) +{ + struct resource *r; + + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + rst_base = devm_ioremap_resource(&pdev->dev, r); + if (IS_ERR(rst_base)) { + dev_err(&pdev->dev, "failed to remap registers\n"); + return PTR_ERR(rst_base); + } + + return register_restart_handler(&bcm63xx_restart_nb); +} + +static struct platform_driver bcm63xx_reboot_driver = { + .probe = bcm63xx_reboot_probe, + .driver = { + .name = "bcm63xx-soft-reset", + .of_match_table = of_match_ptr(bcm63xx_reboot_of_match), + }, +}; + +static int __init bcm63xx_reboot_init(void) +{ + return platform_driver_probe(&bcm63xx_reboot_driver, + bcm63xx_reboot_probe); +} +subsys_initcall(bcm63xx_reboot_init);