public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Dragan Simic <dsimic@manjaro.org>
To: Quentin Schulz <foss+uboot@0leil.net>
Cc: Simon Glass <sjg@chromium.org>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Kever Yang <kever.yang@rock-chips.com>,
	Tom Rini <trini@konsulko.com>,
	Alper Nebi Yasak <alpernebiyasak@gmail.com>,
	Peter Robinson <pbrobinson@gmail.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Klaus Goger <klaus.goger@theobroma-systems.com>,
	Heiko Stuebner <heiko.stuebner@cherry.de>,
	Otavio Salvador <otavio@ossystems.com.br>,
	Andy Yan <andy.yan@rock-chips.com>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Lukasz Majewski <lukma@denx.de>,
	Sean Anderson <seanga2@gmail.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Anatolij Gustschin <agust@denx.de>,
	heiko@sntech.de, u-boot@lists.denx.de,
	Quentin Schulz <quentin.schulz@theobroma-systems.com>
Subject: Re: [PATCH 08/18] rockchip: pine64: rockpro64: migrate to rockchip_early_misc_init_r
Date: Sat, 03 Feb 2024 14:19:36 +0100	[thread overview]
Message-ID: <0d74e5e5482cd32d7cad714e731d4fb8@manjaro.org> (raw)
In-Reply-To: <20240123-jaguar-v1-8-1eec1c34953c@theobroma-systems.com>

Hello Quentin,

Please see my comments below.

On 2024-01-23 15:49, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> 
> Only setup_iodomain() differs from the original misc_init_r from
> Rockchip mach code, so let's use rockchip_early_misc_init_r instead of
> reimplementing the whole misc_init_r from Rockchip.

Your patches from this series are fine, but the trouble is that
we end up executing rockchip_setup_macaddr() for the devices
that don't use the RK3339's built-in Gigabit Ethernet interface,
which includes the Pinebook Pro and the Pinephone Pro.

We should add more ifdef guards to rockchip_setup_macaddr(),
to prevent the execution of its body for devices such as the
ones listed above, which eliminates the unneeded code from the
resulting U-Boot images, making them a bit smaller, and saves
some CPU cycles and a bit of time on boot.  It also prevents
the unneeded "ethaddr" and "eth1addr" variables from being
added to the environment.

The patch below should do the trick, which also performs a few
small code cleanups for additional file-level consistency:

