Skip to contentSkip to conversation

arm: mx5: Add LDB clock config code

PATCH Superseded Marek Vasut 2 participants 3 messages Oct 4, 2018 – Oct 10, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mx5: Add LDB clock config code

Add code to configure PLL4, from which the LDB clock are directly derived.

---
 arch/arm/include/asm/arch-mx5/clock.h |  1 +
 arch/arm/mach-imx/mx5/clock.c         | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
arch/arm/include/asm/arch-mx5/clock.h +1 -0
index 0ecbdeede5..6f5ca5888a 100644
@@ -38,6 +38,7 @@ enum mxc_clock {
 	MXC_NFC_CLK,
 	MXC_PERIPH_CLK,
 	MXC_I2C_CLK,
+	MXC_LDB_CLK,
 };
 
 u32 imx_get_uartclk(void);
arch/arm/mach-imx/mx5/clock.c +21 -0
index 427cb12415..dcefc4276a 100644
@@ -838,6 +838,23 @@ static int config_ddr_clk(u32 emi_clk)
 	return 0;
 }
 
+static int config_ldb_clk(u32 ref, u32 freq)
+{
+	int ret = 0;
+	struct pll_param pll_param;
+
+	memset(&pll_param, 0, sizeof(struct pll_param));
+
+	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(PLL4_CLOCK, &pll_param);
+}
+
 /*
  * 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,
@@ -879,6 +896,10 @@ int mxc_set_clock(u32 ref, u32 freq, enum mxc_clock clk)
 		if (config_nfc_clk(freq))
 			return -EINVAL;
 		break;
+	case MXC_LDB_CLK:
+		if (config_ldb_clk(ref, freq))
+			return -EINVAL;
+		break;
 	default:
 		printf("Warning:Unsupported or invalid clock type\n");
 	}
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/1 arm: mx5: Add LDB clock config code

Hi Marek,

Quoted 35 lines · Marek Vasut

Add code to configure PLL4, from which the LDB clock are directly derived.

---
 arch/arm/include/asm/arch-mx5/clock.h |  1 +
 arch/arm/mach-imx/mx5/clock.c         | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
arch/arm/include/asm/arch-mx5/clock.h +1 -0
index 0ecbdeede5..6f5ca5888a 100644
@@ -38,6 +38,7 @@ enum mxc_clock {
 	MXC_NFC_CLK,
 	MXC_PERIPH_CLK,
 	MXC_I2C_CLK,
+	MXC_LDB_CLK,
 };
 
 u32 imx_get_uartclk(void);
arch/arm/mach-imx/mx5/clock.c +5 -0
index 427cb12415..dcefc4276a 100644
@@ -838,6 +838,23 @@ static int config_ddr_clk(u32 emi_clk)
 	return 0;
 }
 
+static int config_ldb_clk(u32 ref, u32 freq)
+{
+	int ret = 0;
+	struct pll_param pll_param;
+

arch/arm/mach-imx/mx5/clock.c static int config_ddr_clk(u32 emi_clk) · line 855

Quoted 10 lines
arch/arm/mach-imx/mx5/clock.c +10 -0
+	memset(&pll_param, 0, sizeof(struct pll_param));
+
+	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(PLL4_CLOCK, &pll_param);

This patch breaks the ts4800 board because this is not defined. Can you take a look please ?

Quoted 7 lines
arch/arm/mach-imx/mx5/clock.c +2 -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,

arch/arm/mach-imx/mx5/clock.c int mxc_set_clock(u32 ref, u32 freq, enum mxc_clock clk) · line 905

Quoted 10 lines
arch/arm/mach-imx/mx5/clock.c +4 -0
@@ -879,6 +896,10 @@ int mxc_set_clock(u32 ref, u32 freq, enum mxc_clock clk)
 		if (config_nfc_clk(freq))
 			return -EINVAL;
 		break;
+	case MXC_LDB_CLK:
+		if (config_ldb_clk(ref, freq))
+			return -EINVAL;
+		break;
 	default:
 		printf("Warning:Unsupported or invalid clock type\n");
 	}

Best regards,
Stefano

Signature · 5 lines
=====================================================================
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
=====================================================================
#2 lore raw

PATCH 1/1 arm: mx5: Add LDB clock config code

Quoted 43 lines · Stefano Babic

Hi Marek,

Quoted 40 lines · Marek Vasut

Add code to configure PLL4, from which the LDB clock are directly derived.

---
 arch/arm/include/asm/arch-mx5/clock.h |  1 +
 arch/arm/mach-imx/mx5/clock.c         | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
arch/arm/include/asm/arch-mx5/clock.h +1 -0
index 0ecbdeede5..6f5ca5888a 100644
@@ -38,6 +38,7 @@ enum mxc_clock {
 	MXC_NFC_CLK,
 	MXC_PERIPH_CLK,
 	MXC_I2C_CLK,
+	MXC_LDB_CLK,
 };
 
 u32 imx_get_uartclk(void);
arch/arm/mach-imx/mx5/clock.c +10 -0
index 427cb12415..dcefc4276a 100644
@@ -838,6 +838,23 @@ static int config_ddr_clk(u32 emi_clk)
 	return 0;
 }
 
+static int config_ldb_clk(u32 ref, u32 freq)
+{
+	int ret = 0;
+	struct pll_param pll_param;
+
+	memset(&pll_param, 0, sizeof(struct pll_param));
+
+	ret = calc_pll_params(ref, freq, &pll_param);
+	if (ret != 0) {
+		printf("Error:Can't find pll parameters: %d\n",
Quoted 8 lines

arch/arm/mach-imx/mx5/clock.c static int config_ddr_clk(u32 emi_clk) · line 855

Quoted 5 lines
arch/arm/mach-imx/mx5/clock.c +5 -0
+			ret);
+		return ret;
+	}
+
+	return config_pll_clk(PLL4_CLOCK, &pll_param);

This patch breaks the ts4800 board because this is not defined. Can you take a look please ?

V2 is out.

Signature · 2 lines
Best regards,
Marek Vasut