Skip to contentSkip to conversation

clk: meson-g12a: Add EE clock controller driver

PATCH In review Jerome Brunet 3 participants 8 messages Feb 1, 2019 – Feb 7, 2019

Subsystems (4)
lore
Share & tools
lore

Jerome Brunet

author maintainer
#0 lore raw

v6 cover clk: meson-g12a: Add EE clock controller driver

This purpose of this patchset is to the main clock controller of the g12a SoC family

This patchset depends on the recent rework the meson clock directory [7].

Changes since v5 [6]:
* use clock input driver until something better comes along in CCF
* fix pll fractional param size
* fix broken gp0 and hifi pll param (<55)
* add hdmi pll
* fix fdiv2p5
* add mpll_50m
* fix mpll clock tree (missing fix 2 divider)
* add missing sdio clocks
* add vpu clocks
* add some RO clock gates
* rabase on clk-meson tree

Changes since v4 [5]:
* add bypass clock "g12a_ee_core" from DT
* fix Kconfig description
* change g12a_mpll0_div/g12a_mpll1_div/g12a_mpll2_div/g12a_mpll3_div clock's parent name as fixed_pll_dco
* drop CLK_SET_RATE_PARENT flag for pll clock
* drop CLK_GET_RATE_NOCACHE flag for pll_dco clock
* delete usless note
* enable G12A clock driver

Changes since v3 [4]:
* add fixed clocks clk_regmap definition

Changes since v2 [2]:
* fix fixed clock descriptions
* fix alignment
* add enable bit for plls base on [3] patches
* add fixed clock gate bit

Changes since v1 [1]:
* fix typo of 'Everything'.
* change the word 'AmLogic' to 'Amlogic'
* squash patch 1 and 2.
* delete usless message of "Trying obsolete regs".
* delete the empty line in include/dt-bindings/clock/g12a-clkc.h.
* rebase on top of the "next/drivers" branch, and add g12a clock patch.
* add CLK_MUX_ROUND_CLOSEST for g12a_sd_emmc_b_clk0_sel and g12a_sd_emmc_c_clk0_sel.

[1]: https://lkml.kernel.org/r/[email protected]
[2]: https://lkml.kernel.org/r/[email protected]
[3]: https://lkml.kernel.org/r/[email protected]
[4]: https://lkml.kernel.org/r/[email protected]
[5]: https://lkml.kernel.org/r/[email protected]
[6]: https://lkml.kernel.org/r/[email protected]
[7]: https://lkml.kernel.org/r/[email protected]

Jerome Brunet (2):
clk: meson: pll: update driver for the g12a
clk: meson: factorise meson64 peripheral clock controller drivers

Jian Hu (2):
dt-bindings: clk: meson: add g12a periph clock controller bindings
clk: meson: g12a: add peripheral clock controller

 .../bindings/clock/amlogic,gxbb-clkc.txt      |    1 +
 drivers/clk/meson/Kconfig                     |   21 +-
 drivers/clk/meson/Makefile                    |    2 +
 drivers/clk/meson/axg.c                       |   59 +-
 drivers/clk/meson/clk-pll.c                   |  203 +-
 drivers/clk/meson/clk-pll.h                   |   10 +-
 drivers/clk/meson/clk-regmap.h                |    9 +-
 drivers/clk/meson/g12a.c                      | 2359 +++++++++++++++++
 drivers/clk/meson/g12a.h                      |  175 ++
 drivers/clk/meson/gxbb.c                      |  272 +-
 drivers/clk/meson/meson-eeclk.c               |   63 +
 drivers/clk/meson/meson-eeclk.h               |   25 +
 include/dt-bindings/clock/g12a-clkc.h         |  135 +
 13 files changed, 3147 insertions(+), 187 deletions(-)
 create mode 100644 drivers/clk/meson/g12a.c
 create mode 100644 drivers/clk/meson/g12a.h
 create mode 100644 drivers/clk/meson/meson-eeclk.c
 create mode 100644 drivers/clk/meson/meson-eeclk.h
 create mode 100644 include/dt-bindings/clock/g12a-clkc.h
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH v6 1/4 clk: meson: pll: update driver for the g12a

