ARM: boards: phytec-som-am335x: Add unified MLO
Subsystems (2)
PATCH 3/5 ARM: configs: am335x_defconfig: Add state config
In reply to Daniel SchultzEnable the state framework for all AM335x boards.
--- arch/arm/configs/am335x_defconfig | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/configs/am335x_defconfig +3 -0
@@ -88,6 +88,7 @@ CONFIG_CMD_OF_FIXUP_STATUS=y CONFIG_CMD_OFTREE=y CONFIG_CMD_TIME=y CONFIG_CMD_MMC_EXTCSD=y +CONFIG_CMD_STATE=y CONFIG_NET=y CONFIG_NET_NFS=y CONFIG_NET_NETCONSOLE=y
@@ -142,3 +143,5 @@ CONFIG_FS_FAT_LFN=y CONFIG_FS_UBIFS=y CONFIG_FS_UBIFS_COMPRESSION_LZO=y CONFIG_FS_UBIFS_COMPRESSION_ZLIB=y +CONFIG_STATE=y +CONFIG_STATE_DRV=y
Signature · 7 lines
2.7.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/5 ARM: phytec-som-am335x: Set MAC addresses from state
In reply to Daniel SchultzIf a state with the name 'am335x_phytec_mac_state' is available, valid MAC addresses from this state get registerd to their ethernet device.
--- arch/arm/boards/phytec-som-am335x/board.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/arm/boards/phytec-som-am335x/board.c +22 -0
@@ -21,10 +21,12 @@#include <bootsource.h> #include <common.h> #include <nand.h> +#include <net.h> #include <init.h> #include <io.h> #include <linux/sizes.h> #include <envfs.h> +#include <state.h> #include <asm/armlinux.h> #include <generated/mach-types.h> #include <linux/phy.h>
@@ -67,6 +69,10 @@ static char *nandslots[] = {static int physom_devices_init (void ) { +struct state *state; +struct state_variable *sv; +struct state_mac *mac; +if (!of_machine_is_compatible ("phytec,am335x-som" ))return 0 ;
@@ -114,6 +120,22 @@ static int physom_devices_init(void) ARRAY_SIZE(nandslots));am33xx_bbu_emmc_mlo_register_handler ("MLO.emmc" ,"/dev/mmc1" ); +if (IS_ENABLED (CONFIG_STATE )) { + state =state_by_name ("am335x_phytec_mac_state" ); +if (state) { + sv =state_find_var (state,"mac0" ); +if (!IS_ERR (sv)) { + mac =to_state_mac (sv); +eth_register_ethaddr (0 , mac->value); + } + sv =state_find_var (state,"mac1" ); +if (!IS_ERR (sv)) { + mac =to_state_mac (sv); +eth_register_ethaddr (1 , mac->value); + } + } + } +if (IS_ENABLED (CONFIG_SHELL_NONE ))return am33xx_of_register_bootdevice ();
Signature · 7 lines
2.7.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/5 ARM: boards: phytec-som-am335x: Add unified MLO
PCM-060 modules only have one-bank RAMs populated, which allows us to find out the populated RAM size at run-time.
Therefore, a new entry point was create 'PHYTEC_ENTRY_UNIFIED_MLO'. This creates a MLO for all modules of one family and all existing PCM-060 MLOs were replaced with this new entry point. To provide backward compatibility for older modules, these were not affected.
In the first step generic RAM timings for the module family get loaded, because RAM accesses are only possible with an initialized controller. After that, the RAM size will be calculated and the RAM controller gets reinitialized with the correct RAM timings.
--- arch/arm/boards/phytec-som-am335x/lowlevel.c | 150 +++++++++++++++++++++++---- images/Makefile.am33xx | 24 ++--- 2 files changed, 138 insertions(+), 36 deletions(-)
arch/arm/boards/phytec-som-am335x/lowlevel.c +132 -18
@@ -46,6 +46,94 @@ static const struct am33xx_cmd_control physom_cmd = { .invert_clkout2 = 0x0, }; +/* Module family for the unified MLO +* +* NONE: Unified MLO is not supported +* PHYCORE_R2: Unified MLO for PCM-060, PCM-062 +*/ +enum { +NONE , +PHYCORE_R2 , +}; + +/* @brief Supplies default ram timings for all ram sizes +* +* Returns generic ram timings for module families to find the correct +* ram size. +* +* @return struct am335x_sdram_timings* or NULL +*/ + +static noinline struct am335x_sdram_timings* get_minimal_timings( +int module_family) +{ +struct am335x_sdram_timings *timing; + +switch (module_family) { +case PHYCORE_R2 : + timing = &physom_timings[PHYCORE_R2_MT41K512M16HA125IT_1024MB ]; +break ; +default : + timing =NULL ; + } + +return timing; +} + +/* @brief Converts ramsizes to ram timings for phyCORE-R2 modules +* +* Returns ram timings for a given ram size or NULL, if this size is +* not supported. +* +* @return struct am335x_sdram_timings* or NULL +*/ + +static noinline struct am335x_sdram_timings* convert_phycore_r2_timings( +u32 ramsize) +{ +struct am335x_sdram_timings *timing; + +switch (ramsize) { +case SZ_256M : + timing = &physom_timings[PHYCORE_R2_MT41K128M16JT_256MB ]; +break ; +case SZ_512M : + timing = &physom_timings[PHYCORE_R2_MT41K256M16TW107IT_512MB ]; +break ; +case SZ_1G : + timing = &physom_timings[PHYCORE_R2_MT41K512M16HA125IT_1024MB ]; +break ; +default : + timing =NULL ; + } + +return timing; +} + +/* @brief Converts a module family and ram size to ram timings +* +* Returns ram timings for a given ram size and module family or NULL, +* if the ram size or module family is not supported. +* +* @return struct am335x_sdram_timings* or NULL +*/ + +static noinline struct am335x_sdram_timings* get_timings_by_size( +int module_family,u32 ramsize) +{ +struct am335x_sdram_timings *timing; + +switch (module_family) { +case PHYCORE_R2 : + timing =convert_phycore_r2_timings (ramsize); +break ; +default : + timing =NULL ; + } + +return timing; +} +/** * @brief The basic entry point for board initialization. *
@@ -55,9 +143,10 @@ static const struct am33xx_cmd_control physom_cmd = {* * @return void */ -static noinline void physom_board_init(int sdram, void *fdt) +static noinline void physom_board_init(void *fdt, int sdram, int module_family) { -struct am335x_sdram_timings *timing = &physom_timings[sdram]; +struct am335x_sdram_timings *timing =NULL ; +u32 ramsize;/* * WDT1 is already running when the bootloader gets control
@@ -71,6 +160,24 @@ static noinline void physom_board_init(int sdram, void *fdt)am33xx_pll_init (MPUPLL_M_600 ,DDRPLL_M_400 ); +if (module_family ==NONE ) { + timing = &physom_timings[sdram]; + }else { +/* Load generic DDR3 ram timings to find the ram size */ + timing =get_minimal_timings (module_family); +if (!timing) +hang (); +am335x_sdram_init (DDR_IOCTRL , &physom_cmd, + &timing->regs, + &timing->data); + +/* Find the ram size and set up the correct ram timings */ + ramsize =get_ram_size ((long *)0x80000000 ,SZ_1G ); + timing =get_timings_by_size (module_family, ramsize); +if (!timing) +hang (); + } +am335x_sdram_init (DDR_IOCTRL , &physom_cmd, &timing->regs, &timing->data);
@@ -83,7 +190,8 @@ static noinline void physom_board_init(int sdram, void *fdt)am335x_barebox_entry (fdt); } -static noinline void physom_board_entry(unsigned long bootinfo, int sdram, void *fdt) +static noinline void physom_board_entry(unsigned long bootinfo, int sdram, +void *fdt,int module_family) {am33xx_save_bootinfo ((void *)bootinfo);
@@ -95,26 +203,34 @@ static noinline void physom_board_entry(unsigned long bootinfo, int sdram, void*/ relocate_to_current_adr ();setup_c (); - -physom_board_init (sdram, fdt); +physom_board_init (fdt, sdram, module_family); } -#define PHYTEC_ENTRY_MLO (name, fdt_name, sdram) \ - ENTRY_FUNCTION(name, bootinfo, r1, r2) \ - { \ +#define PHYTEC_ENTRY_UNIFIED_MLO (name, fdt_name, module_family) \ + ENTRY_FUNCTION(name, bootinfo, r1, r2) \ + { \ + extern char __dtb_z_##fdt_name##_start[]; \ + void *fdt = __dtb_z_##fdt_name##_start - \ + get_runtime_offset(); \ + physom_board_entry(bootinfo, 0, fdt, module_family); \ + } + +#define PHYTEC_ENTRY_MLO (name, fdt_name, sdram) \ + ENTRY_FUNCTION(name, bootinfo, r1, r2) \ + { \ extern char __dtb_z_##fdt_name##_start[]; \ void *fdt = __dtb_z_##fdt_name##_start - \ - get_runtime_offset(); \ - physom_board_entry(bootinfo, sdram, fdt); \ + get_runtime_offset(); \ + physom_board_entry(bootinfo, sdram, fdt, NONE); \ } -#define PHYTEC_ENTRY (name, fdt_name) \ - ENTRY_FUNCTION(name, r0, r1, r2) \ - { \ +#define PHYTEC_ENTRY (name, fdt_name) \ + ENTRY_FUNCTION(name, r0, r1, r2) \ + { \ extern char __dtb_z_##fdt_name##_start[]; \ void *fdt = __dtb_z_##fdt_name##_start - \ - get_runtime_offset(); \ - am335x_barebox_entry(fdt); \ + get_runtime_offset(); \ + am335x_barebox_entry(fdt); \ }/* phycore-som */
@@ -122,9 +238,7 @@ PHYTEC_ENTRY_MLO(start_am33xx_phytec_phycore_sram_128mb, am335x_phytec_phycore_sPHYTEC_ENTRY_MLO (start_am33xx_phytec_phycore_sram_256mb, am335x_phytec_phycore_som_mlo,PHYCORE_MT41J128M16125IT_256MB );PHYTEC_ENTRY_MLO (start_am33xx_phytec_phycore_sram_512mb, am335x_phytec_phycore_som_mlo,PHYCORE_MT41J256M16HA15EIT_512MB );PHYTEC_ENTRY_MLO (start_am33xx_phytec_phycore_sram_2x512mb, am335x_phytec_phycore_som_mlo, PHYCORE_MT41J512M8125IT_2x512MB); -PHYTEC_ENTRY_MLO (start_am33xx_phytec_phycore_r2_sram_512mb, am335x_phytec_phycore_som_mlo,PHYCORE_R2_MT41K256M16TW107IT_512MB ); -PHYTEC_ENTRY_MLO (start_am33xx_phytec_phycore_r2_sram_256mb, am335x_phytec_phycore_som_mlo,PHYCORE_R2_MT41K128M16JT_256MB ); -PHYTEC_ENTRY_MLO (start_am33xx_phytec_phycore_r2_sram_1024mb, am335x_phytec_phycore_som_mlo,PHYCORE_R2_MT41K512M16HA125IT_1024MB ); +PHYTEC_ENTRY_UNIFIED_MLO (start_am33xx_phytec_phycore_r2_sram, am335x_phytec_phycore_som_mlo,PHYCORE_R2 );PHYTEC_ENTRY (start_am33xx_phytec_phycore_nand_sdram, am335x_phytec_phycore_som_nand);PHYTEC_ENTRY (start_am33xx_phytec_phycore_emmc_sdram, am335x_phytec_phycore_som_emmc);PHYTEC_ENTRY (start_am33xx_phytec_phycore_nand_no_spi_sdram, am335x_phytec_phycore_som_nand_no_spi);
images/Makefile.am33xx +6 -18
@@ -45,18 +45,18 @@ pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_nand_no_spi FILE_barebox-am33xx-phytec-phycore-no-spi-no-eeprom.img = start_am33xx_phytec_phycore_nand_no_spi_no_eeprom_sdram.pblx am33xx-barebox-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-no-spi-no-eeprom.img +pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_r2_sram +FILE_barebox-am33xx-phytec-phycore-r2-mlo.img = start_am33xx_phytec_phycore_r2_sram.pblx.mlo +FILE_barebox-am33xx-phytec-phycore-r2-mlo.spi.img = start_am33xx_phytec_phycore_r2_sram.pblx.mlospi +am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo.img +am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo.spi.img + pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_sram_256mb FILE_barebox-am33xx-phytec-phycore-mlo-256mb.img = start_am33xx_phytec_phycore_sram_256mb.pblx.mlo FILE_barebox-am33xx-phytec-phycore-mlo-256mb.spi.img = start_am33xx_phytec_phycore_sram_256mb.pblx.mlospi am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-256mb.img am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-256mb.spi.img -pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_r2_sram_256mb -FILE_barebox-am33xx-phytec-phycore-r2-mlo-256mb.img = start_am33xx_phytec_phycore_r2_sram_256mb.pblx.mlo -FILE_barebox-am33xx-phytec-phycore-r2-mlo-256mb.spi.img = start_am33xx_phytec_phycore_r2_sram_256mb.pblx.mlospi -am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-256mb.img -am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-256mb.spi.img - pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_sram_128mb FILE_barebox-am33xx-phytec-phycore-mlo-128mb.img = start_am33xx_phytec_phycore_sram_128mb.pblx.mlo FILE_barebox-am33xx-phytec-phycore-mlo-128mb.spi.img = start_am33xx_phytec_phycore_sram_128mb.pblx.mlospi
@@ -69,24 +69,12 @@ FILE_barebox-am33xx-phytec-phycore-mlo-512mb.spi.img = start_am33xx_phytec_phyco am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-512mb.img am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-512mb.spi.img -pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_r2_sram_512mb -FILE_barebox-am33xx-phytec-phycore-r2-mlo-512mb.img = start_am33xx_phytec_phycore_r2_sram_512mb.pblx.mlo -FILE_barebox-am33xx-phytec-phycore-r2-mlo-512mb.spi.img = start_am33xx_phytec_phycore_r2_sram_512mb.pblx.mlospi -am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-512mb.img -am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-512mb.spi.img - pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_sram_2x512mb FILE_barebox-am33xx-phytec-phycore-mlo-2x512mb.img = start_am33xx_phytec_phycore_sram_2x512mb.pblx.mlo FILE_barebox-am33xx-phytec-phycore-mlo-2x512mb.spi.img = start_am33xx_phytec_phycore_sram_2x512mb.pblx.mlospi am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-2x512mb.img am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-mlo-2x512mb.spi.img -pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phycore_r2_sram_1024mb -FILE_barebox-am33xx-phytec-phycore-r2-mlo-1024mb.img = start_am33xx_phytec_phycore_r2_sram_1024mb.pblx.mlo -FILE_barebox-am33xx-phytec-phycore-r2-mlo-1024mb.spi.img = start_am33xx_phytec_phycore_r2_sram_1024mb.pblx.mlospi -am33xx-mlo-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-1024mb.img -am33xx-mlospi-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phycore-r2-mlo-1024mb.spi.img - pblx-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += start_am33xx_phytec_phyflex_sdram FILE_barebox-am33xx-phytec-phyflex.img = start_am33xx_phytec_phyflex_sdram.pblx am33xx-barebox-$(CONFIG_MACH_PHYTEC_SOM_AM335X) += barebox-am33xx-phytec-phyflex.img
Signature · 7 lines
2.7.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/5 common: state: Make find_var public
Make find_var public to grant access to state variables.
Make also the MAC node public to receive the stored address.
--- common/state/state.h | 27 +-------------------------- include/state.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-)
common/state/state.h +1 -26
@@ -1,6 +1,7 @@#include <linux/types.h> #include <linux/list.h> #include <driver.h> +#include <state.h> struct state ;struct mtd_info_user ;
@@ -128,16 +129,6 @@ struct variable_type { struct device_node *); }; -/* instance of a single variable */ -struct state_variable { -struct state *state; -struct list_head list; -const char *name; -unsigned int start; -unsigned int size; -void *raw; -}; -/* * uint32 */
@@ -161,16 +152,6 @@ struct state_enum32 { };/* -* MAC address -*/ -struct state_mac { -struct state_variable var; -struct param_d *param; -uint8_t value[6 ]; -uint8_t value_default[6 ]; -}; - -/* * string */ struct state_string {
@@ -204,7 +185,6 @@ int state_backend_bucket_circular_create(struct device_d *dev, const char *path,int state_backend_bucket_cached_create (struct device_d *dev,struct state_backend_storage_bucket *raw,struct state_backend_storage_bucket **out); -struct state_variable *state_find_var (struct state *state,const char *name);struct digest *state_backend_format_raw_get_digest (struct state_backend_format *format);void state_backend_set_readonly (struct state *state);
@@ -229,11 +209,6 @@ static inline struct state_enum32 *to_state_enum32(struct state_variable *s) return container_of(s, struct state_enum32, var); } -static inline struct state_mac *to_state_mac (struct state_variable *s) -{ - return container_of(s, struct state_mac, var); -} -static inline struct state_string *to_state_string (struct state_variable *s) { return container_of(s, struct state_string, var);
include/state.h +26 -0
@@ -5,6 +5,30 @@struct state ; +/* instance of a single variable */ +struct state_variable { +struct state *state; +struct list_head list; +const char *name; +unsigned int start; +unsigned int size; +void *raw; +}; + +/* +* MAC address +*/ +struct state_mac { +struct state_variable var; +struct param_d *param; +uint8_t value[6 ]; +uint8_t value_default[6 ]; +}; +static inline struct state_mac *to_state_mac (struct state_variable *s) +{ + return container_of(s, struct state_mac, var); +} +int state_backend_dtb_file (struct state *state,const char *of_path,const char *path); int state_backend_raw_file(struct state *state, const char *of_path,
@@ -23,4 +47,6 @@ int state_load(struct state *state);int state_save (struct state *state);void state_info (void ); +struct state_variable *state_find_var (struct state *state,const char *name); +#endif /* __STATE_H */
Signature · 7 lines
2.7.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/5 ARM: dts: AM335x: Add state framework
In reply to Daniel SchultzThis patch adds the state framework with an EEPROM partition and two nodes for MAC addresses. It will be available for all phycore AM335x images with EEPROMs.
--- arch/arm/dts/am335x-phytec-phycore-som-emmc.dts | 1 + .../dts/am335x-phytec-phycore-som-nand-no-spi.dts | 1 + arch/arm/dts/am335x-phytec-phycore-som-nand.dts | 1 + arch/arm/dts/am335x-phytec-state.dtsi | 52 ++++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 arch/arm/dts/am335x-phytec-state.dtsi
arch/arm/dts/am335x-phytec-phycore-som-emmc.dts +1 -0
@@ -16,6 +16,7 @@ #include "am33xx.dtsi" #include "am335x-phytec-phycore-som.dtsi" +#include "am335x-phytec-state.dtsi" / { model = "Phytec phyCORE EMMC AM335x";
arch/arm/dts/am335x-phytec-phycore-som-nand-no-spi.dts +1 -0
@@ -9,6 +9,7 @@ #include "am33xx.dtsi" #include "am335x-phytec-phycore-som.dtsi" +#include "am335x-phytec-state.dtsi" / { model = "Phytec phyCORE AM335x";
arch/arm/dts/am335x-phytec-phycore-som-nand.dts +1 -0
@@ -9,6 +9,7 @@ #include "am33xx.dtsi" #include "am335x-phytec-phycore-som.dtsi" +#include "am335x-phytec-state.dtsi" / { model = "Phytec phyCORE AM335x";
arch/arm/dts/am335x-phytec-state.dtsi new file +52 -0
52 lines not on this page · raw message
Signature · 7 lines
2.7.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 4/5] common: state: Make find_var public
In reply to Daniel SchultzQuoted 112 lines · Daniel Schultz
Make
find_varpublic to grant access to state variables.Make also the MAC node public to receive the stored address.
Signed-off-by Daniel Schultz <[email protected]>--- common/state/state.h | 27 +-------------------------- include/state.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-)common/state/state.h +1
-26@@ -1,6 +1,7 @@#include <linux/types.h> #include <linux/list.h> #include <driver.h> +#include <state.h> struct state ;struct mtd_info_user ;@@ -128,16 +129,6 @@ struct variable_type { struct device_node *); }; -/* instance of a single variable */ -struct state_variable { -struct state *state; -struct list_head list; -const char *name; -unsigned int start; -unsigned int size; -void *raw; -}; -/* * uint32 */ @@ -161,16 +152,6 @@ struct state_enum32 { };/* -* MAC address -*/ -struct state_mac { -struct state_variable var; -struct param_d *param; -uint8_t value[6 ]; -uint8_t value_default[6 ]; -}; - -/* * string */ struct state_string {@@ -204,7 +185,6 @@ int state_backend_bucket_circular_create(struct device_d *dev, const char *path,int state_backend_bucket_cached_create (struct device_d *dev,struct state_backend_storage_bucket *raw,struct state_backend_storage_bucket **out); -struct state_variable *state_find_var (struct state *state,const char *name);struct digest *state_backend_format_raw_get_digest (struct state_backend_format *format);void state_backend_set_readonly (struct state *state);@@ -229,11 +209,6 @@ static inline struct state_enum32 *to_state_enum32(struct state_variable *s) return container_of(s, struct state_enum32, var); } -static inline struct state_mac *to_state_mac (struct state_variable *s) -{ - return container_of(s, struct state_mac, var); -} -static inline struct state_string *to_state_string (struct state_variable *s) { return container_of(s, struct state_string, var);include/state.h +24
-0@@ -5,6 +5,30 @@struct state ; +/* instance of a single variable */ +struct state_variable { +struct state *state; +struct list_head list; +const char *name; +unsigned int start; +unsigned int size; +void *raw; +}; + +/* +* MAC address +*/ +struct state_mac { +struct state_variable var; +struct param_d *param; +uint8_t value[6 ]; +uint8_t value_default[6 ]; +}; +static inline struct state_mac *to_state_mac (struct state_variable *s) +{ + return container_of(s, struct state_mac, var); +} +int state_backend_dtb_file (struct state *state,const char *of_path,const char *path); int state_backend_raw_file(struct state *state, const char *of_path,
include/state.h int state_load(struct state *state); · line 51
Quoted 5 lines
include/state.h +2
-0@@ -23,4 +47,6 @@ int state_load(struct state *state);int state_save (struct state *state);void state_info (void ); +struct state_variable *state_find_var (struct state *state,const char *name); +
I don't like exporting this state internal stuff very much. I rather suggest a
int state_read_mac(struct state *state, const char *name, u8 *buf);
to read the mac.
This function should also provide the type safety to check whether the state variable actually is of type MAC address. To make that possible we may have to store a pointer to the variable_type in struct state_variable.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox