ARM: rpi: parse useful data from vc fdt
Subsystems (4)
PATCH v3 1/1 ARM: rpi: parse useful data from vc fdt
Videocore first-stage loader on rpi passes us many useful information inside the vc fdt, including the real value of PM_RSTS register, not easily available by other means and which we can use to determine the reset cause.
Also make the relevant funtions just print error/warning and continue in case of some errors, since the fdt from vc is now optional for barebox's basic function.
--- arch/arm/boards/raspberry-pi/rpi-common.c | 167 ++++++++++++++++------ drivers/watchdog/bcm2835_wdt.c | 23 +-- include/soc/bcm283x/wdt.h | 40 ++++++ 3 files changed, 167 insertions(+), 63 deletions(-) create mode 100644 include/soc/bcm283x/wdt.h
arch/arm/boards/raspberry-pi/rpi-common.c +126 -41
@@ -23,13 +23,28 @@#include <linux/sizes.h> #include <globalvar.h> #include <asm/system_info.h> +#include <reset_source.h> #include <mach/core.h> #include <mach/mbox.h> #include <mach/platform.h> +#include <soc/bcm283x/wdt.h> +#include "lowlevel.h" +//https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#BOOT_ORDER +static const char *const boot_mode_names[] = { + [0x0 ] ="unknown" , + [0x1 ] ="sd" , + [0x2 ] ="net" , + [0x3 ] ="rpiboot" , + [0x4 ] ="usbmsd" , + [0x5 ] ="usbc" , + [0x6 ] ="nvme" , + [0x7 ] ="http" , +}; +struct rpi_priv ;struct rpi_machine_data {int (*init)(struct rpi_priv *priv);
@@ -186,54 +201,117 @@ static int rpi_env_init(void)return 0 ; } -/* Extract /chosen/bootargs from the VideoCore FDT into vc.bootargs -* global variable. */ -static int rpi_vc_fdt_bootargs (void *fdt) +/* Extract useful information from the VideoCore FDT we got. +* Some parameters are defined here: +* https://www.raspberrypi.com/documentation/computers/configuration.html#part4 +*/ +static void rpi_vc_fdt_parse (void *fdt) { -int ret =0 ; -struct device_node *root =NULL , *node; -const char *cmdline; +int ret, len; +struct device_node *root, *chosen, *bootloader; +enum reset_src_type rst_src =RESET_UKWN ; +const char *str; +char *dynstr; +u32 num, *pnum; root =of_unflatten_dtb (fdt,INT_MAX ); -if (IS_ERR (root)) { - ret =PTR_ERR (root); - root =NULL ; - goto out; +if (IS_ERR (root)) +return ; + + str =of_get_property (root,"serial-number" , &len); +if (!str) { +pr_warn ("no 'serial-number' property found in vc fdt\n" ); + }else { + dynstr =xstrndup (str, len); +barebox_set_serial_number (dynstr); +free (dynstr); } - node =of_find_node_by_path_from (root,"/chosen" ); -if (!node) { -pr_err ("no /chosen node\n" ); - ret = -ENOENT ; - goto out; + str =of_get_property (root,"model" , &len); +if (!str) { +pr_warn ("no 'model' property found in vc fdt\n" ); + }else { + dynstr =xstrndup (str, len); +barebox_set_model (dynstr); +free (dynstr); } - cmdline =of_get_property (node,"bootargs" ,NULL ); -if (!cmdline) { -pr_err ("no bootargs property in the /chosen node\n" ); - ret = -ENOENT ; + chosen =of_find_node_by_path_from (root,"/chosen" ); +if (!chosen) { +pr_err ("no '/chosen' node found in vc fdt\n" ); goto out; } -globalvar_add_simple ("vc.bootargs" , cmdline); + bootloader =of_find_node_by_name (chosen,"bootloader" ); + + str =of_get_property (chosen,"bootargs" , &len); +if (!str) +pr_warn ("no 'bootargs' property in the /chosen node\n" ); +else +globalvar_add_simple ("vc.bootargs" ,xstrndup (str, len)); + + str =of_get_property (chosen,"overlay_prefix" , &len); +if (!str) +pr_warn ("no 'overlay_prefix' property in the /chosen node\n" ); +else +globalvar_add_simple ("vc.overlay_prefix" ,xstrndup (str, len)); + + str =of_get_property (chosen,"os_prefix" , &len); +if (!str) +pr_warn ("no 'os_prefix' property in the /chosen node\n" ); +else +globalvar_add_simple ("vc.os_prefix" ,xstrndup (str, len)); + + ret =of_property_read_u32 (chosen,"boot-mode" , &num); +if (ret && bootloader) + ret =of_property_read_u32 (bootloader,"boot-mode" , &num); +if (ret) { +pr_warn ("'boot-mode' property not found\n" ); + }else { + pnum =xmalloc (sizeof (u32)); + *pnum = num; +globalvar_add_simple_enum ("vc.boot_mode" , pnum, + boot_mode_names, +ARRAY_SIZE (boot_mode_names)); + } -switch (cpu_architecture ()) { -case CPU_ARCH_ARMv6: -globalvar_add_simple ("vc.kernel" ,"kernel.img" ); -break ; -case CPU_ARCH_ARMv7: -globalvar_add_simple ("vc.kernel" ,"kernel7.img" ); -break ; -case CPU_ARCH_ARMv8: -globalvar_add_simple ("vc.kernel" ,"kernel8.img" ); -break ; + ret =of_property_read_u32 (chosen,"partition" , &num); +if (ret && bootloader) + ret =of_property_read_u32 (bootloader,"partition" , &num); +if (ret) { +pr_warn ("'partition' property not found\n" ); + }else { + pnum =xmalloc (sizeof (u32)); + *pnum = num; +globalvar_add_simple_int ("vc.boot_partition" , pnum,"%u" ); } +if (IS_ENABLED (CONFIG_RESET_SOURCE )) { + ret =of_property_read_u32 (chosen,"pm_rsts" , &num); +if (ret && bootloader) + ret =of_property_read_u32 (bootloader,"rsts" , &num); + +if (ret) { +pr_warn ("'pm_rsts'/'rsts' property not found\n" ); + }else { +/* +* https://github.com/raspberrypi/linux/issues/932#issuecomment-93989581 +*/ +if (num &PM_RSTS_HADPOR_SET ) + rst_src =RESET_POR ; +else if (num &PM_RSTS_HADDR_SET ) + rst_src =RESET_JTAG ; +else if (num &PM_RSTS_HADWR_SET ) + rst_src =RESET_WDG ; +else if (num &PM_RSTS_HADSR_SET ) + rst_src =RESET_RST ; +reset_source_set (rst_src); + } + } out:if (root)of_delete_node (root); - -return ret; +return ; }static void rpi_vc_fdt (void )
@@ -241,7 +319,6 @@ static void rpi_vc_fdt(void)void *saved_vc_fdt;struct fdt_header *oftree;unsigned long magic, size; -int ret;/* VideoCore FDT was copied in PBL just above Barebox memory */ saved_vc_fdt = (void *)(arm_mem_endmem_get ());
@@ -260,16 +337,23 @@ static void rpi_vc_fdt(void)return ; size =be32_to_cpu (oftree->totalsize); -if (write_file ("/vc.dtb" , saved_vc_fdt, size)) { +if (write_file ("/vc.dtb" , saved_vc_fdt, size))pr_err ("failed to save videocore fdt to a file\n" ); -return ; - } - ret =rpi_vc_fdt_bootargs (saved_vc_fdt); -if (ret) { -pr_err ("failed to extract bootargs from videocore fdt: %d\n" , - ret); -return ; +rpi_vc_fdt_parse (saved_vc_fdt); +} + +static void rpi_set_kernel_name (void ) { +switch (cpu_architecture ()) { +case CPU_ARCH_ARMv6: +globalvar_add_simple ("vc.kernel" ,"kernel.img" ); +break ; +case CPU_ARCH_ARMv7: +globalvar_add_simple ("vc.kernel" ,"kernel7.img" ); +break ; +case CPU_ARCH_ARMv8: +globalvar_add_simple ("vc.kernel" ,"kernel8.img" ); +break ; } }
@@ -348,6 +432,7 @@ static int rpi_devices_probe(struct device_d *dev)armlinux_set_architecture (MACH_TYPE_BCM2708 );rpi_env_init ();rpi_vc_fdt (); +rpi_set_kernel_name ();if (dcfg && dcfg->init) dcfg->init (priv);
drivers/watchdog/bcm2835_wdt.c +1 -22
@@ -10,28 +10,7 @@#include <restart.h> #include <watchdog.h> -#define PM_RSTC 0x1c -#define PM_RSTS 0x20 -#define PM_WDOG 0x24 - -#define PM_WDOG_RESET 0000000000 -#define PM_PASSWORD 0x5a000000 -#define PM_WDOG_TIME_SET 0x000fffff -#define PM_RSTC_WRCFG_CLR 0xffffffcf -#define PM_RSTC_WRCFG_SET 0x00000030 -#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 -#define PM_RSTC_RESET 0x00000102 - -#define PM_RSTS_HADPOR_SET 0x00001000 -#define PM_RSTS_HADSRH_SET 0x00000400 -#define PM_RSTS_HADSRF_SET 0x00000200 -#define PM_RSTS_HADSRQ_SET 0x00000100 -#define PM_RSTS_HADWRH_SET 0x00000040 -#define PM_RSTS_HADWRF_SET 0x00000020 -#define PM_RSTS_HADWRQ_SET 0x00000010 -#define PM_RSTS_HADDRH_SET 0x00000004 -#define PM_RSTS_HADDRF_SET 0x00000002 -#define PM_RSTS_HADDRQ_SET 0x00000001 +#include <soc/bcm283x/wdt.h> #define SECS_TO_WDOG_TICKS (x) ((x) << 16)
include/soc/bcm283x/wdt.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2017 Pengutronix, Lucas Stach <[email protected]> +* +* Based on code from Carlo Caione <[email protected]> +*/ + +#ifndef __BCM2835_WDT_H +#define __BCM2835_WDT_H + +#define PM_RSTC 0x1c +#define PM_RSTS 0x20 +#define PM_WDOG 0x24 + +#define PM_WDOG_RESET 0000000000 +#define PM_PASSWORD 0x5a000000 +#define PM_WDOG_TIME_SET 0x000fffff +#define PM_RSTC_WRCFG_CLR 0xffffffcf +#define PM_RSTC_WRCFG_SET 0x00000030 +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 +#define PM_RSTC_RESET 0x00000102 + +#define PM_RSTS_HADPOR_SET 0x00001000 +#define PM_RSTS_HADSRH_SET 0x00000400 +#define PM_RSTS_HADSRF_SET 0x00000200 +#define PM_RSTS_HADSRQ_SET 0x00000100 +#define PM_RSTS_HADWRH_SET 0x00000040 +#define PM_RSTS_HADWRF_SET 0x00000020 +#define PM_RSTS_HADWRQ_SET 0x00000010 +#define PM_RSTS_HADDRH_SET 0x00000004 +#define PM_RSTS_HADDRF_SET 0x00000002 +#define PM_RSTS_HADDRQ_SET 0x00000001 + +#define PM_RSTS_HADDR_SET \ + (PM_RSTS_HADDRQ_SET | PM_RSTS_HADDRF_SET | PM_RSTS_HADDRH_SET) +#define PM_RSTS_HADWR_SET \ + (PM_RSTS_HADWRQ_SET | PM_RSTS_HADWRF_SET | PM_RSTS_HADWRH_SET) +#define PM_RSTS_HADSR_SET \ + (PM_RSTS_HADSRQ_SET | PM_RSTS_HADSRF_SET | PM_RSTS_HADSRH_SET) + +#endif
Signature · 1 line
2.17.1
Hello Daniel,
Quoted 78 lines · Daniel Brát
Videocore first-stage loader on rpi passes us many useful information inside the vc fdt, including the real value of
PM_RSTSregister, not easily available by other means and which we can use to determine the reset cause.
Also make the relevant funtions just print error/warning and continue in case of some errors, since the fdt from vc is now optional for barebox's basic function.Signed-off-by Daniel Brát <[email protected]>--- arch/arm/boards/raspberry-pi/rpi-common.c | 167 ++++++++++++++++------ drivers/watchdog/bcm2835_wdt.c | 23 +-- include/soc/bcm283x/wdt.h | 40 ++++++ 3 files changed, 167 insertions(+), 63 deletions(-) create mode 100644 include/soc/bcm283x/wdt.harch/arm/boards/raspberry-pi/rpi-common.c +27
-10@@ -23,13 +23,28 @@#include <linux/sizes.h> #include <globalvar.h> #include <asm/system_info.h> +#include <reset_source.h> #include <mach/core.h> #include <mach/mbox.h> #include <mach/platform.h> +#include <soc/bcm283x/wdt.h> +#include "lowlevel.h" +//https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#BOOT_ORDER +static const char *const boot_mode_names[] = { + [0x0 ] ="unknown" , + [0x1 ] ="sd" , + [0x2 ] ="net" , + [0x3 ] ="rpiboot" , + [0x4 ] ="usbmsd" , + [0x5 ] ="usbc" , + [0x6 ] ="nvme" , + [0x7 ] ="http" , +}; +struct rpi_priv ;struct rpi_machine_data {int (*init)(struct rpi_priv *priv);@@ -186,54 +201,117 @@ static int rpi_env_init(void)return 0 ; } -/* Extract /chosen/bootargs from the VideoCore FDT into vc.bootargs -* global variable. */ -static int rpi_vc_fdt_bootargs (void *fdt) +/* Extract useful information from the VideoCore FDT we got. +* Some parameters are defined here: +* https://www.raspberrypi.com/documentation/computers/configuration.html#part4 +*/ +static void rpi_vc_fdt_parse (void *fdt) { -int ret =0 ; -struct device_node *root =NULL , *node; -const char *cmdline; +int ret, len; +struct device_node *root, *chosen, *bootloader; +enum reset_src_type rst_src =RESET_UKWN ; +const char *str; +char *dynstr; +u32 num, *pnum; root =of_unflatten_dtb (fdt,INT_MAX ); -if (IS_ERR (root)) { - ret =PTR_ERR (root); - root =NULL ; - goto out; +if (IS_ERR (root))
arch/arm/boards/raspberry-pi/rpi-common.c static int rpi_env_init(void) · line 228
Quoted 10 lines
arch/arm/boards/raspberry-pi/rpi-common.c +9
-0+return ; + + str =of_get_property (root,"serial-number" , &len); +if (!str) { +pr_warn ("no 'serial-number' property found in vc fdt\n" ); + }else { + dynstr =xstrndup (str, len); +barebox_set_serial_number (dynstr); +free (dynstr); }
How about:
static const char *of_read_vc_string(struct device_node *root,
const char *propname)
{
const char *str;
char *dynstr;
int len;
str = of_get_property(root, propname, &len);
if (!str) {
pr_warn("no '%s' property found in vc fdt\n", propname);
return NULL;
};
return xstrndup(str, len);
}and then use it throughout?
This should make the code much better readable IMO.
Quoted 23 lines
arch/arm/boards/raspberry-pi/rpi-common.c +10
-9- node =of_find_node_by_path_from (root,"/chosen" ); -if (!node) { -pr_err ("no /chosen node\n" ); - ret = -ENOENT ; - goto out; + str =of_get_property (root,"model" , &len); +if (!str) { +pr_warn ("no 'model' property found in vc fdt\n" ); + }else { + dynstr =xstrndup (str, len); +barebox_set_model (dynstr); +free (dynstr); } - cmdline =of_get_property (node,"bootargs" ,NULL ); -if (!cmdline) { -pr_err ("no bootargs property in the /chosen node\n" ); - ret = -ENOENT ; + chosen =of_find_node_by_path_from (root,"/chosen" ); +if (!chosen) { +pr_err ("no '/chosen' node found in vc fdt\n" ); goto out;
arch/arm/boards/raspberry-pi/rpi-common.c static int rpi_env_init(void) · line 251
Quoted 10 lines
arch/arm/boards/raspberry-pi/rpi-common.c +7
-1} -globalvar_add_simple ("vc.bootargs" , cmdline); + bootloader =of_find_node_by_name (chosen,"bootloader" ); + + str =of_get_property (chosen,"bootargs" , &len); +if (!str) +pr_warn ("no 'bootargs' property in the /chosen node\n" ); +else +globalvar_add_simple ("vc.bootargs" ,xstrndup (str, len));
second argument is xstrdup'd, so this leaks.
Quoted 8 lines
arch/arm/boards/raspberry-pi/rpi-common.c +8
-0+ + str =of_get_property (chosen,"overlay_prefix" , &len); +if (!str) +pr_warn ("no 'overlay_prefix' property in the /chosen node\n" ); +else +globalvar_add_simple ("vc.overlay_prefix" ,xstrndup (str, len)); + + str =of_get_property (chosen,"os_prefix" , &len);
arch/arm/boards/raspberry-pi/rpi-common.c static int rpi_env_init(void) · line 269
Quoted 10 lines
arch/arm/boards/raspberry-pi/rpi-common.c +10
-0+if (!str) +pr_warn ("no 'os_prefix' property in the /chosen node\n" ); +else +globalvar_add_simple ("vc.os_prefix" ,xstrndup (str, len)); + + ret =of_property_read_u32 (chosen,"boot-mode" , &num); +if (ret && bootloader) + ret =of_property_read_u32 (bootloader,"boot-mode" , &num); +if (ret) { +pr_warn ("'boot-mode' property not found\n" );
Nitpick: Did they always populate this property? I would skip this warning here, so it doesn't spam old firmware + new barebox.
arch/arm/boards/raspberry-pi/rpi-common.c static int rpi_env_init(void) · line 270
Quoted 2 lines
arch/arm/boards/raspberry-pi/rpi-common.c +2
-0+ }else { + pnum =xmalloc (sizeof (u32));
Just make it a static variable?
Quoted 186 lines
arch/arm/boards/raspberry-pi/rpi-common.c +53
-21+ *pnum = num; +globalvar_add_simple_enum ("vc.boot_mode" , pnum, + boot_mode_names, +ARRAY_SIZE (boot_mode_names)); + } -switch (cpu_architecture ()) { -case CPU_ARCH_ARMv6: -globalvar_add_simple ("vc.kernel" ,"kernel.img" ); -break ; -case CPU_ARCH_ARMv7: -globalvar_add_simple ("vc.kernel" ,"kernel7.img" ); -break ; -case CPU_ARCH_ARMv8: -globalvar_add_simple ("vc.kernel" ,"kernel8.img" ); -break ; + ret =of_property_read_u32 (chosen,"partition" , &num); +if (ret && bootloader) + ret =of_property_read_u32 (bootloader,"partition" , &num); +if (ret) { +pr_warn ("'partition' property not found\n" ); + }else { + pnum =xmalloc (sizeof (u32)); + *pnum = num; +globalvar_add_simple_int ("vc.boot_partition" , pnum,"%u" ); } +if (IS_ENABLED (CONFIG_RESET_SOURCE )) { + ret =of_property_read_u32 (chosen,"pm_rsts" , &num); +if (ret && bootloader) + ret =of_property_read_u32 (bootloader,"rsts" , &num); + +if (ret) { +pr_warn ("'pm_rsts'/'rsts' property not found\n" ); + }else { +/* +* https://github.com/raspberrypi/linux/issues/932#issuecomment-93989581 +*/ +if (num &PM_RSTS_HADPOR_SET ) + rst_src =RESET_POR ; +else if (num &PM_RSTS_HADDR_SET ) + rst_src =RESET_JTAG ; +else if (num &PM_RSTS_HADWR_SET ) + rst_src =RESET_WDG ; +else if (num &PM_RSTS_HADSR_SET ) + rst_src =RESET_RST ; +reset_source_set (rst_src); + } + } out:if (root)of_delete_node (root); - -return ret; +return ; }static void rpi_vc_fdt (void )@@ -241,7 +319,6 @@ static void rpi_vc_fdt(void)void *saved_vc_fdt;struct fdt_header *oftree;unsigned long magic, size; -int ret;/* VideoCore FDT was copied in PBL just above Barebox memory */ saved_vc_fdt = (void *)(arm_mem_endmem_get ());@@ -260,16 +337,23 @@ static void rpi_vc_fdt(void)return ; size =be32_to_cpu (oftree->totalsize); -if (write_file ("/vc.dtb" , saved_vc_fdt, size)) { +if (write_file ("/vc.dtb" , saved_vc_fdt, size))pr_err ("failed to save videocore fdt to a file\n" ); -return ; - } - ret =rpi_vc_fdt_bootargs (saved_vc_fdt); -if (ret) { -pr_err ("failed to extract bootargs from videocore fdt: %d\n" , - ret); -return ; +rpi_vc_fdt_parse (saved_vc_fdt); +} + +static void rpi_set_kernel_name (void ) { +switch (cpu_architecture ()) { +case CPU_ARCH_ARMv6: +globalvar_add_simple ("vc.kernel" ,"kernel.img" ); +break ; +case CPU_ARCH_ARMv7: +globalvar_add_simple ("vc.kernel" ,"kernel7.img" ); +break ; +case CPU_ARCH_ARMv8: +globalvar_add_simple ("vc.kernel" ,"kernel8.img" ); +break ; } }@@ -348,6 +432,7 @@ static int rpi_devices_probe(struct device_d *dev)armlinux_set_architecture (MACH_TYPE_BCM2708 );rpi_env_init ();rpi_vc_fdt (); +rpi_set_kernel_name ();if (dcfg && dcfg->init) dcfg->init (priv);drivers/watchdog/bcm2835_wdt.c +1
-22@@ -10,28 +10,7 @@#include <restart.h> #include <watchdog.h> -#define PM_RSTC 0x1c -#define PM_RSTS 0x20 -#define PM_WDOG 0x24 - -#define PM_WDOG_RESET 0000000000 -#define PM_PASSWORD 0x5a000000 -#define PM_WDOG_TIME_SET 0x000fffff -#define PM_RSTC_WRCFG_CLR 0xffffffcf -#define PM_RSTC_WRCFG_SET 0x00000030 -#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 -#define PM_RSTC_RESET 0x00000102 - -#define PM_RSTS_HADPOR_SET 0x00001000 -#define PM_RSTS_HADSRH_SET 0x00000400 -#define PM_RSTS_HADSRF_SET 0x00000200 -#define PM_RSTS_HADSRQ_SET 0x00000100 -#define PM_RSTS_HADWRH_SET 0x00000040 -#define PM_RSTS_HADWRF_SET 0x00000020 -#define PM_RSTS_HADWRQ_SET 0x00000010 -#define PM_RSTS_HADDRH_SET 0x00000004 -#define PM_RSTS_HADDRF_SET 0x00000002 -#define PM_RSTS_HADDRQ_SET 0x00000001 +#include <soc/bcm283x/wdt.h> #define SECS_TO_WDOG_TICKS (x) ((x) << 16)include/soc/bcm283x/wdt.h new file +40
-0@@ -0,0 +1,40 @@ +/* +* Copyright (C) 2017 Pengutronix, Lucas Stach <[email protected]> +* +* Based on code from Carlo Caione <[email protected]> +*/ + +#ifndef __BCM2835_WDT_H +#define __BCM2835_WDT_H + +#define PM_RSTC 0x1c +#define PM_RSTS 0x20 +#define PM_WDOG 0x24 + +#define PM_WDOG_RESET 0000000000 +#define PM_PASSWORD 0x5a000000 +#define PM_WDOG_TIME_SET 0x000fffff +#define PM_RSTC_WRCFG_CLR 0xffffffcf +#define PM_RSTC_WRCFG_SET 0x00000030 +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 +#define PM_RSTC_RESET 0x00000102 + +#define PM_RSTS_HADPOR_SET 0x00001000 +#define PM_RSTS_HADSRH_SET 0x00000400 +#define PM_RSTS_HADSRF_SET 0x00000200 +#define PM_RSTS_HADSRQ_SET 0x00000100 +#define PM_RSTS_HADWRH_SET 0x00000040 +#define PM_RSTS_HADWRF_SET 0x00000020 +#define PM_RSTS_HADWRQ_SET 0x00000010 +#define PM_RSTS_HADDRH_SET 0x00000004 +#define PM_RSTS_HADDRF_SET 0x00000002 +#define PM_RSTS_HADDRQ_SET 0x00000001 + +#define PM_RSTS_HADDR_SET \ + (PM_RSTS_HADDRQ_SET | PM_RSTS_HADDRF_SET | PM_RSTS_HADDRH_SET) +#define PM_RSTS_HADWR_SET \ + (PM_RSTS_HADWRQ_SET | PM_RSTS_HADWRF_SET | PM_RSTS_HADWRH_SET) +#define PM_RSTS_HADSR_SET \ + (PM_RSTS_HADSRQ_SET | PM_RSTS_HADSRF_SET | PM_RSTS_HADSRH_SET) + +#endif
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Hi,
Quoted 3 lines · Ahmad Fatoum
arch/arm/boards/raspberry-pi/rpi-common.c static int rpi_env_init(void) · line 286
Quoted 3 lines
arch/arm/boards/raspberry-pi/rpi-common.c +3
-0+ pnum =xmalloc (sizeof (u32)); + *pnum = num; +globalvar_add_simple_int ("vc.boot_partition" , pnum,"%u" );
You could use setenv() with a format string instead, see Sascha's change to the mailing list, this would simplify this chunk here.
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 9 lines · Ahmad Fatoum
Hi,
Quoted 3 lines · Ahmad Fatoum
arch/arm/boards/raspberry-pi/rpi-common.c static int rpi_env_init(void) · line 286
Quoted 3 lines
arch/arm/boards/raspberry-pi/rpi-common.c +3
-0+ pnum =xmalloc (sizeof (u32)); + *pnum = num; +globalvar_add_simple_int ("vc.boot_partition" , pnum,"%u" );You could use
setenv()with a format string instead, see Sascha's change to the mailing list, this would simplify this chunk here.
You can't create a globalvar with setenv().
Anyway, when I see this hunk I want to suggest to just use a global static variable instead of allocating memory dynamically for it.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |