diff mbox series

[U-Boot,RFC,2/2] arm64: zynqmp: Try to create bootcm_mmcX at run time

Message ID 8a301ac42ef1dc24fd5ee67759365593e6324548.1524659886.git.michal.simek@xilinx.com
State RFC
Delegated to: Michal Simek
Headers show
Series [U-Boot,RFC,1/2] arm64: zynqmp: Setup the first boot_target at run time | expand

Commit Message

Michal Simek April 25, 2018, 12:38 p.m. UTC
Just an attept to create boot commands for mmcs above 2 which is not
generated.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Probably some ifdefs around are missing.
---
 board/xilinx/zynqmp/zynqmp.c    | 28 ++++++++++++++++++++++++++++
 include/configs/xilinx_zynqmp.h |  7 -------
 2 files changed, 28 insertions(+), 7 deletions(-)

Comments

Alexander Graf April 26, 2018, 6:23 a.m. UTC | #1
On 25.04.18 14:38, Michal Simek wrote:
> Just an attept to create boot commands for mmcs above 2 which is not
> generated.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Probably some ifdefs around are missing.
> ---
>  board/xilinx/zynqmp/zynqmp.c    | 28 ++++++++++++++++++++++++++++
>  include/configs/xilinx_zynqmp.h |  7 -------
>  2 files changed, 28 insertions(+), 7 deletions(-)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index 96ea0f578d30..37fa8f4f4d3f 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -451,6 +451,32 @@ void reset_cpu(ulong addr)
>  {
>  }
>  
> +static int create_mmc_boot_commands(void)
> +{
> +/* Size of strings below + one terminating char \0 + 3 possitions for seq */
> +#define MAX_COMMAND_LEN	15
> +#define MAX_BODY_LEN	32
> +
> +	int ret;
> +	struct uclass *uc;
> +	struct udevice *dev;
> +	char body[MAX_BODY_LEN];
> +	char command[MAX_COMMAND_LEN];
> +
> +	ret = uclass_get(UCLASS_MMC, &uc);
> +	if (ret)
> +		return ret;
> +
> +	uclass_foreach_dev(dev, uc) {
> +		snprintf(body, MAX_BODY_LEN, "setenv devnum %x; run mmc_boot",
> +			 dev->seq);
> +		snprintf(command, MAX_COMMAND_LEN, "bootcmd_mmc%x", dev->seq);
> +		env_set(command, body);
> +	}

Why not just remove the ones you don't need? You could leave the
template in and just remove bootcmd_mmc0 if you don't see an mmc0 device.


Alex

> +
> +	return 0;
> +}
> +
>  int board_late_init(void)
>  {
>  	u32 reg = 0;
> @@ -546,6 +572,8 @@ int board_late_init(void)
>  		debug("Bootseq len: %x\n", bootseq_len);
>  	}
>  
> +	create_mmc_boot_commands();
> +
>  	/*
>  	 * One terminating char + one byte for space between mode
>  	 * and default boot_targets
> diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h
> index c8a0dbb7e3b5..a2590998429e 100644
> --- a/include/configs/xilinx_zynqmp.h
> +++ b/include/configs/xilinx_zynqmp.h
> @@ -155,12 +155,6 @@
>  	"scriptaddr=0x02000000\0" \
>  	"ramdisk_addr_r=0x02100000\0" \
>  
> -#if defined(CONFIG_MMC_SDHCI_ZYNQ)
> -# define BOOT_TARGET_DEVICES_MMC(func)	func(MMC, mmc, 0) func(MMC, mmc, 1)
> -#else
> -# define BOOT_TARGET_DEVICES_MMC(func)
> -#endif
> -
>  #if defined(CONFIG_SATA_CEVA)
>  # define BOOT_TARGET_DEVICES_SCSI(func)	func(SCSI, scsi, 0)
>  #else
> @@ -186,7 +180,6 @@
>  #endif
>  
>  #define BOOT_TARGET_DEVICES(func) \
> -	BOOT_TARGET_DEVICES_MMC(func) \
>  	BOOT_TARGET_DEVICES_USB(func) \
>  	BOOT_TARGET_DEVICES_SCSI(func) \
>  	BOOT_TARGET_DEVICES_PXE(func) \
>
Michal Simek April 26, 2018, 6:27 a.m. UTC | #2
On 26.4.2018 08:23, Alexander Graf wrote:
> 
> 
> On 25.04.18 14:38, Michal Simek wrote:
>> Just an attept to create boot commands for mmcs above 2 which is not
>> generated.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> Probably some ifdefs around are missing.
>> ---
>>  board/xilinx/zynqmp/zynqmp.c    | 28 ++++++++++++++++++++++++++++
>>  include/configs/xilinx_zynqmp.h |  7 -------
>>  2 files changed, 28 insertions(+), 7 deletions(-)
>>
>> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
>> index 96ea0f578d30..37fa8f4f4d3f 100644
>> --- a/board/xilinx/zynqmp/zynqmp.c
>> +++ b/board/xilinx/zynqmp/zynqmp.c
>> @@ -451,6 +451,32 @@ void reset_cpu(ulong addr)
>>  {
>>  }
>>  
>> +static int create_mmc_boot_commands(void)
>> +{
>> +/* Size of strings below + one terminating char \0 + 3 possitions for seq */
>> +#define MAX_COMMAND_LEN	15
>> +#define MAX_BODY_LEN	32
>> +
>> +	int ret;
>> +	struct uclass *uc;
>> +	struct udevice *dev;
>> +	char body[MAX_BODY_LEN];
>> +	char command[MAX_COMMAND_LEN];
>> +
>> +	ret = uclass_get(UCLASS_MMC, &uc);
>> +	if (ret)
>> +		return ret;
>> +
>> +	uclass_foreach_dev(dev, uc) {
>> +		snprintf(body, MAX_BODY_LEN, "setenv devnum %x; run mmc_boot",
>> +			 dev->seq);
>> +		snprintf(command, MAX_COMMAND_LEN, "bootcmd_mmc%x", dev->seq);
>> +		env_set(command, body);
>> +	}
> 
> Why not just remove the ones you don't need? You could leave the
> template in and just remove bootcmd_mmc0 if you don't see an mmc0 device.

