From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Stephen Boyd <sboyd@kernel.org>
Cc: <broonie@kernel.org>, <lee.jones@linaro.org>,
<linus.walleij@linaro.org>, <mturquette@baylibre.com>,
<robh+dt@kernel.org>, <mark.rutland@arm.com>,
<lgirdwood@gmail.com>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <patches@opensource.cirrus.com>,
<linux-clk@vger.kernel.org>, <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH v2 3/5] clk: lochnagar: Add support for the Cirrus Logic Lochnagar
Date: Thu, 11 Oct 2018 14:26:02 +0100 [thread overview]
Message-ID: <20181011132602.GD1653@imbe.wolfsonmicro.main> (raw)
In-Reply-To: <153924124658.207691.10370075148426001371@swboyd.mtv.corp.google.com>
On Thu, Oct 11, 2018 at 12:00:46AM -0700, Stephen Boyd wrote:
> Quoting Charles Keepax (2018-10-08 06:25:40)
> > +#include <linux/clk.h>
>
> Is this used?
>
> > +#include <linux/clk-provider.h>
> > +#include <linux/delay.h>
>
> Is this used?
>
> > +#include <linux/device.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/pm_runtime.h>
>
> Used?
Apparently not, will remove the three of them.
> > +struct lochnagar_regmap_clk {
> > + unsigned int cfg_reg;
> > + unsigned int ena_mask;
> > + unsigned int dir_mask;
> > +
> > + unsigned int src_reg;
> > + unsigned int src_mask;
>
> Are these 32 bits or 16 bits or 8 bits? Please use a u32/u16/u8 so we
> know the register width.
>
Can do.
> > +struct lochnagar_clk_priv {
> > + struct device *dev;
> > + struct lochnagar *lochnagar;
>
> Is this used for anything besides getting the regmap? Can you get the
> pointer to the parent in probe and use that to get the regmap pointer
> from dev_get_remap() and also use the of_node of the parent to register
> a clk provider? It would be nice to avoid including the mfd header file
> unless it's providing something useful.
>
It is also used to find out which type of Lochnagar we have
connected, which determines which clocks we should register. I
could perhaps pass that using another mechanism but we would
still want to include the MFD stuff to get the register
definitions. So this approach seems simplest.
> > +#define LN_CLK_FIXED(ID, NAME, RATE) \
> > + [LOCHNAGAR_##ID] = { \
> > + .name = NAME, .type = LOCHNAGAR_CLK_TYPE_FIXED, \
> > + { .fixed.rate = RATE, }, \
> > + }
>
> Can all these fixed clks come from DT instead of being populated by this
> driver? Unless they're being generated by this hardware block and not
> actually a crystal or some other on-board clock that goes into this
> hardware block and then right out of it?
>
Technically they are supplied by a clock generator chip (bunch of
PLLs) which is controlled by the board controller chip. That said
I don't really ever see them changing so will move them in DT.
> > +static int lochnagar_regmap_prepare(struct clk_hw *hw)
> > +{
> > + struct lochnagar_clk *lclk = lochnagar_hw_to_lclk(hw);
> > + struct lochnagar_clk_priv *priv = lclk->priv;
> > + struct regmap *regmap = priv->lochnagar->regmap;
> > + int ret;
> > +
> > + dev_dbg(priv->dev, "Prepare %s\n", lclk->name);
>
> Nitpick: Can you just rely on the clk tracepoints?
>
Can do they are hardly essential.
> > +
> > + if (!lclk->regmap.ena_mask)
>
> Why did we assign the ops to the clk if it can't be enabled? Please make
> different ops for different types of clks so we don't have to check
> something else and bail out early when the op is called.
>
This is a bit of a leak from earlier versions of the code I
can just remove them.
> > +static int lochnagar_regmap_set_parent(struct clk_hw *hw, u8 index)
> > +{
> > + struct lochnagar_clk *lclk = lochnagar_hw_to_lclk(hw);
> > + struct lochnagar_clk_priv *priv = lclk->priv;
> > + struct regmap *regmap = priv->lochnagar->regmap;
> > + int ret;
> > +
> > + dev_dbg(priv->dev, "Reparent %s to %s\n",
> > + lclk->name, priv->parents[index]);
> > +
> > + if (lclk->regmap.dir_mask) {
> > + ret = regmap_update_bits(regmap, lclk->regmap.cfg_reg,
> > + lclk->regmap.dir_mask,
> > + lclk->regmap.dir_mask);
> > + if (ret < 0) {
> > + dev_err(priv->dev, "Failed to set %s direction: %d\n",
>
> What does direction mean?
>
Some of the clocks can both generate and receive a clock. For
example the PSIA (external audio interface) MCLKs, the attached
device could be expecting or providing a master audio clock. If
the user assigns a parent to the clock we assume the attached
device is providing a clock to us, otherwise we assume we are
providing the clock.
> > + ret = regmap_read(regmap, lclk->regmap.src_reg, &val);
> > + if (ret < 0) {
> > + dev_err(priv->dev, "Failed to read parent of %s: %d\n",
> > + lclk->name, ret);
> > + return 0;
>
> Return a number greater than all possible parents of this clk?
>
Can do.
> > + for (i = 0; i < ARRAY_SIZE(priv->lclks); i++) {
> > + lclk = &priv->lclks[i];
> > +
> > + lclk->priv = priv;
> > +
> > + switch (lclk->type) {
> > + case LOCHNAGAR_CLK_TYPE_FIXED:
> > + clk = clk_register_fixed_rate(priv->dev, lclk->name,
> > + NULL, 0,
> > + lclk->fixed.rate);
> > + break;
> > + case LOCHNAGAR_CLK_TYPE_REGMAP:
> > + clk_init.name = lclk->name;
> > + lclk->hw.init = &clk_init;
> > +
> > + clk = devm_clk_register(priv->dev, &lclk->hw);
>
> Please use the clk_hw based registration APIs.
>
Can do.
> > +static int lochnagar_clk_remove(struct platform_device *pdev)
> > +{
> > + struct lochnagar_clk_priv *priv = platform_get_drvdata(pdev);
> > + int i;
> > +
> > + of_clk_del_provider(priv->lochnagar->dev->of_node);
>
> Use devm variant of clk provider registration?
>
This isn't using the devm version as it makes the assumption
that the device that contains the DT is the same one we want
to devm against which isn't the case here.
I could update probe to copy the of_node over from the parent, if
you prefer? I think that would also work.
> > +static struct platform_driver lochnagar_clk_driver = {
> > + .driver = {
> > + .name = "lochnagar-clk",
> > + },
>
> Any id_table?
>
Doesn't really need one since the driver will only ever be bound
in by the MFD, so matching on the driver name is fine.
Thanks,
Charles
next prev parent reply other threads:[~2018-10-11 13:26 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-08 13:25 [PATCH v2 1/5] mfd: lochnagar: Add initial binding documentation Charles Keepax
2018-10-08 13:25 ` [PATCH v2 2/5] mfd: lochnagar: Add support for the Cirrus Logic Lochnagar Charles Keepax
2018-10-25 7:44 ` Lee Jones
2018-10-25 8:26 ` Charles Keepax
2018-10-25 9:28 ` Richard Fitzgerald
2018-10-25 10:12 ` Mark Brown
2018-10-25 10:56 ` Charles Keepax
2018-10-25 11:42 ` Lee Jones
2018-10-25 12:49 ` Charles Keepax
2018-10-25 13:20 ` Charles Keepax
2018-10-25 13:47 ` Richard Fitzgerald
2018-10-26 15:49 ` Mark Brown
2018-10-26 7:33 ` Lee Jones
2018-10-26 15:47 ` Mark Brown
2018-10-25 13:40 ` Richard Fitzgerald
2018-10-26 8:00 ` Lee Jones
2018-10-26 20:32 ` Mark Brown
2018-10-29 11:04 ` Lee Jones
2018-10-29 11:52 ` Richard Fitzgerald
2018-10-29 12:36 ` Richard Fitzgerald
2018-10-29 12:57 ` Mark Brown
2018-11-01 10:28 ` Charles Keepax
2018-11-01 11:40 ` Richard Fitzgerald
2018-11-01 12:04 ` Mark Brown
2018-11-01 12:01 ` Mark Brown
2018-11-01 14:17 ` Richard Fitzgerald
2018-10-08 13:25 ` [PATCH v2 3/5] clk: " Charles Keepax
2018-10-11 7:00 ` Stephen Boyd
2018-10-11 13:26 ` Charles Keepax [this message]
2018-10-12 15:59 ` Stephen Boyd
2018-10-15 10:49 ` Charles Keepax
2018-10-15 16:39 ` Stephen Boyd
2018-10-15 16:55 ` Mark Brown
2018-10-15 21:53 ` Stephen Boyd
2018-10-11 14:54 ` Mark Brown
2018-10-11 19:36 ` Stephen Boyd
2018-10-12 16:52 ` Mark Brown
2018-10-08 13:25 ` [PATCH v2 4/5] regulator: " Charles Keepax
2018-10-08 13:25 ` [PATCH v2 5/5] pinctrl: " Charles Keepax
2018-10-12 22:08 ` [PATCH v2 1/5] mfd: lochnagar: Add initial binding documentation Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181011132602.GD1653@imbe.wolfsonmicro.main \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@baylibre.com \
--cc=patches@opensource.cirrus.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox