Re: [RFT PATCH 3/3] ARM: dts: rk356x: align bootsource_instance numbering and MMC DT aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2022-07-20 at 07:50 +0200, Ahmad Fatoum wrote:
> A common scripting pattern in barebox is continuing boot from
> the current bootsource:
> 
>   if [ "$bootsource" = "mmc" ]; then
>         global.boot.default="mmc${bootsource_instance}
> ${global.boot.default}"
>   fi
> 
> This fails on the RK356x boards, because of a mismatch in numbering:
> block device numbering is dictated by the mmc* DT aliases and
> numbering
> used for bootsource_instance is taken as is from what the bootrom
> reports.
> 
> On SoCs like i.MX, this is a much rarer issue, because the upstream
> DT
> has predefined aliases in the same order as reported by the bootrom.
> 
> In Rockchip DTs on the other hand, aliases are delegated to the board
> device trees and all boards we support have aliases in an order
> different from what the bootrom numbering.
> 
> Fix this by employing the newly supported barebox,bootsource-*
> mapping
> table. As a result $bootsource_instance will change. We fix the
> upstream
> code depending on specific numbering here, but custom scripts and
> board
> code may still be broken.
> 
> Co-developed-by: Johannes Zink <j.zink@xxxxxxxxxxxxxx>
> Signed-off-by: Johannes Zink <j.zink@xxxxxxxxxxxxxx>
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> ---
>  arch/arm/boards/radxa-rock3/board.c               | 2 +-
>  arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c | 2 +-
>  arch/arm/boards/rockchip-rk3568-evb/board.c       | 2 +-
>  arch/arm/dts/rk3566-quartz64-a.dts                | 1 +
>  arch/arm/dts/rk3568-bpi-r2-pro.dts                | 1 +
>  arch/arm/dts/rk3568-evb1-v10.dts                  | 1 +
>  arch/arm/dts/rk3568-rock-3a.dts                   | 1 +
>  arch/arm/dts/rk356x.dtsi                          | 9 +++++++++
>  arch/arm/mach-rockchip/rk3568.c                   | 8 +++-----
>  9 files changed, 19 insertions(+), 8 deletions(-)
>  create mode 100644 arch/arm/dts/rk356x.dtsi
> 
> diff --git a/arch/arm/boards/radxa-rock3/board.c
> b/arch/arm/boards/radxa-rock3/board.c
> index aef5ec5df669..2413ea6cacc0 100644
> --- a/arch/arm/boards/radxa-rock3/board.c
> +++ b/arch/arm/boards/radxa-rock3/board.c
> @@ -21,7 +21,7 @@ static int rock3_probe(struct device_d *dev)
>         barebox_set_model(model->name);
>         barebox_set_hostname(model->shortname);
>  
> -       if (bootsource == BOOTSOURCE_MMC && instance == 1)
> +       if (bootsource == BOOTSOURCE_MMC && instance == 0)
>                 of_device_enable_path("/chosen/environment-sd");
>         else
>                 of_device_enable_path("/chosen/environment-emmc");
> diff --git a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
> b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
> index e472f13c8bbf..1a5faa8afb12 100644
> --- a/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
> +++ b/arch/arm/boards/rockchip-rk3568-bpi-r2pro/board.c
> @@ -23,7 +23,7 @@ static int rk3568_bpi_r2pro_probe(struct device_d
> *dev)
>         barebox_set_hostname("bpi-r2pro");
>         machine_is_bpi_r2pro = true;
>  
> -       if (bootsource == BOOTSOURCE_MMC && instance == 1)
> +       if (bootsource == BOOTSOURCE_MMC && instance == 0)
>                 of_device_enable_path("/chosen/environment-sd");
>         else
>                 of_device_enable_path("/chosen/environment-emmc");
> diff --git a/arch/arm/boards/rockchip-rk3568-evb/board.c
> b/arch/arm/boards/rockchip-rk3568-evb/board.c
> index a466d385a223..212c801c93d3 100644
> --- a/arch/arm/boards/rockchip-rk3568-evb/board.c
> +++ b/arch/arm/boards/rockchip-rk3568-evb/board.c
> @@ -23,7 +23,7 @@ static int rk3568_evb_probe(struct device_d *dev)
>         barebox_set_hostname("rk3568-evb");
>         machine_is_rk3568_evb = true;
>  
> -       if (bootsource == BOOTSOURCE_MMC && instance == 1)
> +       if (bootsource == BOOTSOURCE_MMC && instance == 0)
>                 of_device_enable_path("/chosen/environment-sd");
>         else
>                 of_device_enable_path("/chosen/environment-emmc");
> diff --git a/arch/arm/dts/rk3566-quartz64-a.dts
> b/arch/arm/dts/rk3566-quartz64-a.dts
> index 8639ca0886f1..0036ef31f13a 100644
> --- a/arch/arm/dts/rk3566-quartz64-a.dts
> +++ b/arch/arm/dts/rk3566-quartz64-a.dts
> @@ -3,6 +3,7 @@
>  /dts-v1/;
>  
>  #include <arm64/rockchip/rk3566-quartz64-a.dts>
> +#include "rk356x.dtsi"
>  
>  / {
>         memory@a00000 {
> diff --git a/arch/arm/dts/rk3568-bpi-r2-pro.dts
> b/arch/arm/dts/rk3568-bpi-r2-pro.dts
> index da76ab64c106..8c13ddd5c103 100644
> --- a/arch/arm/dts/rk3568-bpi-r2-pro.dts
> +++ b/arch/arm/dts/rk3568-bpi-r2-pro.dts
> @@ -9,6 +9,7 @@
>  #include <dt-bindings/leds/common.h>
>  #include <dt-bindings/pinctrl/rockchip.h>
>  #include "rk3568.dtsi"
> +#include "rk356x.dtsi"
>  
>  / {
>         model = "Bananapi-R2 Pro (RK3568) DDR4 Board";
> diff --git a/arch/arm/dts/rk3568-evb1-v10.dts b/arch/arm/dts/rk3568-
> evb1-v10.dts
> index d2c1fc89a8cb..82186ff86ead 100644
> --- a/arch/arm/dts/rk3568-evb1-v10.dts
> +++ b/arch/arm/dts/rk3568-evb1-v10.dts
> @@ -7,6 +7,7 @@
>  /dts-v1/;
>  
>  #include <arm64/rockchip/rk3568-evb1-v10.dts>
> +#include "rk356x.dtsi"
>  
>  / {
>         chosen: chosen {
> diff --git a/arch/arm/dts/rk3568-rock-3a.dts b/arch/arm/dts/rk3568-
> rock-3a.dts
> index 44d4fc9686df..25a0c05737d0 100644
> --- a/arch/arm/dts/rk3568-rock-3a.dts
> +++ b/arch/arm/dts/rk3568-rock-3a.dts
> @@ -3,6 +3,7 @@
>  /dts-v1/;
>  
>  #include <arm64/rockchip/rk3568-rock-3a.dts>
> +#include "rk356x.dtsi"
>  
>  / {
>         chosen: chosen {
> diff --git a/arch/arm/dts/rk356x.dtsi b/arch/arm/dts/rk356x.dtsi
> new file mode 100644
> index 000000000000..254450d78fa8
> --- /dev/null
> +++ b/arch/arm/dts/rk356x.dtsi
> @@ -0,0 +1,9 @@
> +// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
> +
> +/ {
> +       aliases {
> +               barebox,bootsource-mmc0 = &sdhci;
> +               barebox,bootsource-mmc1 = &sdmmc0;
> +               barebox,bootsource-mmc2 = &sdmmc1;
> +       };
> +};
> diff --git a/arch/arm/mach-rockchip/rk3568.c b/arch/arm/mach-
> rockchip/rk3568.c
> index 2d80bad8a658..19dfa9b87151 100644
> --- a/arch/arm/mach-rockchip/rk3568.c
> +++ b/arch/arm/mach-rockchip/rk3568.c
> @@ -151,18 +151,16 @@ static struct rk_bootsource bootdev_map[] = {
>         [0xa] = { .src = BOOTSOURCE_USB, .instance = 0 },
>  };
>  
> -static enum bootsource rk3568_bootsource(void)
> +static void rk3568_bootsource(void)
>  {
>         u32 v;
>  
>         v = readl(RK3568_IRAM_BASE + 0x10);
>  
>         if (v >= ARRAY_SIZE(bootdev_map))
> -               return BOOTSOURCE_UNKNOWN;
> +               return;
>  
> -       bootsource_set_raw(bootdev_map[v].src,
> bootdev_map[v].instance);
> -
> -       return bootdev_map[v].src;
> +       bootsource_set(bootdev_map[v].src, bootdev_map[v].instance);
>  }
>  
>  int rk3568_init(void)

Tested-by: Johannes Zink <j.zink@xxxxxxxxxxxxxx> # Radxa Rockpi3A
(RK3568)

-- 
Pengutronix e.K.                | Johannes Zink                  |
Steuerwalder Str. 21            | https://www.pengutronix.de/    |
31137 Hildesheim, Germany       | Phone: +49-5121-206917-0       |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-5555    |





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux