devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Andy Yan <andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
	heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	khilman-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org,
	pawel.moll-5wv7dgnIgG8@public.gmane.org,
	ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
	benchan-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org,
	sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
	treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org,
	wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
	john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH v3 3/5] soc: rockchip: add reboot notifier driver
Date: Mon, 14 Dec 2015 12:39:44 +0100	[thread overview]
Message-ID: <10162108.nOThMrrbdf@wuerfel> (raw)
In-Reply-To: <1447840582-19850-1-git-send-email-andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org>

On Wednesday 18 November 2015 17:56:22 Andy Yan wrote:
> rockchip platform have a protocol to pass the kernel reboot
> mode to bootloader by some special registers when system reboot.
> By this way the bootloader can take different action according
> to the different kernel reboot mode, for example, command
> "reboot loader" will reboot the board to rockusb mode, this is
> a very convenient way to get the board enter download mode.
> 
> Signed-off-by: Andy Yan <andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org>

Adding John Stultz to Cc

I just saw this thread pop up again, and had to think of John's recent
patch to unify this across platforms.

John, can you have a look at this driver too, and see how it fits in?
I think this is yet another variant, using an MMIO register rather than
RAM (as HTC / NVIDIA does) or SRAM (as Qualcomm does), but otherwise
it conceptually fits in with what you had.

The driver goes through an existing syscon regmap as far as I can
tell, rather than a memory area or its own device.

	Arnd