The g12a use fractional parameter of 17 useful bits. At the moment, this parameter in encoded using u16 value. Use this opportunity to switch all the pll to parameter to unsigned int. This should save us some annoying trouble shooting when and m and n field eventually grow as well.

This patch also introduce pll multiplier range. On the g12a, the hifi and gp0 plls are able to lock as long as the following condition is met:
55 <= m/n <= 255.

The param table describing this would be huge which is a waste of memory. Using ranges, we can save memory. Ranges also help find the best pll parameter significantly faster since we don't have to try all the possible settings.

---

Side note:
You may notice that the g12a documentation says that the fractional parameter of the hifi and gp0 pll is actually 19 bits long.

On older plls, frac was a ratio in the [0, 1[ range. On the newer plls, the range is ]-2, 2[.

The last 2 bits give the sign and allows to go over 1. Supporting this would complicate things a lot while not bringing anything useful. Instead of using this extended frac range, we can simply adjust m and reach the same solution.

Discarding the last two bits allows to treat older and newer pll models indifferently.

 drivers/clk/meson/clk-pll.c | 203 ++++++++++++++++++++++++++----------
 drivers/clk/meson/clk-pll.h |  10 +-
 2 files changed, 154 insertions(+), 59 deletions(-)
drivers/clk/meson/clk-pll.c +146 -57
index 4a8c68ae8801..7946d21a4ff4 100644
@@ -32,6 +32,7 @@
 #include <linux/io.h>
 #include <linux/math64.h>
 #include <linux/module.h>
+#include <linux/rational.h>
 
 #include "clk-regmap.h"
 #include "clk-pll.h"
@@ -42,12 +43,21 @@ meson_clk_pll_data(struct clk_regmap *clk)
 	return (struct meson_clk_pll_data *)clk->data;
 }
 
+static int __pll_round_closest_mult(struct meson_clk_pll_data *pll)
+{
+	if ((pll->flags & CLK_MESON_PLL_ROUND_CLOSEST) &&
+	    !MESON_PARM_APPLICABLE(&pll->frac))
+		return 1;
+
+	return 0;
+}
+
 static unsigned long __pll_params_to_rate(unsigned long parent_rate,
-					  const struct pll_params_table *pllt,
-					  u16 frac,
+					  unsigned int m, unsigned int n,
+					  unsigned int frac,
 					  struct meson_clk_pll_data *pll)
 {
-	u64 rate = (u64)parent_rate * pllt->m;
+	u64 rate = (u64)parent_rate * m;
 
 	if (frac && MESON_PARM_APPLICABLE(&pll->frac)) {
 		u64 frac_rate = (u64)parent_rate * frac;
@@ -56,7 +66,7 @@ static unsigned long __pll_params_to_rate(unsigned long parent_rate,
 					 (1 << pll->frac.width));
 	}
 
-	return DIV_ROUND_UP_ULL(rate, pllt->n);
+	return DIV_ROUND_UP_ULL(rate, n);
 }
 
 static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
@@ -64,35 +74,39 @@ static unsigned long meson_clk_pll_recalc_rate(struct clk_hw *hw,
 {
 	struct clk_regmap *clk = to_clk_regmap(hw);
 	struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
-	struct pll_params_table pllt;
-	u16 frac;
+	unsigned int m, n, frac;
 
-	pllt.n = meson_parm_read(clk->map, &pll->n);
-	pllt.m = meson_parm_read(clk->map, &pll->m);
+	n = meson_parm_read(clk->map, &pll->n);
+	m = meson_parm_read(clk->map, &pll->m);
 
 	frac = MESON_PARM_APPLICABLE(&pll->frac) ?
 		meson_parm_read(clk->map, &pll->frac) :
 		0;
 
-	return __pll_params_to_rate(parent_rate, &pllt, frac, pll);
+	return __pll_params_to_rate(parent_rate, m, n, frac, pll);
 }
 
-static u16 __pll_params_with_frac(unsigned long rate,
-				  unsigned long parent_rate,
-				  const struct pll_params_table *pllt,
-				  struct meson_clk_pll_data *pll)
+static unsigned int __pll_params_with_frac(unsigned long rate,
+					   unsigned long parent_rate,
+					   unsigned int m,
+					   unsigned int n,
+					   struct meson_clk_pll_data *pll)
 {
-	u16 frac_max = (1 << pll->frac.width);
-	u64 val = (u64)rate * pllt->n;
+	unsigned int frac_max = (1 << pll->frac.width);
+	u64 val = (u64)rate * n;
+
+	/* Bail out if we are already over the requested rate */
+	if (rate < parent_rate * m / n)
+		return 0;
 
 	if (pll->flags & CLK_MESON_PLL_ROUND_CLOSEST)
 		val = DIV_ROUND_CLOSEST_ULL(val * frac_max, parent_rate);
 	else
 		val = div_u64(val * frac_max, parent_rate);
 
-	val -= pllt->m * frac_max;
+	val -= m * frac_max;
 
-	return min((u16)val, (u16)(frac_max - 1));
+	return min((unsigned int)val, (frac_max - 1));
 }
 
 static bool meson_clk_pll_is_better(unsigned long rate,
@@ -100,45 +114,123 @@ static bool meson_clk_pll_is_better(unsigned long rate,
 				    unsigned long now,
 				    struct meson_clk_pll_data *pll)
 {
-	if (!(pll->flags & CLK_MESON_PLL_ROUND_CLOSEST) ||
-	    MESON_PARM_APPLICABLE(&pll->frac)) {
-		/* Round down */
-		if (now < rate && best < now)
-			return true;
-	} else {
+	if (__pll_round_closest_mult(pll)) {
 		/* Round Closest */
 		if (abs(now - rate) < abs(best - rate))
 			return true;
+	} else {
+		/* Round down */
+		if (now < rate && best < now)
+			return true;
 	}
 
 	return false;
 }
 
-static const struct pll_params_table *
-meson_clk_get_pll_settings(unsigned long rate,
-			   unsigned long parent_rate,
-			   struct meson_clk_pll_data *pll)
+static int meson_clk_get_pll_table_index(unsigned int index,
+					 unsigned int *m,
+					 unsigned int *n,
+					 struct meson_clk_pll_data *pll)
 {
-	const struct pll_params_table *table = pll->table;
-	unsigned long best = 0, now = 0;
-	unsigned int i, best_i = 0;
+	if (!pll->table[index].n)
+		return -EINVAL;
+
+	*m = pll->table[index].m;
+	*n = pll->table[index].n;
+
+	return 0;
+}
+
+static unsigned int meson_clk_get_pll_range_m(unsigned long rate,
+					      unsigned long parent_rate,
+					      unsigned int n,
+					      struct meson_clk_pll_data *pll)
+{
+	u64 val = (u64)rate * n;
+
+	if (__pll_round_closest_mult(pll))
+		return DIV_ROUND_CLOSEST_ULL(val, parent_rate);
 
-	if (!table)
-		return NULL;
+	return val / parent_rate;
+}
+
+static int meson_clk_get_pll_range_index(unsigned long rate,
+					 unsigned long parent_rate,
+					 unsigned int index,
+					 unsigned int *m,
+					 unsigned int *n,
+					 struct meson_clk_pll_data *pll)
+{
+	*n = index + 1;
+
+	/* Check the predivider range */
+	if (*n >= (1 << pll->n.width))
+		return -EINVAL;
+
+	if (*n == 1) {
+		/* Get the boundaries out the way */
+		if (rate <= pll->range->min * parent_rate) {
+			*m = pll->range->min;
+			return -ENODATA;
+		} else if (rate >= pll->range->max * parent_rate) {
+			*m = pll->range->max;
+			return -ENODATA;
+		}
+	}
+
+	*m = meson_clk_get_pll_range_m(rate, parent_rate, *n, pll);
+
+	/* the pre-divider gives a multiplier too big - stop */
+	if (*m >= (1 << pll->m.width))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int meson_clk_get_pll_get_index(unsigned long rate,
+				       unsigned long parent_rate,
+				       unsigned int index,
+				       unsigned int *m,
+				       unsigned int *n,
+				       struct meson_clk_pll_data *pll)
+{
+	if (pll->range)
+		return meson_clk_get_pll_range_index(rate, parent_rate,
+						     index, m, n, pll);
+	else if (pll->table)
+		return meson_clk_get_pll_table_index(index, m, n, pll);
+
+	return -EINVAL;
+}
 
-	for (i = 0; table[i].n; i++) {
-		now = __pll_params_to_rate(parent_rate, &table[i], 0, pll);
+static int meson_clk_get_pll_settings(unsigned long rate,
+				      unsigned long parent_rate,
+				      unsigned int *best_m,
+				      unsigned int *best_n,
+				      struct meson_clk_pll_data *pll)
+{
+	unsigned long best = 0, now = 0;
+	unsigned int i, m, n;
+	int ret;
+
+	for (i = 0, ret = 0; !ret; i++) {
+		ret = meson_clk_get_pll_get_index(rate, parent_rate,
+						  i, &m, &n, pll);
+		if (ret == -EINVAL)
+			break;
 
-		/* If we get an exact match, don't bother any further */
-		if (now == rate) {
-			return &table[i];
-		} else if (meson_clk_pll_is_better(rate, best, now, pll)) {
+		now = __pll_params_to_rate(parent_rate, m, n, 0, pll);
+		if (meson_clk_pll_is_better(rate, best, now, pll)) {
 			best = now;
-			best_i = i;
+			*best_m = m;
+			*best_n = n;
+
+			if (now == rate)
+				break;
 		}
 	}
 
-	return (struct pll_params_table *)&table[best_i];
+	return best ? 0 : -EINVAL;
 }
 
 static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
@@ -146,15 +238,15 @@ static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
 {
 	struct clk_regmap *clk = to_clk_regmap(hw);
 	struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
-	const struct pll_params_table *pllt =
-		meson_clk_get_pll_settings(rate, *parent_rate, pll);
+	unsigned int m, n, frac;
 	unsigned long round;
-	u16 frac;
+	int ret;
 
-	if (!pllt)
+	ret = meson_clk_get_pll_settings(rate, *parent_rate, &m, &n, pll);
+	if (ret)
 		return meson_clk_pll_recalc_rate(hw, *parent_rate);
 
-	round = __pll_params_to_rate(*parent_rate, pllt, 0, pll);
+	round = __pll_params_to_rate(*parent_rate, m, n, 0, pll);
 
 	if (!MESON_PARM_APPLICABLE(&pll->frac) || rate == round)
 		return round;
@@ -163,9 +255,9 @@ static long meson_clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
 	 * The rate provided by the setting is not an exact match, let's
 	 * try to improve the result using the fractional parameter
 	 */
-	frac = __pll_params_with_frac(rate, *parent_rate, pllt, pll);
+	frac = __pll_params_with_frac(rate, *parent_rate, m, n, pll);
 
-	return __pll_params_to_rate(*parent_rate, pllt, frac, pll);
+	return __pll_params_to_rate(*parent_rate, m, n, frac, pll);
 }
 
 static int meson_clk_pll_wait_lock(struct clk_hw *hw)
@@ -252,30 +344,27 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 {
 	struct clk_regmap *clk = to_clk_regmap(hw);
 	struct meson_clk_pll_data *pll = meson_clk_pll_data(clk);
-	const struct pll_params_table *pllt;
-	unsigned int enabled;
+	unsigned int enabled, m, n, frac = 0, ret;
 	unsigned long old_rate;
-	u16 frac = 0;
 
 	if (parent_rate == 0 || rate == 0)
 		return -EINVAL;
 
 	old_rate = rate;
 
-	pllt = meson_clk_get_pll_settings(rate, parent_rate, pll);
-	if (!pllt)
-		return -EINVAL;
+	ret = meson_clk_get_pll_settings(rate, parent_rate, &m, &n, pll);
+	if (ret)
+		return ret;
 
 	enabled = meson_parm_read(clk->map, &pll->en);
 	if (enabled)
 		meson_clk_pll_disable(hw);
 
-	meson_parm_write(clk->map, &pll->n, pllt->n);
-	meson_parm_write(clk->map, &pll->m, pllt->m);
-
+	meson_parm_write(clk->map, &pll->n, n);
+	meson_parm_write(clk->map, &pll->m, m);
 
 	if (MESON_PARM_APPLICABLE(&pll->frac)) {
-		frac = __pll_params_with_frac(rate, parent_rate, pllt, pll);
+		frac = __pll_params_with_frac(rate, parent_rate, m, n, pll);
 		meson_parm_write(clk->map, &pll->frac, frac);
 	}
 
drivers/clk/meson/clk-pll.h +8 -2
index 5ccf0854d932..55af2e285b1b 100644
@@ -12,8 +12,13 @@
 #include "parm.h"
 
 struct pll_params_table {
-	u16		m;
-	u16		n;
+	unsigned int	m;
+	unsigned int	n;
+};
+
+struct pll_mult_range {
+	unsigned int	min;
+	unsigned int	max;
 };
 
 #define PLL_PARAMS(_m, _n)						\
@@ -34,6 +39,7 @@ struct meson_clk_pll_data {
 	const struct reg_sequence *init_regs;
 	unsigned int init_count;
 	const struct pll_params_table *table;
+	const struct pll_mult_range *range;
 	u8 flags;
 };
 
Signature · 1 line
2.20.1
author maintainer
#2 lore raw

PATCH v6 2/4 dt-bindings: clk: meson: add g12a periph clock controller bindings

In reply to Jerome Brunet

From: Jian Hu <[email protected]>

Add new clock controller compatible and dt-bindings header for the Everything-Else domain of the g12a SoC

---
 .../bindings/clock/amlogic,gxbb-clkc.txt      |   1 +
 include/dt-bindings/clock/g12a-clkc.h         | 135 ++++++++++++++++++
 2 files changed, 136 insertions(+)
 create mode 100644 include/dt-bindings/clock/g12a-clkc.h
Documentation/devicetree/bindings/clock/amlogic,gxbb-clkc.txt +1 -0
index a6871953bf04..5c8b105be4d6 100644
@@ -9,6 +9,7 @@ Required Properties:
 		"amlogic,gxbb-clkc" for GXBB SoC,
 		"amlogic,gxl-clkc" for GXL and GXM SoC,
 		"amlogic,axg-clkc" for AXG SoC.
+		"amlogic,g12a-clkc" for G12A SoC.
 - clocks : list of clock phandle, one for each entry clock-names.
 - clock-names : should contain the following:
   * "xtal": the platform xtal
include/dt-bindings/clock/g12a-clkc.h new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
2.20.1
author maintainer
#3 lore raw

PATCH v6 3/4 clk: meson: g12a: add peripheral clock controller

In reply to Jerome Brunet

From: Jian Hu <[email protected]>

Add the peripheral clock controller found in the g12a SoC family

---
 drivers/clk/meson/Kconfig      |   12 +
 drivers/clk/meson/Makefile     |    1 +
 drivers/clk/meson/clk-regmap.h |    9 +-
 drivers/clk/meson/g12a.c       | 2399 ++++++++++++++++++++++++++++++++
 drivers/clk/meson/g12a.h       |  175 +++
 5 files changed, 2594 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/meson/g12a.c
 create mode 100644 drivers/clk/meson/g12a.h
drivers/clk/meson/Kconfig +12 -0
index f2e757aea4f1..4f61dd71f26d 100644
@@ -88,3 +88,15 @@ config COMMON_CLK_AXG_AUDIO
 	help
 	  Support for the audio clock controller on AmLogic A113D devices,
 	  aka axg, Say Y if you want audio subsystem to work.
+
+config COMMON_CLK_G12A
+	bool
+	depends on ARCH_MESON
+	select COMMON_CLK_MESON_INPUT
+	select COMMON_CLK_MESON_REGMAP
+	select COMMON_CLK_MESON_MPLL
+	select COMMON_CLK_MESON_PLL
+	select MFD_SYSCON
+	help
+	  Support for the clock controller on Amlogic S905D2, S905X2 and S905Y2
+	  devices, aka g12a. Say Y if you want peripherals to work.
drivers/clk/meson/Makefile +1 -0
index e339d8f58488..c3dd3901afe3 100644
@@ -15,4 +15,5 @@ obj-$(CONFIG_COMMON_CLK_MESON_VID_PLL_DIV) += vid-pll-div.o
 obj-$(CONFIG_COMMON_CLK_AXG) += axg.o axg-aoclk.o
 obj-$(CONFIG_COMMON_CLK_AXG_AUDIO) += axg-audio.o
 obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o
+obj-$(CONFIG_COMMON_CLK_G12A) += g12a.o
 obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
drivers/clk/meson/clk-regmap.h +7 -2
index b7a085bbf072..1dd0abe3ba91 100644
@@ -111,7 +111,7 @@ clk_get_regmap_mux_data(struct clk_regmap *clk)
 extern const struct clk_ops clk_regmap_mux_ops;
 extern const struct clk_ops clk_regmap_mux_ro_ops;
 
-#define MESON_GATE(_name, _reg, _bit)					\
+#define __MESON_GATE(_name, _reg, _bit, _ops)				\
 struct clk_regmap _name = {						\
 	.data = &(struct clk_regmap_gate_data){				\
 		.offset = (_reg),					\
@@ -119,11 +119,16 @@ struct clk_regmap _name = {						\
 	},								\
 	.hw.init = &(struct clk_init_data) {				\
 		.name = #_name,						\
-		.ops = &clk_regmap_gate_ops,				\
+		.ops = _ops,						\
 		.parent_names = (const char *[]){ "clk81" },		\
 		.num_parents = 1,					\
 		.flags = (CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED),	\
 	},								\
 }
 
+#define MESON_GATE(_name, _reg, _bit)	\
+	__MESON_GATE(_name, _reg, _bit, &clk_regmap_gate_ops)
+
+#define MESON_GATE_RO(_name, _reg, _bit)	\
+	__MESON_GATE(_name, _reg, _bit, &clk_regmap_gate_ro_ops)
 #endif /* __CLK_REGMAP_H */
drivers/clk/meson/g12a.c new file +2399 -0

2,399 lines not on this page · raw message

drivers/clk/meson/g12a.h new file +175 -0

175 lines not on this page · raw message

Signature · 1 line
2.20.1
author maintainer
#4 lore raw

PATCH v6 4/4 clk: meson: factorise meson64 peripheral clock controller drivers

In reply to Jerome Brunet

The function used to probe the peripheral clock controller of the arm64 amlogic SoCs is mostly the same. We now have 3 of those controllers so it is time to factorize things a bit.

---
 drivers/clk/meson/Kconfig       |  11 +-
 drivers/clk/meson/Makefile      |   1 +
 drivers/clk/meson/axg.c         |  59 ++-----
 drivers/clk/meson/g12a.c        |  58 ++-----
 drivers/clk/meson/gxbb.c        | 272 +++++++++++++++++++++++---------
 drivers/clk/meson/meson-eeclk.c |  63 ++++++++
 drivers/clk/meson/meson-eeclk.h |  25 +++
 7 files changed, 313 insertions(+), 176 deletions(-)
 create mode 100644 drivers/clk/meson/meson-eeclk.c
 create mode 100644 drivers/clk/meson/meson-eeclk.h
drivers/clk/meson/Kconfig +8 -3
index 4f61dd71f26d..b72439315340 100644
@@ -35,6 +35,11 @@ config COMMON_CLK_MESON_AO_CLKC
 	select COMMON_CLK_MESON_INPUT
 	select RESET_CONTROLLER
 
+config COMMON_CLK_MESON_EE_CLKC
+	tristate
+	select COMMON_CLK_MESON_REGMAP
+	select COMMON_CLK_MESON_INPUT
+
 config COMMON_CLK_MESON8B
 	bool
 	depends on ARCH_MESON
@@ -51,13 +56,13 @@ config COMMON_CLK_MESON8B
 config COMMON_CLK_GXBB
 	bool
 	depends on ARCH_MESON
-	select COMMON_CLK_MESON_INPUT
 	select COMMON_CLK_MESON_REGMAP
 	select COMMON_CLK_MESON_DUALDIV
 	select COMMON_CLK_MESON_VID_PLL_DIV
 	select COMMON_CLK_MESON_MPLL
 	select COMMON_CLK_MESON_PLL
 	select COMMON_CLK_MESON_AO_CLKC
+	select COMMON_CLK_MESON_EE_CLKC
 	select MFD_SYSCON
 	help
 	  Support for the clock controller on AmLogic S905 devices, aka gxbb.
@@ -66,12 +71,12 @@ config COMMON_CLK_GXBB
 config COMMON_CLK_AXG
 	bool
 	depends on ARCH_MESON
-	select COMMON_CLK_MESON_INPUT
 	select COMMON_CLK_MESON_REGMAP
 	select COMMON_CLK_MESON_DUALDIV
 	select COMMON_CLK_MESON_MPLL
 	select COMMON_CLK_MESON_PLL
 	select COMMON_CLK_MESON_AO_CLKC
+	select COMMON_CLK_MESON_EE_CLKC
 	select MFD_SYSCON
 	help
 	  Support for the clock controller on AmLogic A113D devices, aka axg.
@@ -92,10 +97,10 @@ config COMMON_CLK_AXG_AUDIO
 config COMMON_CLK_G12A
 	bool
 	depends on ARCH_MESON
-	select COMMON_CLK_MESON_INPUT
 	select COMMON_CLK_MESON_REGMAP
 	select COMMON_CLK_MESON_MPLL
 	select COMMON_CLK_MESON_PLL
+	select COMMON_CLK_MESON_EE_CLKC
 	select MFD_SYSCON
 	help
 	  Support for the clock controller on Amlogic S905D2, S905X2 and S905Y2
drivers/clk/meson/Makefile +1 -0
index c3dd3901afe3..32d17f18541e 100644
@@ -2,6 +2,7 @@
 
 obj-$(CONFIG_COMMON_CLK_MESON_AO_CLKC) += meson-aoclk.o
 obj-$(CONFIG_COMMON_CLK_MESON_DUALDIV) += clk-dualdiv.o
+obj-$(CONFIG_COMMON_CLK_MESON_EE_CLKC) += meson-eeclk.o
 obj-$(CONFIG_COMMON_CLK_MESON_INPUT) += clk-input.o
 obj-$(CONFIG_COMMON_CLK_MESON_MPLL) += clk-mpll.o
 obj-$(CONFIG_COMMON_CLK_MESON_PHASE) += clk-phase.o
drivers/clk/meson/axg.c +10 -49

86 lines not on this page · raw message

drivers/clk/meson/g12a.c +9 -49

84 lines not on this page · raw message

drivers/clk/meson/gxbb.c +197 -75

320 lines not on this page · raw message

drivers/clk/meson/meson-eeclk.c new file +63 -0

63 lines not on this page · raw message

drivers/clk/meson/meson-eeclk.h new file +25 -0
new file mode 100644
index 000000000000..1b809b1419fe
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019 BayLibre, SAS.
+ * Author: Jerome Brunet <[email protected]>
+ */
+
+#ifndef __MESON_CLKC_H
+#define __MESON_CLKC_H
+
+#include <linux/clk-provider.h>
+#include "clk-regmap.h"
+
+#define IN_PREFIX "ee-in-"
+
+struct platform_device;
+
+struct meson_eeclkc_data {
+	struct clk_regmap *const	*regmap_clks;
+	unsigned int			regmap_clk_num;
+	struct clk_hw_onecell_data	*hw_onecell_data;
+};
+
+int meson_eeclkc_probe(struct platform_device *pdev);
+
+#endif /* __MESON_CLKC_H */
Signature · 1 line
2.20.1
Reviewed-by on the v6 series
#5 lore raw
In reply to Jerome Brunet

Hi,

Quoted 74 lines · Jerome Brunet

This purpose of this patchset is to the main clock controller of the g12a SoC family

This patchset depends on the recent rework the meson clock directory [7].

Changes since v5 [6]:
* use clock input driver until something better comes along in CCF
* fix pll fractional param size
* fix broken gp0 and hifi pll param (<55)
* add hdmi pll
* fix fdiv2p5
* add mpll_50m
* fix mpll clock tree (missing fix 2 divider)
* add missing sdio clocks
* add vpu clocks
* add some RO clock gates
* rabase on clk-meson tree

Changes since v4 [5]:
* add bypass clock "g12a_ee_core" from DT
* fix Kconfig description
* change g12a_mpll0_div/g12a_mpll1_div/g12a_mpll2_div/g12a_mpll3_div clock's parent name as fixed_pll_dco
* drop CLK_SET_RATE_PARENT flag for pll clock
* drop CLK_GET_RATE_NOCACHE flag for pll_dco clock
* delete usless note
* enable G12A clock driver

Changes since v3 [4]:
* add fixed clocks clk_regmap definition

Changes since v2 [2]:
* fix fixed clock descriptions
* fix alignment
* add enable bit for plls base on [3] patches
* add fixed clock gate bit

Changes since v1 [1]:
* fix typo of 'Everything'.
* change the word 'AmLogic' to 'Amlogic'
* squash patch 1 and 2.
* delete usless message of "Trying obsolete regs".
* delete the empty line in include/dt-bindings/clock/g12a-clkc.h.
* rebase on top of the "next/drivers" branch, and add g12a clock patch.
* add CLK_MUX_ROUND_CLOSEST for g12a_sd_emmc_b_clk0_sel and g12a_sd_emmc_c_clk0_sel.

[1]: https://lkml.kernel.org/r/[email protected]
[2]: https://lkml.kernel.org/r/[email protected]
[3]: https://lkml.kernel.org/r/[email protected]
[4]: https://lkml.kernel.org/r/[email protected]
[5]: https://lkml.kernel.org/r/[email protected]
[6]: https://lkml.kernel.org/r/[email protected]
[7]: https://lkml.kernel.org/r/[email protected]

Jerome Brunet (2):
clk: meson: pll: update driver for the g12a
clk: meson: factorise meson64 peripheral clock controller drivers

Jian Hu (2):
dt-bindings: clk: meson: add g12a periph clock controller bindings
clk: meson: g12a: add peripheral clock controller

 .../bindings/clock/amlogic,gxbb-clkc.txt      |    1 +
 drivers/clk/meson/Kconfig                     |   21 +-
 drivers/clk/meson/Makefile                    |    2 +
 drivers/clk/meson/axg.c                       |   59 +-
 drivers/clk/meson/clk-pll.c                   |  203 +-
 drivers/clk/meson/clk-pll.h                   |   10 +-
 drivers/clk/meson/clk-regmap.h                |    9 +-
 drivers/clk/meson/g12a.c                      | 2359 +++++++++++++++++
 drivers/clk/meson/g12a.h                      |  175 ++
 drivers/clk/meson/gxbb.c                      |  272 +-
 drivers/clk/meson/meson-eeclk.c               |   63 +
Quoted 9 lines
 drivers/clk/meson/meson-eeclk.h               |   25 +
 include/dt-bindings/clock/g12a-clkc.h         |  135 +
 13 files changed, 3147 insertions(+), 187 deletions(-)
 create mode 100644 drivers/clk/meson/g12a.c
 create mode 100644 drivers/clk/meson/g12a.h
 create mode 100644 drivers/clk/meson/meson-eeclk.c
 create mode 100644 drivers/clk/meson/meson-eeclk.h
 create mode 100644 include/dt-bindings/clock/g12a-clkc.h

I'm applying these to next/drivers for Linux 5.1-rc1, is it necessary to have a tag for the headers ?

Neil

maintainer
#6 lore raw
Quoted 5 lines · Neil Armstrong
Quoted 4 lines · Jerome Brunet

This purpose of this patchset is to the main clock controller of the g12a SoC family

This patchset depends on the recent rework the meson clock directory [7].

[...]

Quoted 4 lines

I'm applying these to next/drivers for Linux 5.1-rc1, is it necessary to have a tag for the headers ?

Only if we have some users that we want to merge in the v5.1 cycle (which I haven't seen yet.)

Kevin

#7 lore raw
Quoted 10 lines · Kevin Hilman
Quoted 5 lines · Neil Armstrong
Quoted 4 lines · Jerome Brunet

This purpose of this patchset is to the main clock controller of the g12a SoC family

This patchset depends on the recent rework the meson clock directory [7].

[...]

Quoted 7 lines
Quoted 4 lines

I'm applying these to next/drivers for Linux 5.1-rc1, is it necessary to have a tag for the headers ?

Only if we have some users that we want to merge in the v5.1 cycle (which I haven't seen yet.)

Same, we will wait for next cycle then.

Neil

Quoted 3 lines

Kevin