devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: Fabien Parent <fparent@baylibre.com>,
	linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-pwm@vger.kernel.org
Cc: robh+dt@kernel.org, lee.jones@linaro.org,
	u.kleine-koenig@pengutronix.de, thierry.reding@gmail.com
Subject: Re: [PATCH 2/5] pwm: pwm-mediatek: always use bus clock
Date: Mon, 19 Oct 2020 16:27:38 +0200	[thread overview]
Message-ID: <0f2dc182-868c-43c3-8ae8-999e7cf1d986@gmail.com> (raw)
In-Reply-To: <20201019140705.1518822-3-fparent@baylibre.com>



On 19/10/2020 16:07, Fabien Parent wrote:
> The MediaTek PWM IP can sometimes use the 26MHz source clock to generate
> the PWM signal, but the driver currently assumes that we always use
> the PWM bus clock to generate the PWM signal.
> 
> This commit modifies the PWM driver in order to force the PWM IP to
> always use the bus clock as source clock.
> 
> I do not have the datasheet of all the MediaTek SoC, so I don't know
> if the register to choose the source clk is present in all the SoCs
> or only in subset. As a consequence I made this change optional by
> using a platform data paremeter to says whether this register is
> supported or not. On all the SoC I don't have the datasheet
> (MT2712, MT7622, MT7623, MT7628, MT7629) I kept the behavior
> to be the same as before this change.
> 
> Signed-off-by: Fabien Parent <fparent@baylibre.com>

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

> ---
>   drivers/pwm/pwm-mediatek.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c
> index ab001ce55178..108881619aea 100644
> --- a/drivers/pwm/pwm-mediatek.c
> +++ b/drivers/pwm/pwm-mediatek.c
> @@ -30,12 +30,14 @@
>   #define PWM45DWIDTH_FIXUP	0x30
>   #define PWMTHRES		0x30
>   #define PWM45THRES_FIXUP	0x34
> +#define PWM_CK_26M_SEL		0x210
>   
>   #define PWM_CLK_DIV_MAX		7
>   
>   struct pwm_mediatek_of_data {
>   	unsigned int num_pwms;
>   	bool pwm45_fixup;
> +	bool has_ck_26m_sel;
>   };
>   
>   /**
> @@ -132,6 +134,10 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
>   	if (ret < 0)
>   		return ret;
>   
> +	/* Make sure we use the bus clock and not the 26MHz clock */
> +	if (pc->soc->has_ck_26m_sel)
> +		writel(0, pc->regs + PWM_CK_26M_SEL);
> +
>   	/* Using resolution in picosecond gets accuracy higher */
>   	resolution = (u64)NSEC_PER_SEC * 1000;
>   	do_div(resolution, clk_get_rate(pc->clk_pwms[pwm->hwpwm]));
> @@ -281,31 +287,37 @@ static int pwm_mediatek_remove(struct platform_device *pdev)
>   static const struct pwm_mediatek_of_data mt2712_pwm_data = {
>   	.num_pwms = 8,
>   	.pwm45_fixup = false,
> +	.has_ck_26m_sel = false,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7622_pwm_data = {
>   	.num_pwms = 6,
>   	.pwm45_fixup = false,
> +	.has_ck_26m_sel = false,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7623_pwm_data = {
>   	.num_pwms = 5,
>   	.pwm45_fixup = true,
> +	.has_ck_26m_sel = false,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7628_pwm_data = {
>   	.num_pwms = 4,
>   	.pwm45_fixup = true,
> +	.has_ck_26m_sel = false,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7629_pwm_data = {
>   	.num_pwms = 1,
>   	.pwm45_fixup = false,
> +	.has_ck_26m_sel = false,
>   };
>   
>   static const struct pwm_mediatek_of_data mt8516_pwm_data = {
>   	.num_pwms = 5,
>   	.pwm45_fixup = false,
> +	.has_ck_26m_sel = true,
>   };
>   
>   static const struct of_device_id pwm_mediatek_of_match[] = {
> 

  reply	other threads:[~2020-10-19 14:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 14:07 [PATCH 0/5] Add PWM support for MT8183 EVB Fabien Parent
2020-10-19 14:07 ` [PATCH 1/5] dt-bindings: pwm: pwm-mediatek: Add documentation for MT8183 SoC Fabien Parent
2020-10-19 14:31   ` Matthias Brugger
2020-10-26 13:38   ` Rob Herring
2020-10-19 14:07 ` [PATCH 2/5] pwm: pwm-mediatek: always use bus clock Fabien Parent
2020-10-19 14:27   ` Matthias Brugger [this message]
2020-10-19 14:07 ` [PATCH 3/5] pwm: pwm-mediatek: Add MT8183 SoC support Fabien Parent
2020-10-19 14:30   ` Matthias Brugger
2020-10-19 14:07 ` [PATCH 4/5] arm64: dts: mediatek: mt8183: add pwm node Fabien Parent
2020-10-19 14:07 ` [PATCH 5/5] arm64: dts: mediatek: mt8183-evb: add PWM support Fabien Parent
2020-11-11 20:27 ` [PATCH 0/5] Add PWM support for MT8183 EVB Thierry Reding

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=0f2dc182-868c-43c3-8ae8-999e7cf1d986@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=fparent@baylibre.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.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).