From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 To: Jens Renner , sebastian.hesselbarth@gmail.com From: Michael Turquette In-Reply-To: <1464190261-1660-1-git-send-email-renner@efe-gmbh.de> Cc: linux-clk@vger.kernel.org, sboyd@codeaurora.org, "Jens Renner" References: <1464190261-1660-1-git-send-email-renner@efe-gmbh.de> Message-ID: <147208523240.32728.8544490000662473501@resonance> Subject: Re: [PATCH] clk: si5351: Add invert clock output option Date: Wed, 24 Aug 2016 17:33:52 -0700 List-ID: Quoting Jens Renner (2016-05-25 08:31:01) > This patch implements the clock invert option for the Silabs Si5351. Clock > output invert can be enabled via DT entry "silabs,clk-invert" for each > clock child node. > = > The change has been tested with a Si5351A on actual hardware. > = > Signed-off-by: Jens Renner > --- > .../devicetree/bindings/clock/silabs,si5351.txt | 1 + > drivers/clk/clk-si5351.c | 25 ++++++++++++++++= ++++++ > include/linux/platform_data/si5351.h | 1 + > 3 files changed, 27 insertions(+) > = > diff --git a/Documentation/devicetree/bindings/clock/silabs,si5351.txt b/= Documentation/devicetree/bindings/clock/silabs,si5351.txt > index 28b2830..2e23cdd 100644 > --- a/Documentation/devicetree/bindings/clock/silabs,si5351.txt > +++ b/Documentation/devicetree/bindings/clock/silabs,si5351.txt > @@ -45,6 +45,7 @@ Optional child node properties: > - silabs,multisynth-source: source pll A(0) or B(1) of corresponding mul= tisynth > divider. > - silabs,pll-master: boolean, multisynth can change pll frequency. > +- silabs,clk-invert: boolean, clock output is inverted. Instead of making this a DT property (of the provider!) can you use the existing clk_set_phase(foo_clk, 180) function? Just supply _si5351_clkout_set_clk_invert as the .set_phase callback, fail if the value is anything other than 0 or a multiple of 180. Either your provider driver or the consumer driver can call this function. Regards, Mike > - silabs,disable-state : clock output disable state, shall be > 0 =3D clock output is driven LOW when disabled > 1 =3D clock output is driven HIGH when disabled > diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c > index b1bc12c..34a9d6f 100644 > --- a/drivers/clk/clk-si5351.c > +++ b/drivers/clk/clk-si5351.c > @@ -898,6 +898,19 @@ static int _si5351_clkout_set_disable_state( > return 0; > } > = > +static int _si5351_clkout_set_clk_invert( > + struct si5351_driver_data *drvdata, int num, > + bool invert) > +{ > + if (num > 8) > + return -EINVAL; > + > + si5351_set_bits(drvdata, SI5351_CLK0_CTRL + num, > + SI5351_CLK_INVERT, (invert) ? SI5351_CLK_INVERT := 0); > + > + return 0; > +} > + > static int si5351_clkout_prepare(struct clk_hw *hw) > { > struct si5351_hw_data *hwdata =3D > @@ -1299,6 +1312,9 @@ static int si5351_dt_parse(struct i2c_client *clien= t, > = > pdata->clkout[num].pll_master =3D > of_property_read_bool(child, "silabs,pll-master"); > + > + pdata->clkout[num].clk_invert =3D > + of_property_read_bool(child, "silabs,clk-invert"); > } > client->dev.platform_data =3D pdata; > = > @@ -1420,6 +1436,15 @@ static int si5351_i2c_probe(struct i2c_client *cli= ent, > n, pdata->clkout[n].disable_state); > return ret; > } > + > + ret =3D _si5351_clkout_set_clk_invert(drvdata, n, > + pdata->clkout[n].clk_inve= rt); > + if (ret) { > + dev_err(&client->dev, > + "failed set invert of clkout%d to %d\n", > + n, pdata->clkout[n].clk_invert); > + return ret; > + } > } > = > if (!IS_ERR(drvdata->pxtal)) > diff --git a/include/linux/platform_data/si5351.h b/include/linux/platfor= m_data/si5351.h > index 533d980..38ffda5 100644 > --- a/include/linux/platform_data/si5351.h > +++ b/include/linux/platform_data/si5351.h > @@ -94,6 +94,7 @@ struct si5351_clkout_config { > enum si5351_drive_strength drive; > enum si5351_disable_state disable_state; > bool pll_master; > + bool clk_invert; > unsigned long rate; > }; > = > -- = > 2.8.1 > = > -- > To unsubscribe from this list: send the line "unsubscribe linux-clk" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html