Skip to contentSkip to conversation

clk: exynos: add support for exynos5260 SoC

PATCH Superseded Rahul Sharma 3 participants 13 messages Feb 18, 2014 – Mar 7, 2014

Subsystems (4)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover clk: exynos: add support for exynos5260 SoC

From: Rahul Sharma <[email protected]>

Add basic support for exynos5260 SoC.

This series is based on Kukjin's for-next and
Mike's clk-next branches.

This patch is dependent on the following series from Tomasz Figa <[email protected]>:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-October/205144.html

V3:
1) Removed "samsung,exynos5260-clock" property from clock files.
2) Replaced "__SPIN_LOCK_UNLOCKED(lock)" with spin_lock_init.
3) Removed '(' and ')' around numeric constants in macros.

V2:
1) Move suspend resume handling to Exynos5410 Clock file.
2) Removed Unused Macros and Condition checks for Exynos5260.
3) Add spin lock to clock provider context.
4) Add clock provider context for Exynos5410.
5) Uniform implementation for callbacks for PLL2550xx.
6) Split Exynos5260 clock file patch to bring it under 100 Kb limit.
7) Replace aclk/pclk/hclk gates with combined gates.
8) Remove CLK_IGNORE_UNUSED flag for gate clocks.

Pankaj Dubey (1):
clk/samsung: add support for pll2550xx

Rahul Sharma (4):
clk/samsung: add support for multiple clock providers clk/samsung: add support for pll2650xx clk/exynos5260: add macros and documentation for exynos5260 clk/exynos5260: add clock file for exynos5260

 .../devicetree/bindings/clock/exynos5260-clock.txt |  299 +++
 drivers/clk/samsung/Makefile                       |    1 +
 drivers/clk/samsung/clk-exynos4.c                  |   47 +-
 drivers/clk/samsung/clk-exynos5250.c               |   25 +-
 drivers/clk/samsung/clk-exynos5260.c               | 2235 ++++++++++++++++++++
 drivers/clk/samsung/clk-exynos5260.h               |  480 +++++
 drivers/clk/samsung/clk-exynos5420.c               |   24 +-
 drivers/clk/samsung/clk-exynos5440.c               |   18 +-
 drivers/clk/samsung/clk-pll.c                      |  223 +-
 drivers/clk/samsung/clk-pll.h                      |    2 +
 drivers/clk/samsung/clk-s3c64xx.c                  |   44 +-
 drivers/clk/samsung/clk.c                          |  115 +-
 drivers/clk/samsung/clk.h                          |   72 +-
 include/dt-bindings/clk/exynos5260-clk.h           |  234 ++
 14 files changed, 3670 insertions(+), 149 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/exynos5260-clock.txt
 create mode 100644 drivers/clk/samsung/clk-exynos5260.c
 create mode 100644 drivers/clk/samsung/clk-exynos5260.h
 create mode 100644 include/dt-bindings/clk/exynos5260-clk.h
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/5 clk/samsung: add support for multiple clock providers

Samsung CCF helper functions do not provide support to register multiple Clock Providers for a given SoC. Due to this limitation SoC platforms are not able to use these helpers for registering multiple clock providers and are forced to bypass this layer.

This layer is modified accordingly to enable the support.

Clock file for exynos4, exynos5250, exynos5420, exynos5440 and S3c64xx are also modified as per changed helper functions.

---
 drivers/clk/samsung/clk-exynos4.c    |   47 +++++++-------
 drivers/clk/samsung/clk-exynos5250.c |   25 +++++---
 drivers/clk/samsung/clk-exynos5420.c |   24 ++++---
 drivers/clk/samsung/clk-exynos5440.c |   18 +++---
 drivers/clk/samsung/clk-pll.c        |   14 +++--
 drivers/clk/samsung/clk-s3c64xx.c    |   44 +++++++------
 drivers/clk/samsung/clk.c            |  115 +++++++++++++++++++---------------
 drivers/clk/samsung/clk.h            |   72 ++++++++++++++-------
 8 files changed, 210 insertions(+), 149 deletions(-)
drivers/clk/samsung/clk-exynos4.c +25 -22
index b4f9672..57ed5a8 100644
@@ -1043,7 +1043,7 @@ static unsigned long exynos4_get_xom(void)
 	return xom;
 }
 
-static void __init exynos4_clk_register_finpll(void)
+static void __init exynos4_clk_register_finpll(struct samsung_clk_provider *ctx)
 {
 	struct samsung_fixed_rate_clock fclk;
 	struct clk *clk;
@@ -1066,7 +1066,7 @@ static void __init exynos4_clk_register_finpll(void)
 	fclk.parent_name = NULL;
 	fclk.flags = CLK_IS_ROOT;
 	fclk.fixed_rate = finpll_f;
-	samsung_clk_register_fixed_rate(&fclk, 1);
+	samsung_clk_register_fixed_rate(ctx, &fclk, 1);
 
 }
 
