From: Nikita Travkin <nikita@trvn.ru>
To: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Cc: thierry.reding@gmail.com, lee.jones@linaro.org,
u.kleine-koenig@pengutronix.de, robh+dt@kernel.org,
sboyd@kernel.org, linus.walleij@linaro.org,
masneyb@onstation.org, sean.anderson@seco.com,
linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v5 2/2] pwm: Add clock based PWM output driver
Date: Sat, 19 Feb 2022 11:48:50 +0500 [thread overview]
Message-ID: <170305a686280ed44a5d3e49dee3176f@trvn.ru> (raw)
In-Reply-To: <e1f2f9c4-a597-2c8f-df0c-4ae30a5ad594@canonical.com>
Hi,
Krzysztof Kozlowski писал(а) 14.02.2022 16:19:
> On 12/02/2022 17:23, Nikita Travkin wrote:
>> Some systems have clocks exposed to external devices. If the clock
>> controller supports duty-cycle configuration, such clocks can be used as
>> pwm outputs. In fact PWM and CLK subsystems are interfaced with in a
>> similar way and an "opposite" driver already exists (clk-pwm). Add a
>> driver that would enable pwm devices to be used via clk subsystem.
>>
>> Signed-off-by: Nikita Travkin <nikita@trvn.ru>
>> --
>>
>
> (...)
>
>> +
>> +static int pwm_clk_probe(struct platform_device *pdev)
>> +{
>> + struct pwm_clk_chip *chip;
>> + int ret;
>> +
>> + chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
>> + if (!chip)
>> + return -ENOMEM;
>> +
>> + chip->clk = devm_clk_get(&pdev->dev, NULL);
>> + if (IS_ERR(chip->clk))
>> + return dev_err_probe(&pdev->dev, PTR_ERR(chip->clk),
>> + "Failed to get clock\n");
>> +
>> + chip->chip.dev = &pdev->dev;
>> + chip->chip.ops = &pwm_clk_ops;
>> + chip->chip.npwm = 1;
>> +
>> + ret = clk_prepare(chip->clk);
>> + if (ret < 0)
>> + return dev_err_probe(&pdev->dev, ret, "Failed to prepare clock\n");
>> +
>> + ret = pwmchip_add(&chip->chip);
>> + if (ret < 0)
>> + return dev_err_probe(&pdev->dev, ret, "Failed to add pwm chip\n");
>
> You need to cleanup - unprepare the clock.
>
Oops, I will add unprepare in v6, Thanks!
Nikita
>> +
>> + platform_set_drvdata(pdev, chip);
>> + return 0;
>> +}
>> +
>
>
> Best regards,
> Krzysztof
next prev parent reply other threads:[~2022-02-19 6:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 16:23 [PATCH v5 0/2] Clock based PWM output driver Nikita Travkin
2022-02-12 16:23 ` [PATCH v5 1/2] dt-bindings: pwm: Document clk based PWM controller Nikita Travkin
2022-02-14 7:43 ` Krzysztof Kozlowski
2022-02-12 16:23 ` [PATCH v5 2/2] pwm: Add clock based PWM output driver Nikita Travkin
2022-02-14 11:19 ` Krzysztof Kozlowski
2022-02-19 6:48 ` Nikita Travkin [this message]
2022-02-14 18:43 ` Uwe Kleine-König
2022-02-19 6:46 ` Nikita Travkin
2022-02-19 10:10 ` Uwe Kleine-König
2022-02-19 13:54 ` Nikita Travkin
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=170305a686280ed44a5d3e49dee3176f@trvn.ru \
--to=nikita@trvn.ru \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski@canonical.com \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=masneyb@onstation.org \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=sean.anderson@seco.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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).