[U-Boot] [PATCH v3 03/15] imx: Use IMX6_BMODE_* macros instead of numericals
Stefano Babic
sbabic at denx.de
Sun Feb 19 15:50:50 UTC 2017
On 02/02/2017 15:56, Jagan Teki wrote:
> Use meaningful macros IMX6_BMODE_*, instead of numerical
> number in boot mode detection code.
>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Tim Harvey <tharvey at gateworks.com>
> Signed-off-by: Jagan Teki <jagan at openedev.com>
> ---
> Changes for v3:
> - Update IMX6_BMODE_* shift macros with real number instead of bitops
> - %s/IMX6_BMODE_SERIAL/IMX6_BMODE_SERIAL_ROM
> - Assign enums with numbers so-that it can easy to see same in RM
>
> arch/arm/imx-common/spl.c | 39 ++++++++++++++++++-----------
> arch/arm/include/asm/imx-common/sys_proto.h | 34 +++++++++++++++++++++++++
> 2 files changed, 58 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm/imx-common/spl.c b/arch/arm/imx-common/spl.c
> index fc3704b..acf268d 100644
> --- a/arch/arm/imx-common/spl.c
> +++ b/arch/arm/imx-common/spl.c
> @@ -30,39 +30,48 @@ u32 spl_boot_device(void)
> if ((((bmode >> 24) & 0x03) == 0x01) || /* Serial Downloader */
> (imx6_is_bmode_from_gpr9() && (reg == 1)))
> return BOOT_DEVICE_UART;
> +
> /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
> - switch ((reg & 0x000000FF) >> 4) {
> + switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
> /* EIM: See 8.5.1, Table 8-9 */
> - case 0x0:
> + case IMX6_BMODE_EMI:
> /* BOOT_CFG1[3]: NOR/OneNAND Selection */
> - if ((reg & 0x00000008) >> 3)
> + switch ((reg & IMX6_BMODE_EMI_MASK) >> IMX6_BMODE_EMI_SHIFT) {
> + case IMX6_BMODE_ONENAND:
> return BOOT_DEVICE_ONENAND;
> - else
> + case IMX6_BMODE_NOR:
> return BOOT_DEVICE_NOR;
> - break;
> + }
> /* SATA: See 8.5.4, Table 8-20 */
> - case 0x2:
> + case IMX6_BMODE_SATA:
> return BOOT_DEVICE_SATA;
> /* Serial ROM: See 8.5.5.1, Table 8-22 */
> - case 0x3:
> + case IMX6_BMODE_SERIAL_ROM:
> /* BOOT_CFG4[2:0] */
> - switch ((reg & 0x07000000) >> 24) {
> - case 0x0 ... 0x4:
> + switch ((reg & IMX6_BMODE_SERIAL_ROM_MASK) >>
> + IMX6_BMODE_SERIAL_ROM_SHIFT) {
> + case IMX6_BMODE_ECSPI1:
> + case IMX6_BMODE_ECSPI2:
> + case IMX6_BMODE_ECSPI3:
> + case IMX6_BMODE_ECSPI4:
> + case IMX6_BMODE_ECSPI5:
> return BOOT_DEVICE_SPI;
> - case 0x5 ... 0x7:
> + case IMX6_BMODE_I2C1:
> + case IMX6_BMODE_I2C2:
> + case IMX6_BMODE_I2C3:
> return BOOT_DEVICE_I2C;
> }
> break;
> /* SD/eSD: 8.5.3, Table 8-15 */
> - case 0x4:
> - case 0x5:
> + case IMX6_BMODE_SD:
> + case IMX6_BMODE_ESD:
> return BOOT_DEVICE_MMC1;
> /* MMC/eMMC: 8.5.3 */
> - case 0x6:
> - case 0x7:
> + case IMX6_BMODE_MMC:
> + case IMX6_BMODE_EMMC:
> return BOOT_DEVICE_MMC1;
> /* NAND Flash: 8.5.2, Table 8-10 */
> - case 0x8:
> + case IMX6_BMODE_NAND:
> return BOOT_DEVICE_NAND;
> }
> return BOOT_DEVICE_NONE;
> diff --git a/arch/arm/include/asm/imx-common/sys_proto.h b/arch/arm/include/asm/imx-common/sys_proto.h
> index 99e3869..ba95641 100644
> --- a/arch/arm/include/asm/imx-common/sys_proto.h
> +++ b/arch/arm/include/asm/imx-common/sys_proto.h
> @@ -42,6 +42,40 @@
> #ifdef CONFIG_MX6
> #define IMX6_SRC_GPR10_BMODE BIT(28)
>
> +#define IMX6_BMODE_MASK GENMASK(7, 0)
> +#define IMX6_BMODE_SHIFT 4
> +#define IMX6_BMODE_EMI_MASK BIT(3)
> +#define IMX6_BMODE_EMI_SHIFT 3
> +#define IMX6_BMODE_SERIAL_ROM_MASK GENMASK(26, 24)
> +#define IMX6_BMODE_SERIAL_ROM_SHIFT 24
> +
> +enum imx6_bmode_serial_rom {
> + IMX6_BMODE_ECSPI1,
> + IMX6_BMODE_ECSPI2,
> + IMX6_BMODE_ECSPI3,
> + IMX6_BMODE_ECSPI4,
> + IMX6_BMODE_ECSPI5,
> + IMX6_BMODE_I2C1,
> + IMX6_BMODE_I2C2,
> + IMX6_BMODE_I2C3,
> +};
> +
> +enum imx6_bmode_emi {
> + IMX6_BMODE_ONENAND,
> + IMX6_BMODE_NOR,
> +};
> +
> +enum imx6_bmode {
> + IMX6_BMODE_EMI = 0x0,
> + IMX6_BMODE_SATA = 0x2,
> + IMX6_BMODE_SERIAL_ROM = 0x3,
> + IMX6_BMODE_SD = 0x4,
> + IMX6_BMODE_ESD = 0x5,
> + IMX6_BMODE_MMC = 0x6,
> + IMX6_BMODE_EMMC = 0x7,
> + IMX6_BMODE_NAND = 0x8,
> +};
> +
> static inline u8 imx6_is_bmode_from_gpr9(void)
> {
> struct src *psrc = (struct src *)SRC_BASE_ADDR;
>
Fully agree to get rid of hex code !
Acked by : Stefano Babic |sbabic at denx.de>
Best regards,
Stefano Babic
--
Meet DENX at the Embedded World Trade Show
14 Mar - 16 Mar 2017, Nuremberg Trade Fair Centre, Hall 4, Booth 581
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
More information about the U-Boot
mailing list