From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Yan Subject: Re: [PATCH] ARM: rockchip: add reboot notifier Date: Thu, 10 Sep 2015 18:48:33 +0800 Message-ID: <55F16001.3000100@rock-chips.com> References: <1441716187-29446-1-git-send-email-andy.yan@rock-chips.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Alexey Klimov Cc: =?UTF-8?Q?Heiko_St=c3=bcbner?= , linux-rockchip@lists.infradead.org, linux@arm.linux.org.uk, Linux Kernel Mailing List , linux-arm-kernel@lists.infradead.org List-Id: linux-rockchip.vger.kernel.org Hi Alexey: On 2015=E5=B9=B409=E6=9C=8809=E6=97=A5 05:50, Alexey Klimov wrote: > Hi Andy, > > On Tue, Sep 8, 2015 at 3:43 PM, Andy Yan wr= ote: >> rockchip platform have a protocol to pass the the kernel > Double 'the'? this is will be removed. > >> 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 >> to download mode. >> >> Signed-off-by: Andy Yan >> --- >> >> arch/arm/mach-rockchip/Makefile | 2 +- >> arch/arm/mach-rockchip/loader.h | 22 +++++++++ >> arch/arm/mach-rockchip/reboot.c | 103 ++++++++++++++++++++++++++++= ++++++++++++ >> 3 files changed, 126 insertions(+), 1 deletion(-) >> create mode 100644 arch/arm/mach-rockchip/loader.h >> create mode 100644 arch/arm/mach-rockchip/reboot.c >> >> diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchi= p/Makefile >> index 5c3a9b2..cd291e3 100644 >> --- a/arch/arm/mach-rockchip/Makefile >> +++ b/arch/arm/mach-rockchip/Makefile >> @@ -1,5 +1,5 @@ >> CFLAGS_platsmp.o :=3D -march=3Darmv7-a >> >> -obj-$(CONFIG_ARCH_ROCKCHIP) +=3D rockchip.o >> +obj-$(CONFIG_ARCH_ROCKCHIP) +=3D rockchip.o reboot.o >> obj-$(CONFIG_PM_SLEEP) +=3D pm.o sleep.o >> obj-$(CONFIG_SMP) +=3D headsmp.o platsmp.o >> diff --git a/arch/arm/mach-rockchip/loader.h b/arch/arm/mach-rockchi= p/loader.h >> new file mode 100644 >> index 0000000..bf51baa >> --- /dev/null >> +++ b/arch/arm/mach-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 =3D 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.*/ > Looks like you only implemented NORMAL, RECOVER, LOADER and CHARGING. > Are you keeping other entries for keeping right order and keep > consistency? > Or have plans for future? to keep the right order,some of them maybe implemented in the future. > >> +}; >> +#endif >> diff --git a/arch/arm/mach-rockchip/reboot.c b/arch/arm/mach-rockchi= p/reboot.c >> new file mode 100644 >> index 0000000..704bc16 >> --- /dev/null >> +++ b/arch/arm/mach-rockchip/reboot.c >> @@ -0,0 +1,103 @@ >> +#include > Usually people place in the beginning copyright and GPL license heade= r info. > >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include "loader.h" >> + >> +#define RK3188_PMU_SYS_REG0 0x40 >> +#define RK3288_PMU_SYS_REG0 0x94 >> + >> +struct regmap *regmap; >> +int flag_reg; >> + >> +static int rockchip_get_pmu_regmap(void) >> +{ >> + struct device_node *node; >> + >> + node =3D of_find_node_by_path("/cpus"); > Is it critical not to check node for NULL here? ok, I will add a check here > >> + regmap =3D syscon_regmap_lookup_by_phandle(node, "rockchip,p= mu"); >> + of_node_put(node); >> + if (!IS_ERR(regmap)) >> + return 0; >> + >> + regmap =3D syscon_regmap_lookup_by_compatible("rockchip,rk30= 66-pmu"); >> + of_node_put(node); >> + if (!IS_ERR(regmap)) >> + return 0; >> + >> + return -ENODEV; >> +} > This double of_node_put(node) confuses me. Could you please guide me = over it? > > After I tried to re-create it by myself looking to code I think that > second of_node_put() is not needed. the second of_node_put is not needed, it will be removed. >> +static int rockchip_get_reboot_flag_regmap(void) >> +{ >> + int ret =3D rockchip_get_pmu_regmap(); >> + >> + if (ret < 0) >> + return ret; >> + >> + if (of_machine_is_compatible("rockchip,rk3288")) { >> + flag_reg =3D RK3288_PMU_SYS_REG0; >> + return 0; >> + } else if (of_machine_is_compatible("rockchip,rk3066a") || >> + of_machine_is_compatible("rockchip,rk3066b") || >> + of_machine_is_compatible("rockchip,rk3188")) { >> + flag_reg =3D RK3188_PMU_SYS_REG0; >> + return 0; >> + } >> + >> + return -ENODEV; > [..] > >> + >> +static int __init rockchip_reboot_init(void) >> +{ >> + int ret =3D 0; >> + >> + if (!rockchip_get_reboot_flag_regmap()) { >> + ret =3D register_restart_handler(&rockchip_reboot_ha= ndler); >> + if (ret) >> + pr_err("%s: cannot register reboot handler, = %d\n", >> + __func__, ret); >> + } >> + >> +return ret; > Please align this correctly. OK, this will be aligned next version > > Thanks, > Alexey Klimov > > > Thanks for your review.