devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Fabien Parent <fparent@baylibre.com>
Cc: linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, matthias.bgg@gmail.com,
	tglx@linutronix.de, daniel.lezcano@linaro.org
Subject: Re: [PATCH 2/2] clocksource: mediatek: add clk13m and bus clock support
Date: Mon, 26 Oct 2020 08:30:06 -0500	[thread overview]
Message-ID: <20201026133006.GA29275@bogus> (raw)
In-Reply-To: <20201017153857.2494845-2-fparent@baylibre.com>

On Sat, Oct 17, 2020 at 05:38:57PM +0200, Fabien Parent wrote:
> Some MediaTek SoC like MT8516 need to enable additional clocks
> for the GPT timer. Enable them if present.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>
> ---
>  drivers/clocksource/timer-mediatek.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
> index 9318edcd8963..42e2d2090484 100644
> --- a/drivers/clocksource/timer-mediatek.c
> +++ b/drivers/clocksource/timer-mediatek.c
> @@ -9,6 +9,7 @@
>  
>  #define pr_fmt(fmt)	KBUILD_MODNAME ": " fmt
>  
> +#include <linux/clk.h>
>  #include <linux/clockchips.h>
>  #include <linux/clocksource.h>
>  #include <linux/interrupt.h>
> @@ -278,8 +279,19 @@ static int __init mtk_syst_init(struct device_node *node)
>  
>  static int __init mtk_gpt_init(struct device_node *node)
>  {
> +	struct clk *clk_13m, *clk_bus;
>  	int ret;
>  
> +	/* Optional clock*/

Then use the optional api variant.

> +	clk_13m = of_clk_get_by_name(node, "clk13m");
> +	if (!IS_ERR(clk_13m))

And then you can drop this check (or handle it for any error other than 
clock is not present).

> +		clk_prepare_enable(clk_13m);
> +
> +	/* Optional clock*/
> +	clk_bus = of_clk_get_by_name(node, "bus");
> +	if (!IS_ERR(clk_bus))
> +		clk_prepare_enable(clk_bus);
> +
>  	to.clkevt.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
>  	to.clkevt.set_state_shutdown = mtk_gpt_clkevt_shutdown;
>  	to.clkevt.set_state_periodic = mtk_gpt_clkevt_set_periodic;
> -- 
> 2.28.0
> 

  reply	other threads:[~2020-10-26 13:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17 15:38 [PATCH 1/2] dt-bindings: timer: mtk-timer: add optional 13m and bus clock Fabien Parent
2020-10-17 15:38 ` [PATCH 2/2] clocksource: mediatek: add clk13m and bus clock support Fabien Parent
2020-10-26 13:30   ` Rob Herring [this message]
2020-10-26 18:08     ` Fabien Parent
2020-10-26 13:30 ` [PATCH 1/2] dt-bindings: timer: mtk-timer: add optional 13m and bus clock 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=20201026133006.GA29275@bogus \
    --to=robh@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fparent@baylibre.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).