All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Yan <andy.yan@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-Boot, v3, 1/3] rockchip: make boot_mode related codes reused across all platforms
Date: Tue, 21 Nov 2017 08:48:51 +0800	[thread overview]
Message-ID: <2d2fa9bb-ae23-b673-9319-bdf28972cba7@rock-chips.com> (raw)
In-Reply-To: <alpine.OSX.2.21.1711201543150.11675@vpn-10-11-0-14.lan>

Hi Philipp:


On 2017年11月20日 22:50, Philipp Tomsich wrote:
>
>
> On Wed, 11 Oct 2017, Andy Yan wrote:
>
>> setup_boot_mode function use the same logic but different
>> mode register address across all the rockchip platforms,
>> so it's better to make this function reused across all the
>> platforms, and let the mode register address setting from
>> the config file.
>>
>> Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
>> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>
> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>
> See below for a suggestion...
>
>> ---
>>
>> Changes in v3:
>> - add support for rk3188
>>
>> Changes in v2:
>> - correct the rk322x boot mode register address
>> - make the help text more clear
>>
>> arch/arm/include/asm/arch-rockchip/boot_mode.h |  2 ++
>> arch/arm/mach-rockchip/Kconfig                 | 15 ++++++++++++
>> arch/arm/mach-rockchip/Makefile                |  6 +++++
>> arch/arm/mach-rockchip/boot_mode.c             | 33 
>> ++++++++++++++++++++++++++
>> arch/arm/mach-rockchip/rk3036-board.c          | 24 -------------------
>> arch/arm/mach-rockchip/rk3188-board.c          |  1 +
>> arch/arm/mach-rockchip/rk322x-board.c          | 24 -------------------
>> arch/arm/mach-rockchip/rk3288-board.c          | 25 -------------------
>> arch/arm/mach-rockchip/rk3399-board.c          | 14 +++++++++++
>> 9 files changed, 71 insertions(+), 73 deletions(-)
>> create mode 100644 arch/arm/mach-rockchip/boot_mode.c
>> create mode 100644 arch/arm/mach-rockchip/rk3399-board.c
>>
>> diff --git a/arch/arm/include/asm/arch-rockchip/boot_mode.h 
>> b/arch/arm/include/asm/arch-rockchip/boot_mode.h
>> index bd65f60..163b2e7 100644
>> --- a/arch/arm/include/asm/arch-rockchip/boot_mode.h
>> +++ b/arch/arm/include/asm/arch-rockchip/boot_mode.h
>> @@ -16,4 +16,6 @@
>> /* enter usb mass storage mode */
>> #define BOOT_UMS        (REBOOT_FLAG + 12)
>>
>> +int setup_boot_mode(void);
>> +
>> #endif
>> diff --git a/arch/arm/mach-rockchip/Kconfig 
>> b/arch/arm/mach-rockchip/Kconfig
>> index 36df484..6144057 100644
>> --- a/arch/arm/mach-rockchip/Kconfig
>> +++ b/arch/arm/mach-rockchip/Kconfig
>> @@ -117,6 +117,7 @@ config ROCKCHIP_RK3399
>>     select SPL_SERIAL_SUPPORT
>>     select SPL_DRIVERS_MISC_SUPPORT
>>     select DEBUG_UART_BOARD_INIT
>> +    select BOARD_LATE_INIT
>>     help
>>       The Rockchip RK3399 is a ARM-based SoC with a dual-core Cortex-A72
>>       and quad-core Cortex-A53.
>> @@ -152,6 +153,20 @@ config TPL_ROCKCHIP_BACK_TO_BROM
>>           SPL will return to the boot rom, which will then load the 
>> U-Boot
>>           binary to keep going on.
>>
>> +config ROCKCHIP_BOOT_MODE_REG
>> +    hex "Rockchip boot mode flag register address"
>> +    default 0x200081c8 if ROCKCHIP_RK3036
>> +    default 0x20004040 if ROCKCHIP_RK3188
>> +    default 0x110005c8 if ROCKCHIP_RK322X
>> +    default 0xff730094 if ROCKCHIP_RK3288
>> +    default 0xff738200 if ROCKCHIP_RK3368
>> +    default 0xff320300 if ROCKCHIP_RK3399
>> +    default 0x10300580 if ROCKCHIP_RV1108
>> +    default 0
>> +    help
>> +      The Soc will enter to different boot mode(defined in 
>> asm/arch/boot_mode.h)
>> +      according to the value from this register.
>> +
>> config ROCKCHIP_SPL_RESERVE_IRAM
>>     hex "Size of IRAM reserved in SPL"
>>     default 0x4000
>> diff --git a/arch/arm/mach-rockchip/Makefile 
>> b/arch/arm/mach-rockchip/Makefile
>> index c15e9bf..2127f2b 100644
>> --- a/arch/arm/mach-rockchip/Makefile
>> +++ b/arch/arm/mach-rockchip/Makefile
>> @@ -22,10 +22,16 @@ obj-spl-$(CONFIG_ROCKCHIP_RK3368) += 
>> rk3368-board-spl.o spl-boot-order.o
>> obj-spl-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board-spl.o spl-boot-order.o
>>
>> ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),)
>> +
>> +ifneq ($(CONFIG_ROCKCHIP_BOOT_MODE_REG),0)
>> +obj-y += boot_mode.o
>> +endif
>> +
>> obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188-board.o
>> obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x-board.o
>> obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288-board.o
>> obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036-board.o
>> +obj-$(CONFIG_ROCKCHIP_RK3399) += rk3399-board.o
>> endif
>>
>> obj-$(CONFIG_$(SPL_TPL_)RAM) += sdram_common.o
>> diff --git a/arch/arm/mach-rockchip/boot_mode.c 
>> b/arch/arm/mach-rockchip/boot_mode.c
>> new file mode 100644
>> index 0000000..4652490
>> --- /dev/null
>> +++ b/arch/arm/mach-rockchip/boot_mode.c
>> @@ -0,0 +1,33 @@
>> +/*
>> + * (C) Copyright 2016 Rockchip Electronics Co., Ltd
>> + *
>> + * SPDX-License-Identifier:     GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <asm/io.h>
>> +#include <asm/arch/boot_mode.h>
>> +
>> +int setup_boot_mode(void)
>> +{
>> +    void *reg = (void *)CONFIG_ROCKCHIP_BOOT_MODE_REG;
>
> I am somewhat uneasy about this... could we use a syscon/regmap instead
> that will map to something different on each device?  I am thinking of 
> something along the lines of "syscon_get_first_range(ROCKCHIP_BOOTMODE)".


  The reason why we put the BOOTMODE register in Kconfig is because that 
we also need to access the resister in function save_boot_params(see 
patch 2/3) to check
the BROM_DNL flag, we have no way to access the dtb or syscon driver at 
that point(it's the first step we enter the tpl/spl world from bootrom).
>
>> +    int boot_mode = readl(reg);
>> +
>> +    debug("boot mode %x.\n", boot_mode);
>> +
>> +    /* Clear boot mode */
>> +    writel(BOOT_NORMAL, reg);
>> +
>> +    switch (boot_mode) {
>> +    case BOOT_FASTBOOT:
>> +        printf("enter fastboot!\n");
>> +        env_set("preboot", "setenv preboot; fastboot usb0");
>> +        break;
>> +    case BOOT_UMS:
>> +        printf("enter UMS!\n");
>> +        env_set("preboot", "setenv preboot; ums mmc 0");
>> +        break;
>> +    }
>> +
>> +    return 0;
>> +}
>> diff --git a/arch/arm/mach-rockchip/rk3036-board.c 
>> b/arch/arm/mach-rockchip/rk3036-board.c
>> index a3457f3..a5d2571 100644
>> --- a/arch/arm/mach-rockchip/rk3036-board.c
>> +++ b/arch/arm/mach-rockchip/rk3036-board.c
>> @@ -19,30 +19,6 @@
>>
>> DECLARE_GLOBAL_DATA_PTR;
>>
>> -#define GRF_BASE    0x20008000
>> -
>> -static void setup_boot_mode(void)
>> -{
>> -    struct rk3036_grf *const grf = (void *)GRF_BASE;
>> -    int boot_mode = readl(&grf->os_reg[4]);
>> -
>> -    debug("boot mode %x.\n", boot_mode);
>> -
>> -    /* Clear boot mode */
>> -    writel(BOOT_NORMAL, &grf->os_reg[4]);
>> -
>> -    switch (boot_mode) {
>> -    case BOOT_FASTBOOT:
>> -        printf("enter fastboot!\n");
>> -        env_set("preboot", "setenv preboot; fastboot usb0");
>> -        break;
>> -    case BOOT_UMS:
>> -        printf("enter UMS!\n");
>> -        env_set("preboot", "setenv preboot; ums mmc 0");
>> -        break;
>> -    }
>> -}
>> -
>> __weak int rk_board_late_init(void)
>> {
>>     return 0;
>> diff --git a/arch/arm/mach-rockchip/rk3188-board.c 
>> b/arch/arm/mach-rockchip/rk3188-board.c
>> index 96859a5..916d18f 100644
>> --- a/arch/arm/mach-rockchip/rk3188-board.c
>> +++ b/arch/arm/mach-rockchip/rk3188-board.c
>> @@ -24,6 +24,7 @@ int board_late_init(void)
>> {
>>     struct rk3188_grf *grf;
>>
>> +    setup_boot_mode();
>>     grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
>>     if (IS_ERR(grf)) {
>>         pr_err("grf syscon returned %ld\n", PTR_ERR(grf));
>> diff --git a/arch/arm/mach-rockchip/rk322x-board.c 
>> b/arch/arm/mach-rockchip/rk322x-board.c
>> index d443114..e71847d 100644
>> --- a/arch/arm/mach-rockchip/rk322x-board.c
>> +++ b/arch/arm/mach-rockchip/rk322x-board.c
>> @@ -16,30 +16,6 @@
>>
>> DECLARE_GLOBAL_DATA_PTR;
>>
>> -#define GRF_BASE    0x11000000
>> -
>> -static void setup_boot_mode(void)
>> -{
>> -    struct rk322x_grf *const grf = (void *)GRF_BASE;
>> -    int boot_mode = readl(&grf->os_reg[0]);
>> -
>> -    debug("boot mode %x.\n", boot_mode);
>> -
>> -    /* Clear boot mode */
>> -    writel(BOOT_NORMAL, &grf->os_reg[0]);
>> -
>> -    switch (boot_mode) {
>> -    case BOOT_FASTBOOT:
>> -        printf("enter fastboot!\n");
>> -        env_set("preboot", "setenv preboot; fastboot usb0");
>> -        break;
>> -    case BOOT_UMS:
>> -        printf("enter UMS!\n");
>> -        env_set("preboot", "setenv preboot; ums mmc 0");
>> -        break;
>> -    }
>> -}
>> -
>> __weak int rk_board_late_init(void)
>> {
>>     return 0;
>> diff --git a/arch/arm/mach-rockchip/rk3288-board.c 
>> b/arch/arm/mach-rockchip/rk3288-board.c
>> index 278bb40..1c53cca 100644
>> --- a/arch/arm/mach-rockchip/rk3288-board.c
>> +++ b/arch/arm/mach-rockchip/rk3288-board.c
>> @@ -23,31 +23,6 @@
>>
>> DECLARE_GLOBAL_DATA_PTR;
>>
>> -#define PMU_BASE    0xff730000
>> -
>> -static void setup_boot_mode(void)
>> -{
>> -    struct rk3288_pmu *const pmu = (void *)PMU_BASE;
>> -    int boot_mode = readl(&pmu->sys_reg[0]);
>> -
>> -    debug("boot mode %x.\n", boot_mode);
>> -
>> -    /* Clear boot mode */
>> -    writel(BOOT_NORMAL, &pmu->sys_reg[0]);
>> -
>> -    switch (boot_mode) {
>> -    case BOOT_FASTBOOT:
>> -        printf("enter fastboot!\n");
>> -        env_set("preboot", "setenv preboot; fastboot usb0");
>> -        break;
>> -    case BOOT_UMS:
>> -        printf("enter UMS!\n");
>> -        env_set("preboot", "setenv preboot; if mmc dev 0;"
>> -               "then ums mmc 0; else ums mmc 1;fi");
>> -        break;
>> -    }
>> -}
>> -
>> __weak int rk_board_late_init(void)
>> {
>>     return 0;
>> diff --git a/arch/arm/mach-rockchip/rk3399-board.c 
>> b/arch/arm/mach-rockchip/rk3399-board.c
>> new file mode 100644
>> index 0000000..9293843
>> --- /dev/null
>> +++ b/arch/arm/mach-rockchip/rk3399-board.c
>> @@ -0,0 +1,14 @@
>> +/*
>> + * Copyright (c) 2017 Rockchip Electronics Co., Ltd
>> + *
>> + * SPDX-License-Identifier:     GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <asm/arch/boot_mode.h>
>> +
>> +int board_late_init(void)
>> +{
>> +    setup_boot_mode();
>> +    return 0;
>> +}
>>
>
>
>

  reply	other threads:[~2017-11-21  0:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  6:59 [U-Boot] [PATCH v3 0/3] Most rockchip platform based boards use a key to instruct Andy Yan
2017-10-11  7:00 ` [U-Boot] [PATCH v3 1/3] rockchip: make boot_mode related codes reused across all platforms Andy Yan
2017-11-20 14:06   ` [U-Boot] [U-Boot, v3, " Philipp Tomsich
2017-11-20 14:50   ` Philipp Tomsich
2017-11-21  0:48     ` Andy Yan [this message]
2017-11-21  8:25       ` Dr. Philipp Tomsich
2017-11-21 22:32   ` Philipp Tomsich
2017-10-11  7:00 ` [U-Boot] [PATCH v3 2/3] rockchip: add support for enter to bootrom download mode Andy Yan
2017-11-20 14:06   ` [U-Boot] [U-Boot, v3, " Philipp Tomsich
2017-11-20 14:07   ` Philipp Tomsich
2017-11-21 22:32   ` Philipp Tomsich
2017-10-11  7:01 ` [U-Boot] [PATCH v3 3/3] rockchip: check download key before bootup Andy Yan
2017-11-20 14:06   ` [U-Boot] [U-Boot, v3, " Philipp Tomsich
2017-11-20 14:51   ` Philipp Tomsich
2017-11-21  1:02     ` Andy Yan
2017-11-21 12:31       ` Dr. Philipp Tomsich
2017-11-21 22:32   ` Philipp Tomsich
2017-11-17 10:09 ` [U-Boot] [PATCH v3 0/3] Most rockchip platform based boards use a key to instruct Andy Yan
2017-11-17 10:19   ` Dr. Philipp Tomsich

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=2d2fa9bb-ae23-b673-9319-bdf28972cba7@rock-chips.com \
    --to=andy.yan@rock-chips.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.