[U-Boot] [PATCH] mx6slevk: Fix MMC breakage for the SPL target

2017-10-01 Thread Fabio Estevam
From: Fabio Estevam 

Commit 001cdbbb32ef1f6 ("imx: mx6slevk: enable more DM drivers") breaks
MMC support in U-Boot proper on the mx6slevk_spl_defconfig target:

U-Boot SPL 2017.09-00396-g6ca43a5 (Oct 01 2017 - 16:20:18)  
Trying to boot from MMC1

U-Boot 2017.09-00396-g6ca43a5 (Oct 01 2017 - 16:20:18 -0300)

CPU:   Freescale i.MX6SL rev1.0 792 MHz (running at 396 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 33C  
Reset cause: POR
Board: MX6SLEVK 
I2C:   ready
DRAM:  1 GiB
MMC:   FSL_SDHC: 0  
MMC Device 1 not found  
*** Warning - No MMC card found, using default environment 

Fix this by re-introducing the U-Boot proper mmc init code inside
board_mmc_init().

Signed-off-by: Fabio Estevam 
---
 board/freescale/mx6slevk/mx6slevk.c | 81 -
 1 file changed, 63 insertions(+), 18 deletions(-)

diff --git a/board/freescale/mx6slevk/mx6slevk.c 
b/board/freescale/mx6slevk/mx6slevk.c
index 8afd5da..e9a9bbf 100644
--- a/board/freescale/mx6slevk/mx6slevk.c
+++ b/board/freescale/mx6slevk/mx6slevk.c
@@ -66,7 +66,6 @@ static iomux_v3_cfg_t const uart1_pads[] = {
MX6_PAD_UART1_RXD__UART1_RXD | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
-#ifdef CONFIG_SPL_BUILD
 static iomux_v3_cfg_t const usdhc1_pads[] = {
/* 8 bit SD */
MX6_PAD_SD1_CLK__USDHC1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -107,7 +106,6 @@ static iomux_v3_cfg_t const usdhc3_pads[] = {
/*CD pin*/
MX6_PAD_REF_CLK_32K__GPIO_3_22 | MUX_PAD_CTRL(NO_PAD_CTRL),
 };
-#endif
 
 static iomux_v3_cfg_t const fec_pads[] = {
MX6_PAD_FEC_MDC__FEC_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL),
@@ -157,11 +155,6 @@ static void setup_iomux_fec(void)
udelay(15000);
 }
 
-int board_mmc_get_env_dev(int devno)
-{
-   return devno;
-}
-
 #ifdef CONFIG_DM_PMIC_PFUZE100
 int power_init_board(void)
 {
@@ -294,17 +287,6 @@ int board_init(void)
return 0;
 }
 
-int checkboard(void)
-{
-   puts("Board: MX6SLEVK\n");
-
-   return 0;
-}
-
-#ifdef CONFIG_SPL_BUILD
-#include 
-#include 
-
 #define USDHC1_CD_GPIO IMX_GPIO_NR(4, 7)
 #define USDHC2_CD_GPIO IMX_GPIO_NR(5, 0)
 #define USDHC3_CD_GPIO IMX_GPIO_NR(3, 22)
@@ -315,6 +297,11 @@ static struct fsl_esdhc_cfg usdhc_cfg[3] = {
{USDHC3_BASE_ADDR, 0, 4},
 };
 
+int board_mmc_get_env_dev(int devno)
+{
+   return devno;
+}
+
 int board_mmc_getcd(struct mmc *mmc)
 {
struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
@@ -337,6 +324,52 @@ int board_mmc_getcd(struct mmc *mmc)
 
 int board_mmc_init(bd_t *bis)
 {
+#ifndef CONFIG_SPL_BUILD
+   int i, ret;
+
+   /*
+* According to the board_mmc_init() the following map is done:
+* (U-Boot device node)(Physical Port)
+* mmc0USDHC1
+* mmc1USDHC2
+* mmc2USDHC3
+*/
+   for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
+   switch (i) {
+   case 0:
+   imx_iomux_v3_setup_multiple_pads(
+   usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
+   gpio_direction_input(USDHC1_CD_GPIO);
+   usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+   break;
+   case 1:
+   imx_iomux_v3_setup_multiple_pads(
+   usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
+   gpio_direction_input(USDHC2_CD_GPIO);
+   usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
+   break;
+   case 2:
+   imx_iomux_v3_setup_multiple_pads(
+   usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
+   gpio_direction_input(USDHC3_CD_GPIO);
+   usdhc_cfg[2].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+   break;
+   default:
+   printf("Warning: you configured more USDHC controllers"
+   "(%d) than supported by the board\n", i + 1);
+   return -EINVAL;
+   }
+
+   ret = fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
+   if (ret) {
+   printf("Warning: failed to initialize "
+   "mmc dev %d\n", i);
+   r

Re: [U-Boot] [PATCH] mx6slevk: Fix MMC breakage for the SPL target

2017-10-12 Thread Fabio Estevam
Hi Stefano,

On Sun, Oct 1, 2017 at 4:23 PM, Fabio Estevam  wrote:
> From: Fabio Estevam 
>
> Commit 001cdbbb32ef1f6 ("imx: mx6slevk: enable more DM drivers") breaks
> MMC support in U-Boot proper on the mx6slevk_spl_defconfig target:
>
> U-Boot SPL 2017.09-00396-g6ca43a5 (Oct 01 2017 - 16:20:18)
> Trying to boot from MMC1
>
> U-Boot 2017.09-00396-g6ca43a5 (Oct 01 2017 - 16:20:18 -0300)
>
> CPU:   Freescale i.MX6SL rev1.0 792 MHz (running at 396 MHz)
> CPU:   Commercial temperature grade (0C to 95C) at 33C
> Reset cause: POR
> Board: MX6SLEVK
> I2C:   ready
> DRAM:  1 GiB
> MMC:   FSL_SDHC: 0
> MMC Device 1 not found
> *** Warning - No MMC card found, using default environment
>
> Fix this by re-introducing the U-Boot proper mmc init code inside
> board_mmc_init().
>
> Signed-off-by: Fabio Estevam 

Please disregard this patch and others I sent related to the MMC
breakage. We are discussing in another thread a more generic way to
fix these problems.

Thanks
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] mx6slevk: Fix MMC breakage for the SPL target

2017-10-12 Thread Stefano Babic
Hi Fabio,

On 12/10/2017 18:27, Fabio Estevam wrote:
> Hi Stefano,
> 
> On Sun, Oct 1, 2017 at 4:23 PM, Fabio Estevam  wrote:
>> From: Fabio Estevam 
>>
>> Commit 001cdbbb32ef1f6 ("imx: mx6slevk: enable more DM drivers") breaks
>> MMC support in U-Boot proper on the mx6slevk_spl_defconfig target:
>>
>> U-Boot SPL 2017.09-00396-g6ca43a5 (Oct 01 2017 - 16:20:18)
>> Trying to boot from MMC1
>>
>> U-Boot 2017.09-00396-g6ca43a5 (Oct 01 2017 - 16:20:18 -0300)
>>
>> CPU:   Freescale i.MX6SL rev1.0 792 MHz (running at 396 MHz)
>> CPU:   Commercial temperature grade (0C to 95C) at 33C
>> Reset cause: POR
>> Board: MX6SLEVK
>> I2C:   ready
>> DRAM:  1 GiB
>> MMC:   FSL_SDHC: 0
>> MMC Device 1 not found
>> *** Warning - No MMC card found, using default environment
>>
>> Fix this by re-introducing the U-Boot proper mmc init code inside
>> board_mmc_init().
>>
>> Signed-off-by: Fabio Estevam 
> 
> Please disregard this patch and others I sent related to the MMC
> breakage. We are discussing in another thread a more generic way to
> fix these problems.
> 

Yes, I dropped this and "mx6slevk: Remove some DM drivers". They won't
be merged.

Best regards,
Stefano

-- 
=
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: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot