From: "Heiko Stübner" <heiko@sntech.de>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC PATCH 12/15] pwm: rockchip: add initial state retrieval
Date: Wed, 01 Jul 2015 21:44:46 +0000 [thread overview]
Message-ID: <3258341.kaLi8uDfLr@diego> (raw)
In-Reply-To: <1435738921-25027-13-git-send-email-boris.brezillon@free-electrons.com>
Hi Boris,
Am Mittwoch, 1. Juli 2015, 10:21:58 schrieb Boris Brezillon:
> Implement the ->init_state() function to expose initial state.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
[...]
> @@ -98,6 +110,36 @@ static void rockchip_pwm_set_enable_v2(struct pwm_chip
> *chip, writel_relaxed(val, pc->base + pc->data->regs.ctrl);
> }
>
> +static void rockchip_pwm_init_state(struct pwm_chip *chip,
> + struct pwm_device *pwm)
> +{
> + struct rockchip_pwm_chip *pc = to_rockchip_pwm_chip(chip);
> + unsigned long clk_rate;
> + u64 tmp;
> + int ret;
> +
> + ret = clk_enable(pc->clk);
> + if (ret)
> + return;
> +
> + clk_rate = clk_get_rate(pc->clk);
> +
> + tmp = readl(pc->base + pc->data->regs.period);
> + tmp *= pc->data->prescaler * NSEC_PER_SEC;
> + tmp = do_div(tmp, clk_rate);
I guess you want to have the division result here and not the remainder, so
- tmp = do_div(tmp, clk_rate);
+ do_div(tmp, clk_rate);
> + pwm->state.period = tmp;
> +
> + tmp = readl(pc->base + pc->data->regs.duty);
> + tmp *= pc->data->prescaler * NSEC_PER_SEC;
> + tmp = do_div(tmp, clk_rate);
ditto
> + pwm->state.duty_cycle = tmp;
> +
> + pc->data->init(chip, chip->pwms);
> +
> + if (!pwm_is_enabled(pwm))
> + clk_disable(pc->clk);
> +}
> +
> static int rockchip_pwm_config(struct pwm_chip *chip, struct pwm_device
> *pwm, int duty_ns, int period_ns)
> {
> @@ -171,6 +213,7 @@ static void rockchip_pwm_disable(struct pwm_chip *chip,
> struct pwm_device *pwm) }
>
> static const struct pwm_ops rockchip_pwm_ops_v1 = {
> + .init_state = rockchip_pwm_init_state,
> .config = rockchip_pwm_config,
> .enable = rockchip_pwm_enable,
> .disable = rockchip_pwm_disable,
> @@ -178,6 +221,7 @@ static const struct pwm_ops rockchip_pwm_ops_v1 = {
> };
>
> static const struct pwm_ops rockchip_pwm_ops_v2 = {
> + .init_state = rockchip_pwm_init_state,
> .config = rockchip_pwm_config,
> .set_polarity = rockchip_pwm_set_polarity,
> .enable = rockchip_pwm_enable,
> @@ -195,6 +239,7 @@ static const struct rockchip_pwm_data pwm_data_v1 = {
> .prescaler = 2,
> .ops = &rockchip_pwm_ops_v1,
> .set_enable = rockchip_pwm_set_enable_v1,
> + .init = rockchip_pwm_init_v1,
> };
>
> static const struct rockchip_pwm_data pwm_data_v2 = {
> @@ -207,6 +252,7 @@ static const struct rockchip_pwm_data pwm_data_v2 = {
> .prescaler = 1,
> .ops = &rockchip_pwm_ops_v2,
> .set_enable = rockchip_pwm_set_enable_v2,
> + .init = rockchip_pwm_init_v2,
you're referencing the v2 init here, but only add it in the next patch?
[pwm: rockchip: add support for atomic update]
> };
>
> static const struct rockchip_pwm_data pwm_data_vop = {
> @@ -219,6 +265,7 @@ static const struct rockchip_pwm_data pwm_data_vop = {
> .prescaler = 1,
> .ops = &rockchip_pwm_ops_v2,
> .set_enable = rockchip_pwm_set_enable_v2,
> + .init = rockchip_pwm_init_v2,
ditto
Heiko
next prev parent reply other threads:[~2015-07-01 21:44 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-01 8:21 [RFC PATCH 00/15] pwm: add support for atomic update Boris Brezillon
2015-07-01 8:21 ` [RFC PATCH 01/15] pwm: add the pwm_is_enabled() helper Boris Brezillon
2015-07-20 7:47 ` Thierry Reding
2015-07-01 8:21 ` [RFC PATCH 02/15] pwm: fix pwm_get_period and pwm_get_duty_cycle prototypes Boris Brezillon
2015-07-20 7:50 ` Thierry Reding
2015-07-01 8:21 ` [RFC PATCH 03/15] pwm: add pwm_get_polarity helper function Boris Brezillon
2015-07-20 7:52 ` Thierry Reding
2015-07-01 8:21 ` [RFC PATCH 04/15] pwm: make use of pwm_get_xxx helpers where appropriate Boris Brezillon
2015-07-20 8:00 ` Thierry Reding
2015-07-01 8:21 ` [RFC PATCH 05/15] pwm: introduce default period and polarity concepts Boris Brezillon
2015-07-02 6:44 ` Uwe Kleine-König
2015-07-02 7:49 ` Boris Brezillon
2015-07-20 8:03 ` Thierry Reding
2015-07-20 8:14 ` Boris Brezillon
2015-07-20 8:22 ` Thierry Reding
2015-07-20 8:32 ` Boris Brezillon
2015-07-01 8:21 ` [RFC PATCH 06/15] pwm: define a new pwm_state struct Boris Brezillon
2015-07-20 8:04 ` Thierry Reding
2015-07-20 10:01 ` Boris Brezillon
2015-07-20 10:09 ` Thierry Reding
2015-07-20 10:12 ` Boris Brezillon
2015-07-01 8:21 ` [RFC PATCH 07/15] pwm: move the enabled/disabled info to " Boris Brezillon
2015-07-20 8:11 ` Thierry Reding
2015-07-01 8:21 ` [RFC PATCH 08/15] backlight: pwm_bl: remove useless call to pwm_set_period Boris Brezillon
2015-07-20 8:16 ` Thierry Reding
2015-07-20 8:21 ` Boris Brezillon
2015-07-20 8:36 ` Thierry Reding
2015-07-20 8:50 ` Boris Brezillon
2015-07-20 9:10 ` Thierry Reding
2015-07-20 9:57 ` Boris Brezillon
2015-07-20 10:01 ` Thierry Reding
2015-07-01 8:21 ` [RFC PATCH 09/15] pwm: declare a default PWM state Boris Brezillon
2015-07-01 8:21 ` [RFC PATCH 10/15] pwm: add the PWM initial state retrieval infra Boris Brezillon
2015-07-20 9:01 ` Thierry Reding
2015-07-20 9:42 ` Boris Brezillon
2015-07-01 8:21 ` [RFC PATCH 11/15] pwm: add the core infrastructure to allow atomic update Boris Brezillon
2015-07-20 8:59 ` Thierry Reding
2015-07-20 9:48 ` Boris Brezillon
2015-07-20 10:04 ` Thierry Reding
2015-07-01 8:21 ` [RFC PATCH 12/15] pwm: rockchip: add initial state retrieval Boris Brezillon
2015-07-01 21:44 ` Heiko Stübner [this message]
2015-07-02 7:46 ` Boris Brezillon
2015-07-01 8:21 ` [RFC PATCH 13/15] pwm: rockchip: add support for atomic update Boris Brezillon
2015-07-01 21:48 ` Heiko Stübner
2015-07-02 7:43 ` Boris Brezillon
2015-07-01 8:22 ` [RFC PATCH 14/15] regulator: pwm: implement ->enable(), ->disable() and ->is_enabled methods Boris Brezillon
2015-07-01 11:58 ` Heiko Stübner
2015-07-01 12:05 ` Boris Brezillon
2015-07-01 12:08 ` Heiko Stübner
2015-07-01 12:19 ` Boris Brezillon
2015-07-14 10:50 ` Mark Brown
2015-07-14 11:02 ` Boris Brezillon
2015-07-14 11:08 ` Mark Brown
2015-07-14 11:16 ` Boris Brezillon
2015-07-01 8:22 ` [RFC PATCH 15/15] regulator: pwm: properly initialize the ->state field Boris Brezillon
2015-07-14 10:51 ` Mark Brown
2015-07-14 11:03 ` Boris Brezillon
2015-07-01 21:50 ` [RFC PATCH 16/15] pwm: add informations about polarity, duty cycle and period to debugfs Heiko Stübner
2015-07-02 13:01 ` Boris Brezillon
2015-07-03 8:43 ` [PATCH] " Heiko Stübner
2015-07-01 21:57 ` [RFC PATCH 00/15] pwm: add support for atomic update Heiko Stübner
2015-07-02 7:55 ` Boris Brezillon
2015-07-02 7:03 ` Uwe Kleine-König
2015-07-02 7:17 ` Tomi Valkeinen
2015-07-02 7:42 ` Uwe Kleine-König
2015-07-02 7:30 ` Boris Brezillon
2015-07-20 7:16 ` Boris Brezillon
2015-07-20 7:43 ` 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=3258341.kaLi8uDfLr@diego \
--to=heiko@sntech.de \
--cc=linux-arm-kernel@lists.infradead.org \
/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).