Message ID | Y1K5ym1EL8kwzQEt@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp760447wrr; Fri, 21 Oct 2022 08:29:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sMnwaN1z4mJ3hKgiLpyIAEakKItkOSmgjE+OtrEEil2+srA10eTMKbePQi4bI1x+sA/wM X-Received: by 2002:a63:211a:0:b0:451:f444:3b55 with SMTP id h26-20020a63211a000000b00451f4443b55mr16125406pgh.60.1666366187354; Fri, 21 Oct 2022 08:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666366187; cv=none; d=google.com; s=arc-20160816; b=PKpfD3mgAqnAJlkM9ZHicvjCvqA/I33HkgkPSIdJh3rOnFq3bqPoM+1fFr26e7kiy1 FVAmLzv7AgGCCnXCvhU5LaYTSRlwMfdo5CYHkagjnoKO/T3yTt5BXD44fmpgscBFYFfh Q1OSjhqKNjwO+XzQ/ZAgAymkfzRcLGFO5PmP8UcTr9owWsN2hv22zu46JR8MuBcGphV1 Juqk8HZj716seTv4318N7L2898qLgO/emS4Z6COgVjTH7AoJhHNzoIbqsUQO8+9R/Mbr 02geJL8H51tkYFAu/KQ4tkxK6OfEvl4eUxl53SyhAMF1ZP8Y5pB60jI7YD8zKTGA0TST Y8Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=8ocrk29+zQhD/YXlLJWL8+BOfa0Z62qLlDumaoqPjzs=; b=xzwsA8r6EXIZsr8NAZ2XowYc6AW+KVcR490wcHE8L78yt/xy2HC+nw1iKyWlMnx50z HcJbW1G2cEvoTZ9TPF+haCgcoq2H8Vq0JiVjyWlo9CYKwWb5YfWKA3gjbHVecUeM5UVw HYZizvyNpTtZsByRmNIz6+LNHPuZti6gtvNBSpKgRSt/yQd3JrtIAdrb7up2iReCBKGw zCOZFafGfnpeyLl072zJFc/xT2+9lGoSydDVtu/ayn9EXKM5jImkHb8xkEbMu0wEzi5m OqdpUo5rrhqC9xcCSn3dyOrTuer51ZyUrRuaRZwhD7a7Dy4C7LJPpTig4/9TP4D6F7M4 fsFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k16-20020a170902c41000b00175449cf6f8si31396991plk.606.2022.10.21.08.29.33; Fri, 21 Oct 2022 08:29:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbiJUPZO (ORCPT <rfc822;mntrajkot1@gmail.com> + 99 others); Fri, 21 Oct 2022 11:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230038AbiJUPZM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Oct 2022 11:25:12 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03DC21057D4; Fri, 21 Oct 2022 08:25:09 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.94.2) (envelope-from <daniel@makrotopia.org>) id 1olttR-0001TH-Ko; Fri, 21 Oct 2022 17:25:05 +0200 Date: Fri, 21 Oct 2022 16:24:58 +0100 From: Daniel Golle <daniel@makrotopia.org> To: 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 =?iso-8859-1?q?Kleine-K=F6ni?= =?iso-8859-1?q?g?= <u.kleine-koenig@pengutronix.de>, Matthias Brugger <matthias.bgg@gmail.com> Cc: Frank Wunderlich <frank-w@public-files.de> Subject: [PATCH 1/2] pwm: mediatek: Add support for MT7986 Message-ID: <Y1K5ym1EL8kwzQEt@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747311591122133847?= X-GMAIL-MSGID: =?utf-8?q?1747311591122133847?= |
Series |
[1/2] pwm: mediatek: Add support for MT7986
|
|
Commit Message
Daniel Golle
Oct. 21, 2022, 3:24 p.m. UTC
Add support for PWM on MT7986 which has 2 PWM channels, one of them is
typically used for a temperature controlled fan.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/pwm/pwm-mediatek.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
Hi Daniel: On Fri, 2022-10-21 at 16:24 +0100, Daniel Golle wrote: > Add support for PWM on MT7986 which has 2 PWM channels, one of them > is > typically used for a temperature controlled fan. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/pwm/pwm-mediatek.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c > index 6901a44dc428de..2219cba033e348 100644 > --- a/drivers/pwm/pwm-mediatek.c > +++ b/drivers/pwm/pwm-mediatek.c > @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data > mt8365_pwm_data = { > .has_ck_26m_sel = true, > }; > > +static const struct pwm_mediatek_of_data mt7986_pwm_data = { > + .num_pwms = 2, > + .pwm45_fixup = false, > + .has_ck_26m_sel = true, For MT7986 SoC, I think the value of "has_ck_26m_sel" should be 'false' > +}; > + > static const struct pwm_mediatek_of_data mt8516_pwm_data = { > .num_pwms = 5, > .pwm45_fixup = false, > @@ -342,6 +348,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,mt7986-pwm", .data = &mt7986_pwm_data > }, > { .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data > }, > { .compatible = "mediatek,mt8365-pwm", .data = &mt8365_pwm_data > }, > { .compatible = "mediatek,mt8516-pwm", .data = &mt8516_pwm_data > }, Regards, Sam
On Tue, Oct 25, 2022 at 02:35:43PM +0800, Sam Shih wrote: > Hi Daniel: > > On Fri, 2022-10-21 at 16:24 +0100, Daniel Golle wrote: > > Add support for PWM on MT7986 which has 2 PWM channels, one of them > > is > > typically used for a temperature controlled fan. > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > --- > > drivers/pwm/pwm-mediatek.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c > > index 6901a44dc428de..2219cba033e348 100644 > > --- a/drivers/pwm/pwm-mediatek.c > > +++ b/drivers/pwm/pwm-mediatek.c > > @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data > > mt8365_pwm_data = { > > .has_ck_26m_sel = true, > > }; > > > > +static const struct pwm_mediatek_of_data mt7986_pwm_data = { > > + .num_pwms = 2, > > + .pwm45_fixup = false, > > + .has_ck_26m_sel = true, > > For MT7986 SoC, I think the value of "has_ck_26m_sel" should be 'false' That's a bit surprising, please explain why. Reading the commit adding .has_ck_26m_sel field: > commit 0c0ead76235db0bcfaab83f04db546995449d002 > Author: Fabien Parent <fparent@baylibre.com> > Date: Mon Oct 19 16:07:02 2020 +0200 > > pwm: mediatek: Always use bus clock > > The MediaTek PWM IP can sometimes use the 26 MHz 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 clock 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 SoCs 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> > Signed-off-by: Thierry Reding <thierry.reding@gmail.com> From MT7986 datasheet: > 0x10048210 PWM_CK_26M_SEL PWM BCLK Selection > Reset value 0x00000001 > Description > 0: Select bus CLK as BCLK > 1: Select 26M fix CLK as BCLK So after reset, the 26M clock is selected by default. In pwm-mediatek.c I read: > #define PWM_CK_26M_SEL 0x210 > ... > /* 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); So this PWM_CK_26M_SEL register does exist on MT7986 and has the same address as expected by the driver ($PWM_BASE + 0x210). The default value selected after reset (0x00000001) matches the problem and solution described in the commit description "pwm: mediatek: Always use bus clock". Sidenode: I've tried with both, .has_ck_26m_sel = true as well as .has_ck_26m_sel = false. Both do work, but the behavior is slightly different, again matching the commit description above. > > > +}; > > + > > static const struct pwm_mediatek_of_data mt8516_pwm_data = { > > .num_pwms = 5, > > .pwm45_fixup = false, > > @@ -342,6 +348,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,mt7986-pwm", .data = &mt7986_pwm_data > > }, > > { .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data > > }, > > { .compatible = "mediatek,mt8365-pwm", .data = &mt8365_pwm_data > > }, > > { .compatible = "mediatek,mt8516-pwm", .data = &mt8516_pwm_data > > }, > > Regards, > Sam >
On Tue, 2022-10-25 at 12:57 +0100, Daniel Golle wrote: > On Tue, Oct 25, 2022 at 02:35:43PM +0800, Sam Shih wrote: > > Hi Daniel: > > > > On Fri, 2022-10-21 at 16:24 +0100, Daniel Golle wrote: > > > Add support for PWM on MT7986 which has 2 PWM channels, one of > > > them > > > is > > > typically used for a temperature controlled fan. > > > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > > --- > > > drivers/pwm/pwm-mediatek.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm- > > > mediatek.c > > > index 6901a44dc428de..2219cba033e348 100644 > > > --- a/drivers/pwm/pwm-mediatek.c > > > +++ b/drivers/pwm/pwm-mediatek.c > > > @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data > > > mt8365_pwm_data = { > > > .has_ck_26m_sel = true, > > > }; > > > > > > +static const struct pwm_mediatek_of_data mt7986_pwm_data = { > > > + .num_pwms = 2, > > > + .pwm45_fixup = false, > > > + .has_ck_26m_sel = true, > > > > For MT7986 SoC, I think the value of "has_ck_26m_sel" should be > > 'false' > > That's a bit surprising, please explain why. > The clock tree of MT7981/MT7986 PWM BCLK is as bellow: PLL --> topckgen fix-factors --> TOP_PWM_SEL (topckgen clock mux) --> -- > CLK_INFRA_PWM_BSEL (infra clock mux) --> PWM BCLK (gate) We do have the clock multiplexer to select the source clock for PWM_BCLK https://github.com/torvalds/linux/blob/master/drivers/clk/mediatek/clk-mt7986-infracfg.c#L63 In my knowledge, the pwm hardware of MT7981/MT7986 SoC should ignore this register directtly, but we still keep the register for backword compatibility. In fact, the MT7986 SoC is also working whether 'has_ck_26m_sel' is 'true' or 'false'. Going back to the definition of 'has_ck_26m_sel', if it means "PWM_CK_26M_SEL" register exists or not, we should use 'true', but if it means clock from 26M clock or BUS clock, we should use 'false' > Reading the commit adding .has_ck_26m_sel field: > > commit 0c0ead76235db0bcfaab83f04db546995449d002 > > Author: Fabien Parent <fparent@baylibre.com> > > Date: Mon Oct 19 16:07:02 2020 +0200 > > > > pwm: mediatek: Always use bus clock > > > > The MediaTek PWM IP can sometimes use the 26 MHz 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 clock 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 SoCs 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> > > Signed-off-by: Thierry Reding <thierry.reding@gmail.com> > > From MT7986 datasheet: > > 0x10048210 PWM_CK_26M_SEL PWM BCLK Selection > > Reset value 0x00000001 > > Description > > 0: Select bus CLK as BCLK > > 1: Select 26M fix CLK as BCLK > So after reset, the 26M clock is selected by default. > > In pwm-mediatek.c I read: > > #define PWM_CK_26M_SEL 0x210 > > ... > > /* 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); > > So this PWM_CK_26M_SEL register does exist on MT7986 and has the > same address as expected by the driver ($PWM_BASE + 0x210). > The default value selected after reset (0x00000001) matches the > problem and solution described in the commit description > "pwm: mediatek: Always use bus clock". > > Sidenode: I've tried with both, .has_ck_26m_sel = true as well as > .has_ck_26m_sel = false. Both do work, but the behavior is slightly > different, again matching the commit description above. What is the difference between the two? I tried to config the pwm ch0 period=1000000 and duty=500000, Modify PWM_CK_26M_SEL, and measure the output waveform, the waveform keep the same. Regards, Sam
On Wed, Oct 26, 2022 at 02:17:06PM +0800, Sam Shih wrote: > On Tue, 2022-10-25 at 12:57 +0100, Daniel Golle wrote: > > On Tue, Oct 25, 2022 at 02:35:43PM +0800, Sam Shih wrote: > > > Hi Daniel: > > > > > > On Fri, 2022-10-21 at 16:24 +0100, Daniel Golle wrote: > > > > Add support for PWM on MT7986 which has 2 PWM channels, one of > > > > them > > > > is > > > > typically used for a temperature controlled fan. > > > > > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > > > --- > > > > drivers/pwm/pwm-mediatek.c | 7 +++++++ > > > > 1 file changed, 7 insertions(+) > > > > > > > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm- > > > > mediatek.c > > > > index 6901a44dc428de..2219cba033e348 100644 > > > > --- a/drivers/pwm/pwm-mediatek.c > > > > +++ b/drivers/pwm/pwm-mediatek.c > > > > @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data > > > > mt8365_pwm_data = { > > > > .has_ck_26m_sel = true, > > > > }; > > > > > > > > +static const struct pwm_mediatek_of_data mt7986_pwm_data = { > > > > + .num_pwms = 2, > > > > + .pwm45_fixup = false, > > > > + .has_ck_26m_sel = true, > > > > > > For MT7986 SoC, I think the value of "has_ck_26m_sel" should be > > > 'false' > > > > That's a bit surprising, please explain why. > > > > The clock tree of MT7981/MT7986 PWM BCLK is as bellow: > PLL --> topckgen fix-factors --> TOP_PWM_SEL (topckgen clock mux) --> > -- > > CLK_INFRA_PWM_BSEL (infra clock mux) --> PWM BCLK (gate) > > We do have the clock multiplexer to select the source clock for PWM_BCLK > https://github.com/torvalds/linux/blob/master/drivers/clk/mediatek/clk-mt7986-infracfg.c#L63 > > In my knowledge, the pwm hardware of MT7981/MT7986 SoC should ignore > this register directtly, but we still keep the register for backword > compatibility. > > In fact, the MT7986 SoC is also working whether 'has_ck_26m_sel' is > 'true' or 'false'. > > Going back to the definition of 'has_ck_26m_sel', if it means > "PWM_CK_26M_SEL" register exists or not, we should use 'true', but if > it means clock from 26M clock or BUS clock, we should use 'false' It means 'write 0 to PWM_CK_26M_SEL to make sure PWM BCLK is selected'. If the register isn't used at all on MT7986 (despite being mentioned in the datasheet) or the value written there never has any effect then there is no need to do this and has_ck_26m_sel can be false. > > > Reading the commit adding .has_ck_26m_sel field: > > > commit 0c0ead76235db0bcfaab83f04db546995449d002 > > > Author: Fabien Parent <fparent@baylibre.com> > > > Date: Mon Oct 19 16:07:02 2020 +0200 > > > > > > pwm: mediatek: Always use bus clock > > > > > > The MediaTek PWM IP can sometimes use the 26 MHz 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 clock 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 SoCs 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> > > > Signed-off-by: Thierry Reding <thierry.reding@gmail.com> > > > > From MT7986 datasheet: > > > 0x10048210 PWM_CK_26M_SEL PWM BCLK Selection > > > Reset value 0x00000001 > > > Description > > > 0: Select bus CLK as BCLK > > > 1: Select 26M fix CLK as BCLK > > So after reset, the 26M clock is selected by default. > > > > In pwm-mediatek.c I read: > > > #define PWM_CK_26M_SEL 0x210 > > > ... > > > /* 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); > > > > So this PWM_CK_26M_SEL register does exist on MT7986 and has the > > same address as expected by the driver ($PWM_BASE + 0x210). > > The default value selected after reset (0x00000001) matches the > > problem and solution described in the commit description > > "pwm: mediatek: Always use bus clock". > > > > Sidenode: I've tried with both, .has_ck_26m_sel = true as well as > > .has_ck_26m_sel = false. Both do work, but the behavior is slightly > > different, again matching the commit description above. > > What is the difference between the two? > > I tried to config the pwm ch0 period=1000000 and duty=500000, > Modify PWM_CK_26M_SEL, and measure the output waveform, the waveform > keep the same. Maybe something else already sets the PWM_CK_26M_SEL register to 0 before Linux starts (e.g. U-Boot)?
On Tue, Oct 25, 2022 at 02:35:43PM +0800, Sam Shih wrote: > Hi Daniel: > > On Fri, 2022-10-21 at 16:24 +0100, Daniel Golle wrote: > > Add support for PWM on MT7986 which has 2 PWM channels, one of them > > is > > typically used for a temperature controlled fan. > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > --- > > drivers/pwm/pwm-mediatek.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c > > index 6901a44dc428de..2219cba033e348 100644 > > --- a/drivers/pwm/pwm-mediatek.c > > +++ b/drivers/pwm/pwm-mediatek.c > > @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data > > mt8365_pwm_data = { > > .has_ck_26m_sel = true, > > }; > > > > +static const struct pwm_mediatek_of_data mt7986_pwm_data = { > > + .num_pwms = 2, > > + .pwm45_fixup = false, > > + .has_ck_26m_sel = true, > > For MT7986 SoC, I think the value of "has_ck_26m_sel" should be 'false' The status of the discussion isn't clear to me. You didn't visibly agree which value is right now. Will there be a v2 of this patch? Or is it expected to be picked up as is. From my side (i.e. not having checked the hw details just judging with the PWM hat on) the patch is fine. Best regards Uwe
On Thu, Nov 17, 2022 at 12:56:24PM +0100, Uwe Kleine-König wrote: > On Tue, Oct 25, 2022 at 02:35:43PM +0800, Sam Shih wrote: > > Hi Daniel: > > > > On Fri, 2022-10-21 at 16:24 +0100, Daniel Golle wrote: > > > Add support for PWM on MT7986 which has 2 PWM channels, one of them > > > is > > > typically used for a temperature controlled fan. > > > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > > --- > > > drivers/pwm/pwm-mediatek.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c > > > index 6901a44dc428de..2219cba033e348 100644 > > > --- a/drivers/pwm/pwm-mediatek.c > > > +++ b/drivers/pwm/pwm-mediatek.c > > > @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data > > > mt8365_pwm_data = { > > > .has_ck_26m_sel = true, > > > }; > > > > > > +static const struct pwm_mediatek_of_data mt7986_pwm_data = { > > > + .num_pwms = 2, > > > + .pwm45_fixup = false, > > > + .has_ck_26m_sel = true, > > > > For MT7986 SoC, I think the value of "has_ck_26m_sel" should be 'false' > > The status of the discussion isn't clear to me. You didn't visibly agree > which value is right now. Will there be a v2 of this patch? Or is it > expected to be picked up as is. The patch has been tested thoroughly and works well as-is. The CK_26M_SEL register does exist on MT7986 and, at least according to the datasheet[1], is set to the wrong value (selecting 26M clock) on reset (but probably then already set to 0 to select the bus clock, e.g. by the bootloader). So in the worst case, this is a no-op. [1]: MT7986 Reference Manual, version 1.0 released 2022-05-29, page 428 available at https://wiki.banana-pi.org/Banana_Pi_BPI-R3#Documents > > From my side (i.e. not having checked the hw details just judging with > the PWM hat on) the patch is fine. > > Best regards > Uwe > > -- > Pengutronix e.K. | Uwe Kleine-König | > Industrial Linux Solutions | https://www.pengutronix.de/ | /
Hi Uwe, Sorry for the late reply. Since the CK_26M_SEL register does exist on MT7986, and for the other mediatek SoCs, we should update the value of the CK_26M_SEL register if it exists on the SoC, even the MT7986's PWM hardware just bypasses this setting. From this point of view, I think it is fine to mark '.has_ck_26m_sel' attribute to 'true'. For this patch: Reviewed-by: Sam Shih <sam.shih@mediatek.com> Thanks, Best Regards, Sam Shih On Thu, 2022-11-17 at 12:56 +0100, Uwe Kleine-König wrote: > On Tue, Oct 25, 2022 at 02:35:43PM +0800, Sam Shih wrote: > > Hi Daniel: > > > > On Fri, 2022-10-21 at 16:24 +0100, Daniel Golle wrote: > > > Add support for PWM on MT7986 which has 2 PWM channels, one of > > > them > > > is > > > typically used for a temperature controlled fan. > > > > > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > > --- > > > drivers/pwm/pwm-mediatek.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm- > > > mediatek.c > > > index 6901a44dc428de..2219cba033e348 100644 > > > --- a/drivers/pwm/pwm-mediatek.c > > > +++ b/drivers/pwm/pwm-mediatek.c > > > @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data > > > mt8365_pwm_data = { > > > .has_ck_26m_sel = true, > > > }; > > > > > > +static const struct pwm_mediatek_of_data mt7986_pwm_data = { > > > + .num_pwms = 2, > > > + .pwm45_fixup = false, > > > + .has_ck_26m_sel = true, > > > > For MT7986 SoC, I think the value of "has_ck_26m_sel" should be > > 'false' > > The status of the discussion isn't clear to me. You didn't visibly > agree > which value is right now. Will there be a v2 of this patch? Or is it > expected to be picked up as is. > > From my side (i.e. not having checked the hw details just judging > with > the PWM hat on) the patch is fine. > > Best regards > Uwe >
diff --git a/drivers/pwm/pwm-mediatek.c b/drivers/pwm/pwm-mediatek.c index 6901a44dc428de..2219cba033e348 100644 --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -329,6 +329,12 @@ static const struct pwm_mediatek_of_data mt8365_pwm_data = { .has_ck_26m_sel = true, }; +static const struct pwm_mediatek_of_data mt7986_pwm_data = { + .num_pwms = 2, + .pwm45_fixup = false, + .has_ck_26m_sel = true, +}; + static const struct pwm_mediatek_of_data mt8516_pwm_data = { .num_pwms = 5, .pwm45_fixup = false, @@ -342,6 +348,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,mt7986-pwm", .data = &mt7986_pwm_data }, { .compatible = "mediatek,mt8183-pwm", .data = &mt8183_pwm_data }, { .compatible = "mediatek,mt8365-pwm", .data = &mt8365_pwm_data }, { .compatible = "mediatek,mt8516-pwm", .data = &mt8516_pwm_data },