From: "David.Wu" <david.wu@rock-chips.com>
To: Doug Anderson <dianders@chromium.org>
Cc: "Thierry Reding" <thierry.reding@gmail.com>,
"Heiko Stübner" <heiko@sntech.de>,
"Boris Brezillon" <boris.brezillon@free-electrons.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Brian Norris" <briannorris@chromium.org>,
"Mark Rutland" <mark.rutland@arm.com>,
黄涛 <huangtao@rock-chips.com>,
linux-pwm <linux-pwm@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"open list:ARM/Rockchip SoC..."
<linux-rockchip@lists.infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/7] pwm: rockchip: Add APB and function both clocks support
Date: Wed, 12 Jul 2017 16:38:09 +0800 [thread overview]
Message-ID: <caba81f3-d066-d64e-7e8e-6457b759e757@rock-chips.com> (raw)
In-Reply-To: <CAD=FV=Vqkueo_cqU8bJXXT3pV5d1dZR5LF+c=O-Ka1qR-Ff-WQ@mail.gmail.com>
Hi Doug,
在 2017/7/12 1:03, Doug Anderson 写道:
> Hi,
>
> On Fri, Jul 7, 2017 at 9:03 PM, David Wu <david.wu@rock-chips.com> wrote:
>
>> @@ -6,7 +6,13 @@ Required properties:
>> "rockchip,rk3288-pwm": found on RK3288 SoC
>> "rockchip,vop-pwm": found integrated in VOP on RK3288 SoC
>> - reg: physical base address and length of the controller's registers
>> - - clocks: phandle and clock specifier of the PWM reference clock
>> + - clocks: See ../clock/clock-bindings.txt
>> + - For older hardware (rk2928, rk3066, rk3188, rk3228, rk3288, rk3399):
>> + - There is one clock that's used both to derive the functional clock
>> + for the device and as the bus clock.
>> + - For newer hardware (rk3328 and future socs): specified by name
>> + - "pwm": This is used to derive the functional clock.
>> + - "pclk": This is the APB bus clock.
>
> I'm pretty sure that that the above description doesn't quite match the code.
>
> * The above description says that for old hardware there is one clock
> and 'clock-names' was not necessary (though as I understand it it's OK
> if it's there).
>
> * The old code matched the old description. AKA: if there was no
> "clock-names" then everything was OK.
>
> * The new code will not work if there was no "clock-names".
>
> Many of the old devices had a clock-names present (and it was "pwm"),
> but not all. Specifically it looks like
> "arch/arm/boot/dts/rk3xxx.dtsi" doesn't specify a clock-names.
>
So we can keep code: the pc->clk = devm_clk_get(&pdev->dev, NULL);
If the name is NULL, we can get the first clk defined at DTB.
>> @@ -343,13 +344,38 @@ static int rockchip_pwm_probe(struct platform_device *pdev)
>> if (IS_ERR(pc->base))
>> return PTR_ERR(pc->base);
>>
>> - pc->clk = devm_clk_get(&pdev->dev, NULL);
>> - if (IS_ERR(pc->clk))
>> - return PTR_ERR(pc->clk);
>> + pc->clk = devm_clk_get(&pdev->dev, "pwm");
>> + count = of_property_count_strings(pdev->dev.of_node, "clock-names");
>> + if (count == 2)
>> + pc->pclk = devm_clk_get(&pdev->dev, "pclk");
>> + else
>> + pc->pclk = pc->clk;
>> +
>> + if (IS_ERR(pc->clk)) {
>> + ret = PTR_ERR(pc->clk);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err(&pdev->dev, "Can't get bus clk: %d\n", ret);
>> + return ret;
>> + }
>> +
>> + if (IS_ERR(pc->pclk)) {
>> + ret = PTR_ERR(pc->pclk);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err(&pdev->dev, "Can't get APB clk: %d\n", ret);
>> + return ret;
>> + }
>
> In the above code you need to check the count _before_ trying to get
> the clock by name.
Okay, I will fix it.
>
>
> -Doug
>
>
>
next prev parent reply other threads:[~2017-07-12 8:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 4:03 [PATCH v2 0/7] Add rk3328 pwm support David Wu
2017-07-08 4:03 ` [PATCH v2 1/7] pwm: rockchip: Add APB and function both clocks support David Wu
2017-07-11 17:03 ` Doug Anderson
2017-07-12 8:38 ` David.Wu [this message]
2017-07-12 19:09 ` Heiko Stübner
2017-07-08 4:03 ` [PATCH v2 2/7] pwm: rockchip: Remove the judge from return value of pwm_config David Wu
2017-07-08 4:03 ` [PATCH v2 3/7] pwm: rockchip: Remove the dumplicate rockchip_pwm_ops ops David Wu
2017-08-02 8:59 ` Boris Brezillon
2017-08-02 11:31 ` David.Wu
2017-08-02 11:40 ` Boris Brezillon
2017-08-04 2:38 ` David.Wu
2017-08-04 7:09 ` Boris Brezillon
2017-08-08 15:41 ` David.Wu
2017-07-08 4:03 ` [PATCH v2 4/7] pwm: rockchip: Use pwm_apply instead of the pwm_enable David Wu
2017-07-08 4:08 ` [PATCH v2 5/7] pwm: rockchip: Move the configuration of polarity from rockchip_pwm_set_enable() to rockchip_pwm_config() David Wu
2017-07-08 4:09 ` [PATCH v2 6/7] pwm: rockchip: Add rk3328 pwm support David Wu
2017-07-08 4:10 ` [PATCH v2 7/7] arm64: dts: rockchip: Add pwm nodes for rk3328 David Wu
2017-07-08 4:25 ` [RESEND PATCH v2 6/7] pwm: rockchip: Add rk3328 pwm support David Wu
2017-08-02 8:46 ` [PATCH v2 0/7] " David.Wu
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=caba81f3-d066-d64e-7e8e-6457b759e757@rock-chips.com \
--to=david.wu@rock-chips.com \
--cc=boris.brezillon@free-electrons.com \
--cc=briannorris@chromium.org \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=heiko@sntech.de \
--cc=huangtao@rock-chips.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@gmail.com \
/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®