[PATCH v2 6/7] arm: rockchip: rk3568: refactor common rk3568_start method

Sascha Hauer sha at pengutronix.de
Wed Sep 21 02:17:24 PDT 2022


On Mon, Sep 19, 2022 at 01:39:47PM +0200, Michael Riesch wrote:
> After the removal of the IO domain configuration code, the low-level
> initialization is the same for all RK356x boards. Add a common
> method rk3568_start to remove this code duplication.
> 
> Signed-off-by: Michael Riesch <michael.riesch at wolfvision.net>
> ---
>  arch/arm/boards/pine64-quartz64/lowlevel.c    | 30 +----------------
>  arch/arm/boards/radxa-rock3/lowlevel.c        | 27 ---------------
>  .../arm/boards/rockchip-rk3568-evb/lowlevel.c | 33 +------------------
>  .../arm/mach-rockchip/include/mach/rockchip.h |  1 +
>  arch/arm/mach-rockchip/rk3568.c               | 24 ++++++++++++++
>  5 files changed, 27 insertions(+), 88 deletions(-)
> 
> diff --git a/arch/arm/boards/pine64-quartz64/lowlevel.c b/arch/arm/boards/pine64-quartz64/lowlevel.c
> index b295885522..e1beb3e624 100644
> --- a/arch/arm/boards/pine64-quartz64/lowlevel.c
> +++ b/arch/arm/boards/pine64-quartz64/lowlevel.c
> @@ -1,39 +1,11 @@
>  // SPDX-License-Identifier: GPL-2.0-only
>  #include <common.h>
> -#include <linux/sizes.h>
> -#include <asm/barebox-arm-head.h>
>  #include <asm/barebox-arm.h>
> -#include <mach/hardware.h>
> -#include <mach/atf.h>
> -#include <debug_ll.h>
>  #include <mach/rockchip.h>
>  
>  extern char __dtb_rk3566_quartz64_a_start[];
>  
> -static noinline void start_quartz64(void *fdt)
> -{
> -	/*
> -	 * Image execution starts at 0x0, but this is used for ATF and
> -	 * OP-TEE later, so move away from here.
> -	 */
> -	if (current_el() == 3)
> -		relocate_to_adr_full(RK3568_BAREBOX_LOAD_ADDRESS);
> -	else
> -		relocate_to_current_adr();
> -
> -	setup_c();
> -
> -	if (current_el() == 3) {
> -		rk3568_lowlevel_init();
> -		rk3568_atf_load_bl31(fdt);
> -		/* not reached */
> -	}
> -
> -	barebox_arm_entry(RK3568_DRAM_BOTTOM, 0x80000000 - RK3568_DRAM_BOTTOM,
> -			  fdt);
> -}
> -
>  ENTRY_FUNCTION(start_quartz64a, r0, r1, r2)
>  {
> -	start_quartz64(__dtb_rk3566_quartz64_a_start);
> +	rk3568_start(__dtb_rk3566_quartz64_a_start);
>  }

Here __dtb_rk3566_quartz64_a_start is accessed before setup_c() has been
called. That is not allowed, see the patch I just sent.

BTW this patch breaks compilation, which is only fixed in 7/7:

/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c:14:22: error: conflicting types for 'rk3568_start'
   14 | static noinline void rk3568_start(void)
      |                      ^~~~~~~~~~~~
In file included from /ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/boards/rockchip-rk3568-bpi-r2pro/lowlevel.c:10:
/ptx/work/WORK_EIHEI/sha/projects/barebox/barebox/arch/arm/mach-rockchip/include/mach/rockchip.h:37:6: note: previous declaration of 'rk3568_start' was here
   37 | void rk3568_start(void *fdt);
      |      ^~~~~~~~~~~~


Sascha

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



More information about the barebox mailing list