All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree
@ 2017-05-10 12:44 ` Philipp Tomsich
  2017-05-10 12:44   ` [U-Boot] [PATCH v3 2/2] doc: document u-boot, mmc-env-offset and u-boot, mmc-env-offset-redund Philipp Tomsich
  2017-05-15 21:33   ` [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree Jaehoon Chung
  0 siblings, 2 replies; 5+ messages in thread
From: Philipp Tomsich @ 2017-05-10 12:44 UTC (permalink / raw)
  To: u-boot

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 v3:
- changes the config-check to depend on CONFIG_OF_CONTROL to detect
  if 'fdtdec_get_config_int' is available

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..c10eec5 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)
+#if defined(CONFIG_OF_CONTROL)
+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;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v3 2/2] doc: document u-boot, mmc-env-offset and u-boot, mmc-env-offset-redund
  2017-05-10 12:44 ` [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree Philipp Tomsich
@ 2017-05-10 12:44   ` Philipp Tomsich
  2017-05-16  0:18     ` Simon Glass
  2017-05-15 21:33   ` [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree Jaehoon Chung
  1 sibling, 1 reply; 5+ messages in thread
From: Philipp Tomsich @ 2017-05-10 12:44 UTC (permalink / raw)
  To: u-boot

Adding documentation on the new config properties:
       'u-boot,mmc-env-offset' - overrides CONFIG_ENV_OFFSET
       'u-boot,mmc-env-offset-redundant'
                               - overrides CONFIG_ENV_OFFSET_REDUND

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>

---

Changes in v3: None
Changes in v2:
- added documentation in config.txt

 doc/device-tree-bindings/config.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/doc/device-tree-bindings/config.txt b/doc/device-tree-bindings/config.txt
index d4bc1df..fe0e04a 100644
--- a/doc/device-tree-bindings/config.txt
+++ b/doc/device-tree-bindings/config.txt
@@ -21,6 +21,18 @@ u-boot,efi-partition-entries-offset
 
 	This setting will override any values configured via Kconfig.
 
+u-boot,mmc-env-offset
+u-boot,mmc-env-offset-redundant
+	If present, the values of the 'u-boot,mmc-env-offset' and/or
+	of the u-boot,mmc-env-offset-redundant' properties overrides
+	CONFIG_ENV_OFFSET and CONFIG_ENV_OFFSET_REDUND, respectively,
+	for SD/MMC devices.
+
+	Values are interpreted as the offset from the start of the
+	device, specified in bytes.  It is assumed that the setting
+	will point at the beginning of a LBA and values that are not
+	LBA-aligned will be rounded up to the next LBA address.
+
 u-boot,spl-payload-offset
 	If present (and SPL is controlled by the device-tree), this allows
 	to override the CONFIG_SYS_SPI_U_BOOT_OFFS setting using a value
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree
  2017-05-10 12:44 ` [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree Philipp Tomsich
  2017-05-10 12:44   ` [U-Boot] [PATCH v3 2/2] doc: document u-boot, mmc-env-offset and u-boot, mmc-env-offset-redund Philipp Tomsich
@ 2017-05-15 21:33   ` Jaehoon Chung
  2017-05-15 22:21     ` Dr. Philipp Tomsich
  1 sibling, 1 reply; 5+ messages in thread
From: Jaehoon Chung @ 2017-05-15 21:33 UTC (permalink / raw)
  To: u-boot

Hi Philipp,

On 05/10/2017 09:44 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>

your patch has the compile error about building spl.

+common/built-in.o: In function `mmc_offset':
+common/env_mmc.c:53: undefined reference to `fdtdec_get_config_int'
+make[2]: *** [spl/u-boot-spl] Error 1
+make[1]: *** [spl/u-boot-spl] Error 2
+make: *** [sub-make] Error 2

Plz, fix this.


Best Regards,
Jaehoon Chung

> ---
> 
> Changes in v3:
> - changes the config-check to depend on CONFIG_OF_CONTROL to detect
>   if 'fdtdec_get_config_int' is available
> 
> 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..c10eec5 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)
> +#if defined(CONFIG_OF_CONTROL)
> +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;
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree
  2017-05-15 21:33   ` [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree Jaehoon Chung
@ 2017-05-15 22:21     ` Dr. Philipp Tomsich
  0 siblings, 0 replies; 5+ messages in thread
From: Dr. Philipp Tomsich @ 2017-05-15 22:21 UTC (permalink / raw)
  To: u-boot

Hi Jaehoon,

I haven’t been able to reproduce this on any our configs, but I believe to have caught
the issue: testing the OF_CONTROL using defined(CONFIG_OF_CONTROL) gives
a false positive in the SPL build, as the SPL infrastructure does not undefine it … yet,
lib/Makefile uses CONFIG_$(SPL_)OF_CONTROL to control the inclusion of fdtdec.o.

Please let me know if the resubmitted (v4) series fixes the issue on the configurations
that you see the error on.  If not, I’d appreciate a pointer to one of the broken configurations
so I can reproduce locally.

Best regards,
Philipp.

> On 15 May 2017, at 23:33, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> 
> Hi Philipp,
> 
> On 05/10/2017 09:44 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>
> 
> your patch has the compile error about building spl.
> 
> +common/built-in.o: In function `mmc_offset':
> +common/env_mmc.c:53: undefined reference to `fdtdec_get_config_int'
> +make[2]: *** [spl/u-boot-spl] Error 1
> +make[1]: *** [spl/u-boot-spl] Error 2
> +make: *** [sub-make] Error 2
> 
> Plz, fix this.
> 
> 
> Best Regards,
> Jaehoon Chung
> 
>> ---
>> 
>> Changes in v3:
>> - changes the config-check to depend on CONFIG_OF_CONTROL to detect
>>  if 'fdtdec_get_config_int' is available
>> 
>> 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..c10eec5 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)
>> +#if defined(CONFIG_OF_CONTROL)
>> +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;
>> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v3 2/2] doc: document u-boot, mmc-env-offset and u-boot, mmc-env-offset-redund
  2017-05-10 12:44   ` [U-Boot] [PATCH v3 2/2] doc: document u-boot, mmc-env-offset and u-boot, mmc-env-offset-redund Philipp Tomsich
@ 2017-05-16  0:18     ` Simon Glass
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2017-05-16  0:18 UTC (permalink / raw)
  To: u-boot

On 10 May 2017 at 06:44, Philipp Tomsich
<philipp.tomsich@theobroma-systems.com> wrote:
> Adding documentation on the new config properties:
>        'u-boot,mmc-env-offset' - overrides CONFIG_ENV_OFFSET
>        'u-boot,mmc-env-offset-redundant'
>                                - overrides CONFIG_ENV_OFFSET_REDUND
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
>
> ---
>
> Changes in v3: None
> Changes in v2:
> - added documentation in config.txt
>
>  doc/device-tree-bindings/config.txt | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-16  0:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170510124509epcas1p31c5f03706e5cf2342d285b8fba93330d@epcas1p3.samsung.com>
2017-05-10 12:44 ` [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree Philipp Tomsich
2017-05-10 12:44   ` [U-Boot] [PATCH v3 2/2] doc: document u-boot, mmc-env-offset and u-boot, mmc-env-offset-redund Philipp Tomsich
2017-05-16  0:18     ` Simon Glass
2017-05-15 21:33   ` [U-Boot] [PATCH v3 1/2] env_mmc: configure environment offsets via device tree Jaehoon Chung
2017-05-15 22:21     ` Dr. Philipp Tomsich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.