[U-Boot] [PATCH 1/4] mx6: add function to determine boot device

Eric Nelson eric.nelson at boundarydevices.com
Sat Nov 9 00:09:07 CET 2013


Hi Edward,

On 11/08/2013 02:34 AM, Edward Lin wrote:
> During boot the boot pin configuration is copied to the SBMR registers.
> This patch adds a function to read the boot device from SBMR.
>
> Signed-off-by: Edward Lin <edward.lin at technexion.com>
> Signed-off-by: Richard Hu <richard.hu at technexion.com>
>
> ---
>   arch/arm/cpu/armv7/mx6/soc.c              | 43
> +++++++++++++++++++++++++++++++
>   arch/arm/include/asm/arch-mx6/sys_proto.h | 17 ++++++++++++
>   2 files changed, 60 insertions(+)
>
> diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
> index a390296..6bacdab 100644
> --- a/arch/arm/cpu/armv7/mx6/soc.c
> +++ b/arch/arm/cpu/armv7/mx6/soc.c
> @@ -243,6 +243,49 @@ void s_init(void)
>          writel(mask528, &anatop->pfd_528_clr);
>   }
>
> +enum mx6_boot_device imx_get_boot_device(void)
> +{
> +       uint soc_sbmr = readl(SRC_BASE_ADDR + 0x4);

(struct src)->sbmr1? (from imx-regs.h)

> +       uint bt_mem_ctl = (soc_sbmr & 0x000000FF) >> 4 ;

You may want a macro here, but certainly don't need the
low four bits set.

> +       uint bt_mem_type = (soc_sbmr & 0x00000008) >> 3;
> +       uint bt_mem_mmc = (soc_sbmr & 0x00001000) >> 12;
> +
> +       switch (bt_mem_ctl) {
> +       case 0x0:
> +               if (bt_mem_type)
> +                       return MX6_ONE_NAND_BOOT;
> +               else
> +                       return MX6_WEIM_NOR_BOOT;
> +               break;
> +       case 0x2:
> +                       return MX6_SATA_BOOT;
> +               break;
> +       case 0x3:
> +               if (bt_mem_type)
> +                       return MX6_I2C_BOOT;
> +               else
> +                       return MX6_SPI_NOR_BOOT;
> +               break;
> +       case 0x4:
> +       case 0x5:
> +               if (bt_mem_mmc)
> +                       return MX6_SD0_BOOT;
> +               else
> +                       return MX6_SD1_BOOT;
> +               break;
> +       case 0x6:
> +       case 0x7:
> +               return MX6_MMC_BOOT;
> +               break;
> +       case 0x8 ... 0xf:
> +               return MX6_NAND_BOOT;
> +               break;
> +       default:
> +               return MX6_UNKNOWN_BOOT;
> +               break;
> +       }
> +}
> +

These magic values are the same as those used in
arch/arm/cpu/armv7/mx6/soc.c for the "bmode" command,
so I'd personally like to see some constants...

I'd also like to know where the definitive reference
for these is. I have a spreadsheet of dubious ancestry,
and the current RM has the very helpful comment
"Refer to the fusemap", and the fuse map is similarly
opaque.

Troy? Anyone?

>   #ifdef CONFIG_IMX_HDMI
>   void imx_enable_hdmi_phy(void)
>   {
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h
> b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index 8c21364..b26955e 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -17,6 +17,21 @@
>   #define MXC_CPU_MX6SOLO                0x62
>   #define MXC_CPU_MX6Q           0x63
>
> +enum mx6_boot_device {
> +        MX6_SD0_BOOT,
> +        MX6_SD1_BOOT,
> +        MX6_MMC_BOOT,
> +        MX6_NAND_BOOT,
> +        MX6_SATA_BOOT,
> +        MX6_WEIM_NOR_BOOT,
> +        MX6_ONE_NAND_BOOT,
> +        MX6_PATA_BOOT,
> +        MX6_I2C_BOOT,
> +        MX6_SPI_NOR_BOOT,
> +        MX6_UNKNOWN_BOOT,
> +        MX6_BOOT_DEV_NUM = MX6_UNKNOWN_BOOT,
> +};
> +

It might make sense to just place these into the
soc_boot_modes table, gain "bmode" support for all
of them, and have imx_get_boot_device() walk the
table.

At the moment, it appears that only USB, SATA,
SPI-NOR, and SD card are supported by "bmode".

Regards,


Eric


More information about the U-Boot mailing list