@@ -1176,22 +1176,25 @@ static struct samsung_pll_clock exynos4x12_plls[nr_plls] __initdata = {
 static void __init exynos4_clk_init(struct device_node *np,
 				    enum exynos4_soc soc)
 {
+	struct samsung_clk_provider *ctx;
 	exynos4_soc = soc;
 
 	reg_base = of_iomap(np, 0);
 	if (!reg_base)
 		panic("%s: failed to map registers\n", __func__);
 
-	samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+	ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+	if (!ctx)
+		panic("%s: unable to allocate context.\n", __func__);
 
-	samsung_clk_of_register_fixed_ext(exynos4_fixed_rate_ext_clks,
+	samsung_clk_of_register_fixed_ext(ctx, exynos4_fixed_rate_ext_clks,
 			ARRAY_SIZE(exynos4_fixed_rate_ext_clks),
 			ext_clk_match);
 
-	exynos4_clk_register_finpll();
+	exynos4_clk_register_finpll(ctx);
 
 	if (exynos4_soc == EXYNOS4210) {
-		samsung_clk_register_mux(exynos4210_mux_early,
+		samsung_clk_register_mux(ctx, exynos4210_mux_early,
 					ARRAY_SIZE(exynos4210_mux_early));
 
 		if (_get_rate("fin_pll") == 24000000) {
@@ -1205,7 +1208,7 @@ static void __init exynos4_clk_init(struct device_node *np,
 			exynos4210_plls[vpll].rate_table =
 							exynos4210_vpll_rates;
 
-		samsung_clk_register_pll(exynos4210_plls,
+		samsung_clk_register_pll(ctx, exynos4210_plls,
 					ARRAY_SIZE(exynos4210_plls), reg_base);
 	} else {
 		if (_get_rate("fin_pll") == 24000000) {
@@ -1217,42 +1220,42 @@ static void __init exynos4_clk_init(struct device_node *np,
 							exynos4x12_vpll_rates;
 		}
 
-		samsung_clk_register_pll(exynos4x12_plls,
+		samsung_clk_register_pll(ctx, exynos4x12_plls,
 					ARRAY_SIZE(exynos4x12_plls), reg_base);
 	}
 
-	samsung_clk_register_fixed_rate(exynos4_fixed_rate_clks,
+	samsung_clk_register_fixed_rate(ctx, exynos4_fixed_rate_clks,
 			ARRAY_SIZE(exynos4_fixed_rate_clks));
-	samsung_clk_register_mux(exynos4_mux_clks,
+	samsung_clk_register_mux(ctx, exynos4_mux_clks,
 			ARRAY_SIZE(exynos4_mux_clks));
-	samsung_clk_register_div(exynos4_div_clks,
+	samsung_clk_register_div(ctx, exynos4_div_clks,
 			ARRAY_SIZE(exynos4_div_clks));
-	samsung_clk_register_gate(exynos4_gate_clks,
+	samsung_clk_register_gate(ctx, exynos4_gate_clks,
 			ARRAY_SIZE(exynos4_gate_clks));
 
 	if (exynos4_soc == EXYNOS4210) {
-		samsung_clk_register_fixed_rate(exynos4210_fixed_rate_clks,
+		samsung_clk_register_fixed_rate(ctx, exynos4210_fixed_rate_clks,
 			ARRAY_SIZE(exynos4210_fixed_rate_clks));
-		samsung_clk_register_mux(exynos4210_mux_clks,
+		samsung_clk_register_mux(ctx, exynos4210_mux_clks,
 			ARRAY_SIZE(exynos4210_mux_clks));
-		samsung_clk_register_div(exynos4210_div_clks,
+		samsung_clk_register_div(ctx, exynos4210_div_clks,
 			ARRAY_SIZE(exynos4210_div_clks));
-		samsung_clk_register_gate(exynos4210_gate_clks,
+		samsung_clk_register_gate(ctx, exynos4210_gate_clks,
 			ARRAY_SIZE(exynos4210_gate_clks));
-		samsung_clk_register_alias(exynos4210_aliases,
+		samsung_clk_register_alias(ctx, exynos4210_aliases,
 			ARRAY_SIZE(exynos4210_aliases));
 	} else {
-		samsung_clk_register_mux(exynos4x12_mux_clks,
+		samsung_clk_register_mux(ctx, exynos4x12_mux_clks,
 			ARRAY_SIZE(exynos4x12_mux_clks));
-		samsung_clk_register_div(exynos4x12_div_clks,
+		samsung_clk_register_div(ctx, exynos4x12_div_clks,
 			ARRAY_SIZE(exynos4x12_div_clks));
-		samsung_clk_register_gate(exynos4x12_gate_clks,
+		samsung_clk_register_gate(ctx, exynos4x12_gate_clks,
 			ARRAY_SIZE(exynos4x12_gate_clks));
-		samsung_clk_register_alias(exynos4x12_aliases,
+		samsung_clk_register_alias(ctx, exynos4x12_aliases,
 			ARRAY_SIZE(exynos4x12_aliases));
 	}
 
-	samsung_clk_register_alias(exynos4_aliases,
+	samsung_clk_register_alias(ctx, exynos4_aliases,
 			ARRAY_SIZE(exynos4_aliases));
 
 	exynos4_clk_sleep_init();
drivers/clk/samsung/clk-exynos5250.c +15 -10
index e7ee442..e549e86 100644
@@ -686,6 +686,8 @@ static struct of_device_id ext_clk_match[] __initdata = {
 /* register exynox5250 clocks */
 static void __init exynos5250_clk_init(struct device_node *np)
 {
+	struct samsung_clk_provider *ctx;
+
 	if (np) {
 		reg_base = of_iomap(np, 0);
 		if (!reg_base)
@@ -694,11 +696,13 @@ static void __init exynos5250_clk_init(struct device_node *np)
 		panic("%s: unable to determine soc\n", __func__);
 	}
 
-	samsung_clk_init(np, reg_base, CLK_NR_CLKS);
-	samsung_clk_of_register_fixed_ext(exynos5250_fixed_rate_ext_clks,
+	ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+	if (!ctx)
+		panic("%s: unable to allocate context.\n", __func__);
+	samsung_clk_of_register_fixed_ext(ctx, exynos5250_fixed_rate_ext_clks,
 			ARRAY_SIZE(exynos5250_fixed_rate_ext_clks),
 			ext_clk_match);
-	samsung_clk_register_mux(exynos5250_pll_pmux_clks,
+	samsung_clk_register_mux(ctx, exynos5250_pll_pmux_clks,
 				ARRAY_SIZE(exynos5250_pll_pmux_clks));
 
 	if (_get_rate("fin_pll") == 24 * MHZ) {
@@ -709,17 +713,18 @@ static void __init exynos5250_clk_init(struct device_node *np)
 	if (_get_rate("mout_vpllsrc") == 24 * MHZ)
 		exynos5250_plls[vpll].rate_table =  vpll_24mhz_tbl;
 
-	samsung_clk_register_pll(exynos5250_plls, ARRAY_SIZE(exynos5250_plls),
-					reg_base);
-	samsung_clk_register_fixed_rate(exynos5250_fixed_rate_clks,
+	samsung_clk_register_pll(ctx, exynos5250_plls,
+			ARRAY_SIZE(exynos5250_plls),
+			reg_base);
+	samsung_clk_register_fixed_rate(ctx, exynos5250_fixed_rate_clks,
 			ARRAY_SIZE(exynos5250_fixed_rate_clks));
-	samsung_clk_register_fixed_factor(exynos5250_fixed_factor_clks,
+	samsung_clk_register_fixed_factor(ctx, exynos5250_fixed_factor_clks,
 			ARRAY_SIZE(exynos5250_fixed_factor_clks));
-	samsung_clk_register_mux(exynos5250_mux_clks,
+	samsung_clk_register_mux(ctx, exynos5250_mux_clks,
 			ARRAY_SIZE(exynos5250_mux_clks));
-	samsung_clk_register_div(exynos5250_div_clks,
+	samsung_clk_register_div(ctx, exynos5250_div_clks,
 			ARRAY_SIZE(exynos5250_div_clks));
-	samsung_clk_register_gate(exynos5250_gate_clks,
+	samsung_clk_register_gate(ctx, exynos5250_gate_clks,
 			ARRAY_SIZE(exynos5250_gate_clks));
 
 	exynos5250_clk_sleep_init();
drivers/clk/samsung/clk-exynos5420.c +15 -9
index 60b2681..c3e0894 100644
@@ -778,6 +778,8 @@ static struct of_device_id ext_clk_match[] __initdata = {
 /* register exynos5420 clocks */
 static void __init exynos5420_clk_init(struct device_node *np)
 {
+	struct samsung_clk_provider *ctx;
+
 	if (np) {
 		reg_base = of_iomap(np, 0);
 		if (!reg_base)
@@ -786,21 +788,25 @@ static void __init exynos5420_clk_init(struct device_node *np)
 		panic("%s: unable to determine soc\n", __func__);
 	}
 
-	samsung_clk_init(np, reg_base, CLK_NR_CLKS);
-	samsung_clk_of_register_fixed_ext(exynos5420_fixed_rate_ext_clks,
+	ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+	if (!ctx)
+		panic("%s: unable to allocate context.\n", __func__);
+
+	samsung_clk_of_register_fixed_ext(ctx, exynos5420_fixed_rate_ext_clks,
 			ARRAY_SIZE(exynos5420_fixed_rate_ext_clks),
 			ext_clk_match);
-	samsung_clk_register_pll(exynos5420_plls, ARRAY_SIZE(exynos5420_plls),
-					reg_base);
-	samsung_clk_register_fixed_rate(exynos5420_fixed_rate_clks,
+	samsung_clk_register_pll(ctx, exynos5420_plls,
+			ARRAY_SIZE(exynos5420_plls),
+			reg_base);
+	samsung_clk_register_fixed_rate(ctx, exynos5420_fixed_rate_clks,
 			ARRAY_SIZE(exynos5420_fixed_rate_clks));
-	samsung_clk_register_fixed_factor(exynos5420_fixed_factor_clks,
+	samsung_clk_register_fixed_factor(ctx, exynos5420_fixed_factor_clks,
 			ARRAY_SIZE(exynos5420_fixed_factor_clks));
-	samsung_clk_register_mux(exynos5420_mux_clks,
+	samsung_clk_register_mux(ctx, exynos5420_mux_clks,
 			ARRAY_SIZE(exynos5420_mux_clks));
-	samsung_clk_register_div(exynos5420_div_clks,
+	samsung_clk_register_div(ctx, exynos5420_div_clks,
 			ARRAY_SIZE(exynos5420_div_clks));
-	samsung_clk_register_gate(exynos5420_gate_clks,
+	samsung_clk_register_gate(ctx, exynos5420_gate_clks,
 			ARRAY_SIZE(exynos5420_gate_clks));
 
 	exynos5420_clk_sleep_init();
drivers/clk/samsung/clk-exynos5440.c +11 -7
index 2bfad5a..aeb76d1 100644
@@ -93,6 +93,7 @@ static struct of_device_id ext_clk_match[] __initdata = {
 static void __init exynos5440_clk_init(struct device_node *np)
 {
 	void __iomem *reg_base;
+	struct samsung_clk_provider *ctx;
 
 	reg_base = of_iomap(np, 0);
 	if (!reg_base) {
@@ -101,22 +102,25 @@ static void __init exynos5440_clk_init(struct device_node *np)
 		return;
 	}
 
-	samsung_clk_init(np, reg_base, CLK_NR_CLKS);
-	samsung_clk_of_register_fixed_ext(exynos5440_fixed_rate_ext_clks,
+	ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
+	if (!ctx)
+		panic("%s: unable to allocate context.\n", __func__);
+
+	samsung_clk_of_register_fixed_ext(ctx, exynos5440_fixed_rate_ext_clks,
 		ARRAY_SIZE(exynos5440_fixed_rate_ext_clks), ext_clk_match);
 
 	samsung_clk_register_pll2550x("cplla", "xtal", reg_base + 0x1c, 0x10);
 	samsung_clk_register_pll2550x("cpllb", "xtal", reg_base + 0x20, 0x10);
 
-	samsung_clk_register_fixed_rate(exynos5440_fixed_rate_clks,
+	samsung_clk_register_fixed_rate(ctx, eexynos5440_fixed_rate_clks,
 			ARRAY_SIZE(exynos5440_fixed_rate_clks));
-	samsung_clk_register_fixed_factor(exynos5440_fixed_factor_clks,
+	samsung_clk_register_fixed_factor(ctx, eexynos5440_fixed_factor_clks,
 			ARRAY_SIZE(exynos5440_fixed_factor_clks));
-	samsung_clk_register_mux(exynos5440_mux_clks,
+	samsung_clk_register_mux(ctx, eexynos5440_mux_clks,
 			ARRAY_SIZE(exynos5440_mux_clks));
-	samsung_clk_register_div(exynos5440_div_clks,
+	samsung_clk_register_div(ctx, eexynos5440_div_clks,
 			ARRAY_SIZE(exynos5440_div_clks));
-	samsung_clk_register_gate(exynos5440_gate_clks,
+	samsung_clk_register_gate(ctx, exynos5440_gate_clks,
 			ARRAY_SIZE(exynos5440_gate_clks));
 
 	pr_info("Exynos5440: arm_clk = %ldHz\n", _get_rate("arm_clk"));
drivers/clk/samsung/clk-pll.c +8 -6
index 81e6d2f..dced769 100644
@@ -710,8 +710,9 @@ struct clk * __init samsung_clk_register_pll2550x(const char *name,
 	return clk;
 }
 
-static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk,
-						void __iomem *base)
+static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
+				struct samsung_pll_clock *pll_clk,
+				void __iomem *base)
 {
 	struct samsung_clk_pll *pll;
 	struct clk *clk;
@@ -804,7 +805,7 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk,
 		return;
 	}
 
-	samsung_clk_add_lookup(clk, pll_clk->id);
+	samsung_clk_add_lookup(ctx, clk, pll_clk->id);
 
 	if (!pll_clk->alias)
 		return;
@@ -815,11 +816,12 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk,
 			__func__, pll_clk->name, ret);
 }
 
-void __init samsung_clk_register_pll(struct samsung_pll_clock *pll_list,
-				unsigned int nr_pll, void __iomem *base)
+void __init samsung_clk_register_pll(struct samsung_clk_provider *ctx,
+			struct samsung_pll_clock *pll_list,
+			unsigned int nr_pll, void __iomem *base)
 {
 	int cnt;
 
 	for (cnt = 0; cnt < nr_pll; cnt++)
-		_samsung_clk_register_pll(&pll_list[cnt], base);
+		_samsung_clk_register_pll(ctx, &pll_list[cnt], base);
 }
drivers/clk/samsung/clk-s3c64xx.c +25 -19

91 lines not on this page · raw message

drivers/clk/samsung/clk.c +63 -52

246 lines not on this page · raw message

drivers/clk/samsung/clk.h +48 -24

94 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 2/5 clk/samsung: add support for pll2550xx

In reply to Rahul Sharma

From: Pankaj Dubey <[email protected]>

exynos5260 use pll2550xx and it has different bit fields for P,M,S values as compared to pll2550. Support for pll2550xx is added here.

---
 drivers/clk/samsung/clk-pll.c |  108 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-pll.h |    1 +
 2 files changed, 109 insertions(+)
drivers/clk/samsung/clk-pll.c +108 -0
index dced769..56b3fbe 100644
@@ -710,6 +710,108 @@ struct clk * __init samsung_clk_register_pll2550x(const char *name,
 	return clk;
 }
 
+/*
+ * PLL2550xx Clock Type
+ */
+
+/* Maximum lock time can be 270 * PDIV cycles */
+#define PLL2550XX_LOCK_FACTOR 270
+
+#define PLL2550XX_M_MASK		0x3FF
+#define PLL2550XX_P_MASK		0x3F
+#define PLL2550XX_S_MASK		0x7
+#define PLL2550XX_LOCK_STAT_MASK	0x1
+#define PLL2550XX_M_SHIFT		9
+#define PLL2550XX_P_SHIFT		3
+#define PLL2550XX_S_SHIFT		0
+#define PLL2550XX_LOCK_STAT_SHIFT	21
+
+static unsigned long samsung_pll2550xx_recalc_rate(struct clk_hw *hw,
+				unsigned long parent_rate)
+{
+	struct samsung_clk_pll *pll = to_clk_pll(hw);
+	u32 mdiv, pdiv, sdiv, pll_con;
+	u64 fvco = parent_rate;
+
+	pll_con = __raw_readl(pll->con_reg);
+	mdiv = (pll_con >> PLL2550XX_M_SHIFT) & PLL2550XX_M_MASK;
+	pdiv = (pll_con >> PLL2550XX_P_SHIFT) & PLL2550XX_P_MASK;
+	sdiv = (pll_con >> PLL2550XX_S_SHIFT) & PLL2550XX_S_MASK;
+
+	fvco *= mdiv;
+	do_div(fvco, (pdiv << sdiv));
+
+	return (unsigned long)fvco;
+}
+
+static inline bool samsung_pll2550xx_mp_change(u32 mdiv, u32 pdiv, u32 pll_con)
+{
+	u32 old_mdiv, old_pdiv;
+
+	old_mdiv = (pll_con >> PLL2550XX_M_SHIFT) & PLL2550XX_M_MASK;
+	old_pdiv = (pll_con >> PLL2550XX_P_SHIFT) & PLL2550XX_P_MASK;
+
+	return mdiv != old_mdiv || pdiv != old_pdiv;
+}
+
+static int samsung_pll2550xx_set_rate(struct clk_hw *hw, unsigned long drate,
+					unsigned long prate)
+{
+	struct samsung_clk_pll *pll = to_clk_pll(hw);
+	const struct samsung_pll_rate_table *rate;
+	u32 tmp;
+
+	/* Get required rate settings from table */
+	rate = samsung_get_pll_settings(pll, drate);
+	if (!rate) {
+		pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__,
+			drate, __clk_get_name(hw->clk));
+		return -EINVAL;
+	}
+
+	tmp = __raw_readl(pll->con_reg);
+
+	if (!(samsung_pll2550xx_mp_change(rate->mdiv, rate->pdiv, tmp))) {
+		/* If only s change, change just s value only*/
+		tmp &= ~(PLL2550XX_S_MASK << PLL2550XX_S_SHIFT);
+		tmp |= rate->sdiv << PLL2550XX_S_SHIFT;
+		__raw_writel(tmp, pll->con_reg);
+
+		return 0;
+	}
+
+	/* Set PLL lock time. */
+	__raw_writel(rate->pdiv * PLL2550XX_LOCK_FACTOR, pll->lock_reg);
+
+	/* Change PLL PMS values */
+	tmp &= ~((PLL2550XX_M_MASK << PLL2550XX_M_SHIFT) |
+			(PLL2550XX_P_MASK << PLL2550XX_P_SHIFT) |
+			(PLL2550XX_S_MASK << PLL2550XX_S_SHIFT));
+	tmp |= (rate->mdiv << PLL2550XX_M_SHIFT) |
+			(rate->pdiv << PLL2550XX_P_SHIFT) |
+			(rate->sdiv << PLL2550XX_S_SHIFT);
+	__raw_writel(tmp, pll->con_reg);
+
+	/* wait_lock_time */
+	do {
+		cpu_relax();
+		tmp = __raw_readl(pll->con_reg);
+	} while (!(tmp & (PLL2550XX_LOCK_STAT_MASK
+			<< PLL2550XX_LOCK_STAT_SHIFT)));
+
+	return 0;
+}
+
+static const struct clk_ops samsung_pll2550xx_clk_ops = {
+	.recalc_rate = samsung_pll2550xx_recalc_rate,
+	.round_rate = samsung_pll_round_rate,
+	.set_rate = samsung_pll2550xx_set_rate,
+};
+
+static const struct clk_ops samsung_pll2550xx_clk_min_ops = {
+	.recalc_rate = samsung_pll2550xx_recalc_rate,
+};
+
 static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
 				struct samsung_pll_clock *pll_clk,
 				void __iomem *base)
@@ -787,6 +889,12 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
 		else
 			init.ops = &samsung_pll46xx_clk_ops;
 		break;
+	case pll_2550xx:
+		if (!pll->rate_table)
+			init.ops = &samsung_pll2550xx_clk_min_ops;
+		else
+			init.ops = &samsung_pll2550xx_clk_ops;
+		break;
 	default:
 		pr_warn("%s: Unknown pll type for pll clk %s\n",
 			__func__, pll_clk->name);
drivers/clk/samsung/clk-pll.h +1 -0
index 6c39030..e106470 100644
@@ -25,6 +25,7 @@ enum samsung_pll_type {
 	pll_4650c,
 	pll_6552,
 	pll_6553,
+	pll_2550xx,
 };
 
 #define PLL_35XX_RATE(_rate, _m, _p, _s)			\
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v3 3/5 clk/samsung: add support for pll2650xx

In reply to Rahul Sharma

Add support for pll2650xx in samsung pll file. This pll variant is close to pll36xx but uses CON2 registers instead of CON1.

Aud_pll in Exynos5260 is pll2650xx and uses this code.

---
 drivers/clk/samsung/clk-pll.c |  101 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-pll.h |    1 +
 2 files changed, 102 insertions(+)
drivers/clk/samsung/clk-pll.c +101 -0
index 56b3fbe..801b3dd 100644
@@ -812,6 +812,101 @@ static const struct clk_ops samsung_pll2550xx_clk_min_ops = {
 	.recalc_rate = samsung_pll2550xx_recalc_rate,
 };
 
+/*
+ * PLL2650XX Clock Type
+ */
+
+/* Maximum lock time can be 3000 * PDIV cycles */
+#define PLL2650XX_LOCK_FACTOR 3000
+
+#define PLL2650XX_MDIV_SHIFT		9
+#define PLL2650XX_PDIV_SHIFT		3
+#define PLL2650XX_SDIV_SHIFT		0
+#define PLL2650XX_KDIV_SHIFT		0
+#define PLL2650XX_MDIV_MASK		0x1ff
+#define PLL2650XX_PDIV_MASK		0x3f
+#define PLL2650XX_SDIV_MASK		0x7
+#define PLL2650XX_KDIV_MASK		0xffff
+#define PLL2650XX_PLL_ENABLE_SHIFT	23
+#define PLL2650XX_PLL_LOCKTIME_SHIFT	21
+#define PLL2650XX_PLL_FOUTMASK_SHIFT	31
+
+static unsigned long samsung_pll2650xx_recalc_rate(struct clk_hw *hw,
+				unsigned long parent_rate)
+{
+	struct samsung_clk_pll *pll = to_clk_pll(hw);
+	u32 mdiv, pdiv, sdiv, pll_con0, pll_con2;
+	s16 kdiv;
+	u64 fvco = parent_rate;
+
+	pll_con0 = __raw_readl(pll->con_reg);
+	pll_con2 = __raw_readl(pll->con_reg + 8);
+	mdiv = (pll_con0 >> PLL2650XX_MDIV_SHIFT) & PLL2650XX_MDIV_MASK;
+	pdiv = (pll_con0 >> PLL2650XX_PDIV_SHIFT) & PLL2650XX_PDIV_MASK;
+	sdiv = (pll_con0 >> PLL2650XX_SDIV_SHIFT) & PLL2650XX_SDIV_MASK;
+	kdiv = (s16)(pll_con2 & PLL2650XX_KDIV_MASK);
+
+	fvco *= (mdiv << 16) + kdiv;
+	do_div(fvco, (pdiv << sdiv));
+	fvco >>= 16;
+
+	return (unsigned long)fvco;
+}
+
+static int samsung_pll2650xx_set_rate(struct clk_hw *hw, unsigned long drate,
+					unsigned long parent_rate)
+{
+	struct samsung_clk_pll *pll = to_clk_pll(hw);
+	u32 tmp, pll_con0, pll_con2;
+	const struct samsung_pll_rate_table *rate;
+
+	rate = samsung_get_pll_settings(pll, drate);
+	if (!rate) {
+		pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__,
+			drate, __clk_get_name(hw->clk));
+		return -EINVAL;
+	}
+
+	pll_con0 = __raw_readl(pll->con_reg);
+	pll_con2 = __raw_readl(pll->con_reg + 8);
+
+	 /* Change PLL PMS values */
+	pll_con0 &= ~(PLL2650XX_MDIV_MASK << PLL2650XX_MDIV_SHIFT |
+			PLL2650XX_PDIV_MASK << PLL2650XX_PDIV_SHIFT |
+			PLL2650XX_SDIV_MASK << PLL2650XX_SDIV_SHIFT);
+	pll_con0 |= rate->mdiv << PLL2650XX_MDIV_SHIFT;
+	pll_con0 |= rate->pdiv << PLL2650XX_PDIV_SHIFT;
+	pll_con0 |= rate->sdiv << PLL2650XX_SDIV_SHIFT;
+	pll_con0 |= 1 << PLL2650XX_PLL_ENABLE_SHIFT;
+	pll_con0 |= 1 << PLL2650XX_PLL_FOUTMASK_SHIFT;
+
+	pll_con2 &= ~(PLL2650XX_KDIV_MASK << PLL2650XX_KDIV_SHIFT);
+	pll_con2 |= ((~(rate->kdiv) + 1) & PLL2650XX_KDIV_MASK)
+			<< PLL2650XX_KDIV_SHIFT;
+
+	/* Set PLL lock time. */
+	__raw_writel(PLL2650XX_LOCK_FACTOR * rate->pdiv, pll->lock_reg);
+
+	__raw_writel(pll_con0, pll->con_reg);
+	__raw_writel(pll_con2, pll->con_reg + 8);
+
+	do {
+		tmp = __raw_readl(pll->con_reg);
+	} while (!(tmp & (0x1 << PLL2650XX_PLL_LOCKTIME_SHIFT)));
+
+	return 0;
+}
+
+static const struct clk_ops samsung_pll2650xx_clk_ops = {
+	.recalc_rate = samsung_pll2650xx_recalc_rate,
+	.set_rate = samsung_pll2650xx_set_rate,
+	.round_rate = samsung_pll_round_rate,
+};
+
+static const struct clk_ops samsung_pll2650xx_clk_min_ops = {
+	.recalc_rate = samsung_pll2650xx_recalc_rate,
+};
+
 static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
 				struct samsung_pll_clock *pll_clk,
 				void __iomem *base)
@@ -895,6 +990,12 @@ static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
 		else
 			init.ops = &samsung_pll2550xx_clk_ops;
 		break;
+	case pll_2650xx:
+		if (!pll->rate_table)
+			init.ops = &samsung_pll2650xx_clk_min_ops;
+		else
+			init.ops = &samsung_pll2650xx_clk_ops;
+		break;
 	default:
 		pr_warn("%s: Unknown pll type for pll clk %s\n",
 			__func__, pll_clk->name);
drivers/clk/samsung/clk-pll.h +1 -0
index e106470..fa9bdaf 100644
@@ -26,6 +26,7 @@ enum samsung_pll_type {
 	pll_6552,
 	pll_6553,
 	pll_2550xx,
+	pll_2650xx,
 };
 
 #define PLL_35XX_RATE(_rate, _m, _p, _s)			\
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v3 4/5 clk/exynos5260: add macros and documentation for exynos5260

In reply to Rahul Sharma

Add macros which are used as Clock IDs in DT and clock file. It also adds the documentation for the exynos5260 clocks.

---
 .../devicetree/bindings/clock/exynos5260-clock.txt |  299 ++++++++++++++++++++
 include/dt-bindings/clk/exynos5260-clk.h           |  234 +++++++++++++++
 2 files changed, 533 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/exynos5260-clock.txt
 create mode 100644 include/dt-bindings/clk/exynos5260-clk.h
Documentation/devicetree/bindings/clock/exynos5260-clock.txt new file +299 -0
new file mode 100644
index 0000000..ec180c0
@@ -0,0 +1,299 @@
+* Samsung Exynos5260 Clock Controller
+
+The Exynos5260 clock controller encalsulate all CMUs which are
+instantiaited independently from the device-tree. As a whole,
+these CMUs generates and supplies clocks to various controllers
+within the Exynos5260 SoC.
+
+Required Properties:
+
+- compatible: should be one of the following.
+  - First compatible should be one of the following
+		"exynos5260-cmu-top"
+		"exynos5260-cmu-peri"
+		"exynos5260-cmu-egl"
+		"exynos5260-cmu-kfc"
+		"exynos5260-cmu-g2d"
+		"exynos5260-cmu-mif"
+		"exynos5260-cmu-mfc"
+		"exynos5260-cmu-g3d"
+		"exynos5260-cmu-fsys"
+		"exynos5260-cmu-aud"
+		"exynos5260-cmu-isp"
+		"exynos5260-cmu-gscl"
+		"exynos5260-cmu-disp"
+  - Second compatible should be "samsung,exynos5260-clock".
+
+- reg: physical base address of the controller and length of memory mapped
+  region.
+
+- #clock-cells: should be 1.
+
+The following is the list of clocks generated by the each controller. Each
+clock is assigned a MACRO constant. These constants are defined in
+"dt-bindings/clk/exynos5260-clk.h". DT client nodes use this MACRO to specify
+the clock which they consume.
+
+-----------------------
+  CMU_TOP clocks
+-----------------------
+
+  FIN_PLL
+  TOP_FOUT_DISP_PLL
+  TOP_FOUT_AUD_PLL
+  TOP_SCLK_MMC0
+  TOP_SCLK_MMC1
+  TOP_SCLK_MMC2
+  TOP_SCLK_HDMIPHY
+  TOP_SCLK_FIMD1
+  TOP_MOUT_FIMD1
+  TOP_MOUT_DISP_PLL
+
+-----------------------
+  CMU_EGL clocks
+-----------------------
+
+  EGL_FOUT_EGL_PLL
+  EGL_FOUT_EGL_DPLL
+
+-----------------------
+  CMU_KFC clocks
+-----------------------
+
+  KFC_FOUT_KFC_PLL
+
+-----------------------
+  CMU_MIF clocks
+-----------------------
+
+  MIF_FOUT_MEM_PLL
+  MIF_FOUT_BUS_PLL
+  MIF_FOUT_MEDIA_PLL
+
+-----------------------
+  CMU_G3D clocks
+-----------------------
+
+  G3D_FOUT_G3D_PLL
+  G3D_CLK_G3D_HPM
+  G3D_CLK_G3D
+
+-----------------------
+  CMU_AUD clocks
+-----------------------
+
+  AUD_CLK_AUD_UART
+  AUD_CLK_PCM
+  AUD_CLK_I2S
+  AUD_CLK_DMAC
+  AUD_SCLK_AUD_UART
+  AUD_SCLK_PCM
+  AUD_SCLK_I2S
+  AUD_NR_CLK
+
+-----------------------
+  CMU_MFC clocks
+-----------------------
+
+  MFC_CLK_MFC
+  MFC_CLK_SMMU2_MFCM1
+  MFC_CLK_SMMU2_MFCM0
+
+-----------------------
+  CMU_GSCL clocks
+-----------------------
+
+  GSCL_CLK_PIXEL_GSCL1
+  GSCL_CLK_PIXEL_GSCL0
+  GSCL_CLK_MSCL1
+  GSCL_CLK_MSCL0
+  GSCL_CLK_GSCL1
+  GSCL_CLK_GSCL0
+  GSCL_CLK_FIMC_LITE_D
+  GSCL_CLK_FIMC_LITE_B
+  GSCL_CLK_FIMC_LITE_A
+  GSCL_CLK_CSIS1
+  GSCL_CLK_CSIS0
+  GSCL_CLK_SMMU3_LITE_D
+  GSCL_CLK_SMMU3_LITE_B
+  GSCL_CLK_SMMU3_LITE_A
+  GSCL_CLK_SMMU3_GSCL0
+  GSCL_CLK_SMMU3_GSCL1
+  GSCL_CLK_SMMU3_MSCL0
+  GSCL_CLK_SMMU3_MSCL1
+  GSCL_SCLK_CSIS1_WRAP
+  GSCL_SCLK_CSIS0_WRAP
+
+-----------------------
+  CMU_FSYS clocks
+-----------------------
+
+  FSYS_CLK_TSI
+  FSYS_CLK_USBLINK
+  FSYS_CLK_USBHOST20
+  FSYS_CLK_USBDRD30
+  FSYS_CLK_SROMC
+  FSYS_CLK_PDMA
+  FSYS_CLK_MMC2
+  FSYS_CLK_MMC1
+  FSYS_CLK_MMC0
+  FSYS_CLK_RTIC
+  FSYS_CLK_SMMU_RTIC
+  FSYS_PHYCLK_USBDRD30
+  FSYS_PHYCLK_USBHOST20
+  FSYS_NR_CLK
+
+-----------------------
+  CMU_PERI clocks
+-----------------------
+
+  PERI_CLK_WDT_KFC
+  PERI_CLK_WDT_EGL
+  PERI_CLK_HSIC3
+  PERI_CLK_HSIC2
+  PERI_CLK_HSIC1
+  PERI_CLK_HSIC0
+  PERI_CLK_PCM
+  PERI_CLK_MCT
+  PERI_CLK_I2S
+  PERI_CLK_I2CHDMI
+  PERI_CLK_I2C7
+  PERI_CLK_I2C6
+  PERI_CLK_I2C5
+  PERI_CLK_I2C4
+  PERI_CLK_I2C9
+  PERI_CLK_I2C8
+  PERI_CLK_I2C11
+  PERI_CLK_I2C10
+  PERI_CLK_HDMICEC
+  PERI_CLK_EFUSE_WRITER
+  PERI_CLK_ABB
+  PERI_CLK_UART2
+  PERI_CLK_UART1
+  PERI_CLK_UART0
+  PERI_CLK_ADC
+  PERI_CLK_TMU4
+  PERI_CLK_TMU3
+  PERI_CLK_TMU2
+  PERI_CLK_TMU1
+  PERI_CLK_TMU0
+  PERI_CLK_SPI2
+  PERI_CLK_SPI1
+  PERI_CLK_SPI0
+  PERI_CLK_SPDIF
+  PERI_CLK_PWM
+  PERI_CLK_UART4
+  PERI_CLK_CHIPID
+  PERI_CLK_PROVKEY0
+  PERI_CLK_PROVKEY1
+  PERI_CLK_SECKEY
+  PERI_CLK_TOP_RTC
+  PERI_CLK_TZPC10
+  PERI_CLK_TZPC9
+  PERI_CLK_TZPC8
+  PERI_CLK_TZPC7
+  PERI_CLK_TZPC6
+  PERI_CLK_TZPC5
+  PERI_CLK_TZPC4
+  PERI_CLK_TZPC3
+  PERI_CLK_TZPC2
+  PERI_CLK_TZPC1
+  PERI_CLK_TZPC0
+  PERI_SCLK_SPI2
+  PERI_SCLK_SPI1
+  PERI_SCLK_SPI0
+  PERI_SCLK_SPDIF
+  PERI_SCLK_I2S
+  PERI_SCLK_PCM1
+  PERI_SCLK_UART2
+  PERI_SCLK_UART1
+  PERI_SCLK_UART0
+
+-----------------------
+  CMU_DISP clocks
+-----------------------
+
+  DISP_CLK_SMMU_TV
+  DISP_CLK_SMMU_FIMD1M1
+  DISP_CLK_SMMU_FIMD1M0
+  DISP_CLK_MIXER
+  DISP_CLK_MIPIPHY
+  DISP_CLK_HDMIPHY
+  DISP_CLK_HDMI
+  DISP_CLK_FIMD1
+  DISP_CLK_DSIM1
+  DISP_CLK_DPPHY
+  DISP_CLK_DP
+  DISP_SCLK_PIXEL
+  DISP_SCLK_HDMI
+  DISP_MOUT_HDMI_PHY_PIXEL
+  DISP_NR_CLK
+
+-----------------------
+  CMU_G2D clocks
+-----------------------
+
+  G2D_CLK_SMMU3_JPEG
+  G2D_CLK_MDMA
+  G2D_CLK_JPEG
+  G2D_CLK_G2D
+  G2D_CLK_SSS
+  G2D_CLK_SLIM_SSS
+  G2D_CLK_SMMU_SLIM_SSS
+  G2D_CLK_SMMU_SSS
+  G2D_CLK_SMMU_MDMA
+  G2D_CLK_SMMU3_G2D
+
+-----------------------
+  CMU_ISP clocks
+-----------------------
+
+  ISP_CLK_GIC
+  ISP_CLK_WDT
+  ISP_CLK_UART
+  ISP_CLK_SPI1
+  ISP_CLK_SPI0
+  ISP_CLK_SMMU_SCALERP
+  ISP_CLK_SMMU_SCALERC
+  ISP_CLK_SMMU_ISPCX
+  ISP_CLK_SMMU_ISP
+  ISP_CLK_SMMU_FD
+  ISP_CLK_SMMU_DRC
+  ISP_CLK_PWM
+  ISP_CLK_MTCADC
+  ISP_CLK_MPWM
+  ISP_CLK_MCUCTL
+  ISP_CLK_I2C1
+  ISP_CLK_I2C0
+  ISP_CLK_FIMC_SCALERP
+  ISP_CLK_FIMC_SCALERC
+  ISP_CLK_FIMC
+  ISP_CLK_FIMC_FD
+  ISP_CLK_FIMC_DRC
+  ISP_CLK_CA5
+  ISP_SCLK_SPI0_EXT
+  ISP_SCLK_SPI1_EXT
+  ISP_SCLK_UART_EXT
+
+
+Example 1: An example of a clock controller node is listed below.
+
+	cmu_disp: clock-controller at 0x14550000 {
+		compatible = "exynos5260-cmu-disp", "samsung,exynos5260-clock";
+		reg = <0x14550000 0x10000>;
+		#clock-cells = <1>;
+	};
+
+Example 2: UART controller node that consumes the clock generated by the
+		peri clock controller. Refer to the standard clock bindings for
+		information about 'clocks' and 'clock-names' property.
+
+	serial at 12C00000 {
+		compatible = "samsung,exynos4210-uart";
+		reg = <0x12C00000 0x100>;
+		interrupts = <0 146 0>;
+		clocks = <&cmu_peri PERI_PCLK_UART0>, <&cmu_peri PERI_SCLK_UART0>;
+		clock-names = "uart", "clk_uart_baud0";
+		status = "disabled";
+	};
+
include/dt-bindings/clk/exynos5260-clk.h new file +234 -0

234 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v3 4/5 clk/exynos5260: add macros and documentation for exynos5260

Hi Rahul,

Quoted 32 lines · Rahul Sharma

Add macros which are used as Clock IDs in DT and clock file. It also adds the documentation for the exynos5260 clocks.

---
  .../devicetree/bindings/clock/exynos5260-clock.txt |  299 ++++++++++++++++++++
  include/dt-bindings/clk/exynos5260-clk.h           |  234 +++++++++++++++
  2 files changed, 533 insertions(+)

create mode 100644 Documentation/devicetree/bindings/clock/exynos5260-clock.txt create mode 100644 include/dt-bindings/clk/exynos5260-clk.h

Documentation/devicetree/bindings/clock/exynos5260-clock.txt new file +15 -0
new file mode 100644
index 0000000..ec180c0
@@ -0,0 +1,299 @@
+* Samsung Exynos5260 Clock Controller
+
+The Exynos5260 clock controller encalsulate all CMUs which are
+instantiaited independently from the device-tree. As a whole,
+these CMUs generates and supplies clocks to various controllers
+within the Exynos5260 SoC.
+
+Required Properties:
+
+- compatible: should be one of the following.
+  - First compatible should be one of the following
+		"exynos5260-cmu-top"
+		"exynos5260-cmu-peri"
+		"exynos5260-cmu-egl"
+		"exynos5260-cmu-kfc"

Documentation/devicetree/bindings/clock/exynos5260-clock.txt line 25

Quoted 10 lines
Documentation/devicetree/bindings/clock/exynos5260-clock.txt new file +10 -0
+		"exynos5260-cmu-g2d"
+		"exynos5260-cmu-mif"
+		"exynos5260-cmu-mfc"
+		"exynos5260-cmu-g3d"
+		"exynos5260-cmu-fsys"
+		"exynos5260-cmu-aud"
+		"exynos5260-cmu-isp"
+		"exynos5260-cmu-gscl"
+		"exynos5260-cmu-disp"
+  - Second compatible should be "samsung,exynos5260-clock".

This is no longer true, as we have decided to remove the second compatible.

Documentation/devicetree/bindings/clock/exynos5260-clock.txt line 35

Quoted 10 lines
Documentation/devicetree/bindings/clock/exynos5260-clock.txt new file +10 -0
+
+- reg: physical base address of the controller and length of memory mapped
+  region.
+
+- #clock-cells: should be 1.
+
+The following is the list of clocks generated by the each controller. Each
+clock is assigned a MACRO constant. These constants are defined in
+"dt-bindings/clk/exynos5260-clk.h". DT client nodes use this MACRO to specify
+the clock which they consume.

There is no need to list all the macros in this file, if there is a reference to the header where they are defined.

Quoted 9 lines
Documentation/devicetree/bindings/clock/exynos5260-clock.txt new file +9 -0
+
+-----------------------
+  CMU_TOP clocks
+-----------------------
+
+  FIN_PLL
+  TOP_FOUT_DISP_PLL
+  TOP_FOUT_AUD_PLL
+  TOP_SCLK_MMC0

[snip]

Documentation/devicetree/bindings/clock/exynos5260-clock.txt line 282

Quoted 9 lines
Documentation/devicetree/bindings/clock/exynos5260-clock.txt new file +9 -0
+  ISP_SCLK_SPI0_EXT
+  ISP_SCLK_SPI1_EXT
+  ISP_SCLK_UART_EXT
+
+
+Example 1: An example of a clock controller node is listed below.
+
+	cmu_disp: clock-controller at 0x14550000 {
+		compatible = "exynos5260-cmu-disp", "samsung,exynos5260-clock";

Forgot to remove second compatible?

Quoted 27 lines
Documentation/devicetree/bindings/clock/exynos5260-clock.txt new file +17 -0
+		reg = <0x14550000 0x10000>;
+		#clock-cells = <1>;
+	};
+
+Example 2: UART controller node that consumes the clock generated by the
+		peri clock controller. Refer to the standard clock bindings for
+		information about 'clocks' and 'clock-names' property.
+
+	serial at 12C00000 {
+		compatible = "samsung,exynos4210-uart";
+		reg = <0x12C00000 0x100>;
+		interrupts = <0 146 0>;
+		clocks = <&cmu_peri PERI_PCLK_UART0>, <&cmu_peri PERI_SCLK_UART0>;
+		clock-names = "uart", "clk_uart_baud0";
+		status = "disabled";
+	};
+
include/dt-bindings/clk/exynos5260-clk.h new file +4 -0
new file mode 100644
index 0000000..d2fb7fa
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify

include/dt-bindings/clk/exynos5260-clk.h line 14

Quoted 10 lines
include/dt-bindings/clk/exynos5260-clk.h new file +10 -0
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Provides Constants for Exynos5260 clocks.
+*/
+
+#ifndef _DT_BINDINGS_CLK_EXYNOS5260_H
+#define _DT_BINDINGS_CLK_EXYNOS5260_H
+
+#define	ID_NONE		0

This is not a part of DT binding and should not be defined here. Furthermore, the driver should simply use 0 directly.

include/dt-bindings/clk/exynos5260-clk.h line 23

Quoted 9 lines
include/dt-bindings/clk/exynos5260-clk.h new file +9 -0
+
+/*
+ * Clock names: XXXXXX_YYYYY_ZZZZZ
+ *                    |------| |----| |----|
+ *                       cmu       type      IP
+*/
+
+/* list of clocks for CMU_TOP */
+#define	FIN_PLL			1

Hmm, isn't this an external clock?

Best regards,
Tomasz

#6 lore raw

PATCH v3 5/5 clk/exynos5260: add clock file for exynos5260

In reply to Rahul Sharma

Add support for exynos5260 clocks in clock driver.

---
 drivers/clk/samsung/Makefile         |    1 +
 drivers/clk/samsung/clk-exynos5260.c | 2235 ++++++++++++++++++++++++++++++++++
 drivers/clk/samsung/clk-exynos5260.h |  480 ++++++++
 3 files changed, 2716 insertions(+)
 create mode 100644 drivers/clk/samsung/clk-exynos5260.c
 create mode 100644 drivers/clk/samsung/clk-exynos5260.h
drivers/clk/samsung/Makefile +1 -0
index 8eb4799..f791b31 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_COMMON_CLK)	+= clk.o clk-pll.o
 obj-$(CONFIG_ARCH_EXYNOS4)	+= clk-exynos4.o
 obj-$(CONFIG_SOC_EXYNOS5250)	+= clk-exynos5250.o
+obj-$(CONFIG_SOC_EXYNOS5260)	+= clk-exynos5260.o
 obj-$(CONFIG_SOC_EXYNOS5420)	+= clk-exynos5420.o
 obj-$(CONFIG_SOC_EXYNOS5440)	+= clk-exynos5440.o
 obj-$(CONFIG_ARCH_EXYNOS)	+= clk-exynos-audss.o
drivers/clk/samsung/clk-exynos5260.c new file +2235 -0

2,235 lines not on this page · raw message

drivers/clk/samsung/clk-exynos5260.h new file +480 -0

480 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v3 5/5 clk/exynos5260: add clock file for exynos5260

Hi Rahul,

On 18.02.2014 12:56, Rahul Sharma wrote:

[snip]

drivers/clk/samsung/clk-exynos5260.c line 2

Quoted 8 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
new file mode 100644
index 0000000..bcb633e
@@ -0,0 +1,2235 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.

Most likely it should be 2013-2014 now.

Quoted 7 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Common Clock Framework support for Exynos5260 SoC.
+*/

[snip]

drivers/clk/samsung/clk-exynos5260.c line 39

Quoted 6 lines
drivers/clk/samsung/clk-exynos5260.c new file +6 -0
+#ifdef CONFIG_PM_SLEEP
+
+/*
+ * list of controller registers to be saved and restored during a
+ * suspend/resume cycle.
+*/

nit: Unaligned star. + The same for a lot of comments in this file.

drivers/clk/samsung/clk-exynos5260.c

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+
+static unsigned long exynos5260_aud_clk_regs[] __initdata = {

nit: There is no need to prefix every static variable in this file with exynos5260_. Shorter (but still completely readable) names will let the code using them have shorter lines.

Quoted 5 lines

+ *Registers for CMU_AUD

drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+*/
+	MUX_SEL_AUD,
+	DIV_AUD0,
+	DIV_AUD1,

[snip]

Quoted 11 lines
drivers/clk/samsung/clk-exynos5260.c new file +11 -0
+static void exynos5260_clk_sleep_init(void __iomem *reg_base,
+			unsigned long *rdump,
+			unsigned long nr_rdump)
+{
+	struct exynos5260_clock_reg_cache *reg_cache;
+
+	reg_cache = kzalloc(sizeof(struct exynos5260_clock_reg_cache),
+			GFP_KERNEL);
+	if (!reg_cache)
+		panic("could not allocate register cache.\n");
+

drivers/clk/samsung/clk-exynos5260.c line 382

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	reg_cache->rdump = samsung_clk_alloc_reg_dump(rdump, nr_rdump);
+
+	if (!reg_cache->rdump)
+		panic("could not allocate register dump storage.\n");
+
+	reg_cache->rd_num = nr_rdump;
+	reg_cache->reg_base = reg_base;
+	list_add_tail(&reg_cache->node, &clock_reg_cache_list);
+
+	if (!syscore_ops_registered) {

To eliminate the need for having a separate variable, you can simply move this if clause before list_add_tail() and check for list_empty().

drivers/clk/samsung/clk-exynos5260.c line 387

Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +5 -0
+		register_syscore_ops(&exynos5260_clk_syscore_ops);
+		syscore_ops_registered = true;
+	}
+
+	exynos5260_clk_suspend();

What is the reason to call this here and save register values of all registered CMus every time a new CMU is instantiated?

Quoted 14 lines
drivers/clk/samsung/clk-exynos5260.c new file +14 -0
+}
+
+#else
+static void exynos5260_clk_sleep_init(void) {}
+#endif
+
+/*
+ * List of parent clocks for muses in CMU_AUD
+*/
+PNAME(mout_aud_pll_user_p) = {"fin_pll", "fout_aud_pll"};
+PNAME(mout_sclk_aud_i2s_p) = {"mout_aud_pll_user", "ioclk_audcdclk0_user"};
+PNAME(mout_sclk_aud_pcm_p) = {"mout_aud_pll_user", "ioclk_audcdclk0_user"};
+
+/*

drivers/clk/samsung/clk-exynos5260.c line 411

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+ * List of parent clocks for muses in CMU_DISP
+*/
+PNAME(mout_phyclk_dptx_phy_ch3_txd_clk_user_p) = {"fin_pll",
+			"phyclk_dptx_phy_ch3_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch2_txd_clk_user_p) = {"fin_pll",
+			"phyclk_dptx_phy_ch2_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch1_txd_clk_user_p) = {"fin_pll",
+			"phyclk_dptx_phy_ch1_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch0_txd_clk_user_p) = {"fin_pll",
+			"phyclk_dptx_phy_ch0_txd_clk"};

Whoa, these clock names are incredibly long. Are they real names from SoC User's Manual?

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+
+PNAME(mout_aclk_disp_222_user_p) = {"fin_pll", "dout_aclk_disp_222"};
+PNAME(mout_sclk_disp_pixel_user_p) = {"fin_pll", "dout_sclk_disp_pixel"};

[snip]

Quoted 1 line

+/* fixed rate clocks generated outside the soc */

Huh? If they are generated outside the SoC, they shouldn't be registered by this driver, but rather by respective fixed rate clock nodes in DT.

Quoted 23 lines
drivers/clk/samsung/clk-exynos5260.c new file +23 -0
+struct samsung_fixed_rate_clock exynos5260_fixed_rate_ext_clks[] __initdata = {
+	FRATE(FIN_PLL, "fin_pll", NULL, CLK_IS_ROOT, 24000000),
+	FRATE(ID_NONE, "xrtcxti", NULL, CLK_IS_ROOT, 32768),
+
+	FRATE(ID_NONE, "ioclk_audcdclk0_user", NULL, CLK_IS_ROOT, 0),
+
+	FRATE(ID_NONE, "ioclk_pcm_extclk", NULL, CLK_IS_ROOT, 2048000),
+	FRATE(ID_NONE, "ioclk_aud_i2s_bclk", NULL, CLK_IS_ROOT, 2048000),
+	FRATE(ID_NONE, "ioclk_spdif_extclk", NULL, CLK_IS_ROOT, 49152000),
+	FRATE(ID_NONE, "ioclk_i2s_cdclk", NULL, CLK_IS_ROOT, 0),
+	FRATE(ID_NONE, "ioclk_spdif_extlk", NULL, CLK_IS_ROOT, 0),
+
+	FRATE(ID_NONE, "ioclk_i2s_sclk", NULL, CLK_IS_ROOT, 0),
+	FRATE(ID_NONE, "ioclk_spi0_clkin", NULL, CLK_IS_ROOT, 0),
+	FRATE(ID_NONE, "ioclk_spi1_clkin", NULL, CLK_IS_ROOT, 0),
+	FRATE(ID_NONE, "ioclk_spi2_clkin", NULL, CLK_IS_ROOT, 0),
+
+	FRATE(ID_NONE, "ioclk_mmc0_sdrdqs_in", NULL, CLK_IS_ROOT, 200000000),
+
+	FRATE(ID_NONE, "ioclk_spi0_isp_spi_clk_in", NULL,
+			CLK_IS_ROOT, 50000000),
+	FRATE(ID_NONE, "ioclk_spi1_isp_spi_clk_in", NULL,
+			CLK_IS_ROOT, 50000000),

drivers/clk/samsung/clk-exynos5260.c line 615

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	FRATE(ID_NONE, "ioclk_spi0_isp_spi_clk_out", NULL,
+			CLK_IS_ROOT, 50000000),
+	FRATE(ID_NONE, "ioclk_spi1_isp_spi_clk_out", NULL,
+			CLK_IS_ROOT, 50000000),
+};
+
+/* fixed rate clocks generated inside the soc */
+struct samsung_fixed_rate_clock exynos5260_fixed_rate_clks[] __initdata = {
+	FRATE(ID_NONE, "phyclk_dptx_phy_ch3_txd_clk", NULL,
+			CLK_IS_ROOT, 270000000),

Please define IDs for all clocks defined in this driver. This is necessary to allow rate and parent configuration using DT in future.

However, if there is a reason to not export some clock, please use 0 directly, without defining a special macro like ID_NONE.

drivers/clk/samsung/clk-exynos5260.c line 625

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	FRATE(ID_NONE, "phyclk_dptx_phy_ch2_txd_clk", NULL,
+			CLK_IS_ROOT, 270000000),
+	FRATE(ID_NONE, "phyclk_dptx_phy_ch1_txd_clk", NULL,
+			CLK_IS_ROOT, 270000000),
+	FRATE(ID_NONE, "phyclk_dptx_phy_ch0_txd_clk", NULL,
+			CLK_IS_ROOT, 270000000),
+	FRATE(ID_NONE, "phyclk_hdmi_phy_tmds_clko", NULL,
+			CLK_IS_ROOT, 250000000),
+	FRATE(TOP_SCLK_HDMIPHY, "phyclk_hdmi_phy_pixel_clko", NULL,
+			CLK_IS_ROOT, 1660000000),

Hmm, so is this clock top_sclk_hdmiphy or phyclk_hdmi_phy_pixel_clko? Shouldn't the macro and the name be using the same pattern?

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	FRATE(ID_NONE, "phyclk_hdmi_link_o_tmds_clkhi", NULL,
+			CLK_IS_ROOT, 125000000),
+	FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_txbyteclkhs", NULL,
+			CLK_IS_ROOT, 187500000),
+	FRATE(ID_NONE, "phyclk_dptx_phy_o_ref_clk_24m", NULL,
+			CLK_IS_ROOT, 24000000),
+	FRATE(ID_NONE, "phyclk_dptx_phy_clk_div2", NULL,
+			CLK_IS_ROOT, 135000000),
+	FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_rxclkesc0", NULL,
+			CLK_IS_ROOT, 20000000),

drivers/clk/samsung/clk-exynos5260.c line 645

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	FRATE(ID_NONE, "phyclk_usbhost20_phy_phyclock", NULL,
+			CLK_IS_ROOT, 60000000),
+	FRATE(ID_NONE, "phyclk_usbhost20_phy_freeclk", NULL,
+			CLK_IS_ROOT, 60000000),
+	FRATE(ID_NONE, "phyclk_usbhost20_phy_clk48mohci", NULL,
+			CLK_IS_ROOT, 48000000),
+	FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_pipe_pclk", NULL,
+			CLK_IS_ROOT, 125000000),
+	FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_phyclock", NULL,
+			CLK_IS_ROOT, 60000000),

Are these really fixed rate clocks? It looks strange, because it's a bit unlike previous Samsung SoCs, which used to have up 5 fixed rate clocks in average.

drivers/clk/samsung/clk-exynos5260.c line 649

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+};
+
+struct samsung_fixed_factor_clock exynos5260_fixed_factor_clks[] __initdata = {
+};

If empty, why define this array?

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+
+/* MULITPLEXER CLOCKS */

[snip]

Quoted 11 lines
drivers/clk/samsung/clk-exynos5260.c new file +11 -0
+
+/* GATE CLOCKS */
+
+/*
+ * List of Gate clocks for CMU_AUD
+*/
+struct samsung_gate_clock exynos5260_aud_gate_clks[] __initdata = {
+	GATE(AUD_CLK_AUD_UART, "clk_aud_uart", "dout_aclk_aud_131",
+			EN_IP_AUD, 4, 0, 0),
+	GATE(AUD_CLK_PCM, "clk_pcm", "dout_aclk_aud_131", EN_IP_AUD, 3, 0, 0),
+	GATE(AUD_CLK_I2S, "clk_i2s", "dout_aclk_aud_131", EN_IP_AUD, 2, 0, 0),

drivers/clk/samsung/clk-exynos5260.c line 1232

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	GATE(AUD_CLK_DMAC, "clk_dmac", "dout_aclk_aud_131",
+			EN_IP_AUD, 1, 0, 0),
+	GATE(ID_NONE, "clk_sramc", "dout_aclk_aud_131", EN_IP_AUD, 0, 0, 0),
+
+	GATE(AUD_SCLK_AUD_UART, "sclk_aud_uart", "dout_sclk_aud_uart",
+			EN_SCLK_AUD, 2, 0, 0),
+	GATE(AUD_SCLK_PCM, "sclk_aud_pcm", "dout_sclk_aud_pcm",
+			EN_SCLK_AUD, 1, 0, 0),
+	GATE(AUD_SCLK_I2S, "sclk_aud_i2s", "dout_sclk_aud_i2s",
+			EN_SCLK_AUD, 0, 0, 0),

Shouldn't all the sclk's above have CLK_SET_RATE_PARENT flags to let consumer drivers change divisors of parent dividers? The same comment for remaining SCLK gates further in the file.

Quoted 8 lines
drivers/clk/samsung/clk-exynos5260.c new file +8 -0
+};
+
+/*
+ * List of Gate clocks for CMU_DISP
+*/
+struct samsung_gate_clock exynos5260_disp_gate_clks[] __initdata = {
+	GATE(DISP_CLK_SMMU_TV, "clk_smmu3_tv", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 25, 0, 0),

drivers/clk/samsung/clk-exynos5260.c line 1250

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	GATE(DISP_CLK_SMMU_FIMD1M1, "clk_smmu3_fimd1m1",
+			"mout_aclk_disp_222_user",
+			EN_IP_DISP, 23, 0, 0),
+	GATE(DISP_CLK_SMMU_FIMD1M0, "clk_smmu3_fimd1m0",
+			"mout_aclk_disp_222_user",
+			EN_IP_DISP, 22, 0, 0),
+	GATE(ID_NONE, "clk_pixel_mixer", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 13, CLK_IGNORE_UNUSED, 0),
+	GATE(ID_NONE, "clk_pixel_disp", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 12, CLK_IGNORE_UNUSED, 0),

Why CLK_IGNORE_UNUSED?

Quoted 20 lines
drivers/clk/samsung/clk-exynos5260.c new file +20 -0
+	GATE(DISP_CLK_MIXER, "clk_mixer", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 11, 0, 0),
+	GATE(DISP_CLK_MIPIPHY, "clk_mipi_dphy", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 10, 0, 0),
+	GATE(DISP_CLK_HDMIPHY, "clk_hdmiphy", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 9, 0, 0),
+	GATE(DISP_CLK_HDMI, "clk_hdmi", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 8, 0, 0),
+	GATE(DISP_CLK_FIMD1, "clk_fimd1", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 7, 0, 0),
+	GATE(DISP_CLK_DSIM1, "clk_dsim1", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 6, 0, 0),
+	GATE(DISP_CLK_DPPHY, "clk_dptx_phy", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 5, 0, 0),
+	GATE(DISP_CLK_DP, "clk_dptx_link", "mout_aclk_disp_222_user",
+			EN_IP_DISP, 4, 0, 0),
+
+	GATE(DISP_SCLK_PIXEL, "sclk_hdmi_phy_pixel_clki",
+			"dout_sclk_hdmi_phy_pixel_clki",
+			EN_SCLK_DISP0, 29, 0, 0),

drivers/clk/samsung/clk-exynos5260.c line 1280

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	GATE(DISP_SCLK_HDMI, "sclk_hdmi_link_i_pixel",
+			"mout_phyclk_hdmi_phy_pixel_clko_user",
+			EN_SCLK_DISP0, 26, 0, 0),
+};
+
+/*
+ * List of Gate clocks for CMU_EGL
+*/
+struct samsung_gate_clock exynos5260_egl_gate_clks[] __initdata = {
+};

Empty array.

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+
+/*
+ * List of Gate clocks for CMU_FSYS

[snip]

Quoted 24 lines
drivers/clk/samsung/clk-exynos5260.c new file +24 -0
+
+/*
+* Applicable for all 2550 Type PLLS for Exynos5260, listed below
+* DISP_PLL, EGL_PLL, KFC_PLL, MEM_PLL,
+* BUS_PLL, MEDIA_PLL, G3D_PLL.
+*/
+static const struct samsung_pll_rate_table exynos5260_pll2550_24mhz_tbl[] = {
+	PLL_35XX_RATE(1700000000, 425, 6, 0),
+	PLL_35XX_RATE(1600000000, 200, 3, 0),
+	PLL_35XX_RATE(1500000000, 250, 4, 0),
+	PLL_35XX_RATE(1400000000, 175, 3, 0),
+	PLL_35XX_RATE(1300000000, 325, 6, 0),
+	PLL_35XX_RATE(1200000000, 400, 4, 1),
+	PLL_35XX_RATE(1100000000, 275, 3, 1),
+	PLL_35XX_RATE(1000000000, 250, 3, 1),
+	PLL_35XX_RATE(933000000, 311, 4, 1),
+	PLL_35XX_RATE(900000000, 300, 4, 1),
+	PLL_35XX_RATE(800000000, 200, 3, 1),
+	PLL_35XX_RATE(733000000, 733, 12, 1),
+	PLL_35XX_RATE(700000000, 175, 3, 1),
+	PLL_35XX_RATE(667000000, 667, 12, 1),
+	PLL_35XX_RATE(633000000, 211, 4, 1),
+	PLL_35XX_RATE(620000000, 310, 3, 2),
+	PLL_35XX_RATE(600000000, 400, 4, 2),

drivers/clk/samsung/clk-exynos5260.c line 1706

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	PLL_35XX_RATE(543000000, 362, 4, 2),
+	PLL_35XX_RATE(533000000, 533, 6, 2),
+	PLL_35XX_RATE(500000000, 250, 3, 2),
+	PLL_35XX_RATE(450000000, 300, 4, 2),
+	PLL_35XX_RATE(400000000, 200, 3, 2),
+	PLL_35XX_RATE(350000000, 175, 3, 2),
+	PLL_35XX_RATE(300000000, 400, 4, 3),
+	PLL_35XX_RATE(266000000, 266, 3, 3),
+	PLL_35XX_RATE(200000000, 200, 3, 3),
+	PLL_35XX_RATE(160000000, 160, 3, 3),

Are all of those exact values, without any (incorrect) rounding? This is imporant for the rate setting code to work correctly.

Quoted 14 lines
drivers/clk/samsung/clk-exynos5260.c new file +14 -0
+};
+
+/*
+* Applicable for 2650 Type PLL for AUD_PLL.
+*/
+static const struct samsung_pll_rate_table exynos5260_pll2650_24mhz_tbl[] = {
+	PLL_36XX_RATE(1600000000, 200, 3, 0, 0),
+	PLL_36XX_RATE(1200000000, 100, 2, 0, 0),
+	PLL_36XX_RATE(1000000000, 250, 3, 1, 0),
+	PLL_36XX_RATE(800000000, 200, 3, 1, 0),
+	PLL_36XX_RATE(600000000, 100, 2, 1, 0),
+	PLL_36XX_RATE(532000000, 266, 3, 2, 0),
+	PLL_36XX_RATE(480000000, 160, 2, 2, 0),
+	PLL_36XX_RATE(432000000, 144, 2, 2, 0),

drivers/clk/samsung/clk-exynos5260.c line 1730

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+	PLL_36XX_RATE(400000000, 200, 3, 2, 0),
+	PLL_36XX_RATE(394216000, 459, 7, 2, 49282),
+	PLL_36XX_RATE(333000000, 111, 2, 2, 0),
+	PLL_36XX_RATE(300000000, 100, 2, 2, 0),
+	PLL_36XX_RATE(266000000, 266, 3, 3, 0),
+	PLL_36XX_RATE(200000000, 200, 3, 3, 0),
+	PLL_36XX_RATE(166000000, 166, 3, 3, 0),
+	PLL_36XX_RATE(133000000, 266, 3, 4, 0),
+	PLL_36XX_RATE(100000000, 200, 3, 4, 0),
+	PLL_36XX_RATE(66000000, 176, 2, 5, 0),

Ditto.

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+};
+

[snip]

Quoted 1 line

+void __init exynos5260_clk_aud_init(struct device_node *np)

static void

drivers/clk/samsung/clk-exynos5260.c line 1775

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+{
+	void __iomem *reg_base;
+	static unsigned long *rdump;

Static?

drivers/clk/samsung/clk-exynos5260.c line 1780

Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +5 -0
+	struct samsung_clk_provider *ctx;
+	unsigned long nr_rdump;
+
+	if (!np)
+		panic("%s: unable to determine cmu\n", __func__);

Can't happen. This function will be only called if a matching node is found in DT.

drivers/clk/samsung/clk-exynos5260.c line 1787

Quoted 7 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+
+	reg_base = of_iomap(np, 0);
+	if (!reg_base)
+		panic("%s: failed to map registers\n", __func__);
+
+	rdump = exynos5260_aud_clk_regs;
+	nr_rdump = ARRAY_SIZE(exynos5260_aud_clk_regs);

You can use those two directly, without creating variables for them.

Quoted 35 lines
drivers/clk/samsung/clk-exynos5260.c new file +35 -0
+
+	ctx = samsung_clk_init(np, reg_base, AUD_NR_CLK);
+	if (!ctx)
+		panic("%s: unable to alllocate ctx\n", __func__);
+
+	samsung_clk_register_mux(ctx, exynos5260_aud_mux_clks,
+		ARRAY_SIZE(exynos5260_aud_mux_clks));
+	samsung_clk_register_div(ctx, exynos5260_aud_div_clks,
+		ARRAY_SIZE(exynos5260_aud_div_clks));
+	samsung_clk_register_gate(ctx, exynos5260_aud_gate_clks,
+		ARRAY_SIZE(exynos5260_aud_gate_clks));
+
+	exynos5260_clk_sleep_init(reg_base, rdump, nr_rdump);
+}
+
+void __init exynos5260_clk_disp_init(struct device_node *np)
+{
+	void __iomem *reg_base;
+	static unsigned long *rdump;
+	struct samsung_clk_provider *ctx;
+	unsigned long nr_rdump;
+
+	if (!np)
+		panic("%s: unable to determine cmu\n", __func__);
+
+	reg_base = of_iomap(np, 0);
+	if (!reg_base)
+		panic("%s: failed to map registers\n", __func__);
+
+	rdump = exynos5260_disp_clk_regs;
+	nr_rdump = ARRAY_SIZE(exynos5260_disp_clk_regs);
+
+	ctx = samsung_clk_init(np, reg_base, DISP_NR_CLK);
+	if (!ctx)
+		panic("%s: unable to alllocate ctx\n", __func__);

drivers/clk/samsung/clk-exynos5260.c line 1832

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+
+	samsung_clk_register_mux(ctx, exynos5260_disp_mux_clks,
+		ARRAY_SIZE(exynos5260_disp_mux_clks));
+	samsung_clk_register_div(ctx, exynos5260_disp_div_clks,
+		ARRAY_SIZE(exynos5260_disp_div_clks));
+	samsung_clk_register_gate(ctx, exynos5260_disp_gate_clks,
+		ARRAY_SIZE(exynos5260_disp_gate_clks));
+
+	exynos5260_clk_sleep_init(reg_base, rdump, nr_rdump);
+}

Hmm, instead of repeating almost exactly the same function for each CMU, wouldn't it be better to simply write a single parametrized one?

What about creating a struct like this:

struct exynos5260_cmu_type {
	unsigned long *rdump;
	unsigned long nr_rdump;

	unsigned int nr_clks;

	struct samsung_mux_clock *mux_clks;
	unsigned int nr_mux_clks;
	/* Same for remaining clock types. */
};

and then defining instances for all the needed CMUs and passing a pointer to such struct to a generic registering function?

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+
+void __init exynos5260_clk_egl_init(struct device_node *np)
+{
+	void __iomem *reg_base;

[snip]

drivers/clk/samsung/clk-exynos5260.c line 2193

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+struct of_device_id __clk_of_table_exynos5260[]
+		__used __section(__clk_of_table) = {

I don't think this is a good idea. This construct should not be used directly. This is what CLK_OF_DECLARE() macro is for.

If you define a struct as mentioned above for every CMU, then you should end up with following code:

static const struct exynos5260_cmu_type cmu_xxx = {
	// ...
};

static void __init cmu_xxx_init(struct device_node *np)

{
         exynos5260_cmu_register_one(np, &cmu_xxx);
}

CLK_OF_DECLARE(cmu_xxx, "samsung,exynos5260-clock-xxx", cmu_xxx_init);

for every CMU type, which still needs some duplication, but should be much less than in current form.

Also it would be nice to group definitions for particular CMUs together, e.g.

/* CMU XXX */
// regs
// fixed rate
// muxes
// dividers
// gates
// plls
// struct exynos5260_cmu_type
// cmu_xxx_init()

/* CMU YYY */
...

This should improve readability of the driver, as definitions for different IP blocks would not be intermingled.

[snip]

drivers/clk/samsung/clk-exynos5260.h line 6

Quoted 12 lines
drivers/clk/samsung/clk-exynos5260.h new file +6 -0
new file mode 100644
index 0000000..392c152
@@ -0,0 +1,480 @@
+#ifndef __CLK_EXYNOS5260_H
+#define __CLK_EXYNOS5260_H
+
+/*
+*Base address for different CMUs
+*TODO: All Bases should be removed at earliest.

True, very true. Please remove them in next version ;).

Quoted 34 lines
drivers/clk/samsung/clk-exynos5260.h new file +34 -0
+*/
+#define CMU_AUD_BASE	0x128C0000
+#define CMU_DISP_BASE	0x14550000
+#define CMU_EGL_BASE	0x10600000
+#define CMU_FSYS_BASE	0x122E0000
+#define CMU_G2D_BASE	0x10A00000
+#define CMU_G3D_BASE	0x11830000
+#define CMU_GSCL_BASE	0x13F00000
+#define CMU_ISP_BASE	0x133C0000
+#define CMU_KFC_BASE	0x10700000
+#define CMU_MFC_BASE	0x11090000
+#define CMU_MIF_BASE	0x10CE0000
+#define CMU_PERI_BASE	0x10200000
+#define CMU_TOP_BASE	0x10010000
+
+#define AUD_REG(x)		(x)
+#define DISP_REG(x)		(x)
+#define EGL_REG(x)		(x)
+#define FSYS_REG(x)		(x)
+#define G2D_REG(x)		(x)
+#define G3D_REG(x)		(x)
+#define GSCL_REG(x)		(x)
+#define ISP_REG(x)		(x)
+#define KFC_REG(x)		(x)
+#define MFC_REG(x)		(x)
+#define MIF_REG(x)		(x)
+#define PERI_REG(x)		(x)
+#define TOP_REG(x)		(x)
+
+/*
+*Registers for CMU_AUD
+*/
+#define MUX_SEL_AUD		AUD_REG(0x0200)
+#define MUX_ENABLE_AUD		AUD_REG(0x0300)

drivers/clk/samsung/clk-exynos5260.h line 50

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.h new file +10 -0
+#define MUX_STAT_AUD		AUD_REG(0x0400)
+#define MUX_IGNORE_AUD		AUD_REG(0x0500)
+#define DIV_AUD0		AUD_REG(0x0600)
+#define DIV_AUD1		AUD_REG(0x0604)
+#define DIV_STAT_AUD0		AUD_REG(0x0700)
+#define DIV_STAT_AUD1		AUD_REG(0x0704)
+#define EN_ACLK_AUD		AUD_REG(0x0800)
+#define EN_PCLK_AUD		AUD_REG(0x0900)
+#define EN_SCLK_AUD		AUD_REG(0x0a00)
+#define EN_IP_AUD		AUD_REG(0x0b00)

No need to use XXX_REG() macros, simple offsets are enough. Also I don't think there is a need to have a separate header for these definitions used just by one source file. They can be safely moved there.

Best regards,
Tomasz

#8 lore raw

PATCH v3 5/5 clk/exynos5260: add clock file for exynos5260

Thanks Tomasz,

I have almost reworked this file as per your comments. Please find my inline comments.

Quoted 7 lines · Tomasz Figa

Hi Rahul,

On 18.02.2014 12:56, Rahul Sharma wrote:

[snip]

Quoted 12 lines

drivers/clk/samsung/clk-exynos5260.c line 2

Quoted 9 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
new file mode 100644
index 0000000..bcb633e
@@ -0,0 +1,2235 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.

Most likely it should be 2013-2014 now.

Done.

Quoted 14 lines
Quoted 9 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Common Clock Framework support for Exynos5260 SoC.
+*/

[snip]

Quoted 10 lines

drivers/clk/samsung/clk-exynos5260.c line 39

Quoted 6 lines
drivers/clk/samsung/clk-exynos5260.c new file +6 -0
+#ifdef CONFIG_PM_SLEEP
+
+/*
+ * list of controller registers to be saved and restored during a
+ * suspend/resume cycle.
+*/

nit: Unaligned star. + The same for a lot of comments in this file.

Done.

Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+
+static unsigned long exynos5260_aud_clk_regs[] __initdata = {

nit: There is no need to prefix every static variable in this file with exynos5260_. Shorter (but still completely readable) names will let the code using them have shorter lines.

Removed.

Quoted 28 lines
Quoted 6 lines

+ *Registers for CMU_AUD

drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+*/
+       MUX_SEL_AUD,
+       DIV_AUD0,
+       DIV_AUD1,

[snip]

Quoted 17 lines
drivers/clk/samsung/clk-exynos5260.c new file +17 -0
+static void exynos5260_clk_sleep_init(void __iomem *reg_base,
+                       unsigned long *rdump,
+                       unsigned long nr_rdump)
+{
+       struct exynos5260_clock_reg_cache *reg_cache;
+
+       reg_cache = kzalloc(sizeof(struct exynos5260_clock_reg_cache),
+                       GFP_KERNEL);
+       if (!reg_cache)
+               panic("could not allocate register cache.\n");
+
+       reg_cache->rdump = samsung_clk_alloc_reg_dump(rdump, nr_rdump);
+
+       if (!reg_cache->rdump)
+               panic("could not allocate register dump storage.\n");
+
+       reg_cache->rd_num = nr_rdump;
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c line 382

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+       reg_cache->reg_base = reg_base;
+       list_add_tail(&reg_cache->node, &clock_reg_cache_list);
+
+       if (!syscore_ops_registered) {

To eliminate the need for having a separate variable, you can simply move this if clause before list_add_tail() and check for list_empty().

Done. Removed this var.

Quoted 11 lines

drivers/clk/samsung/clk-exynos5260.c line 387

Quoted 6 lines
drivers/clk/samsung/clk-exynos5260.c new file +5 -0
+               register_syscore_ops(&exynos5260_clk_syscore_ops);
+               syscore_ops_registered = true;
+       }
+
+       exynos5260_clk_suspend();

What is the reason to call this here and save register values of all registered CMus every time a new CMU is instantiated?

It is not required. Cleaned.

Quoted 23 lines
Quoted 23 lines
drivers/clk/samsung/clk-exynos5260.c new file +11 -0
+}
+
+#else
+static void exynos5260_clk_sleep_init(void) {}
+#endif
+
+/*
+ * List of parent clocks for muses in CMU_AUD
+*/
+PNAME(mout_aud_pll_user_p) = {"fin_pll", "fout_aud_pll"};
+PNAME(mout_sclk_aud_i2s_p) = {"mout_aud_pll_user",

"ioclk_audcdclk0_user"}; +PNAME(mout_sclk_aud_pcm_p) = {"mout_aud_pll_user", "ioclk_audcdclk0_user"};

drivers/clk/samsung/clk-exynos5260.c new file +8 -0
+
+/*
+ * List of parent clocks for muses in CMU_DISP
+*/
+PNAME(mout_phyclk_dptx_phy_ch3_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch3_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch2_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch2_txd_clk"};
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c line 411

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+PNAME(mout_phyclk_dptx_phy_ch1_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch1_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch0_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch0_txd_clk"};

Whoa, these clock names are incredibly long. Are they real names from SoC User's Manual?

Yea, these are same in manual. I kept the name similar, otherwise not easy to search them in UM.

Quoted 9 lines
Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+
+PNAME(mout_aclk_disp_222_user_p) = {"fin_pll", "dout_aclk_disp_222"};
+PNAME(mout_sclk_disp_pixel_user_p) = {"fin_pll", "dout_sclk_disp_pixel"};

[snip]

Quoted 5 lines
Quoted 1 line

+/* fixed rate clocks generated outside the soc */

Huh? If they are generated outside the SoC, they shouldn't be registered by this driver, but rather by respective fixed rate clock nodes in DT.

I tried but system doesn't boot if fin_plll is registered from DT as "fixed-clock".
of_fixed_clk_setup hits after the registration of other CMUs. System asserts in many places due to div by zero error. It is exactly same for Exynos5420. So I took 5420 as example and defined fin_pll as osc clock of compatible type "samsung,exynos5260-oscclk". Rest of the ext clocks are registered as "fixed-clock". What you say on this ?

Quoted 43 lines
Quoted 36 lines

+struct samsung_fixed_rate_clock exynos5260_fixed_rate_ext_clks[] __initdata = {

drivers/clk/samsung/clk-exynos5260.c new file +17 -0
+       FRATE(FIN_PLL, "fin_pll", NULL, CLK_IS_ROOT, 24000000),
+       FRATE(ID_NONE, "xrtcxti", NULL, CLK_IS_ROOT, 32768),
+
+       FRATE(ID_NONE, "ioclk_audcdclk0_user", NULL, CLK_IS_ROOT, 0),
+
+       FRATE(ID_NONE, "ioclk_pcm_extclk", NULL, CLK_IS_ROOT, 2048000),
+       FRATE(ID_NONE, "ioclk_aud_i2s_bclk", NULL, CLK_IS_ROOT, 2048000),
+       FRATE(ID_NONE, "ioclk_spdif_extclk", NULL, CLK_IS_ROOT, 49152000),
+       FRATE(ID_NONE, "ioclk_i2s_cdclk", NULL, CLK_IS_ROOT, 0),
+       FRATE(ID_NONE, "ioclk_spdif_extlk", NULL, CLK_IS_ROOT, 0),
+
+       FRATE(ID_NONE, "ioclk_i2s_sclk", NULL, CLK_IS_ROOT, 0),
+       FRATE(ID_NONE, "ioclk_spi0_clkin", NULL, CLK_IS_ROOT, 0),
+       FRATE(ID_NONE, "ioclk_spi1_clkin", NULL, CLK_IS_ROOT, 0),
+       FRATE(ID_NONE, "ioclk_spi2_clkin", NULL, CLK_IS_ROOT, 0),
+
+       FRATE(ID_NONE, "ioclk_mmc0_sdrdqs_in", NULL, CLK_IS_ROOT,

200000000),

drivers/clk/samsung/clk-exynos5260.c new file +13 -0
+
+       FRATE(ID_NONE, "ioclk_spi0_isp_spi_clk_in", NULL,
+                       CLK_IS_ROOT, 50000000),
+       FRATE(ID_NONE, "ioclk_spi1_isp_spi_clk_in", NULL,
+                       CLK_IS_ROOT, 50000000),
+       FRATE(ID_NONE, "ioclk_spi0_isp_spi_clk_out", NULL,
+                       CLK_IS_ROOT, 50000000),
+       FRATE(ID_NONE, "ioclk_spi1_isp_spi_clk_out", NULL,
+                       CLK_IS_ROOT, 50000000),
+};
+
+/* fixed rate clocks generated inside the soc */
+struct samsung_fixed_rate_clock exynos5260_fixed_rate_clks[] __initdata =

{

drivers/clk/samsung/clk-exynos5260.c

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+       FRATE(ID_NONE, "phyclk_dptx_phy_ch3_txd_clk", NULL,
+                       CLK_IS_ROOT, 270000000),

Please define IDs for all clocks defined in this driver. This is necessary to allow rate and parent configuration using DT in future.

Quoted 3 lines

However, if there is a reason to not export some clock, please use 0 directly, without defining a special macro like ID_NONE.

replaced.

Quoted 13 lines

drivers/clk/samsung/clk-exynos5260.c line 625

Quoted 11 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_dptx_phy_ch2_txd_clk", NULL,
+                       CLK_IS_ROOT, 270000000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_ch1_txd_clk", NULL,
+                       CLK_IS_ROOT, 270000000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_ch0_txd_clk", NULL,
+                       CLK_IS_ROOT, 270000000),
+       FRATE(ID_NONE, "phyclk_hdmi_phy_tmds_clko", NULL,
+                       CLK_IS_ROOT, 250000000),
+       FRATE(TOP_SCLK_HDMIPHY, "phyclk_hdmi_phy_pixel_clko", NULL,
+                       CLK_IS_ROOT, 1660000000),
Quoted 3 lines

Hmm, so is this clock top_sclk_hdmiphy or phyclk_hdmi_phy_pixel_clko? Shouldn't the macro and the name be using the same pattern?

I changed these macros as per clock name.

Quoted 23 lines
Quoted 11 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_hdmi_link_o_tmds_clkhi", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_txbyteclkhs", NULL,
+                       CLK_IS_ROOT, 187500000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_o_ref_clk_24m", NULL,
+                       CLK_IS_ROOT, 24000000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_clk_div2", NULL,
+                       CLK_IS_ROOT, 135000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_rxclkesc0", NULL,
+                       CLK_IS_ROOT, 20000000),

drivers/clk/samsung/clk-exynos5260.c line 645

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_freeclk", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_clk48mohci", NULL,
+                       CLK_IS_ROOT, 48000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_pipe_pclk", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
Quoted 4 lines

Are these really fixed rate clocks? It looks strange, because it's a bit unlike previous Samsung SoCs, which used to have up 5 fixed rate clocks in average.

These are outputs of various phys. If these are removed we will be left with many orphan clocks.

Quoted 10 lines
Quoted 6 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+};
+
+struct samsung_fixed_factor_clock exynos5260_fixed_factor_clks[]

__initdata = {
+};

If empty, why define this array?

Removed.

Quoted 29 lines
Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+
+/* MULITPLEXER CLOCKS */

[snip]

Quoted 21 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+
+/* GATE CLOCKS */
+
+/*
+ * List of Gate clocks for CMU_AUD
+*/
+struct samsung_gate_clock exynos5260_aud_gate_clks[] __initdata = {
+       GATE(AUD_CLK_AUD_UART, "clk_aud_uart", "dout_aclk_aud_131",
+                       EN_IP_AUD, 4, 0, 0),
+       GATE(AUD_CLK_PCM, "clk_pcm", "dout_aclk_aud_131", EN_IP_AUD, 3, 0,

0),
+ GATE(AUD_CLK_I2S, "clk_i2s", "dout_aclk_aud_131", EN_IP_AUD, 2, 0,
0),

drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+       GATE(AUD_CLK_DMAC, "clk_dmac", "dout_aclk_aud_131",
+                       EN_IP_AUD, 1, 0, 0),
+       GATE(ID_NONE, "clk_sramc", "dout_aclk_aud_131", EN_IP_AUD, 0, 0,

0),

drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+
+       GATE(AUD_SCLK_AUD_UART, "sclk_aud_uart", "dout_sclk_aud_uart",
+                       EN_SCLK_AUD, 2, 0, 0),
+       GATE(AUD_SCLK_PCM, "sclk_aud_pcm", "dout_sclk_aud_pcm",
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c line 1232

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+                       EN_SCLK_AUD, 1, 0, 0),
+       GATE(AUD_SCLK_I2S, "sclk_aud_i2s", "dout_sclk_aud_i2s",
+                       EN_SCLK_AUD, 0, 0, 0),

Shouldn't all the sclk's above have CLK_SET_RATE_PARENT flags to let consumer drivers change divisors of parent dividers? The same comment for remaining SCLK gates further in the file.

Added to all sclks.

Quoted 14 lines
Quoted 14 lines
drivers/clk/samsung/clk-exynos5260.c new file +13 -0
+};
+
+/*
+ * List of Gate clocks for CMU_DISP
+*/
+struct samsung_gate_clock exynos5260_disp_gate_clks[] __initdata = {
+       GATE(DISP_CLK_SMMU_TV, "clk_smmu3_tv", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 25, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M1, "clk_smmu3_fimd1m1",
+                       "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 23, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M0, "clk_smmu3_fimd1m0",
+                       "mout_aclk_disp_222_user",
Quoted 8 lines

drivers/clk/samsung/clk-exynos5260.c line 1250

Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +5 -0
+                       EN_IP_DISP, 22, 0, 0),
+       GATE(ID_NONE, "clk_pixel_mixer", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 13, CLK_IGNORE_UNUSED, 0),
+       GATE(ID_NONE, "clk_pixel_disp", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 12, CLK_IGNORE_UNUSED, 0),

Why CLK_IGNORE_UNUSED?

these clocks are required for correct representation of clock tree but they are not enabled by the drivers. like sclk_uart clock is only used for set rate and never enable by the driver. Second category is clock like lpddr which will be used by mif dvfs for lpddr only. These needs to left ingnored for Non lpddr boards. I treid to kept them to minimum.

Quoted 27 lines
Quoted 27 lines
drivers/clk/samsung/clk-exynos5260.c new file +25 -0
+       GATE(DISP_CLK_MIXER, "clk_mixer", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 11, 0, 0),
+       GATE(DISP_CLK_MIPIPHY, "clk_mipi_dphy", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 10, 0, 0),
+       GATE(DISP_CLK_HDMIPHY, "clk_hdmiphy", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 9, 0, 0),
+       GATE(DISP_CLK_HDMI, "clk_hdmi", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 8, 0, 0),
+       GATE(DISP_CLK_FIMD1, "clk_fimd1", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 7, 0, 0),
+       GATE(DISP_CLK_DSIM1, "clk_dsim1", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 6, 0, 0),
+       GATE(DISP_CLK_DPPHY, "clk_dptx_phy", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 5, 0, 0),
+       GATE(DISP_CLK_DP, "clk_dptx_link", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 4, 0, 0),
+
+       GATE(DISP_SCLK_PIXEL, "sclk_hdmi_phy_pixel_clki",
+                       "dout_sclk_hdmi_phy_pixel_clki",
+                       EN_SCLK_DISP0, 29, 0, 0),
+       GATE(DISP_SCLK_HDMI, "sclk_hdmi_link_i_pixel",
+                       "mout_phyclk_hdmi_phy_pixel_clko_user",
+                       EN_SCLK_DISP0, 26, 0, 0),
+};
+
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c line 1280

Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +5 -0
+/*
+ * List of Gate clocks for CMU_EGL
+*/
+struct samsung_gate_clock exynos5260_egl_gate_clks[] __initdata = {
+};

Empty array.

removed.

Quoted 40 lines
Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+
+/*
+ * List of Gate clocks for CMU_FSYS

[snip]

Quoted 31 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+
+/*
+* Applicable for all 2550 Type PLLS for Exynos5260, listed below
+* DISP_PLL, EGL_PLL, KFC_PLL, MEM_PLL,
+* BUS_PLL, MEDIA_PLL, G3D_PLL.
+*/
+static const struct samsung_pll_rate_table exynos5260_pll2550_24mhz_tbl[]

= {

drivers/clk/samsung/clk-exynos5260.c new file +23 -0
+       PLL_35XX_RATE(1700000000, 425, 6, 0),
+       PLL_35XX_RATE(1600000000, 200, 3, 0),
+       PLL_35XX_RATE(1500000000, 250, 4, 0),
+       PLL_35XX_RATE(1400000000, 175, 3, 0),
+       PLL_35XX_RATE(1300000000, 325, 6, 0),
+       PLL_35XX_RATE(1200000000, 400, 4, 1),
+       PLL_35XX_RATE(1100000000, 275, 3, 1),
+       PLL_35XX_RATE(1000000000, 250, 3, 1),
+       PLL_35XX_RATE(933000000, 311, 4, 1),
+       PLL_35XX_RATE(900000000, 300, 4, 1),
+       PLL_35XX_RATE(800000000, 200, 3, 1),
+       PLL_35XX_RATE(733000000, 733, 12, 1),
+       PLL_35XX_RATE(700000000, 175, 3, 1),
+       PLL_35XX_RATE(667000000, 667, 12, 1),
+       PLL_35XX_RATE(633000000, 211, 4, 1),
+       PLL_35XX_RATE(620000000, 310, 3, 2),
+       PLL_35XX_RATE(600000000, 400, 4, 2),
+       PLL_35XX_RATE(543000000, 362, 4, 2),
+       PLL_35XX_RATE(533000000, 533, 6, 2),
+       PLL_35XX_RATE(500000000, 250, 3, 2),
+       PLL_35XX_RATE(450000000, 300, 4, 2),
+       PLL_35XX_RATE(400000000, 200, 3, 2),
+       PLL_35XX_RATE(350000000, 175, 3, 2),
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c line 1706

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+       PLL_35XX_RATE(300000000, 400, 4, 3),
+       PLL_35XX_RATE(266000000, 266, 3, 3),
+       PLL_35XX_RATE(200000000, 200, 3, 3),
+       PLL_35XX_RATE(160000000, 160, 3, 3),

Are all of those exact values, without any (incorrect) rounding? This is imporant for the rate setting code to work correctly.

I verfied; all of them are correct other than this:
PLL_36XX_RATE(394216000, 459, 7, 2, 49282),

Its computed values is coming to be 394073128. I will replace 394216000 with 394073128 in the above entry.

Quoted 43 lines
Quoted 16 lines
drivers/clk/samsung/clk-exynos5260.c new file +6 -0
+};
+
+/*
+* Applicable for 2650 Type PLL for AUD_PLL.
+*/
+static const struct samsung_pll_rate_table exynos5260_pll2650_24mhz_tbl[]

= {

drivers/clk/samsung/clk-exynos5260.c new file +8 -0
+       PLL_36XX_RATE(1600000000, 200, 3, 0, 0),
+       PLL_36XX_RATE(1200000000, 100, 2, 0, 0),
+       PLL_36XX_RATE(1000000000, 250, 3, 1, 0),
+       PLL_36XX_RATE(800000000, 200, 3, 1, 0),
+       PLL_36XX_RATE(600000000, 100, 2, 1, 0),
+       PLL_36XX_RATE(532000000, 266, 3, 2, 0),
+       PLL_36XX_RATE(480000000, 160, 2, 2, 0),
+       PLL_36XX_RATE(432000000, 144, 2, 2, 0),

drivers/clk/samsung/clk-exynos5260.c line 1730

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       PLL_36XX_RATE(400000000, 200, 3, 2, 0),
+       PLL_36XX_RATE(394216000, 459, 7, 2, 49282),
+       PLL_36XX_RATE(333000000, 111, 2, 2, 0),
+       PLL_36XX_RATE(300000000, 100, 2, 2, 0),
+       PLL_36XX_RATE(266000000, 266, 3, 3, 0),
+       PLL_36XX_RATE(200000000, 200, 3, 3, 0),
+       PLL_36XX_RATE(166000000, 166, 3, 3, 0),
+       PLL_36XX_RATE(133000000, 266, 3, 4, 0),
+       PLL_36XX_RATE(100000000, 200, 3, 4, 0),
+       PLL_36XX_RATE(66000000, 176, 2, 5, 0),

Ditto.

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+};
+

[snip]

Quoted 1 line

+void __init exynos5260_clk_aud_init(struct device_node *np)

static void

Quoted 7 lines

drivers/clk/samsung/clk-exynos5260.c line 1775

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+{
+       void __iomem *reg_base;
+       static unsigned long *rdump;

Static?

done.

Quoted 11 lines

drivers/clk/samsung/clk-exynos5260.c line 1780

Quoted 6 lines
drivers/clk/samsung/clk-exynos5260.c new file +5 -0
+       struct samsung_clk_provider *ctx;
+       unsigned long nr_rdump;
+
+       if (!np)
+               panic("%s: unable to determine cmu\n", __func__);

Can't happen. This function will be only called if a matching node is found in DT.

Removed.

Quoted 76 lines

drivers/clk/samsung/clk-exynos5260.c line 1787

Quoted 8 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+
+       reg_base = of_iomap(np, 0);
+       if (!reg_base)
+               panic("%s: failed to map registers\n", __func__);
+
+       rdump = exynos5260_aud_clk_regs;
+       nr_rdump = ARRAY_SIZE(exynos5260_aud_clk_regs);

You can use those two directly, without creating variables for them.

Quoted 35 lines
drivers/clk/samsung/clk-exynos5260.c new file +35 -0
+
+       ctx = samsung_clk_init(np, reg_base, AUD_NR_CLK);
+       if (!ctx)
+               panic("%s: unable to alllocate ctx\n", __func__);
+
+       samsung_clk_register_mux(ctx, exynos5260_aud_mux_clks,
+               ARRAY_SIZE(exynos5260_aud_mux_clks));
+       samsung_clk_register_div(ctx, exynos5260_aud_div_clks,
+               ARRAY_SIZE(exynos5260_aud_div_clks));
+       samsung_clk_register_gate(ctx, exynos5260_aud_gate_clks,
+               ARRAY_SIZE(exynos5260_aud_gate_clks));
+
+       exynos5260_clk_sleep_init(reg_base, rdump, nr_rdump);
+}
+
+void __init exynos5260_clk_disp_init(struct device_node *np)
+{
+       void __iomem *reg_base;
+       static unsigned long *rdump;
+       struct samsung_clk_provider *ctx;
+       unsigned long nr_rdump;
+
+       if (!np)
+               panic("%s: unable to determine cmu\n", __func__);
+
+       reg_base = of_iomap(np, 0);
+       if (!reg_base)
+               panic("%s: failed to map registers\n", __func__);
+
+       rdump = exynos5260_disp_clk_regs;
+       nr_rdump = ARRAY_SIZE(exynos5260_disp_clk_regs);
+
+       ctx = samsung_clk_init(np, reg_base, DISP_NR_CLK);
+       if (!ctx)
+               panic("%s: unable to alllocate ctx\n", __func__);

drivers/clk/samsung/clk-exynos5260.c line 1832

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+
+       samsung_clk_register_mux(ctx, exynos5260_disp_mux_clks,
+               ARRAY_SIZE(exynos5260_disp_mux_clks));
+       samsung_clk_register_div(ctx, exynos5260_disp_div_clks,
+               ARRAY_SIZE(exynos5260_disp_div_clks));
+       samsung_clk_register_gate(ctx, exynos5260_disp_gate_clks,
+               ARRAY_SIZE(exynos5260_disp_gate_clks));
+
+       exynos5260_clk_sleep_init(reg_base, rdump, nr_rdump);
+}

Hmm, instead of repeating almost exactly the same function for each CMU, wouldn't it be better to simply write a single parametrized one?

What about creating a struct like this:

struct exynos5260_cmu_type {
        unsigned long *rdump;
        unsigned long nr_rdump;

        unsigned int nr_clks;

        struct samsung_mux_clock *mux_clks;
        unsigned int nr_mux_clks;
        /* Same for remaining clock types. */
};
Quoted 3 lines

and then defining instances for all the needed CMUs and passing a pointer to such struct to a generic registering function?

Changed.

Quoted 24 lines
Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+
+void __init exynos5260_clk_egl_init(struct device_node *np)
+{
+       void __iomem *reg_base;

[snip]

drivers/clk/samsung/clk-exynos5260.c line 2193

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+struct of_device_id __clk_of_table_exynos5260[]
+               __used __section(__clk_of_table) = {

I don't think this is a good idea. This construct should not be used directly. This is what CLK_OF_DECLARE() macro is for.

If you define a struct as mentioned above for every CMU, then you should end up with following code:

static const struct exynos5260_cmu_type cmu_xxx = {
        // ...
};
Quoted 6 lines

static void __init cmu_xxx_init(struct device_node *np)

{
        exynos5260_cmu_register_one(np, &cmu_xxx);
}

CLK_OF_DECLARE(cmu_xxx, "samsung,exynos5260-clock-xxx", cmu_xxx_init);

I will be filling cmu_xxx struct in cmu_xxx_init. I hope that is fine.

Quoted 16 lines

for every CMU type, which still needs some duplication, but should be much less than in current form.

Also it would be nice to group definitions for particular CMUs together, e.g.

/* CMU XXX */
// regs
// fixed rate
// muxes
// dividers
// gates
// plls
// struct exynos5260_cmu_type
// cmu_xxx_init()

Quoted 6 lines

/* CMU YYY */
...

This should improve readability of the driver, as definitions for different IP blocks would not be intermingled.

ok.

Quoted 20 lines

[snip]

drivers/clk/samsung/clk-exynos5260.h line 6

Quoted 13 lines
drivers/clk/samsung/clk-exynos5260.h new file +6 -0
new file mode 100644
index 0000000..392c152
@@ -0,0 +1,480 @@
+#ifndef __CLK_EXYNOS5260_H
+#define __CLK_EXYNOS5260_H
+
+/*
+*Base address for different CMUs
+*TODO: All Bases should be removed at earliest.

True, very true. Please remove them in next version ;).

ok :).

Quoted 42 lines
Quoted 42 lines
drivers/clk/samsung/clk-exynos5260.h new file +41 -0
+*/
+#define CMU_AUD_BASE   0x128C0000
+#define CMU_DISP_BASE  0x14550000
+#define CMU_EGL_BASE   0x10600000
+#define CMU_FSYS_BASE  0x122E0000
+#define CMU_G2D_BASE   0x10A00000
+#define CMU_G3D_BASE   0x11830000
+#define CMU_GSCL_BASE  0x13F00000
+#define CMU_ISP_BASE   0x133C0000
+#define CMU_KFC_BASE   0x10700000
+#define CMU_MFC_BASE   0x11090000
+#define CMU_MIF_BASE   0x10CE0000
+#define CMU_PERI_BASE  0x10200000
+#define CMU_TOP_BASE   0x10010000
+
+#define AUD_REG(x)             (x)
+#define DISP_REG(x)            (x)
+#define EGL_REG(x)             (x)
+#define FSYS_REG(x)            (x)
+#define G2D_REG(x)             (x)
+#define G3D_REG(x)             (x)
+#define GSCL_REG(x)            (x)
+#define ISP_REG(x)             (x)
+#define KFC_REG(x)             (x)
+#define MFC_REG(x)             (x)
+#define MIF_REG(x)             (x)
+#define PERI_REG(x)            (x)
+#define TOP_REG(x)             (x)
+
+/*
+*Registers for CMU_AUD
+*/
+#define MUX_SEL_AUD            AUD_REG(0x0200)
+#define MUX_ENABLE_AUD         AUD_REG(0x0300)
+#define MUX_STAT_AUD           AUD_REG(0x0400)
+#define MUX_IGNORE_AUD         AUD_REG(0x0500)
+#define DIV_AUD0               AUD_REG(0x0600)
+#define DIV_AUD1               AUD_REG(0x0604)
+#define DIV_STAT_AUD0          AUD_REG(0x0700)
+#define DIV_STAT_AUD1          AUD_REG(0x0704)
+#define EN_ACLK_AUD            AUD_REG(0x0800)
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.h line 50

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.h new file +3 -0
+#define EN_PCLK_AUD            AUD_REG(0x0900)
+#define EN_SCLK_AUD            AUD_REG(0x0a00)
+#define EN_IP_AUD              AUD_REG(0x0b00)

No need to use XXX_REG() macros, simple offsets are enough. Also I don't think there is a need to have a separate header for these definitions used just by one source file. They can be safely moved there.

Fine. I will changes this.

Regards,
Rahul Sharma

Quoted 2 lines

Best regards,
Tomasz

#9 lore raw

PATCH v3 5/5 clk/exynos5260: add clock file for exynos5260

Hi Rahul,

Quoted 18 lines · Rahul Sharma
Quoted 17 lines · Tomasz Figa

drivers/clk/samsung/clk-exynos5260.c line 411

Quoted 11 lines · Rahul Sharma
drivers/clk/samsung/clk-exynos5260.c new file +11 -0
+/*
+ * List of parent clocks for muses in CMU_DISP
+*/
+PNAME(mout_phyclk_dptx_phy_ch3_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch3_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch2_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch2_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch1_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch1_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch0_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch0_txd_clk"};

Whoa, these clock names are incredibly long. Are they real names from SoC User's Manual?

Quoted 3 lines

Yea, these are same in manual. I kept the name similar, otherwise not easy to search them in UM.

OK.

Quoted 15 lines
Quoted 9 lines
Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+
+PNAME(mout_aclk_disp_222_user_p) = {"fin_pll", "dout_aclk_disp_222"};
+PNAME(mout_sclk_disp_pixel_user_p) = {"fin_pll", "dout_sclk_disp_pixel"};

[snip]

Quoted 5 lines
Quoted 1 line

+/* fixed rate clocks generated outside the soc */

Huh? If they are generated outside the SoC, they shouldn't be registered by this driver, but rather by respective fixed rate clock nodes in DT.

Quoted 8 lines

I tried but system doesn't boot if fin_plll is registered from DT as "fixed-clock".
of_fixed_clk_setup hits after the registration of other CMUs. System asserts in many places due to div by zero error. It is exactly same for Exynos5420. So I took 5420 as example and defined fin_pll as osc clock of compatible type "samsung,exynos5260-oscclk". Rest of the ext clocks are registered as "fixed-clock". What you say on this ?

Hmm, the common clock framework is designed to account for late registration of parent clocks. Fixed rate clocks defined from DT seem to work fine for S3C64xx and Exynos5410 (patches posted some time ago by Tarek Dakhran). I'm not sure why it doesn't work for you.

Quoted 22 lines
Quoted 22 lines
Quoted 20 lines
drivers/clk/samsung/clk-exynos5260.c new file +20 -0
+       FRATE(ID_NONE, "phyclk_hdmi_link_o_tmds_clkhi", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_txbyteclkhs", NULL,
+                       CLK_IS_ROOT, 187500000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_o_ref_clk_24m", NULL,
+                       CLK_IS_ROOT, 24000000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_clk_div2", NULL,
+                       CLK_IS_ROOT, 135000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_rxclkesc0", NULL,
+                       CLK_IS_ROOT, 20000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_freeclk", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_clk48mohci", NULL,
+                       CLK_IS_ROOT, 48000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_pipe_pclk", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
Quoted 8 lines
Quoted 4 lines

Are these really fixed rate clocks? It looks strange, because it's a bit unlike previous Samsung SoCs, which used to have up 5 fixed rate clocks in average.

These are outputs of various phys. If these are removed we will be left with many orphan clocks.

OK. Just wanted to make sure that they are real clocks found in the SoC, as I don't have access to Exynos 5420 datasheet yet.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
drivers/clk/samsung/clk-exynos5260.c new file +13 -0
+};
+
+/*
+ * List of Gate clocks for CMU_DISP
+*/
+struct samsung_gate_clock exynos5260_disp_gate_clks[] __initdata = {
+       GATE(DISP_CLK_SMMU_TV, "clk_smmu3_tv", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 25, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M1, "clk_smmu3_fimd1m1",
+                       "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 23, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M0, "clk_smmu3_fimd1m0",
+                       "mout_aclk_disp_222_user",
Quoted 8 lines

drivers/clk/samsung/clk-exynos5260.c line 1250

Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +5 -0
+                       EN_IP_DISP, 22, 0, 0),
+       GATE(ID_NONE, "clk_pixel_mixer", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 13, CLK_IGNORE_UNUSED, 0),
+       GATE(ID_NONE, "clk_pixel_disp", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 12, CLK_IGNORE_UNUSED, 0),

Why CLK_IGNORE_UNUSED?

Quoted 6 lines

these clocks are required for correct representation of clock tree but they are not enabled by the drivers. like sclk_uart clock is only used for set rate and never enable by the driver. Second category is clock like lpddr which will be used by mif dvfs for lpddr only. These needs to left ingnored for Non lpddr boards. I treid to kept them to minimum.

It's OK for core system peripherals, such as lpddr, monocnt, mif, drex, intmem, etc. I'm not sure about the two display clocks. Respective drivers should be fixed to gate them correctly, but for now maybe it's OK to keep them enabled. However I believe it's wrong for sclk_uart's.

Looking at the code, Samsung serial driver enables selected baud clock properly, so I don't see any reason why sclk_uart clocks should have this flag set. Are you sure you have correct clock look-up in your DT?

Quoted 41 lines
Quoted 31 lines
Quoted 31 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+
+/*
+* Applicable for all 2550 Type PLLS for Exynos5260, listed below
+* DISP_PLL, EGL_PLL, KFC_PLL, MEM_PLL,
+* BUS_PLL, MEDIA_PLL, G3D_PLL.
+*/
+static const struct samsung_pll_rate_table exynos5260_pll2550_24mhz_tbl[]

= {

drivers/clk/samsung/clk-exynos5260.c new file +23 -0
+       PLL_35XX_RATE(1700000000, 425, 6, 0),
+       PLL_35XX_RATE(1600000000, 200, 3, 0),
+       PLL_35XX_RATE(1500000000, 250, 4, 0),
+       PLL_35XX_RATE(1400000000, 175, 3, 0),
+       PLL_35XX_RATE(1300000000, 325, 6, 0),
+       PLL_35XX_RATE(1200000000, 400, 4, 1),
+       PLL_35XX_RATE(1100000000, 275, 3, 1),
+       PLL_35XX_RATE(1000000000, 250, 3, 1),
+       PLL_35XX_RATE(933000000, 311, 4, 1),
+       PLL_35XX_RATE(900000000, 300, 4, 1),
+       PLL_35XX_RATE(800000000, 200, 3, 1),
+       PLL_35XX_RATE(733000000, 733, 12, 1),
+       PLL_35XX_RATE(700000000, 175, 3, 1),
+       PLL_35XX_RATE(667000000, 667, 12, 1),
+       PLL_35XX_RATE(633000000, 211, 4, 1),
+       PLL_35XX_RATE(620000000, 310, 3, 2),
+       PLL_35XX_RATE(600000000, 400, 4, 2),
+       PLL_35XX_RATE(543000000, 362, 4, 2),
+       PLL_35XX_RATE(533000000, 533, 6, 2),
+       PLL_35XX_RATE(500000000, 250, 3, 2),
+       PLL_35XX_RATE(450000000, 300, 4, 2),
+       PLL_35XX_RATE(400000000, 200, 3, 2),
+       PLL_35XX_RATE(350000000, 175, 3, 2),
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c line 1706

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+       PLL_35XX_RATE(300000000, 400, 4, 3),
+       PLL_35XX_RATE(266000000, 266, 3, 3),
+       PLL_35XX_RATE(200000000, 200, 3, 3),
+       PLL_35XX_RATE(160000000, 160, 3, 3),

Are all of those exact values, without any (incorrect) rounding? This is imporant for the rate setting code to work correctly.

Quoted 6 lines

I verfied; all of them are correct other than this:
PLL_36XX_RATE(394216000, 459, 7, 2, 49282),

Its computed values is coming to be 394073128. I will replace 394216000 with 394073128 in the above entry.

OK.

Quoted 14 lines
Quoted 14 lines

drivers/clk/samsung/clk-exynos5260.c line 2193

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+struct of_device_id __clk_of_table_exynos5260[]
+               __used __section(__clk_of_table) = {

I don't think this is a good idea. This construct should not be used directly. This is what CLK_OF_DECLARE() macro is for.

If you define a struct as mentioned above for every CMU, then you should end up with following code:

static const struct exynos5260_cmu_type cmu_xxx = {
         // ...
};
Quoted 8 lines
Quoted 6 lines

static void __init cmu_xxx_init(struct device_node *np)

{
         exynos5260_cmu_register_one(np, &cmu_xxx);
}

CLK_OF_DECLARE(cmu_xxx, "samsung,exynos5260-clock-xxx", cmu_xxx_init);

I will be filling cmu_xxx struct in cmu_xxx_init. I hope that is fine.

Should be fine.

Best regards,
Tomasz

#10 lore raw

PATCH v3 5/5 clk/exynos5260: add clock file for exynos5260

Quoted 31 lines · Tomasz Figa
Quoted 30 lines · Rahul Sharma
Quoted 28 lines · Tomasz Figa
Quoted 10 lines · Rahul Sharma
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_hdmi_link_o_tmds_clkhi", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_txbyteclkhs", NULL,
+                       CLK_IS_ROOT, 187500000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_o_ref_clk_24m", NULL,
+                       CLK_IS_ROOT, 24000000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_clk_div2", NULL,
+                       CLK_IS_ROOT, 135000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_rxclkesc0", NULL,
+                       CLK_IS_ROOT, 20000000),

drivers/clk/samsung/clk-exynos5260.c line 645

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_freeclk", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_clk48mohci", NULL,
+                       CLK_IS_ROOT, 48000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_pipe_pclk", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),

Are these really fixed rate clocks? It looks strange, because it's a bit unlike previous Samsung SoCs, which used to have up 5 fixed rate clocks in
average.

Quoted 7 lines
Quoted 4 lines

These are outputs of various phys. If these are removed we will be left with
many orphan clocks.

OK. Just wanted to make sure that they are real clocks found in the SoC, as I don't have access to Exynos 5420 datasheet yet.

Exynos 5260 of course.

Best regards,
Tomasz

#11 lore raw

PATCH v3 5/5 clk/exynos5260: add clock file for exynos5260

In reply to Tomasz Figa

Hi Tomasz,

Quoted 146 lines · Tomasz Figa

Hi Rahul,

Quoted 22 lines · Rahul Sharma
Quoted 20 lines · Tomasz Figa

drivers/clk/samsung/clk-exynos5260.c line 411

Quoted 12 lines · Rahul Sharma
drivers/clk/samsung/clk-exynos5260.c new file +11 -0
+/*
+ * List of parent clocks for muses in CMU_DISP
+*/
+PNAME(mout_phyclk_dptx_phy_ch3_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch3_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch2_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch2_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch1_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch1_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch0_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch0_txd_clk"};

Whoa, these clock names are incredibly long. Are they real names from SoC User's Manual?

Quoted 4 lines

Yea, these are same in manual. I kept the name similar, otherwise not easy to
search them in UM.

OK.

Quoted 20 lines
Quoted 11 lines
Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+
+PNAME(mout_aclk_disp_222_user_p) = {"fin_pll", "dout_aclk_disp_222"};
+PNAME(mout_sclk_disp_pixel_user_p) = {"fin_pll",

"dout_sclk_disp_pixel"};

[snip]

Quoted 7 lines
Quoted 1 line

+/* fixed rate clocks generated outside the soc */

Huh? If they are generated outside the SoC, they shouldn't be registered by
this driver, but rather by respective fixed rate clock nodes in DT.

Quoted 11 lines

I tried but system doesn't boot if fin_plll is registered from DT as "fixed-clock".
of_fixed_clk_setup hits after the registration of other CMUs. System asserts
in many places due to div by zero error. It is exactly same for Exynos5420.
So I took 5420 as example and defined fin_pll as osc clock of compatible type
"samsung,exynos5260-oscclk". Rest of the ext clocks are registered as "fixed-clock". What you say on this ?

Hmm, the common clock framework is designed to account for late registration of parent clocks. Fixed rate clocks defined from DT seem to work fine for S3C64xx and Exynos5410 (patches posted some time ago by Tarek Dakhran). I'm not sure why it doesn't work for you.

Quoted 29 lines
Quoted 23 lines
Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_hdmi_link_o_tmds_clkhi", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_txbyteclkhs", NULL,
+                       CLK_IS_ROOT, 187500000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_o_ref_clk_24m", NULL,
+                       CLK_IS_ROOT, 24000000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_clk_div2", NULL,
+                       CLK_IS_ROOT, 135000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_rxclkesc0", NULL,
+                       CLK_IS_ROOT, 20000000),

drivers/clk/samsung/clk-exynos5260.c line 645

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_freeclk", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_clk48mohci", NULL,
+                       CLK_IS_ROOT, 48000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_pipe_pclk", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
Quoted 5 lines

Are these really fixed rate clocks? It looks strange, because it's a bit unlike previous Samsung SoCs, which used to have up 5 fixed rate clocks in
average.

Quoted 4 lines

These are outputs of various phys. If these are removed we will be left with
many orphan clocks.

OK. Just wanted to make sure that they are real clocks found in the SoC, as I don't have access to Exynos 5420 datasheet yet.

Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+};
+
+/*
+ * List of Gate clocks for CMU_DISP
+*/
+struct samsung_gate_clock exynos5260_disp_gate_clks[] __initdata = {
+       GATE(DISP_CLK_SMMU_TV, "clk_smmu3_tv",

"mout_aclk_disp_222_user",

drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+                       EN_IP_DISP, 25, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M1, "clk_smmu3_fimd1m1",
+                       "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 23, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M0, "clk_smmu3_fimd1m0",
+                       "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 22, 0, 0),
Quoted 8 lines

drivers/clk/samsung/clk-exynos5260.c line 1250

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+       GATE(ID_NONE, "clk_pixel_mixer", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 13, CLK_IGNORE_UNUSED, 0),
+       GATE(ID_NONE, "clk_pixel_disp", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 12, CLK_IGNORE_UNUSED, 0),

Why CLK_IGNORE_UNUSED?

Quoted 10 lines

these clocks are required for correct representation of clock tree but they are
not enabled by the drivers. like sclk_uart clock is only used for set rate and
never enable by the driver. Second category is clock like lpddr which will be
used by mif dvfs for lpddr only. These needs to left ingnored for Non lpddr
boards. I treid to kept them to minimum.

Quoted 9 lines

It's OK for core system peripherals, such as lpddr, monocnt, mif, drex, intmem, etc. I'm not sure about the two display clocks. Respective drivers should be fixed to gate them correctly, but for now maybe it's OK to keep them enabled. However I believe it's wrong for sclk_uart's.

Looking at the code, Samsung serial driver enables selected baud clock properly, so I don't see any reason why sclk_uart clocks should have this flag set. Are you sure you have correct clock look-up in your DT?

I checked. sclk_uart is enabled properly by serial driver. But for some reason, if I remove INGNORE flag, system throws "imprecise external abort (0x1406) at 0x00000000".

    1.870000] Unhandled fault: imprecise external abort (0x1406) at 0x00000000
[    1.870000] Internal error: : 1406 [#1] SMP ARM
[    1.870000] Modules linked in:
[    1.870000] CPU: 0 PID: 72 Comm: init Not tainted 3.14.0-rc4+ #49
[    1.870000] task: ed81d140 ti: ed84e000 task.ti: ed84e000
[    1.870000] PC is at s3c64xx_serial_startup+0xa8/0xbc
[    1.870000] LR is at _raw_spin_unlock+0x18/0x1c
[    1.870000] ffa0: c000e280 c00fec14 01797b29 00000005 01797b29
00020802 00000000 00000000
[    1.870000] ffc0: 01797b29 00000005 00000802 00000005 01797b29
00000000 b6eed000 00000000
[    1.870000] ffe0: 000a23f4 be969c08 0006d780 b6e706c4 60000010
01797b29 e7f7fb3f ffffffff
[    1.870000] [<c027ecdc>] (s3c64xx_serial_startup) from [<c02790b0>]
(uart_startup.part.3+0x78/0x1a0)
[    1.870000] [<c02790b0>] (uart_startup.part.3) from [<c0279bb0>]
(uart_open+0xe4/0x13c)
[    1.870000] [<c0279bb0>] (uart_open) from [<c025f120>] (tty_open+0x39c/0x544)
[    1.870000] [<c025f120>] (tty_open) from [<c01034fc>]
(chrdev_open+0x140/0x16c)
[    1.870000] [<c01034fc>] (chrdev_open) from [<c00fd598>]
(do_dentry_open+0x1c4/0x284)
[    1.870000] [<c00fd598>] (do_dentry_open) from [<c00fd964>]
(finish_open+0x48/0x5c)
[    1.870000] [<c00fd964>] (finish_open) from [<c010cbe0>]

(do_last.isra.19+0x958/0xb44)

But it is completely fine with sclk_uartX are declared with IGNORE flag. I am not
able to find any clue at software level. Probably we can accept Uart clocks with this flag for exynos5260.

I have already posted V4 for this series where I addressed most of your review comments.
Please review.

Regards,
Rahul Sharma.

Quoted 84 lines
Quoted 44 lines
Quoted 34 lines
Quoted 34 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+
+/*
+* Applicable for all 2550 Type PLLS for Exynos5260, listed below
+* DISP_PLL, EGL_PLL, KFC_PLL, MEM_PLL,
+* BUS_PLL, MEDIA_PLL, G3D_PLL.
+*/
+static const struct samsung_pll_rate_table

exynos5260_pll2550_24mhz_tbl[]
= {

drivers/clk/samsung/clk-exynos5260.c new file +24 -0
+       PLL_35XX_RATE(1700000000, 425, 6, 0),
+       PLL_35XX_RATE(1600000000, 200, 3, 0),
+       PLL_35XX_RATE(1500000000, 250, 4, 0),
+       PLL_35XX_RATE(1400000000, 175, 3, 0),
+       PLL_35XX_RATE(1300000000, 325, 6, 0),
+       PLL_35XX_RATE(1200000000, 400, 4, 1),
+       PLL_35XX_RATE(1100000000, 275, 3, 1),
+       PLL_35XX_RATE(1000000000, 250, 3, 1),
+       PLL_35XX_RATE(933000000, 311, 4, 1),
+       PLL_35XX_RATE(900000000, 300, 4, 1),
+       PLL_35XX_RATE(800000000, 200, 3, 1),
+       PLL_35XX_RATE(733000000, 733, 12, 1),
+       PLL_35XX_RATE(700000000, 175, 3, 1),
+       PLL_35XX_RATE(667000000, 667, 12, 1),
+       PLL_35XX_RATE(633000000, 211, 4, 1),
+       PLL_35XX_RATE(620000000, 310, 3, 2),
+       PLL_35XX_RATE(600000000, 400, 4, 2),
+       PLL_35XX_RATE(543000000, 362, 4, 2),
+       PLL_35XX_RATE(533000000, 533, 6, 2),
+       PLL_35XX_RATE(500000000, 250, 3, 2),
+       PLL_35XX_RATE(450000000, 300, 4, 2),
+       PLL_35XX_RATE(400000000, 200, 3, 2),
+       PLL_35XX_RATE(350000000, 175, 3, 2),
+       PLL_35XX_RATE(300000000, 400, 4, 3),
Quoted 9 lines

drivers/clk/samsung/clk-exynos5260.c line 1706

Quoted 3 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+       PLL_35XX_RATE(266000000, 266, 3, 3),
+       PLL_35XX_RATE(200000000, 200, 3, 3),
+       PLL_35XX_RATE(160000000, 160, 3, 3),

Are all of those exact values, without any (incorrect) rounding? This is imporant for the rate setting code to work correctly.

Quoted 6 lines

I verfied; all of them are correct other than this:
PLL_36XX_RATE(394216000, 459, 7, 2, 49282),

Its computed values is coming to be 394073128. I will replace 394216000 with 394073128 in the above entry.

OK.

Quoted 16 lines
Quoted 16 lines

drivers/clk/samsung/clk-exynos5260.c line 2193

Quoted 2 lines
drivers/clk/samsung/clk-exynos5260.c new file +2 -0
+struct of_device_id __clk_of_table_exynos5260[]
+               __used __section(__clk_of_table) = {

I don't think this is a good idea. This construct should not be used directly. This is what CLK_OF_DECLARE() macro is for.

If you define a struct as mentioned above for every CMU, then you should end
up with following code:

static const struct exynos5260_cmu_type cmu_xxx = {
         // ...
};
Quoted 8 lines
Quoted 6 lines

static void __init cmu_xxx_init(struct device_node *np)

{
         exynos5260_cmu_register_one(np, &cmu_xxx);
}

CLK_OF_DECLARE(cmu_xxx, "samsung,exynos5260-clock-xxx", cmu_xxx_init);

I will be filling cmu_xxx struct in cmu_xxx_init. I hope that is fine.

Should be fine.

Best regards,
Tomasz

#12 lore raw

PATCH v3 5/5 clk/exynos5260: add clock file for exynos5260

Quoted 188 lines · Rahul Sharma

Hi Tomasz,

Quoted 146 lines · Tomasz Figa

Hi Rahul,

Quoted 22 lines · Rahul Sharma
Quoted 20 lines · Tomasz Figa

drivers/clk/samsung/clk-exynos5260.c line 411

Quoted 12 lines · Rahul Sharma
drivers/clk/samsung/clk-exynos5260.c new file +11 -0
+/*
+ * List of parent clocks for muses in CMU_DISP
+*/
+PNAME(mout_phyclk_dptx_phy_ch3_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch3_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch2_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch2_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch1_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch1_txd_clk"};
+PNAME(mout_phyclk_dptx_phy_ch0_txd_clk_user_p) = {"fin_pll",
+                       "phyclk_dptx_phy_ch0_txd_clk"};

Whoa, these clock names are incredibly long. Are they real names from SoC User's Manual?

Quoted 4 lines

Yea, these are same in manual. I kept the name similar, otherwise not easy to
search them in UM.

OK.

Quoted 20 lines
Quoted 11 lines
Quoted 5 lines
drivers/clk/samsung/clk-exynos5260.c new file +3 -0
+
+PNAME(mout_aclk_disp_222_user_p) = {"fin_pll", "dout_aclk_disp_222"};
+PNAME(mout_sclk_disp_pixel_user_p) = {"fin_pll",

"dout_sclk_disp_pixel"};

[snip]

Quoted 7 lines
Quoted 1 line

+/* fixed rate clocks generated outside the soc */

Huh? If they are generated outside the SoC, they shouldn't be registered by
this driver, but rather by respective fixed rate clock nodes in DT.

Quoted 11 lines

I tried but system doesn't boot if fin_plll is registered from DT as "fixed-clock".
of_fixed_clk_setup hits after the registration of other CMUs. System asserts
in many places due to div by zero error. It is exactly same for Exynos5420.
So I took 5420 as example and defined fin_pll as osc clock of compatible type
"samsung,exynos5260-oscclk". Rest of the ext clocks are registered as "fixed-clock". What you say on this ?

Hmm, the common clock framework is designed to account for late registration of parent clocks. Fixed rate clocks defined from DT seem to work fine for S3C64xx and Exynos5410 (patches posted some time ago by Tarek Dakhran). I'm not sure why it doesn't work for you.

Quoted 29 lines
Quoted 23 lines
Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_hdmi_link_o_tmds_clkhi", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_txbyteclkhs", NULL,
+                       CLK_IS_ROOT, 187500000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_o_ref_clk_24m", NULL,
+                       CLK_IS_ROOT, 24000000),
+       FRATE(ID_NONE, "phyclk_dptx_phy_clk_div2", NULL,
+                       CLK_IS_ROOT, 135000000),
+       FRATE(ID_NONE, "phyclk_mipi_dphy_4l_m_rxclkesc0", NULL,
+                       CLK_IS_ROOT, 20000000),

drivers/clk/samsung/clk-exynos5260.c line 645

Quoted 10 lines
drivers/clk/samsung/clk-exynos5260.c new file +10 -0
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_freeclk", NULL,
+                       CLK_IS_ROOT, 60000000),
+       FRATE(ID_NONE, "phyclk_usbhost20_phy_clk48mohci", NULL,
+                       CLK_IS_ROOT, 48000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_pipe_pclk", NULL,
+                       CLK_IS_ROOT, 125000000),
+       FRATE(ID_NONE, "phyclk_usbdrd30_udrd30_phyclock", NULL,
+                       CLK_IS_ROOT, 60000000),
Quoted 5 lines

Are these really fixed rate clocks? It looks strange, because it's a bit unlike previous Samsung SoCs, which used to have up 5 fixed rate clocks in
average.

Quoted 4 lines

These are outputs of various phys. If these are removed we will be left with
many orphan clocks.

OK. Just wanted to make sure that they are real clocks found in the SoC, as I don't have access to Exynos 5420 datasheet yet.

Quoted 25 lines
Quoted 15 lines
Quoted 15 lines
drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+};
+
+/*
+ * List of Gate clocks for CMU_DISP
+*/
+struct samsung_gate_clock exynos5260_disp_gate_clks[] __initdata = {
+       GATE(DISP_CLK_SMMU_TV, "clk_smmu3_tv",

"mout_aclk_disp_222_user",

drivers/clk/samsung/clk-exynos5260.c new file +7 -0
+                       EN_IP_DISP, 25, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M1, "clk_smmu3_fimd1m1",
+                       "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 23, 0, 0),
+       GATE(DISP_CLK_SMMU_FIMD1M0, "clk_smmu3_fimd1m0",
+                       "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 22, 0, 0),
Quoted 8 lines

drivers/clk/samsung/clk-exynos5260.c line 1250

Quoted 4 lines
drivers/clk/samsung/clk-exynos5260.c new file +4 -0
+       GATE(ID_NONE, "clk_pixel_mixer", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 13, CLK_IGNORE_UNUSED, 0),
+       GATE(ID_NONE, "clk_pixel_disp", "mout_aclk_disp_222_user",
+                       EN_IP_DISP, 12, CLK_IGNORE_UNUSED, 0),

Why CLK_IGNORE_UNUSED?

Quoted 10 lines

these clocks are required for correct representation of clock tree but they are
not enabled by the drivers. like sclk_uart clock is only used for set rate and
never enable by the driver. Second category is clock like lpddr which will be
used by mif dvfs for lpddr only. These needs to left ingnored for Non lpddr
boards. I treid to kept them to minimum.

Quoted 9 lines

It's OK for core system peripherals, such as lpddr, monocnt, mif, drex, intmem, etc. I'm not sure about the two display clocks. Respective drivers should be fixed to gate them correctly, but for now maybe it's OK to keep them enabled. However I believe it's wrong for sclk_uart's.

Looking at the code, Samsung serial driver enables selected baud clock properly, so I don't see any reason why sclk_uart clocks should have this flag set. Are you sure you have correct clock look-up in your DT?

I checked. sclk_uart is enabled properly by serial driver. But for some reason, if I remove INGNORE flag, system throws "imprecise external abort (0x1406) at 0x00000000".

     1.870000] Unhandled fault: imprecise external abort (0x1406) at 0x00000000
[    1.870000] Internal error: : 1406 [#1] SMP ARM
[    1.870000] Modules linked in:
[    1.870000] CPU: 0 PID: 72 Comm: init Not tainted 3.14.0-rc4+ #49
[    1.870000] task: ed81d140 ti: ed84e000 task.ti: ed84e000
[    1.870000] PC is at s3c64xx_serial_startup+0xa8/0xbc
[    1.870000] LR is at _raw_spin_unlock+0x18/0x1c
[    1.870000] ffa0: c000e280 c00fec14 01797b29 00000005 01797b29
00020802 00000000 00000000
[    1.870000] ffc0: 01797b29 00000005 00000802 00000005 01797b29
00000000 b6eed000 00000000
[    1.870000] ffe0: 000a23f4 be969c08 0006d780 b6e706c4 60000010
01797b29 e7f7fb3f ffffffff
[    1.870000] [<c027ecdc>] (s3c64xx_serial_startup) from [<c02790b0>]
(uart_startup.part.3+0x78/0x1a0)
[    1.870000] [<c02790b0>] (uart_startup.part.3) from [<c0279bb0>]
(uart_open+0xe4/0x13c)
[    1.870000] [<c0279bb0>] (uart_open) from [<c025f120>] (tty_open+0x39c/0x544)
[    1.870000] [<c025f120>] (tty_open) from [<c01034fc>]
(chrdev_open+0x140/0x16c)
[    1.870000] [<c01034fc>] (chrdev_open) from [<c00fd598>]
(do_dentry_open+0x1c4/0x284)
[    1.870000] [<c00fd598>] (do_dentry_open) from [<c00fd964>]
(finish_open+0x48/0x5c)
[    1.870000] [<c00fd964>] (finish_open) from [<c010cbe0>]
Quoted 6 lines

(do_last.isra.19+0x958/0xb44)

But it is completely fine with sclk_uartX are declared with IGNORE flag. I am not
able to find any clue at software level. Probably we can accept Uart clocks with this flag for exynos5260.

This looks to me like masking a bug somewhere else. I don't think this is a good idea, because such bug forgotten may strike again later with worse and hard to debug effects. I'd insist on fixing it instead.

Quoted 3 lines

I have already posted V4 for this series where I addressed most of your review comments.
Please review.

Well, you have not addressed the comment about using generic fixed rate clock bindings. The old vendor-specific bindings are deprecated and must not be used anymore by new code. Please fix it.

I'll see how v4 looks, though.

Best regards,
Tomasz