u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Quentin Schulz via U-Boot <u-boot@lists.u-boot-project.org>
To: Fabio Estevam <festevam@gmail.com>
Cc: trini@konsulko.com, sjg@chromium.org, kever.yang@rock-chips.com,
	u-boot@lists.u-boot-project.org,
	Fabio Estevam <festevam@nabladev.com>
Subject: Re: [PATCH v4 3/4] rockchip: rk3399: Add ROC-PC-PLUS board detection
Date: Tue, 11 Aug 2026 13:55:35 +0200	[thread overview]
Message-ID: <d4d49e17-e125-4121-b0be-e486e1be5393@0leil.net> (raw)
In-Reply-To: <20260722194638.1285159-3-festevam@gmail.com>

Hi Fabio,

On 7/22/26 9:46 PM, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@nabladev.com>
> 
> The ROC-RK3399-PC has an MP8859 regulator on I2C7 at address 0x66,
> while the ROC-RK3399-PC-PLUS does not. Probe for the regulator in SPL
> and use the result to select the matching devicetree from the U-Boot
> FIT. Fall back to the original board if the I2C bus cannot be probed.
> 
> Build both devicetrees from the existing roc-pc-rk3399_defconfig and
> enable the XMC SPI NOR driver used by the Plus variant. Set fdtfile
> from the selected U-Boot devicetree so the matching Linux devicetree
> is used as well.
> 
> Signed-off-by: Fabio Estevam <festevam@nabladev.com>
> ---
> Changes since v3:
> - Explicitly sets fdtfile for both PC and PC-PLUS.
> 
>   arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi |  3 ++
>   arch/arm/dts/rk3399-roc-pc-u-boot.dtsi      |  8 +++++
>   board/firefly/roc-pc-rk3399/roc-pc-rk3399.c | 39 +++++++++++++++++++++
>   configs/roc-pc-rk3399_defconfig             |  3 ++
>   doc/board/rockchip/rockchip.rst             |  2 +-
>   5 files changed, 54 insertions(+), 1 deletion(-)
>   create mode 100644 arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi
> 
> diff --git a/arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi b/arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi
> new file mode 100644
> index 000000000000..c80529a62b97
> --- /dev/null
> +++ b/arch/arm/dts/rk3399-roc-pc-plus-u-boot.dtsi
> @@ -0,0 +1,3 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +#include "rk3399-roc-pc-u-boot.dtsi"
> diff --git a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
> index a85e9549c83e..e7e4a2c89072 100644
> --- a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
> +++ b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi
> @@ -12,6 +12,14 @@
>   	};
>   };
>   
> +&i2c7 {
> +	bootph-pre-ram;
> +};
> +
> +&i2c7_xfer {
> +	bootph-pre-ram;
> +};
> +
>   &gpio4 {
>   	bootph-pre-ram;
>   };
> diff --git a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c
> index 6937a27176f9..a12180e65573 100644
> --- a/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c
> +++ b/board/firefly/roc-pc-rk3399/roc-pc-rk3399.c
> @@ -5,14 +5,24 @@
>   
>   #include <dm.h>
>   #include <env.h>
> +#include <fdtdec.h>
> +#include <i2c.h>
> +#include <image.h>
>   #include <log.h>
>   #include <spl_gpio.h>
> +#include <asm/global_data.h>
>   #include <asm/io.h>
>   
>   #include <asm/arch-rockchip/cru.h>
>   #include <asm/arch-rockchip/gpio.h>
>   #include <asm/arch-rockchip/grf_rk3399.h>
>   
> +#define ROC_PC_MP8859_BUS	"i2c@ff160000"
> +#define ROC_PC_MP8859_ADDR	0x66
> +#define ROC_PC_PLUS_FDTFILE	"rockchip/rk3399-roc-pc-plus.dtb"
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
>   #ifdef CONFIG_XPL_BUILD
>   
>   #define PMUGRF_BASE	0xff320000
> @@ -54,4 +64,33 @@ void led_setup(void)
>   	spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1);
>   }
>   
> +static bool is_roc_pc_plus(void)
> +{
> +	struct udevice *bus, *dev;
> +
> +	if (uclass_get_device_by_name(UCLASS_I2C, ROC_PC_MP8859_BUS, &bus))
> +		return false;
> +
> +	return dm_i2c_probe(bus, ROC_PC_MP8859_ADDR, 0, &dev);

This fails to build due to undefined reference to dm_i2c_probe in SPL:

+Some images are invalid
    aarch64:  +   roc-pc-mezzanine-rk3399
+aarch64-linux-ld: board/firefly/roc-pc-rk3399/roc-pc-rk3399.o: in 
function `is_roc_pc_plus':
+board/firefly/roc-pc-rk3399/roc-pc-rk3399.c:74:(.text.board_fit_config_name_match+0x38): 
undefined reference to `dm_i2c_probe'
+make[2]: *** [scripts/Makefile.xpl:546: spl/u-boot-spl] Error 1
+make[1]: *** [Makefile:2448: spl/u-boot-spl] Error 2
+make: *** [Makefile:189: __sub-make] Error 2

c.f. 
https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/jobs/67143#L592

Note this applies to the roc-pc-mezzanine-rk3399 defconfig which is only 
slightly different from roc-pc-rk3399.

Ideally, we should be able to automatically detect whether it's a 
roc-pc-mezzanine-rk3399, but I couldn't find schematics for it and from 
the Device Tree, there doesn't seem to be something we could use to 
detect it like we do for ROC-PC-PLUS/ROC-PC. So instead I recommend to 
check for CONFIG_IS_ENABLED(DM_I2C). If it ever gets enabled for 
roc-pc-mezzanine-rk3399_defconfig, the logic will return that it's NOT a 
ROC-PC-PLUS and thus use CONFIG_DEFAULT_FDT_FILE which is 
rockchip/rk3399-roc-pc-mezzanine.dtb which is correct.

What do you think? Can you send a v5 for this? Please pick Takahiro's 
R-b and the Link that was suggested to be added to the commit log of 
patch 1.

Thanks!
Quentin

  parent reply	other threads:[~2026-08-11 11:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 19:46 [PATCH v4 1/4] mtd: spi-nor-ids: Add XMC XM25QH128C Fabio Estevam via U-Boot
2026-07-22 19:46 ` [PATCH v4 2/4] rockchip: rk3399: Remove ROC-PC regulator overrides Fabio Estevam via U-Boot
2026-07-22 19:46 ` [PATCH v4 3/4] rockchip: rk3399: Add ROC-PC-PLUS board detection Fabio Estevam via U-Boot
2026-07-23 10:49   ` Quentin Schulz
2026-08-11 11:55   ` Quentin Schulz via U-Boot [this message]
2026-08-11 23:01     ` Fabio Estevam
2026-08-12  8:04       ` Quentin Schulz via U-Boot
2026-08-12 21:48         ` Fabio Estevam
2026-08-13  8:05           ` Quentin Schulz via U-Boot
2026-07-22 19:46 ` [PATCH v4 4/4] rockchip: roc-pc-rk3399: Enable redundant environment Fabio Estevam via U-Boot
2026-07-23 10:50   ` Quentin Schulz
2026-07-29  8:59 ` [PATCH v4 1/4] mtd: spi-nor-ids: Add XMC XM25QH128C Takahiro.Kuwano
2026-07-30 14:26   ` Quentin Schulz via U-Boot
2026-07-31  0:37   ` Fabio Estevam
2026-07-31  3:47     ` Takahiro.Kuwano

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=d4d49e17-e125-4121-b0be-e486e1be5393@0leil.net \
    --to=u-boot@lists.u-boot-project.org \
    --cc=festevam@gmail.com \
    --cc=festevam@nabladev.com \
    --cc=kever.yang@rock-chips.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@0leil.net \
    /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;
as well as URLs for NNTP newsgroup(s).