From: Sebastian Reichel <sre@kernel.org>
To: Michel Pollet <michel.pollet@bp.renesas.com>
Cc: linux-renesas-soc@vger.kernel.org,
Simon Horman <horms@verge.net.au>,
phil.edworthy@renesas.com,
Michel Pollet <buserror+upstream@gmail.com>,
Magnus Damm <magnus.damm@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Russell King <linux@armlinux.org.uk>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v5 6/6] reset: Renesas RZ/N1 reboot driver
Date: Wed, 25 Apr 2018 23:37:32 +0200 [thread overview]
Message-ID: <20180425213732.tdmla3kdeuc2jjke@earth.universe> (raw)
In-Reply-To: <1523963101-56725-7-git-send-email-michel.pollet@bp.renesas.com>
[-- Attachment #1: Type: text/plain, Size: 5388 bytes --]
Hi,
On Tue, Apr 17, 2018 at 12:04:21PM +0100, Michel Pollet wrote:
> The Renesas RZ/N1 Family (Part #R9A06G0xx) needs a small driver
> to reboot the Cortex-A7 cores. This driver is a sub driver of
> the sysctrl MFD.
>
> Signed-off-by: Michel Pollet <michel.pollet@bp.renesas.com>
> ---
> drivers/power/reset/Kconfig | 7 +++
> drivers/power/reset/Makefile | 1 +
> drivers/power/reset/rzn1-reboot.c | 96 +++++++++++++++++++++++++++++++++++++++
> 3 files changed, 104 insertions(+)
> create mode 100644 drivers/power/reset/rzn1-reboot.c
>
> diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
> index df58fc8..1416d88 100644
> --- a/drivers/power/reset/Kconfig
> +++ b/drivers/power/reset/Kconfig
> @@ -144,6 +144,13 @@ config POWER_RESET_RESTART
> Instead they restart, and u-boot holds the SoC until the
> user presses a key. u-boot then boots into Linux.
>
> +config POWER_RESET_RZN1
> + bool "Renesas RZ/N1 reboot driver"
> + depends on ARCH_RZN1
> + help
> + This driver allows rebooting the CA7 cores of the
> + Renesas RZ/N1 Family of SoC (Part # R9A06G0xx).
> +
> config POWER_RESET_ST
> bool "ST restart driver"
> depends on ARCH_STI
> diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> index 7778c74..bad9702 100644
> --- a/drivers/power/reset/Makefile
> +++ b/drivers/power/reset/Makefile
> @@ -16,6 +16,7 @@ obj-$(CONFIG_POWER_RESET_PIIX4_POWEROFF) += piix4-poweroff.o
> obj-$(CONFIG_POWER_RESET_LTC2952) += ltc2952-poweroff.o
> obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
> obj-$(CONFIG_POWER_RESET_RESTART) += restart-poweroff.o
> +obj-$(CONFIG_POWER_RESET_RZN1) += rzn1-reboot.o
> obj-$(CONFIG_POWER_RESET_ST) += st-poweroff.o
> obj-$(CONFIG_POWER_RESET_VERSATILE) += arm-versatile-reboot.o
> obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
> diff --git a/drivers/power/reset/rzn1-reboot.c b/drivers/power/reset/rzn1-reboot.c
> new file mode 100644
> index 0000000..43876d5
> --- /dev/null
> +++ b/drivers/power/reset/rzn1-reboot.c
> @@ -0,0 +1,96 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * RZ/N1 reboot driver
> + *
> + * Copyright (C) 2018 Renesas Electronics Europe Limited
> + *
> + * Michel Pollet <michel.pollet@bp.renesas.com>, <buserror@gmail.com>
> + * Derived from zx-reboot.c
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/notifier.h>
> +#include <linux/of_address.h>
> +#include <linux/platform_device.h>
> +#include <linux/reboot.h>
> +
> +/* Definitions from the SDK rzn1-sysctrl.h autogenerated file */
> +#define RZN1_SYSCTRL_REG_RSTEN_MRESET_EN 0
> +#define RZN1_SYSCTRL_REG_RSTEN_WDA7RST_EN 1
> +#define RZN1_SYSCTRL_REG_RSTEN_WDA7RST_EN_MASK 0x6
> +#define RZN1_SYSCTRL_REG_RSTEN_WDM3RST_EN 3
> +#define RZN1_SYSCTRL_REG_RSTEN_CM3LOCKUPRST_EN 4
> +#define RZN1_SYSCTRL_REG_RSTEN_CM3SYSRESET_EN 5
> +#define RZN1_SYSCTRL_REG_RSTEN_SWRST_EN 6
> +#define RZN1_SYSCTRL_REG_RSTCTRL_WDA7RST_REQ 1
> +#define RZN1_SYSCTRL_REG_RSTCTRL_WDA7RST_REQ_MASK 0x6
> +#define RZN1_SYSCTRL_REG_RSTCTRL_WDM3RST_REQ 3
> +#define RZN1_SYSCTRL_REG_RSTCTRL_CM3LOCKUPRST_REQ 4
> +#define RZN1_SYSCTRL_REG_RSTCTRL_CM3SYSRESET_REQ 5
> +#define RZN1_SYSCTRL_REG_RSTCTRL_SWRST_REQ 6
> +
> +static void __iomem *reg_rsten, *reg_rstctrl;
Please make this into a proper driver and allocate this dynamically.
You can get device context from the notifier_block, see for example
gpio-restart.
> +static int rzn1_reboot_handler(struct notifier_block *this,
> + unsigned long mode, void *cmd)
> +{
> + writel(readl(reg_rsten) |
> + BIT(RZN1_SYSCTRL_REG_RSTEN_SWRST_EN) |
> + BIT(RZN1_SYSCTRL_REG_RSTEN_MRESET_EN),
> + reg_rsten);
> + writel(readl(reg_rstctrl) |
> + BIT(RZN1_SYSCTRL_REG_RSTCTRL_SWRST_REQ),
> + reg_rstctrl);
> +
> + mdelay(50);
> + pr_emerg("Unable to restart system\n");
> +
> + return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block rzn1_reboot_nb = {
> + .notifier_call = rzn1_reboot_handler,
> + .priority = 128,
> +};
> +
> +static int rzn1_reboot_probe(struct platform_device *ofdev)
> +{
> + int err;
> +
> + reg_rsten = of_iomap(ofdev->dev.of_node, 0);
> + reg_rstctrl = of_iomap(ofdev->dev.of_node, 1);
Please use devm_ioremap().
> +
> + if (!reg_rsten || !reg_rstctrl) {
> + dev_err(&ofdev->dev, "invalid register mapping\n");
> + return -ENODEV;
> + }
> +
> + err = register_restart_handler(&rzn1_reboot_nb);
> + if (err) {
> + dev_err(&ofdev->dev, "register restart handler failed(err=%d)\n",
> + err);
> + }
Missing unregister_restart_handler() in .remove.
> +
> + return err;
> +}
> +
> +static const struct of_device_id rzn1_reboot_of_match[] = {
> + { .compatible = "renesas,rzn1-reboot" },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, rzn1_reboot_of_match);
> +
> +static struct platform_driver rzn1_reboot_driver = {
> + .probe = rzn1_reboot_probe,
> + .driver = {
> + .name = "rzn1-reboot",
> + .of_match_table = rzn1_reboot_of_match,
> + },
> +};
> +module_platform_driver(rzn1_reboot_driver);
> +
> +MODULE_DESCRIPTION("RZ/N1 reboot driver");
> +MODULE_AUTHOR("Michel Pollet <michel.pollet@bp.renesas.com>, <buserror@gmail.com>");
> +MODULE_LICENSE("GPL v2");
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2018-04-25 21:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 11:04 [PATCH v5 0/8] arm: Base support for Renesas RZN1D-DB Board Michel Pollet
2018-04-17 11:04 ` [PATCH v5 1/6] arm: shmobile: Add the RZ/N1D (R9A06G032) to the shmobile Kconfig Michel Pollet
2018-04-23 10:08 ` Simon Horman
2018-04-17 11:04 ` [PATCH v5 2/6] dt-bindings: reset: renesas,rzn1-reboot: document RZ/N1 reboot driver Michel Pollet
2018-04-19 9:10 ` Geert Uytterhoeven
2018-04-17 11:04 ` [PATCH v5 3/6] dt-bindings: arm: Document the RZN1D-DB board Michel Pollet
2018-04-17 13:23 ` Rob Herring
2018-04-17 15:49 ` Geert Uytterhoeven
2018-04-23 10:02 ` Simon Horman
2018-04-17 11:04 ` [PATCH v5 4/6] ARM: dts: Renesas RZ/N1 SoC base device tree file Michel Pollet
2018-04-23 10:14 ` Simon Horman
2018-04-17 11:04 ` [PATCH v5 5/6] ARM: dts: Renesas RZN1D-DB Board base file Michel Pollet
2018-04-17 11:04 ` [PATCH v5 6/6] reset: Renesas RZ/N1 reboot driver Michel Pollet
2018-04-25 21:37 ` Sebastian Reichel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180425213732.tdmla3kdeuc2jjke@earth.universe \
--to=sre@kernel.org \
--cc=buserror+upstream@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=horms@verge.net.au \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=magnus.damm@gmail.com \
--cc=mark.rutland@arm.com \
--cc=michel.pollet@bp.renesas.com \
--cc=phil.edworthy@renesas.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).