Skip to contentSkip to conversation

mx5: board: code clean up for checkboard code

PATCH New Jason Liu 5 participants 19 messages Apr 22, 2011 – May 16, 2011

Subsystems (3)
lore
Share & tools
lore

Jason Liu

author
#0 lore raw

PATCH v2 1/1 mx5: board: code clean up for checkboard code

The boot cause code has been factor out to soc common code,we need drop the part from the board support code

This patch also remove the redundant cpu version print

---
changes since v1
-include more clean up by remove the redundant cpu version print

---
 board/efikamx/efikamx.c           |   42 +------------------------------------
 board/freescale/mx51evk/mx51evk.c |   36 +------------------------------
 board/freescale/mx53evk/mx53evk.c |   21 +-----------------
 board/ttcontrol/vision2/vision2.c |   42 +------------------------------------
 4 files changed, 4 insertions(+), 137 deletions(-)
board/efikamx/efikamx.c +1 -41
index f735260..16be532 100644
@@ -643,47 +643,7 @@ int board_late_init(void)
 
 int checkboard(void)
 {
-	u32 system_rev = get_cpu_rev();
-	u32 cause;
-	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
-
-	puts("Board: Efika MX ");
-
-	switch (system_rev & 0xff) {
-	case CHIP_REV_3_0:
-		puts("3.0 [");
-		break;
-	case CHIP_REV_2_5:
-		puts("2.5 [");
-		break;
-	case CHIP_REV_2_0:
-		puts("2.0 [");
-		break;
-	case CHIP_REV_1_1:
-		puts("1.1 [");
-		break;
-	case CHIP_REV_1_0:
-	default:
-		puts("1.0 [");
-		break;
-	}
-
-	cause = src_regs->srsr;
-	switch (cause) {
-	case 0x0001:
-		puts("POR");
-		break;
-	case 0x0009:
-		puts("RST");
-		break;
-	case 0x0010:
-	case 0x0011:
-		puts("WDOG");
-		break;
-	default:
-		printf("unknown 0x%x", cause);
-	}
-	puts("]\n");
+	puts("Board: Efika MX\n");
 
 	return 0;
 }
board/freescale/mx51evk/mx51evk.c +1 -35
index 02a765d..e2d3d74 100644
@@ -431,41 +431,7 @@ int board_late_init(void)
 
 int checkboard(void)
 {
-	puts("Board: MX51EVK ");
-
-	switch (system_rev & 0xff) {
-	case CHIP_REV_3_0:
-		puts("3.0 [");
-		break;
-	case CHIP_REV_2_5:
-		puts("2.5 [");
-		break;
-	case CHIP_REV_2_0:
-		puts("2.0 [");
-		break;
-	case CHIP_REV_1_1:
-		puts("1.1 [");
-		break;
-	case CHIP_REV_1_0:
-	default:
-		puts("1.0 [");
-		break;
-	}
+	puts("Board: MX51EVK\n");
 
-	switch (__raw_readl(SRC_BASE_ADDR + 0x8)) {
-	case 0x0001:
-		puts("POR");
-		break;
-	case 0x0009:
-		puts("RST");
-		break;
-	case 0x0010:
-	case 0x0011:
-		puts("WDOG");
-		break;
-	default:
-		puts("unknown");
-	}
-	puts("]\n");
 	return 0;
 }
board/freescale/mx53evk/mx53evk.c +1 -20
index e71701b..a89aa25 100644
@@ -372,26 +372,7 @@ int board_late_init(void)
 
 int checkboard(void)
 {
-	u32 cause;
-	struct src *src_regs = (struct src *)SRC_BASE_ADDR;
+	puts("Board: MX53EVK\n");
 
-	puts("Board: MX53EVK [");
-
-	cause = src_regs->srsr;
-	switch (cause) {
-	case 0x0001:
-		printf("POR");
-		break;
-	case 0x0009:
-		printf("RST");
-		break;
-	case 0x0010:
-	case 0x0011:
-		printf("WDOG");
-		break;
-	default:
-		printf("unknown");
-	}
-	printf("]\n");
 	return 0;
 }
board/ttcontrol/vision2/vision2.c +1 -41

48 lines not on this page · raw message

Signature · 1 line
1.7.1
author
#1 lore raw

PATCH v6 1/3 MX5: clock: Add clock config interface

Add clock config interface support, so that we
can configure CPU or DDR clock in the later init

---
 arch/arm/cpu/armv7/mx5/clock.c           |  551 +++++++++++++++++++++++++++++-
 arch/arm/include/asm/arch-mx5/clock.h    |    4 +
 arch/arm/include/asm/arch-mx5/crm_regs.h |    6 +
 arch/arm/include/asm/arch-mx5/imx-regs.h |    1 +
 4 files changed, 559 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/mx5/clock.c +548 -3
index 0b04a88..04d9f71 100644
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <div64.h>
 #include <asm/io.h>
 #include <asm/errno.h>
 #include <asm/arch/imx-regs.h>
@@ -34,6 +35,7 @@ enum pll_clocks {
 	PLL1_CLOCK = 0,
 	PLL2_CLOCK,
 	PLL3_CLOCK,
+	PLL4_CLOCK,
 	PLL_CLOCKS,
 };
 
@@ -41,8 +43,42 @@ struct mxc_pll_reg *mxc_plls[PLL_CLOCKS] = {
 	[PLL1_CLOCK] = (struct mxc_pll_reg *)PLL1_BASE_ADDR,
 	[PLL2_CLOCK] = (struct mxc_pll_reg *)PLL2_BASE_ADDR,
 	[PLL3_CLOCK] = (struct mxc_pll_reg *)PLL3_BASE_ADDR,
+	[PLL4_CLOCK] = (struct mxc_pll_reg *)PLL4_BASE_ADDR,
 };
 
+#define AHB_CLK_ROOT    133333333
+#define SZ_DEC_1M       1000000
+#define PLL_PD_MAX      16      /* Actual pd+1 */
+#define PLL_MFI_MAX     15
+#define PLL_MFI_MIN     5
+#define ARM_DIV_MAX     8
+#define IPG_DIV_MAX     4
+#define AHB_DIV_MAX     8
+#define EMI_DIV_MAX     8
+#define NFC_DIV_MAX     8
+
+struct fixed_pll_mfd {
+	u32 ref_clk_hz;
+	u32 mfd;
+};
+
+const struct fixed_pll_mfd fixed_mfd[] = {
+	{CONFIG_SYS_MX5_HCLK, 24 * 16},
+};
+
+struct pll_param {
+	u32 pd;
+	u32 mfi;
+	u32 mfn;
+	u32 mfd;
+};
+
+#define PLL_FREQ_MAX(ref_clk)  (4 * (ref_clk) * PLL_MFI_MAX)
+#define PLL_FREQ_MIN(ref_clk) \
+		((2 * (ref_clk) * (PLL_MFI_MIN - 1)) / PLL_PD_MAX)
+#define MAX_DDR_CLK     420000000
+#define NFC_CLK_MAX     34000000
+
 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
 
 /*
@@ -175,7 +211,7 @@ static u32 get_uart_clk(void)
 /*
  * This function returns the low power audio clock.
  */
-u32 get_lp_apm(void)
+static u32 get_lp_apm(void)
 {
 	u32 ret_val = 0;
 	u32 ccsr = __raw_readl(&mxc_ccm->ccsr);
@@ -191,7 +227,7 @@ u32 get_lp_apm(void)
 /*
  * get cspi clock rate.
  */
-u32 imx_get_cspiclk(void)
+static u32 get_cspi_clk(void)
 {
 	u32 ret_val = 0, pdf, pre_pdf, clk_sel;
 	u32 cscmr1 = __raw_readl(&mxc_ccm->cscmr1);
@@ -228,6 +264,94 @@ u32 imx_get_cspiclk(void)
 	return ret_val;
 }
 
+static u32 get_axi_a_clk(void)
+{
+	u32 cbcdr =  __raw_readl(&mxc_ccm->cbcdr);
+	u32 pdf = (cbcdr & MXC_CCM_CBCDR_AXI_A_PODF_MASK) \
+			>> MXC_CCM_CBCDR_AXI_A_PODF_OFFSET;
+
+	return  get_periph_clk() / (pdf + 1);
+}
+
+static u32 get_axi_b_clk(void)
+{
+	u32 cbcdr =  __raw_readl(&mxc_ccm->cbcdr);
+	u32 pdf = (cbcdr & MXC_CCM_CBCDR_AXI_B_PODF_MASK) \
+			>> MXC_CCM_CBCDR_AXI_B_PODF_OFFSET;
+
+	return  get_periph_clk() / (pdf + 1);
+}
+
+static u32 get_ahb_clk(void)
+{
+	u32 cbcdr = __raw_readl(&mxc_ccm->cbcdr);
+	u32 pdf = (cbcdr & MXC_CCM_CBCDR_AHB_PODF_MASK) \
+			>> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
+
+	return  get_periph_clk() / (pdf + 1);
+}
+
+static u32 get_emi_slow_clk(void)
+{
+	u32 cbcdr = __raw_readl(&mxc_ccm->cbcdr);
+	u32 emi_clk_sel = cbcdr & MXC_CCM_CBCDR_EMI_CLK_SEL;
+	u32 pdf = (cbcdr & MXC_CCM_CBCDR_EMI_PODF_MASK) \
+			>> MXC_CCM_CBCDR_EMI_PODF_OFFSET;
+
+	if (emi_clk_sel)
+		return  get_ahb_clk() / (pdf + 1);
+
+	return  get_periph_clk() / (pdf + 1);
+}
+
+static u32 get_nfc_clk(void)
+{
+	u32 cbcdr = __raw_readl(&mxc_ccm->cbcdr);
+	u32 pdf = (cbcdr & MXC_CCM_CBCDR_NFC_PODF_MASK) \
+			>> MXC_CCM_CBCDR_NFC_PODF_OFFSET;
+
+	return  get_emi_slow_clk() / (pdf + 1);
+}
+
+static u32 get_ddr_clk(void)
+{
+	u32 ret_val = 0;
+	u32 cbcmr = __raw_readl(&mxc_ccm->cbcmr);
+	u32 ddr_clk_sel = (cbcmr & MXC_CCM_CBCMR_DDR_CLK_SEL_MASK) \
+				>> MXC_CCM_CBCMR_DDR_CLK_SEL_OFFSET;
+#ifdef CONFIG_MX51
+	u32 cbcdr = __raw_readl(&mxc_ccm->cbcdr);
+	if (cbcdr & MXC_CCM_CBCDR_DDR_HIFREQ_SEL) {
+		u32 ddr_clk_podf = (cbcdr & MXC_CCM_CBCDR_DDR_PODF_MASK) >> \
+					MXC_CCM_CBCDR_DDR_PODF_OFFSET;
+
+		ret_val = decode_pll(mxc_plls[PLL1_CLOCK], CONFIG_SYS_MX5_HCLK);
+		ret_val /= ddr_clk_podf + 1;
+
+		return ret_val;
+	}
+#endif
+	switch (ddr_clk_sel) {
+	case 0:
+		ret_val = get_axi_a_clk();
+		break;
+	case 1:
+		ret_val = get_axi_b_clk();
+		break;
+	case 2:
+		ret_val = get_emi_slow_clk();
+		break;
+	case 3:
+		ret_val = get_ahb_clk();
+		break;
+	default:
+		break;
+	}
+
+	return ret_val;
+}
+
+
 /*
  * The API of get mxc clockes.
  */
@@ -245,10 +369,12 @@ unsigned int mxc_get_clock(enum mxc_clock clk)
 	case MXC_UART_CLK:
 		return get_uart_clk();
 	case MXC_CSPI_CLK:
-		return imx_get_cspiclk();
+		return get_cspi_clk();
 	case MXC_FEC_CLK:
 		return decode_pll(mxc_plls[PLL1_CLOCK],
 				    CONFIG_SYS_MX5_HCLK);
+	case MXC_DDR_CLK:
+		return get_ddr_clk();
 	default:
 		break;
 	}
@@ -267,6 +393,424 @@ u32 imx_get_fecclk(void)
 }
 
 /*
+ * Clock config code start here
+ */
+
+/* precondition: m>0 and n>0.  Let g=gcd(m,n). */
+static int gcd(int m, int n)
+{
+	int t;
+	while (m > 0) {
+		if (n > m) {
+			t = m;
+			m = n;
+			n = t;
+		} /* swap */
+		m -= n;
+	}
+	return n;
+}
+
+/*
+ * This is to calculate various parameters based on reference clock and
+ * targeted clock based on the equation:
+ *      t_clk = 2*ref_freq*(mfi + mfn/(mfd+1))/(pd+1)
+ * This calculation is based on a fixed MFD value for simplicity.
+ *
+ * @param ref       reference clock freq in Hz
+ * @param target    targeted clock in Hz
+ * @param pll       pll_param structure.
+ *
+ * @return          0 if successful; non-zero otherwise.
+ */
+static int calc_pll_params(u32 ref, u32 target, struct pll_param *pll)
+{
+	u64 pd, mfi = 1, mfn, mfd, t1;
+	u32 n_target = target;
+	u32 n_ref = ref, i;
+
+	/*
+	 * Make sure targeted freq is in the valid range.
+	 * Otherwise the following calculation might be wrong!!!
+	 */
+	if (n_target < PLL_FREQ_MIN(ref) ||
+		n_target > PLL_FREQ_MAX(ref)) {
+		printf("Targeted peripheral clock should be"
+			"within [%d - %d]\n",
+			PLL_FREQ_MIN(ref) / SZ_DEC_1M,
+			PLL_FREQ_MAX(ref) / SZ_DEC_1M);
+		return -1;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(fixed_mfd); i++) {
+		if (fixed_mfd[i].ref_clk_hz == ref) {
+			mfd = fixed_mfd[i].mfd;
+			break;
+		}
+	}
+
+	if (i == ARRAY_SIZE(fixed_mfd))
+		return -1;
+
+	/* Use n_target and n_ref to avoid overflow */
+	for (pd = 1; pd <= PLL_PD_MAX; pd++) {
+		t1 = n_target * pd;
+		do_div(t1, (4 * n_ref));
+		mfi = t1;
+		if (mfi > PLL_MFI_MAX)
+			return -1;
+		else if (mfi < 5)
+			continue;
+		break;
+	}
+	/* Now got pd and mfi already */
+	/*
+	mfn = (((n_target * pd) / 4 - n_ref * mfi) * mfd) / n_ref;
+	*/
+	t1 = n_target * pd;
+	do_div(t1, 4);
+	t1 -= n_ref * mfi;
+	t1 *= mfd;
+	do_div(t1, n_ref);
+	mfn = t1;
+#ifdef CMD_CLOCK_DEBUG
+	printf("ref=%d, target=%d, pd=%d," "mfi=%d,mfn=%d, mfd=%d\n",
+		ref, n_target, (u32)pd, (u32)mfi, (u32)mfn, (u32)mfd);
+#endif
+	i = 1;
+	if (mfn != 0)
+		i = gcd(mfd, mfn);
+	pll->pd = (u32)pd;
+	pll->mfi = (u32)mfi;
+	do_div(mfn, i);
+	pll->mfn = (u32)mfn;
+	do_div(mfd, i);
+	pll->mfd = (u32)mfd;
+
+	return 0;
+}
+
+#define calc_div(tgt_clk, src_clk, limit) ({		\
+		u32 v = 0;				\
+		if (((src_clk) % (tgt_clk)) <= 100)	\
+			v = (src_clk) / (tgt_clk);	\
+		else					\
+			v = ((src_clk) / (tgt_clk)) + 1;\
+		if (v > limit)				\
+			v = limit;			\
+		(v - 1);				\
+	})
+
+static u32 calc_per_cbcdr_val(u32 per_clk)
+{
+	u32 cbcdr = __raw_readl(&mxc_ccm->cbcdr);
+	u32 tmp_clk = 0, div = 0, clk_sel = 0;
+
+	cbcdr &= ~MXC_CCM_CBCDR_PERIPH_CLK_SEL;
+
+	/* emi_slow_podf divider */
+	tmp_clk = get_emi_slow_clk();
+	clk_sel = cbcdr & MXC_CCM_CBCDR_EMI_CLK_SEL;
+	if (clk_sel) {
+		div = calc_div(tmp_clk, per_clk, 8);
+		cbcdr &= ~MXC_CCM_CBCDR_EMI_PODF_MASK;
+		cbcdr |= (div << MXC_CCM_CBCDR_EMI_PODF_OFFSET);
+	}
+
+	/* axi_b_podf divider */
+	tmp_clk = get_axi_b_clk();
+	div = calc_div(tmp_clk, per_clk, 8);
+	cbcdr &= ~MXC_CCM_CBCDR_AXI_B_PODF_MASK;
+	cbcdr |= (div << MXC_CCM_CBCDR_AXI_B_PODF_OFFSET);
+
+	/* axi_b_podf divider */
+	tmp_clk = get_axi_a_clk();
+	div = calc_div(tmp_clk, per_clk, 8);
+	cbcdr &= ~MXC_CCM_CBCDR_AXI_A_PODF_MASK;
+	cbcdr |= (div << MXC_CCM_CBCDR_AXI_A_PODF_OFFSET);
+
+	/* ahb podf divider */
+	tmp_clk = AHB_CLK_ROOT;
+	div = calc_div(tmp_clk, per_clk, 8);
+	cbcdr &= ~MXC_CCM_CBCDR_AHB_PODF_MASK;
+	cbcdr |= (div << MXC_CCM_CBCDR_AHB_PODF_OFFSET);
+
+	return cbcdr;
+}
+
+#define CHANGE_PLL_SETTINGS(pll, pd, fi, fn, fd) \
+	{	\
+		__raw_writel(0x1232, &pll->ctrl);		\
+		__raw_writel(0x2, &pll->config);		\
+		__raw_writel((((pd) - 1) << 0) | ((fi) << 4),	\
+			&pll->op);				\
+		__raw_writel(fn, &(pll->mfn));			\
+		__raw_writel((fd) - 1, &pll->mfd);		\
+		__raw_writel((((pd) - 1) << 0) | ((fi) << 4),	\
+			&pll->hfs_op);				\
+		__raw_writel(fn, &pll->hfs_mfn);		\
+		__raw_writel((fd) - 1, &pll->hfs_mfd);		\
+		__raw_writel(0x1232, &pll->ctrl);		\
+		while (!__raw_readl(&pll->ctrl) & 0x1)		\
+			;\
+	}
+
+static int config_pll_clk(enum pll_clocks index, struct pll_param *pll_param)
+{
+	u32 ccsr = __raw_readl(&mxc_ccm->ccsr);
+	struct mxc_pll_reg *pll = mxc_plls[index];
+
+	switch (index) {
+	case PLL1_CLOCK:
+		/* Switch ARM to PLL2 clock */
+		__raw_writel(ccsr | 0x4, &mxc_ccm->ccsr);
+		CHANGE_PLL_SETTINGS(pll, pll_param->pd,
+					pll_param->mfi, pll_param->mfn,
+					pll_param->mfd);
+		/* Switch back */
+		__raw_writel(ccsr & ~0x4, &mxc_ccm->ccsr);
+		break;
+	case PLL2_CLOCK:
+		/* Switch to pll2 bypass clock */
+		__raw_writel(ccsr | 0x2, &mxc_ccm->ccsr);
+		CHANGE_PLL_SETTINGS(pll, pll_param->pd,
+					pll_param->mfi, pll_param->mfn,
+					pll_param->mfd);
+		/* Switch back */
+		__raw_writel(ccsr & ~0x2, &mxc_ccm->ccsr);
+		break;
+	case PLL3_CLOCK:
+		/* Switch to pll3 bypass clock */
+		__raw_writel(ccsr | 0x1, &mxc_ccm->ccsr);
+		CHANGE_PLL_SETTINGS(pll, pll_param->pd,
+					pll_param->mfi, pll_param->mfn,
+					pll_param->mfd);
+		/* Switch back */
+		__raw_writel(ccsr & ~0x1, &mxc_ccm->ccsr);
+		break;
+	case PLL4_CLOCK:
+		/* Switch to pll4 bypass clock */
+		__raw_writel(ccsr | 0x20, &mxc_ccm->ccsr);
+		CHANGE_PLL_SETTINGS(pll, pll_param->pd,
+					pll_param->mfi, pll_param->mfn,
+					pll_param->mfd);
+		/* Switch back */
+		__raw_writel(ccsr & ~0x20, &mxc_ccm->ccsr);
+		break;
+	default:
+		return -1;
+	}
+
+	return 0;
+}
+
+/* Config CPU clock */
+static int config_core_clk(u32 ref, u32 freq)
+{
+	int ret = 0;
+	struct pll_param pll_param;
+
+	memset(&pll_param, 0, sizeof(struct pll_param));
+
+	/* The case that periph uses PLL1 is not considered here */
+	ret = calc_pll_params(ref, freq, &pll_param);
+	if (ret != 0) {
+		printf("Error:Can't find pll parameters: %d\n", ret);
+		return ret;
+	}
+
+	return config_pll_clk(PLL1_CLOCK, &pll_param);
+}
+
+static int config_nfc_clk(u32 nfc_clk)
+{
+	u32 reg;
+	u32 parent_rate = get_emi_slow_clk();
+	u32 div = parent_rate / nfc_clk;
+
+	if (nfc_clk <= 0)
+		return -1;
+	if (div == 0)
+		div++;
+	if (parent_rate / div > NFC_CLK_MAX)
+		div++;
+	reg = __raw_readl(&mxc_ccm->cbcdr);
+	reg &= ~MXC_CCM_CBCDR_NFC_PODF_MASK;
+	reg |= (div - 1) << MXC_CCM_CBCDR_NFC_PODF_OFFSET;
+	__raw_writel(reg, &mxc_ccm->cbcdr);
+	while (__raw_readl(&mxc_ccm->cdhipr) != 0)
+		;
+	return 0;
+}
+
+/* Config main_bus_clock for periphs */
+static int config_periph_clk(u32 ref, u32 freq)
+{
+	int ret = 0;
+	struct pll_param pll_param;
+
+	memset(&pll_param, 0, sizeof(struct pll_param));
+
+	if (__raw_readl(&mxc_ccm->cbcdr) & MXC_CCM_CBCDR_PERIPH_CLK_SEL) {
+		ret = calc_pll_params(ref, freq, &pll_param);
+		if (ret != 0) {
+			printf("Error:Can't find pll parameters: %d\n",
+				ret);
+			return ret;
+		}
+		switch ((__raw_readl(&mxc_ccm->cbcmr) & \
+			MXC_CCM_CBCMR_PERIPH_CLK_SEL_MASK) >> \
+			MXC_CCM_CBCMR_PERIPH_CLK_SEL_OFFSET) {
+		case 0:
+			return config_pll_clk(PLL1_CLOCK, &pll_param);
+			break;
+		case 1:
+			return config_pll_clk(PLL3_CLOCK, &pll_param);
+			break;
+		default:
+			return -1;
+		}
+	} else {
+		u32 old_cbcmr = __raw_readl(&mxc_ccm->cbcmr);
+		u32 new_cbcdr = calc_per_cbcdr_val(freq);
+		u32 old_nfc = get_nfc_clk();
+
+		/* Switch peripheral to PLL3 */
+		__raw_writel(0x00015154, &mxc_ccm->cbcmr);
+		__raw_writel(0x02888945, &mxc_ccm->cbcdr);
+
+		/* Make sure change is effective */
+		while (__raw_readl(&mxc_ccm->cdhipr) != 0)
+			;
+
+		/* Setup PLL2 */
+		ret = calc_pll_params(ref, freq, &pll_param);
+		if (ret != 0) {
+			printf("Error:Can't find pll parameters: %d\n",
+				ret);
+			return ret;
+		}
+		config_pll_clk(PLL2_CLOCK, &pll_param);
+
+		/* Switch peripheral back */
+		__raw_writel(new_cbcdr, &mxc_ccm->cbcdr);
+		__raw_writel(old_cbcmr, &mxc_ccm->cbcmr);
+
+		/* Make sure change is effective */
+		while (__raw_readl(&mxc_ccm->cdhipr) != 0)
+			;
+		/* restore to old NFC clock */
+		config_nfc_clk(old_nfc);
+	}
+
+	return 0;
+}
+
+static int config_ddr_clk(u32 emi_clk)
+{
+	u32 clk_src;
+	s32 shift = 0, clk_sel, div = 1;
+	u32 cbcmr = __raw_readl(&mxc_ccm->cbcmr);
+	u32 cbcdr = __raw_readl(&mxc_ccm->cbcdr);
+
+	if (emi_clk > MAX_DDR_CLK) {
+		printf("Warning:DDR clock should not exceed %d MHz\n",
+			MAX_DDR_CLK / SZ_DEC_1M);
+		emi_clk = MAX_DDR_CLK;
+	}
+
+	clk_src = get_periph_clk();
+	/* Find DDR clock input */
+	clk_sel = (cbcmr >> 10) & 0x3;
+	switch (clk_sel) {
+	case 0:
+		shift = 16;
+		break;
+	case 1:
+		shift = 19;
+		break;
+	case 2:
+		shift = 22;
+		break;
+	case 3:
+		shift = 10;
+		break;
+	default:
+		return -1;
+	}
+
+	if ((clk_src % emi_clk) < 10000000)
+		div = clk_src / emi_clk;
+	else
+		div = (clk_src / emi_clk) + 1;
+	if (div > 8)
+		div = 8;
+
+	cbcdr = cbcdr & ~(0x7 << shift);
+	cbcdr |= ((div - 1) << shift);
+	__raw_writel(cbcdr, &mxc_ccm->cbcdr);
+	while (__raw_readl(&mxc_ccm->cdhipr) != 0)
+		;
+	__raw_writel(0x0, &mxc_ccm->ccdr);
+
+	return 0;
+}
+
+/*!
+ * This function assumes the expected core clock has to be changed by
+ * modifying the PLL. This is NOT true always but for most of the times,
+ * it is. So it assumes the PLL output freq is the same as the expected
+ * core clock (presc=1) unless the core clock is less than PLL_FREQ_MIN.
+ * In the latter case, it will try to increase the presc value until
+ * (presc*core_clk) is greater than PLL_FREQ_MIN. It then makes call to
+ * calc_pll_params() and obtains the values of PD, MFI,MFN, MFD based
+ * on the targeted PLL and reference input clock to the PLL. Lastly,
+ * it sets the register based on these values along with the dividers.
+ * Note 1) There is no value checking for the passed-in divider values
+ *         so the caller has to make sure those values are sensible.
+ *      2) Also adjust the NFC divider such that the NFC clock doesn't
+ *         exceed NFC_CLK_MAX.
+ *      3) IPU HSP clock is independent of AHB clock. Even it can go up to
+ *         177MHz for higher voltage, this function fixes the max to 133MHz.
+ *      4) This function should not have allowed diag_printf() calls since
+ *         the serial driver has been stoped. But leave then here to allow
+ *         easy debugging by NOT calling the cyg_hal_plf_serial_stop().
+ *
+ * @param ref   pll input reference clock (24MHz)
+ * @param freq  core clock in Hz
+ * @param clk   clock type, e.g CPU_CLK, DDR_CLK, etc.
+ * @return      0 if successful; non-zero otherwise
+ */
+int mxc_set_clock(u32 ref, u32 freq, enum mxc_clock clk)
+{
+	freq *= SZ_DEC_1M;
+
+	switch (clk) {
+	case MXC_ARM_CLK:
+		if (config_core_clk(ref, freq))
+			return -1;
+		break;
+	case MXC_PERIPH_CLK:
+		if (config_periph_clk(ref, freq))
+			return -1;
+		break;
+	case MXC_DDR_CLK:
+		if (config_ddr_clk(freq))
+			return -1;
+		break;
+	case MXC_NFC_CLK:
+		if (config_nfc_clk(freq))
+			return -1;
+		break;
+	default:
+		printf("Warning:Unsupported or invalid clock type\n");
+	}
+
+	return 0;
+}
+
+
+/*
  * Dump some core clockes.
  */
 int do_mx5_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -281,6 +825,7 @@ int do_mx5_showclocks(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	printf("pll3: %dMHz\n", freq / 1000000);
 	printf("ipg clock     : %dHz\n", mxc_get_clock(MXC_IPG_CLK));
 	printf("ipg per clock : %dHz\n", mxc_get_clock(MXC_IPG_PERCLK));
+	printf("ddr clock     : %dHz\n", mxc_get_clock(MXC_DDR_CLK));
 
 	return 0;
 }
arch/arm/include/asm/arch-mx5/clock.h +4 -0
index 1f8a537..bcecd45 100644
@@ -32,6 +32,9 @@ enum mxc_clock {
 	MXC_UART_CLK,
 	MXC_CSPI_CLK,
 	MXC_FEC_CLK,
+	MXC_DDR_CLK,
+	MXC_NFC_CLK,
+	MXC_PERIPH_CLK,
 };
 
 unsigned int imx_decode_pll(unsigned int pll, unsigned int f_ref);
@@ -39,5 +42,6 @@ unsigned int imx_decode_pll(unsigned int pll, unsigned int f_ref);
 u32 imx_get_uartclk(void);
 u32 imx_get_fecclk(void);
 unsigned int mxc_get_clock(enum mxc_clock clk);
+int mxc_set_clock(u32 ref, u32 freq, u32 clk_type);
 
 #endif /* __ASM_ARCH_CLOCK_H */
arch/arm/include/asm/arch-mx5/crm_regs.h +6 -0
index 4ed8eb3..735e4bd 100644
@@ -76,6 +76,9 @@ struct mxc_ccm_reg {
 	u32 CCGR4;
 	u32 CCGR5;
 	u32 CCGR6;	/* 0x0080 */
+#ifdef CONFIG_MX53
+	u32 CCGR7;      /* 0x0084 */
+#endif
 	u32 cmeor;
 };
 
@@ -84,6 +87,9 @@ struct mxc_ccm_reg {
 #define MXC_CCM_CACRR_ARM_PODF_MASK		0x7
 
 /* Define the bits in register CBCDR */
+#define MXC_CCM_CBCDR_DDR_HIFREQ_SEL		(0x1 << 30)
+#define MXC_CCM_CBCDR_DDR_PODF_MASK		(0x7 << 27)
+#define MXC_CCM_CBCDR_DDR_PODF_OFFSET		27
 #define MXC_CCM_CBCDR_EMI_CLK_SEL		(0x1 << 26)
 #define MXC_CCM_CBCDR_PERIPH_CLK_SEL		(0x1 << 25)
 #define MXC_CCM_CBCDR_EMI_PODF_OFFSET		22
arch/arm/include/asm/arch-mx5/imx-regs.h +1 -0
index a1849f8..896a229 100644
@@ -98,6 +98,7 @@
 #define PLL1_BASE_ADDR		(AIPS2_BASE_ADDR + 0x00080000)
 #define PLL2_BASE_ADDR		(AIPS2_BASE_ADDR + 0x00084000)
 #define PLL3_BASE_ADDR		(AIPS2_BASE_ADDR + 0x00088000)
+#define PLL4_BASE_ADDR          (AIPS2_BASE_ADDR + 0x0008c000)
 #define AHBMAX_BASE_ADDR	(AIPS2_BASE_ADDR + 0x00094000)
 #define IIM_BASE_ADDR		(AIPS2_BASE_ADDR + 0x00098000)
 #define CSU_BASE_ADDR		(AIPS2_BASE_ADDR + 0x0009C000)
Signature · 1 line
1.7.1
author
#2 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

In reply to Jason Liu

Add dialog pmic(DA9053) driver with I2C interface support

---
 drivers/misc/Makefile      |    1 +
 drivers/misc/dialog_pmic.c |  123 +++++++++++++++++++++++++++++
 include/da9053.h           |  186 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 310 insertions(+), 0 deletions(-)
drivers/misc/Makefile +1 -0
index b152486..c557a14 100644
@@ -35,6 +35,7 @@ COBJS-$(CONFIG_NS87308) += ns87308.o
 COBJS-$(CONFIG_PDSP188x) += pdsp188x.o
 COBJS-$(CONFIG_STATUS_LED) += status_led.o
 COBJS-$(CONFIG_TWL4030_LED) += twl4030_led.o
+COBJS-$(CONFIG_DIALOG_PMIC) += dialog_pmic.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/misc/dialog_pmic.c new file +123 -0

123 lines not on this page · raw message

include/da9053.h new file +186 -0

186 lines not on this page · raw message

Signature · 1 line
1.7.1
#3 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Quoted 2 lines · Jason Liu

Add dialog pmic(DA9053) driver with I2C interface support

Hi Jason,

drivers/misc/dialog_pmic.c line 3

Quoted 9 lines
drivers/misc/dialog_pmic.c new file +3 -0
new file mode 100644
index 0000000..95dc6ea
@@ -0,0 +1,123 @@
+/*
+ * (C) Copyright 2011 Freescale Semiconductor, Inc.
+ * Based on drivers/misc/fsl_pmic.c

As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ?

I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are:
- registers are 1 byte wide instead of 32 bit
- different size of register area

Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#4 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Hi, Stefano,

2011/4/22 Stefano Babic <[email protected]>:

Quoted 20 lines · Jason Liu
Quoted 2 lines

Add dialog pmic(DA9053) driver with I2C interface support

Hi Jason,

drivers/misc/dialog_pmic.c line 3

Quoted 9 lines
drivers/misc/dialog_pmic.c new file +3 -0
new file mode 100644
index 0000000..95dc6ea
@@ -0,0 +1,123 @@
+/*
+ * (C) Copyright 2011 Freescale Semiconductor, Inc.
+ * Based on drivers/misc/fsl_pmic.c

As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ?

Quoted 8 lines

I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are:
? ? ? ?- registers are 1 byte wide instead of 32 bit
? ? ? ?- different size of register area

Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one.

fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right?

As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch
the original file and add one new file. The head of this file tell it clear that this patch is
Based on drivers/misc/fsl_pmic.c.

If you still want me to include the DA9053 support into fsl_pmic, could you please
extend the fsl_pmic support to easily add another vender's pmic support first?

Jason

Quoted 15 lines

Best regards,
Stefano Babic

--
=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#5 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Am 22/04/2011 16:50, schrieb Jason Liu:

Hi Jason,

Quoted 9 lines
Quoted 9 lines

As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ?

I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are:
- registers are 1 byte wide instead of 32 bit
- different size of register area

Quoted 6 lines
Quoted 3 lines

Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one.

fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right?

It was for MC13892, but it is for MC13783 as well, used in i.MX31 boards.

Quoted 7 lines

As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch
the original file and add one new file. The head of this file tell it clear that this patch is
Based on drivers/misc/fsl_pmic.c.

I do not mind an issue related to set where the driver is coming from. My concern is due to the fact that your patch is very similar (for the i2c part) to the fsl_pmic.c file, and I want to avoid to have two different driver making the same things, having then the necessity to maintain both. At the end, this file expones only a common interface to the board maintainers to access the pmic registers (via I2c or SPI as well). Running diff on the two files I do not see a lot of differences.

Quoted 4 lines

If you still want me to include the DA9053 support into fsl_pmic, could you please
extend the fsl_pmic support to easily add another vender's pmic support first?

Really I have not understood your question. What do you mean ?

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
author
#6 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Hi, Stefano,

Quoted 39 lines · stefano babic

Am 22/04/2011 16:50, schrieb Jason Liu:

Hi Jason,

Quoted 9 lines
Quoted 9 lines

As I can see now, this driver is quite a copy of fsl_pmic.c, with slightly changes. Are you sure we cannot simply change the already provided driver, adding support for the new chip ?

I have not read the DA9053 datasheet, but from your patch it seems to me that the relevant changes are:
? ? ? ?- registers are 1 byte wide instead of 32 bit
? ? ? ?- different size of register area

Quoted 6 lines
Quoted 3 lines

Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one.

fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right?

It was for MC13892, but it is for MC13783 as well, used in i.MX31 boards.

Quoted 7 lines

As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch
the original file and add one new file. The head of this file tell it clear that this patch is
Based on drivers/misc/fsl_pmic.c.

I do not mind an issue related to set where the driver is coming from. My concern is due to the fact that your patch is very similar (for the i2c part) to the fsl_pmic.c file, and I want to avoid to have two different driver making the same things, having then the necessity to maintain both. At the end, this file expones only a common interface to the board maintainers to access the pmic registers (via I2c or SPI as well). Running diff on the two files I do not see a lot of differences.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines

If you still want me to include the DA9053 support into fsl_pmic, could you please
extend the fsl_pmic support to easily add another vender's pmic support first?

Really I have not understood your question. What do you mean ?

Then, Can you tell me how to add the dialog pmic support into fsl_pmi.c file which is dedicated for
freescale mc13xxx? Thanks,

Quoted 12 lines

Best regards,
Stefano Babic

--
=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================

#7 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Quoted 1 line · Jason Hui

Hi, Stefano,

Hi Jason,

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

If you still want me to include the DA9053 support into fsl_pmic, could you please
extend the fsl_pmic support to easily add another vender's pmic support first?

Really I have not understood your question. What do you mean ?

Then, Can you tell me how to add the dialog pmic support into fsl_pmi.c file which is dedicated for
freescale mc13xxx? Thanks,

IMHO the details for each Power Controllers are inside the corresponding header, that contains the register description, in your xace DA09053.h. The fsl_pmic.c expones only a general way to speak with the controller via SPI or I2C interface. If I see your patch, the only real difference with the original file is that a single byte is read/written with the DA09053, while the mc13xxx have 32-bit registers. You can add this option as CONFIG_ switch, or in another way.

Only the board is aware about which PMIC is used. In fact, the fsl_pmic.c does not include neither mc13892.h nor mc13783.h.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#8 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Hi Stefano,

Quoted 23 lines · Jason Hui
Quoted 1 line

Hi, Stefano,

Hi Jason,

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

If you still want me to include the DA9053 support into fsl_pmic, could you please
extend the fsl_pmic support to easily add another vender's pmic support first?

Really I have not understood your question. What do you mean ?

Then, Can you tell me how to add the dialog pmic support into fsl_pmi.c file which is dedicated for
freescale mc13xxx? Thanks,

IMHO the details for each Power Controllers are inside the corresponding header, that contains the register description, in your xace DA09053.h. The fsl_pmic.c expones only a general way to speak with the controller via SPI or I2C interface. If I see your patch, the only real difference with the original file is that a single byte is read/written with the DA09053, while the mc13xxx have 32-bit registers. You can add this option as CONFIG_ switch, or in another way.

Quoted 2 lines

Only the board is aware about which PMIC is used. In fact, the fsl_pmic.c does not include neither mc13892.h nor mc13783.h.

Then why not rename the driver to something else than "fsl_pmic"? Maybe this is what Jason really is asking? I have not looked any deeper, but maybe something like "i2c_pmic" or such...

Cheers
Detlev

Signature · 7 lines
Don't trust everything you read, and don't assume every poster in
a thread is actually relevant to the problem.
        -- Stefan Monnier <[email protected]>
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#9 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Quoted 2 lines · Detlev Zundel

Then why not rename the driver to something else than "fsl_pmic"? Maybe this is what Jason really is asking?

Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point.

Best regards,
Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#10 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Hi, Stefano,

2011/4/27 Stefano Babic <[email protected]>:

Quoted 8 lines · Detlev Zundel
Quoted 3 lines

Then why not rename the driver to something else than "fsl_pmic"? ?Maybe this is what Jason really is asking?

Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point.

Sorry for the late response due to some reason. :(

Yes, We had better rename fsl_ to something else, I would like use generic_pmic or something else, what's your idea?

Jason

Quoted 15 lines

Best regards,
Stefano

--
=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#11 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Quoted 2 lines · Jason Liu

Hi, Stefano,

Hi Jason,

Quoted 11 lines

2011/4/27 Stefano Babic <[email protected]>:

Quoted 8 lines · Detlev Zundel
Quoted 3 lines

Then why not rename the driver to something else than "fsl_pmic"? Maybe this is what Jason really is asking?

Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point.

Sorry for the late response due to some reason. :(

No problem at all.

Quoted 3 lines

Yes, We had better rename fsl_ to something else, I would like use generic_pmic or something else, what's your idea?

I am open for new names. Probably we should state that this driver is a wrapper when SPI or I2C is used, and something like spi_i2c_pmic gives a better idea. With generic_pmic we could think there is a general layout for PMICs (and it is not true).

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
author
#12 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

Hi, Stefano,

Quoted 21 lines · Stefano Babic
Quoted 2 lines · Jason Liu

Hi, Stefano,

Hi Jason,

Quoted 11 lines

2011/4/27 Stefano Babic <[email protected]>:

Quoted 8 lines · Detlev Zundel
Quoted 3 lines

Then why not rename the driver to something else than "fsl_pmic"? ?Maybe this is what Jason really is asking?

Yes, of course, no problem at all. Jason, if you meant to drop the fsl_ to make the driver more general, I completely agree. Sorry, I have not got the point.

Sorry for the late response due to some reason. :(

No problem at all.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Yes, We had better rename fsl_ to something else, I would like use generic_pmic or something else, what's your idea?

I am open for new names. Probably we should state that this driver is a wrapper when SPI or I2C is used, and something like spi_i2c_pmic gives a better idea. With generic_pmic we could think there is a general layout for PMICs (and it is not true).

OK, agree. I will change it to spi_i2c_pmic.c. :)

Quoted 11 lines

Best regards,
Stefano Babic

--
=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================

#13 lore raw

PATCH v6 2/3 PMIC: Add dialog pmic support

In reply to Jason Liu

Dear Jason Liu,

Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 4 lines

Really not enough to justify a new driver. All functions are really copied from the old one. Please consider to adapt fsl_pmic.c instead of adding a slightly different new one.

fsl_pmic is about freescale mc13892 and fsl_pmic.c is dedicated for fsl pmic as you write this file, right?

Quoted 6 lines

As I add the Dialog PMIC support, I do want to not add one new file, but I find it's not easy to add it and it will make the file very mess, so, I decide not to touch
the original file and add one new file. The head of this file tell it clear that this patch is
Based on drivers/misc/fsl_pmic.c.

Stefano is right. We cannot accept such duplication of code. Please merge into a single common driver.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"When people are least sure, they are often most dogmatic."
- John Kenneth Galbraith
author
#14 lore raw

PATCH v6 3/3 MX53: support for freescale MX53LOCO board

In reply to Jason Liu

This patch add initial support for freescale MX53LOCO board. Network(FEC),SD/MMC,UART have been supported by this patch

The patch also config CPU:1GHZ,DDR:400MHZ for better peformance

---
Changes since v5:
- merge the "Add power init support" patch
changes since v4:
- remove the boot reset cause from board support changes since v3:
- include other two small patch into this commit,
mx53loco: set mmc env to MMC slot1
MX5: Enable flat-device-tree support on mx53 loco board changes since V2:
-factor out the boot cause function to common code, -fix gd->ram_size with full memory size
-remove the '1' from all #defines that just enable features -correct memory test end address value

---
 MAINTAINERS                               |    1 +
 arch/arm/cpu/armv7/mx5/soc.c              |    2 +-
 arch/arm/include/asm/arch-mx5/sys_proto.h |    2 +
 board/freescale/mx53loco/Makefile         |   47 ++++
 board/freescale/mx53loco/imximage.cfg     |   96 +++++++
 board/freescale/mx53loco/mx53loco.c       |  395 +++++++++++++++++++++++++++++
 boards.cfg                                |    1 +
 include/configs/mx53loco.h                |  198 +++++++++++++++
 8 files changed, 741 insertions(+), 1 deletions(-)
MAINTAINERS +1 -0
index 1299cbb..c00a196 100644
@@ -567,6 +567,7 @@ Stefano Babic <[email protected]>
 Jason Liu <[email protected]>
 
 	mx53evk         i.MX53
+	mx53loco        i.MX53
 
 Enric Balletbo i Serra <[email protected]>
 
arch/arm/cpu/armv7/mx5/soc.c +1 -1
index 6f4e8db..9c03474 100644
@@ -116,7 +116,7 @@ int print_cpuinfo(void)
 		(cpurev & 0x000F0) >> 4,
 		(cpurev & 0x0000F) >> 0,
 		mxc_get_clock(MXC_ARM_CLK) / 1000000);
-	printf("Reset cause: %s\n", get_reset_cause());
+	printf("Reset  cause: %s\n", get_reset_cause());
 	return 0;
 }
 #endif
arch/arm/include/asm/arch-mx5/sys_proto.h +2 -0
index f687503..2d7e9ed 100644
@@ -27,5 +27,7 @@
 u32 get_cpu_rev(void);
 #define is_soc_rev(rev)	((get_cpu_rev() & 0xFF) - rev)
 void sdelay(unsigned long);
+void pmic_reg_write(u32 reg, u32 value);
+u32 pmic_reg_read(u32 reg);
 
 #endif
board/freescale/mx53loco/Makefile new file +47 -0

47 lines not on this page · raw message

board/freescale/mx53loco/imximage.cfg new file +96 -0

96 lines not on this page · raw message

board/freescale/mx53loco/mx53loco.c new file +395 -0

395 lines not on this page · raw message

boards.cfg +1 -0
index 55c21f2..4d1b211 100644
@@ -110,6 +110,7 @@ ca9x4_ct_vxp                 arm         armv7       vexpress            armltd
 efikamx                      arm         armv7       efikamx             -              mx5
 mx51evk                      arm         armv7       mx51evk             freescale      mx5		mx51evk:IMX_CONFIG=board/freescale/mx51evk/imximage.cfg
 mx53evk                      arm         armv7       mx53evk             freescale      mx5		mx53evk:IMX_CONFIG=board/freescale/mx53evk/imximage.cfg
+mx53loco                     arm         armv7       mx53loco            freescale      mx5		mx53loco:IMX_CONFIG=board/freescale/mx53loco/imximage.cfg
 vision2                      arm         armv7       vision2             ttcontrol      mx5
 cm_t35                       arm         armv7       cm_t35              -              omap3
 omap3_overo                  arm         armv7       overo               -              omap3
include/configs/mx53loco.h new file +198 -0

198 lines not on this page · raw message

Signature · 1 line
1.7.1
#15 lore raw

PATCH v2 1/1 mx5: board: code clean up for checkboard code

In reply to Jason Liu

Hi, Stefano,

2011/4/22 Jason Liu <[email protected]>:

Quoted 10 lines

The boot cause code has been factor out to soc common code,we need drop the part from the board support code

This patch also remove the redundant cpu version print

---
changes since v1
-include more clean up by remove the redundant cpu version print
---

Quoted 6 lines
?board/efikamx/efikamx.c ? ? ? ? ? | ? 42 +------------------------------------
?board/freescale/mx51evk/mx51evk.c | ? 36 +------------------------------
?board/freescale/mx53evk/mx53evk.c | ? 21 +-----------------
?board/ttcontrol/vision2/vision2.c | ? 42 +------------------------------------

?4 files changed, 4 insertions(+), 137 deletions(-)

Ping, any comments about this patch?

Jason

Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#16 lore raw

PATCH v2 1/1 mx5: board: code clean up for checkboard code

Hi,Stefano,

2011/5/11 Jason Liu <[email protected]>:

Quoted 20 lines

Hi, Stefano,

2011/4/22 Jason Liu <[email protected]>:

Quoted 10 lines

The boot cause code has been factor out to soc common code,we need drop the part from the board support code

This patch also remove the redundant cpu version print

---
changes since v1
-include more clean up by remove the redundant cpu version print
---

Quoted 6 lines
?board/efikamx/efikamx.c ? ? ? ? ? | ? 42 +------------------------------------
?board/freescale/mx51evk/mx51evk.c | ? 36 +------------------------------
?board/freescale/mx53evk/mx53evk.c | ? 21 +-----------------
?board/ttcontrol/vision2/vision2.c | ? 42 +------------------------------------

?4 files changed, 4 insertions(+), 137 deletions(-)

Quoted 2 lines

Ping, any comments about this patch?

Any comments, if not, please pull it, thanks.

Quoted 8 lines

Jason

Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#17 lore raw

PATCH v2 1/1 mx5: board: code clean up for checkboard code

Quoted 3 lines · Jason Liu

Hi,Stefano,

Any comments, if not, please pull it, thanks.

No, I have not. I will pull it.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#18 lore raw

PATCH v2 1/1 mx5: board: code clean up for checkboard code

In reply to Jason Liu
Quoted 5 lines · Jason Liu

The boot cause code has been factor out to soc common code,we need drop the part from the board support code

This patch also remove the redundant cpu version print

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================