All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name
@ 2015-04-23  3:57 Fabio Estevam
  2015-04-23  3:57 ` [U-Boot] [PATCH 2/5] mx6cuboxi: Prepare for multi SoC support Fabio Estevam
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Fabio Estevam @ 2015-04-23  3:57 UTC (permalink / raw)
  To: u-boot

From: Fabio Estevam <fabio.estevam@freescale.com>

The correct name of the defconfig file is 'mx6cuboxi_defconfig'.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 board/solidrun/mx6cuboxi/MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/solidrun/mx6cuboxi/MAINTAINERS b/board/solidrun/mx6cuboxi/MAINTAINERS
index 3d468ed..a3506c2 100644
--- a/board/solidrun/mx6cuboxi/MAINTAINERS
+++ b/board/solidrun/mx6cuboxi/MAINTAINERS
@@ -3,4 +3,4 @@ M:	Fabio Estevam <fabio.estevam@freescale.com>
 S:	Maintained
 F:	board/solidrun/mx6cuboxi/
 F:	include/configs/mx6cuboxi.h
-F:	configs/mx6cuboxi_spl_defconfig
+F:	configs/mx6cuboxi_defconfig
-- 
1.9.1

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

* [U-Boot] [PATCH 2/5] mx6cuboxi: Prepare for multi SoC support
  2015-04-23  3:57 [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Fabio Estevam
@ 2015-04-23  3:57 ` Fabio Estevam
  2015-04-23  6:14   ` Stefano Babic
  2015-04-23  3:57 ` [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support Fabio Estevam
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Fabio Estevam @ 2015-04-23  3:57 UTC (permalink / raw)
  To: u-boot

From: Fabio Estevam <fabio.estevam@freescale.com>

Cubox-i and Hummingboard support several MX6 SoCs: mx6solo, mx6dual-lite,
mx6dual and mx6quad.

Use IOMUX_PADS() macro in order to prepare for the multi-SoC support. 
Also pass 'MX6QDL' in the defconfig to indicate it. 

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 60 ++++++++++++++++++------------------
 configs/mx6cuboxi_defconfig          |  2 +-
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index b696dcb..0377dc4 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -28,7 +28,6 @@
 #include <asm/arch/crm_regs.h>
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
-#include <asm/arch/mx6-ddr.h>
 #include <spl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -59,22 +58,22 @@ int dram_init(void)
 }
 
 static iomux_v3_cfg_t const uart1_pads[] = {
-	MX6_PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
-	MX6_PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
+	IOMUX_PADS(PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
+	IOMUX_PADS(PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
 };
 
 static iomux_v3_cfg_t const usdhc2_pads[] = {
-	MX6_PAD_SD2_CLK__SD2_CLK	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_CMD__SD2_CMD	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT0__SD2_DATA0	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT1__SD2_DATA1	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT2__SD2_DATA2	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
-	MX6_PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	IOMUX_PADS(PAD_SD2_CLK__SD2_CLK	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_CMD__SD2_CMD	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT1__SD2_DATA1	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT2__SD2_DATA2	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
 };
 
 static void setup_iomux_uart(void)
 {
-	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
+	SETUP_IOMUX_PADS(uart1_pads);
 }
 
 static struct fsl_esdhc_cfg usdhc_cfg[1] = {
@@ -88,7 +87,7 @@ int board_mmc_getcd(struct mmc *mmc)
 
 int board_mmc_init(bd_t *bis)
 {
-	imx_iomux_v3_setup_multiple_pads(usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
+	SETUP_IOMUX_PADS(usdhc2_pads);
 	usdhc_cfg[0].esdhc_base = USDHC2_BASE_ADDR;
 	usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
 	gd->arch.sdhc_clk = usdhc_cfg[0].sdhc_clk;
@@ -97,33 +96,33 @@ int board_mmc_init(bd_t *bis)
 }
 
 static iomux_v3_cfg_t const enet_pads[] = {
-	MX6_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL),
+	IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
 	/* AR8035 reset */
-	MX6_PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
+	IOMUX_PADS(PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
 	/* AR8035 interrupt */
-	MX6_PAD_DI0_PIN2__GPIO4_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL),
+	IOMUX_PADS(PAD_DI0_PIN2__GPIO4_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL)),
 	/* GPIO16 -> AR8035 25MHz */
-	MX6_PAD_GPIO_16__ENET_REF_CLK	  | MUX_PAD_CTRL(NO_PAD_CTRL),
-	MX6_PAD_RGMII_TXC__RGMII_TXC	  | MUX_PAD_CTRL(NO_PAD_CTRL),
-	MX6_PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
+	IOMUX_PADS(PAD_GPIO_16__ENET_REF_CLK	  | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC	  | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL)),
 	/* AR8035 CLK_25M --> ENET_REF_CLK (V22) */
-	MX6_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL_CLK),
-	MX6_PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
-	MX6_PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
-	MX6_PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
-	MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
+	IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL_CLK)),
+	IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
+	IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
+	IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
 };
 
 static void setup_iomux_enet(void)
 {
-	imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));
+	SETUP_IOMUX_PADS(enet_pads);
 
 	gpio_direction_output(ETH_PHY_RESET, 0);
 	mdelay(2);
@@ -175,6 +174,7 @@ int checkboard(void)
 }
 
 #ifdef CONFIG_SPL_BUILD
