mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
From: narmstrong@baylibre.com (Neil Armstrong)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 3/4] clk: add Amlogic meson clock driver
Date: Fri, 30 Mar 2018 09:53:52 +0200	[thread overview]
Message-ID: <37e9510f-8150-9c4e-e3b9-3938d637c650@baylibre.com> (raw)
In-Reply-To: <CAPnjgZ176Z7gjh=zvpzFvWEp=XrA6jML4UmgxSzc_WfDqyOJbw@mail.gmail.com>

On 30/03/2018 00:41, Simon Glass wrote:
> Hi Neil,
> 
> On 29 March 2018 at 16:42, Neil Armstrong <narmstrong@baylibre.com> wrote:
>> Hi Beniamino,
>>
>> On 03/12/2017 10:17, Beniamino Galvani wrote:
>>> Introduce a basic clock driver for Amlogic Meson SoCs which supports
>>> enabling/disabling clock gates and getting their frequency.
>>>
>>> Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
>>> ---
>>>  arch/arm/mach-meson/Kconfig |   2 +
>>>  drivers/clk/Makefile        |   1 +
>>>  drivers/clk/clk_meson.c     | 196 ++++++++++++++++++++++++++++++++++++++++++++
>>>  3 files changed, 199 insertions(+)
>>>  create mode 100644 drivers/clk/clk_meson.c
>>>
>>> diff --git a/arch/arm/mach-meson/Kconfig b/arch/arm/mach-meson/Kconfig
>>> index d4bd230be3..7acee3bc5c 100644
>>> --- a/arch/arm/mach-meson/Kconfig
>>> +++ b/arch/arm/mach-meson/Kconfig
>>
>> [...]
>>> +
>>> +static int meson_set_gate(struct clk *clk, bool on)
>>> +{
>>> +     struct meson_clk *priv = dev_get_priv(clk->dev);
>>> +     struct meson_gate *gate;
>>> +
>>> +     if (clk->id >= ARRAY_SIZE(gates))
>>> +             return -ENOENT;
>>
>> This should be -ENOSYS, otherwise it breaks the ethernet driver since it waits -ENOSYS if clock cannot be enabled.
> 
> Perhaps, but this is a genuine error, so it is OK to break the
> Ethernet driver, isn't it? We don't want errors to be silently
> ignored.
> 
> Not having a device is one thing, but having a device that does not work is bad.
> 

The driver only manages the gates, enabling and disabling them and getting their freq.
The missing clocks of the ethernet driver in this case are dividers of the PLL, thus
we don't need to enable them, and for now the driver don't need the freq.

> Also I have tried to keep -ENOSYS for cases where the driver does not
> support the operation. We should be very clear in clk-uclass.h as to
> what errors are returned. At present I don't see ENOSYS mentioned. At
> the very least we should update the docs if certain behaviour is
> expected. I would also expect us to have a sandbox test for it.

In this case, the driver does not support the operation for these clocks, but maybe it would be
better to add them with reg=0 and return -ENOSYS in the following return :

> 
>>
>>> +
>>> +     gate = &gates[clk->id];
>>> +
>>> +     if (gate->reg == 0)
>>> +             return -ENOENT;
>>
>> Same here -ENOSYS

Here thsi means it's not a gate.

>>
>>> +
>>> +     clrsetbits_le32(priv->addr + gate->reg,
>>> +                     BIT(gate->bit), on ? BIT(gate->bit) : 0);
>>> +     return 0;
>>> +}
>>> +
>>> +static int meson_clk_enable(struct clk *clk)
>>> +{
>>> +     return meson_set_gate(clk, true);
>>> +}
>>> +
>>> +static int meson_clk_disable(struct clk *clk)
>>> +{
>>> +     return meson_set_gate(clk, false);
>>> +}
>>> +
>>> +static ulong meson_clk_get_rate(struct clk *clk)
>>> +{
>>> +     struct meson_clk *priv = dev_get_priv(clk->dev);
>>> +
>>> +     if (clk->id != CLKID_CLK81) {
>>> +             if (clk->id >= ARRAY_SIZE(gates))
>>> +                     return -ENOENT;
>>
>> Same here -ENOSYS
>>
>>> +             if (gates[clk->id].reg == 0)
>>> +                     return -ENOENT;
>>
>> Same here -ENOSYS
>>
>>> +     }
>>> +
>>> +     /* Use cached value if available */
>>> +     if (priv->rate)
>>> +             return priv->rate;
>>> +
>>> +     priv->rate = meson_measure_clk_rate(CLK_81);
>>> +
>>> +     return priv->rate;
>>> +}
>>> +
>>
>> [...]
>>
>> Neil
> 
> Regards,
> Simon
> 

  reply	other threads:[~2018-03-30  7:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-03  9:17 [PATCH 0/4] Meson " Beniamino Galvani
2017-12-03  9:17 ` [PATCH 1/4] ARM: dts: update gxbb-clkc.h from Linux 4.14 Beniamino Galvani
2017-12-06 13:38   ` Neil Armstrong
2017-12-03  9:17 ` [PATCH 2/4] ARM: meson: add clock measurement function Beniamino Galvani
2017-12-06 13:40   ` Neil Armstrong
2017-12-11 14:57   ` Simon Glass
2017-12-03  9:17 ` [PATCH 3/4] clk: add Amlogic meson clock driver Beniamino Galvani
2017-12-06 13:41   ` Neil Armstrong
2017-12-11 14:57   ` Simon Glass
2018-03-29  8:42   ` Neil Armstrong
2018-03-29 22:41     ` Simon Glass
2018-03-30  7:53       ` Neil Armstrong [this message]
2018-03-30  8:41         ` Simon Glass
2018-03-30 14:27           ` Andreas Färber
2018-03-31  8:44             ` Simon Glass
2017-12-03  9:17 ` [PATCH 4/4] meson: use the " Beniamino Galvani
2017-12-06 13:43   ` Neil Armstrong
2017-12-11 14:57   ` Simon Glass
2017-12-13  2:33   ` [U-Boot,4/4] " Tom Rini
2018-03-28  8:59 ` [PATCH 0/4] Meson " Neil Armstrong
2018-03-28 10:52   ` Beniamino Galvani
2018-03-28 13:44     ` Neil Armstrong

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=37e9510f-8150-9c4e-e3b9-3938d637c650@baylibre.com \
    --to=narmstrong@baylibre.com \
    --cc=linus-amlogic@lists.infradead.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

all inboxes | Powered by JetHome®