All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] mx6cuboxi: enable support for OF_CONTROL and DM in SPL
@ 2020-03-04 14:41 Walter Lozano
  2020-03-04 14:41 ` [PATCH 1/4] mx6cuboxi: enable MMC and eMMC in DT for SPL Walter Lozano
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Walter Lozano @ 2020-03-04 14:41 UTC (permalink / raw)
  To: u-boot

Make an additional step to add full DM support to mx6cuboxi, including its support for SPL

With this new configuration SPL image is 50 KB, higher than the
38 KB from the previous version, but it still under the 68 KB limit.

Walter Lozano (4):
  mx6cuboxi: enable MMC and eMMC in DT for SPL
  mx6cuboxi: enable MMC iomux on board_early_init_f
  mx6cuboxi: customize board_boot_order to access eMMC
  mx6cuboxi: enable OF_CONTROL and DM in SPL

 ...qdl-hummingboard2-emmc-som-v15-u-boot.dtsi |  8 ++
 board/solidrun/mx6cuboxi/mx6cuboxi.c          | 74 +++++++++++++++++++
 configs/mx6cuboxi_defconfig                   |  3 +
 3 files changed, 85 insertions(+)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] mx6cuboxi: enable MMC and eMMC in DT for SPL
  2020-03-04 14:41 [PATCH 0/4] mx6cuboxi: enable support for OF_CONTROL and DM in SPL Walter Lozano
@ 2020-03-04 14:41 ` Walter Lozano
  2020-03-04 14:41 ` [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f Walter Lozano
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Walter Lozano @ 2020-03-04 14:41 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 .../dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi    | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi b/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi
index d302b2e275..400b885e43 100644
--- a/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi
+++ b/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi
@@ -34,3 +34,11 @@
 &usdhc1 {
 	status = "disabled";
 };
+
+&usdhc2 {
+	u-boot,dm-pre-reloc;
+};
+
+&usdhc3 {
+	u-boot,dm-pre-reloc;
+};
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f
  2020-03-04 14:41 [PATCH 0/4] mx6cuboxi: enable support for OF_CONTROL and DM in SPL Walter Lozano
  2020-03-04 14:41 ` [PATCH 1/4] mx6cuboxi: enable MMC and eMMC in DT for SPL Walter Lozano
@ 2020-03-04 14:41 ` Walter Lozano
  2020-03-08  4:38   ` Baruch Siach
  2020-03-04 14:41 ` [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC Walter Lozano
  2020-03-04 14:41 ` [PATCH 4/4] mx6cuboxi: enable OF_CONTROL and DM in SPL Walter Lozano
  3 siblings, 1 reply; 9+ messages in thread
From: Walter Lozano @ 2020-03-04 14:41 UTC (permalink / raw)
  To: u-boot

MMC iomux is done on board_mmc_init which is valid when DM_MMC is not
enabled. After enabling it, the iomux setup needs to be moved to a
valid place.

This patch moves the MMC iomux to board_early_init_f where other iomux
is done.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 6a96f9ecdb..71c77ad2a2 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -179,6 +179,28 @@ int board_mmc_get_env_dev(int devno)
 
 #define USDHC2_CD_GPIO  IMX_GPIO_NR(1, 4)
 
