diff mbox

[U-Boot,v2,1/2] env_mmc: configure environment offsets via device tree

Message ID 1493105963-44967-2-git-send-email-philipp.tomsich@theobroma-systems.com
State Superseded
Delegated to: Jaehoon Chung
Headers show

Commit Message

Philipp Tomsich April 25, 2017, 7:39 a.m. UTC
This introduces the ability to override the environment offets from the
device tree by setting the following nodes in '/config':
	'u-boot,mmc-env-offset' - overrides CONFIG_ENV_OFFSET
	'u-boot,mmc-env-offset-redundant'
				- overrides CONFIG_ENV_OFFSET_REDUND

To keep with the previous logic, the CONFIG_* defines still need to
be available and the statically defined values become the defaults,
when the corresponding properties are not set in the device-tree.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Acked-by: Simon Glass <sjg@chromium.org>

---

Changes in v2: None

 common/env_mmc.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

Comments

Jaehoon Chung May 10, 2017, 11:49 a.m. UTC | #1
Hi,

On 04/25/2017 04:39 PM, Philipp Tomsich wrote:
> This introduces the ability to override the environment offets from the
> device tree by setting the following nodes in '/config':
> 	'u-boot,mmc-env-offset' - overrides CONFIG_ENV_OFFSET
> 	'u-boot,mmc-env-offset-redundant'
> 				- overrides CONFIG_ENV_OFFSET_REDUND
> 
> To keep with the previous logic, the CONFIG_* defines still need to
> be available and the statically defined values become the defaults,
> when the corresponding properties are not set in the device-tree.
> 
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Acked-by: Simon Glass <sjg@chromium.org>

There are build error with some configs..

+common/built-in.o: In function `mmc_offset':
+common/env_mmc.c:53: undefined reference to `fdtdec_get_config_int'


Best Regards,
Jaehoon Chung

> 
> ---
> 
> Changes in v2: None
> 
>  common/env_mmc.c | 31 +++++++++++++++++++++++++++----
>  1 file changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/common/env_mmc.c b/common/env_mmc.c
> index a5d14d4..65c5690 100644
> --- a/common/env_mmc.c
> +++ b/common/env_mmc.c
> @@ -10,6 +10,7 @@
>  
>  #include <command.h>
>  #include <environment.h>
> +#include <fdtdec.h>
>  #include <linux/stddef.h>
>  #include <malloc.h>
>  #include <memalign.h>
> @@ -36,15 +37,37 @@ DECLARE_GLOBAL_DATA_PTR;
>  #define CONFIG_ENV_OFFSET 0
>  #endif
>  
> -__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
> +#ifdef CONFIG_OF_LIBFDT
> +static inline s64 mmc_offset(int copy)
>  {
> -	s64 offset;
> +	const char *propname = "u-boot,mmc-env-offset";
> +	s64 defvalue = CONFIG_ENV_OFFSET;
>  
> -	offset = CONFIG_ENV_OFFSET;
> -#ifdef CONFIG_ENV_OFFSET_REDUND
> +#if defined(CONFIG_ENV_OFFSET_REDUND)
> +	if (copy) {
> +		propname = "u-boot,mmc-env-offset-redundant";
> +		defvalue = CONFIG_ENV_OFFSET_REDUND;
> +	}
> +#endif
> +
> +	return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue);
> +}
> +#else
> +static inline s64 mmc_offset(int copy)
> +{
> +	s64 offset = CONFIG_ENV_OFFSET;
> +
> +#if defined(CONFIG_ENV_OFFSET_REDUND)
>  	if (copy)
>  		offset = CONFIG_ENV_OFFSET_REDUND;
>  #endif
> +	return offset;
> +}
> +#endif
> +
> +__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
> +{
> +	s64 offset = mmc_offset(copy);
>  
>  	if (offset < 0)
>  		offset += mmc->capacity;
>
diff mbox

Patch

diff --git a/common/env_mmc.c b/common/env_mmc.c
index a5d14d4..65c5690 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -10,6 +10,7 @@ 
 
 #include <command.h>
 #include <environment.h>
+#include <fdtdec.h>
 #include <linux/stddef.h>
 #include <malloc.h>
 #include <memalign.h>
@@ -36,15 +37,37 @@  DECLARE_GLOBAL_DATA_PTR;
 #define CONFIG_ENV_OFFSET 0
 #endif
 
-__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
+#ifdef CONFIG_OF_LIBFDT
+static inline s64 mmc_offset(int copy)
 {
-	s64 offset;
+	const char *propname = "u-boot,mmc-env-offset";
+	s64 defvalue = CONFIG_ENV_OFFSET;
 
-	offset = CONFIG_ENV_OFFSET;
-#ifdef CONFIG_ENV_OFFSET_REDUND
+#if defined(CONFIG_ENV_OFFSET_REDUND)
+	if (copy) {
+		propname = "u-boot,mmc-env-offset-redundant";
+		defvalue = CONFIG_ENV_OFFSET_REDUND;
+	}
+#endif
+
+	return fdtdec_get_config_int(gd->fdt_blob, propname, defvalue);
+}
+#else
+static inline s64 mmc_offset(int copy)
+{
+	s64 offset = CONFIG_ENV_OFFSET;
+
+#if defined(CONFIG_ENV_OFFSET_REDUND)
 	if (copy)
 		offset = CONFIG_ENV_OFFSET_REDUND;
 #endif
+	return offset;
+}
+#endif
+
+__weak int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr)
+{
+	s64 offset = mmc_offset(copy);
 
 	if (offset < 0)
 		offset += mmc->capacity;