All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs
@ 2017-06-29 10:18 Marek Vasut
  2017-06-29 10:18 ` [PATCH 2/8] clk: vc5: Fix trivial typo Marek Vasut
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Stephen Boyd, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

In case the initial values of the FOD registers are not configured in
the OTP or by the bootloader, it is possible that the FOD registers
will contain zeroes. The code in vc5_fod_recalc_rate() immediately
feeds the FOD divider value obtained from the FOD registers into the
div64_u64() and if the FOD divider value is zero, triggers division
by zero exception.

Check if the FOD divider value is zero and return the frequency of
the FOD output as 0 Hz if it is so. This prevents the division by
zero exception.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/clk/clk-versaclock5.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index ea7d552a2f2b..60bf4afb51bd 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -426,6 +426,10 @@ static unsigned long vc5_fod_recalc_rate(struct clk_hw *hw,
 	div_frc = (od_frc[0] << 22) | (od_frc[1] << 14) |
 		  (od_frc[2] << 6) | (od_frc[3] >> 2);
 
+	/* Avoid division by zero if the output is not configured. */
+	if ((div_int == 0) && (div_frc == 0))
+		return 0;
+
 	/* The PLL divider has 12 integer bits and 30 fractional bits */
 	return div64_u64((u64)f_in << 24ULL, ((u64)div_int << 24ULL) + div_frc);
 }
-- 
2.11.0

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

* [PATCH 2/8] clk: vc5: Fix trivial typo
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
@ 2017-06-29 10:18 ` Marek Vasut
  2017-06-29 10:18 ` [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes Marek Vasut
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Stephen Boyd, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

Fix trivial typo in vc5_clk_out_unprepare() , s/Enable/Disable/ .

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/clk/clk-versaclock5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 60bf4afb51bd..d835d48cf14d 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -520,7 +520,7 @@ static void vc5_clk_out_unprepare(struct clk_hw *hw)
 	struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
 	struct vc5_driver_data *vc5 = hwdata->vc5;
 
-	/* Enable the clock buffer */
+	/* Disable the clock buffer */
 	regmap_update_bits(vc5->regmap, VC5_CLK_OUTPUT_CFG(hwdata->num, 1),
 			   VC5_CLK_OUTPUT_CFG1_EN_CLKBUF, 0);
 }
-- 
2.11.0

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

* [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
  2017-06-29 10:18 ` [PATCH 2/8] clk: vc5: Fix trivial typo Marek Vasut
