From 8dd15b43b016e6b45885313e2ea660bab4e1f683 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 25 Dec 2012 10:20:39 +0000 Subject: [PATCH 01/15] mx35pdk: Allow booting of a device tree kernel Select CONFIG_OF_LIBFDT, so that a dt kernel can be launched. Signed-off-by: Fabio Estevam --- include/configs/mx35pdk.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/configs/mx35pdk.h b/include/configs/mx35pdk.h index 88b2bd6ed4..0db92a7803 100644 --- a/include/configs/mx35pdk.h +++ b/include/configs/mx35pdk.h @@ -95,6 +95,7 @@ #include +#define CONFIG_OF_LIBFDT #define CONFIG_CMD_BOOTZ #define CONFIG_CMD_PING #define CONFIG_CMD_DHCP From aef8af6a3dbd95d77b35a23004b6256dc70fb78f Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 21 Dec 2012 06:59:04 +0000 Subject: [PATCH 02/15] mx53loco: We shouldn't hardcode a rootfs filesystem type For a generic environment, we shouldn't have a fixed rootfs filesystem so we drop it from env. Signed-off-by: Otavio Salvador --- include/configs/mx53loco.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h index e30502b4e2..5f8f52e4cd 100644 --- a/include/configs/mx53loco.h +++ b/include/configs/mx53loco.h @@ -120,11 +120,8 @@ "uimage=uImage\0" \ "mmcdev=0\0" \ "mmcpart=2\0" \ - "mmcroot=/dev/mmcblk0p3 rw\0" \ - "mmcrootfstype=ext3 rootwait\0" \ - "mmcargs=setenv bootargs console=ttymxc0,${baudrate} " \ - "root=${mmcroot} " \ - "rootfstype=${mmcrootfstype}\0" \ + "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \ + "mmcargs=setenv bootargs console=ttymxc0,${baudrate} root=${mmcroot} " \ "loadbootscript=" \ "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ "bootscript=echo Running bootscript from mmc ...; " \ From fe51f787149eda05cc68ba3616f91bbaf98f0955 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 21 Dec 2012 06:59:05 +0000 Subject: [PATCH 03/15] mx53loco: Change default loadaddr to 0x72000000 This allow use of mainline and Freescale BSP Linux kernel with same environment. Signed-off-by: Otavio Salvador --- include/configs/mx53loco.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h index 5f8f52e4cd..4cfdc0b958 100644 --- a/include/configs/mx53loco.h +++ b/include/configs/mx53loco.h @@ -112,7 +112,7 @@ #define CONFIG_ETHPRIME "FEC0" -#define CONFIG_LOADADDR 0x70800000 /* loadaddr env var */ +#define CONFIG_LOADADDR 0x72000000 /* loadaddr env var */ #define CONFIG_SYS_TEXT_BASE 0x77800000 #define CONFIG_EXTRA_ENV_SETTINGS \ From 589b1afdb5d63d0b0d8dfca57061dd24a66885b3 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 21 Dec 2012 06:59:06 +0000 Subject: [PATCH 04/15] mx6qsabrelite: Change default loadaddr to 0x12000000 This allow use of mainline and Freescale BSP Linux kernel with same environment. Signed-off-by: Otavio Salvador --- include/configs/mx6qsabrelite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index 4ce4d4c086..0f6bbb4be2 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -148,7 +148,7 @@ #define CONFIG_PREBOOT "" -#define CONFIG_LOADADDR 0x10800000 +#define CONFIG_LOADADDR 0x12000000 #define CONFIG_SYS_TEXT_BASE 0x17800000 #define CONFIG_EXTRA_ENV_SETTINGS \ From 2f994fe622dcb01a87d83eacee5df0b29f33d306 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 21 Dec 2012 06:59:07 +0000 Subject: [PATCH 05/15] mx6qsabre_common: Change default loadaddr to 0x12000000 This allow use of mainline and Freescale BSP Linux kernel with same environment. Signed-off-by: Otavio Salvador --- include/configs/mx6qsabre_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/configs/mx6qsabre_common.h b/include/configs/mx6qsabre_common.h index 0f226f790e..9a254808b9 100644 --- a/include/configs/mx6qsabre_common.h +++ b/include/configs/mx6qsabre_common.h @@ -78,7 +78,7 @@ #define CONFIG_BOOTDELAY 1 -#define CONFIG_LOADADDR 0x10800000 +#define CONFIG_LOADADDR 0x12000000 #define CONFIG_SYS_TEXT_BASE 0x17800000 #define CONFIG_EXTRA_ENV_SETTINGS \ From 54bb84115da5f43b0e23f1c57f7d1ab80748005c Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 26 Dec 2012 05:50:20 +0000 Subject: [PATCH 06/15] mx53loco: Call PMIC related functions from board_late_init() Since commit c733681 (pmic: Extend PMIC framework to support multiple instances of PMIC devices) mx53loco fails to allocate the memory for PMIC: U-Boot 2013.01-rc2-dirty (Dec 20 2012 - 15:55:01) Board: MX53 LOCO I2C: ready DRAM: 1 GiB pmic_alloc: No available memory for allocation! pmic_init: POWER allocation error! CPU: Freescale i.MX53 family rev2.0 at 800 MHz Reset cause: POR MMC: FSL_SDHC: 0, FSL_SDHC: 1 Calling the PMIC related functions at a later stage, ie, from board_late_init() fixes the issue. Reported-by: Robert Nelson Signed-off-by: Fabio Estevam Tested-by: Stefano Babic --- board/freescale/mx53loco/mx53loco.c | 10 ++++++++-- include/configs/mx53loco.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c index 2c8cb7a1cc..63a4f8baf3 100644 --- a/board/freescale/mx53loco/mx53loco.c +++ b/board/freescale/mx53loco/mx53loco.c @@ -462,12 +462,18 @@ int board_init(void) mxc_set_sata_internal_clock(); setup_iomux_i2c(); + + lcd_enable(); + + return 0; +} + +int board_late_init(void) +{ if (!power_init()) clock_1GHz(); print_cpuinfo(); - lcd_enable(); - return 0; } diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h index 4cfdc0b958..996396b99b 100644 --- a/include/configs/mx53loco.h +++ b/include/configs/mx53loco.h @@ -39,6 +39,7 @@ #define CONFIG_SYS_MALLOC_LEN (10 * 1024 * 1024) #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_BOARD_LATE_INIT #define CONFIG_MXC_GPIO #define CONFIG_REVISION_TAG From 1f75b5415083a14326449fed9b85177ca8c16dfa Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 25 Dec 2012 15:08:40 +0000 Subject: [PATCH 07/15] mxs: Add NAND fdt and ramdisk partition to m28evk Adjust the NAND partitioning layout so that there is a separate partition for the ramdisk and fdt blob on the NAND. Signed-off-by: Marek Vasut Cc: Detlev Zundel Cc: Stefano Babic Cc: Wolfgang Denk --- include/configs/m28evk.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/configs/m28evk.h b/include/configs/m28evk.h index b49ec8c7dd..36ce672361 100644 --- a/include/configs/m28evk.h +++ b/include/configs/m28evk.h @@ -178,6 +178,8 @@ "512k(environment)," \ "512k(redundant-environment)," \ "4m(kernel)," \ + "128k(fdt)," \ + "8m(ramdisk)," \ "-(filesystem)" #else #define CONFIG_ENV_IS_NOWHERE From e660c44d9e3b4b6d156e5a6dacf62ced86fac216 Mon Sep 17 00:00:00 2001 From: Ashok Date: Wed, 7 Nov 2012 07:37:15 +0000 Subject: [PATCH 08/15] mx35pdk:Use IMX_GPIO_NR macro Use IMX_GPO_NR macro Signed-off-by: Ashok Kumar Reddy Acked-by: Stefano Babic --- board/freescale/mx35pdk/mx35pdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/freescale/mx35pdk/mx35pdk.c b/board/freescale/mx35pdk/mx35pdk.c index 2aa000f238..b7f474e5ef 100644 --- a/board/freescale/mx35pdk/mx35pdk.c +++ b/board/freescale/mx35pdk/mx35pdk.c @@ -274,7 +274,7 @@ int board_late_init(void) mxc_request_iomux(MX35_PIN_COMPARE, MUX_CONFIG_GPIO); mxc_iomux_set_input(MUX_IN_GPIO1_IN_5, INPUT_CTL_PATH0); - gpio_direction_output(37, 1); + gpio_direction_output(IMX_GPIO_NR(2, 5), 1); } val = mc9sdz60_reg_read(MC9SDZ60_REG_GPIO_1) | 0x04; From fb8302bfc50c6763e20a077cba4a315404ffb727 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Sun, 30 Dec 2012 14:14:58 +0000 Subject: [PATCH 09/15] fsl_esdhc: add MMC_MODE_HC host_caps All esdhc variants we know should support high capacity MMC cards, so let's add MMC_MODE_HC host_caps unconditionally to support those MMC cards (capacity > 2 GB). Signed-off-by: Shawn Guo --- drivers/mmc/fsl_esdhc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index e93e38ac43..3d5c9c0f77 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -577,7 +577,7 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) return -1; } - mmc->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT; + mmc->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT | MMC_MODE_HC; if (caps & ESDHC_HOSTCAPBLT_HSS) mmc->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; From de7d02aeba2a8d3d2b2f688ee396cdc112fc4e29 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Sun, 30 Dec 2012 14:14:59 +0000 Subject: [PATCH 10/15] mx6qsabresd: add usdhc2 and usdhc4 support The on-board number of available usdhc devices is something board specific. The patch moves CONFIG_SYS_FSL_USDHC_NUM out of mx6qsabre_common.h and adds usdhc2 and usdhc4 support for mx6qsabresd board. To keep the default mmc device for environment same as before (usdhc3), it moves CONFIG_SYS_MMC_ENV_DEV out of mx6qsabre_common.h and changes it to 1 for mx6qsabresd. Signed-off-by: Shawn Guo --- board/freescale/mx6qsabresd/mx6qsabresd.c | 80 +++++++++++++++++++++-- include/configs/mx6qsabre_common.h | 2 - include/configs/mx6qsabreauto.h | 5 ++ include/configs/mx6qsabresd.h | 5 ++ 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/board/freescale/mx6qsabresd/mx6qsabresd.c b/board/freescale/mx6qsabresd/mx6qsabresd.c index 0240fb5479..65c4a1a4f3 100644 --- a/board/freescale/mx6qsabresd/mx6qsabresd.c +++ b/board/freescale/mx6qsabresd/mx6qsabresd.c @@ -86,6 +86,20 @@ static void setup_iomux_enet(void) gpio_set_value(IMX_GPIO_NR(1, 25), 1); } +iomux_v3_cfg_t const usdhc2_pads[] = { + MX6Q_PAD_SD2_CLK__USDHC2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD2_CMD__USDHC2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD2_DAT0__USDHC2_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD2_DAT1__USDHC2_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD2_DAT2__USDHC2_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD2_DAT3__USDHC2_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_NANDF_D4__USDHC2_DAT4 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_NANDF_D5__USDHC2_DAT5 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_NANDF_D6__USDHC2_DAT6 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_NANDF_D7__USDHC2_DAT7 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_NANDF_D2__GPIO_2_2 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */ +}; + iomux_v3_cfg_t const usdhc3_pads[] = { MX6Q_PAD_SD3_CLK__USDHC3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), MX6Q_PAD_SD3_CMD__USDHC3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), @@ -100,28 +114,82 @@ iomux_v3_cfg_t const usdhc3_pads[] = { MX6Q_PAD_NANDF_D0__GPIO_2_0 | MUX_PAD_CTRL(NO_PAD_CTRL), /* CD */ }; +iomux_v3_cfg_t const usdhc4_pads[] = { + MX6Q_PAD_SD4_CLK__USDHC4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_CMD__USDHC4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT0__USDHC4_DAT0 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT1__USDHC4_DAT1 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT2__USDHC4_DAT2 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT3__USDHC4_DAT3 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT4__USDHC4_DAT4 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT5__USDHC4_DAT5 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT6__USDHC4_DAT6 | MUX_PAD_CTRL(USDHC_PAD_CTRL), + MX6Q_PAD_SD4_DAT7__USDHC4_DAT7 | MUX_PAD_CTRL(USDHC_PAD_CTRL), +}; + static void setup_iomux_uart(void) { imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads)); } #ifdef CONFIG_FSL_ESDHC -struct fsl_esdhc_cfg usdhc_cfg[1] = { +struct fsl_esdhc_cfg usdhc_cfg[3] = { + {USDHC2_BASE_ADDR}, {USDHC3_BASE_ADDR}, + {USDHC4_BASE_ADDR}, }; +#define USDHC2_CD_GPIO IMX_GPIO_NR(2, 2) +#define USDHC3_CD_GPIO IMX_GPIO_NR(2, 0) + int board_mmc_getcd(struct mmc *mmc) { - gpio_direction_input(IMX_GPIO_NR(2, 0)); - return !gpio_get_value(IMX_GPIO_NR(2, 0)); + struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; + + switch (cfg->esdhc_base) { + case USDHC2_BASE_ADDR: + return !gpio_get_value(USDHC2_CD_GPIO); + case USDHC3_BASE_ADDR: + return !gpio_get_value(USDHC3_CD_GPIO); + default: + return 1; /* eMMC/uSDHC4 is always present */ + } } int board_mmc_init(bd_t *bis) { - imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); + int i; - usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); - return fsl_esdhc_initialize(bis, &usdhc_cfg[0]); + for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) { + switch (i) { + case 0: + imx_iomux_v3_setup_multiple_pads( + usdhc2_pads, ARRAY_SIZE(usdhc2_pads)); + gpio_direction_input(USDHC2_CD_GPIO); + usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK); + break; + case 1: + imx_iomux_v3_setup_multiple_pads( + usdhc3_pads, ARRAY_SIZE(usdhc3_pads)); + gpio_direction_input(USDHC3_CD_GPIO); + usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); + break; + case 2: + imx_iomux_v3_setup_multiple_pads( + usdhc4_pads, ARRAY_SIZE(usdhc4_pads)); + usdhc_cfg[2].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK); + break; + default: + printf("Warning: you configured more USDHC controllers" + "(%d) than supported by the board\n", i + 1); + return 0; + } + + if (fsl_esdhc_initialize(bis, &usdhc_cfg[i])) + printf("Warning: failed to initialize mmc dev %d\n", i); + } + + return 0; } #endif diff --git a/include/configs/mx6qsabre_common.h b/include/configs/mx6qsabre_common.h index 9a254808b9..bd2fb108f4 100644 --- a/include/configs/mx6qsabre_common.h +++ b/include/configs/mx6qsabre_common.h @@ -41,7 +41,6 @@ #define CONFIG_FSL_ESDHC #define CONFIG_FSL_USDHC #define CONFIG_SYS_FSL_ESDHC_ADDR 0 -#define CONFIG_SYS_FSL_USDHC_NUM 2 #define CONFIG_MMC #define CONFIG_CMD_MMC @@ -166,7 +165,6 @@ #if defined(CONFIG_ENV_IS_IN_MMC) #define CONFIG_ENV_OFFSET (6 * 64 * 1024) -#define CONFIG_SYS_MMC_ENV_DEV 0 #endif #define CONFIG_OF_LIBFDT diff --git a/include/configs/mx6qsabreauto.h b/include/configs/mx6qsabreauto.h index 760f3ce0c9..f1ff20169b 100644 --- a/include/configs/mx6qsabreauto.h +++ b/include/configs/mx6qsabreauto.h @@ -20,4 +20,9 @@ #include "mx6qsabre_common.h" +#define CONFIG_SYS_FSL_USDHC_NUM 2 +#if defined(CONFIG_ENV_IS_IN_MMC) +#define CONFIG_SYS_MMC_ENV_DEV 0 +#endif + #endif /* __MX6QSABREAUTO_CONFIG_H */ diff --git a/include/configs/mx6qsabresd.h b/include/configs/mx6qsabresd.h index 771d1297f7..227d4100f4 100644 --- a/include/configs/mx6qsabresd.h +++ b/include/configs/mx6qsabresd.h @@ -25,4 +25,9 @@ #include "mx6qsabre_common.h" +#define CONFIG_SYS_FSL_USDHC_NUM 3 +#if defined(CONFIG_ENV_IS_IN_MMC) +#define CONFIG_SYS_MMC_ENV_DEV 1 +#endif + #endif /* __MX6QSABRESD_CONFIG_H */ From 49ea0ff5cc9f015cb03440de7e2f4019158ab8d9 Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Sun, 30 Dec 2012 14:15:00 +0000 Subject: [PATCH 11/15] mx6qsabresd: use on-board eMMC to store environment It makes more sense to use on-board eMMC to store environments. The boot partition 1 is selected by default. Signed-off-by: Shawn Guo --- include/configs/mx6qsabresd.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/configs/mx6qsabresd.h b/include/configs/mx6qsabresd.h index 227d4100f4..a1d92850c8 100644 --- a/include/configs/mx6qsabresd.h +++ b/include/configs/mx6qsabresd.h @@ -27,7 +27,8 @@ #define CONFIG_SYS_FSL_USDHC_NUM 3 #if defined(CONFIG_ENV_IS_IN_MMC) -#define CONFIG_SYS_MMC_ENV_DEV 1 +#define CONFIG_SYS_MMC_ENV_DEV 2 /* eMMC/uSDHC4 */ +#define CONFIG_SYS_MMC_ENV_PART 1 /* Boot partition 1 */ #endif #endif /* __MX6QSABRESD_CONFIG_H */ From 7093f85c9e6824c153a3ddd645d5065884567305 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 27 Dec 2012 05:46:33 +0000 Subject: [PATCH 12/15] mx51evk: Remove unneeded comment Looks like the original comment came from a copy and paste from mx31ads.h. It does not have a context on mx51evk anymore, so delete it. Signed-off-by: Fabio Estevam --- include/configs/mx51evk.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/configs/mx51evk.h b/include/configs/mx51evk.h index fa0db3824b..cb3d93890c 100644 --- a/include/configs/mx51evk.h +++ b/include/configs/mx51evk.h @@ -34,10 +34,6 @@ #define CONFIG_SYS_TEXT_BASE 0x97800000 #include -/* - * Disabled for now due to build problems under Debian and a significant - * increase in the final file size: 144260 vs. 109536 Bytes. - */ #define CONFIG_CMDLINE_TAG /* enable passing of ATAGs */ #define CONFIG_SETUP_MEMORY_TAGS From d22925108e46491900815c9ec3c32122ead80d8e Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 28 Dec 2012 04:05:28 +0000 Subject: [PATCH 13/15] mx53loco: Remove unneeded 'retval' variable commit c73368150 (pmic: Extend PMIC framework to support multiple instances of PMIC devices) introduced an extra 'retval' variable, but this is not necessary since we have already the variable 'ret' in place. So use 'ret' to store the return values from the pmic related calls and remove 'retval'. Signed-off-by: Fabio Estevam --- board/freescale/mx53loco/mx53loco.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c index 63a4f8baf3..b1bfb90389 100644 --- a/board/freescale/mx53loco/mx53loco.c +++ b/board/freescale/mx53loco/mx53loco.c @@ -345,12 +345,11 @@ static int power_init(void) unsigned int val; int ret = -1; struct pmic *p; - int retval; if (!i2c_probe(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR)) { - retval = pmic_dialog_init(I2C_PMIC); - if (retval) - return retval; + ret = pmic_dialog_init(I2C_PMIC); + if (ret) + return ret; p = pmic_get("DIALOG_PMIC"); if (!p) @@ -370,9 +369,9 @@ static int power_init(void) } if (!i2c_probe(CONFIG_SYS_FSL_PMIC_I2C_ADDR)) { - retval = pmic_init(I2C_PMIC); - if (retval) - return retval; + ret = pmic_init(I2C_PMIC); + if (ret) + return ret; p = pmic_get("FSL_PMIC"); if (!p) From 085e728aa56a71f0e52bd657a441b4bf9212841a Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 28 Dec 2012 04:05:29 +0000 Subject: [PATCH 14/15] mx53loco: Improve error handling on power_init() Make the error handling more robust. Check if each one of the PMIC writes fail and if they do, just return immediately. Also, print the cause for the failures. Signed-off-by: Fabio Estevam --- board/freescale/mx53loco/mx53loco.c | 61 ++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c index b1bfb90389..60cd4f0cfb 100644 --- a/board/freescale/mx53loco/mx53loco.c +++ b/board/freescale/mx53loco/mx53loco.c @@ -343,7 +343,7 @@ static void setup_iomux_i2c(void) static int power_init(void) { unsigned int val; - int ret = -1; + int ret; struct pmic *p; if (!i2c_probe(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR)) { @@ -358,14 +358,33 @@ static int power_init(void) /* Set VDDA to 1.25V */ val = DA9052_BUCKCORE_BCOREEN | DA_BUCKCORE_VBCORE_1_250V; ret = pmic_reg_write(p, DA9053_BUCKCORE_REG, val); + if (ret) { + printf("Writing to BUCKCORE_REG failed: %d\n", ret); + return ret; + } - ret |= pmic_reg_read(p, DA9053_SUPPLY_REG, &val); + pmic_reg_read(p, DA9053_SUPPLY_REG, &val); val |= DA9052_SUPPLY_VBCOREGO; - ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, val); + ret = pmic_reg_write(p, DA9053_SUPPLY_REG, val); + if (ret) { + printf("Writing to SUPPLY_REG failed: %d\n", ret); + return ret; + } /* Set Vcc peripheral to 1.30V */ - ret |= pmic_reg_write(p, DA9053_BUCKPRO_REG, 0x62); - ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, 0x62); + ret = pmic_reg_write(p, DA9053_BUCKPRO_REG, 0x62); + if (ret) { + printf("Writing to BUCKPRO_REG failed: %d\n", ret); + return ret; + } + + ret = pmic_reg_write(p, DA9053_SUPPLY_REG, 0x62); + if (ret) { + printf("Writing to SUPPLY_REG failed: %d\n", ret); + return ret; + } + + return ret; } if (!i2c_probe(CONFIG_SYS_FSL_PMIC_I2C_ADDR)) { @@ -381,28 +400,50 @@ static int power_init(void) pmic_reg_read(p, REG_SW_0, &val); val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_250V_MC34708; ret = pmic_reg_write(p, REG_SW_0, val); + if (ret) { + printf("Writing to REG_SW_0 failed: %d\n", ret); + return ret; + } /* Set VCC as 1.30V on SW2 */ pmic_reg_read(p, REG_SW_1, &val); val = (val & ~SWx_VOLT_MASK_MC34708) | SWx_1_300V_MC34708; - ret |= pmic_reg_write(p, REG_SW_1, val); + ret = pmic_reg_write(p, REG_SW_1, val); + if (ret) { + printf("Writing to REG_SW_1 failed: %d\n", ret); + return ret; + } /* Set global reset timer to 4s */ pmic_reg_read(p, REG_POWER_CTL2, &val); val = (val & ~TIMER_MASK_MC34708) | TIMER_4S_MC34708; - ret |= pmic_reg_write(p, REG_POWER_CTL2, val); + ret = pmic_reg_write(p, REG_POWER_CTL2, val); + if (ret) { + printf("Writing to REG_POWER_CTL2 failed: %d\n", ret); + return ret; + } /* Set VUSBSEL and VUSBEN for USB PHY supply*/ pmic_reg_read(p, REG_MODE_0, &val); val |= (VUSBSEL_MC34708 | VUSBEN_MC34708); - ret |= pmic_reg_write(p, REG_MODE_0, val); + ret = pmic_reg_write(p, REG_MODE_0, val); + if (ret) { + printf("Writing to REG_MODE_0 failed: %d\n", ret); + return ret; + } /* Set SWBST to 5V in auto mode */ val = SWBST_AUTO; - ret |= pmic_reg_write(p, SWBST_CTRL, val); + ret = pmic_reg_write(p, SWBST_CTRL, val); + if (ret) { + printf("Writing to SWBST_CTRL failed: %d\n", ret); + return ret; + } + + return ret; } - return ret; + return -1; } static void clock_1GHz(void) From 1411fb37b5a8d56bececc5e6ea09d2e0670b9810 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 3 Jan 2013 08:24:33 +0000 Subject: [PATCH 15/15] tools: imximage: Load a size that is multiple of 512 In order to mx53 ROM to properly load the U-boot image, its header size should be multiple of 512 bytes. This issue was observed with gcc 4.6.2/4.7.3, which caused data aborts: U-Boot 2013.01-rc2-00172-gf8cfcf1-dirty (Dec 26 2012 - 13:13:28) Board: MX53 LOCO I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 In: serial Out: serial Err: serial CPU: Freescale i.MX53 family rev2.1 at 1000 MHz Reset cause: WDOG Net: FEC Warning: FEC using MAC address from net device Hit any key to stop autoboot: 0 data abort MAYBE you should read doc/README.arm-unaligned-accesses pc : [] lr : [] sp : af565e20 ip : af566918 fp : 00000000 r10: 00000003 r9 : affabb5b r8 : af565f58 r7 : 00000000 r6 : 36747fff r5 : af5668e8 r4 : 36747fff r3 : af5668ec r2 : af5668eb r1 : 00000000 r0 : af5668e8 Flags: NzcV IRQs off FIQs off Mode SVC_32 Resetting CPU ... resetting ... ,and this patch fixes it. Also, even though the ROUND macro is already defined in common.h, the reason for redefining it in image.h is explained by Stefano Babic: "I will remark a previous comment - even if including common.h seems a good idea to avoid duplications, it makes tools like mkimage to depend on the selected board, because _config must run. Even if this is not a problem for us u-boot developers, it becomes an issue when these tools are included in distros (like u-boot-tools in Ubuntu) and cannot be packaged." Signed-off-by: Troy Kisky Signed-off-by: Fabio Estevam --- include/image.h | 3 +++ tools/imximage.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/image.h b/include/image.h index f54d983306..3a472c9b7c 100644 --- a/include/image.h +++ b/include/image.h @@ -179,6 +179,9 @@ #define IH_MAGIC 0x27051956 /* Image Magic Number */ #define IH_NMLEN 32 /* Image Name Length */ +/* Reused from common.h */ +#define ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1)) + /* * Legacy format image header, * all data in network byte order (aka natural aka bigendian). diff --git a/tools/imximage.c b/tools/imximage.c index 63f88b6c42..a93d7eb543 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -515,7 +515,14 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd, /* Set the imx header */ (*set_imx_hdr)(imxhdr, dcd_len, params->ep, imxhdr->flash_offset); - *header_size_ptr = sbuf->st_size + imxhdr->flash_offset; + + /* + * ROM bug alert + * mx53 only loads 512 byte multiples. + * The remaining fraction of a block bytes would + * not be loaded. + */ + *header_size_ptr = ROUND(sbuf->st_size + imxhdr->flash_offset, 512); } int imximage_check_params(struct mkimage_params *params)