Hi Igor,

On 06/22/2016 06:02 PM, Igor Grinberg wrote:
> Hi Christopher,
> 
> On 06/19/2016 06:44 PM, Christopher Spinrath wrote:
>> The cm-fx6 module has an on-board st,m25p compatible spi flash chip
>> used for u-boot (binary & environment). Overwrite the partitions in
>> the device tree by the partition table provided in the mtdparts
>> environment variable, if it is set.
>>
>> This allows to specify a kernel independent partitioning in the
>> environment and provides a convient way for the user to adapt the
>> partition table.
>>
>> Signed-off-by: Christopher Spinrath <[email protected]>
>> ---
>>  board/compulab/cm_fx6/cm_fx6.c | 16 +++++++++++++++-
>>  1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
>> index 712057a..81a7ae2 100644
>> --- a/board/compulab/cm_fx6/cm_fx6.c
>> +++ b/board/compulab/cm_fx6/cm_fx6.c
>> @@ -12,6 +12,7 @@
>>  #include <dm.h>
>>  #include <fsl_esdhc.h>
>>  #include <miiphy.h>
>> +#include <mtd_node.h>
>>  #include <netdev.h>
>>  #include <errno.h>
>>  #include <usb.h>
>> @@ -28,6 +29,7 @@
>>  #include <asm/io.h>
>>  #include <asm/gpio.h>
>>  #include <dm/platform_data/serial_mxc.h>
>> +#include <jffs2/load_kernel.h>
> 
> Why is this needed?
> 
The MTD_DEV_TYPE_NOR constant is defined in this header. I agree that it
is a bit ugly but this header is used for the same purpose in other
board files, too (e.g.board/pdm360ng/pdm360ng.c).

>>  #include "common.h"
>>  #include "../common/eeprom.h"
>>  #include "../common/common.h"
>> @@ -581,6 +583,13 @@ int cm_fx6_setup_ecspi(void) { return 0; }
>>  
>>  #ifdef CONFIG_OF_BOARD_SETUP
>>  #define USDHC3_PATH "/soc/aips-bus@02100000/usdhc@02198000/"
>> +
>> +#ifdef CONFIG_FDT_FIXUP_PARTITIONS
>> +struct node_info nodes[] = {
>> +    { "st,m25p",    MTD_DEV_TYPE_NOR,       },
>> +};
>> +#endif
>> +
>>  int ft_board_setup(void *blob, bd_t *bd)
>>  {
>>      u32 baseboard_rev;
>> @@ -589,6 +598,8 @@ int ft_board_setup(void *blob, bd_t *bd)
>>      char baseboard_name[16];
>>      int err;
>>  
>> +    fdt_shrink_to_minimum(blob); /* Make room for new properties */
>> +
>>      /* MAC addr */
>>      if (eth_getenv_enetaddr("ethaddr", enetaddr)) {
>>              fdt_find_and_setprop(blob,
>> @@ -607,7 +618,6 @@ int ft_board_setup(void *blob, bd_t *bd)
>>              return 0; /* Assume not an early revision SB-FX6m baseboard */
>>  
>>      if (!strncmp("SB-FX6m", baseboard_name, 7) && baseboard_rev <= 120) {
>> -            fdt_shrink_to_minimum(blob); /* Make room for new properties */
>>              nodeoffset = fdt_path_offset(blob, USDHC3_PATH);
>>              fdt_delprop(blob, nodeoffset, "cd-gpios");
>>              fdt_find_and_setprop(blob, USDHC3_PATH, "broken-cd",
>> @@ -616,6 +626,10 @@ int ft_board_setup(void *blob, bd_t *bd)
>>                                   NULL, 0, 1);
>>      }
>>  
>> +#ifdef CONFIG_FDT_FIXUP_PARTITIONS
>> +    fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
>> +#endif
> 
> I really dislike the ifdeffery inside functions.
> Care to introduce a stub for the !CONFIG_FDT_FIXUP_PARTITIONS case in
> include/fdt_support.h for this one?
> 
Sure. Is the header the correct place for this or should I add a #else
case in the .c file?

Cheers,
Christopher

>> +
>>      return 0;
>>  }
>>  #endif
>>
> 
_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to