Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: "Daniel Golle" <daniel@makrotopia.org>,
	linux-pwm@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"John Crispin" <john@phrozen.org>
Subject: Re: [PATCH v3 2/2] pwm: mediatek: Add support for MT7981
Date: Mon, 24 Apr 2023 14:28:54 +0200	[thread overview]
Message-ID: <16cf2101-b9ba-154a-9932-3115e2447c82@gmail.com> (raw)
In-Reply-To: <7f404164337a2e06a6026c5c7e066e0cfba1fb32.1682007088.git.daniel@makrotopia.org>



On 21/04/2023 01:23, Daniel Golle wrote:
> The PWM unit on MT7981 uses different register offsets than previous
> MediaTek PWM units. Add support for these new offsets and add support
> for PWM on MT7981 which has 3 PWM channels, one of them is typically
> used for a temperature controlled fan.
> While at it, also reorder pwm_mediatek_of_data entries to restore
> alphabetic order.
> 
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

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

> ---
>   drivers/pwm/pwm-mediatek.c | 39 ++++++++++++++++++++++++++++++--------
>   1 file changed, 31 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c
> index 5b5eeaff35da6..7a51d210a8778 100644
> --- a/drivers/pwm/pwm-mediatek.c
> +++ b/drivers/pwm/pwm-mediatek.c
> @@ -38,6 +38,7 @@ struct pwm_mediatek_of_data {
>   	unsigned int num_pwms;
>   	bool pwm45_fixup;
>   	bool has_ck_26m_sel;
> +	const unsigned int *reg_offset;
>   };
>   
>   /**
> @@ -59,10 +60,14 @@ struct pwm_mediatek_chip {
>   	const struct pwm_mediatek_of_data *soc;
>   };
>   
> -static const unsigned int pwm_mediatek_reg_offset[] = {
> +static const unsigned int mtk_pwm_reg_offset_v1[] = {
>   	0x0010, 0x0050, 0x0090, 0x00d0, 0x0110, 0x0150, 0x0190, 0x0220
>   };
>   
> +static const unsigned int mtk_pwm_reg_offset_v2[] = {
> +	0x0080, 0x00c0, 0x0100, 0x0140, 0x0180, 0x01c0, 0x0200, 0x0240
> +};
> +
>   static inline struct pwm_mediatek_chip *
>   to_pwm_mediatek_chip(struct pwm_chip *chip)
>   {
> @@ -111,7 +116,7 @@ static inline void pwm_mediatek_writel(struct pwm_mediatek_chip *chip,
>   				       unsigned int num, unsigned int offset,
>   				       u32 value)
>   {
> -	writel(value, chip->regs + pwm_mediatek_reg_offset[num] + offset);
> +	writel(value, chip->regs + chip->soc->reg_offset[num] + offset);
>   }
>   
>   static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,
> @@ -285,60 +290,77 @@ static const struct pwm_mediatek_of_data mt2712_pwm_data = {
>   	.num_pwms = 8,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = false,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
>   static const struct pwm_mediatek_of_data mt6795_pwm_data = {
>   	.num_pwms = 7,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = false,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7622_pwm_data = {
>   	.num_pwms = 6,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = true,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7623_pwm_data = {
>   	.num_pwms = 5,
>   	.pwm45_fixup = true,
>   	.has_ck_26m_sel = false,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7628_pwm_data = {
>   	.num_pwms = 4,
>   	.pwm45_fixup = true,
>   	.has_ck_26m_sel = false,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
>   static const struct pwm_mediatek_of_data mt7629_pwm_data = {
>   	.num_pwms = 1,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = false,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
> -static const struct pwm_mediatek_of_data mt8183_pwm_data = {
> -	.num_pwms = 4,
> +static const struct pwm_mediatek_of_data mt7981_pwm_data = {
> +	.num_pwms = 3,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = true,
> +	.reg_offset = mtk_pwm_reg_offset_v2,
>   };
>   
> -static const struct pwm_mediatek_of_data mt8365_pwm_data = {
> -	.num_pwms = 3,
> +static const struct pwm_mediatek_of_data mt7986_pwm_data = {
> +	.num_pwms = 2,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = true,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
> -static const struct pwm_mediatek_of_data mt7986_pwm_data = {
> -	.num_pwms = 2,
> +static const struct pwm_mediatek_of_data mt8183_pwm_data = {
> +	.num_pwms = 4,
> +	.pwm45_fixup = false,
> +	.has_ck_26m_sel = true,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
> +};
> +
> +static const struct pwm_mediatek_of_data mt8365_pwm_data = {
> +	.num_pwms = 3,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = true,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
>   static const struct pwm_mediatek_of_data mt8516_pwm_data = {
>   	.num_pwms = 5,
>   	.pwm45_fixup = false,
>   	.has_ck_26m_sel = true,
> +	.reg_offset = mtk_pwm_reg_offset_v1,
>   };
>   
>   static const struct of_device_id pwm_mediatek_of_match[] = {
> @@ -348,6 +370,7 @@ static const struct of_device_id pwm_mediatek_of_match[] = {
>   	{ .compatible = "mediatek,mt7623-pwm", .data = &mt7623_pwm_data },
>   	{ .compatible = "mediatek,mt7628-pwm", .data = &mt7628_pwm_data },
>   	{ .compatible = "mediatek,mt7629-pwm", .data = &mt7629_pwm_data },
> +	{ .compatible = "mediatek,mt7981-pwm", .data = &mt7981_pwm_data },
>   	{ .compatible = "mediatek,mt7986-pwm", .data = &mt7986_pwm_data },
>   	{ .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data },
>   	{ .compatible = "mediatek,mt8365-pwm", .data = &mt8365_pwm_data },

  reply	other threads:[~2023-04-24 12:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 23:22 [PATCH v3 0/2] Support PWM on MediaTek MT7981 Daniel Golle
2023-04-20 23:22 ` [PATCH v3 1/2] dt-bindings: pwm: mediatek: Add mediatek,mt7981 compatible Daniel Golle
2023-04-20 23:23 ` [PATCH v3 2/2] pwm: mediatek: Add support for MT7981 Daniel Golle
2023-04-24 12:28   ` Matthias Brugger [this message]
2023-05-16  6:50 ` [PATCH v3 0/2] Support PWM on MediaTek MT7981 Uwe Kleine-König
2023-06-23 14:51 ` 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=16cf2101-b9ba-154a-9932-3115e2447c82@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=daniel@makrotopia.org \
    --cc=john@phrozen.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=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