Re: [U-Boot] [PATCH] spl: add a generic function board_init_r

2019-09-17 Thread Simon Goldschmidt
On Thu, Sep 5, 2019 at 6:50 PM Philippe Reynes
 wrote:
>
> This commit add a generic function board_init_r that
> only initialize some device (for example serial). It
> avoid to define a board function only to launch the
> serial configuration.
>
> Signed-off-by: Philippe Reynes 
> ---
>  common/spl/Kconfig |  8 
>  common/spl/spl.c   | 19 +++
>  2 files changed, 27 insertions(+)
>
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index f467eca..d5b331a 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -25,6 +25,14 @@ config SPL_FRAMEWORK
>   supports MMC, NAND and YMODEM and other methods loading of U-Boot
>   and the Linux Kernel.  If unsure, say Y.
>
> +config SPL_FRAMEWORK_BOARD_INIT_F
> +   bool "Define a generic function board_init_f"
> +   depends on SPL_FRAMEWORK
> +   default n
> +   help
> + Define a generic function board_init_f, unless you want to
> + provide your own board_init_f, you should say Y.
> +
>  config SPL_SIZE_LIMIT
> int "Maximum size of SPL image"
> depends on SPL
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 082fa2b..73bf984 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -566,6 +566,25 @@ static int boot_from_devices(struct spl_image_info 
> *spl_image,
> return -ENODEV;
>  }
>
> +#if defined(CONFIG_SPL_FRAMEWORK_BOARD_INIT_F)
> +void board_init_f(ulong dummy)

You're actually defining 'board_init_f' here, not 'board_init_r' like
the commit message says...

Regards,
Simon

> +{
> +#if CONFIG_IS_ENABLED(OF_CONTROL)
> +   int ret;
> +
> +   ret = spl_early_init();
> +   if (ret) {
> +   debug("spl_early_init() failed: %d\n", ret);
> +   hang();
> +   }
> +#endif
> +
> +#if CONFIG_IS_ENABLED(SERIAL_SUPPORT)
> +   preloader_console_init();
> +#endif
> +}
> +#endif
> +
>  void board_init_r(gd_t *dummy1, ulong dummy2)
>  {
> u32 spl_boot_list[] = {
> --
> 2.7.4
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] spl: add a generic function board_init_r

2019-09-16 Thread Simon Glass
Hi Philippe,

On Thu, 5 Sep 2019 at 09:50, Philippe Reynes
 wrote:
>
> This commit add a generic function board_init_r that
> only initialize some device (for example serial). It
> avoid to define a board function only to launch the
> serial configuration.
>
> Signed-off-by: Philippe Reynes 
> ---
>  common/spl/Kconfig |  8 
>  common/spl/spl.c   | 19 +++
>  2 files changed, 27 insertions(+)
>
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index f467eca..d5b331a 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -25,6 +25,14 @@ config SPL_FRAMEWORK
>   supports MMC, NAND and YMODEM and other methods loading of U-Boot
>   and the Linux Kernel.  If unsure, say Y.
>
> +config SPL_FRAMEWORK_BOARD_INIT_F
> +   bool "Define a generic function board_init_f"
> +   depends on SPL_FRAMEWORK
> +   default n

not needed

> +   help
> + Define a generic function board_init_f, unless you want to
> + provide your own board_init_f, you should say Y.

Should state what this default function does

> +
>  config SPL_SIZE_LIMIT
> int "Maximum size of SPL image"
> depends on SPL
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index 082fa2b..73bf984 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -566,6 +566,25 @@ static int boot_from_devices(struct spl_image_info 
> *spl_image,
> return -ENODEV;
>  }
>
> +#if defined(CONFIG_SPL_FRAMEWORK_BOARD_INIT_F)
> +void board_init_f(ulong dummy)
> +{
> +#if CONFIG_IS_ENABLED(OF_CONTROL)

Can you use if() instead of #if, for these things?

> +   int ret;
> +
> +   ret = spl_early_init();
> +   if (ret) {
> +   debug("spl_early_init() failed: %d\n", ret);
> +   hang();
> +   }
> +#endif
> +
> +#if CONFIG_IS_ENABLED(SERIAL_SUPPORT)
> +   preloader_console_init();
> +#endif
> +}
> +#endif
> +
>  void board_init_r(gd_t *dummy1, ulong dummy2)
>  {
> u32 spl_boot_list[] = {
> --
> 2.7.4
>

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] spl: add a generic function board_init_r

2019-09-05 Thread Philippe Reynes
This commit add a generic function board_init_r that
only initialize some device (for example serial). It
avoid to define a board function only to launch the
serial configuration.

Signed-off-by: Philippe Reynes 
---
 common/spl/Kconfig |  8 
 common/spl/spl.c   | 19 +++
 2 files changed, 27 insertions(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index f467eca..d5b331a 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -25,6 +25,14 @@ config SPL_FRAMEWORK
  supports MMC, NAND and YMODEM and other methods loading of U-Boot
  and the Linux Kernel.  If unsure, say Y.
 
+config SPL_FRAMEWORK_BOARD_INIT_F
+   bool "Define a generic function board_init_f"
+   depends on SPL_FRAMEWORK
+   default n
+   help
+ Define a generic function board_init_f, unless you want to
+ provide your own board_init_f, you should say Y.
+
 config SPL_SIZE_LIMIT
int "Maximum size of SPL image"
depends on SPL
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 082fa2b..73bf984 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -566,6 +566,25 @@ static int boot_from_devices(struct spl_image_info 
*spl_image,
return -ENODEV;
 }
 
+#if defined(CONFIG_SPL_FRAMEWORK_BOARD_INIT_F)
+void board_init_f(ulong dummy)
+{
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+   int ret;
+
+   ret = spl_early_init();
+   if (ret) {
+   debug("spl_early_init() failed: %d\n", ret);
+   hang();
+   }
+#endif
+
+#if CONFIG_IS_ENABLED(SERIAL_SUPPORT)
+   preloader_console_init();
+#endif
+}
+#endif
+
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
u32 spl_boot_list[] = {
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot