Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932353AbbLNLkh (ORCPT ); Mon, 14 Dec 2015 06:40:37 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:57004 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932206AbbLNLkf (ORCPT ); Mon, 14 Dec 2015 06:40:35 -0500 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Andy Yan , heiko@sntech.de, linux-kernel@vger.kernel.org, mark.rutland@arm.com, devicetree@vger.kernel.org, khilman@linaro.org, linux@arm.linux.org.uk, pawel.moll@arm.com, ijc+devicetree@hellion.org.uk, benchan@google.com, sjg@chromium.org, linux-rockchip@lists.infradead.org, robh+dt@kernel.org, galak@codeaurora.org, treding@nvidia.com, wxt@rock-chips.com, john.stultz@linaro.org Subject: Re: [PATCH v3 3/5] soc: rockchip: add reboot notifier driver Date: Mon, 14 Dec 2015 12:39:44 +0100 Message-ID: <10162108.nOThMrrbdf@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <1447840582-19850-1-git-send-email-andy.yan@rock-chips.com> References: <1447840044-19689-1-git-send-email-andy.yan@rock-chips.com> <1447840582-19850-1-git-send-email-andy.yan@rock-chips.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:mxTOtWceQVFFK7C8ONuEgLyxJv7Lxqce8iPKmRCqoPARQ92gi9L AhFruTp6GkCVk5NFq2axtx7eTqKsW0njTm+YE3EFfNBM3weQ/rA1Dn9dBn+FKwp3oX+YBKO BJrb5Yq0N+z19M+gR2HLqpgZEXcZYylXWmiPjaGdcMUPS8st3298Cz+/WtT2rEADPyRYehs cuqliHdeLVmyYZuWEUmWQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:ocQDTl3Wauw=:OA5GCPpDbUOIgn2UGRDZl/ BwIBmSD/9MxUx9eTMqhVktvdZDj2/vRAo6e89DhsRq4nugSIuaOi/nzati8JIm2eJfJmqaa/P 2nf2yXrk1I2z9DxQh0a/zw5jpHrg2LzijAstxGdm/ND0Yj5gWrt3E5rYKXVG/AZ1h8Bf7MEF5 HzS1x0ze5sXwUmY0F9U7MZvKjTT1R7K8NjmUDkz0Hp3aBp85sOCFK164duAQXmEJr2BVOfIzq bC183iWlok96q0vBHf3TA5EMW9k8EnDP3ZLkiWG9X1XBvMtKidocR13OdHJDqwpwgO1WqDMOC LUSSYDxDNmS9lDSkIxl9F6ls+uFdfY+vpFo4kbkmD457LDCFLv+gScVrCZw1zXnOpM8ES87ez TT5qwJbn5/OEa6Ux60IcbvV8gwWRNjbA6Mnihsg7DIcyPbiepXAOEOHXPRd+kQiYNC8KIqEGI i34GIPQDHUD163P5k5XDqpvSsNTsjJTQ690fuvgqeLKUBBCXmXMMzd63IX4AnvNpnnVFrDaTM QYpnKgzNCIA3qzkNVb10CxcMszKDQEtUjWucGXcyU/FC4LbVDSG0dhRNcCIdf2B58fFQOqrLR 9iiO4Q4M6Qo6euRnr9z+ucW1i25qkHM5X0FbQRWU+5h7EMytG/zibnfmBtV5yTYYgHrNS81Wj WHgO8jjNw/cbKUGBGpXQVwUyIgNPnE1vtg2J0yBg+MQZ+zXmn5XUgtEReqW0e1O0u2VDBkrGE qzWyBfBHACGrc9G2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7074 Lines: 209 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 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#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 +MODULE_DESCRIPTION("Rockchip platform reboot notifier driver"); > +MODULE_LICENSE("GPL"); > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/