[PATCH] mci: arasan: rework register_sdclk

2024-04-08 Thread Steffen Trumtrar
_clk_data *clk_data,
clk_name = __clk_get_name(clk_xin);
sampleclk_init.parent_names = _name;
sampleclk_init.num_parents = 1;
-   sampleclk_init.ops = _sampleclk_ops;
+   sampleclk_init.ops = sdhci_arasan->sampleclk_ops;
 
clk_data->sampleclk_hw.init = _init;
clk_data->sampleclk = clk_register(dev, _data->sampleclk_hw);
@@ -559,10 +570,11 @@ arasan_sdhci_register_sampleclk(struct 
sdhci_arasan_clk_data *clk_data,
  * Return: 0 on success and error value on error
  */
 static int
-arasan_sdhci_register_sdcardclk(struct sdhci_arasan_clk_data *clk_data,
+arasan_sdhci_register_sdcardclk(struct arasan_sdhci_host *sdhci_arasan,
struct clk *clk_xin,
struct device *dev)
 {
+   struct sdhci_arasan_clk_data *clk_data = _arasan->clk_data;
struct device_node *np = dev->of_node;
struct clk_init_data sdcardclk_init = {};
const char *clk_name;
@@ -577,7 +589,7 @@ arasan_sdhci_register_sdcardclk(struct 
sdhci_arasan_clk_data *clk_data,
 
clk_name = __clk_get_name(clk_xin);
sdcardclk_init.parent_names = _name;
-   sdcardclk_init.ops = _sdcardclk_ops;
+   sdcardclk_init.ops = sdhci_arasan->sdcardclk_ops;
sdcardclk_init.num_parents = 1;
 
clk_data->sdcardclk_hw.init = _init;
@@ -615,7 +627,7 @@ arasan_sdhci_register_sdcardclk(struct 
sdhci_arasan_clk_data *clk_data,
  *
  * Return: 0 on success and error value on error
  */
-static int arasan_sdhci_register_sdclk(struct sdhci_arasan_clk_data 
*sdhci_arasan,
+static int arasan_sdhci_register_sdclk(struct arasan_sdhci_host *sdhci_arasan,
   struct clk *clk_xin,
   struct device *dev)
 {
@@ -772,8 +784,15 @@ static int arasan_sdhci_probe(struct device *dev)
 
mci->f_min = 5000 / 256;
 
-   if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
-   arasan_sdhci_register_sdclk(_sdhci->clk_data, clk_xin, 
dev);
+   if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) {
+   arasan_sdhci->sdcardclk_ops = _sdcardclk_ops;
+   arasan_sdhci->sampleclk_ops = _sampleclk_ops;
+   } else {
+   arasan_sdhci->sdcardclk_ops = _sdcardclk_ops;
+   arasan_sdhci->sampleclk_ops = _sampleclk_ops;
+   }
+
+   arasan_sdhci_register_sdclk(arasan_sdhci, clk_xin, dev);
 
arasan_dt_parse_clk_phases(dev, _sdhci->clk_data);
 
diff --git a/include/mach/zynqmp/firmware-zynqmp.h 
b/include/mach/zynqmp/firmware-zynqmp.h
index 00c63058f4..9f833189d3 100644
--- a/include/mach/zynqmp/firmware-zynqmp.h
+++ b/include/mach/zynqmp/firmware-zynqmp.h
@@ -119,8 +119,19 @@ struct zynqmp_eemi_ops {
 
 const struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void);
 
+#if defined(CONFIG_ARCH_ZYNQMP)
 int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value);
 int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type);
+#else
+static inline int zynqmp_pm_set_sd_tapdelay(u32 node_id, u32 type, u32 value)
+{
+   return -ENOSYS;
+}
+static inline int zynqmp_pm_sd_dll_reset(u32 node_id, u32 type)
+{
+   return -ENOSYS;
+}
+#endif
 
 int zynqmp_pm_write_ggs(u32 index, u32 value);
 int zynqmp_pm_read_ggs(u32 index, u32 *value);

---
base-commit: aa03dc194997eabf157118b76b0ab5ef88a9faff
change-id: 20240408-v2024-03-0-topic-arasan-fixes-199c8b0710dc

Best regards,
-- 
Steffen Trumtrar 




[PATCH] mci: sdhci: fix dma mapping

2024-04-08 Thread Marco Felsch
In case of MMC_DATA_READ the dest address should be used and in case of
MMC_DATA_WRITE the src address should be used. We had no issues for now
since both dest and src point to same address due to the union.

Signed-off-by: Marco Felsch 
---
 drivers/mci/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index edb819d66d42..a141e504971b 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -233,10 +233,10 @@ void sdhci_setup_data_dma(struct sdhci *sdhci, struct 
mci_data *data,
nbytes = data->blocks * data->blocksize;
 
if (data->flags & MMC_DATA_READ)
-   *dma = dma_map_single(dev, (void *)data->src, nbytes,
+   *dma = dma_map_single(dev, data->dest, nbytes,
  DMA_FROM_DEVICE);
else
-   *dma = dma_map_single(dev, data->dest, nbytes,
+   *dma = dma_map_single(dev, (void *)data->src, nbytes,
  DMA_TO_DEVICE);
 
if (dma_mapping_error(dev, *dma)) {
-- 
2.39.2




[PATCH v2 1/2] bootm: replace CONFIG_BOOTM_FORCE_SIGNED_IMAGES with helper

2024-04-08 Thread Marco Felsch
From: Ahmad Fatoum 

In preparation for allowing even CONFIG_BOOTM_FORCE_SIGNED_IMAGES=n
configurations to force boot of only signed images, replace direct
use of IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES) with a helper that
queries a static variable that can be forced at runtime in a follow-up
commit.

No functional change.

Signed-off-by: Ahmad Fatoum 
Signed-off-by: Marco Felsch 
---
Changelog:
v2:
- add my s-o-b tag
v1:
- 
https://lore.barebox.org/barebox/20231023162748.533468-1-a.fat...@pengutronix.de/

 arch/arm/lib32/bootm.c |  2 +-
 common/bootm.c | 11 +--
 include/bootm.h|  2 ++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index e814593dce43..aeb873a3a723 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -294,7 +294,7 @@ static int __do_bootm_linux(struct image_data *data, 
unsigned long free_mem,
}
 
if (IS_ENABLED(CONFIG_BOOTM_OPTEE)) {
-   if (data->tee_file && 
!IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+   if (data->tee_file && !bootm_signed_images_are_forced()) {
ret = bootm_load_tee_from_file(data);
if (ret)
return ret;
diff --git a/common/bootm.c b/common/bootm.c
index a59fa35008a9..3cd4aa1528a7 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -87,6 +87,13 @@ static const char * const bootm_verify_names[] = {
[BOOTM_VERIFY_SIGNATURE] = "signature",
 };
 
+static bool force_signed_images = IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES);
+
+bool bootm_signed_images_are_forced(void)
+{
+   return force_signed_images;
+}
+
 static int uimage_part_num(const char *partname)
 {
if (!partname)
@@ -694,7 +701,7 @@ int bootm_boot(struct bootm_data *bootm_data)
goto err_out;
}
 
-   if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+   if (bootm_signed_images_are_forced()) {
data->verify = BOOTM_VERIFY_SIGNATURE;
 
/*
@@ -985,7 +992,7 @@ static int bootm_init(void)
globalvar_add_simple("bootm.initrd.loadaddr", NULL);
}
 
-   if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES))
+   if (bootm_signed_images_are_forced())
bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
 
globalvar_add_simple_int("bootm.verbose", _verbosity, "%u");
diff --git a/include/bootm.h b/include/bootm.h
index c69da85cdda1..e4d59b566edf 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -152,6 +152,8 @@ int bootm_get_os_size(struct image_data *data);
 enum bootm_verify bootm_get_verify_mode(void);
 void bootm_set_verify_mode(enum bootm_verify mode);
 
+bool bootm_signed_images_are_forced(void);
+
 #define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1)
 
 void *booti_load_image(struct image_data *data, phys_addr_t *oftree);
-- 
2.39.2




[PATCH v2 2/2] bootm: add support for dynamically forcing signature verification

2024-04-08 Thread Marco Felsch
From: Ahmad Fatoum 

So far, secure booting systems statically configured
CONFIG_BOOTM_FORCE_SIGNED_IMAGES=y to restrict bootm to signed images.

This remains the recommended way, but some systems require the ability
to decide at runtime whether to enforce secure boot or to disable it,
e.g. after verifying a JSON web token with the appropriate claim.

For such systems, provide a bootm_force_signed_images() function.
There's intentionally no unforce counterpart as this is meant to be
non-reversible.

Signed-off-by: Ahmad Fatoum 
Signed-off-by: Marco Felsch 
---
Changelog:
v2:
- fix commit message typo
- add my s-o-b tag
v1:
- 
https://lore.barebox.org/barebox/20231023162748.533468-1-a.fat...@pengutronix.de/

 common/bootm.c  | 16 
 include/bootm.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/common/bootm.c b/common/bootm.c
index 3cd4aa1528a7..c851ab0456b8 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -89,6 +89,22 @@ static const char * const bootm_verify_names[] = {
 
 static bool force_signed_images = IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES);
 
+void bootm_force_signed_images(void)
+{
+   static unsigned int verify_mode = 0;
+
+   if (force_signed_images)
+   return;
+
+   /* recreate bootm.verify with a single enumeration as option */
+   globalvar_remove("bootm.verify");
+   globalvar_add_simple_enum("bootm.verify", _mode,
+ _verify_names[BOOTM_VERIFY_SIGNATURE], 
1);
+
+   bootm_verify_mode = BOOTM_VERIFY_SIGNATURE;
+   force_signed_images = true;
+}
+
 bool bootm_signed_images_are_forced(void)
 {
return force_signed_images;
diff --git a/include/bootm.h b/include/bootm.h
index e4d59b566edf..98ac5e5a9374 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -153,6 +153,7 @@ enum bootm_verify bootm_get_verify_mode(void);
 void bootm_set_verify_mode(enum bootm_verify mode);
 
 bool bootm_signed_images_are_forced(void);
+void bootm_force_signed_images(void);
 
 #define UIMAGE_SOME_ADDRESS (UIMAGE_INVALID_ADDRESS - 1)
 
-- 
2.39.2




Re: [PATCH 2/2] bootm: always apply strict signed FIT boot rules

2024-04-08 Thread Marco Felsch
On 24-04-08, Ahmad Fatoum wrote:
> Hello Marco,
> 
> On 08.04.24 09:36, Marco Felsch wrote:
> > We do use an strict boot rule if the CONFIG_BOOTM_FORCE_SIGNED_IMAGES
> > switch was enabled. Instead of only checking the compile time switch we
> > should check the runtime configurable $global.bootm.verify param too
> > while applying the rule.
> > 
> > Therefore make use of the bootm_get_verify_mode() to query the mode. If
> > CONFIG_BOOTM_FORCE_SIGNED_IMAGES was enabled the only allowed value is
> > BOOTM_VERIFY_SIGNATURE.
> > 
> > Signed-off-by: Marco Felsch 
> 
> Are you aware of 
> https://lore.barebox.org/barebox/20231023162748.533468-1-a.fat...@pengutronix.de/
> 
> Would that address your use case?

Yes :) @Sascha do you have any concerns about Ahmads above patchset
(except the small typo in the 2nd commit message)?

Regards,
  Marco

> 
> Cheers,
> Ahmad
> 
> > ---
> >  common/bootm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/common/bootm.c b/common/bootm.c
> > index e6703b19b3ba..03af3d2b28f7 100644
> > --- a/common/bootm.c
> > +++ b/common/bootm.c
> > @@ -699,7 +699,7 @@ int bootm_boot(struct bootm_data *bootm_data)
> > goto err_out;
> > }
> >  
> > -   if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
> > +   if (bootm_get_verify_mode() == BOOTM_VERIFY_SIGNATURE) {
> > data->verify = BOOTM_VERIFY_SIGNATURE;
> >  
> > /*
> 
> -- 
> 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- |
> 
> 



Re: [PATCH 1/2] bootm: don't allow bootm_set_verify_mode if BOOTM_FORCE_SIGNED_IMAGES is enabled

2024-04-08 Thread Marco Felsch
On 24-04-08, Ahmad Fatoum wrote:
> Hello Marco,
> 
> On 08.04.24 09:36, Marco Felsch wrote:
> > The only allowed value for bootm_verify_mode is BOOTM_VERIFY_SIGNATURE
> > if CONFIG_BOOTM_FORCE_SIGNED_IMAGES is enabled. This is set via the
> > bootm_init() initcall. All further attempts to modify this variable
> > should be prevented.
> > 
> > Signed-off-by: Marco Felsch 
> > ---
> >  common/bootm.c | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/common/bootm.c b/common/bootm.c
> > index a59fa35008a9..e6703b19b3ba 100644
> > --- a/common/bootm.c
> > +++ b/common/bootm.c
> > @@ -75,6 +75,11 @@ enum bootm_verify bootm_get_verify_mode(void)
> >  
> >  void bootm_set_verify_mode(enum bootm_verify mode)
> >  {
> > +   if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
> > +   pr_err("BOOTM_FORCE_SIGNED_IMAGES enabled, prevent modifying 
> > bootm_verify_mode\n");
> > +   return;
> > +   }
> 
> We bootm_set_verify_mode(BOOTM_VERIFY_SIGNATURE) shouldn't result
> in a warning message.

I was considering this as well.. I will add it, thanks.

> With this addressed:
> 
> Reviewed-by: Ahmad Fatoum 
> 
> > +
> > bootm_verify_mode = mode;
> >  }
> >  
> 
> -- 
> 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- |
> 
> 



Re: [PATCH 2/2] bootm: always apply strict signed FIT boot rules

2024-04-08 Thread Ahmad Fatoum
Hello Marco,

On 08.04.24 09:36, Marco Felsch wrote:
> We do use an strict boot rule if the CONFIG_BOOTM_FORCE_SIGNED_IMAGES
> switch was enabled. Instead of only checking the compile time switch we
> should check the runtime configurable $global.bootm.verify param too
> while applying the rule.
> 
> Therefore make use of the bootm_get_verify_mode() to query the mode. If
> CONFIG_BOOTM_FORCE_SIGNED_IMAGES was enabled the only allowed value is
> BOOTM_VERIFY_SIGNATURE.
> 
> Signed-off-by: Marco Felsch 

Are you aware of 
https://lore.barebox.org/barebox/20231023162748.533468-1-a.fat...@pengutronix.de/

Would that address your use case?

Cheers,
Ahmad

> ---
>  common/bootm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index e6703b19b3ba..03af3d2b28f7 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -699,7 +699,7 @@ int bootm_boot(struct bootm_data *bootm_data)
>   goto err_out;
>   }
>  
> - if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
> + if (bootm_get_verify_mode() == BOOTM_VERIFY_SIGNATURE) {
>   data->verify = BOOTM_VERIFY_SIGNATURE;
>  
>   /*

-- 
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- |




Re: [PATCH 1/2] bootm: don't allow bootm_set_verify_mode if BOOTM_FORCE_SIGNED_IMAGES is enabled

2024-04-08 Thread Ahmad Fatoum
Hello Marco,

On 08.04.24 09:36, Marco Felsch wrote:
> The only allowed value for bootm_verify_mode is BOOTM_VERIFY_SIGNATURE
> if CONFIG_BOOTM_FORCE_SIGNED_IMAGES is enabled. This is set via the
> bootm_init() initcall. All further attempts to modify this variable
> should be prevented.
> 
> Signed-off-by: Marco Felsch 
> ---
>  common/bootm.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index a59fa35008a9..e6703b19b3ba 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -75,6 +75,11 @@ enum bootm_verify bootm_get_verify_mode(void)
>  
>  void bootm_set_verify_mode(enum bootm_verify mode)
>  {
> + if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
> + pr_err("BOOTM_FORCE_SIGNED_IMAGES enabled, prevent modifying 
> bootm_verify_mode\n");
> + return;
> + }

We bootm_set_verify_mode(BOOTM_VERIFY_SIGNATURE) shouldn't result
in a warning message.

With this addressed:

Reviewed-by: Ahmad Fatoum 

> +
>   bootm_verify_mode = mode;
>  }
>  

-- 
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- |




[PATCH 2/2] bootm: always apply strict signed FIT boot rules

2024-04-08 Thread Marco Felsch
We do use an strict boot rule if the CONFIG_BOOTM_FORCE_SIGNED_IMAGES
switch was enabled. Instead of only checking the compile time switch we
should check the runtime configurable $global.bootm.verify param too
while applying the rule.

Therefore make use of the bootm_get_verify_mode() to query the mode. If
CONFIG_BOOTM_FORCE_SIGNED_IMAGES was enabled the only allowed value is
BOOTM_VERIFY_SIGNATURE.

Signed-off-by: Marco Felsch 
---
 common/bootm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index e6703b19b3ba..03af3d2b28f7 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -699,7 +699,7 @@ int bootm_boot(struct bootm_data *bootm_data)
goto err_out;
}
 
-   if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+   if (bootm_get_verify_mode() == BOOTM_VERIFY_SIGNATURE) {
data->verify = BOOTM_VERIFY_SIGNATURE;
 
/*
-- 
2.39.2




[PATCH 1/2] bootm: don't allow bootm_set_verify_mode if BOOTM_FORCE_SIGNED_IMAGES is enabled

2024-04-08 Thread Marco Felsch
The only allowed value for bootm_verify_mode is BOOTM_VERIFY_SIGNATURE
if CONFIG_BOOTM_FORCE_SIGNED_IMAGES is enabled. This is set via the
bootm_init() initcall. All further attempts to modify this variable
should be prevented.

Signed-off-by: Marco Felsch 
---
 common/bootm.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/common/bootm.c b/common/bootm.c
index a59fa35008a9..e6703b19b3ba 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -75,6 +75,11 @@ enum bootm_verify bootm_get_verify_mode(void)
 
 void bootm_set_verify_mode(enum bootm_verify mode)
 {
+   if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) {
+   pr_err("BOOTM_FORCE_SIGNED_IMAGES enabled, prevent modifying 
bootm_verify_mode\n");
+   return;
+   }
+
bootm_verify_mode = mode;
 }
 
-- 
2.39.2




Re: [PATCH] arm: mecsbc: fixup /regulator-sd device tree node

2024-04-08 Thread Sascha Hauer


On Fri, 05 Apr 2024 12:12:50 +0200, Sascha Hauer wrote:
> The MECSBC prototype board has a bug which makes the 1.8V SD mode
> unusable. Add a fixup which sets the regulator-min-microvolt property of
> the SD regulator to 3.3V to prevent the Kernel from going into 1.8V.
> 
> 

Applied, thanks!

[1/1] arm: mecsbc: fixup /regulator-sd device tree node
  https://git.pengutronix.de/cgit/barebox/commit/?id=004911504554 (link may 
not be stable)

Best regards,
-- 
Sascha Hauer 




Re: [PATCH 2/4] common: add wolfvision board code library

2024-04-08 Thread Sascha Hauer
On Fri, Apr 05, 2024 at 04:04:43PM +0200, Michael Riesch wrote:
> Add board code library for all WolfVision boards.
> 
> Signed-off-by: Michael Riesch 
> ---
>  common/boards/Kconfig  |   3 +
>  common/boards/Makefile |   1 +
>  common/boards/wolfvision/Makefile  |   2 +
>  common/boards/wolfvision/common.c  | 145 
> +
>  include/boards/wolfvision/common.h |  32 
>  5 files changed, 183 insertions(+)
> 
> diff --git a/common/boards/Kconfig b/common/boards/Kconfig
> index f6d4a56f88..a2a51155ea 100644
> --- a/common/boards/Kconfig
> +++ b/common/boards/Kconfig
> @@ -14,3 +14,6 @@ config BOARD_PHYTEC_SOM_IMX8M_DETECTION
>  config BOARD_TQ
>   select CRC_ITU_T
>   bool
> +
> +config BOARD_WOLFVISION
> + bool
> diff --git a/common/boards/Makefile b/common/boards/Makefile
> index 147c36643d..3f8ac57b2f 100644
> --- a/common/boards/Makefile
> +++ b/common/boards/Makefile
> @@ -3,3 +3,4 @@
>  obj-$(CONFIG_BOARD_QEMU_VIRT)+= qemu-virt/
>  obj-$(CONFIG_BOARD_PHYTEC_SOM_DETECTION) += phytec/
>  obj-$(CONFIG_BOARD_TQ) += tq/
> +obj-$(CONFIG_BOARD_WOLFVISION) += wolfvision/
> diff --git a/common/boards/wolfvision/Makefile 
> b/common/boards/wolfvision/Makefile
> new file mode 100644
> index 00..b2be4b73f4
> --- /dev/null
> +++ b/common/boards/wolfvision/Makefile
> @@ -0,0 +1,2 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +obj-pbl-y += common.o
> diff --git a/common/boards/wolfvision/common.c 
> b/common/boards/wolfvision/common.c
> new file mode 100644
> index 00..188931c24c
> --- /dev/null
> +++ b/common/boards/wolfvision/common.c
> @@ -0,0 +1,145 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Common board code functions WolfVision boards.
> + *
> + * Copyright (C) 2024 WolfVision GmbH.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#define WV_RK3568_HWID_TOLERANCE 50
> +
> +int wolfvision_apply_overlay(const struct wv_overlay *overlay, char **files)
> +{
> + int ret;
> +
> + if (overlay->filename) {
> + if (*files) {
> + char *old = *files;
> + *files = basprintf("%s %s", old, overlay->filename);
> + free(old);
> + } else {
> + *files = basprintf("%s", overlay->filename);
> + }
> + }
> +
> + if (overlay->data) {
> + struct device_node *node =
> + of_unflatten_dtb(overlay->data, INT_MAX);
> +
> + if (!node) {

of_unflatten_dtb returns an error pointer in case of failure.

> + pr_err("Cannot unflatten dtbo\n");

Please provide a pt_fmt() macro to give the messages a meaningful
prefix.

> + return -EINVAL;
> + }
> +
> + ret = of_overlay_apply_tree(of_get_root_node(), node);
> +
> + of_delete_node(node);
> +
> + if (ret) {
> + pr_err("Cannot apply overlay: %s\n", strerror(-ret));

Should be "%pe\n", ERR_PTR(ret)

> + return ret;
> + }
> +
> + of_clk_init();
> + of_probe();
> + }
> +
> + return 0;
> +}
> +
> +int wolfvision_register_ethaddr(void)
> +{
> + struct device_node *eth0;
> + struct state *state;
> + char mac[ETH_ALEN];
> + int ret;
> +
> + ret = of_device_ensure_probed_by_alias("state");
> + if (ret)
> + return ret;
> +
> + state = state_by_name("state");
> + if (!state)
> + return -ENOENT;
> +
> + ret = state_read_mac(state, "mac-address", mac);
> + if (ret)
> + return ret;
> +
> + if (!is_valid_ether_addr(mac))
> + return -EINVAL;
> +
> + eth0 = of_find_node_by_alias(of_get_root_node(), "ethernet0");
> + if (eth0)
> + of_eth_register_ethaddr(eth0, mac);
> +
> + return 0;
> +}
> +
> +int wolfvision_rk3568_get_hwid(int chan_idx)
> +{
> + const int values[WV_RK3568_HWID_MAX] = {
> + 0,112,  225,  337,  450,  562,  675,  787,  900,
> + 1012, 1125, 1237, 1350, 1462, 1575, 1687, 1800,
> + };
> + struct aiochannel *chan;
> + int ret, hwid, voltage;
> + char *chan_name;
> +
> + chan_name = basprintf("saradc.in_value%d_mV", chan_idx);
> + chan = aiochannel_by_name(chan_name);
> + free(chan_name);
> + if (IS_ERR(chan))
> + return PTR_ERR(chan);
> +
> + ret = aiochannel_get_value(chan, );
> + if (ret)
> + return ret;

I just recently added aiochannel_name_get_value() which combines
aiochannel_by_name() and aiochannel_get_value(), you can use this here.

> +
> + for (hwid = 0; hwid < ARRAY_SIZE(values); hwid++)
> + if (abs(voltage - values[hwid]) < WV_RK3568_HWID_TOLERANCE)
> + return hwid;
> +
> + return -EINVAL;
> +};
> +
> +int wolfvision_rk3568_detect_hw(const struct