+static int setup_iomux_mmc(void)
+{
+	struct src *psrc = (struct src *)SRC_BASE_ADDR;
+	unsigned reg = readl(&psrc->sbmr1) >> 11;
+
+	/*
+	 * Upon reading BOOT_CFG register the following map is done:
+	 * Bit 11 and 12 of BOOT_CFG register can determine the current
+	 * mmc port
+	 * 0x1                  SD2
+	 * 0x2                  SD3
+	 */
+	switch (reg & 0x3) {
+	case 0x1:
+		SETUP_IOMUX_PADS(usdhc2_pads);
+	case 0x2:
+		SETUP_IOMUX_PADS(usdhc3_pads);
+	}
+
+	return 0;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
 	struct fsl_esdhc_cfg *cfg = mmc->priv;
@@ -432,9 +454,12 @@ int board_early_init_f(void)
 {
 	setup_iomux_uart();
 
+	setup_iomux_mmc();
+
 #ifdef CONFIG_CMD_SATA
 	setup_sata();
 #endif
+
 	return 0;
 }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC
  2020-03-04 14:41 [PATCH 0/4] mx6cuboxi: enable support for OF_CONTROL and DM in SPL Walter Lozano
  2020-03-04 14:41 ` [PATCH 1/4] mx6cuboxi: enable MMC and eMMC in DT for SPL Walter Lozano
  2020-03-04 14:41 ` [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f Walter Lozano
@ 2020-03-04 14:41 ` Walter Lozano
  2020-03-08  4:42   ` Baruch Siach
  2020-03-04 14:41 ` [PATCH 4/4] mx6cuboxi: enable OF_CONTROL and DM in SPL Walter Lozano
  3 siblings, 1 reply; 9+ messages in thread
From: Walter Lozano @ 2020-03-04 14:41 UTC (permalink / raw)
  To: u-boot

In SPL legacy code only one MMC device is created, based on BOOT_CFG
register, which can be either SD or eMMC. In this context
board_boot_order return always MMC1 when configure to boot from
SD/eMMC. After switching to DM both SD and eMMC devices are created
based on the information available on DT, but as board_boot_order
only returns MMC1 is not possible to boot from eMMC.

This patch customizes board_boot_order taking into account BOOT_CFG
register to point to correct MMC1 / MMC2 device.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 49 ++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 71c77ad2a2..3ce122e8b9 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -649,6 +649,55 @@ int board_fit_config_name_match(const char *name)
 	return strcmp(name, tmp_name);
 }
 
+void board_boot_order(u32 *spl_boot_list)
+{
+	struct src *psrc = (struct src *)SRC_BASE_ADDR;
+	unsigned int reg = readl(&psrc->sbmr1) >> 11;
+	u32 boot_mode = imx6_src_get_boot_mode() & IMX6_BMODE_MASK;
+	unsigned int bmode = readl(&src_base->sbmr2);
+
+	/* If bmode is serial or USB phy is active, return serial */
+	if (((bmode >> 24) & 0x03) == 0x01 || is_usbotg_phy_active()) {
+		spl_boot_list[0] = BOOT_DEVICE_BOARD;
+		return;
+	}
+
+	switch (boot_mode >> IMX6_BMODE_SHIFT) {
+	case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
+		spl_boot_list[0] = BOOT_DEVICE_NAND;
+		break;
+	case IMX6_BMODE_SD:
+	case IMX6_BMODE_ESD:
+	case IMX6_BMODE_MMC:
+	case IMX6_BMODE_EMMC:
+		/*
+		 * Upon reading BOOT_CFG register the following map is done:
+		 * Bit 11 and 12 of BOOT_CFG register can determine the current
+		 * mmc port
+		 * 0x1                  SD2
+		 * 0x2                  SD3
+		 */
+
+		reg &= 0x3; /* Only care about bottom 2 bits */
+		switch (reg) {
+		case 1:
+			spl_boot_list[0] = BOOT_DEVICE_MMC1;
+			break;
+		case 2:
+			spl_boot_list[0] = BOOT_DEVICE_MMC2;
+			break;
+		}
+		break;
+	default:
+		/* By default use USB downloader */
+		spl_boot_list[0] = BOOT_DEVICE_BOARD;
+		break;
+	}
+
+	/* As a last resort, use serial downloader */
+	spl_boot_list[1] = BOOT_DEVICE_BOARD;
+}
+
 #ifdef CONFIG_SPL_BUILD
 #include <asm/arch/mx6-ddr.h>
 static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] mx6cuboxi: enable OF_CONTROL and DM in SPL
  2020-03-04 14:41 [PATCH 0/4] mx6cuboxi: enable support for OF_CONTROL and DM in SPL Walter Lozano
                   ` (2 preceding siblings ...)
  2020-03-04 14:41 ` [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC Walter Lozano
@ 2020-03-04 14:41 ` Walter Lozano
  3 siblings, 0 replies; 9+ messages in thread
From: Walter Lozano @ 2020-03-04 14:41 UTC (permalink / raw)
  To: u-boot

In order to take the beneficts of DT and DM in SPL, like reusing the code
and avoid redundancy, enable SPL_OF_CONTROL, SPL_DM and SPL_DM_MMC.

With this new configuration SPL image is 50 KB, higher than the
38 KB from the previous version, but it still under the 68 KB limit.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 configs/mx6cuboxi_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/mx6cuboxi_defconfig b/configs/mx6cuboxi_defconfig
index bee7d280f0..7ea79b9064 100644
--- a/configs/mx6cuboxi_defconfig
+++ b/configs/mx6cuboxi_defconfig
@@ -25,6 +25,7 @@ CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="if hdmidet; then usb start; setenv stdin  serial,usbkbd; setenv stdout serial,vga; setenv stderr serial,vga; else setenv stdin  serial; setenv stdout serial; setenv stderr serial; fi;"
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_FS_EXT4=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_WATCHDOG_SUPPORT=y
@@ -37,6 +38,7 @@ CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="imx6dl-hummingboard2-emmc-som-v15"
 CONFIG_OF_LIST="imx6dl-hummingboard2-emmc-som-v15 imx6q-hummingboard2-emmc-som-v15"
 CONFIG_MULTI_DTB_FIT=y
@@ -45,6 +47,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_DM=y
+CONFIG_SPL_DM=y
 CONFIG_DWC_AHSATA=y
 CONFIG_DM_MMC=y
 CONFIG_FSL_USDHC=y
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f
  2020-03-04 14:41 ` [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f Walter Lozano
@ 2020-03-08  4:38   ` Baruch Siach
  2020-03-09 19:55     ` Walter Lozano
  0 siblings, 1 reply; 9+ messages in thread
From: Baruch Siach @ 2020-03-08  4:38 UTC (permalink / raw)
  To: u-boot

Hi Walter,

Thanks for your SPL_DM support work on this platform.

One comment inline below.

On Wed, Mar 04 2020, Walter Lozano wrote:
> MMC iomux is done on board_mmc_init which is valid when DM_MMC is not
> enabled. After enabling it, the iomux setup needs to be moved to a
> valid place.
>
> This patch moves the MMC iomux to board_early_init_f where other iomux
> is done.
>
> Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
> ---
>  board/solidrun/mx6cuboxi/mx6cuboxi.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 6a96f9ecdb..71c77ad2a2 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -179,6 +179,28 @@ int board_mmc_get_env_dev(int devno)
>  
>  #define USDHC2_CD_GPIO  IMX_GPIO_NR(1, 4)
>  
> +static int setup_iomux_mmc(void)
> +{
> +	struct src *psrc = (struct src *)SRC_BASE_ADDR;
> +	unsigned reg = readl(&psrc->sbmr1) >> 11;

This mostly duplicates the existing mmc_init_spl() routine. As I understand,
mmc_init_spl() becomes dead code once you enable CONFIG_SPL_DM in patch #4 of
this series. Can you remove mmc_init_spl() in a followup patch? Both
struct fsl_esdhc_cfg can also be removed, I believe.

baruch

> +
> +	/*
> +	 * Upon reading BOOT_CFG register the following map is done:
> +	 * Bit 11 and 12 of BOOT_CFG register can determine the current
> +	 * mmc port
> +	 * 0x1                  SD2
> +	 * 0x2                  SD3
> +	 */
> +	switch (reg & 0x3) {
> +	case 0x1:
> +		SETUP_IOMUX_PADS(usdhc2_pads);
> +	case 0x2:
> +		SETUP_IOMUX_PADS(usdhc3_pads);
> +	}
> +
> +	return 0;
> +}
> +
>  int board_mmc_getcd(struct mmc *mmc)
>  {
>  	struct fsl_esdhc_cfg *cfg = mmc->priv;
> @@ -432,9 +454,12 @@ int board_early_init_f(void)
>  {
>  	setup_iomux_uart();
>  
> +	setup_iomux_mmc();
> +
>  #ifdef CONFIG_CMD_SATA
>  	setup_sata();
>  #endif
> +
>  	return 0;
>  }

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC
  2020-03-04 14:41 ` [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC Walter Lozano
@ 2020-03-08  4:42   ` Baruch Siach
  2020-03-09 19:55     ` Walter Lozano
  0 siblings, 1 reply; 9+ messages in thread
From: Baruch Siach @ 2020-03-08  4:42 UTC (permalink / raw)
  To: u-boot

Hi Walter,

On Wed, Mar 04 2020, Walter Lozano wrote:
> In SPL legacy code only one MMC device is created, based on BOOT_CFG
> register, which can be either SD or eMMC. In this context
> board_boot_order return always MMC1 when configure to boot from
> SD/eMMC. After switching to DM both SD and eMMC devices are created
> based on the information available on DT, but as board_boot_order
> only returns MMC1 is not possible to boot from eMMC.
>
> This patch customizes board_boot_order taking into account BOOT_CFG
> register to point to correct MMC1 / MMC2 device.
>
> Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
> ---
>  board/solidrun/mx6cuboxi/mx6cuboxi.c | 49 ++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
>
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 71c77ad2a2..3ce122e8b9 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -649,6 +649,55 @@ int board_fit_config_name_match(const char *name)
>  	return strcmp(name, tmp_name);
>  }
>  
> +void board_boot_order(u32 *spl_boot_list)
> +{
> +	struct src *psrc = (struct src *)SRC_BASE_ADDR;
> +	unsigned int reg = readl(&psrc->sbmr1) >> 11;
> +	u32 boot_mode = imx6_src_get_boot_mode() & IMX6_BMODE_MASK;
> +	unsigned int bmode = readl(&src_base->sbmr2);

This is duplication of the logicpd/imx6 board code. But..

> +
> +	/* If bmode is serial or USB phy is active, return serial */
> +	if (((bmode >> 24) & 0x03) == 0x01 || is_usbotg_phy_active()) {
> +		spl_boot_list[0] = BOOT_DEVICE_BOARD;
> +		return;
> +	}
> +
> +	switch (boot_mode >> IMX6_BMODE_SHIFT) {
> +	case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
> +		spl_boot_list[0] = BOOT_DEVICE_NAND;
> +		break;

... we have no raw NAND device on Hummingboard.

> +	case IMX6_BMODE_SD:
> +	case IMX6_BMODE_ESD:
> +	case IMX6_BMODE_MMC:
> +	case IMX6_BMODE_EMMC:
> +		/*
> +		 * Upon reading BOOT_CFG register the following map is done:
> +		 * Bit 11 and 12 of BOOT_CFG register can determine the current
> +		 * mmc port
> +		 * 0x1                  SD2
> +		 * 0x2                  SD3
> +		 */
> +
> +		reg &= 0x3; /* Only care about bottom 2 bits */
> +		switch (reg) {
> +		case 1:
> +			spl_boot_list[0] = BOOT_DEVICE_MMC1;
> +			break;
> +		case 2:
> +			spl_boot_list[0] = BOOT_DEVICE_MMC2;
> +			break;

This code is very similar to setup_iomux_mmc(). Maybe an opportunity to share
code between functions?

Thanks,
baruch

> +		}
> +		break;
> +	default:
> +		/* By default use USB downloader */
> +		spl_boot_list[0] = BOOT_DEVICE_BOARD;
> +		break;
> +	}
> +
> +	/* As a last resort, use serial downloader */
> +	spl_boot_list[1] = BOOT_DEVICE_BOARD;
> +}
> +
>  #ifdef CONFIG_SPL_BUILD
>  #include <asm/arch/mx6-ddr.h>
>  static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {


-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f
  2020-03-08  4:38   ` Baruch Siach
@ 2020-03-09 19:55     ` Walter Lozano
  0 siblings, 0 replies; 9+ messages in thread
From: Walter Lozano @ 2020-03-09 19:55 UTC (permalink / raw)
  To: u-boot

Hi Baruch,

Thanks for you comments.

On 8/3/20 01:38, Baruch Siach wrote:
> Hi Walter,
>
> Thanks for your SPL_DM support work on this platform.
>
> One comment inline below.
>
> On Wed, Mar 04 2020, Walter Lozano wrote:
>> MMC iomux is done on board_mmc_init which is valid when DM_MMC is not
>> enabled. After enabling it, the iomux setup needs to be moved to a
>> valid place.
>>
>> This patch moves the MMC iomux to board_early_init_f where other iomux
>> is done.
>>
>> Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
>> ---
>>   board/solidrun/mx6cuboxi/mx6cuboxi.c | 25 +++++++++++++++++++++++++
>>   1 file changed, 25 insertions(+)
>>
>> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> index 6a96f9ecdb..71c77ad2a2 100644
>> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> @@ -179,6 +179,28 @@ int board_mmc_get_env_dev(int devno)
>>   
>>   #define USDHC2_CD_GPIO  IMX_GPIO_NR(1, 4)
>>   
>> +static int setup_iomux_mmc(void)
>> +{
>> +	struct src *psrc = (struct src *)SRC_BASE_ADDR;
>> +	unsigned reg = readl(&psrc->sbmr1) >> 11;
> This mostly duplicates the existing mmc_init_spl() routine. As I understand,
> mmc_init_spl() becomes dead code once you enable CONFIG_SPL_DM in patch #4 of
> this series. Can you remove mmc_init_spl() in a followup patch? Both
> struct fsl_esdhc_cfg can also be removed, I believe.

You are right, if we enable both CONFIG_SPL_DM and CONFIG_SPL_DM_MMC the 
function mmc_init_spl is useless, so I understand we can safety remove it.

> baruch
>
Regards,

Walter

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC
  2020-03-08  4:42   ` Baruch Siach
@ 2020-03-09 19:55     ` Walter Lozano
  0 siblings, 0 replies; 9+ messages in thread
From: Walter Lozano @ 2020-03-09 19:55 UTC (permalink / raw)
  To: u-boot

Hi Baruch

On 8/3/20 01:42, Baruch Siach wrote:
> Hi Walter,
>
> On Wed, Mar 04 2020, Walter Lozano wrote:
>> In SPL legacy code only one MMC device is created, based on BOOT_CFG
>> register, which can be either SD or eMMC. In this context
>> board_boot_order return always MMC1 when configure to boot from
>> SD/eMMC. After switching to DM both SD and eMMC devices are created
>> based on the information available on DT, but as board_boot_order
>> only returns MMC1 is not possible to boot from eMMC.
>>
>> This patch customizes board_boot_order taking into account BOOT_CFG
>> register to point to correct MMC1 / MMC2 device.
>>
>> Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
>> ---
>>   board/solidrun/mx6cuboxi/mx6cuboxi.c | 49 ++++++++++++++++++++++++++++
>>   1 file changed, 49 insertions(+)
>>
>> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> index 71c77ad2a2..3ce122e8b9 100644
>> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
>> @@ -649,6 +649,55 @@ int board_fit_config_name_match(const char *name)
>>   	return strcmp(name, tmp_name);
>>   }
>>   
>> +void board_boot_order(u32 *spl_boot_list)
>> +{
>> +	struct src *psrc = (struct src *)SRC_BASE_ADDR;
>> +	unsigned int reg = readl(&psrc->sbmr1) >> 11;
>> +	u32 boot_mode = imx6_src_get_boot_mode() & IMX6_BMODE_MASK;
>> +	unsigned int bmode = readl(&src_base->sbmr2);
> This is duplication of the logicpd/imx6 board code. But..
>
>> +
>> +	/* If bmode is serial or USB phy is active, return serial */
>> +	if (((bmode >> 24) & 0x03) == 0x01 || is_usbotg_phy_active()) {
>> +		spl_boot_list[0] = BOOT_DEVICE_BOARD;
>> +		return;
>> +	}
>> +
>> +	switch (boot_mode >> IMX6_BMODE_SHIFT) {
>> +	case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
>> +		spl_boot_list[0] = BOOT_DEVICE_NAND;
>> +		break;
> ... we have no raw NAND device on Hummingboard.
Yes, you are right, I use the logicpd/imx6 as reference and forgot about 
the NAND. Thanks you pointing at it.
>
>> +	case IMX6_BMODE_SD:
>> +	case IMX6_BMODE_ESD:
>> +	case IMX6_BMODE_MMC:
>> +	case IMX6_BMODE_EMMC:
>> +		/*
>> +		 * Upon reading BOOT_CFG register the following map is done:
>> +		 * Bit 11 and 12 of BOOT_CFG register can determine the current
>> +		 * mmc port
>> +		 * 0x1                  SD2
>> +		 * 0x2                  SD3
>> +		 */
>> +
>> +		reg &= 0x3; /* Only care about bottom 2 bits */
>> +		switch (reg) {
>> +		case 1:
>> +			spl_boot_list[0] = BOOT_DEVICE_MMC1;
>> +			break;
>> +		case 2:
>> +			spl_boot_list[0] = BOOT_DEVICE_MMC2;
>> +			break;
> This code is very similar to setup_iomux_mmc(). Maybe an opportunity to share
> code between functions?


Thanks for your suggestion, I will do a little rework.


> Thanks,
> baruch


Regards,

Walter

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-03-09 19:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04 14:41 [PATCH 0/4] mx6cuboxi: enable support for OF_CONTROL and DM in SPL Walter Lozano
2020-03-04 14:41 ` [PATCH 1/4] mx6cuboxi: enable MMC and eMMC in DT for SPL Walter Lozano
2020-03-04 14:41 ` [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f Walter Lozano
2020-03-08  4:38   ` Baruch Siach
2020-03-09 19:55     ` Walter Lozano
2020-03-04 14:41 ` [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC Walter Lozano
2020-03-08  4:42   ` Baruch Siach
2020-03-09 19:55     ` Walter Lozano
2020-03-04 14:41 ` [PATCH 4/4] mx6cuboxi: enable OF_CONTROL and DM in SPL Walter Lozano

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.