It is not a problem if that alias is mmc0 or mmc1 but if that alias is
mmc3 because none is generating that distro default boot command line.
Look at my reply on 1/2

M
diff mbox series

Patch

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 96ea0f578d30..37fa8f4f4d3f 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -451,6 +451,32 @@  void reset_cpu(ulong addr)
 {
 }
 
+static int create_mmc_boot_commands(void)
+{
+/* Size of strings below + one terminating char \0 + 3 possitions for seq */
+#define MAX_COMMAND_LEN	15
+#define MAX_BODY_LEN	32
+
+	int ret;
+	struct uclass *uc;
+	struct udevice *dev;
+	char body[MAX_BODY_LEN];
+	char command[MAX_COMMAND_LEN];
+
+	ret = uclass_get(UCLASS_MMC, &uc);
+	if (ret)
+		return ret;
+
+	uclass_foreach_dev(dev, uc) {
+		snprintf(body, MAX_BODY_LEN, "setenv devnum %x; run mmc_boot",
+			 dev->seq);
+		snprintf(command, MAX_COMMAND_LEN, "bootcmd_mmc%x", dev->seq);
+		env_set(command, body);
+	}
+
+	return 0;
+}
+
 int board_late_init(void)
 {
 	u32 reg = 0;
@@ -546,6 +572,8 @@  int board_late_init(void)
 		debug("Bootseq len: %x\n", bootseq_len);
 	}
 
+	create_mmc_boot_commands();
+
 	/*
 	 * One terminating char + one byte for space between mode
 	 * and default boot_targets
diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h
index c8a0dbb7e3b5..a2590998429e 100644
--- a/include/configs/xilinx_zynqmp.h
+++ b/include/configs/xilinx_zynqmp.h
@@ -155,12 +155,6 @@ 
 	"scriptaddr=0x02000000\0" \
 	"ramdisk_addr_r=0x02100000\0" \
 
-#if defined(CONFIG_MMC_SDHCI_ZYNQ)
-# define BOOT_TARGET_DEVICES_MMC(func)	func(MMC, mmc, 0) func(MMC, mmc, 1)
-#else
-# define BOOT_TARGET_DEVICES_MMC(func)
-#endif
-
 #if defined(CONFIG_SATA_CEVA)
 # define BOOT_TARGET_DEVICES_SCSI(func)	func(SCSI, scsi, 0)
 #else
@@ -186,7 +180,6 @@ 
 #endif
 
 #define BOOT_TARGET_DEVICES(func) \
-	BOOT_TARGET_DEVICES_MMC(func) \
 	BOOT_TARGET_DEVICES_USB(func) \
 	BOOT_TARGET_DEVICES_SCSI(func) \
 	BOOT_TARGET_DEVICES_PXE(func) \