* [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check
@ 2020-07-31 14:31 Patrick Delaunay
2020-07-31 14:31 ` [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected Patrick Delaunay
` (10 more replies)
0 siblings, 11 replies; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in board_key_check
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 52 ++++++++++++++++++------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 1d274c3157..1ad41796fb 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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)
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:22 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power Patrick Delaunay
` (9 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
and in g_dnl_bind_fixup
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 1ad41796fb..5c84b09c3e 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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 0x0afb
int 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)
{
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
2020-07-31 14:31 ` [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:22 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 7:22 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 04/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init Patrick Delaunay
` (8 subsequent siblings)
10 siblings, 2 replies; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in board_check_usb_power.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 5c84b09c3e..3182f44598 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 04/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
2020-07-31 14:31 ` [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected Patrick Delaunay
2020-07-31 14:31 ` [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 05/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf Patrick Delaunay
` (7 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in sysconf_init.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 3182f44598..a0a2f9978f 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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();
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 05/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (2 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 04/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 06/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix Patrick Delaunay
` (6 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use CONFIG_IS_ENABLED to prevent ifdef in set_dfu_alt_inf.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/common/stm32mp_dfu.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
index 0cda9196f9..2fb307efe4 100644
--- a/board/st/common/stm32mp_dfu.c
+++ b/board/st/common/stm32mp_dfu.c
@@ -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");
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 06/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (3 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 05/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 07/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init Patrick Delaunay
` (5 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in dk2_i2c1_fix.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index a0a2f9978f..985233f2b3 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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();
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 07/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (4 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 06/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 08/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions Patrick Delaunay
` (4 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in board_late_init.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 60 ++++++++++++++++++------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 985233f2b3..a9705baa24 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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();
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 08/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (5 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 07/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 09/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup Patrick Delaunay
` (3 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in env functions:
- env_get_location
- env_ext4_get_intf
- mmc_get_env_dev
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index a9705baa24..08d18b6da8 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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)
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 09/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (6 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 08/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 10/11] arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef Patrick Delaunay
` (2 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in ft_board_setup.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
board/st/stm32mp1/stm32mp1.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 08d18b6da8..4d26738a24 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 10/11] arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (7 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 09/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:24 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 11/11] arm: stm32mp: stm32prog: " Patrick Delaunay
2020-08-13 7:51 ` [Uboot-stm32] [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrice CHOTARD
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in bsec driver.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
arch/arm/mach-stm32mp/bsec.c | 86 +++++++++++++++++++-----------------
1 file changed, 46 insertions(+), 40 deletions(-)
diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
index 0c56b440f5..a9b9bd0902 100644
--- a/arch/arm/mach-stm32mp/bsec.c
+++ b/arch/arm/mach-stm32mp/bsec.c
@@ -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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH 11/11] arm: stm32mp: stm32prog: use IS_ENABLED to prevent ifdef
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (8 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 10/11] arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef Patrick Delaunay
@ 2020-07-31 14:31 ` Patrick Delaunay
2020-08-13 7:25 ` Patrice CHOTARD
2020-08-13 7:51 ` [Uboot-stm32] [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrice CHOTARD
10 siblings, 1 reply; 34+ messages in thread
From: Patrick Delaunay @ 2020-07-31 14:31 UTC (permalink / raw)
To: u-boot
Use IS_ENABLED to prevent ifdef in stm32prog command.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
.../cmd_stm32prog/cmd_stm32prog.c | 5 +-
.../mach-stm32mp/cmd_stm32prog/stm32prog.c | 100 ++++++++++--------
2 files changed, 58 insertions(+), 47 deletions(-)
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
index cbf0120adc..49dd25b28f 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
@@ -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));
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index e4199dbaa5..ec3355d816 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -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);
- 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++) {
--
2.17.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
2020-07-31 14:31 ` [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected Patrick Delaunay
@ 2020-08-13 7:22 ` Patrice CHOTARD
2020-08-13 9:49 ` Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:22 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
> and in g_dnl_bind_fixup
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 1ad41796fb..5c84b09c3e 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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 0x0afb
>
> int 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)
> {
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
2020-07-31 14:31 ` [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power Patrick Delaunay
@ 2020-08-13 7:22 ` Patrice CHOTARD
2020-08-13 7:22 ` Patrice CHOTARD
1 sibling, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:22 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in board_check_usb_power.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 5c84b09c3e..3182f44598 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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;
> }
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
2020-07-31 14:31 ` [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power Patrick Delaunay
2020-08-13 7:22 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 7:22 ` Patrice CHOTARD
2020-08-13 9:49 ` Patrice CHOTARD
1 sibling, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:22 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in board_check_usb_power.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 5c84b09c3e..3182f44598 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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;
> }
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 04/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init
2020-07-31 14:31 ` [PATCH 04/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init Patrick Delaunay
@ 2020-08-13 7:23 ` Patrice CHOTARD
2020-08-13 9:50 ` Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:23 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in sysconf_init.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 3182f44598..a0a2f9978f 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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();
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 05/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf
2020-07-31 14:31 ` [PATCH 05/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf Patrick Delaunay
@ 2020-08-13 7:23 ` Patrice CHOTARD
2020-08-13 9:51 ` Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:23 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use CONFIG_IS_ENABLED to prevent ifdef in set_dfu_alt_inf.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/common/stm32mp_dfu.c | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
> index 0cda9196f9..2fb307efe4 100644
> --- a/board/st/common/stm32mp_dfu.c
> +++ b/board/st/common/stm32mp_dfu.c
> @@ -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");
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 06/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix
2020-07-31 14:31 ` [PATCH 06/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix Patrick Delaunay
@ 2020-08-13 7:23 ` Patrice CHOTARD
2020-08-13 9:51 ` Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:23 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in dk2_i2c1_fix.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index a0a2f9978f..985233f2b3 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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();
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 07/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init
2020-07-31 14:31 ` [PATCH 07/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init Patrick Delaunay
@ 2020-08-13 7:24 ` Patrice CHOTARD
2020-08-13 9:52 ` Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:24 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in board_late_init.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 60 ++++++++++++++++++------------------
> 1 file changed, 30 insertions(+), 30 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 985233f2b3..a9705baa24 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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();
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 08/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions
2020-07-31 14:31 ` [PATCH 08/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions Patrick Delaunay
@ 2020-08-13 7:24 ` Patrice CHOTARD
2020-08-13 9:53 ` Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:24 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in env functions:
> - env_get_location
> - env_ext4_get_intf
> - mmc_get_env_dev
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 36 +++++++++++++++++-------------------
> 1 file changed, 17 insertions(+), 19 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index a9705baa24..08d18b6da8 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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)
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 09/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup
2020-07-31 14:31 ` [PATCH 09/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup Patrick Delaunay
@ 2020-08-13 7:24 ` Patrice CHOTARD
2020-08-13 9:53 ` Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:24 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in ft_board_setup.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 08d18b6da8..4d26738a24 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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;
> }
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH 10/11] arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef
2020-07-31 14:31 ` [PATCH 10/11] arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef Patrick Delaunay
@ 2020-08-13 7:24 ` Patrice CHOTARD
2020-08-13 9:54 ` [Uboot-stm32] " Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:24 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in bsec driver.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> arch/arm/mach-stm32mp/bsec.c | 86 +++++++++++++++++++-----------------
> 1 file changed, 46 insertions(+), 40 deletions(-)
>
> diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
> index 0c56b440f5..a9b9bd0902 100644
> --- a/arch/arm/mach-stm32mp/bsec.c
> +++ b/arch/arm/mach-stm32mp/bsec.c
> @@ -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;
> }
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH 11/11] arm: stm32mp: stm32prog: use IS_ENABLED to prevent ifdef
2020-07-31 14:31 ` [PATCH 11/11] arm: stm32mp: stm32prog: " Patrick Delaunay
@ 2020-08-13 7:25 ` Patrice CHOTARD
2020-08-13 9:55 ` [Uboot-stm32] " Patrice CHOTARD
0 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:25 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in stm32prog command.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> .../cmd_stm32prog/cmd_stm32prog.c | 5 +-
> .../mach-stm32mp/cmd_stm32prog/stm32prog.c | 100 ++++++++++--------
> 2 files changed, 58 insertions(+), 47 deletions(-)
>
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
> index cbf0120adc..49dd25b28f 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
> @@ -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));
>
> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> index e4199dbaa5..ec3355d816 100644
> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
> @@ -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);
> - 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 <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
` (9 preceding siblings ...)
2020-07-31 14:31 ` [PATCH 11/11] arm: stm32mp: stm32prog: " Patrick Delaunay
@ 2020-08-13 7:51 ` Patrice CHOTARD
2020-08-13 9:49 ` Patrice CHOTARD
10 siblings, 1 reply; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 7:51 UTC (permalink / raw)
To: u-boot
Hi Patrick
On 7/31/20 4:31 PM, Patrick Delaunay wrote:
> Use IS_ENABLED to prevent ifdef in board_key_check
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
>
> board/st/stm32mp1/stm32mp1.c | 52 ++++++++++++++++++------------------
> 1 file changed, 26 insertions(+), 26 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index 1d274c3157..1ad41796fb 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -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)
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Thanks
Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check
2020-08-13 7:51 ` [Uboot-stm32] [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrice CHOTARD
@ 2020-08-13 9:49 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:49 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:51 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in board_key_check
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 52 ++++++++++++++++++------------------
>> 1 file changed, 26 insertions(+), 26 deletions(-)
Applied on u-boot-stm/master
Thanks
>>
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 1d274c3157..1ad41796fb 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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)
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
2020-08-13 7:22 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 9:49 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:49 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:22 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected
>> and in g_dnl_bind_fixup
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 15 +++++++++------
>> 1 file changed, 9 insertions(+), 6 deletions(-)
Applied on u-boot-stm/master
Thanks
>>
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 1ad41796fb..5c84b09c3e 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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 0x0afb
>>
>> int 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)
>> {
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power
2020-08-13 7:22 ` Patrice CHOTARD
@ 2020-08-13 9:49 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:49 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:22 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in board_check_usb_power.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
Applied on u-boot-stm/master
Thanks
>>
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 5c84b09c3e..3182f44598 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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;
>> }
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 04/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 9:50 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:50 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:23 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in sysconf_init.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 11 +++--------
>> 1 file changed, 3 insertions(+), 8 deletions(-)
Applied on u-boot-stm/master
Thanks
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 3182f44598..a0a2f9978f 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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();
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 05/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 9:51 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:51 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:23 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use CONFIG_IS_ENABLED to prevent ifdef in set_dfu_alt_inf.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/common/stm32mp_dfu.c | 20 +++++++++++---------
>> 1 file changed, 11 insertions(+), 9 deletions(-)
Applied on u-boot-stm/master
Thanks
>>
>> diff --git a/board/st/common/stm32mp_dfu.c b/board/st/common/stm32mp_dfu.c
>> index 0cda9196f9..2fb307efe4 100644
>> --- a/board/st/common/stm32mp_dfu.c
>> +++ b/board/st/common/stm32mp_dfu.c
>> @@ -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");
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 06/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 9:51 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:51 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:23 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in dk2_i2c1_fix.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
Applied on u-boot-stm/master
Thanks
>>
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index a0a2f9978f..985233f2b3 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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();
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 07/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 9:52 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:52 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:24 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in board_late_init.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 60 ++++++++++++++++++------------------
>> 1 file changed, 30 insertions(+), 30 deletions(-)
Applied on u-boot-stm/master
Thanks
>>
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 985233f2b3..a9705baa24 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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();
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 08/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 9:53 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:53 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:24 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in env functions:
>> - env_get_location
>> - env_ext4_get_intf
>> - mmc_get_env_dev
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 36 +++++++++++++++++-------------------
>> 1 file changed, 17 insertions(+), 19 deletions(-)
Applied on u-boot-stm/master
Thanks
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index a9705baa24..08d18b6da8 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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)
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 09/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
@ 2020-08-13 9:53 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:53 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:24 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in ft_board_setup.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> board/st/stm32mp1/stm32mp1.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
Applied on u-boot-stm/master
Thanks
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index 08d18b6da8..4d26738a24 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -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;
>> }
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 10/11] arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef
2020-08-13 7:24 ` Patrice CHOTARD
@ 2020-08-13 9:54 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:54 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:24 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in bsec driver.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> arch/arm/mach-stm32mp/bsec.c | 86 +++++++++++++++++++-----------------
>> 1 file changed, 46 insertions(+), 40 deletions(-)
Applied on u-boot-stm/master
Thanks
>>
>> diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
>> index 0c56b440f5..a9b9bd0902 100644
>> --- a/arch/arm/mach-stm32mp/bsec.c
>> +++ b/arch/arm/mach-stm32mp/bsec.c
>> @@ -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;
>> }
> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Uboot-stm32] [PATCH 11/11] arm: stm32mp: stm32prog: use IS_ENABLED to prevent ifdef
2020-08-13 7:25 ` Patrice CHOTARD
@ 2020-08-13 9:55 ` Patrice CHOTARD
0 siblings, 0 replies; 34+ messages in thread
From: Patrice CHOTARD @ 2020-08-13 9:55 UTC (permalink / raw)
To: u-boot
On 8/13/20 9:25 AM, Patrice CHOTARD wrote:
> Hi Patrick
>
> On 7/31/20 4:31 PM, Patrick Delaunay wrote:
>> Use IS_ENABLED to prevent ifdef in stm32prog command.
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
>> ---
>>
>> .../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
>>
>> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
>> index cbf0120adc..49dd25b28f 100644
>> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
>> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
>> @@ -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));
>>
>> diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> index e4199dbaa5..ec3355d816 100644
>> --- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> +++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
>> @@ -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);
>> - 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 <patrice.chotard@st.com>
>
> Thanks
>
> Patrice
> _______________________________________________
> Uboot-stm32 mailing list
> Uboot-stm32 at st-md-mailman.stormreply.com
> https://st-md-mailman.stormreply.com/mailman/listinfo/uboot-stm32
^ permalink raw reply [flat|nested] 34+ messages in thread
end of thread, other threads:[~2020-08-13 9:55 UTC | newest]
Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31 14:31 [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrick Delaunay
2020-07-31 14:31 ` [PATCH 02/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in g_dnl_board_usb_cable_connected Patrick Delaunay
2020-08-13 7:22 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 9:49 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 03/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_check_usb_power Patrick Delaunay
2020-08-13 7:22 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 7:22 ` Patrice CHOTARD
2020-08-13 9:49 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 04/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in sysconf_init Patrick Delaunay
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 9:50 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 05/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in set_dfu_alt_inf Patrick Delaunay
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 9:51 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 06/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in dk2_i2c1_fix Patrick Delaunay
2020-08-13 7:23 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 9:51 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 07/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init Patrick Delaunay
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 9:52 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 08/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in env functions Patrick Delaunay
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 9:53 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 09/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in ft_board_setup Patrick Delaunay
2020-08-13 7:24 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 9:53 ` Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 10/11] arm: stm32mp: bsec: use IS_ENABLED to prevent ifdef Patrick Delaunay
2020-08-13 7:24 ` Patrice CHOTARD
2020-08-13 9:54 ` [Uboot-stm32] " Patrice CHOTARD
2020-07-31 14:31 ` [PATCH 11/11] arm: stm32mp: stm32prog: " Patrick Delaunay
2020-08-13 7:25 ` Patrice CHOTARD
2020-08-13 9:55 ` [Uboot-stm32] " Patrice CHOTARD
2020-08-13 7:51 ` [Uboot-stm32] [PATCH 01/11] board: stm32mp1: use IS_ENABLED to prevent ifdef in board_key_check Patrice CHOTARD
2020-08-13 9:49 ` Patrice CHOTARD
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.