board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check
Subsystems (3)
PATCH 1/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check
Use IS_ENABLED to prevent ifdef in board_key_check
---
board/st/stm32mp1/stm32mp1.c | 52 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-)
board/st/stm32mp1/stm32mp1.c +26 -26
@@ -135,51 +135,51 @@ int checkboard(void)static void board_key_check (void ) { -#if defined(CONFIG_FASTBOOT ) || defined(CONFIG_CMD_STM32PROG )ofnode node;struct gpio_desc gpio;enum forced_boot_mode boot_mode =BOOT_NORMAL ; +if (!IS_ENABLED (CONFIG_FASTBOOT ) && !IS_ENABLED (CONFIG_CMD_STM32PROG )) +return ; + node =ofnode_path ("/config" );if (!ofnode_valid (node)) {debug ("%s: no /config node?\n" , __func__);return ; } -#ifdef CONFIG_FASTBOOT -if (gpio_request_by_name_nodev (node,"st,fastboot-gpios" ,0 , - &gpio,GPIOD_IS_IN )) { -debug ("%s: could not find a /config/st,fastboot-gpios\n" , - __func__); - }else { -if (dm_gpio_get_value (&gpio)) { -puts ("Fastboot key pressed, " ); - boot_mode =BOOT_FASTBOOT ; - } +if (IS_ENABLED (CONFIG_FASTBOOT )) { +if (gpio_request_by_name_nodev (node,"st,fastboot-gpios" ,0 , + &gpio,GPIOD_IS_IN )) { +debug ("%s: could not find a /config/st,fastboot-gpios\n" , + __func__); + }else { +if (dm_gpio_get_value (&gpio)) { +puts ("Fastboot key pressed, " ); + boot_mode =BOOT_FASTBOOT ; + } -dm_gpio_free (NULL , &gpio); +dm_gpio_free (NULL , &gpio); + } } -#endif -#ifdef CONFIG_CMD_STM32PROG -if (gpio_request_by_name_nodev (node,"st,stm32prog-gpios" ,0 , - &gpio,GPIOD_IS_IN )) { -debug ("%s: could not find a /config/st,stm32prog-gpios\n" , - __func__); - }else { -if (dm_gpio_get_value (&gpio)) { -puts ("STM32Programmer key pressed, " ); - boot_mode =BOOT_STM32PROG ; +if (IS_ENABLED (CONFIG_CMD_STM32PROG )) { +if (gpio_request_by_name_nodev (node,"st,stm32prog-gpios" ,0 , + &gpio,GPIOD_IS_IN )) { +debug ("%s: could not find a /config/st,stm32prog-gpios\n" , + __func__); + }else { +if (dm_gpio_get_value (&gpio)) { +puts ("STM32Programmer key pressed, " ); + boot_mode =BOOT_STM32PROG ; + } +dm_gpio_free (NULL , &gpio); } -dm_gpio_free (NULL , &gpio); } -#endif -if (boot_mode !=BOOT_NORMAL ) {puts ("entering download mode...\n" );clrsetbits_le32 (TAMP_BOOT_CONTEXT ,TAMP_BOOT_FORCED_MASK , boot_mode); } -#endif }#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG )
Signature · 1 line
2.17.1
PATCH 2/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
Use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected and in g_dnl_bind_fixup
---
board/st/stm32mp1/stm32mp1.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
board/st/stm32mp1/stm32mp1.c +9 -6
@@ -182,13 +182,14 @@ static void board_key_check(void) } } -#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG ) -#include <usb/dwc2_udc.h> int g_dnl_board_usb_cable_connected (void ) {struct udevice *dwc2_udc_otg;int ret; +if (!IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG )) +return -ENODEV ; +/* if typec stusb160x is present, means DK1 or DK2 board */ ret =stusb160x_cable_connected ();if (ret >=0 )
@@ -203,14 +204,17 @@ int g_dnl_board_usb_cable_connected(void)return dwc2_udc_B_session_valid (dwc2_udc_otg); } +#ifdef CONFIG_USB_GADGET_DOWNLOAD #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11#define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afbint g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) { -if (!strcmp (name,"usb_dnl_dfu" )) +if (IS_ENABLED (CONFIG_DFU_OVER_USB ) && + !strcmp (name,"usb_dnl_dfu" ))put_unaligned (STM32MP1_G_DNL_DFU_PRODUCT_NUM , &dev->idProduct); -else if (!strcmp (name,"usb_dnl_fastboot" )) +else if (IS_ENABLED (CONFIG_FASTBOOT ) && + !strcmp (name,"usb_dnl_fastboot" ))put_unaligned (STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM , &dev->idProduct);else
@@ -218,8 +222,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) return 0; } - -#endif /* CONFIG_USB_GADGET */ +#endif /* CONFIG_USB_GADGET_DOWNLOAD */ static int get_led (struct udevice **dev,char *led_string) {
Signature · 1 line
2.17.1
PATCH 2/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
Hi Patrick
Quoted 51 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef ing_dnl_board_usb_cable_connectedand ing_dnl_bind_fixupSigned-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)board/st/stm32mp1/stm32mp1.c +8
-4@@ -182,13 +182,14 @@ static void board_key_check(void) } } -#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG ) -#include <usb/dwc2_udc.h> int g_dnl_board_usb_cable_connected (void ) {struct udevice *dwc2_udc_otg;int ret; +if (!IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG )) +return -ENODEV ; +/* if typec stusb160x is present, means DK1 or DK2 board */ ret =stusb160x_cable_connected ();if (ret >=0 )@@ -203,14 +204,17 @@ int g_dnl_board_usb_cable_connected(void)return dwc2_udc_B_session_valid (dwc2_udc_otg); } +#ifdef CONFIG_USB_GADGET_DOWNLOAD #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11#define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afbint g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) { -if (!strcmp (name,"usb_dnl_dfu" )) +if (IS_ENABLED (CONFIG_DFU_OVER_USB ) && + !strcmp (name,"usb_dnl_dfu" ))put_unaligned (STM32MP1_G_DNL_DFU_PRODUCT_NUM , &dev->idProduct); -else if (!strcmp (name,"usb_dnl_fastboot" )) +else if (IS_ENABLED (CONFIG_FASTBOOT ) && + !strcmp (name,"usb_dnl_fastboot" ))put_unaligned (STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM , &dev->idProduct);else
board/st/stm32mp1/stm32mp1.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 228
Quoted 9 lines
board/st/stm32mp1/stm32mp1.c +1
-2@@ -218,8 +222,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) return 0; } - -#endif /* CONFIG_USB_GADGET */ +#endif /* CONFIG_USB_GADGET_DOWNLOAD */ static int get_led (struct udevice **dev,char *led_string) {
Thanks
Patrice
PATCH 2/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
Quoted 11 lines · Patrice CHOTARD
Hi Patrick
Quoted 8 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef ing_dnl_board_usb_cable_connectedand ing_dnl_bind_fixupSigned-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 61 lines
Quoted 43 lines
board/st/stm32mp1/stm32mp1.c +8
-4@@ -182,13 +182,14 @@ static void board_key_check(void) } } -#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG ) -#include <usb/dwc2_udc.h> int g_dnl_board_usb_cable_connected (void ) {struct udevice *dwc2_udc_otg;int ret; +if (!IS_ENABLED (CONFIG_USB_GADGET_DWC2_OTG )) +return -ENODEV ; +/* if typec stusb160x is present, means DK1 or DK2 board */ ret =stusb160x_cable_connected ();if (ret >=0 )@@ -203,14 +204,17 @@ int g_dnl_board_usb_cable_connected(void)return dwc2_udc_B_session_valid (dwc2_udc_otg); } +#ifdef CONFIG_USB_GADGET_DOWNLOAD #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11#define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afbint g_dnl_bind_fixup (struct usb_device_descriptor *dev,const char *name) { -if (!strcmp (name,"usb_dnl_dfu" )) +if (IS_ENABLED (CONFIG_DFU_OVER_USB ) && + !strcmp (name,"usb_dnl_dfu" ))put_unaligned (STM32MP1_G_DNL_DFU_PRODUCT_NUM , &dev->idProduct); -else if (!strcmp (name,"usb_dnl_fastboot" )) +else if (IS_ENABLED (CONFIG_FASTBOOT ) && + !strcmp (name,"usb_dnl_fastboot" ))put_unaligned (STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM , &dev->idProduct);else board/st/stm32mp1/stm32mp1.c int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) · line 228
Quoted 9 lines
board/st/stm32mp1/stm32mp1.c +1
-2@@ -218,8 +222,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) return 0; } - -#endif /* CONFIG_USB_GADGET */ +#endif /* CONFIG_USB_GADGET_DOWNLOAD */ static int get_led (struct udevice **dev,char *led_string) {Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 3/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in board_check_usb_power.
---
board/st/stm32mp1/stm32mp1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
board/st/stm32mp1/stm32mp1.c +4 -4
@@ -288,7 +288,6 @@ static void __maybe_unused led_error_blink(u32 nb_blink)hang (); } -#ifdef CONFIG_ADC static int board_check_usb_power (void ) {struct ofnode_phandle_args adc_args;
@@ -300,6 +299,10 @@ static int board_check_usb_power(void)int ret, uV, adc_count;u32 nb_blink;u8 i; + +if (!IS_ENABLED (CONFIG_ADC )) +return -ENODEV ; + node =ofnode_path ("/config" );if (!ofnode_valid (node)) {debug ("%s: no /config node?\n" , __func__);
@@ -422,7 +425,6 @@ static int board_check_usb_power(void)return 0 ; } -#endif /* CONFIG_ADC */ static void sysconf_init (void ) {
@@ -699,10 +701,8 @@ int board_late_init(void) }#endif -#ifdef CONFIG_ADC /* for DK1/DK2 boards */ board_check_usb_power (); -#endif /* CONFIG_ADC */ return 0 ; }
Signature · 1 line
2.17.1
PATCH 3/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
Hi Patrick
Quoted 40 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inboard_check_usb_power.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)board/st/stm32mp1/stm32mp1.c +4
-2@@ -288,7 +288,6 @@ static void __maybe_unused led_error_blink(u32 nb_blink)hang (); } -#ifdef CONFIG_ADC static int board_check_usb_power (void ) {struct ofnode_phandle_args adc_args;@@ -300,6 +299,10 @@ static int board_check_usb_power(void)int ret, uV, adc_count;u32 nb_blink;u8 i; + +if (!IS_ENABLED (CONFIG_ADC )) +return -ENODEV ; + node =ofnode_path ("/config" );if (!ofnode_valid (node)) {debug ("%s: no /config node?\n" , __func__);@@ -422,7 +425,6 @@ static int board_check_usb_power(void)return 0 ; } -#endif /* CONFIG_ADC */ static void sysconf_init (void ) {
board/st/stm32mp1/stm32mp1.c int board_late_init(void) · line 708
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-2@@ -699,10 +701,8 @@ int board_late_init(void) }#endif -#ifdef CONFIG_ADC /* for DK1/DK2 boards */ board_check_usb_power (); -#endif /* CONFIG_ADC */ return 0 ; }
Thanks
Patrice
PATCH 3/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
In reply to Patrick DelaunayHi Patrick
Quoted 40 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inboard_check_usb_power.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)board/st/stm32mp1/stm32mp1.c +4
-2@@ -288,7 +288,6 @@ static void __maybe_unused led_error_blink(u32 nb_blink)hang (); } -#ifdef CONFIG_ADC static int board_check_usb_power (void ) {struct ofnode_phandle_args adc_args;@@ -300,6 +299,10 @@ static int board_check_usb_power(void)int ret, uV, adc_count;u32 nb_blink;u8 i; + +if (!IS_ENABLED (CONFIG_ADC )) +return -ENODEV ; + node =ofnode_path ("/config" );if (!ofnode_valid (node)) {debug ("%s: no /config node?\n" , __func__);@@ -422,7 +425,6 @@ static int board_check_usb_power(void)return 0 ; } -#endif /* CONFIG_ADC */ static void sysconf_init (void ) {
board/st/stm32mp1/stm32mp1.c int board_late_init(void) · line 708
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-2@@ -699,10 +701,8 @@ int board_late_init(void) }#endif -#ifdef CONFIG_ADC /* for DK1/DK2 boards */ board_check_usb_power (); -#endif /* CONFIG_ADC */ return 0 ; }
Thanks
Patrice
PATCH 3/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inboard_check_usb_power.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 52 lines
Quoted 33 lines
board/st/stm32mp1/stm32mp1.c +4
-2@@ -288,7 +288,6 @@ static void __maybe_unused led_error_blink(u32 nb_blink)hang (); } -#ifdef CONFIG_ADC static int board_check_usb_power (void ) {struct ofnode_phandle_args adc_args;@@ -300,6 +299,10 @@ static int board_check_usb_power(void)int ret, uV, adc_count;u32 nb_blink;u8 i; + +if (!IS_ENABLED (CONFIG_ADC )) +return -ENODEV ; + node =ofnode_path ("/config" );if (!ofnode_valid (node)) {debug ("%s: no /config node?\n" , __func__);@@ -422,7 +425,6 @@ static int board_check_usb_power(void)return 0 ; } -#endif /* CONFIG_ADC */ static void sysconf_init (void ) {board/st/stm32mp1/stm32mp1.c int board_late_init(void) · line 708
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-2@@ -699,10 +701,8 @@ int board_late_init(void) }#endif -#ifdef CONFIG_ADC /* for DK1/DK2 boards */ board_check_usb_power (); -#endif /* CONFIG_ADC */ return 0 ; }Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 4/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in sysconf_init.
---
board/st/stm32mp1/stm32mp1.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
board/st/stm32mp1/stm32mp1.c +3 -8
@@ -428,14 +428,11 @@ static int board_check_usb_power(void)static void sysconf_init (void ) { -#ifndef CONFIG_TFABOOT u8 *syscfg; -#ifdef CONFIG_DM_REGULATOR struct udevice *pwr_dev;struct udevice *pwr_reg;struct udevice *dev;u32 otp =0 ; -#endif int ret;u32 bootr, val;
@@ -453,7 +450,6 @@ static void sysconf_init(void) bootr |= (bootr &SYSCFG_BOOTR_BOOT_MASK ) <<SYSCFG_BOOTR_BOOTPD_SHIFT ;writel (bootr, syscfg +SYSCFG_BOOTR ); -#ifdef CONFIG_DM_REGULATOR /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection. * The customer will have to disable this for low frequencies
@@ -470,7 +466,7 @@ static void sysconf_init(void) ret =uclass_get_device_by_driver (UCLASS_PMIC ,DM_GET_DRIVER (stm32mp_pwr_pmic), &pwr_dev); -if (!ret) { +if (!ret &&IS_ENABLED (CONFIG_DM_REGULATOR )) { ret =uclass_get_device_by_driver (UCLASS_MISC ,DM_GET_DRIVER (stm32mp_bsec), &dev);
@@ -507,7 +503,6 @@ static void sysconf_init(void)debug ("VDD unknown" ); } } -#endif /* activate automatic I/O compensation * warning: need to ensure CSI enabled and ready in clock driver
@@ -524,7 +519,6 @@ static void sysconf_init(void) }clrbits_le32 (syscfg +SYSCFG_CMPCR ,SYSCFG_CMPCR_SW_CTRL ); -#endif }#ifdef CONFIG_DM_REGULATOR
@@ -647,7 +641,8 @@ int board_init(void)regulators_enable_boot_on (_DEBUG);#endif -sysconf_init (); +if (!IS_ENABLED (CONFIG_TFABOOT )) +sysconf_init ();if (CONFIG_IS_ENABLED (LED ))led_default_state ();
Signature · 1 line
2.17.1
PATCH 4/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init
Hi Patrick
Quoted 61 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef insysconf_init.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)board/st/stm32mp1/stm32mp1.c +1
-7@@ -428,14 +428,11 @@ static int board_check_usb_power(void)static void sysconf_init (void ) { -#ifndef CONFIG_TFABOOT u8 *syscfg; -#ifdef CONFIG_DM_REGULATOR struct udevice *pwr_dev;struct udevice *pwr_reg;struct udevice *dev;u32 otp =0 ; -#endif int ret;u32 bootr, val;@@ -453,7 +450,6 @@ static void sysconf_init(void) bootr |= (bootr &SYSCFG_BOOTR_BOOT_MASK ) <<SYSCFG_BOOTR_BOOTPD_SHIFT ;writel (bootr, syscfg +SYSCFG_BOOTR ); -#ifdef CONFIG_DM_REGULATOR /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection. * The customer will have to disable this for low frequencies @@ -470,7 +466,7 @@ static void sysconf_init(void) ret =uclass_get_device_by_driver (UCLASS_PMIC ,DM_GET_DRIVER (stm32mp_pwr_pmic), &pwr_dev); -if (!ret) { +if (!ret &&IS_ENABLED (CONFIG_DM_REGULATOR )) { ret =uclass_get_device_by_driver (UCLASS_MISC ,DM_GET_DRIVER (stm32mp_bsec), &dev);@@ -507,7 +503,6 @@ static void sysconf_init(void)debug ("VDD unknown" ); } } -#endif /* activate automatic I/O compensation * warning: need to ensure CSI enabled and ready in clock driver @@ -524,7 +519,6 @@ static void sysconf_init(void) }clrbits_le32 (syscfg +SYSCFG_CMPCR ,SYSCFG_CMPCR_SW_CTRL ); -#endif }#ifdef CONFIG_DM_REGULATOR
board/st/stm32mp1/stm32mp1.c int board_init(void) · line 648
Quoted 9 lines
board/st/stm32mp1/stm32mp1.c +2
-1@@ -647,7 +641,8 @@ int board_init(void)regulators_enable_boot_on (_DEBUG);#endif -sysconf_init (); +if (!IS_ENABLED (CONFIG_TFABOOT )) +sysconf_init ();if (CONFIG_IS_ENABLED (LED ))led_default_state ();
Thanks
Patrice
PATCH 4/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef insysconf_init.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 71 lines
Quoted 53 lines
board/st/stm32mp1/stm32mp1.c +1
-7@@ -428,14 +428,11 @@ static int board_check_usb_power(void)static void sysconf_init (void ) { -#ifndef CONFIG_TFABOOT u8 *syscfg; -#ifdef CONFIG_DM_REGULATOR struct udevice *pwr_dev;struct udevice *pwr_reg;struct udevice *dev;u32 otp =0 ; -#endif int ret;u32 bootr, val;@@ -453,7 +450,6 @@ static void sysconf_init(void) bootr |= (bootr &SYSCFG_BOOTR_BOOT_MASK ) <<SYSCFG_BOOTR_BOOTPD_SHIFT ;writel (bootr, syscfg +SYSCFG_BOOTR ); -#ifdef CONFIG_DM_REGULATOR /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection. * The customer will have to disable this for low frequencies @@ -470,7 +466,7 @@ static void sysconf_init(void) ret =uclass_get_device_by_driver (UCLASS_PMIC ,DM_GET_DRIVER (stm32mp_pwr_pmic), &pwr_dev); -if (!ret) { +if (!ret &&IS_ENABLED (CONFIG_DM_REGULATOR )) { ret =uclass_get_device_by_driver (UCLASS_MISC ,DM_GET_DRIVER (stm32mp_bsec), &dev);@@ -507,7 +503,6 @@ static void sysconf_init(void)debug ("VDD unknown" ); } } -#endif /* activate automatic I/O compensation * warning: need to ensure CSI enabled and ready in clock driver @@ -524,7 +519,6 @@ static void sysconf_init(void) }clrbits_le32 (syscfg +SYSCFG_CMPCR ,SYSCFG_CMPCR_SW_CTRL ); -#endif }#ifdef CONFIG_DM_REGULATOR board/st/stm32mp1/stm32mp1.c int board_init(void) · line 648
Quoted 9 lines
board/st/stm32mp1/stm32mp1.c +2
-1@@ -647,7 +641,8 @@ int board_init(void)regulators_enable_boot_on (_DEBUG);#endif -sysconf_init (); +if (!IS_ENABLED (CONFIG_TFABOOT )) +sysconf_init ();if (CONFIG_IS_ENABLED (LED ))led_default_state ();Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 5/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf
In reply to Patrick DelaunayUse CONFIG_IS_ENABLED to prevent ifdef in set_dfu_alt_inf.
---
board/st/common/stm32mp_dfu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
board/st/common/stm32mp_dfu.c +11 -9
@@ -113,11 +113,13 @@ void set_dfu_alt_info(char *interface, char *devstr)snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 ); -if (!uclass_get_device (UCLASS_MMC ,0 , &dev)) -board_get_alt_info_mmc (dev, buf); +if (CONFIG_IS_ENABLED (MMC )) { +if (!uclass_get_device (UCLASS_MMC ,0 , &dev)) +board_get_alt_info_mmc (dev, buf); -if (!uclass_get_device (UCLASS_MMC ,1 , &dev)) -board_get_alt_info_mmc (dev, buf); +if (!uclass_get_device (UCLASS_MMC ,1 , &dev)) +board_get_alt_info_mmc (dev, buf); + }if (CONFIG_IS_ENABLED (MTD )) {/* probe all MTD devices */
@@ -139,12 +141,12 @@ void set_dfu_alt_info(char *interface, char *devstr)board_get_alt_info_mtd (mtd, buf); } -#ifdef CONFIG_DFU_VIRT -strncat (buf,"&virt 0=OTP" ,DFU_ALT_BUF_LEN ); +if (IS_ENABLED (CONFIG_DFU_VIRT )) { +strncat (buf,"&virt 0=OTP" ,DFU_ALT_BUF_LEN ); -if (IS_ENABLED (CONFIG_PMIC_STPMIC1 )) -strncat (buf,"&virt 1=PMIC" ,DFU_ALT_BUF_LEN ); -#endif +if (IS_ENABLED (CONFIG_PMIC_STPMIC1 )) +strncat (buf,"&virt 1=PMIC" ,DFU_ALT_BUF_LEN ); + }env_set ("dfu_alt_info" , buf);puts ("DFU alt info setting: done\n" );
Signature · 1 line
2.17.1
PATCH 5/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf
Hi Patrick
Quoted 38 lines · Patrick Delaunay
Use
CONFIG_IS_ENABLEDto prevent ifdef inset_dfu_alt_inf.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/common/stm32mp_dfu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)board/st/common/stm32mp_dfu.c +8
-6@@ -113,11 +113,13 @@ void set_dfu_alt_info(char *interface, char *devstr)snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 ); -if (!uclass_get_device (UCLASS_MMC ,0 , &dev)) -board_get_alt_info_mmc (dev, buf); +if (CONFIG_IS_ENABLED (MMC )) { +if (!uclass_get_device (UCLASS_MMC ,0 , &dev)) +board_get_alt_info_mmc (dev, buf); -if (!uclass_get_device (UCLASS_MMC ,1 , &dev)) -board_get_alt_info_mmc (dev, buf); +if (!uclass_get_device (UCLASS_MMC ,1 , &dev)) +board_get_alt_info_mmc (dev, buf); + }if (CONFIG_IS_ENABLED (MTD )) {/* probe all MTD devices */ @@ -139,12 +141,12 @@ void set_dfu_alt_info(char *interface, char *devstr)board_get_alt_info_mtd (mtd, buf); } -#ifdef CONFIG_DFU_VIRT -strncat (buf,"&virt 0=OTP" ,DFU_ALT_BUF_LEN ); +if (IS_ENABLED (CONFIG_DFU_VIRT )) { +strncat (buf,"&virt 0=OTP" ,DFU_ALT_BUF_LEN );
board/st/common/stm32mp_dfu.c void set_dfu_alt_info(char *interface, char *devstr) · line 152
Quoted 10 lines
board/st/common/stm32mp_dfu.c +3
-3-if (IS_ENABLED (CONFIG_PMIC_STPMIC1 )) -strncat (buf,"&virt 1=PMIC" ,DFU_ALT_BUF_LEN ); -#endif +if (IS_ENABLED (CONFIG_PMIC_STPMIC1 )) +strncat (buf,"&virt 1=PMIC" ,DFU_ALT_BUF_LEN ); + }env_set ("dfu_alt_info" , buf);puts ("DFU alt info setting: done\n" );
Thanks
Patrice
PATCH 5/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
CONFIG_IS_ENABLEDto prevent ifdef inset_dfu_alt_inf.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/common/stm32mp_dfu.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 50 lines
Quoted 31 lines
board/st/common/stm32mp_dfu.c +8
-6@@ -113,11 +113,13 @@ void set_dfu_alt_info(char *interface, char *devstr)snprintf (buf,DFU_ALT_BUF_LEN ,"ram 0=%s" ,CONFIG_DFU_ALT_RAM0 ); -if (!uclass_get_device (UCLASS_MMC ,0 , &dev)) -board_get_alt_info_mmc (dev, buf); +if (CONFIG_IS_ENABLED (MMC )) { +if (!uclass_get_device (UCLASS_MMC ,0 , &dev)) +board_get_alt_info_mmc (dev, buf); -if (!uclass_get_device (UCLASS_MMC ,1 , &dev)) -board_get_alt_info_mmc (dev, buf); +if (!uclass_get_device (UCLASS_MMC ,1 , &dev)) +board_get_alt_info_mmc (dev, buf); + }if (CONFIG_IS_ENABLED (MTD )) {/* probe all MTD devices */ @@ -139,12 +141,12 @@ void set_dfu_alt_info(char *interface, char *devstr)board_get_alt_info_mtd (mtd, buf); } -#ifdef CONFIG_DFU_VIRT -strncat (buf,"&virt 0=OTP" ,DFU_ALT_BUF_LEN ); +if (IS_ENABLED (CONFIG_DFU_VIRT )) { +strncat (buf,"&virt 0=OTP" ,DFU_ALT_BUF_LEN );board/st/common/stm32mp_dfu.c void set_dfu_alt_info(char *interface, char *devstr) · line 152
Quoted 10 lines
board/st/common/stm32mp_dfu.c +3
-3-if (IS_ENABLED (CONFIG_PMIC_STPMIC1 )) -strncat (buf,"&virt 1=PMIC" ,DFU_ALT_BUF_LEN ); -#endif +if (IS_ENABLED (CONFIG_PMIC_STPMIC1 )) +strncat (buf,"&virt 1=PMIC" ,DFU_ALT_BUF_LEN ); + }env_set ("dfu_alt_info" , buf);puts ("DFU alt info setting: done\n" );Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 6/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in dk2_i2c1_fix.
---
board/st/stm32mp1/stm32mp1.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
board/st/stm32mp1/stm32mp1.c +5 -5
@@ -521,7 +521,6 @@ static void sysconf_init(void)clrbits_le32 (syscfg +SYSCFG_CMPCR ,SYSCFG_CMPCR_SW_CTRL ); } -#ifdef CONFIG_DM_REGULATOR /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */ static int dk2_i2c1_fix (void ) {
@@ -529,6 +528,9 @@ static int dk2_i2c1_fix(void)struct gpio_desc hdmi, audio;int ret =0 ; +if (!IS_ENABLED (CONFIG_DM_REGULATOR )) +return -ENODEV ; + node =ofnode_path ("/soc/i2c at 40012000/hdmi-transmitter at 39" );if (!ofnode_valid (node)) {pr_debug ("%s: no hdmi-transmitter at 39 ?\n" , __func__);
@@ -586,7 +588,6 @@ static bool board_is_dk2(void)return false; } -#endif static bool board_is_ev1 (void ) {
@@ -634,12 +635,11 @@ int board_init(void)if (board_is_ev1 ())board_ev1_init (); -#ifdef CONFIG_DM_REGULATOR if (board_is_dk2 ())dk2_i2c1_fix (); -regulators_enable_boot_on (_DEBUG); -#endif +if (IS_ENABLED (CONFIG_DM_REGULATOR )) +regulators_enable_boot_on (_DEBUG);if (!IS_ENABLED (CONFIG_TFABOOT ))sysconf_init ();
Signature · 1 line
2.17.1
PATCH 6/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix
Hi Patrick
Quoted 43 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef indk2_i2c1_fix.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)board/st/stm32mp1/stm32mp1.c +3
-3@@ -521,7 +521,6 @@ static void sysconf_init(void)clrbits_le32 (syscfg +SYSCFG_CMPCR ,SYSCFG_CMPCR_SW_CTRL ); } -#ifdef CONFIG_DM_REGULATOR /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */ static int dk2_i2c1_fix (void ) {@@ -529,6 +528,9 @@ static int dk2_i2c1_fix(void)struct gpio_desc hdmi, audio;int ret =0 ; +if (!IS_ENABLED (CONFIG_DM_REGULATOR )) +return -ENODEV ; + node =ofnode_path ("/soc/i2c at 40012000/hdmi-transmitter at 39" );if (!ofnode_valid (node)) {pr_debug ("%s: no hdmi-transmitter at 39 ?\n" , __func__);@@ -586,7 +588,6 @@ static bool board_is_dk2(void)return false; } -#endif static bool board_is_ev1 (void ) {@@ -634,12 +635,11 @@ int board_init(void)if (board_is_ev1 ())board_ev1_init (); -#ifdef CONFIG_DM_REGULATOR
board/st/stm32mp1/stm32mp1.c int board_init(void) · line 645
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +2
-2if (board_is_dk2 ())dk2_i2c1_fix (); -regulators_enable_boot_on (_DEBUG); -#endif +if (IS_ENABLED (CONFIG_DM_REGULATOR )) +regulators_enable_boot_on (_DEBUG);if (!IS_ENABLED (CONFIG_TFABOOT ))sysconf_init ();
Thanks
Patrice
PATCH 6/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef indk2_i2c1_fix.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 55 lines
Quoted 36 lines
board/st/stm32mp1/stm32mp1.c +3
-3@@ -521,7 +521,6 @@ static void sysconf_init(void)clrbits_le32 (syscfg +SYSCFG_CMPCR ,SYSCFG_CMPCR_SW_CTRL ); } -#ifdef CONFIG_DM_REGULATOR /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */ static int dk2_i2c1_fix (void ) {@@ -529,6 +528,9 @@ static int dk2_i2c1_fix(void)struct gpio_desc hdmi, audio;int ret =0 ; +if (!IS_ENABLED (CONFIG_DM_REGULATOR )) +return -ENODEV ; + node =ofnode_path ("/soc/i2c at 40012000/hdmi-transmitter at 39" );if (!ofnode_valid (node)) {pr_debug ("%s: no hdmi-transmitter at 39 ?\n" , __func__);@@ -586,7 +588,6 @@ static bool board_is_dk2(void)return false; } -#endif static bool board_is_ev1 (void ) {@@ -634,12 +635,11 @@ int board_init(void)if (board_is_ev1 ())board_ev1_init (); -#ifdef CONFIG_DM_REGULATOR board/st/stm32mp1/stm32mp1.c int board_init(void) · line 645
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +2
-2if (board_is_dk2 ())dk2_i2c1_fix (); -regulators_enable_boot_on (_DEBUG); -#endif +if (IS_ENABLED (CONFIG_DM_REGULATOR )) +regulators_enable_boot_on (_DEBUG);if (!IS_ENABLED (CONFIG_TFABOOT ))sysconf_init ();Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 7/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in board_late_init.
---
board/st/stm32mp1/stm32mp1.c | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-)
board/st/stm32mp1/stm32mp1.c +30 -30
@@ -654,47 +654,47 @@ int board_init(void)int board_late_init (void ) { -#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG const void *fdt_compat;int fdt_compat_len;int ret;u32 otp;struct udevice *dev;char buf[10 ]; +char dtb_name[256 ]; +int buf_len; + +if (IS_ENABLED (CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG )) { + fdt_compat =fdt_getprop (gd->fdt_blob,0 ,"compatible" , + &fdt_compat_len); +if (fdt_compat && fdt_compat_len) { +if (strncmp (fdt_compat,"st," ,3 ) !=0 ) { +env_set ("board_name" , fdt_compat); + }else { +env_set ("board_name" , fdt_compat +3 ); - fdt_compat =fdt_getprop (gd->fdt_blob,0 ,"compatible" , - &fdt_compat_len); -if (fdt_compat && fdt_compat_len) { -if (strncmp (fdt_compat,"st," ,3 ) !=0 ) { -env_set ("board_name" , fdt_compat); - }else { -char dtb_name[256 ]; -int buf_len =sizeof (dtb_name); + buf_len =sizeof (dtb_name); +strncpy (dtb_name, fdt_compat +3 , buf_len); + buf_len -=strlen (fdt_compat +3 ); +strncat (dtb_name,".dtb" , buf_len); +env_set ("fdtfile" , dtb_name); + } + } + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_GET_DRIVER (stm32mp_bsec), + &dev); -env_set ("board_name" , fdt_compat +3 ); +if (!ret) + ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), + &otp,sizeof (otp)); +if (ret >0 && otp) { +snprintf (buf,sizeof (buf),"0x%04x" , otp >>16 ); +env_set ("board_id" , buf); -strncpy (dtb_name, fdt_compat +3 , buf_len); - buf_len -=strlen (fdt_compat +3 ); -strncat (dtb_name,".dtb" , buf_len); -env_set ("fdtfile" , dtb_name); +snprintf (buf,sizeof (buf),"0x%04x" , + ((otp >>8 ) &0xF ) -1 +0xA ); +env_set ("board_rev" , buf); } } - ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), - &dev); - -if (!ret) - ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), - &otp,sizeof (otp)); -if (ret >0 && otp) { -snprintf (buf,sizeof (buf),"0x%04x" , otp >>16 ); -env_set ("board_id" , buf); - -snprintf (buf,sizeof (buf),"0x%04x" , - ((otp >>8 ) &0xF ) -1 +0xA ); -env_set ("board_rev" , buf); - } -#endif /* for DK1/DK2 boards */ board_check_usb_power ();
Signature · 1 line
2.17.1
PATCH 7/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init
Hi Patrick
Quoted 80 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inboard_late_init.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-)board/st/stm32mp1/stm32mp1.c +30
-23@@ -654,47 +654,47 @@ int board_init(void)int board_late_init (void ) { -#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG const void *fdt_compat;int fdt_compat_len;int ret;u32 otp;struct udevice *dev;char buf[10 ]; +char dtb_name[256 ]; +int buf_len; + +if (IS_ENABLED (CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG )) { + fdt_compat =fdt_getprop (gd->fdt_blob,0 ,"compatible" , + &fdt_compat_len); +if (fdt_compat && fdt_compat_len) { +if (strncmp (fdt_compat,"st," ,3 ) !=0 ) { +env_set ("board_name" , fdt_compat); + }else { +env_set ("board_name" , fdt_compat +3 ); - fdt_compat =fdt_getprop (gd->fdt_blob,0 ,"compatible" , - &fdt_compat_len); -if (fdt_compat && fdt_compat_len) { -if (strncmp (fdt_compat,"st," ,3 ) !=0 ) { -env_set ("board_name" , fdt_compat); - }else { -char dtb_name[256 ]; -int buf_len =sizeof (dtb_name); + buf_len =sizeof (dtb_name); +strncpy (dtb_name, fdt_compat +3 , buf_len); + buf_len -=strlen (fdt_compat +3 ); +strncat (dtb_name,".dtb" , buf_len); +env_set ("fdtfile" , dtb_name); + } + } + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_GET_DRIVER (stm32mp_bsec), + &dev); -env_set ("board_name" , fdt_compat +3 ); +if (!ret) + ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), + &otp,sizeof (otp)); +if (ret >0 && otp) { +snprintf (buf,sizeof (buf),"0x%04x" , otp >>16 ); +env_set ("board_id" , buf); -strncpy (dtb_name, fdt_compat +3 , buf_len); - buf_len -=strlen (fdt_compat +3 ); -strncat (dtb_name,".dtb" , buf_len); -env_set ("fdtfile" , dtb_name); +snprintf (buf,sizeof (buf),"0x%04x" , + ((otp >>8 ) &0xF ) -1 +0xA ); +env_set ("board_rev" , buf); } } - ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), - &dev); - -if (!ret) - ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), - &otp,sizeof (otp)); -if (ret >0 && otp) { -snprintf (buf,sizeof (buf),"0x%04x" , otp >>16 );
board/st/stm32mp1/stm32mp1.c int board_init(void) · line 700
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-7-env_set ("board_id" , buf); - -snprintf (buf,sizeof (buf),"0x%04x" , - ((otp >>8 ) &0xF ) -1 +0xA ); - env_set("board_rev", buf); - } -#endif /* for DK1/DK2 boards */ board_check_usb_power ();
Thanks
Patrice
PATCH 7/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inboard_late_init.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 88 lines
Quoted 73 lines
board/st/stm32mp1/stm32mp1.c +30
-23@@ -654,47 +654,47 @@ int board_init(void)int board_late_init (void ) { -#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG const void *fdt_compat;int fdt_compat_len;int ret;u32 otp;struct udevice *dev;char buf[10 ]; +char dtb_name[256 ]; +int buf_len; + +if (IS_ENABLED (CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG )) { + fdt_compat =fdt_getprop (gd->fdt_blob,0 ,"compatible" , + &fdt_compat_len); +if (fdt_compat && fdt_compat_len) { +if (strncmp (fdt_compat,"st," ,3 ) !=0 ) { +env_set ("board_name" , fdt_compat); + }else { +env_set ("board_name" , fdt_compat +3 ); - fdt_compat =fdt_getprop (gd->fdt_blob,0 ,"compatible" , - &fdt_compat_len); -if (fdt_compat && fdt_compat_len) { -if (strncmp (fdt_compat,"st," ,3 ) !=0 ) { -env_set ("board_name" , fdt_compat); - }else { -char dtb_name[256 ]; -int buf_len =sizeof (dtb_name); + buf_len =sizeof (dtb_name); +strncpy (dtb_name, fdt_compat +3 , buf_len); + buf_len -=strlen (fdt_compat +3 ); +strncat (dtb_name,".dtb" , buf_len); +env_set ("fdtfile" , dtb_name); + } + } + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_GET_DRIVER (stm32mp_bsec), + &dev); -env_set ("board_name" , fdt_compat +3 ); +if (!ret) + ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), + &otp,sizeof (otp)); +if (ret >0 && otp) { +snprintf (buf,sizeof (buf),"0x%04x" , otp >>16 ); +env_set ("board_id" , buf); -strncpy (dtb_name, fdt_compat +3 , buf_len); - buf_len -=strlen (fdt_compat +3 ); -strncat (dtb_name,".dtb" , buf_len); -env_set ("fdtfile" , dtb_name); +snprintf (buf,sizeof (buf),"0x%04x" , + ((otp >>8 ) &0xF ) -1 +0xA ); +env_set ("board_rev" , buf); } } - ret =uclass_get_device_by_driver (UCLASS_MISC , -DM_GET_DRIVER (stm32mp_bsec), - &dev); - -if (!ret) - ret =misc_read (dev,STM32_BSEC_SHADOW (BSEC_OTP_BOARD ), - &otp,sizeof (otp)); -if (ret >0 && otp) { -snprintf (buf,sizeof (buf),"0x%04x" , otp >>16 );board/st/stm32mp1/stm32mp1.c int board_init(void) · line 700
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-7-env_set ("board_id" , buf); - -snprintf (buf,sizeof (buf),"0x%04x" , - ((otp >>8 ) &0xF ) -1 +0xA ); - env_set("board_rev", buf); - } -#endif /* for DK1/DK2 boards */ board_check_usb_power ();Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
PATCH 8/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in env functions:
- env_get_location
- env_ext4_get_intf
- mmc_get_env_dev
---
board/st/stm32mp1/stm32mp1.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
board/st/stm32mp1/stm32mp1.c +17 -19
@@ -785,31 +785,33 @@ enum env_location env_get_location(enum env_operation op, int prio)return ENVL_UNKNOWN ;switch (bootmode &TAMP_BOOT_DEVICE_MASK ) { -#if CONFIG_IS_ENABLED (ENV_IS_IN_MMC )case BOOT_FLASH_SD :case BOOT_FLASH_EMMC : -return ENVL_MMC ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_EXT4 ) -case BOOT_FLASH_SD : -case BOOT_FLASH_EMMC : -return ENVL_EXT4 ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_UBI ) +if (CONFIG_IS_ENABLED (ENV_IS_IN_MMC )) +return ENVL_MMC ; +else if (CONFIG_IS_ENABLED (ENV_IS_IN_EXT4 )) +return ENVL_EXT4 ; +else +return ENVL_NOWHERE ; +case BOOT_FLASH_NAND :case BOOT_FLASH_SPINAND : -return ENVL_UBI ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_SPI_FLASH ) +if (CONFIG_IS_ENABLED (ENV_IS_IN_UBI )) +return ENVL_UBI ; +else +return ENVL_NOWHERE ; +case BOOT_FLASH_NOR : -return ENVL_SPI_FLASH ; -#endif +if (CONFIG_IS_ENABLED (ENV_IS_IN_SPI_FLASH )) +return ENVL_SPI_FLASH ; +else +return ENVL_NOWHERE ; +default :return ENVL_NOWHERE ; } } -#if defined(CONFIG_ENV_IS_IN_EXT4 )const char *env_ext4_get_intf (void ) {u32 bootmode =get_bootmode ();
@@ -830,16 +832,12 @@ const char *env_ext4_get_dev_part(void)return dev_part[(bootmode &TAMP_BOOT_INSTANCE_MASK ) -1 ]; } -#endif - -#if defined(CONFIG_ENV_IS_IN_MMC )int mmc_get_env_dev (void ) {u32 bootmode =get_bootmode ();return (bootmode &TAMP_BOOT_INSTANCE_MASK ) -1 ; } -#endif #if defined(CONFIG_OF_BOARD_SETUP )int ft_board_setup (void *blob,struct bd_info *bd)
Signature · 1 line
2.17.1
PATCH 8/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions
Hi Patrick
Quoted 71 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef in env functions:
-env_get_location
-env_ext4_get_intf
-mmc_get_env_devSigned-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)board/st/stm32mp1/stm32mp1.c +17
-18@@ -785,31 +785,33 @@ enum env_location env_get_location(enum env_operation op, int prio)return ENVL_UNKNOWN ;switch (bootmode &TAMP_BOOT_DEVICE_MASK ) { -#if CONFIG_IS_ENABLED (ENV_IS_IN_MMC )case BOOT_FLASH_SD :case BOOT_FLASH_EMMC : -return ENVL_MMC ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_EXT4 ) -case BOOT_FLASH_SD : -case BOOT_FLASH_EMMC : -return ENVL_EXT4 ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_UBI ) +if (CONFIG_IS_ENABLED (ENV_IS_IN_MMC )) +return ENVL_MMC ; +else if (CONFIG_IS_ENABLED (ENV_IS_IN_EXT4 )) +return ENVL_EXT4 ; +else +return ENVL_NOWHERE ; +case BOOT_FLASH_NAND :case BOOT_FLASH_SPINAND : -return ENVL_UBI ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_SPI_FLASH ) +if (CONFIG_IS_ENABLED (ENV_IS_IN_UBI )) +return ENVL_UBI ; +else +return ENVL_NOWHERE ; +case BOOT_FLASH_NOR : -return ENVL_SPI_FLASH ; -#endif +if (CONFIG_IS_ENABLED (ENV_IS_IN_SPI_FLASH )) +return ENVL_SPI_FLASH ; +else +return ENVL_NOWHERE ; +default :return ENVL_NOWHERE ; } } -#if defined(CONFIG_ENV_IS_IN_EXT4 )const char *env_ext4_get_intf (void ) {u32 bootmode =get_bootmode ();@@ -830,16 +832,12 @@ const char *env_ext4_get_dev_part(void)return dev_part[(bootmode &TAMP_BOOT_INSTANCE_MASK ) -1 ]; } -#endif - -#if defined(CONFIG_ENV_IS_IN_MMC )
board/st/stm32mp1/stm32mp1.c const char *env_ext4_get_dev_part(void) · line 843
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-1int mmc_get_env_dev (void ) {u32 bootmode =get_bootmode ();return (bootmode &TAMP_BOOT_INSTANCE_MASK ) -1 ; } -#endif #if defined(CONFIG_OF_BOARD_SETUP )int ft_board_setup (void *blob,struct bd_info *bd)
Thanks
Patrice
PATCH 8/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions
Quoted 13 lines · Patrice CHOTARD
Hi Patrick
Quoted 10 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef in env functions:
-env_get_location
-env_ext4_get_intf
-mmc_get_env_devSigned-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 79 lines
Quoted 60 lines
board/st/stm32mp1/stm32mp1.c +17
-18@@ -785,31 +785,33 @@ enum env_location env_get_location(enum env_operation op, int prio)return ENVL_UNKNOWN ;switch (bootmode &TAMP_BOOT_DEVICE_MASK ) { -#if CONFIG_IS_ENABLED (ENV_IS_IN_MMC )case BOOT_FLASH_SD :case BOOT_FLASH_EMMC : -return ENVL_MMC ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_EXT4 ) -case BOOT_FLASH_SD : -case BOOT_FLASH_EMMC : -return ENVL_EXT4 ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_UBI ) +if (CONFIG_IS_ENABLED (ENV_IS_IN_MMC )) +return ENVL_MMC ; +else if (CONFIG_IS_ENABLED (ENV_IS_IN_EXT4 )) +return ENVL_EXT4 ; +else +return ENVL_NOWHERE ; +case BOOT_FLASH_NAND :case BOOT_FLASH_SPINAND : -return ENVL_UBI ; -#endif -#if CONFIG_IS_ENABLED (ENV_IS_IN_SPI_FLASH ) +if (CONFIG_IS_ENABLED (ENV_IS_IN_UBI )) +return ENVL_UBI ; +else +return ENVL_NOWHERE ; +case BOOT_FLASH_NOR : -return ENVL_SPI_FLASH ; -#endif +if (CONFIG_IS_ENABLED (ENV_IS_IN_SPI_FLASH )) +return ENVL_SPI_FLASH ; +else +return ENVL_NOWHERE ; +default :return ENVL_NOWHERE ; } } -#if defined(CONFIG_ENV_IS_IN_EXT4 )const char *env_ext4_get_intf (void ) {u32 bootmode =get_bootmode ();@@ -830,16 +832,12 @@ const char *env_ext4_get_dev_part(void)return dev_part[(bootmode &TAMP_BOOT_INSTANCE_MASK ) -1 ]; } -#endif - -#if defined(CONFIG_ENV_IS_IN_MMC )board/st/stm32mp1/stm32mp1.c const char *env_ext4_get_dev_part(void) · line 843
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-1int mmc_get_env_dev (void ) {u32 bootmode =get_bootmode ();return (bootmode &TAMP_BOOT_INSTANCE_MASK ) -1 ; } -#endif #if defined(CONFIG_OF_BOARD_SETUP )int ft_board_setup (void *blob,struct bd_info *bd)Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 9/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in ft_board_setup.
---
board/st/stm32mp1/stm32mp1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
board/st/stm32mp1/stm32mp1.c +3 -3
@@ -842,14 +842,14 @@ int mmc_get_env_dev(void)#if defined(CONFIG_OF_BOARD_SETUP )int ft_board_setup (void *blob,struct bd_info *bd) { -#ifdef CONFIG_FDT_FIXUP_PARTITIONS struct node_info nodes[] = { {"st,stm32f469-qspi" ,MTD_DEV_TYPE_NOR , }, {"st,stm32f469-qspi" ,MTD_DEV_TYPE_SPINAND }, {"st,stm32mp15-fmc2" ,MTD_DEV_TYPE_NAND , }, }; -fdt_fixup_mtdparts (blob, nodes,ARRAY_SIZE (nodes)); -#endif + +if (IS_ENABLED (CONFIG_FDT_FIXUP_PARTITIONS )) +fdt_fixup_mtdparts (blob, nodes,ARRAY_SIZE (nodes));return 0 ; }
Signature · 1 line
2.17.1
PATCH 9/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup
Hi Patrick
Quoted 20 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inft_board_setup.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)board/st/stm32mp1/stm32mp1.c +0
-1@@ -842,14 +842,14 @@ int mmc_get_env_dev(void) #if defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { -#ifdef CONFIG_FDT_FIXUP_PARTITIONS struct node_info nodes[] = { { "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, }, { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND},
board/st/stm32mp1/stm32mp1.c int mmc_get_env_dev(void) · line 855
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +3
-2{ "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, }, }; -fdt_fixup_mtdparts (blob, nodes,ARRAY_SIZE (nodes)); -#endif + +if (IS_ENABLED (CONFIG_FDT_FIXUP_PARTITIONS )) +fdt_fixup_mtdparts (blob, nodes,ARRAY_SIZE (nodes));return 0 ; }
Thanks
Patrice
PATCH 9/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inft_board_setup.Signed-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 31 lines
Quoted 12 lines
board/st/stm32mp1/stm32mp1.c +0
-1@@ -842,14 +842,14 @@ int mmc_get_env_dev(void) #if defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { -#ifdef CONFIG_FDT_FIXUP_PARTITIONS struct node_info nodes[] = { { "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, }, { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND},board/st/stm32mp1/stm32mp1.c int mmc_get_env_dev(void) · line 855
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +3
-2{ "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, }, }; -fdt_fixup_mtdparts (blob, nodes,ARRAY_SIZE (nodes)); -#endif + +if (IS_ENABLED (CONFIG_FDT_FIXUP_PARTITIONS )) +fdt_fixup_mtdparts (blob, nodes,ARRAY_SIZE (nodes));return 0 ; }Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 10/11 arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in bsec driver.
---
arch/arm/mach-stm32mp/bsec.c | 86 +++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 40 deletions(-)
arch/arm/mach-stm32mp/bsec.c +46 -40
@@ -74,7 +74,6 @@ static bool bsec_read_lock(u32 address, u32 otp)return !!(readl (address + bank) & bit); } -#ifndef CONFIG_TFABOOT /** * bsec_check_error() - Check status of one otp * @base: base address of bsec IP
@@ -279,7 +278,6 @@ static int bsec_program_otp(long base, u32 val, u32 otp)return ret; } -#endif /* CONFIG_TFABOOT */ /* BSEC MISC driver *******************************************************/ struct stm32mp_bsec_platdata {
@@ -288,15 +286,17 @@ struct stm32mp_bsec_platdata {static int stm32mp_bsec_read_otp (struct udevice *dev,u32 *val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc (STM32_SMC_BSEC , -STM32_SMC_READ_OTP , - otp,0 , val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat;u32 tmp_data =0 ;int ret; +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc (STM32_SMC_BSEC , +STM32_SMC_READ_OTP , + otp,0 , val); + + plat =dev_get_platdata (dev); +/* read current shadow value */ ret =bsec_read_shadow (plat->base, &tmp_data, otp);if (ret)
@@ -313,21 +313,22 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp)/* restore shadow value */ ret =bsec_write_shadow (plat->base, tmp_data, otp); +return ret; -#endif }static int stm32mp_bsec_read_shadow (struct udevice *dev,u32 *val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc (STM32_SMC_BSEC , -STM32_SMC_READ_SHADOW , - otp,0 , val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc (STM32_SMC_BSEC , +STM32_SMC_READ_SHADOW , + otp,0 , val); + + plat =dev_get_platdata (dev);return bsec_read_shadow (plat->base, val, otp); -#endif }static int stm32mp_bsec_read_lock (struct udevice *dev,u32 *val,u32 otp)
@@ -342,33 +343,38 @@ static int stm32mp_bsec_read_lock(struct udevice *dev, u32 *val, u32 otp)static int stm32mp_bsec_write_otp (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc_exec (STM32_SMC_BSEC , -STM32_SMC_PROG_OTP , - otp, val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc_exec (STM32_SMC_BSEC , +STM32_SMC_PROG_OTP , + otp, val); + + plat =dev_get_platdata (dev);return bsec_program_otp (plat->base, val, otp); -#endif + }static int stm32mp_bsec_write_shadow (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc_exec (STM32_SMC_BSEC , -STM32_SMC_WRITE_SHADOW , - otp, val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc_exec (STM32_SMC_BSEC , +STM32_SMC_WRITE_SHADOW , + otp, val); + + plat =dev_get_platdata (dev);return bsec_write_shadow (plat->base, val, otp); -#endif }static int stm32mp_bsec_write_lock (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT +if (!IS_ENABLED (CONFIG_TFABOOT )) +return -ENOTSUPP ; +if (val ==1 ) return stm32_smc_exec(STM32_SMC_BSEC, STM32_SMC_WRLOCK_OTP,
@@ -377,9 +383,6 @@ static int stm32mp_bsec_write_lock(struct udevice *dev, u32 val, u32 otp)return 0 ;/* nothing to do */ return -EINVAL ; -#else -return -ENOTSUPP ; -#endif } static int stm32mp_bsec_read(struct udevice *dev, int offset,
@@ -481,18 +484,21 @@ static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev)static int stm32mp_bsec_probe (struct udevice *dev) { -#if !defined(CONFIG_TFABOOT ) && !defined(CONFIG_SPL_BUILD )int otp; -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat;/* * update unlocked shadow for OTP cleared by the rom code * only executed in U-Boot proper when TF-A is not used */ -for (otp =57 ; otp <=BSEC_OTP_MAX_VALUE ; otp++) -if (!bsec_read_SR_lock (plat->base, otp)) -bsec_shadow_register (plat->base, otp); -#endif + +if (!IS_ENABLED (CONFIG_TFABOOT ) && !IS_ENABLED (CONFIG_SPL_BUILD )) { + plat =dev_get_platdata (dev); + +for (otp =57 ; otp <=BSEC_OTP_MAX_VALUE ; otp++) +if (!bsec_read_SR_lock (plat->base, otp)) +bsec_shadow_register (plat->base, otp); + }return 0 ; }
Signature · 1 line
2.17.1
PATCH 10/11 arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef
Hi Patrick
Quoted 165 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef in bsec driver.Signed-off-by Patrick Delaunay <[email protected]>---
arch/arm/mach-stm32mp/bsec.c | 86 +++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 40 deletions(-)arch/arm/mach-stm32mp/bsec.c +39
-40@@ -74,7 +74,6 @@ static bool bsec_read_lock(u32 address, u32 otp)return !!(readl (address + bank) & bit); } -#ifndef CONFIG_TFABOOT /** * bsec_check_error() - Check status of one otp * @base: base address of bsec IP @@ -279,7 +278,6 @@ static int bsec_program_otp(long base, u32 val, u32 otp)return ret; } -#endif /* CONFIG_TFABOOT */ /* BSEC MISC driver *******************************************************/ struct stm32mp_bsec_platdata {@@ -288,15 +286,17 @@ struct stm32mp_bsec_platdata {static int stm32mp_bsec_read_otp (struct udevice *dev,u32 *val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc (STM32_SMC_BSEC , -STM32_SMC_READ_OTP , - otp,0 , val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat;u32 tmp_data =0 ;int ret; +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc (STM32_SMC_BSEC , +STM32_SMC_READ_OTP , + otp,0 , val); + + plat =dev_get_platdata (dev); +/* read current shadow value */ ret =bsec_read_shadow (plat->base, &tmp_data, otp);if (ret)@@ -313,21 +313,22 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp)/* restore shadow value */ ret =bsec_write_shadow (plat->base, tmp_data, otp); +return ret; -#endif }static int stm32mp_bsec_read_shadow (struct udevice *dev,u32 *val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc (STM32_SMC_BSEC , -STM32_SMC_READ_SHADOW , - otp,0 , val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc (STM32_SMC_BSEC , +STM32_SMC_READ_SHADOW , + otp,0 , val); + + plat =dev_get_platdata (dev);return bsec_read_shadow (plat->base, val, otp); -#endif }static int stm32mp_bsec_read_lock (struct udevice *dev,u32 *val,u32 otp)@@ -342,33 +343,38 @@ static int stm32mp_bsec_read_lock(struct udevice *dev, u32 *val, u32 otp)static int stm32mp_bsec_write_otp (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc_exec (STM32_SMC_BSEC , -STM32_SMC_PROG_OTP , - otp, val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc_exec (STM32_SMC_BSEC , +STM32_SMC_PROG_OTP , + otp, val); + + plat =dev_get_platdata (dev);return bsec_program_otp (plat->base, val, otp); -#endif + }static int stm32mp_bsec_write_shadow (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc_exec (STM32_SMC_BSEC , -STM32_SMC_WRITE_SHADOW , - otp, val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc_exec (STM32_SMC_BSEC , +STM32_SMC_WRITE_SHADOW , + otp, val); + + plat =dev_get_platdata (dev);return bsec_write_shadow (plat->base, val, otp); -#endif }static int stm32mp_bsec_write_lock (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT +if (!IS_ENABLED (CONFIG_TFABOOT )) +return -ENOTSUPP ; +if (val ==1 ) return stm32_smc_exec(STM32_SMC_BSEC, STM32_SMC_WRLOCK_OTP,@@ -377,9 +383,6 @@ static int stm32mp_bsec_write_lock(struct udevice *dev, u32 val, u32 otp)return 0 ;/* nothing to do */ return -EINVAL ; -#else -return -ENOTSUPP ; -#endif } static int stm32mp_bsec_read(struct udevice *dev, int offset,@@ -481,18 +484,21 @@ static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev)static int stm32mp_bsec_probe (struct udevice *dev) { -#if !defined(CONFIG_TFABOOT ) && !defined(CONFIG_SPL_BUILD )int otp; -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat;/* * update unlocked shadow for OTP cleared by the rom code * only executed in U-Boot proper when TF-A is not used */ -for (otp =57 ; otp <=BSEC_OTP_MAX_VALUE ; otp++) -if (!bsec_read_SR_lock (plat->base, otp)) -bsec_shadow_register (plat->base, otp); -#endif +
arch/arm/mach-stm32mp/bsec.c static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev) · line 504
Quoted 10 lines
arch/arm/mach-stm32mp/bsec.c +7
-0+if (!IS_ENABLED (CONFIG_TFABOOT ) && !IS_ENABLED (CONFIG_SPL_BUILD )) { + plat =dev_get_platdata (dev); + +for (otp =57 ; otp <=BSEC_OTP_MAX_VALUE ; otp++) +if (!bsec_read_SR_lock (plat->base, otp)) +bsec_shadow_register (plat->base, otp); + }return 0 ; }
Thanks
Patrice
PATCH 10/11 arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef in bsec driver.Signed-off-by Patrick Delaunay <[email protected]>---
arch/arm/mach-stm32mp/bsec.c | 86 +++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 40 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 177 lines
Quoted 158 lines
arch/arm/mach-stm32mp/bsec.c +39
-40@@ -74,7 +74,6 @@ static bool bsec_read_lock(u32 address, u32 otp)return !!(readl (address + bank) & bit); } -#ifndef CONFIG_TFABOOT /** * bsec_check_error() - Check status of one otp * @base: base address of bsec IP @@ -279,7 +278,6 @@ static int bsec_program_otp(long base, u32 val, u32 otp)return ret; } -#endif /* CONFIG_TFABOOT */ /* BSEC MISC driver *******************************************************/ struct stm32mp_bsec_platdata {@@ -288,15 +286,17 @@ struct stm32mp_bsec_platdata {static int stm32mp_bsec_read_otp (struct udevice *dev,u32 *val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc (STM32_SMC_BSEC , -STM32_SMC_READ_OTP , - otp,0 , val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat;u32 tmp_data =0 ;int ret; +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc (STM32_SMC_BSEC , +STM32_SMC_READ_OTP , + otp,0 , val); + + plat =dev_get_platdata (dev); +/* read current shadow value */ ret =bsec_read_shadow (plat->base, &tmp_data, otp);if (ret)@@ -313,21 +313,22 @@ static int stm32mp_bsec_read_otp(struct udevice *dev, u32 *val, u32 otp)/* restore shadow value */ ret =bsec_write_shadow (plat->base, tmp_data, otp); +return ret; -#endif }static int stm32mp_bsec_read_shadow (struct udevice *dev,u32 *val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc (STM32_SMC_BSEC , -STM32_SMC_READ_SHADOW , - otp,0 , val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc (STM32_SMC_BSEC , +STM32_SMC_READ_SHADOW , + otp,0 , val); + + plat =dev_get_platdata (dev);return bsec_read_shadow (plat->base, val, otp); -#endif }static int stm32mp_bsec_read_lock (struct udevice *dev,u32 *val,u32 otp)@@ -342,33 +343,38 @@ static int stm32mp_bsec_read_lock(struct udevice *dev, u32 *val, u32 otp)static int stm32mp_bsec_write_otp (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc_exec (STM32_SMC_BSEC , -STM32_SMC_PROG_OTP , - otp, val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc_exec (STM32_SMC_BSEC , +STM32_SMC_PROG_OTP , + otp, val); + + plat =dev_get_platdata (dev);return bsec_program_otp (plat->base, val, otp); -#endif + }static int stm32mp_bsec_write_shadow (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT -return stm32_smc_exec (STM32_SMC_BSEC , -STM32_SMC_WRITE_SHADOW , - otp, val); -#else -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat; + +if (IS_ENABLED (CONFIG_TFABOOT )) +return stm32_smc_exec (STM32_SMC_BSEC , +STM32_SMC_WRITE_SHADOW , + otp, val); + + plat =dev_get_platdata (dev);return bsec_write_shadow (plat->base, val, otp); -#endif }static int stm32mp_bsec_write_lock (struct udevice *dev,u32 val,u32 otp) { -#ifdef CONFIG_TFABOOT +if (!IS_ENABLED (CONFIG_TFABOOT )) +return -ENOTSUPP ; +if (val ==1 ) return stm32_smc_exec(STM32_SMC_BSEC, STM32_SMC_WRLOCK_OTP,@@ -377,9 +383,6 @@ static int stm32mp_bsec_write_lock(struct udevice *dev, u32 val, u32 otp)return 0 ;/* nothing to do */ return -EINVAL ; -#else -return -ENOTSUPP ; -#endif } static int stm32mp_bsec_read(struct udevice *dev, int offset,@@ -481,18 +484,21 @@ static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev)static int stm32mp_bsec_probe (struct udevice *dev) { -#if !defined(CONFIG_TFABOOT ) && !defined(CONFIG_SPL_BUILD )int otp; -struct stm32mp_bsec_platdata *plat =dev_get_platdata (dev); +struct stm32mp_bsec_platdata *plat;/* * update unlocked shadow for OTP cleared by the rom code * only executed in U-Boot proper when TF-A is not used */ -for (otp =57 ; otp <=BSEC_OTP_MAX_VALUE ; otp++) -if (!bsec_read_SR_lock (plat->base, otp)) -bsec_shadow_register (plat->base, otp); -#endif +arch/arm/mach-stm32mp/bsec.c static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev) · line 504
Quoted 10 lines
arch/arm/mach-stm32mp/bsec.c +7
-0+if (!IS_ENABLED (CONFIG_TFABOOT ) && !IS_ENABLED (CONFIG_SPL_BUILD )) { + plat =dev_get_platdata (dev); + +for (otp =57 ; otp <=BSEC_OTP_MAX_VALUE ; otp++) +if (!bsec_read_SR_lock (plat->base, otp)) +bsec_shadow_register (plat->base, otp); + }return 0 ; }Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 11/11 arm: stm32mp: stm32prog: use IS_ENABLED to prevent ifdef
In reply to Patrick DelaunayUse IS_ENABLED to prevent ifdef in stm32prog command.
---
.../cmd_stm32prog/cmd_stm32prog.c | 5 +- .../mach-stm32mp/cmd_stm32prog/stm32prog.c | 100 ++++++++++-------- 2 files changed, 58 insertions(+), 47 deletions(-)
arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +2 -3
@@ -14,7 +14,6 @@ struct stm32prog_data *stm32prog_data;static void enable_vidconsole (void ) { -#ifdef CONFIG_DM_VIDEO char *stdname;char buf[64 ];
@@ -35,7 +34,6 @@ static void enable_vidconsole(void)snprintf (buf,sizeof (buf),"%s,vidconsole" , stdname);env_set ("stderr" , buf); } -#endif } static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -86,7 +84,8 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, "script at 1"); } -enable_vidconsole (); +if (IS_ENABLED (CONFIG_DM_VIDEO )) +enable_vidconsole (); data = (struct stm32prog_data *)malloc (sizeof (*data));
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +56 -44
236 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 11/11 arm: stm32mp: stm32prog: use IS_ENABLED to prevent ifdef
Hi Patrick
Quoted 285 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef in stm32prog command.Signed-off-by Patrick Delaunay <[email protected]>---
.../cmd_stm32prog/cmd_stm32prog.c | 5 +- .../mach-stm32mp/cmd_stm32prog/stm32prog.c | 100 ++++++++++-------- 2 files changed, 58 insertions(+), 47 deletions(-)arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +2
-3@@ -14,7 +14,6 @@ struct stm32prog_data *stm32prog_data;static void enable_vidconsole (void ) { -#ifdef CONFIG_DM_VIDEO char *stdname;char buf[64 ];@@ -35,7 +34,6 @@ static void enable_vidconsole(void)snprintf (buf,sizeof (buf),"%s,vidconsole" , stdname);env_set ("stderr" , buf); } -#endif } static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,@@ -86,7 +84,8 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, "script at 1"); } -enable_vidconsole (); +if (IS_ENABLED (CONFIG_DM_VIDEO )) +enable_vidconsole (); data = (struct stm32prog_data *)malloc (sizeof (*data));arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +51
-42@@ -544,10 +544,8 @@ static int init_device(struct stm32prog_data *data, {struct mmc *mmc =NULL ;struct blk_desc *block_dev =NULL ; -#ifdef CONFIG_MTD struct mtd_info *mtd =NULL ;char mtd_id[16 ]; -#endif int part_id;int ret;u64 first_addr =0 , last_addr =0 ;@@ -557,8 +555,11 @@ static int init_device(struct stm32prog_data *data,const char *part_name;switch (dev->target) { -#ifdef CONFIG_MMC case STM32PROG_MMC : +if (!IS_ENABLED (CONFIG_MMC )) { +stm32prog_err ("unknown device type = %d" , dev->target); +return -ENODEV ; + } mmc =find_mmc_device (dev->dev_id);if (!mmc ||mmc_init (mmc)) {stm32prog_err ("mmc device %d not found" , dev->dev_id);@@ -589,11 +590,13 @@ static int init_device(struct stm32prog_data *data, first_addr, last_addr);pr_debug (" full_update = %d\n" , dev->full_update);break ; -#endif -#ifdef CONFIG_MTD case STM32PROG_NOR :case STM32PROG_NAND :case STM32PROG_SPI_NAND : +if (!IS_ENABLED (CONFIG_MTD )) { +stm32prog_err ("unknown device type = %d" , dev->target); +return -ENODEV ; + }get_mtd_by_target (mtd_id, dev->target, dev->dev_id);pr_debug ("%s\n" , mtd_id);@@ -612,7 +615,6 @@ static int init_device(struct stm32prog_data *data, first_addr, last_addr); dev->mtd = mtd;break ; -#endif case STM32PROG_RAM : first_addr = gd->bd->bi_dram[0 ].start; last_addr = first_addr + gd->bd->bi_dram[0 ].size;@@ -744,8 +746,7 @@ static int init_device(struct stm32prog_data *data, part_found = true; } -#ifdef CONFIG_MTD -if (mtd) { +if (IS_ENABLED (CONFIG_MTD ) && mtd) {char mtd_part_id[32 ];struct part_info *mtd_part;struct mtd_device *mtd_dev;@@ -766,7 +767,7 @@ static int init_device(struct stm32prog_data *data, part_name = mtd_part->name; part_found = true; } -#endif +if (!part_found) {stm32prog_err ("%s (0x%x): Invalid partition" , part->name, part->id);@@ -873,9 +874,8 @@ static int treat_partition_list(struct stm32prog_data *data)return 0 ; } -static int create_partitions (struct stm32prog_data *data) +static int create_gpt_partitions (struct stm32prog_data *data) { -#ifdef CONFIG_MMC int offset =0 ;const int buflen =SZ_8K ;char *buf;@@ -991,7 +991,6 @@ static int create_partitions(struct stm32prog_data *data)run_command ("mtd list" ,0 );#endif free (buf); -#endif return 0 ; }@@ -1070,28 +1069,35 @@ static int stm32prog_alt_add(struct stm32prog_data *data, offset +=snprintf (buf + offset,ALT_BUF_LEN - offset," %d;" , part->part_id); } + ret = -ENODEV ;switch (part->target) { -#ifdef CONFIG_MMC case STM32PROG_MMC : -sprintf (dfustr,"mmc" ); -sprintf (devstr,"%d" , part->dev_id); +if (IS_ENABLED (CONFIG_MMC )) { + ret =0 ; +sprintf (dfustr,"mmc" ); +sprintf (devstr,"%d" , part->dev_id); + }break ; -#endif -#ifdef CONFIG_MTD case STM32PROG_NAND :case STM32PROG_NOR :case STM32PROG_SPI_NAND : -sprintf (dfustr,"mtd" ); -get_mtd_by_target (devstr, part->target, part->dev_id); +if (IS_ENABLED (CONFIG_MTD )) { + ret =0 ; +sprintf (dfustr,"mtd" ); +get_mtd_by_target (devstr, part->target, part->dev_id); + }break ; -#endif case STM32PROG_RAM : + ret =0 ;sprintf (dfustr,"ram" );sprintf (devstr,"0" );break ;default : +break ; + } +if (ret) {stm32prog_err ("invalid target: %d" , part->target); -return -ENODEV ; +return ret; }pr_debug ("dfu_alt_add(%s,%s,%s)\n" , dfustr, devstr, buf); ret =dfu_alt_add (dfu, dfustr, devstr, buf);@@ -1213,13 +1219,14 @@ int stm32prog_otp_write(struct stm32prog_data *data, u32 offset, u8 *buffer,int stm32prog_otp_read (struct stm32prog_data *data,u32 offset,u8 *buffer,long *size) { -#ifndef CONFIG_ARM_SMCCC -stm32prog_err ("OTP update not supported" ); - -return -1 ; -#else int result =0 ; +if (!IS_ENABLED (CONFIG_ARM_SMCCC )) { +stm32prog_err ("OTP update not supported" ); + +return -1 ; + } +pr_debug ("%s: %x %lx\n" , __func__, offset, *size);/* alway read for first packet */ if (!offset) {@@ -1255,19 +1262,19 @@ end_otp_read:pr_debug ("%s: result %i\n" , __func__, result);return result; -#endif }int stm32prog_otp_start (struct stm32prog_data *data) { -#ifndef CONFIG_ARM_SMCCC -stm32prog_err ("OTP update not supported" ); - -return -1 ; -#else int result =0 ;struct arm_smccc_res res; +if (!IS_ENABLED (CONFIG_ARM_SMCCC )) { +stm32prog_err ("OTP update not supported" ); + +return -1 ; + } +if (!data->otp_part) {stm32prog_err ("start OTP without data" );return -1 ;@@ -1302,7 +1309,6 @@ int stm32prog_otp_start(struct stm32prog_data *data)pr_debug ("%s: result %i\n" , __func__, result);return result; -#endif } int stm32prog_pmic_write(struct stm32prog_data *data, u32 offset, u8 *buffer,@@ -1538,19 +1544,20 @@ static int part_delete(struct stm32prog_data *data, struct stm32prog_part_t *part) {int ret =0 ; -#ifdef CONFIG_MMC unsigned long blks, blks_offset, blks_size;struct blk_desc *block_dev =NULL ; -#endif -#ifdef CONFIG_MTD char cmdbuf[40 ];char devstr[10 ]; -#endif printf ("Erasing %s " , part->name);switch (part->target) { -#ifdef CONFIG_MMC case STM32PROG_MMC : +if (!IS_ENABLED (CONFIG_MMC )) { + ret =-1 ; +stm32prog_err ("%s (0x%x): erase invalid" , + part->name, part->id); +break ; + }printf ("on mmc %d: " , part->dev->dev_id); block_dev =mmc_get_blk_desc (part->dev->mmc); blks_offset =lldiv (part->addr, part->dev->mmc->read_bl_len);@@ -1576,11 +1583,15 @@ static int part_delete(struct stm32prog_data *data, part->name, part->id); }break ; -#endif -#ifdef CONFIG_MTD case STM32PROG_NOR :case STM32PROG_NAND :case STM32PROG_SPI_NAND : +if (!IS_ENABLED (CONFIG_MTD )) { + ret =-1 ; +stm32prog_err ("%s (0x%x): erase invalid" , + part->name, part->id); +break ; + }get_mtd_by_target (devstr, part->target, part->dev->dev_id);printf ("on %s: " , devstr); sprintf(cmdbuf, "mtd erase %s 0x%llx 0x%llx",@@ -1591,7 +1602,6 @@ static int part_delete(struct stm32prog_data *data, part->name, part->id, cmdbuf); }break ; -#endif case STM32PROG_RAM :printf ("on ram: " );memset ((void *)(uintptr_t )part->addr,0 , (size_t )part->size);@@ -1639,9 +1649,11 @@ static void stm32prog_devices_init(struct stm32prog_data *data) goto error; } - ret =create_partitions (data);
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c static void stm32prog_devices_init(struct stm32prog_data *data) · line 1659
Quoted 10 lines
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +5
-2-if (ret) - goto error; +if (IS_ENABLED (CONFIG_MMC )) { + ret =create_gpt_partitions (data); +if (ret) + goto error; + }/* delete partition GPT or MTD */ for (i =0 ; i < data->part_nb; i++) {
Thanks
Patrice
PATCH 11/11 arm: stm32mp: stm32prog: use IS_ENABLED to prevent ifdef
Quoted 11 lines · Patrice CHOTARD
Hi Patrick
Quoted 8 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef in stm32prog command.Signed-off-by Patrick Delaunay <[email protected]>---
.../cmd_stm32prog/cmd_stm32prog.c | 5 +- .../mach-stm32mp/cmd_stm32prog/stm32prog.c | 100 ++++++++++-------- 2 files changed, 58 insertions(+), 47 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 296 lines
Quoted 277 lines
arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c +2
-3@@ -14,7 +14,6 @@ struct stm32prog_data *stm32prog_data;static void enable_vidconsole (void ) { -#ifdef CONFIG_DM_VIDEO char *stdname;char buf[64 ];@@ -35,7 +34,6 @@ static void enable_vidconsole(void)snprintf (buf,sizeof (buf),"%s,vidconsole" , stdname);env_set ("stderr" , buf); } -#endif } static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc,@@ -86,7 +84,8 @@ static int do_stm32prog(struct cmd_tbl *cmdtp, int flag, int argc, "script at 1"); } -enable_vidconsole (); +if (IS_ENABLED (CONFIG_DM_VIDEO )) +enable_vidconsole (); data = (struct stm32prog_data *)malloc (sizeof (*data));arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +51
-42@@ -544,10 +544,8 @@ static int init_device(struct stm32prog_data *data, {struct mmc *mmc =NULL ;struct blk_desc *block_dev =NULL ; -#ifdef CONFIG_MTD struct mtd_info *mtd =NULL ;char mtd_id[16 ]; -#endif int part_id;int ret;u64 first_addr =0 , last_addr =0 ;@@ -557,8 +555,11 @@ static int init_device(struct stm32prog_data *data,const char *part_name;switch (dev->target) { -#ifdef CONFIG_MMC case STM32PROG_MMC : +if (!IS_ENABLED (CONFIG_MMC )) { +stm32prog_err ("unknown device type = %d" , dev->target); +return -ENODEV ; + } mmc =find_mmc_device (dev->dev_id);if (!mmc ||mmc_init (mmc)) {stm32prog_err ("mmc device %d not found" , dev->dev_id);@@ -589,11 +590,13 @@ static int init_device(struct stm32prog_data *data, first_addr, last_addr);pr_debug (" full_update = %d\n" , dev->full_update);break ; -#endif -#ifdef CONFIG_MTD case STM32PROG_NOR :case STM32PROG_NAND :case STM32PROG_SPI_NAND : +if (!IS_ENABLED (CONFIG_MTD )) { +stm32prog_err ("unknown device type = %d" , dev->target); +return -ENODEV ; + }get_mtd_by_target (mtd_id, dev->target, dev->dev_id);pr_debug ("%s\n" , mtd_id);@@ -612,7 +615,6 @@ static int init_device(struct stm32prog_data *data, first_addr, last_addr); dev->mtd = mtd;break ; -#endif case STM32PROG_RAM : first_addr = gd->bd->bi_dram[0 ].start; last_addr = first_addr + gd->bd->bi_dram[0 ].size;@@ -744,8 +746,7 @@ static int init_device(struct stm32prog_data *data, part_found = true; } -#ifdef CONFIG_MTD -if (mtd) { +if (IS_ENABLED (CONFIG_MTD ) && mtd) {char mtd_part_id[32 ];struct part_info *mtd_part;struct mtd_device *mtd_dev;@@ -766,7 +767,7 @@ static int init_device(struct stm32prog_data *data, part_name = mtd_part->name; part_found = true; } -#endif +if (!part_found) {stm32prog_err ("%s (0x%x): Invalid partition" , part->name, part->id);@@ -873,9 +874,8 @@ static int treat_partition_list(struct stm32prog_data *data)return 0 ; } -static int create_partitions (struct stm32prog_data *data) +static int create_gpt_partitions (struct stm32prog_data *data) { -#ifdef CONFIG_MMC int offset =0 ;const int buflen =SZ_8K ;char *buf;@@ -991,7 +991,6 @@ static int create_partitions(struct stm32prog_data *data)run_command ("mtd list" ,0 );#endif free (buf); -#endif return 0 ; }@@ -1070,28 +1069,35 @@ static int stm32prog_alt_add(struct stm32prog_data *data, offset +=snprintf (buf + offset,ALT_BUF_LEN - offset," %d;" , part->part_id); } + ret = -ENODEV ;switch (part->target) { -#ifdef CONFIG_MMC case STM32PROG_MMC : -sprintf (dfustr,"mmc" ); -sprintf (devstr,"%d" , part->dev_id); +if (IS_ENABLED (CONFIG_MMC )) { + ret =0 ; +sprintf (dfustr,"mmc" ); +sprintf (devstr,"%d" , part->dev_id); + }break ; -#endif -#ifdef CONFIG_MTD case STM32PROG_NAND :case STM32PROG_NOR :case STM32PROG_SPI_NAND : -sprintf (dfustr,"mtd" ); -get_mtd_by_target (devstr, part->target, part->dev_id); +if (IS_ENABLED (CONFIG_MTD )) { + ret =0 ; +sprintf (dfustr,"mtd" ); +get_mtd_by_target (devstr, part->target, part->dev_id); + }break ; -#endif case STM32PROG_RAM : + ret =0 ;sprintf (dfustr,"ram" );sprintf (devstr,"0" );break ;default : +break ; + } +if (ret) {stm32prog_err ("invalid target: %d" , part->target); -return -ENODEV ; +return ret; }pr_debug ("dfu_alt_add(%s,%s,%s)\n" , dfustr, devstr, buf); ret =dfu_alt_add (dfu, dfustr, devstr, buf);@@ -1213,13 +1219,14 @@ int stm32prog_otp_write(struct stm32prog_data *data, u32 offset, u8 *buffer,int stm32prog_otp_read (struct stm32prog_data *data,u32 offset,u8 *buffer,long *size) { -#ifndef CONFIG_ARM_SMCCC -stm32prog_err ("OTP update not supported" ); - -return -1 ; -#else int result =0 ; +if (!IS_ENABLED (CONFIG_ARM_SMCCC )) { +stm32prog_err ("OTP update not supported" ); + +return -1 ; + } +pr_debug ("%s: %x %lx\n" , __func__, offset, *size);/* alway read for first packet */ if (!offset) {@@ -1255,19 +1262,19 @@ end_otp_read:pr_debug ("%s: result %i\n" , __func__, result);return result; -#endif }int stm32prog_otp_start (struct stm32prog_data *data) { -#ifndef CONFIG_ARM_SMCCC -stm32prog_err ("OTP update not supported" ); - -return -1 ; -#else int result =0 ;struct arm_smccc_res res; +if (!IS_ENABLED (CONFIG_ARM_SMCCC )) { +stm32prog_err ("OTP update not supported" ); + +return -1 ; + } +if (!data->otp_part) {stm32prog_err ("start OTP without data" );return -1 ;@@ -1302,7 +1309,6 @@ int stm32prog_otp_start(struct stm32prog_data *data)pr_debug ("%s: result %i\n" , __func__, result);return result; -#endif } int stm32prog_pmic_write(struct stm32prog_data *data, u32 offset, u8 *buffer,@@ -1538,19 +1544,20 @@ static int part_delete(struct stm32prog_data *data, struct stm32prog_part_t *part) {int ret =0 ; -#ifdef CONFIG_MMC unsigned long blks, blks_offset, blks_size;struct blk_desc *block_dev =NULL ; -#endif -#ifdef CONFIG_MTD char cmdbuf[40 ];char devstr[10 ]; -#endif printf ("Erasing %s " , part->name);switch (part->target) { -#ifdef CONFIG_MMC case STM32PROG_MMC : +if (!IS_ENABLED (CONFIG_MMC )) { + ret =-1 ; +stm32prog_err ("%s (0x%x): erase invalid" , + part->name, part->id); +break ; + }printf ("on mmc %d: " , part->dev->dev_id); block_dev =mmc_get_blk_desc (part->dev->mmc); blks_offset =lldiv (part->addr, part->dev->mmc->read_bl_len);@@ -1576,11 +1583,15 @@ static int part_delete(struct stm32prog_data *data, part->name, part->id); }break ; -#endif -#ifdef CONFIG_MTD case STM32PROG_NOR :case STM32PROG_NAND :case STM32PROG_SPI_NAND : +if (!IS_ENABLED (CONFIG_MTD )) { + ret =-1 ; +stm32prog_err ("%s (0x%x): erase invalid" , + part->name, part->id); +break ; + }get_mtd_by_target (devstr, part->target, part->dev->dev_id);printf ("on %s: " , devstr); sprintf(cmdbuf, "mtd erase %s 0x%llx 0x%llx",@@ -1591,7 +1602,6 @@ static int part_delete(struct stm32prog_data *data, part->name, part->id, cmdbuf); }break ; -#endif case STM32PROG_RAM :printf ("on ram: " );memset ((void *)(uintptr_t )part->addr,0 , (size_t )part->size);@@ -1639,9 +1649,11 @@ static void stm32prog_devices_init(struct stm32prog_data *data) goto error; } - ret =create_partitions (data);arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c static void stm32prog_devices_init(struct stm32prog_data *data) · line 1659
Quoted 10 lines
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c +5
-2-if (ret) - goto error; +if (IS_ENABLED (CONFIG_MMC )) { + ret =create_gpt_partitions (data); +if (ret) + goto error; + }/* delete partition GPT or MTD */ for (i =0 ; i < data->part_nb; i++) {Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
PATCH 1/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check
In reply to Patrick DelaunayHi Patrick
Quoted 80 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inboard_key_checkSigned-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 52 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-)board/st/stm32mp1/stm32mp1.c +26
-25@@ -135,51 +135,51 @@ int checkboard(void)static void board_key_check (void ) { -#if defined(CONFIG_FASTBOOT ) || defined(CONFIG_CMD_STM32PROG )ofnode node;struct gpio_desc gpio;enum forced_boot_mode boot_mode =BOOT_NORMAL ; +if (!IS_ENABLED (CONFIG_FASTBOOT ) && !IS_ENABLED (CONFIG_CMD_STM32PROG )) +return ; + node =ofnode_path ("/config" );if (!ofnode_valid (node)) {debug ("%s: no /config node?\n" , __func__);return ; } -#ifdef CONFIG_FASTBOOT -if (gpio_request_by_name_nodev (node,"st,fastboot-gpios" ,0 , - &gpio,GPIOD_IS_IN )) { -debug ("%s: could not find a /config/st,fastboot-gpios\n" , - __func__); - }else { -if (dm_gpio_get_value (&gpio)) { -puts ("Fastboot key pressed, " ); - boot_mode =BOOT_FASTBOOT ; - } +if (IS_ENABLED (CONFIG_FASTBOOT )) { +if (gpio_request_by_name_nodev (node,"st,fastboot-gpios" ,0 , + &gpio,GPIOD_IS_IN )) { +debug ("%s: could not find a /config/st,fastboot-gpios\n" , + __func__); + }else { +if (dm_gpio_get_value (&gpio)) { +puts ("Fastboot key pressed, " ); + boot_mode =BOOT_FASTBOOT ; + } -dm_gpio_free (NULL , &gpio); +dm_gpio_free (NULL , &gpio); + } } -#endif -#ifdef CONFIG_CMD_STM32PROG -if (gpio_request_by_name_nodev (node,"st,stm32prog-gpios" ,0 , - &gpio,GPIOD_IS_IN )) { -debug ("%s: could not find a /config/st,stm32prog-gpios\n" , - __func__); - }else { -if (dm_gpio_get_value (&gpio)) { -puts ("STM32Programmer key pressed, " ); - boot_mode =BOOT_STM32PROG ; +if (IS_ENABLED (CONFIG_CMD_STM32PROG )) { +if (gpio_request_by_name_nodev (node,"st,stm32prog-gpios" ,0 , + &gpio,GPIOD_IS_IN )) { +debug ("%s: could not find a /config/st,stm32prog-gpios\n" , + __func__); + }else { +if (dm_gpio_get_value (&gpio)) { +puts ("STM32Programmer key pressed, " ); + boot_mode =BOOT_STM32PROG ; + } +dm_gpio_free (NULL , &gpio); } -dm_gpio_free (NULL , &gpio); } -#endif -
board/st/stm32mp1/stm32mp1.c int checkboard(void) · line 185
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-1if (boot_mode !=BOOT_NORMAL ) {puts ("entering download mode...\n" );clrsetbits_le32 (TAMP_BOOT_CONTEXT ,TAMP_BOOT_FORCED_MASK , boot_mode); } -#endif }#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG )
Thanks
Patrice
PATCH 1/11 board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check
Quoted 10 lines · Patrice CHOTARD
Hi Patrick
Quoted 7 lines · Patrick Delaunay
Use
IS_ENABLEDto prevent ifdef inboard_key_checkSigned-off-by Patrick Delaunay <[email protected]>---
board/st/stm32mp1/stm32mp1.c | 52 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-)
Applied on u-boot-stm/master
Thanks
Quoted 92 lines
Quoted 73 lines
board/st/stm32mp1/stm32mp1.c +26
-25@@ -135,51 +135,51 @@ int checkboard(void)static void board_key_check (void ) { -#if defined(CONFIG_FASTBOOT ) || defined(CONFIG_CMD_STM32PROG )ofnode node;struct gpio_desc gpio;enum forced_boot_mode boot_mode =BOOT_NORMAL ; +if (!IS_ENABLED (CONFIG_FASTBOOT ) && !IS_ENABLED (CONFIG_CMD_STM32PROG )) +return ; + node =ofnode_path ("/config" );if (!ofnode_valid (node)) {debug ("%s: no /config node?\n" , __func__);return ; } -#ifdef CONFIG_FASTBOOT -if (gpio_request_by_name_nodev (node,"st,fastboot-gpios" ,0 , - &gpio,GPIOD_IS_IN )) { -debug ("%s: could not find a /config/st,fastboot-gpios\n" , - __func__); - }else { -if (dm_gpio_get_value (&gpio)) { -puts ("Fastboot key pressed, " ); - boot_mode =BOOT_FASTBOOT ; - } +if (IS_ENABLED (CONFIG_FASTBOOT )) { +if (gpio_request_by_name_nodev (node,"st,fastboot-gpios" ,0 , + &gpio,GPIOD_IS_IN )) { +debug ("%s: could not find a /config/st,fastboot-gpios\n" , + __func__); + }else { +if (dm_gpio_get_value (&gpio)) { +puts ("Fastboot key pressed, " ); + boot_mode =BOOT_FASTBOOT ; + } -dm_gpio_free (NULL , &gpio); +dm_gpio_free (NULL , &gpio); + } } -#endif -#ifdef CONFIG_CMD_STM32PROG -if (gpio_request_by_name_nodev (node,"st,stm32prog-gpios" ,0 , - &gpio,GPIOD_IS_IN )) { -debug ("%s: could not find a /config/st,stm32prog-gpios\n" , - __func__); - }else { -if (dm_gpio_get_value (&gpio)) { -puts ("STM32Programmer key pressed, " ); - boot_mode =BOOT_STM32PROG ; +if (IS_ENABLED (CONFIG_CMD_STM32PROG )) { +if (gpio_request_by_name_nodev (node,"st,stm32prog-gpios" ,0 , + &gpio,GPIOD_IS_IN )) { +debug ("%s: could not find a /config/st,stm32prog-gpios\n" , + __func__); + }else { +if (dm_gpio_get_value (&gpio)) { +puts ("STM32Programmer key pressed, " ); + boot_mode =BOOT_STM32PROG ; + } +dm_gpio_free (NULL , &gpio); } -dm_gpio_free (NULL , &gpio); } -#endif -board/st/stm32mp1/stm32mp1.c int checkboard(void) · line 185
Quoted 10 lines
board/st/stm32mp1/stm32mp1.c +0
-1if (boot_mode !=BOOT_NORMAL ) {puts ("entering download mode...\n" );clrsetbits_le32 (TAMP_BOOT_CONTEXT ,TAMP_BOOT_FORCED_MASK , boot_mode); } -#endif }#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG )Reviewed-by Patrice Chotard <[email protected]>Thanks
Patrice
_______________________________________________
Uboot-stm32 mailing list
Uboot-stm32 at st-md-mailman.stormreply.com
https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32