[U-Boot] [PATCH 1/1] imx-common: cpu: add fdt_file environment variable

Eric Nelson eric.nelson at boundarydevices.com
Sun Mar 30 00:11:33 CET 2014


Hi Troy,

On 03/29/2014 03:34 PM, Troy Kisky wrote:
> This removes one block in the move toward 1 u-boot
> for both a mx6q (quad) and mx6dl (duallite) processor.
>
> Now fdt_file hardcoded value can be removed.
>
> Signed-off-by: Troy Kisky <troy.kisky at boundarydevices.com>
> ---
>   arch/arm/imx-common/cpu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>   arch/arm/lib/board.c      |  7 +++++++
>   2 files changed, 51 insertions(+)
>
> diff --git a/arch/arm/imx-common/cpu.c b/arch/arm/imx-common/cpu.c
> index a77c4de..5d48011 100644
> --- a/arch/arm/imx-common/cpu.c
> +++ b/arch/arm/imx-common/cpu.c
> @@ -180,3 +180,47 @@ void arch_preboot_os(void)
>   	ipuv3_fb_shutdown();
>   }
>   #endif
> +
> +const char *get_dtb_prefix(u32 imxtype)
> +{
> +	switch (imxtype) {
> +	case MXC_CPU_MX6Q:
> +	case MXC_CPU_MX6D:
> +		return "imx6q";		/* Quad/Dual-core version of the mx6 */
> +	case MXC_CPU_MX6DL:
> +	case MXC_CPU_MX6SOLO:
> +		return "imx6dl";	/* Dual Lite/Solo version of the mx6 */
> +	case MXC_CPU_MX6SL:
> +		return "imx6sl";	/* Solo-Lite version of the mx6 */
> +	case MXC_CPU_MX51:
> +		return "imx51";
> +	case MXC_CPU_MX53:
> +		return "imx53";
> +	}
> +	return "??";
> +}
> +

I really dislike this implementation of naming policy in code.

> +int cpu_late_init(void)
> +{
> +	char buf[128];
> +	const char *board;
> +	u32 imxtype = (get_cpu_rev() >> 12) & 0xff;
> +
> +	if (getenv("fdt_file"))
> +		return 0;
> +	board = getenv("board");
> +	if (!board) {
> +		board = CONFIG_SYS_BOARD;

And this part seems to impose a board-naming requirement
to implement the dtb-naming requirement:

> +		if ((board[0] == 'm') && (board[1] == 'x')) {
> +			if (board[2] == '6') {
> +				board += 3;
> +			} else if (board[2] == '5') {
> +				if ((board[3] == '1') || (board[3] == '3'))
> +					board += 4;
> +			}
> +		}
> +	}
> +	sprintf(buf, "%s-%s.dtb", get_dtb_prefix(imxtype), board);
> +	setenv("fdt_file", buf);
> +	return 0;
> +}

I sent patches last year to provide default "cpu" and "board"
environment variables that could be used by boot scripts to
implement this part.

	http://lists.denx.de/pipermail/u-boot/2013-November/thread.html#167129

That seems more generally useful.

Otherwise, I'd rather just see an environment-variable convention.

Regards,


Eric


More information about the U-Boot mailing list