> ---
> 
> Changes in v3:
>  - move from mach-rockchip to drivers/soc/rockchip, as the tegra does
>  - use dts pass the related register
> 
> Changes in v2:
>   - check cpu dt node
>   - remove a unnecessary of_put_node in function rockchip_get_pmu_regmap
>   - fix a align issue
>   - use reboot_notifier instead of restart_handler
> 
>  drivers/soc/rockchip/Kconfig  |  7 ++++
>  drivers/soc/rockchip/Makefile |  1 +
>  drivers/soc/rockchip/loader.h | 22 ++++++++++
>  drivers/soc/rockchip/reboot.c | 98 +++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 128 insertions(+)
>  create mode 100644 drivers/soc/rockchip/loader.h
>  create mode 100644 drivers/soc/rockchip/reboot.c
> 
> diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
> index 7140ff8..4edbc44 100644
> --- a/drivers/soc/rockchip/Kconfig
> +++ b/drivers/soc/rockchip/Kconfig
> @@ -15,4 +15,11 @@ config ROCKCHIP_PM_DOMAINS
>  
>            If unsure, say N.
>  
> +config ROCKCHIP_REBOOT
> +	bool "Rockchip reboot notifier driver"
> +	help
> +	  Say y here will enable reboot notifier support.
> +	  This will get reboot mode arguments from userspace and
> +	  store it in special register.
> +
>  endif
> diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile
> index 3d73d06..9817496 100644
> --- a/drivers/soc/rockchip/Makefile
> +++ b/drivers/soc/rockchip/Makefile
> @@ -2,3 +2,4 @@
>  # Rockchip Soc drivers
>  #
>  obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
> +obj-$(CONFIG_ROCKCHIP_REBOOT) += reboot.o
> diff --git a/drivers/soc/rockchip/loader.h b/drivers/soc/rockchip/loader.h
> new file mode 100644
> index 0000000..bf51baa
> --- /dev/null
> +++ b/drivers/soc/rockchip/loader.h
> @@ -0,0 +1,22 @@
> +#ifndef __MACH_ROCKCHIP_LOADER_H
> +#define __MACH_ROCKCHIP_LOADER_H
> +
> +/*high 24 bits is tag, low 8 bits is type*/
> +#define SYS_LOADER_REBOOT_FLAG   0x5242C300
> +
> +enum {
> +	BOOT_NORMAL = 0, /* normal boot */
> +	BOOT_LOADER,     /* enter loader rockusb mode */
> +	BOOT_MASKROM,    /* enter maskrom rockusb mode (not support now) */
> +	BOOT_RECOVER,    /* enter recover */
> +	BOOT_NORECOVER,  /* do not enter recover */
> +	BOOT_SECONDOS,   /* boot second OS (not support now)*/
> +	BOOT_WIPEDATA,   /* enter recover and wipe data. */
> +	BOOT_WIPEALL,    /* enter recover and wipe all data. */
> +	BOOT_CHECKIMG,   /* check firmware img with backup part*/
> +	BOOT_FASTBOOT,   /* enter fast boot mode */
> +	BOOT_SECUREBOOT_DISABLE,
> +	BOOT_CHARGING,   /* enter charge mode */
> +	BOOT_MAX         /* MAX VALID BOOT TYPE.*/
> +};
> +#endif
> diff --git a/drivers/soc/rockchip/reboot.c b/drivers/soc/rockchip/reboot.c
> new file mode 100644
> index 0000000..048aeb0b
> --- /dev/null
> +++ b/drivers/soc/rockchip/reboot.c
> @@ -0,0 +1,98 @@
> +/*
> + * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
> + *
> + * 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; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/platform_device.h>
> +#include <linux/reboot.h>
> +#include <linux/regmap.h>
> +#include <linux/mfd/syscon.h>
> +#include "loader.h"
> +
> +struct rockchip_reboot {
> +	struct device *dev;
> +	struct regmap *map;
> +	u32 offset;
> +	struct notifier_block reboot_notifier;
> +};
> +
> +static void rockchip_get_reboot_flag(const char *cmd, u32 *flag)
> +{
> +	*flag = SYS_LOADER_REBOOT_FLAG + BOOT_NORMAL;
> +
> +	if (cmd) {
> +		if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader"))
> +			*flag = SYS_LOADER_REBOOT_FLAG + BOOT_LOADER;
> +		else if (!strcmp(cmd, "recovery"))
> +			*flag = SYS_LOADER_REBOOT_FLAG + BOOT_RECOVER;
> +		else if (!strcmp(cmd, "charge"))
> +			*flag = SYS_LOADER_REBOOT_FLAG + BOOT_CHARGING;
> +		else if (!strcmp(cmd, "fastboot"))
> +			*flag = SYS_LOADER_REBOOT_FLAG + BOOT_FASTBOOT;
> +	}
> +}
> +
> +static int rockchip_reboot_notify(struct notifier_block *this,
> +				  unsigned long mode, void *cmd)
> +{
> +	struct rockchip_reboot *reboot;
> +	u32 flag;
> +
> +	reboot = container_of(this, struct rockchip_reboot, reboot_notifier);
> +	rockchip_get_reboot_flag(cmd, &flag);
> +	regmap_write(reboot->map, reboot->offset, flag);
> +
> +	return NOTIFY_DONE;
> +}
> +
> +static int __init rockchip_reboot_probe(struct platform_device *pdev)
> +{
> +	struct rockchip_reboot *reboot;
> +	int ret;
> +
> +	reboot = devm_kzalloc(&pdev->dev, sizeof(*reboot), GFP_KERNEL);
> +	if (!reboot)
> +		return -ENOMEM;
> +
> +	reboot->dev = &pdev->dev;
> +	reboot->map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
> +						      "rockchip,regmap");
> +	if (IS_ERR(reboot->map))
> +		return PTR_ERR(reboot->map);
> +
> +	if (of_property_read_u32(pdev->dev.of_node, "offset", &reboot->offset))
> +		return -EINVAL;
> +
> +	reboot->reboot_notifier.notifier_call = rockchip_reboot_notify;
> +	ret = register_reboot_notifier(&reboot->reboot_notifier);
> +	if (ret)
> +		dev_err(reboot->dev, "can't register reboot notifier\n");
> +
> +	return ret;
> +}
> +
> +static const struct of_device_id rockchip_reboot_of_match[] = {
> +	{ .compatible = "rockchip,reboot" },
> +	{}
> +};
> +
> +static struct platform_driver rockchip_reboot_driver = {
> +	.probe = rockchip_reboot_probe,
> +	.driver = {
> +		.name = "rockchip-reboot",
> +		.of_match_table = rockchip_reboot_of_match,
> +	},
> +};
> +module_platform_driver(rockchip_reboot_driver);
> +
> +MODULE_AUTHOR("Andy Yan <andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org");
> +MODULE_DESCRIPTION("Rockchip platform reboot notifier driver");
> +MODULE_LICENSE("GPL");
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2015-12-14 11:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-18  9:47 [PATCH v3 0/5] Add reboot notifier driver for rockchip platform Andy Yan
2015-11-18  9:50 ` [PATCH v3 1/5] ARM: dts: rockchip: rk3288-veyron: rename pinctrl node reboot to reset Andy Yan
2015-11-18 14:18   ` Sergei Shtylyov
2015-11-19  0:51     ` Andy Yan
2015-11-18  9:53 ` [PATCH v3 2/5] dt-bindings: soc: add document for rockchip reboot notifier driver Andy Yan
     [not found]   ` <1447840410-19794-1-git-send-email-andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-11-18 22:59     ` Rob Herring
2015-11-19  1:17       ` Andy Yan
     [not found]         ` <564D2331.8070503-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-11-19  4:35           ` Heiko Stuebner
2015-11-20  1:16             ` Andy Yan
2015-11-20  1:58               ` Rob Herring
2015-11-23 13:15                 ` Andy Yan
2015-12-01 15:10                   ` Andy Yan
     [not found]                     ` <CANbgqARCYP0rfTPSJLNEnCdrb1+mCYYznnRVH6o8Bj5sWt9fDw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-01 15:47                       ` Heiko Stübner
2015-11-19 12:56           ` Thierry Reding
2015-11-19 13:39             ` Andy Yan
     [not found]               ` <CANbgqASc1fyoV6FJ1g15P27_h0iA_F9h8aP304X8tRovrKrq5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-19 15:30                 ` Thierry Reding
2015-11-18  9:56 ` [PATCH v3 3/5] soc: rockchip: add " Andy Yan
     [not found]   ` <1447840582-19850-1-git-send-email-andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-11-19  0:39     ` kbuild test robot
2015-12-14 11:39     ` Arnd Bergmann [this message]
2015-12-15 16:31       ` Thierry Reding
     [not found]         ` <20151215163120.GA24031-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-12-15 16:34           ` Arnd Bergmann
2015-12-15 17:27             ` Heiko Stübner
2015-12-15 17:42             ` Thierry Reding
     [not found]               ` <20151215174234.GB24031-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-12-15 20:38                 ` Arnd Bergmann
2015-12-28  9:20                   ` Thierry Reding
     [not found]                     ` <20151228092054.GA29195-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2015-12-28 15:35                       ` Arnd Bergmann
2016-01-21 16:20                         ` Thierry Reding
     [not found] ` <1447840044-19689-1-git-send-email-andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-11-18 10:00   ` [PATCH v3 4/5] ARM: dts: rockchip: add reboot node Andy Yan
2015-12-11 21:29   ` [PATCH v3 0/5] Add reboot notifier driver for rockchip platform Heiko Stübner
2015-12-14 10:30     ` Andy Yan
2015-12-17  1:16       ` John Stultz
2015-11-18 10:05 ` [PATCH v3 5/5] ARM64: dts: rockchip: add reboot node Andy Yan

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=10162108.nOThMrrbdf@wuerfel \
    --to=arnd-r2ngtmty4d4@public.gmane.org \
    --cc=andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=benchan-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=khilman-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.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).