linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] clk: cs2000: add AUX_OUT pin support
@ 2017-04-11  0:34 Kuninori Morimoto
  2017-04-11  0:35 ` [PATCH 1/2] clk: cs2000: use existing priv_to_dev() to getting struct device Kuninori Morimoto
  2017-04-11  0:36 ` [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support Kuninori Morimoto
  0 siblings, 2 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2017-04-11  0:34 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-renesas-soc, linux-kernel, linux-clk


Hi Stephen

These adds AUX_OUT support to cs2000 driver.
1st patch is just cleanup patch.

Kuninori Morimoto (2):
  clk: cs2000: use existing priv_to_dev() to getting struct device
  clk: cs2000: add AUX_OUT pin select support

 .../devicetree/bindings/clock/cs2000-cp.txt        |  9 +++
 drivers/clk/clk-cs2000-cp.c                        | 81 ++++++++++++++++++++--
 2 files changed, 83 insertions(+), 7 deletions(-)

-- 
1.9.1

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

* [PATCH 1/2] clk: cs2000: use existing priv_to_dev() to getting struct device
  2017-04-11  0:34 [PATCH 0/2] clk: cs2000: add AUX_OUT pin support Kuninori Morimoto
@ 2017-04-11  0:35 ` Kuninori Morimoto
  2017-04-12 15:14   ` Stephen Boyd
  2017-04-11  0:36 ` [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support Kuninori Morimoto
  1 sibling, 1 reply; 6+ messages in thread
From: Kuninori Morimoto @ 2017-04-11  0:35 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-renesas-soc, linux-kernel, linux-clk

From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 drivers/clk/clk-cs2000-cp.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-cs2000-cp.c b/drivers/clk/clk-cs2000-cp.c
index f5915ff..4df38c5 100644
--- a/drivers/clk/clk-cs2000-cp.c
+++ b/drivers/clk/clk-cs2000-cp.c
@@ -370,8 +370,7 @@ static u8 cs2000_get_parent(struct clk_hw *hw)
 
 static int cs2000_clk_get(struct cs2000_priv *priv)
 {
-	struct i2c_client *client = priv_to_client(priv);
-	struct device *dev = &client->dev;
+	struct device *dev = priv_to_dev(priv);
 	struct clk *clk_in, *ref_clk;
 
 	clk_in = devm_clk_get(dev, "clk_in");
@@ -439,8 +438,7 @@ static int cs2000_clk_register(struct cs2000_priv *priv)
 
 static int cs2000_version_print(struct cs2000_priv *priv)
 {
-	struct i2c_client *client = priv_to_client(priv);
-	struct device *dev = &client->dev;
+	struct device *dev = priv_to_dev(priv);
 	s32 val;
 	const char *revision;
 
@@ -471,7 +469,7 @@ static int cs2000_version_print(struct cs2000_priv *priv)
 static int cs2000_remove(struct i2c_client *client)
 {
 	struct cs2000_priv *priv = i2c_get_clientdata(client);
-	struct device *dev = &client->dev;
+	struct device *dev = priv_to_dev(priv);
 	struct device_node *np = dev->of_node;
 
 	of_clk_del_provider(np);
-- 
1.9.1

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

* [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support
  2017-04-11  0:34 [PATCH 0/2] clk: cs2000: add AUX_OUT pin support Kuninori Morimoto
  2017-04-11  0:35 ` [PATCH 1/2] clk: cs2000: use existing priv_to_dev() to getting struct device Kuninori Morimoto
@ 2017-04-11  0:36 ` Kuninori Morimoto
  2017-04-11  8:35   ` Geert Uytterhoeven
  1 sibling, 1 reply; 6+ messages in thread
From: Kuninori Morimoto @ 2017-04-11  0:36 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-renesas-soc, linux-kernel, linux-clk


From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
---
 .../devicetree/bindings/clock/cs2000-cp.txt        |  9 +++
 drivers/clk/clk-cs2000-cp.c                        | 73 +++++++++++++++++++++-
 2 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/cs2000-cp.txt b/Documentation/devicetree/bindings/clock/cs2000-cp.txt
index 54e6df0..4c2f9cb 100644
--- a/Documentation/devicetree/bindings/clock/cs2000-cp.txt
+++ b/Documentation/devicetree/bindings/clock/cs2000-cp.txt
@@ -8,6 +8,15 @@ Required properties:
 - clock-names:		CLK_IN : clk_in, XTI/REF_CLK : ref_clk
 - #clock-cells:		must be <0>
 
+Option properties:
+
+- auxoutsrc:		select AUX_OUT source from these.
+				refclk:		Timing Reference Clock
+				clk_in:		Frequency Reference Clock
+				pllclkout:	PLL Clock Output
+				push-pull:	PLL Lock/Unlock Indication
+				open-drain:	PLL Lock/Unlock Indication
+
 Example:
 
 &i2c2 {
diff --git a/drivers/clk/clk-cs2000-cp.c b/drivers/clk/clk-cs2000-cp.c
index 4df38c5..234e3b4 100644
--- a/drivers/clk/clk-cs2000-cp.c
+++ b/drivers/clk/clk-cs2000-cp.c
@@ -42,6 +42,8 @@
 /* DEVICE_CFG1 */
 #define RSEL(x)		(((x) & 0x3) << 3)
 #define RSEL_MASK	RSEL(0x3)
+#define AUXOUTSRC(x)	(((x) & 0x3) << 1)
+#define AUXOUTSRC_MASK	AUXOUTSRC(0x3)
 #define ENDEV1		(0x1)
 
 /* DEVICE_CFG2 */
@@ -54,6 +56,8 @@
 #define ENDEV2		(0x1)
 
 /* FUNC_CFG1 */
+#define AUXLOCKCFG(x)	(((x) & 0x1) << 6)
+#define AUXLOCKCFG_MASK	AUXLOCKCFG(1)
 #define REFCLKDIV(x)	(((x) & 0x3) << 3)
 #define REFCLKDIV_MASK	REFCLKDIV(0x3)
 
@@ -66,11 +70,20 @@
 #define REF_CLK	1
 #define CLK_MAX 2
 
+enum auxoutsrc {
+	AUXSRC_REFCLK = 0,
+	AUXSRC_CLKIN,
+	AUXSRC_PLLCLKOUT,
+	AUXSRC_PUSHPULL,
+	AUXSRC_OPENDRAIN,
+};
+
 struct cs2000_priv {
 	struct clk_hw hw;
 	struct i2c_client *client;
 	struct clk *clk_in;
 	struct clk *ref_clk;
+	enum auxoutsrc auxoutsrc;
 
 	/* suspend/resume */
 	unsigned long saved_rate;
@@ -111,9 +124,27 @@ static int cs2000_bset(struct cs2000_priv *priv, u8 addr, u8 mask, u8 val)
 static int cs2000_enable_dev_config(struct cs2000_priv *priv, bool enable)
 {
 	int ret;
+	u8 dcfg1, fcfg1;
+
+	dcfg1 = 0;
+	fcfg1 = 0;
+	if (enable)
+		dcfg1 |= ENDEV1;
+	switch (priv->auxoutsrc) {
+	case AUXSRC_REFCLK:
+	case AUXSRC_CLKIN:
+	case AUXSRC_PLLCLKOUT:
+		dcfg1 |= AUXOUTSRC(priv->auxoutsrc);
+		break;
+	case AUXSRC_OPENDRAIN:
+		fcfg1 |= AUXLOCKCFG(1);
+		/* fall though */
+	case AUXSRC_PUSHPULL:
+		dcfg1 |= AUXOUTSRC(3);
+		break;
+	}
 
-	ret = cs2000_bset(priv, DEVICE_CFG1, ENDEV1,
-			  enable ? ENDEV1 : 0);
+	ret = cs2000_bset(priv, DEVICE_CFG1, (AUXOUTSRC_MASK | ENDEV1), dcfg1);
 	if (ret < 0)
 		return ret;
 
@@ -122,6 +153,10 @@ static int cs2000_enable_dev_config(struct cs2000_priv *priv, bool enable)
 	if (ret < 0)
 		return ret;
 
+	ret = cs2000_bset(priv, FUNC_CFG1, AUXLOCKCFG_MASK, fcfg1);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
@@ -479,6 +514,38 @@ static int cs2000_remove(struct i2c_client *client)
 	return 0;
 }
 
+static void cs2000_of_parse(struct cs2000_priv *priv)
+{
+	struct device *dev = priv_to_dev(priv);
+	struct device_node *np = dev->of_node;
+	const char *auxoutsrc;
+
+	auxoutsrc = of_get_property(np, "auxoutsrc", NULL);
+
+	if (auxoutsrc) {
+		int i;
+		struct {
+			char *name;
+			enum auxoutsrc val;
+		} of_table[] = {
+			{"refclk",	AUXSRC_REFCLK},
+			{"clk_in",	AUXSRC_CLKIN},
+			{"pllclkout",	AUXSRC_PLLCLKOUT},
+			{"push-pull",	AUXSRC_PUSHPULL},
+			{"open-drain",	AUXSRC_OPENDRAIN},
+		};
+
+		for (i = 0; i < ARRAY_SIZE(of_table); i++) {
+			if (strcmp(of_table[i].name, auxoutsrc) == 0) {
+				priv->auxoutsrc = of_table[i].val;
+				dev_dbg(dev, "%s was selected\n",
+					of_table[i].name);
+				break;
+			}
+		}
+	}
+}
+
 static int cs2000_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
@@ -493,6 +560,8 @@ static int cs2000_probe(struct i2c_client *client,
 	priv->client = client;
 	i2c_set_clientdata(client, priv);
 
+	cs2000_of_parse(priv);
+
 	ret = cs2000_clk_get(priv);
 	if (ret < 0)
 		return ret;
-- 
1.9.1

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

* Re: [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support
  2017-04-11  0:36 ` [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support Kuninori Morimoto
@ 2017-04-11  8:35   ` Geert Uytterhoeven
  2017-04-11  9:22     ` Kuninori Morimoto
  0 siblings, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2017-04-11  8:35 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Michael Turquette, Stephen Boyd, Linux-Renesas, linux-kernel,
	linux-clk, Linus Walleij

Hi Morimoto-san,

On Tue, Apr 11, 2017 at 2:36 AM, Kuninori Morimoto
<kuninori.morimoto.gx@renesas.com> wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
> ---
>  .../devicetree/bindings/clock/cs2000-cp.txt        |  9 +++
>  drivers/clk/clk-cs2000-cp.c                        | 73 +++++++++++++++++++++-
>  2 files changed, 80 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/clock/cs2000-cp.txt b/Documentation/devicetree/bindings/clock/cs2000-cp.txt
> index 54e6df0..4c2f9cb 100644
> --- a/Documentation/devicetree/bindings/clock/cs2000-cp.txt
> +++ b/Documentation/devicetree/bindings/clock/cs2000-cp.txt
> @@ -8,6 +8,15 @@ Required properties:
>  - clock-names:         CLK_IN : clk_in, XTI/REF_CLK : ref_clk
>  - #clock-cells:                must be <0>
>
> +Option properties:
> +
> +- auxoutsrc:           select AUX_OUT source from these.
> +                               refclk:         Timing Reference Clock
> +                               clk_in:         Frequency Reference Clock
> +                               pllclkout:      PLL Clock Output
> +                               push-pull:      PLL Lock/Unlock Indication
> +                               open-drain:     PLL Lock/Unlock Indication

AUX_OUT is an output pin?
Hence, isn't this software configuration instead of hardware description?

Selection of refclk vs. clk_in vs. pllclkout can be implemented as a mux clock
driver with three parents.

PLL Lock/Unlock Indication and its pinctrl are something different.
How to support that?

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] 6+ messages in thread

* Re: [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support
  2017-04-11  8:35   ` Geert Uytterhoeven
@ 2017-04-11  9:22     ` Kuninori Morimoto
  0 siblings, 0 replies; 6+ messages in thread
From: Kuninori Morimoto @ 2017-04-11  9:22 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Michael Turquette, Stephen Boyd, Linux-Renesas, linux-kernel,
	linux-clk, Linus Walleij


Hi Geert

Thank you for your feedback

> > +- auxoutsrc:           select AUX_OUT source from these.
> > +                               refclk:         Timing Reference Clock
> > +                               clk_in:         Frequency Reference Clock
> > +                               pllclkout:      PLL Clock Output
> > +                               push-pull:      PLL Lock/Unlock Indication
> > +                               open-drain:     PLL Lock/Unlock Indication
> 
> AUX_OUT is an output pin?
> Hence, isn't this software configuration instead of hardware description?
> 
> Selection of refclk vs. clk_in vs. pllclkout can be implemented as a mux clock
> driver with three parents.
> 
> PLL Lock/Unlock Indication and its pinctrl are something different.
> How to support that?

I think mux clock is nice idea.
I will use this idea.

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 1/2] clk: cs2000: use existing priv_to_dev() to getting struct device
  2017-04-11  0:35 ` [PATCH 1/2] clk: cs2000: use existing priv_to_dev() to getting struct device Kuninori Morimoto
@ 2017-04-12 15:14   ` Stephen Boyd
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Boyd @ 2017-04-12 15:14 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Michael Turquette, linux-renesas-soc, linux-kernel, linux-clk

On 04/11, Kuninori Morimoto wrote:
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---

Applied to clk-next

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

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

end of thread, other threads:[~2017-04-12 15:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11  0:34 [PATCH 0/2] clk: cs2000: add AUX_OUT pin support Kuninori Morimoto
2017-04-11  0:35 ` [PATCH 1/2] clk: cs2000: use existing priv_to_dev() to getting struct device Kuninori Morimoto
2017-04-12 15:14   ` Stephen Boyd
2017-04-11  0:36 ` [PATCH 2/2] clk: cs2000: add AUX_OUT pin select support Kuninori Morimoto
2017-04-11  8:35   ` Geert Uytterhoeven
2017-04-11  9:22     ` Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).