+#include <asm/arch/mx6-ddr.h>
 static const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = {
 	.dram_sdclk_0 =  0x00020030,
 	.dram_sdclk_1 =  0x00020030,
diff --git a/configs/mx6cuboxi_defconfig b/configs/mx6cuboxi_defconfig
index 85dc58a..4c2f0e0 100644
--- a/configs/mx6cuboxi_defconfig
+++ b/configs/mx6cuboxi_defconfig
@@ -1,5 +1,5 @@
 CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,MX6Q"
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,MX6QDL"
 CONFIG_ARM=y
 CONFIG_TARGET_MX6CUBOXI=y
 CONFIG_DM=y
-- 
1.9.1

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

* [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support
  2015-04-23  3:57 [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Fabio Estevam
  2015-04-23  3:57 ` [U-Boot] [PATCH 2/5] mx6cuboxi: Prepare for multi SoC support Fabio Estevam
@ 2015-04-23  3:57 ` Fabio Estevam
  2015-04-23  6:16   ` Stefano Babic
  2015-04-23 19:09   ` Tom Rini
  2015-04-23  3:57 ` [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard Fabio Estevam
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: Fabio Estevam @ 2015-04-23  3:57 UTC (permalink / raw)
  To: u-boot

From: Fabio Estevam <fabio.estevam@freescale.com>

Cubox-i and Hummingboard support several MX6 SoCs: mx6solo, mx6dual-lite,
mx6dual and mx6quad. Add support for the different SoC/memory sizes 
combinations.

Tested on a CuBox-i4Pro, HummingBoard-i2eX and HummingBoard-i1.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 134 ++++++++++++++++++++++++++++++++---
 1 file changed, 125 insertions(+), 9 deletions(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 0377dc4..1f240ae 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -175,7 +175,7 @@ int checkboard(void)
 
 #ifdef CONFIG_SPL_BUILD
 #include <asm/arch/mx6-ddr.h>
-static const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = {
+static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
 	.dram_sdclk_0 =  0x00020030,
 	.dram_sdclk_1 =  0x00020030,
 	.dram_cas =  0x00020030,
@@ -204,7 +204,36 @@ static const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = {
 	.dram_dqm7 =  0x00020030,
 };
 
-static const struct mx6dq_iomux_grp_regs mx6_grp_ioregs = {
+static const struct mx6sdl_iomux_ddr_regs mx6dl_ddr_ioregs = {
+	.dram_sdclk_0 = 0x00000028,
+	.dram_sdclk_1 = 0x00000028,
+	.dram_cas =	0x00000028,
+	.dram_ras =	0x00000028,
+	.dram_reset =	0x000c0028,
+	.dram_sdcke0 =	0x00003000,
+	.dram_sdcke1 =	0x00003000,
+	.dram_sdba2 =	0x00000000,
+	.dram_sdodt0 =	0x00003030,
+	.dram_sdodt1 =	0x00003030,
+	.dram_sdqs0 =	0x00000028,
+	.dram_sdqs1 =	0x00000028,
+	.dram_sdqs2 =	0x00000028,
+	.dram_sdqs3 =	0x00000028,
+	.dram_sdqs4 =	0x00000028,
+	.dram_sdqs5 =	0x00000028,
+	.dram_sdqs6 =	0x00000028,
+	.dram_sdqs7 =	0x00000028,
+	.dram_dqm0 =	0x00000028,
+	.dram_dqm1 =	0x00000028,
+	.dram_dqm2 =	0x00000028,
+	.dram_dqm3 =	0x00000028,
+	.dram_dqm4 =	0x00000028,
+	.dram_dqm5 =	0x00000028,
+	.dram_dqm6 =	0x00000028,
+	.dram_dqm7 =	0x00000028,
+};
+
+static const struct mx6dq_iomux_grp_regs mx6q_grp_ioregs = {
 	.grp_ddr_type =  0x000C0000,
 	.grp_ddrmode_ctl =  0x00020000,
 	.grp_ddrpke =  0x00000000,
@@ -221,7 +250,25 @@ static const struct mx6dq_iomux_grp_regs mx6_grp_ioregs = {
 	.grp_b7ds =  0x00000030,
 };
 
-static const struct mx6_mmdc_calibration mx6_mmcd_calib = {
+static const struct mx6sdl_iomux_grp_regs mx6sdl_grp_ioregs = {
+	.grp_ddr_type = 0x000c0000,
+	.grp_ddrmode_ctl = 0x00020000,
+	.grp_ddrpke = 0x00000000,
+	.grp_addds = 0x00000028,
+	.grp_ctlds = 0x00000028,
+	.grp_ddrmode = 0x00020000,
+	.grp_b0ds = 0x00000028,
+	.grp_b1ds = 0x00000028,
+	.grp_b2ds = 0x00000028,
+	.grp_b3ds = 0x00000028,
+	.grp_b4ds = 0x00000028,
+	.grp_b5ds = 0x00000028,
+	.grp_b6ds = 0x00000028,
+	.grp_b7ds = 0x00000028,
+};
+
+/* microSOM with Dual processor and 1GB memory */
+static const struct mx6_mmdc_calibration mx6q_1g_mmcd_calib = {
 	.p0_mpwldectrl0 =  0x00000000,
 	.p0_mpwldectrl1 =  0x00000000,
 	.p1_mpwldectrl0 =  0x00000000,
@@ -236,7 +283,49 @@ static const struct mx6_mmdc_calibration mx6_mmcd_calib = {
 	.p1_mpwrdlctl =    0x422a423c,
 };
 
-static struct mx6_ddr3_cfg mem_ddr = {
+/* microSOM with Quad processor and 2GB memory */
+static const struct mx6_mmdc_calibration mx6q_2g_mmcd_calib = {
+	.p0_mpwldectrl0 =  0x00000000,
+	.p0_mpwldectrl1 =  0x00000000,
+	.p1_mpwldectrl0 =  0x00000000,
+	.p1_mpwldectrl1 =  0x00000000,
+	.p0_mpdgctrl0 =    0x0314031c,
+	.p0_mpdgctrl1 =    0x023e0304,
+	.p1_mpdgctrl0 =    0x03240330,
+	.p1_mpdgctrl1 =    0x03180260,
+	.p0_mprddlctl =    0x3630323c,
+	.p1_mprddlctl =    0x3436283a,
+	.p0_mpwrdlctl =    0x36344038,
+	.p1_mpwrdlctl =    0x422a423c,
+};
+
+/* microSOM with Solo processor and 512MB memory */
+static const struct mx6_mmdc_calibration mx6dl_512m_mmcd_calib = {
+	.p0_mpwldectrl0 = 0x0045004D,
+	.p0_mpwldectrl1 = 0x003A0047,
+	.p0_mpdgctrl0 =   0x023C0224,
+	.p0_mpdgctrl1 =   0x02000220,
+	.p0_mprddlctl =   0x44444846,
+	.p0_mpwrdlctl =   0x32343032,
+};
+
+/* microSOM with Dual lite processor and 1GB memory */
+static const struct mx6_mmdc_calibration mx6dl_1g_mmcd_calib = {
+	.p0_mpwldectrl0 =  0x0045004D,
+	.p0_mpwldectrl1 =  0x003A0047,
+	.p1_mpwldectrl0 =  0x001F001F,
+	.p1_mpwldectrl1 =  0x00210035,
+	.p0_mpdgctrl0 =    0x023C0224,
+	.p0_mpdgctrl1 =    0x02000220,
+	.p1_mpdgctrl0 =    0x02200220,
+	.p1_mpdgctrl1 =    0x02000220,
+	.p0_mprddlctl =    0x44444846,
+	.p1_mprddlctl =    0x4042463C,
+	.p0_mpwrdlctl =    0x32343032,
+	.p1_mpwrdlctl =    0x36363430,
+};
+
+static struct mx6_ddr3_cfg mem_ddr_2g = {
 	.mem_speed = 1600,
 	.density   = 2,
 	.width     = 16,
@@ -250,6 +339,19 @@ static struct mx6_ddr3_cfg mem_ddr = {
 	.SRT       = 1,
 };
 
+static struct mx6_ddr3_cfg mem_ddr_4g = {
+	.mem_speed = 1600,
+	.density = 4,
+	.width = 16,
+	.banks = 8,
+	.rowaddr = 15,
+	.coladdr = 10,
+	.pagesz = 2,
+	.trcd = 1375,
+	.trcmin = 4875,
+	.trasmin = 3500,
+};
+
 static void ccgr_init(void)
 {
 	struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
@@ -278,11 +380,11 @@ static void gpr_init(void)
  * This section requires the differentiation between Solidrun mx6 boards, but
  * for now, it will configure only for the mx6dual hummingboard version.
  */
-static void spl_dram_init(void)
+static void spl_dram_init(int width)
 {
 	struct mx6_ddr_sysinfo sysinfo = {
 		/* width of data bus: 0=16, 1=32, 2=64 */
-		.dsize = 2,
+		.dsize = width / 32,
 		/* config for full 4GB range so that get_mem_size() works */
 		.cs_density = 32,	/* 32Gb per CS */
 		.ncs = 1,		/* single chip select */
@@ -297,8 +399,19 @@ static void spl_dram_init(void)
 		.rst_to_cke = 0x23,	/* 33 cycles, 500us (JEDEC default) */
 	};
 
-	mx6dq_dram_iocfg(64, &mx6_ddr_ioregs, &mx6_grp_ioregs);
-	mx6_dram_cfg(&sysinfo, &mx6_mmcd_calib, &mem_ddr);
+	if (is_cpu_type(MXC_CPU_MX6D) || is_cpu_type(MXC_CPU_MX6Q))
+		mx6dq_dram_iocfg(width, &mx6q_ddr_ioregs, &mx6q_grp_ioregs);
+	else
+		mx6sdl_dram_iocfg(width, &mx6dl_ddr_ioregs, &mx6sdl_grp_ioregs);
+
+	if (is_cpu_type(MXC_CPU_MX6D))
+		mx6_dram_cfg(&sysinfo, &mx6q_1g_mmcd_calib, &mem_ddr_2g);
+	else if (is_cpu_type(MXC_CPU_MX6Q))
+		mx6_dram_cfg(&sysinfo, &mx6q_2g_mmcd_calib, &mem_ddr_4g);
+	else if (is_cpu_type(MXC_CPU_MX6DL))
+		mx6_dram_cfg(&sysinfo, &mx6q_1g_mmcd_calib, &mem_ddr_2g);
+	else if (is_cpu_type(MXC_CPU_MX6SOLO))
+		mx6_dram_cfg(&sysinfo, &mx6dl_512m_mmcd_calib, &mem_ddr_2g);
 }
 
 void board_init_f(ulong dummy)
@@ -319,7 +432,10 @@ void board_init_f(ulong dummy)
 	preloader_console_init();
 
 	/* DDR initialization */
-	spl_dram_init();
+	if (is_cpu_type(MXC_CPU_MX6SOLO))
+		spl_dram_init(32);
+	else
+		spl_dram_init(64);
 
 	/* Clear the BSS. */
 	memset(__bss_start, 0, __bss_end - __bss_start);
-- 
1.9.1

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

* [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard
  2015-04-23  3:57 [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Fabio Estevam
  2015-04-23  3:57 ` [U-Boot] [PATCH 2/5] mx6cuboxi: Prepare for multi SoC support Fabio Estevam
  2015-04-23  3:57 ` [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support Fabio Estevam
@ 2015-04-23  3:57 ` Fabio Estevam
  2015-04-23  6:16   ` Stefano Babic
  2015-04-23 14:38   ` Nikolay Dimitrov
  2015-04-23  3:57 ` [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable Fabio Estevam
  2015-04-23  6:14 ` [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Stefano Babic
  4 siblings, 2 replies; 17+ messages in thread
From: Fabio Estevam @ 2015-04-23  3:57 UTC (permalink / raw)
  To: u-boot

From: Fabio Estevam <fabio.estevam@freescale.com>

Introduce is_hummingboard() function that reads GPIOs that can distinguish
between Cubox-i and Hummingboard.

Print the board name accordingly.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 41 +++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 1f240ae..83410b2 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -71,6 +71,12 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
 	IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
 };
 
+static iomux_v3_cfg_t const hb_cbi_sense[] = {
+	/* These pins are for sensing if it is a CuBox-i or a HummingBoard */
+	IOMUX_PADS(PAD_KEY_ROW1__GPIO4_IO09  | MUX_PAD_CTRL(UART_PAD_CTRL)),
+	IOMUX_PADS(PAD_EIM_DA4__GPIO3_IO04   | MUX_PAD_CTRL(UART_PAD_CTRL)),
+};
+
 static void setup_iomux_uart(void)
 {
 	SETUP_IOMUX_PADS(uart1_pads);
@@ -167,9 +173,42 @@ int board_init(void)
 	return 0;
 }
 
+static bool is_hummingboard(void)
+{
+	int val1, val2;
+
+	SETUP_IOMUX_PADS(hb_cbi_sense);
+
+	gpio_direction_input(IMX_GPIO_NR(4, 9));
+	gpio_direction_input(IMX_GPIO_NR(3, 4));
+
+	val1 = gpio_get_value(IMX_GPIO_NR(4, 9));
+	val2 = gpio_get_value(IMX_GPIO_NR(3, 4));
+
+	/*
+	 * Machine selection -
+	 * Machine        val1, val2
+	 * -------------------------
+	 * HB rev 3.x     x     0
+	 * CBi            0     1
+	 * HB             1     1
+	 */
+
+	if (val2 == 0)
+		return true;
+	else if (val1 == 0)
+		return false;
+	else
+		return true;
+}
+
 int checkboard(void)
 {
-	puts("Board: MX6 Hummingboard\n");
+	if (is_hummingboard())
+		puts("Board: MX6 Hummingboard\n");
+	else
+		puts("Board: MX6 Cubox-i\n");
+
 	return 0;
 }
 
-- 
1.9.1

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

* [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable
  2015-04-23  3:57 [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Fabio Estevam
                   ` (2 preceding siblings ...)
  2015-04-23  3:57 ` [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard Fabio Estevam
@ 2015-04-23  3:57 ` Fabio Estevam
  2015-04-23  6:13   ` Stefano Babic
  2015-04-23 18:47   ` [U-Boot] [U-Boot, " Vagrant Cascadian
  2015-04-23  6:14 ` [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Stefano Babic
  4 siblings, 2 replies; 17+ messages in thread
From: Fabio Estevam @ 2015-04-23  3:57 UTC (permalink / raw)
  To: u-boot

From: Fabio Estevam <fabio.estevam@freescale.com>

Instead of hardcoding the 'fdt_file' variable, let's introduce a new
function - build_dts_name(), that can build the dtb filename on the fly.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 24 ++++++++++++++++++++++++
 include/configs/mx6cuboxi.h          |  3 +--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 83410b2..1c24a55 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -212,6 +212,30 @@ int checkboard(void)
 	return 0;
 }
 
+static const char *build_dts_name(void)
+{
+	char *dt_prefix = "unknown";
+	char *dt_suffix = "unknown";
+
+	if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
+		dt_prefix = "imx6q";
+	else if (is_cpu_type(MXC_CPU_MX6SOLO) || is_cpu_type(MXC_CPU_MX6DL))
+		dt_prefix = "imx6dl";
+
+	if (is_hummingboard())
+		dt_suffix = "-hummingboard.dtb";
+	else
+		dt_suffix = "-cubox-i.dtb";
+
+	return strcat(dt_prefix, dt_suffix);
+}
+
+int misc_init_r(void)
+{
+	setenv("fdt_file", build_dts_name());
+	return 0;
+}
+
 #ifdef CONFIG_SPL_BUILD
 #include <asm/arch/mx6-ddr.h>
 static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 5d58b16..504a81c 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -29,6 +29,7 @@
 
 #define CONFIG_SYS_MALLOC_LEN		(2 * SZ_1M)
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_MISC_INIT_R
 #define CONFIG_MXC_GPIO
 #define CONFIG_MXC_UART
 #define CONFIG_CMD_FUSE
@@ -81,14 +82,12 @@
 #define CONFIG_MXC_UART_BASE	UART1_BASE
 #define CONFIG_CONSOLE_DEV	"ttymxc0"
 #define CONFIG_MMCROOT		"/dev/mmcblk0p2"
-#define CONFIG_DEFAULT_FDT_FILE	"imx6q-hummingboard.dtb"
 #define CONFIG_SYS_FSL_USDHC_NUM	1
 #define CONFIG_SYS_MMC_ENV_DEV		0	/* SDHC2 */
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"script=boot.scr\0" \
 	"image=zImage\0" \
-	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
 	"fdt_addr=0x18000000\0" \
 	"boot_fdt=try\0" \
 	"ip_dyn=yes\0" \
-- 
1.9.1

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

* [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable
  2015-04-23  3:57 ` [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable Fabio Estevam
@ 2015-04-23  6:13   ` Stefano Babic
  2015-04-23 17:18     ` Fabio Estevam
  2015-04-23 19:10     ` Tom Rini
  2015-04-23 18:47   ` [U-Boot] [U-Boot, " Vagrant Cascadian
  1 sibling, 2 replies; 17+ messages in thread
From: Stefano Babic @ 2015-04-23  6:13 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

On 23/04/2015 05:57, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Instead of hardcoding the 'fdt_file' variable, let's introduce a new
> function - build_dts_name(), that can build the dtb filename on the fly.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  board/solidrun/mx6cuboxi/mx6cuboxi.c | 24 ++++++++++++++++++++++++
>  include/configs/mx6cuboxi.h          |  3 +--
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 83410b2..1c24a55 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -212,6 +212,30 @@ int checkboard(void)
>  	return 0;
>  }
>  
> +static const char *build_dts_name(void)
> +{
> +	char *dt_prefix = "unknown";
> +	char *dt_suffix = "unknown";
> +
> +	if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
> +		dt_prefix = "imx6q";
> +	else if (is_cpu_type(MXC_CPU_MX6SOLO) || is_cpu_type(MXC_CPU_MX6DL))
> +		dt_prefix = "imx6dl";
> +
> +	if (is_hummingboard())
> +		dt_suffix = "-hummingboard.dtb";
> +	else
> +		dt_suffix = "-cubox-i.dtb";
> +
> +	return strcat(dt_prefix, dt_suffix);
> +}
> +

I admit I do not like a lot to have C code setting / fixing the
environment. This has the drawback that when a user try to set the
environment from the console as he wants, he cannot because the code has
reverted back and it is not easy to track. I would like to propose
another solution.

What about to export your is_hummingboard() function as U-Boot command ?
You can then use it in U-Boot scripts, and the correct fdt name can be
set in the "bootcmd" variable. Something like "if is_humming;then ..."

And if a user wants to use other names, he can because it is not hard-coded.


> +int misc_init_r(void)
> +{
> +	setenv("fdt_file", build_dts_name());
> +	return 0;
> +}
> +
>  #ifdef CONFIG_SPL_BUILD
>  #include <asm/arch/mx6-ddr.h>
>  static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
> diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
> index 5d58b16..504a81c 100644
> --- a/include/configs/mx6cuboxi.h
> +++ b/include/configs/mx6cuboxi.h
> @@ -29,6 +29,7 @@
>  
>  #define CONFIG_SYS_MALLOC_LEN		(2 * SZ_1M)
>  #define CONFIG_BOARD_EARLY_INIT_F
> +#define CONFIG_MISC_INIT_R
>  #define CONFIG_MXC_GPIO
>  #define CONFIG_MXC_UART
>  #define CONFIG_CMD_FUSE
> @@ -81,14 +82,12 @@
>  #define CONFIG_MXC_UART_BASE	UART1_BASE
>  #define CONFIG_CONSOLE_DEV	"ttymxc0"
>  #define CONFIG_MMCROOT		"/dev/mmcblk0p2"
> -#define CONFIG_DEFAULT_FDT_FILE	"imx6q-hummingboard.dtb"
>  #define CONFIG_SYS_FSL_USDHC_NUM	1
>  #define CONFIG_SYS_MMC_ENV_DEV		0	/* SDHC2 */
>  
>  #define CONFIG_EXTRA_ENV_SETTINGS \
>  	"script=boot.scr\0" \
>  	"image=zImage\0" \
> -	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \

I do not exclude that the board will switch to distro environment, and
we will have a strong dependency with the code then.

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: sbabic at denx.de
=====================================================================

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

* [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name
  2015-04-23  3:57 [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Fabio Estevam
                   ` (3 preceding siblings ...)
  2015-04-23  3:57 ` [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable Fabio Estevam
@ 2015-04-23  6:14 ` Stefano Babic
  4 siblings, 0 replies; 17+ messages in thread
From: Stefano Babic @ 2015-04-23  6:14 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

On 23/04/2015 05:57, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> The correct name of the defconfig file is 'mx6cuboxi_defconfig'.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  board/solidrun/mx6cuboxi/MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/solidrun/mx6cuboxi/MAINTAINERS b/board/solidrun/mx6cuboxi/MAINTAINERS
> index 3d468ed..a3506c2 100644
> --- a/board/solidrun/mx6cuboxi/MAINTAINERS
> +++ b/board/solidrun/mx6cuboxi/MAINTAINERS
> @@ -3,4 +3,4 @@ M:	Fabio Estevam <fabio.estevam@freescale.com>
>  S:	Maintained
>  F:	board/solidrun/mx6cuboxi/
>  F:	include/configs/mx6cuboxi.h
> -F:	configs/mx6cuboxi_spl_defconfig
> +F:	configs/mx6cuboxi_defconfig
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [PATCH 2/5] mx6cuboxi: Prepare for multi SoC support
  2015-04-23  3:57 ` [U-Boot] [PATCH 2/5] mx6cuboxi: Prepare for multi SoC support Fabio Estevam
@ 2015-04-23  6:14   ` Stefano Babic
  0 siblings, 0 replies; 17+ messages in thread
From: Stefano Babic @ 2015-04-23  6:14 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

On 23/04/2015 05:57, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Cubox-i and Hummingboard support several MX6 SoCs: mx6solo, mx6dual-lite,
> mx6dual and mx6quad.
> 
> Use IOMUX_PADS() macro in order to prepare for the multi-SoC support. 
> Also pass 'MX6QDL' in the defconfig to indicate it. 
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  board/solidrun/mx6cuboxi/mx6cuboxi.c | 60 ++++++++++++++++++------------------
>  configs/mx6cuboxi_defconfig          |  2 +-
>  2 files changed, 31 insertions(+), 31 deletions(-)
> 
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index b696dcb..0377dc4 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -28,7 +28,6 @@
>  #include <asm/arch/crm_regs.h>
>  #include <asm/io.h>
>  #include <asm/arch/sys_proto.h>
> -#include <asm/arch/mx6-ddr.h>
>  #include <spl.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
> @@ -59,22 +58,22 @@ int dram_init(void)
>  }
>  
>  static iomux_v3_cfg_t const uart1_pads[] = {
> -	MX6_PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
> -	MX6_PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
> +	IOMUX_PADS(PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
> +	IOMUX_PADS(PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
>  };
>  
>  static iomux_v3_cfg_t const usdhc2_pads[] = {
> -	MX6_PAD_SD2_CLK__SD2_CLK	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
> -	MX6_PAD_SD2_CMD__SD2_CMD	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
> -	MX6_PAD_SD2_DAT0__SD2_DATA0	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
> -	MX6_PAD_SD2_DAT1__SD2_DATA1	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
> -	MX6_PAD_SD2_DAT2__SD2_DATA2	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
> -	MX6_PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL),
> +	IOMUX_PADS(PAD_SD2_CLK__SD2_CLK	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
> +	IOMUX_PADS(PAD_SD2_CMD__SD2_CMD	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
> +	IOMUX_PADS(PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
> +	IOMUX_PADS(PAD_SD2_DAT1__SD2_DATA1	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
> +	IOMUX_PADS(PAD_SD2_DAT2__SD2_DATA2	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
> +	IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
>  };
>  
>  static void setup_iomux_uart(void)
>  {
> -	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
> +	SETUP_IOMUX_PADS(uart1_pads);
>  }
>  
>  static struct fsl_esdhc_cfg usdhc_cfg[1] = {
> @@ -88,7 +87,7 @@ int board_mmc_getcd(struct mmc *mmc)
>  
>  int board_mmc_init(bd_t *bis)
>  {
> -	imx_iomux_v3_setup_multiple_pads(usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
> +	SETUP_IOMUX_PADS(usdhc2_pads);
>  	usdhc_cfg[0].esdhc_base = USDHC2_BASE_ADDR;
>  	usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
>  	gd->arch.sdhc_clk = usdhc_cfg[0].sdhc_clk;
> @@ -97,33 +96,33 @@ int board_mmc_init(bd_t *bis)
>  }
>  
>  static iomux_v3_cfg_t const enet_pads[] = {
> -	MX6_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL),
> +	IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
>  	/* AR8035 reset */
> -	MX6_PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
> +	IOMUX_PADS(PAD_KEY_ROW4__GPIO4_IO15 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
>  	/* AR8035 interrupt */
> -	MX6_PAD_DI0_PIN2__GPIO4_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL),
> +	IOMUX_PADS(PAD_DI0_PIN2__GPIO4_IO18 | MUX_PAD_CTRL(NO_PAD_CTRL)),
>  	/* GPIO16 -> AR8035 25MHz */
> -	MX6_PAD_GPIO_16__ENET_REF_CLK	  | MUX_PAD_CTRL(NO_PAD_CTRL),
> -	MX6_PAD_RGMII_TXC__RGMII_TXC	  | MUX_PAD_CTRL(NO_PAD_CTRL),
> -	MX6_PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
> +	IOMUX_PADS(PAD_GPIO_16__ENET_REF_CLK	  | MUX_PAD_CTRL(NO_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC	  | MUX_PAD_CTRL(NO_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL)),
>  	/* AR8035 CLK_25M --> ENET_REF_CLK (V22) */
> -	MX6_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL_CLK),
> -	MX6_PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
> -	MX6_PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
> -	MX6_PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
> -	MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL_PD),
> +	IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL_CLK)),
> +	IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
> +	IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
> +	IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)),
> +	IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL_PD)),
>  };
>  
>  static void setup_iomux_enet(void)
>  {
> -	imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));
> +	SETUP_IOMUX_PADS(enet_pads);
>  
>  	gpio_direction_output(ETH_PHY_RESET, 0);
>  	mdelay(2);
> @@ -175,6 +174,7 @@ int checkboard(void)
>  }
>  
>  #ifdef CONFIG_SPL_BUILD
> +#include <asm/arch/mx6-ddr.h>
>  static const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = {
>  	.dram_sdclk_0 =  0x00020030,
>  	.dram_sdclk_1 =  0x00020030,
> diff --git a/configs/mx6cuboxi_defconfig b/configs/mx6cuboxi_defconfig
> index 85dc58a..4c2f0e0 100644
> --- a/configs/mx6cuboxi_defconfig
> +++ b/configs/mx6cuboxi_defconfig
> @@ -1,5 +1,5 @@
>  CONFIG_SPL=y
> -CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,MX6Q"
> +CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/imx-common/spl_sd.cfg,MX6QDL"
>  CONFIG_ARM=y
>  CONFIG_TARGET_MX6CUBOXI=y
>  CONFIG_DM=y
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic


-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support
  2015-04-23  3:57 ` [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support Fabio Estevam
@ 2015-04-23  6:16   ` Stefano Babic
  2015-04-23 19:09   ` Tom Rini
  1 sibling, 0 replies; 17+ messages in thread
From: Stefano Babic @ 2015-04-23  6:16 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

On 23/04/2015 05:57, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Cubox-i and Hummingboard support several MX6 SoCs: mx6solo, mx6dual-lite,
> mx6dual and mx6quad. Add support for the different SoC/memory sizes 
> combinations.
> 
> Tested on a CuBox-i4Pro, HummingBoard-i2eX and HummingBoard-i1.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  board/solidrun/mx6cuboxi/mx6cuboxi.c | 134 ++++++++++++++++++++++++++++++++---
>  1 file changed, 125 insertions(+), 9 deletions(-)
> 
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 0377dc4..1f240ae 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -175,7 +175,7 @@ int checkboard(void)
>  
>  #ifdef CONFIG_SPL_BUILD
>  #include <asm/arch/mx6-ddr.h>
> -static const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = {
> +static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
>  	.dram_sdclk_0 =  0x00020030,
>  	.dram_sdclk_1 =  0x00020030,
>  	.dram_cas =  0x00020030,
> @@ -204,7 +204,36 @@ static const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = {
>  	.dram_dqm7 =  0x00020030,
>  };
>  
> -static const struct mx6dq_iomux_grp_regs mx6_grp_ioregs = {
> +static const struct mx6sdl_iomux_ddr_regs mx6dl_ddr_ioregs = {
> +	.dram_sdclk_0 = 0x00000028,
> +	.dram_sdclk_1 = 0x00000028,
> +	.dram_cas =	0x00000028,
> +	.dram_ras =	0x00000028,
> +	.dram_reset =	0x000c0028,
> +	.dram_sdcke0 =	0x00003000,
> +	.dram_sdcke1 =	0x00003000,
> +	.dram_sdba2 =	0x00000000,
> +	.dram_sdodt0 =	0x00003030,
> +	.dram_sdodt1 =	0x00003030,
> +	.dram_sdqs0 =	0x00000028,
> +	.dram_sdqs1 =	0x00000028,
> +	.dram_sdqs2 =	0x00000028,
> +	.dram_sdqs3 =	0x00000028,
> +	.dram_sdqs4 =	0x00000028,
> +	.dram_sdqs5 =	0x00000028,
> +	.dram_sdqs6 =	0x00000028,
> +	.dram_sdqs7 =	0x00000028,
> +	.dram_dqm0 =	0x00000028,
> +	.dram_dqm1 =	0x00000028,
> +	.dram_dqm2 =	0x00000028,
> +	.dram_dqm3 =	0x00000028,
> +	.dram_dqm4 =	0x00000028,
> +	.dram_dqm5 =	0x00000028,
> +	.dram_dqm6 =	0x00000028,
> +	.dram_dqm7 =	0x00000028,
> +};
> +
> +static const struct mx6dq_iomux_grp_regs mx6q_grp_ioregs = {
>  	.grp_ddr_type =  0x000C0000,
>  	.grp_ddrmode_ctl =  0x00020000,
>  	.grp_ddrpke =  0x00000000,
> @@ -221,7 +250,25 @@ static const struct mx6dq_iomux_grp_regs mx6_grp_ioregs = {
>  	.grp_b7ds =  0x00000030,
>  };
>  
> -static const struct mx6_mmdc_calibration mx6_mmcd_calib = {
> +static const struct mx6sdl_iomux_grp_regs mx6sdl_grp_ioregs = {
> +	.grp_ddr_type = 0x000c0000,
> +	.grp_ddrmode_ctl = 0x00020000,
> +	.grp_ddrpke = 0x00000000,
> +	.grp_addds = 0x00000028,
> +	.grp_ctlds = 0x00000028,
> +	.grp_ddrmode = 0x00020000,
> +	.grp_b0ds = 0x00000028,
> +	.grp_b1ds = 0x00000028,
> +	.grp_b2ds = 0x00000028,
> +	.grp_b3ds = 0x00000028,
> +	.grp_b4ds = 0x00000028,
> +	.grp_b5ds = 0x00000028,
> +	.grp_b6ds = 0x00000028,
> +	.grp_b7ds = 0x00000028,
> +};
> +
> +/* microSOM with Dual processor and 1GB memory */
> +static const struct mx6_mmdc_calibration mx6q_1g_mmcd_calib = {
>  	.p0_mpwldectrl0 =  0x00000000,
>  	.p0_mpwldectrl1 =  0x00000000,
>  	.p1_mpwldectrl0 =  0x00000000,
> @@ -236,7 +283,49 @@ static const struct mx6_mmdc_calibration mx6_mmcd_calib = {
>  	.p1_mpwrdlctl =    0x422a423c,
>  };
>  
> -static struct mx6_ddr3_cfg mem_ddr = {
> +/* microSOM with Quad processor and 2GB memory */
> +static const struct mx6_mmdc_calibration mx6q_2g_mmcd_calib = {
> +	.p0_mpwldectrl0 =  0x00000000,
> +	.p0_mpwldectrl1 =  0x00000000,
> +	.p1_mpwldectrl0 =  0x00000000,
> +	.p1_mpwldectrl1 =  0x00000000,
> +	.p0_mpdgctrl0 =    0x0314031c,
> +	.p0_mpdgctrl1 =    0x023e0304,
> +	.p1_mpdgctrl0 =    0x03240330,
> +	.p1_mpdgctrl1 =    0x03180260,
> +	.p0_mprddlctl =    0x3630323c,
> +	.p1_mprddlctl =    0x3436283a,
> +	.p0_mpwrdlctl =    0x36344038,
> +	.p1_mpwrdlctl =    0x422a423c,
> +};
> +
> +/* microSOM with Solo processor and 512MB memory */
> +static const struct mx6_mmdc_calibration mx6dl_512m_mmcd_calib = {
> +	.p0_mpwldectrl0 = 0x0045004D,
> +	.p0_mpwldectrl1 = 0x003A0047,
> +	.p0_mpdgctrl0 =   0x023C0224,
> +	.p0_mpdgctrl1 =   0x02000220,
> +	.p0_mprddlctl =   0x44444846,
> +	.p0_mpwrdlctl =   0x32343032,
> +};
> +
> +/* microSOM with Dual lite processor and 1GB memory */
> +static const struct mx6_mmdc_calibration mx6dl_1g_mmcd_calib = {
> +	.p0_mpwldectrl0 =  0x0045004D,
> +	.p0_mpwldectrl1 =  0x003A0047,
> +	.p1_mpwldectrl0 =  0x001F001F,
> +	.p1_mpwldectrl1 =  0x00210035,
> +	.p0_mpdgctrl0 =    0x023C0224,
> +	.p0_mpdgctrl1 =    0x02000220,
> +	.p1_mpdgctrl0 =    0x02200220,
> +	.p1_mpdgctrl1 =    0x02000220,
> +	.p0_mprddlctl =    0x44444846,
> +	.p1_mprddlctl =    0x4042463C,
> +	.p0_mpwrdlctl =    0x32343032,
> +	.p1_mpwrdlctl =    0x36363430,
> +};
> +
> +static struct mx6_ddr3_cfg mem_ddr_2g = {
>  	.mem_speed = 1600,
>  	.density   = 2,
>  	.width     = 16,
> @@ -250,6 +339,19 @@ static struct mx6_ddr3_cfg mem_ddr = {
>  	.SRT       = 1,
>  };
>  
> +static struct mx6_ddr3_cfg mem_ddr_4g = {
> +	.mem_speed = 1600,
> +	.density = 4,
> +	.width = 16,
> +	.banks = 8,
> +	.rowaddr = 15,
> +	.coladdr = 10,
> +	.pagesz = 2,
> +	.trcd = 1375,
> +	.trcmin = 4875,
> +	.trasmin = 3500,
> +};
> +
>  static void ccgr_init(void)
>  {
>  	struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
> @@ -278,11 +380,11 @@ static void gpr_init(void)
>   * This section requires the differentiation between Solidrun mx6 boards, but
>   * for now, it will configure only for the mx6dual hummingboard version.
>   */
> -static void spl_dram_init(void)
> +static void spl_dram_init(int width)
>  {
>  	struct mx6_ddr_sysinfo sysinfo = {
>  		/* width of data bus: 0=16, 1=32, 2=64 */
> -		.dsize = 2,
> +		.dsize = width / 32,
>  		/* config for full 4GB range so that get_mem_size() works */
>  		.cs_density = 32,	/* 32Gb per CS */
>  		.ncs = 1,		/* single chip select */
> @@ -297,8 +399,19 @@ static void spl_dram_init(void)
>  		.rst_to_cke = 0x23,	/* 33 cycles, 500us (JEDEC default) */
>  	};
>  
> -	mx6dq_dram_iocfg(64, &mx6_ddr_ioregs, &mx6_grp_ioregs);
> -	mx6_dram_cfg(&sysinfo, &mx6_mmcd_calib, &mem_ddr);
> +	if (is_cpu_type(MXC_CPU_MX6D) || is_cpu_type(MXC_CPU_MX6Q))
> +		mx6dq_dram_iocfg(width, &mx6q_ddr_ioregs, &mx6q_grp_ioregs);
> +	else
> +		mx6sdl_dram_iocfg(width, &mx6dl_ddr_ioregs, &mx6sdl_grp_ioregs);
> +
> +	if (is_cpu_type(MXC_CPU_MX6D))
> +		mx6_dram_cfg(&sysinfo, &mx6q_1g_mmcd_calib, &mem_ddr_2g);
> +	else if (is_cpu_type(MXC_CPU_MX6Q))
> +		mx6_dram_cfg(&sysinfo, &mx6q_2g_mmcd_calib, &mem_ddr_4g);
> +	else if (is_cpu_type(MXC_CPU_MX6DL))
> +		mx6_dram_cfg(&sysinfo, &mx6q_1g_mmcd_calib, &mem_ddr_2g);
> +	else if (is_cpu_type(MXC_CPU_MX6SOLO))
> +		mx6_dram_cfg(&sysinfo, &mx6dl_512m_mmcd_calib, &mem_ddr_2g);
>  }
>  
>  void board_init_f(ulong dummy)
> @@ -319,7 +432,10 @@ void board_init_f(ulong dummy)
>  	preloader_console_init();
>  
>  	/* DDR initialization */
> -	spl_dram_init();
> +	if (is_cpu_type(MXC_CPU_MX6SOLO))
> +		spl_dram_init(32);
> +	else
> +		spl_dram_init(64);
>  
>  	/* Clear the BSS. */
>  	memset(__bss_start, 0, __bss_end - __bss_start);
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard
  2015-04-23  3:57 ` [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard Fabio Estevam
@ 2015-04-23  6:16   ` Stefano Babic
  2015-04-23 14:38   ` Nikolay Dimitrov
  1 sibling, 0 replies; 17+ messages in thread
From: Stefano Babic @ 2015-04-23  6:16 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

On 23/04/2015 05:57, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Introduce is_hummingboard() function that reads GPIOs that can distinguish
> between Cubox-i and Hummingboard.
> 
> Print the board name accordingly.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  board/solidrun/mx6cuboxi/mx6cuboxi.c | 41 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 1f240ae..83410b2 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -71,6 +71,12 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
>  	IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
>  };
>  
> +static iomux_v3_cfg_t const hb_cbi_sense[] = {
> +	/* These pins are for sensing if it is a CuBox-i or a HummingBoard */
> +	IOMUX_PADS(PAD_KEY_ROW1__GPIO4_IO09  | MUX_PAD_CTRL(UART_PAD_CTRL)),
> +	IOMUX_PADS(PAD_EIM_DA4__GPIO3_IO04   | MUX_PAD_CTRL(UART_PAD_CTRL)),
> +};
> +
>  static void setup_iomux_uart(void)
>  {
>  	SETUP_IOMUX_PADS(uart1_pads);
> @@ -167,9 +173,42 @@ int board_init(void)
>  	return 0;
>  }
>  
> +static bool is_hummingboard(void)
> +{
> +	int val1, val2;
> +
> +	SETUP_IOMUX_PADS(hb_cbi_sense);
> +
> +	gpio_direction_input(IMX_GPIO_NR(4, 9));
> +	gpio_direction_input(IMX_GPIO_NR(3, 4));
> +
> +	val1 = gpio_get_value(IMX_GPIO_NR(4, 9));
> +	val2 = gpio_get_value(IMX_GPIO_NR(3, 4));
> +
> +	/*
> +	 * Machine selection -
> +	 * Machine        val1, val2
> +	 * -------------------------
> +	 * HB rev 3.x     x     0
> +	 * CBi            0     1
> +	 * HB             1     1
> +	 */
> +
> +	if (val2 == 0)
> +		return true;
> +	else if (val1 == 0)
> +		return false;
> +	else
> +		return true;
> +}
> +
>  int checkboard(void)
>  {
> -	puts("Board: MX6 Hummingboard\n");
> +	if (is_hummingboard())
> +		puts("Board: MX6 Hummingboard\n");
> +	else
> +		puts("Board: MX6 Cubox-i\n");
> +
>  	return 0;
>  }
>  
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic


-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard
  2015-04-23  3:57 ` [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard Fabio Estevam
  2015-04-23  6:16   ` Stefano Babic
@ 2015-04-23 14:38   ` Nikolay Dimitrov
  2015-04-23 15:17     ` Stefano Babic
  1 sibling, 1 reply; 17+ messages in thread
From: Nikolay Dimitrov @ 2015-04-23 14:38 UTC (permalink / raw)
  To: u-boot

Hi Fabio, guys,

On 04/23/2015 06:57 AM, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
>
> Introduce is_hummingboard() function that reads GPIOs that can distinguish
> between Cubox-i and Hummingboard.
>
> Print the board name accordingly.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>   board/solidrun/mx6cuboxi/mx6cuboxi.c | 41 +++++++++++++++++++++++++++++++++++-
>   1 file changed, 40 insertions(+), 1 deletion(-)
>
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 1f240ae..83410b2 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> @@ -71,6 +71,12 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
>   	IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
>   };
>
> +static iomux_v3_cfg_t const hb_cbi_sense[] = {
> +	/* These pins are for sensing if it is a CuBox-i or a HummingBoard */
> +	IOMUX_PADS(PAD_KEY_ROW1__GPIO4_IO09  | MUX_PAD_CTRL(UART_PAD_CTRL)),
> +	IOMUX_PADS(PAD_EIM_DA4__GPIO3_IO04   | MUX_PAD_CTRL(UART_PAD_CTRL)),
> +};
> +
>   static void setup_iomux_uart(void)
>   {
>   	SETUP_IOMUX_PADS(uart1_pads);
> @@ -167,9 +173,42 @@ int board_init(void)
>   	return 0;
>   }
>
> +static bool is_hummingboard(void)
> +{
> +	int val1, val2;
> +
> +	SETUP_IOMUX_PADS(hb_cbi_sense);
> +
> +	gpio_direction_input(IMX_GPIO_NR(4, 9));
> +	gpio_direction_input(IMX_GPIO_NR(3, 4));
> +
> +	val1 = gpio_get_value(IMX_GPIO_NR(4, 9));
> +	val2 = gpio_get_value(IMX_GPIO_NR(3, 4));
> +
> +	/*
> +	 * Machine selection -
> +	 * Machine        val1, val2
> +	 * -------------------------
> +	 * HB rev 3.x     x     0
> +	 * CBi            0     1
> +	 * HB             1     1
> +	 */
> +
> +	if (val2 == 0)
> +		return true;
> +	else if (val1 == 0)
> +		return false;
> +	else
> +		return true;
> +}

As more and more board variants are supported by unified source files,
functions like "is_specificboard()" are not scaling well - there's a
repetitive code for extracting hw-specific info, and then there's the
multiple functions that return true/false for each board variant.

Here's one proposal how this can be simplified a bit:

typedef enum
{
	BOARD_ALPHA,
	BOARD_BRAVO,
	BOARD_CHARLIE,
} model_t;

/* Can be also named is_board_variant() or something like this */
static bool is_board_model(model_t m)
{
	/* ... Extract HW info */

	switch (m)
	{
		case BOARD_ALPHA:
			if (check for this board model)
				return true;
			break;

		/* do same for the other board models */
		/* ... */
	}

	return false;
}

Not sure whether such code can be shared between different boards, but
can be a step towards unifying the handling of board models/variants.

I'm perfectly fine with Fabio's code here, just using the occasion to
share my idea.

> +
>   int checkboard(void)
>   {
> -	puts("Board: MX6 Hummingboard\n");
> +	if (is_hummingboard())
> +		puts("Board: MX6 Hummingboard\n");
> +	else
> +		puts("Board: MX6 Cubox-i\n");
> +
>   	return 0;
>   }
>
>

Kind regards,
Nikolay

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

* [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard
  2015-04-23 14:38   ` Nikolay Dimitrov
@ 2015-04-23 15:17     ` Stefano Babic
  0 siblings, 0 replies; 17+ messages in thread
From: Stefano Babic @ 2015-04-23 15:17 UTC (permalink / raw)
  To: u-boot

Hi Nikolay,

On 23/04/2015 16:38, Nikolay Dimitrov wrote:
> 
> As more and more board variants are supported by unified source files,
> functions like "is_specificboard()" are not scaling well - there's a
> repetitive code for extracting hw-specific info, and then there's the
> multiple functions that return true/false for each board variant.

ok - let's see what we can do. I have not thinking about it, because how
to get model / version is quite always very specific. Some boards as
this one are reading GPIOs, some other are reading from I2C / SPI, some
other ones check if some hardware is present.

> 
> Here's one proposal how this can be simplified a bit:
> 
> typedef enum
> {
>     BOARD_ALPHA,
>     BOARD_BRAVO,
>     BOARD_CHARLIE,
> } model_t;
> 
> /* Can be also named is_board_variant() or something like this */
> static bool is_board_model(model_t m)
> {
>     /* ... Extract HW info */
> 
>     switch (m)
>     {
>         case BOARD_ALPHA:
>             if (check for this board model)
>                 return true;

The check must be done in board code, because only the board knows the
details.

>             break;
> 
>         /* do same for the other board models */
>         /* ... */
>     }
> 
>     return false;
> }
> 
> Not sure whether such code can be shared between different boards, but
> can be a step towards unifying the handling of board models/variants.
> 

Trying to get further and see if we can factorize it. Maybe not a lot.
We can also think that is_board_model() becomes get_board_model(), or we
generalize what was done in tqma6 with a sort of get_board_name().
Maybe we can factorize just a few code, but at least we could provide a
"standard" method without having all boards doing the same in different way.

> I'm perfectly fine with Fabio's code here, just using the occasion to
> share my idea.

Thanks - by sharing ideas we can improve code !

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: sbabic at denx.de
=====================================================================

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

* [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable
  2015-04-23  6:13   ` Stefano Babic
@ 2015-04-23 17:18     ` Fabio Estevam
  2015-04-23 18:26       ` Stefano Babic
  2015-04-23 19:10     ` Tom Rini
  1 sibling, 1 reply; 17+ messages in thread
From: Fabio Estevam @ 2015-04-23 17:18 UTC (permalink / raw)
  To: u-boot

Hi Stefano,

On Thu, Apr 23, 2015 at 3:13 AM, Stefano Babic <sbabic@denx.de> wrote:

> I admit I do not like a lot to have C code setting / fixing the
> environment. This has the drawback that when a user try to set the
> environment from the console as he wants, he cannot because the code has
> reverted back and it is not easy to track. I would like to propose
> another solution.

Thanks for the suggestion.

> What about to export your is_hummingboard() function as U-Boot command ?
> You can then use it in U-Boot scripts, and the correct fdt name can be
> set in the "bootcmd" variable. Something like "if is_humming;then ..."

I am not sure how I can retrieve the returned value from
is_hummingboard() as a U-boot command and use it inside a script?
Maybe I did not understand your suggestion. Please advise.

> And if a user wants to use other names, he can because it is not hard-coded.

Yes, I understand the concern, but in this specific case we are
talking about a DTB file, which is board specific and cannot really
change.

Regards,

Fabio Estevam

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

* [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable
  2015-04-23 17:18     ` Fabio Estevam
@ 2015-04-23 18:26       ` Stefano Babic
  0 siblings, 0 replies; 17+ messages in thread
From: Stefano Babic @ 2015-04-23 18:26 UTC (permalink / raw)
  To: u-boot

Hi Fabio,

On 23/04/2015 19:18, Fabio Estevam wrote:

>> What about to export your is_hummingboard() function as U-Boot command ?
>> You can then use it in U-Boot scripts, and the correct fdt name can be
>> set in the "bootcmd" variable. Something like "if is_humming;then ..."
> 
> I am not sure how I can retrieve the returned value from
> is_hummingboard() as a U-boot command and use it inside a script?
> Maybe I did not understand your suggestion. Please advise.

U_BOOT_CMD returns a value that can be evaluated, exactly as we do with
"if tftp.." or for other commands. So you could implement:

U_BOOT_CMD(is_hummingbird, 1, 1, do_is_hummingbird, ..

and the do_is_hummingbird can return CMD_RET_SUCCESS or CMD_RET_FAILURE.
This is then evaluated in the script as "if is_hummingbird;then
fdt_file=....;else fdt_file=...;fi"

> 
>> And if a user wants to use other names, he can because it is not hard-coded.
> 
> Yes, I understand the concern, but in this specific case we are
> talking about a DTB file, which is board specific and cannot really
> change.

Well, maybe I am alone, but I am used to have several DTB files during
the developmnet phase - I agree with you that at the end there should be
only one DTB file.

Anyway, my was only a proposal - it is also fine if you decide to
maintain the current implementation.

Best regards,
Stefano Babic

-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [U-Boot, 5/5] mx6cuboxi: Load the correct 'fdt_file' variable
  2015-04-23  3:57 ` [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable Fabio Estevam
  2015-04-23  6:13   ` Stefano Babic
@ 2015-04-23 18:47   ` Vagrant Cascadian
  1 sibling, 0 replies; 17+ messages in thread
From: Vagrant Cascadian @ 2015-04-23 18:47 UTC (permalink / raw)
  To: u-boot

On 2015-04-22, Fabio Estevam wrote:
> Instead of hardcoding the 'fdt_file' variable, let's introduce a new
> function - build_dts_name(), that can build the dtb filename on the fly.
> diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> index 83410b2..1c24a55 100644
> --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
...
> +int misc_init_r(void)
> +{
> +	setenv("fdt_file", build_dts_name());
> +	return 0;
> +}
> +

Shouldn't this set fdtfile instead of fdt_file?

According to top-level README, several variables are configured:

Image               File Name        RAM Address       Flash Location
-----               ---------        -----------       --------------
u-boot              u-boot           u-boot_addr_r     u-boot_addr
Linux kernel        bootfile         kernel_addr_r     kernel_addr
device tree blob    fdtfile          fdt_addr_r        fdt_addr
ramdisk             ramdiskfile      ramdisk_addr_r    ramdisk_addr


FWIW, I'm happy to test and review patches for cubox-i4po, hummingboard
solo and hummingboard i2ex.

live well,
  vagrant
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150423/cc094f2d/attachment.sig>

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

* [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support
  2015-04-23  3:57 ` [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support Fabio Estevam
  2015-04-23  6:16   ` Stefano Babic
@ 2015-04-23 19:09   ` Tom Rini
  1 sibling, 0 replies; 17+ messages in thread
From: Tom Rini @ 2015-04-23 19:09 UTC (permalink / raw)
  To: u-boot

On Thu, Apr 23, 2015 at 12:57:04AM -0300, Fabio Estevam wrote:

> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> Cubox-i and Hummingboard support several MX6 SoCs: mx6solo, mx6dual-lite,
> mx6dual and mx6quad. Add support for the different SoC/memory sizes 
> combinations.
> 
> Tested on a CuBox-i4Pro, HummingBoard-i2eX and HummingBoard-i1.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

This applies to this patch as well as 4 and 5.  This code looks really
similar to the solid run tree and as such make sure you credit the
original author from that tree.  For example, 4/6 looks really really
close to:
commit c81b43e9e3a5cc206fc7716822362d41e8bcaef4
Author: Rabeeh Khoury <rabeeh@solid-run.com>
Date:   Wed May 21 14:02:52 2014 +0300

    Add HummingBoard rev 3.0 detection

In the Solid Run tree.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150423/069f9d73/attachment.sig>

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

* [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable
  2015-04-23  6:13   ` Stefano Babic
  2015-04-23 17:18     ` Fabio Estevam
@ 2015-04-23 19:10     ` Tom Rini
  1 sibling, 0 replies; 17+ messages in thread
From: Tom Rini @ 2015-04-23 19:10 UTC (permalink / raw)
  To: u-boot

On Thu, Apr 23, 2015 at 08:13:05AM +0200, Stefano Babic wrote:
> Hi Fabio,
> 
> On 23/04/2015 05:57, Fabio Estevam wrote:
> > From: Fabio Estevam <fabio.estevam@freescale.com>
> > 
> > Instead of hardcoding the 'fdt_file' variable, let's introduce a new
> > function - build_dts_name(), that can build the dtb filename on the fly.
> > 
> > Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> > ---
> >  board/solidrun/mx6cuboxi/mx6cuboxi.c | 24 ++++++++++++++++++++++++
> >  include/configs/mx6cuboxi.h          |  3 +--
> >  2 files changed, 25 insertions(+), 2 deletions(-)
> > 
> > diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> > index 83410b2..1c24a55 100644
> > --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
> > +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
> > @@ -212,6 +212,30 @@ int checkboard(void)
> >  	return 0;
> >  }
> >  
> > +static const char *build_dts_name(void)
> > +{
> > +	char *dt_prefix = "unknown";
> > +	char *dt_suffix = "unknown";
> > +
> > +	if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
> > +		dt_prefix = "imx6q";
> > +	else if (is_cpu_type(MXC_CPU_MX6SOLO) || is_cpu_type(MXC_CPU_MX6DL))
> > +		dt_prefix = "imx6dl";
> > +
> > +	if (is_hummingboard())
> > +		dt_suffix = "-hummingboard.dtb";
> > +	else
> > +		dt_suffix = "-cubox-i.dtb";
> > +
> > +	return strcat(dt_prefix, dt_suffix);
> > +}
> > +
> 
> I admit I do not like a lot to have C code setting / fixing the
> environment. This has the drawback that when a user try to set the
> environment from the console as he wants, he cannot because the code has
> reverted back and it is not easy to track. I would like to propose
> another solution.

Yes.  Please see how this is done for the various TI boards where we
export into the env enough information to make these kind of decisions
in the shell.  This is even more applicable here as we don't have the
dynamic "pick a DT" for Falcon Mode that the Solid Run tree has where
this originated in.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150423/bb5a16f8/attachment.sig>

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

end of thread, other threads:[~2015-04-23 19:10 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-23  3:57 [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Fabio Estevam
2015-04-23  3:57 ` [U-Boot] [PATCH 2/5] mx6cuboxi: Prepare for multi SoC support Fabio Estevam
2015-04-23  6:14   ` Stefano Babic
2015-04-23  3:57 ` [U-Boot] [PATCH 3/5] mx6cuboxi: Introduce multi-SoC support Fabio Estevam
2015-04-23  6:16   ` Stefano Babic
2015-04-23 19:09   ` Tom Rini
2015-04-23  3:57 ` [U-Boot] [PATCH 4/5] mx6cuboxi: Differentiate Cubox-i and Hummingboard Fabio Estevam
2015-04-23  6:16   ` Stefano Babic
2015-04-23 14:38   ` Nikolay Dimitrov
2015-04-23 15:17     ` Stefano Babic
2015-04-23  3:57 ` [U-Boot] [PATCH 5/5] mx6cuboxi: Load the correct 'fdt_file' variable Fabio Estevam
2015-04-23  6:13   ` Stefano Babic
2015-04-23 17:18     ` Fabio Estevam
2015-04-23 18:26       ` Stefano Babic
2015-04-23 19:10     ` Tom Rini
2015-04-23 18:47   ` [U-Boot] [U-Boot, " Vagrant Cascadian
2015-04-23  6:14 ` [U-Boot] [PATCH 1/5] mx6cuboxi: Fix the defconfig name Stefano Babic

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.