diff --git a/arch/arm/mach-rockchip/misc.c 
b/arch/arm/mach-rockchip/misc.c
index 7d03f0c2b679..ed5bdab5a648 100644
--- a/arch/arm/mach-rockchip/misc.c
+++ b/arch/arm/mach-rockchip/misc.c
@@ -23,7 +23,8 @@

  int rockchip_setup_macaddr(void)
  {
-#if CONFIG_IS_ENABLED(HASH) && CONFIG_IS_ENABLED(SHA256)
+#if CONFIG_IS_ENABLED(HASH) && CONFIG_IS_ENABLED(SHA256) && \
+    CONFIG_IS_ENABLED(GMAC_ROCKCHIP)
  	int ret;
  	const char *cpuid = env_get("cpuid#");
  	u8 hash[SHA256_SUM_LEN];
@@ -64,15 +65,15 @@ int rockchip_cpuid_from_efuse(const u32 
cpuid_offset,
  			      const u32 cpuid_length,
  			      u8 *cpuid)
  {
-#if IS_ENABLED(CONFIG_ROCKCHIP_EFUSE) || 
IS_ENABLED(CONFIG_ROCKCHIP_OTP)
+#if CONFIG_IS_ENABLED(ROCKCHIP_EFUSE) || 
CONFIG_IS_ENABLED(ROCKCHIP_OTP)
  	struct udevice *dev;
  	int ret;

  	/* retrieve the device */
-#if IS_ENABLED(CONFIG_ROCKCHIP_EFUSE)
+#if CONFIG_IS_ENABLED(ROCKCHIP_EFUSE)
  	ret = uclass_get_device_by_driver(UCLASS_MISC,
  					  DM_DRIVER_GET(rockchip_efuse), &dev);
-#elif IS_ENABLED(CONFIG_ROCKCHIP_OTP)
+#elif CONFIG_IS_ENABLED(ROCKCHIP_OTP)
  	ret = uclass_get_device_by_driver(UCLASS_MISC,
  					  DM_DRIVER_GET(rockchip_otp), &dev);
  #endif

> Cc: Quentin Schulz <foss+uboot@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> ---
>  board/pine64/rockpro64_rk3399/rockpro64-rk3399.c | 20 
> ++------------------
>  1 file changed, 2 insertions(+), 18 deletions(-)
> 
> diff --git a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
> b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
> index d79084614f1..d0a694ead1d 100644
> --- a/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
> +++ b/board/pine64/rockpro64_rk3399/rockpro64-rk3399.c
> @@ -11,7 +11,6 @@
>  #include <asm/arch-rockchip/clock.h>
>  #include <asm/arch-rockchip/grf_rk3399.h>
>  #include <asm/arch-rockchip/hardware.h>
> -#include <asm/arch-rockchip/misc.h>
> 
>  #define GRF_IO_VSEL_BT565_SHIFT 0
>  #define PMUGRF_CON0_VSEL_SHIFT 8
> @@ -31,26 +30,11 @@ static void setup_iodomain(void)
>  	rk_setreg(&pmugrf->soc_con0, 1 << PMUGRF_CON0_VSEL_SHIFT);
>  }
> 
> -int misc_init_r(void)
> +int rockchip_early_misc_init_r(void)
>  {
> -	const u32 cpuid_offset = 0x7;
> -	const u32 cpuid_length = 0x10;
> -	u8 cpuid[cpuid_length];
> -	int ret;
> -
>  	setup_iodomain();
> 
> -	ret = rockchip_cpuid_from_efuse(cpuid_offset, cpuid_length, cpuid);
> -	if (ret)
> -		return ret;
> -
> -	ret = rockchip_cpuid_set(cpuid, cpuid_length);
> -	if (ret)
> -		return ret;
> -
> -	ret = rockchip_setup_macaddr();
> -
> -	return ret;
> +	return 0;
>  }
> 
>  #endif

  parent reply	other threads:[~2024-02-03 13:19 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 14:49 [PATCH 00/18] rockchip: add support for Theobroma JAGUAR SBC-RK3588-AMR Quentin Schulz
2024-01-23 14:49 ` [PATCH 01/18] rockchip: rk3588: use mainline pmu-grf compatible Quentin Schulz
2024-02-01  2:47   ` Kever Yang
2024-02-02  4:25   ` Weizhao Ouyang
2024-01-23 14:49 ` [PATCH 02/18] rockchip: rk3588: sync rk3588s dtsi from v6.8-rc1 Quentin Schulz
2024-02-01  2:47   ` Kever Yang
2024-01-23 14:49 ` [PATCH 03/18] rockchip: avoid out-of-bounds when computing cpuid Quentin Schulz
2024-02-01  2:48   ` Kever Yang
2024-01-23 14:49 ` [PATCH 04/18] rockchip: add weak function symbol called at the beginning of misc_init_r Quentin Schulz
2024-02-01  2:48   ` Kever Yang
2024-02-03 13:16   ` Dragan Simic
2024-01-23 14:49 ` [PATCH 05/18] rockchip: google: gru: migrate to rockchip_early_misc_init_r Quentin Schulz
2024-02-01  2:48   ` Kever Yang
2024-01-23 14:49 ` [PATCH 06/18] rockchip: pine64: pinebook: " Quentin Schulz
2024-02-01  2:48   ` Kever Yang
2024-02-01  4:02     ` Dragan Simic
2024-02-01 17:46       ` Quentin Schulz
2024-02-01 17:56         ` Dragan Simic
2024-02-03 13:18       ` Dragan Simic
2024-01-23 14:49 ` [PATCH 07/18] rockchip: pine64: pinephone: " Quentin Schulz
2024-02-01  2:48   ` Kever Yang
2024-02-03 13:18   ` Dragan Simic
2024-01-23 14:49 ` [PATCH 08/18] rockchip: pine64: rockpro64: " Quentin Schulz
2024-02-01  2:48   ` Kever Yang
2024-02-03 13:19   ` Dragan Simic [this message]
2024-02-03 14:18     ` Jonas Karlman
2024-02-03 15:18       ` Dragan Simic
2024-02-04  4:21         ` Dragan Simic
2024-02-04  9:46           ` Jonas Karlman
2024-02-04 10:39             ` Dragan Simic
2024-02-06 12:26               ` Quentin Schulz
2024-02-06 12:33                 ` Dragan Simic
2024-02-06 12:37                   ` Quentin Schulz
2024-02-06 12:42                     ` Dragan Simic
2024-01-23 14:49 ` [PATCH 09/18] rockchip: theobroma-systems: puma: " Quentin Schulz
2024-02-01  2:49   ` Kever Yang
2024-01-23 14:49 ` [PATCH 10/18] rockchip: theobroma-systems: ringneck: " Quentin Schulz
2024-02-01  2:49   ` Kever Yang
2024-01-23 14:49 ` [PATCH 11/18] rockchip: merge misc.c into board.c Quentin Schulz
2024-02-01  2:49   ` Kever Yang
2024-01-23 14:49 ` [PATCH 12/18] rockchip: transform rockchip_capsule_update_board_setup into a weak function symbol Quentin Schulz
2024-02-01  2:49   ` Kever Yang
2024-01-23 14:49 ` [PATCH 13/18] rockchip: rk3588: fix non-working SD controller if booting from other media Quentin Schulz
2024-01-24 10:19   ` Kever Yang
2024-01-24 10:50     ` Quentin Schulz
2024-01-25 10:29       ` Kever Yang
2024-01-25 11:02         ` Quentin Schulz
2024-01-26  2:57           ` Kever Yang
2024-01-26 10:37             ` Quentin Schulz
2024-01-26 11:04               ` Dragan Simic
2024-01-26 11:09                 ` Quentin Schulz
2024-01-26 11:24                   ` Dragan Simic
2024-01-26 11:29                     ` Quentin Schulz
2024-01-26 11:33                       ` Dragan Simic
2024-01-26 13:46                         ` Quentin Schulz
2024-01-26 19:42                           ` Dragan Simic
2024-01-23 14:49 ` [PATCH 14/18] rockchip: rk3588: add constants for some register address spaces Quentin Schulz
2024-02-01  2:58   ` Kever Yang
2024-01-23 14:49 ` [PATCH 15/18] rockchip: migrate hardware.h inclusion into appropriate files Quentin Schulz
2024-01-24 10:46   ` Kever Yang
2024-01-24 11:12     ` Quentin Schulz
2024-01-29  9:55       ` Kever Yang
2024-01-23 14:49 ` [PATCH 16/18] rockchip: include asm/io.h directly in asm/arch-rockchip/hardware.h Quentin Schulz
2024-02-01  2:59   ` Kever Yang
2024-01-23 14:49 ` [PATCH 17/18] rockchip: rk3588: bind MMC controllers in U-Boot proper pre-reloc Quentin Schulz
2024-01-24 10:35   ` Kever Yang
2024-01-24 11:04     ` Quentin Schulz
2024-01-26  8:58       ` Kever Yang
2024-01-26  9:32         ` Quentin Schulz
2024-01-26 10:56           ` Kever Yang
2024-01-26 16:18             ` Quentin Schulz
2024-01-29 10:35               ` Kever Yang
2024-01-31 17:55                 ` Quentin Schulz
2024-02-01  2:43                   ` Kever Yang
2024-01-23 14:49 ` [PATCH 18/18] board: rockchip: add Theobroma-Systems RK3588 Jaguar SBC Quentin Schulz
2024-01-23 18:04   ` Quentin Schulz
2024-02-01  2:46   ` Kever Yang

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=0d74e5e5482cd32d7cad714e731d4fb8@manjaro.org \
    --to=dsimic@manjaro.org \
    --cc=agust@denx.de \
    --cc=alpernebiyasak@gmail.com \
    --cc=andy.yan@rock-chips.com \
    --cc=foss+uboot@0leil.net \
    --cc=heiko.stuebner@cherry.de \
    --cc=heiko@sntech.de \
    --cc=jagan@amarulasolutions.com \
    --cc=joe.hershberger@ni.com \
    --cc=kever.yang@rock-chips.com \
    --cc=klaus.goger@theobroma-systems.com \
    --cc=lukma@denx.de \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=otavio@ossystems.com.br \
    --cc=pbrobinson@gmail.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=quentin.schulz@theobroma-systems.com \
    --cc=rfried.dev@gmail.com \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox