From: Stefan Wahren <stefan.wahren@i2se.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Lee Jones <lee@kernel.org>, Eric Anholt <eric@anholt.net>
Cc: Remi Pommarel <repk@triplefau.lt>,
linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rpi-kernel@lists.infradead.org,
Stefan Wahren <stefan.wahren@i2se.com>
Subject: [PATCH 1/3] pwm: bcm2835: calculate scaler in pwm_config
Date: Tue, 1 Dec 2015 22:55:39 +0000 [thread overview]
Message-ID: <1449010541-3767-2-git-send-email-stefan.wahren@i2se.com> (raw)
In-Reply-To: <1449010541-3767-1-git-send-email-stefan.wahren@i2se.com>
Currently pwm-bcm2835 assumes a fixed clock rate and stores the
resulting scaler in the driver structure. But with the upcoming
PWM clock support for clk-bcm2835 the rate could change.
So calculate the scaler in pwm_config.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/pwm/pwm-bcm2835.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
index b4c7f95..174cca9 100644
--- a/drivers/pwm/pwm-bcm2835.c
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -29,7 +29,6 @@
struct bcm2835_pwm {
struct pwm_chip chip;
struct device *dev;
- unsigned long scaler;
void __iomem *base;
struct clk *clk;
};
@@ -66,6 +65,7 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
int duty_ns, int period_ns)
{
struct bcm2835_pwm *pc = to_bcm2835_pwm(chip);
+ unsigned long scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
if (period_ns <= MIN_PERIOD) {
dev_err(pc->dev, "period %d not supported, minimum %d\n",
@@ -73,8 +73,8 @@ static int bcm2835_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
return -EINVAL;
}
- writel(duty_ns / pc->scaler, pc->base + DUTY(pwm->hwpwm));
- writel(period_ns / pc->scaler, pc->base + PERIOD(pwm->hwpwm));
+ writel(duty_ns / scaler, pc->base + DUTY(pwm->hwpwm));
+ writel(period_ns / scaler, pc->base + PERIOD(pwm->hwpwm));
return 0;
}
@@ -156,8 +156,6 @@ static int bcm2835_pwm_probe(struct platform_device *pdev)
if (ret)
return ret;
- pc->scaler = NSEC_PER_SEC / clk_get_rate(pc->clk);
-
pc->chip.dev = &pdev->dev;
pc->chip.ops = &bcm2835_pwm_ops;
pc->chip.npwm = 2;
--
1.7.9.5
next prev parent reply other threads:[~2015-12-01 22:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-01 22:55 [PATCH 0/3] pwm: bcm2835: improve clock handling Stefan Wahren
2015-12-01 22:55 ` Stefan Wahren [this message]
2015-12-01 22:55 ` [PATCH 2/3] pwm: bcm2835: prevent division by zero Stefan Wahren
2015-12-01 23:16 ` Eric Anholt
2015-12-02 17:08 ` Stefan Wahren
2015-12-02 19:43 ` Eric Anholt
2015-12-02 15:23 ` Mathieu Poirier
2015-12-02 19:41 ` Eric Anholt
2015-12-01 22:55 ` [PATCH 3/3] pwm: bcm2835: fix email address specifiction Stefan Wahren
2015-12-15 17:59 ` [PATCH 0/3] pwm: bcm2835: improve clock handling Stefan Wahren
2015-12-15 18:24 ` Eric Anholt
2015-12-16 15:38 ` 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=1449010541-3767-2-git-send-email-stefan.wahren@i2se.com \
--to=stefan.wahren@i2se.com \
--cc=eric@anholt.net \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=repk@triplefau.lt \
--cc=swarren@wwwdotorg.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;
as well as URLs for NNTP newsgroup(s).