@ 2017-06-29 10:18 ` Marek Vasut
  2017-06-30 19:26   ` Stephen Boyd
  2017-06-29 10:18 ` [PATCH 4/8] clk: vc5: Configure the output buffer input mux on prepare Marek Vasut
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Stephen Boyd, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

The output buffer input mux can be configured in either of three
states -- disabled, input from FOD, input from previous output.
If the output buffer input mux is set to disabled, the code in
vc5_clk_out_get_parent() would consider this an invalid setting
and warn about it, which is not necessarily the case.

In case the output buffer input mux is disabled, default to input
from FOD to have some parent and don't print the warning.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/clk/clk-versaclock5.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index d835d48cf14d..766fcc5cc0b3 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -541,6 +541,9 @@ static unsigned char vc5_clk_out_get_parent(struct clk_hw *hw)
 	regmap_read(vc5->regmap, VC5_OUT_DIV_CONTROL(hwdata->num), &src);
 	src &= mask;
 
+	if (src == 0)	/* Input mux set to DISABLED */
+		return 0;
+
 	if ((src & fodclkmask) == VC5_OUT_DIV_CONTROL_EN_FOD)
 		return 0;
 
@@ -549,6 +552,7 @@ static unsigned char vc5_clk_out_get_parent(struct clk_hw *hw)
 
 	dev_warn(&vc5->client->dev,
 		 "Invalid clock output configuration (%02x)\n", src);
+
 	return 0;
 }
 
-- 
2.11.0

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

* [PATCH 4/8] clk: vc5: Configure the output buffer input mux on prepare
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
  2017-06-29 10:18 ` [PATCH 2/8] clk: vc5: Fix trivial typo Marek Vasut
  2017-06-29 10:18 ` [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes Marek Vasut
@ 2017-06-29 10:18 ` Marek Vasut
  2017-06-29 10:18 ` [PATCH 5/8] clk: vc5: Split clock input mux and predivider Marek Vasut
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Stephen Boyd, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

The output buffer input mux can be configured in either of three
states -- disabled, input from FOD, input from previous output.
Once the .prepare() callback of the output buffer is called, the
output buffer input mux must be set to either input from FOD or
input from previous output, it cannot be set to Disabled anymore
or the output won't work.

Default to the input from FOD if the output buffer input mux was
Disabled and the .prepare() was called on it.

Note that we do not set the output buffer input mux back to Disabled
in the .unprepare() callback as there is no obvious benefit of doing
so. We disable the entire output buffer in the .unprepare() callback
already.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/clk/clk-versaclock5.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 766fcc5cc0b3..a5256f793627 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -507,6 +507,25 @@ static int vc5_clk_out_prepare(struct clk_hw *hw)
 {
 	struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
 	struct vc5_driver_data *vc5 = hwdata->vc5;
+	const u8 mask = VC5_OUT_DIV_CONTROL_SELB_NORM |
+			VC5_OUT_DIV_CONTROL_SEL_EXT |
+			VC5_OUT_DIV_CONTROL_EN_FOD;
+	unsigned int src;
+	int ret;
+
+	/*
+	 * If the input mux is disabled, enable it first and
+	 * select source from matching FOD.
+	 */
+	regmap_read(vc5->regmap, VC5_OUT_DIV_CONTROL(hwdata->num), &src);
+	if ((src & mask) == 0) {
+		src = VC5_OUT_DIV_CONTROL_RESET | VC5_OUT_DIV_CONTROL_EN_FOD;
+		ret = regmap_update_bits(vc5->regmap,
+					 VC5_OUT_DIV_CONTROL(hwdata->num),
+					 mask | VC5_OUT_DIV_CONTROL_RESET, src);
+		if (ret)
+			return ret;
+	}
 
 	/* Enable the clock buffer */
 	regmap_update_bits(vc5->regmap, VC5_CLK_OUTPUT_CFG(hwdata->num, 1),
-- 
2.11.0

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

* [PATCH 5/8] clk: vc5: Split clock input mux and predivider
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
                   ` (2 preceding siblings ...)
  2017-06-29 10:18 ` [PATCH 4/8] clk: vc5: Configure the output buffer input mux on prepare Marek Vasut
@ 2017-06-29 10:18 ` Marek Vasut
  2017-06-29 10:18 ` [PATCH 6/8] clk: vc5: Add support for the input frequency doubler Marek Vasut
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Stephen Boyd, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

Split the VC5 clock input mux and the predivider to more accurately
model the hardware and fix the previously incorrect assumption that
both the OUT_SEL_I2CB and the PLL are fed from the predivider.

It is in fact the clock input mux output which is directly feeding
the clock into the OUT_SEL_I2CB output, while the clock input mux
output first passes through the predivider before it is fed into
the PLL.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/clk/clk-versaclock5.c | 46 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index a5256f793627..fcde42393997 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -157,6 +157,7 @@ struct vc5_driver_data {
 	struct clk		*pin_clkin;
 	unsigned char		clk_mux_ins;
 	struct clk_hw		clk_mux;
+	struct clk_hw		clk_pfd;
 	struct vc5_hw_data	clk_pll;
 	struct vc5_hw_data	clk_fod[VC5_MAX_FOD_NUM];
 	struct vc5_hw_data	clk_out[VC5_MAX_CLK_OUT_NUM];
@@ -166,6 +167,10 @@ static const char * const vc5_mux_names[] = {
 	"mux"
 };
 
+static const char * const vc5_pfd_names[] = {
+	"pfd"
+};
+
 static const char * const vc5_pll_names[] = {
 	"pll"
 };
@@ -254,11 +259,16 @@ static int vc5_mux_set_parent(struct clk_hw *hw, u8 index)
 	return regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN, mask, src);
 }
 
-static unsigned long vc5_mux_recalc_rate(struct clk_hw *hw,
+static const struct clk_ops vc5_mux_ops = {
+	.set_parent	= vc5_mux_set_parent,
+	.get_parent	= vc5_mux_get_parent,
+};
+
+static unsigned long vc5_pfd_recalc_rate(struct clk_hw *hw,
 					 unsigned long parent_rate)
 {
 	struct vc5_driver_data *vc5 =
-		container_of(hw, struct vc5_driver_data, clk_mux);
+		container_of(hw, struct vc5_driver_data, clk_pfd);
 	unsigned int prediv, div;
 
 	regmap_read(vc5->regmap, VC5_VCO_CTRL_AND_PREDIV, &prediv);
@@ -276,7 +286,7 @@ static unsigned long vc5_mux_recalc_rate(struct clk_hw *hw,
 		return parent_rate / VC5_REF_DIVIDER_REF_DIV(div);
 }
 
-static long vc5_mux_round_rate(struct clk_hw *hw, unsigned long rate,
+static long vc5_pfd_round_rate(struct clk_hw *hw, unsigned long rate,
 			       unsigned long *parent_rate)
 {
 	unsigned long idiv;
@@ -296,11 +306,11 @@ static long vc5_mux_round_rate(struct clk_hw *hw, unsigned long rate,
 	return *parent_rate / idiv;
 }
 
-static int vc5_mux_set_rate(struct clk_hw *hw, unsigned long rate,
+static int vc5_pfd_set_rate(struct clk_hw *hw, unsigned long rate,
 			    unsigned long parent_rate)
 {
 	struct vc5_driver_data *vc5 =
-		container_of(hw, struct vc5_driver_data, clk_mux);
+		container_of(hw, struct vc5_driver_data, clk_pfd);
 	unsigned long idiv;
 	u8 div;
 
@@ -328,12 +338,10 @@ static int vc5_mux_set_rate(struct clk_hw *hw, unsigned long rate,
 	return 0;
 }
 
-static const struct clk_ops vc5_mux_ops = {
-	.set_parent	= vc5_mux_set_parent,
-	.get_parent	= vc5_mux_get_parent,
-	.recalc_rate	= vc5_mux_recalc_rate,
-	.round_rate	= vc5_mux_round_rate,
-	.set_rate	= vc5_mux_set_rate,
+static const struct clk_ops vc5_pfd_ops = {
+	.recalc_rate	= vc5_pfd_recalc_rate,
+	.round_rate	= vc5_pfd_round_rate,
+	.set_rate	= vc5_pfd_set_rate,
 };
 
 /*
@@ -699,12 +707,26 @@ static int vc5_probe(struct i2c_client *client,
 		goto err_clk;
 	}
 
+	/* Register PFD */
+	memset(&init, 0, sizeof(init));
+	init.name = vc5_pfd_names[0];
+	init.ops = &vc5_pfd_ops;
+	init.flags = CLK_SET_RATE_PARENT;
+	init.parent_names = vc5_mux_names;
+	init.num_parents = 1;
+	vc5->clk_pfd.init = &init;
+	ret = devm_clk_hw_register(&client->dev, &vc5->clk_pfd);
+	if (ret) {
+		dev_err(&client->dev, "unable to register %s\n", init.name);
+		goto err_clk;
+	}
+
 	/* Register PLL */
 	memset(&init, 0, sizeof(init));
 	init.name = vc5_pll_names[0];
 	init.ops = &vc5_pll_ops;
 	init.flags = CLK_SET_RATE_PARENT;
-	init.parent_names = vc5_mux_names;
+	init.parent_names = vc5_pfd_names;
 	init.num_parents = 1;
 	vc5->clk_pll.num = 0;
 	vc5->clk_pll.vc5 = vc5;
-- 
2.11.0

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

* [PATCH 6/8] clk: vc5: Add support for the input frequency doubler
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
                   ` (3 preceding siblings ...)
  2017-06-29 10:18 ` [PATCH 5/8] clk: vc5: Split clock input mux and predivider Marek Vasut
@ 2017-06-29 10:18 ` Marek Vasut
  2017-06-29 10:18 ` [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901 Marek Vasut
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Stephen Boyd, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

The VersaClock 6 has an input frequency doubler between the input
clock mux and the predivider. Add new capability flag and support
for this frequency doubler block into the driver.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/clk/clk-versaclock5.c | 78 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index fcde42393997..6db84358520a 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -57,6 +57,7 @@
 #define VC5_PRIM_SRC_SHDN			0x10
 #define VC5_PRIM_SRC_SHDN_EN_XTAL		BIT(7)
 #define VC5_PRIM_SRC_SHDN_EN_CLKIN		BIT(6)
+#define VC5_PRIM_SRC_SHDN_EN_DOUBLE_XTAL_FREQ	BIT(3)
 #define VC5_PRIM_SRC_SHDN_SP			BIT(1)
 #define VC5_PRIM_SRC_SHDN_EN_GBL_SHDN		BIT(0)
 
@@ -122,6 +123,8 @@
 /* flags to describe chip features */
 /* chip has built-in oscilator */
 #define VC5_HAS_INTERNAL_XTAL	BIT(0)
+/* chip has PFD requency doubler */
+#define VC5_HAS_PFD_FREQ_DBL	BIT(1)
 
 /* Supported IDT VC5 models. */
 enum vc5_model {
@@ -157,6 +160,7 @@ struct vc5_driver_data {
 	struct clk		*pin_clkin;
 	unsigned char		clk_mux_ins;
 	struct clk_hw		clk_mux;
+	struct clk_hw		clk_mul;
 	struct clk_hw		clk_pfd;
 	struct vc5_hw_data	clk_pll;
 	struct vc5_hw_data	clk_fod[VC5_MAX_FOD_NUM];
@@ -167,6 +171,10 @@ static const char * const vc5_mux_names[] = {
 	"mux"
 };
 
+static const char * const vc5_dbl_names[] = {
+	"dbl"
+};
+
 static const char * const vc5_pfd_names[] = {
 	"pfd"
 };
@@ -264,6 +272,54 @@ static const struct clk_ops vc5_mux_ops = {
 	.get_parent	= vc5_mux_get_parent,
 };
 
+static unsigned long vc5_dbl_recalc_rate(struct clk_hw *hw,
+					 unsigned long parent_rate)
+{
+	struct vc5_driver_data *vc5 =
+		container_of(hw, struct vc5_driver_data, clk_mul);
+	unsigned int premul;
+
+	regmap_read(vc5->regmap, VC5_PRIM_SRC_SHDN, &premul);
+	if (premul & VC5_PRIM_SRC_SHDN_EN_DOUBLE_XTAL_FREQ)
+		parent_rate *= 2;
+
+	return parent_rate;
+}
+
+static long vc5_dbl_round_rate(struct clk_hw *hw, unsigned long rate,
+			       unsigned long *parent_rate)
+{
+	if ((*parent_rate == rate) || ((*parent_rate * 2) == rate))
+		return rate;
+	else
+		return -EINVAL;
+}
+
+static int vc5_dbl_set_rate(struct clk_hw *hw, unsigned long rate,
+			    unsigned long parent_rate)
+{
+	struct vc5_driver_data *vc5 =
+		container_of(hw, struct vc5_driver_data, clk_mul);
+	u32 mask;
+
+	if ((parent_rate * 2) == rate)
+		mask = VC5_PRIM_SRC_SHDN_EN_DOUBLE_XTAL_FREQ;
+	else
+		mask = 0;
+
+	regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN,
+			   VC5_PRIM_SRC_SHDN_EN_DOUBLE_XTAL_FREQ,
+			   mask);
+
+	return 0;
+}
+
+static const struct clk_ops vc5_dbl_ops = {
+	.recalc_rate	= vc5_dbl_recalc_rate,
+	.round_rate	= vc5_dbl_round_rate,
+	.set_rate	= vc5_dbl_set_rate,
+};
+
 static unsigned long vc5_pfd_recalc_rate(struct clk_hw *hw,
 					 unsigned long parent_rate)
 {
@@ -707,12 +763,32 @@ static int vc5_probe(struct i2c_client *client,
 		goto err_clk;
 	}
 
+	if (vc5->chip_info->flags & VC5_HAS_PFD_FREQ_DBL) {
+		/* Register frequency doubler */
+		memset(&init, 0, sizeof(init));
+		init.name = vc5_dbl_names[0];
+		init.ops = &vc5_dbl_ops;
+		init.flags = CLK_SET_RATE_PARENT;
+		init.parent_names = vc5_mux_names;
+		init.num_parents = 1;
+		vc5->clk_mul.init = &init;
+		ret = devm_clk_hw_register(&client->dev, &vc5->clk_mul);
+		if (ret) {
+			dev_err(&client->dev, "unable to register %s\n",
+				init.name);
+			goto err_clk;
+		}
+	}
+
 	/* Register PFD */
 	memset(&init, 0, sizeof(init));
 	init.name = vc5_pfd_names[0];
 	init.ops = &vc5_pfd_ops;
 	init.flags = CLK_SET_RATE_PARENT;
-	init.parent_names = vc5_mux_names;
+	if (vc5->chip_info->flags & VC5_HAS_PFD_FREQ_DBL)
+		init.parent_names = vc5_dbl_names;
+	else
+		init.parent_names = vc5_mux_names;
 	init.num_parents = 1;
 	vc5->clk_pfd.init = &init;
 	ret = devm_clk_hw_register(&client->dev, &vc5->clk_pfd);
-- 
2.11.0

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

* [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
                   ` (4 preceding siblings ...)
  2017-06-29 10:18 ` [PATCH 6/8] clk: vc5: Add support for the input frequency doubler Marek Vasut
@ 2017-06-29 10:18 ` Marek Vasut
  2017-06-29 11:38   ` Geert Uytterhoeven
  2017-06-29 10:18 ` [PATCH 8/8] clk: vc5: Add support " Marek Vasut
  2017-06-29 10:26 ` [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Laurent Pinchart
  7 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Alexey Firago, Rob Herring, Stephen Boyd,
	Michael Turquette, Laurent Pinchart, linux-renesas-soc,
	devicetree

From: Marek Vasut <marek.vasut+renesas@gmail.com>

IDT VersaClock 6 5P49V6901 has 4 clock outputs, 4 fractional dividers.
Input clock source can be taken from either external crystal or from
external reference clock.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
Cc: devicetree@vger.kernel.org
---
 .../devicetree/bindings/clock/idt,versaclock5.txt         | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
index 53d7e50ed875..a3d4260039a8 100644
--- a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
+++ b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
@@ -7,18 +7,20 @@ from 3 to 12 output clocks.
 
 Required properties:
 - compatible:	shall be one of "idt,5p49v5923" , "idt,5p49v5933" ,
-		"idt,5p49v5935".
+		"idt,5p49v5935" , "idt,5p49v6901".
 - reg:		i2c device address, shall be 0x68 or 0x6a.
 - #clock-cells:	from common clock binding; shall be set to 1.
 - clocks:	from common clock binding; list of parent clock handles,
-		- 5p49v5923: (required) either or both of XTAL or CLKIN
+		- 5p49v5923 and
+		  5p49v6901: (required) either or both of XTAL or CLKIN
 					reference clock.
 		- 5p49v5933 and
 		- 5p49v5935: (optional) property not present (internal
 					Xtal used) or CLKIN reference
 					clock.
 - clock-names:	from common clock binding; clock input names, can be
-		- 5p49v5923: (required) either or both of "xin", "clkin".
+		- 5p49v5923 and
+		  5p49v6901: (required) either or both of "xin", "clkin".
 		- 5p49v5933 and
 		- 5p49v5935: (optional) property not present or "clkin".
 
@@ -44,6 +46,13 @@ clock specifier, the following mapping applies:
 	3 -- OUT3
 	4 -- OUT4
 
+5P49V6901:
+	0 -- OUT0_SEL_I2CB
+	1 -- OUT1
+	2 -- OUT2
+	3 -- OUT3
+	4 -- OUT4
+
 ==Example==
 
 /* 25MHz reference crystal */
-- 
2.11.0

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

* [PATCH 8/8] clk: vc5: Add support for IDT VersaClock 5P49V6901
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
                   ` (5 preceding siblings ...)
  2017-06-29 10:18 ` [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901 Marek Vasut
@ 2017-06-29 10:18 ` Marek Vasut
  2017-06-29 11:41   ` Geert Uytterhoeven
  2017-06-29 10:26 ` [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Laurent Pinchart
  7 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 10:18 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Alexey Firago, Stephen Boyd, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

From: Marek Vasut <marek.vasut+renesas@gmail.com>

Update IDT VersaClock 6 driver to support 5P49V6901. This chip has
two clock inputs (external XTAL or external CLKIN), four fractional
dividers (FODs) and five clock outputs (four universal clock outputs
and one reference clock output at OUT0_SELB_I2C).

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
---
 drivers/clk/clk-versaclock5.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 6db84358520a..6e3166e00c8e 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -131,6 +131,7 @@ enum vc5_model {
 	IDT_VC5_5P49V5923,
 	IDT_VC5_5P49V5933,
 	IDT_VC5_5P49V5935,
+	IDT_VC6_5P49V6901,
 };
 
 /* Structure to describe features of a particular VC5 model */
@@ -687,6 +688,7 @@ static int vc5_map_index_to_output(const enum vc5_model model,
 		return (n == 0) ? 0 : 3;
 	case IDT_VC5_5P49V5923:
 	case IDT_VC5_5P49V5935:
+	case IDT_VC6_5P49V6901:
 	default:
 		return n;
 	}
@@ -924,10 +926,18 @@ static const struct vc5_chip_info idt_5p49v5935_info = {
 	.flags = VC5_HAS_INTERNAL_XTAL,
 };
 
+static const struct vc5_chip_info idt_5p49v6901_info = {
+	.model = IDT_VC6_5P49V6901,
+	.clk_fod_cnt = 4,
+	.clk_out_cnt = 5,
+	.flags = VC5_HAS_PFD_FREQ_DBL,
+};
+
 static const struct i2c_device_id vc5_id[] = {
 	{ "5p49v5923", .driver_data = IDT_VC5_5P49V5923 },
 	{ "5p49v5933", .driver_data = IDT_VC5_5P49V5933 },
 	{ "5p49v5935", .driver_data = IDT_VC5_5P49V5935 },
+	{ "5p49v6901", .driver_data = IDT_VC6_5P49V6901 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, vc5_id);
@@ -936,6 +946,7 @@ static const struct of_device_id clk_vc5_of_match[] = {
 	{ .compatible = "idt,5p49v5923", .data = &idt_5p49v5923_info },
 	{ .compatible = "idt,5p49v5933", .data = &idt_5p49v5933_info },
 	{ .compatible = "idt,5p49v5935", .data = &idt_5p49v5935_info },
+	{ .compatible = "idt,5p49v6901", .data = &idt_5p49v6901_info },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, clk_vc5_of_match);
-- 
2.11.0

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

* Re: [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs
  2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
                   ` (6 preceding siblings ...)
  2017-06-29 10:18 ` [PATCH 8/8] clk: vc5: Add support " Marek Vasut
@ 2017-06-29 10:26 ` Laurent Pinchart
  7 siblings, 0 replies; 17+ messages in thread
From: Laurent Pinchart @ 2017-06-29 10:26 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-clk, Marek Vasut, Stephen Boyd, Alexey Firago,
	Michael Turquette, linux-renesas-soc

Hi Marek,

Thank you for the patches.

On Thursday 29 Jun 2017 12:18:44 Marek Vasut wrote:
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
> 
> In case the initial values of the FOD registers are not configured in
> the OTP or by the bootloader, it is possible that the FOD registers
> will contain zeroes. The code in vc5_fod_recalc_rate() immediately
> feeds the FOD divider value obtained from the FOD registers into the
> div64_u64() and if the FOD divider value is zero, triggers division
> by zero exception.
> 
> Check if the FOD divider value is zero and return the frequency of
> the FOD output as 0 Hz if it is so. This prevents the division by
> zero exception.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Alexey Firago <alexey_firago@mentor.com>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: linux-renesas-soc@vger.kernel.org

For the whole series,

Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

on Salvator-XS with the display LVDS output.

> ---
>  drivers/clk/clk-versaclock5.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
> index ea7d552a2f2b..60bf4afb51bd 100644
> --- a/drivers/clk/clk-versaclock5.c
> +++ b/drivers/clk/clk-versaclock5.c
> @@ -426,6 +426,10 @@ static unsigned long vc5_fod_recalc_rate(struct clk_hw
> *hw, div_frc = (od_frc[0] << 22) | (od_frc[1] << 14) |
>  		  (od_frc[2] << 6) | (od_frc[3] >> 2);
> 
> +	/* Avoid division by zero if the output is not configured. */
> +	if ((div_int == 0) && (div_frc == 0))
> +		return 0;
> +
>  	/* The PLL divider has 12 integer bits and 30 fractional bits */
>  	return div64_u64((u64)f_in << 24ULL, ((u64)div_int << 24ULL) + 
div_frc);
>  }

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901
  2017-06-29 10:18 ` [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901 Marek Vasut
@ 2017-06-29 11:38   ` Geert Uytterhoeven
  2017-06-29 15:49     ` Marek Vasut
  0 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2017-06-29 11:38 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-clk, Marek Vasut, Alexey Firago, Rob Herring, Stephen Boyd,
	Michael Turquette, Laurent Pinchart, Linux-Renesas, devicetree

Hi Marek,

On Thu, Jun 29, 2017 at 12:18 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> IDT VersaClock 6 5P49V6901 has 4 clock outputs, 4 fractional dividers.
> Input clock source can be taken from either external crystal or from
> external reference clock.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Alexey Firago <alexey_firago@mentor.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: linux-renesas-soc@vger.kernel.org
> Cc: devicetree@vger.kernel.org
> ---
>  .../devicetree/bindings/clock/idt,versaclock5.txt         | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
> index 53d7e50ed875..a3d4260039a8 100644
> --- a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
> +++ b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt

Probably you want to sprinkle the first few lines of the document with
a few "VersaClock 6" references?

> @@ -7,18 +7,20 @@ from 3 to 12 output clocks.

The rest looks OK to me, so
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 8/8] clk: vc5: Add support for IDT VersaClock 5P49V6901
  2017-06-29 10:18 ` [PATCH 8/8] clk: vc5: Add support " Marek Vasut
@ 2017-06-29 11:41   ` Geert Uytterhoeven
  2017-06-29 15:54     ` Marek Vasut
  0 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2017-06-29 11:41 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-clk, Marek Vasut, Alexey Firago, Stephen Boyd,
	Michael Turquette, Laurent Pinchart, Linux-Renesas

Hi Marek,

On Thu, Jun 29, 2017 at 12:18 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> Update IDT VersaClock 6 driver to support 5P49V6901. This chip has

Update the IDT VersaClock5 driver to support the VersaClock6 5P49V6901?

> two clock inputs (external XTAL or external CLKIN), four fractional
> dividers (FODs) and five clock outputs (four universal clock outputs
> and one reference clock output at OUT0_SELB_I2C).
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Alexey Firago <alexey_firago@mentor.com>
> Cc: Stephen Boyd <sboyd@codeaurora.org>
> Cc: Michael Turquette <mturquette@baylibre.com>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: linux-renesas-soc@vger.kernel.org
> ---
>  drivers/clk/clk-versaclock5.c | 11 +++++++++++

and

--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -210,14 +210,14 @@ config COMMON_CLK_OXNAS
          Support for the OXNAS SoC Family clocks.

 config COMMON_CLK_VC5
-       tristate "Clock driver for IDT VersaClock5 devices"
+       tristate "Clock driver for IDT VersaClock5/6 devices"
        depends on I2C
        depends on OF
        select REGMAP_I2C
        help
        ---help---
-         This driver supports the IDT VersaClock5 programmable clock
-         generator.
+         This driver supports the IDT VersaClock5 and VersaClock6
+         programmable clock generator.

 source "drivers/clk/bcm/Kconfig"
 source "drivers/clk/hisilicon/Kconfig"

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901
  2017-06-29 11:38   ` Geert Uytterhoeven
@ 2017-06-29 15:49     ` Marek Vasut
  2017-06-29 16:27       ` Geert Uytterhoeven
  0 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 15:49 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-clk, Marek Vasut, Alexey Firago, Rob Herring, Stephen Boyd,
	Michael Turquette, Laurent Pinchart, Linux-Renesas, devicetree

On 06/29/2017 01:38 PM, Geert Uytterhoeven wrote:
> Hi Marek,
> 
> On Thu, Jun 29, 2017 at 12:18 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>
>> IDT VersaClock 6 5P49V6901 has 4 clock outputs, 4 fractional dividers.
>> Input clock source can be taken from either external crystal or from
>> external reference clock.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Alexey Firago <alexey_firago@mentor.com>
>> Cc: Rob Herring <robh@kernel.org>
>> Cc: Stephen Boyd <sboyd@codeaurora.org>
>> Cc: Michael Turquette <mturquette@baylibre.com>
>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Cc: linux-renesas-soc@vger.kernel.org
>> Cc: devicetree@vger.kernel.org
>> ---
>>  .../devicetree/bindings/clock/idt,versaclock5.txt         | 15 ++++++++++++---
>>  1 file changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
>> index 53d7e50ed875..a3d4260039a8 100644
>> --- a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
>> +++ b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
> 
> Probably you want to sprinkle the first few lines of the document with
> a few "VersaClock 6" references?

Something like this?

--- a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
+++ b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
@@ -1,7 +1,7 @@
-Binding for IDT VersaClock5 programmable i2c clock generator.
+Binding for IDT VersaClock 5,6 programmable i2c clock generators.

-The IDT VersaClock5 are programmable i2c clock generators providing
-from 3 to 12 output clocks.
+The IDT VersaClock 5 and VersaClock 6 are programmable i2c clock
+generators providing from 3 to 12 output clocks.

 ==I2C device node==

>> @@ -7,18 +7,20 @@ from 3 to 12 output clocks.
> 
> The rest looks OK to me, so
> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks

-- 
Best regards,
Marek Vasut

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

* Re: [PATCH 8/8] clk: vc5: Add support for IDT VersaClock 5P49V6901
  2017-06-29 11:41   ` Geert Uytterhoeven
@ 2017-06-29 15:54     ` Marek Vasut
  0 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2017-06-29 15:54 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-clk, Marek Vasut, Alexey Firago, Stephen Boyd,
	Michael Turquette, Laurent Pinchart, Linux-Renesas

On 06/29/2017 01:41 PM, Geert Uytterhoeven wrote:
> Hi Marek,
> 
> On Thu, Jun 29, 2017 at 12:18 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>
>> Update IDT VersaClock 6 driver to support 5P49V6901. This chip has
> 
> Update the IDT VersaClock5 driver to support the VersaClock6 5P49V6901?
> 
>> two clock inputs (external XTAL or external CLKIN), four fractional
>> dividers (FODs) and five clock outputs (four universal clock outputs
>> and one reference clock output at OUT0_SELB_I2C).
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Alexey Firago <alexey_firago@mentor.com>
>> Cc: Stephen Boyd <sboyd@codeaurora.org>
>> Cc: Michael Turquette <mturquette@baylibre.com>
>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Cc: linux-renesas-soc@vger.kernel.org
>> ---
>>  drivers/clk/clk-versaclock5.c | 11 +++++++++++
> 
> and
> 
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -210,14 +210,14 @@ config COMMON_CLK_OXNAS
>           Support for the OXNAS SoC Family clocks.
> 
>  config COMMON_CLK_VC5
> -       tristate "Clock driver for IDT VersaClock5 devices"
> +       tristate "Clock driver for IDT VersaClock5/6 devices"
>         depends on I2C
>         depends on OF
>         select REGMAP_I2C
>         help
>         ---help---
> -         This driver supports the IDT VersaClock5 programmable clock
> -         generator.
> +         This driver supports the IDT VersaClock5 and VersaClock6
> +         programmable clock generator.

Tweaked a bit more, but yes, good point.

-- 
Best regards,
Marek Vasut

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

* Re: [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901
  2017-06-29 15:49     ` Marek Vasut
@ 2017-06-29 16:27       ` Geert Uytterhoeven
  0 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2017-06-29 16:27 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-clk, Marek Vasut, Alexey Firago, Rob Herring, Stephen Boyd,
	Michael Turquette, Laurent Pinchart, Linux-Renesas, devicetree

Hi Marek,

On Thu, Jun 29, 2017 at 5:49 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> On 06/29/2017 01:38 PM, Geert Uytterhoeven wrote:
>> On Thu, Jun 29, 2017 at 12:18 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
>>> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>>>
>>> IDT VersaClock 6 5P49V6901 has 4 clock outputs, 4 fractional dividers.
>>> Input clock source can be taken from either external crystal or from
>>> external reference clock.
>>>
>>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>

>>> --- a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
>>> +++ b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
>>
>> Probably you want to sprinkle the first few lines of the document with
>> a few "VersaClock 6" references?
>
> Something like this?
>
> --- a/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
> +++ b/Documentation/devicetree/bindings/clock/idt,versaclock5.txt
> @@ -1,7 +1,7 @@
> -Binding for IDT VersaClock5 programmable i2c clock generator.
> +Binding for IDT VersaClock 5,6 programmable i2c clock generators.
>
> -The IDT VersaClock5 are programmable i2c clock generators providing
> -from 3 to 12 output clocks.
> +The IDT VersaClock 5 and VersaClock 6 are programmable i2c clock
> +generators providing from 3 to 12 output clocks.
>
>  ==I2C device node==

Exactly. Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes
  2017-06-29 10:18 ` [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes Marek Vasut
@ 2017-06-30 19:26   ` Stephen Boyd
  2017-07-01 20:00     ` Marek Vasut
  0 siblings, 1 reply; 17+ messages in thread
From: Stephen Boyd @ 2017-06-30 19:26 UTC (permalink / raw)
  To: Marek Vasut
  Cc: linux-clk, Marek Vasut, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

On 06/29, Marek Vasut wrote:
> @@ -549,6 +552,7 @@ static unsigned char vc5_clk_out_get_parent(struct clk_hw *hw)
>  
>  	dev_warn(&vc5->client->dev,
>  		 "Invalid clock output configuration (%02x)\n", src);
> +
>  	return 0;
>  }
>  

Please drop this hunk as it isn't relevant to the patch.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes
  2017-06-30 19:26   ` Stephen Boyd
@ 2017-07-01 20:00     ` Marek Vasut
  0 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2017-07-01 20:00 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-clk, Marek Vasut, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

On 06/30/2017 09:26 PM, Stephen Boyd wrote:
> On 06/29, Marek Vasut wrote:
>> @@ -549,6 +552,7 @@ static unsigned char vc5_clk_out_get_parent(struct clk_hw *hw)
>>  
>>  	dev_warn(&vc5->client->dev,
>>  		 "Invalid clock output configuration (%02x)\n", src);
>> +
>>  	return 0;
>>  }
>>  
> 
> Please drop this hunk as it isn't relevant to the patch.
> 
Done in V2, thanks.

-- 
Best regards,
Marek Vasut

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

* [PATCH 4/8] clk: vc5: Configure the output buffer input mux on prepare
  2017-07-01 20:04 Marek Vasut
@ 2017-07-01 20:04 ` Marek Vasut
  0 siblings, 0 replies; 17+ messages in thread
From: Marek Vasut @ 2017-07-01 20:04 UTC (permalink / raw)
  To: linux-clk
  Cc: Marek Vasut, Stephen Boyd, Alexey Firago, Michael Turquette,
	Laurent Pinchart, linux-renesas-soc

The output buffer input mux can be configured in either of three
states -- disabled, input from FOD, input from previous output.
Once the .prepare() callback of the output buffer is called, the
output buffer input mux must be set to either input from FOD or
input from previous output, it cannot be set to Disabled anymore
or the output won't work.

Default to the input from FOD if the output buffer input mux was
Disabled and the .prepare() was called on it.

Note that we do not set the output buffer input mux back to Disabled
in the .unprepare() callback as there is no obvious benefit of doing
so. We disable the entire output buffer in the .unprepare() callback
already.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexey Firago <alexey_firago@mentor.com>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
on Salvator-XS with the display LVDS output.
---
 drivers/clk/clk-versaclock5.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 248689d89632..7bdfd34e8280 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -507,6 +507,25 @@ static int vc5_clk_out_prepare(struct clk_hw *hw)
 {
 	struct vc5_hw_data *hwdata = container_of(hw, struct vc5_hw_data, hw);
 	struct vc5_driver_data *vc5 = hwdata->vc5;
+	const u8 mask = VC5_OUT_DIV_CONTROL_SELB_NORM |
+			VC5_OUT_DIV_CONTROL_SEL_EXT |
+			VC5_OUT_DIV_CONTROL_EN_FOD;
+	unsigned int src;
+	int ret;
+
+	/*
+	 * If the input mux is disabled, enable it first and
+	 * select source from matching FOD.
+	 */
+	regmap_read(vc5->regmap, VC5_OUT_DIV_CONTROL(hwdata->num), &src);
+	if ((src & mask) == 0) {
+		src = VC5_OUT_DIV_CONTROL_RESET | VC5_OUT_DIV_CONTROL_EN_FOD;
+		ret = regmap_update_bits(vc5->regmap,
+					 VC5_OUT_DIV_CONTROL(hwdata->num),
+					 mask | VC5_OUT_DIV_CONTROL_RESET, src);
+		if (ret)
+			return ret;
+	}
 
 	/* Enable the clock buffer */
 	regmap_update_bits(vc5->regmap, VC5_CLK_OUTPUT_CFG(hwdata->num, 1),
-- 
2.11.0

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

end of thread, other threads:[~2017-07-01 20:05 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 10:18 [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Marek Vasut
2017-06-29 10:18 ` [PATCH 2/8] clk: vc5: Fix trivial typo Marek Vasut
2017-06-29 10:18 ` [PATCH 3/8] clk: vc5: Do not warn about disabled output buffer input muxes Marek Vasut
2017-06-30 19:26   ` Stephen Boyd
2017-07-01 20:00     ` Marek Vasut
2017-06-29 10:18 ` [PATCH 4/8] clk: vc5: Configure the output buffer input mux on prepare Marek Vasut
2017-06-29 10:18 ` [PATCH 5/8] clk: vc5: Split clock input mux and predivider Marek Vasut
2017-06-29 10:18 ` [PATCH 6/8] clk: vc5: Add support for the input frequency doubler Marek Vasut
2017-06-29 10:18 ` [PATCH 7/8] clk: vc5: Add bindings for IDT VersaClock 5P49V6901 Marek Vasut
2017-06-29 11:38   ` Geert Uytterhoeven
2017-06-29 15:49     ` Marek Vasut
2017-06-29 16:27       ` Geert Uytterhoeven
2017-06-29 10:18 ` [PATCH 8/8] clk: vc5: Add support " Marek Vasut
2017-06-29 11:41   ` Geert Uytterhoeven
2017-06-29 15:54     ` Marek Vasut
2017-06-29 10:26 ` [PATCH 1/8] clk: vc5: Prevent division by zero on unconfigured outputs Laurent Pinchart
2017-07-01 20:04 Marek Vasut
2017-07-01 20:04 ` [PATCH 4/8] clk: vc5: Configure the output buffer input mux on prepare Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.