From: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
To: Chew Chiau Ee <chiau.ee.chew@intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Chew Kean Ho <kean.ho.chew@intel.com>,
Chang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com>
Subject: Re: [PATCH] pwm: add support for Intel Low Power Subsystem PWM
Date: Mon, 20 Jan 2014 13:28:14 +0000 [thread overview]
Message-ID: <20140120132814.212929bd@alan.etchedpixels.co.uk> (raw)
In-Reply-To: <1390240808-18582-1-git-send-email-chiau.ee.chew@intel.com>
> +static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm,
> + int duty_ns, int period_ns)
> +{
> + struct pwm_lpss_chip *lpwm = to_lpwm(chip);
> + u8 on_time_div;
> + unsigned long c = clk_get_rate(lpwm->clk);
> + unsigned long long base_unit, hz = 1000000000UL;
> + u32 ctrl;
> +
> + do_div(hz, period_ns);
> +
> + /* The equation is: base_unit = ((hz / c) * 65536) + correction */
> + base_unit = hz * 65536;
> + do_div(base_unit, c);
> + base_unit += PWM_DIVISION_CORRECTION;
> + if (base_unit > PWM_LIMIT)
> + return -EINVAL;
> +
> + if (duty_ns <= 0)
> + duty_ns = 1;
> + on_time_div = 255 - (255 * duty_ns / period_ns);
> +
> + ctrl = readl(lpwm->regs + PWM);
> + ctrl &= ~(PWM_BASE_UNIT_MASK | PWM_ON_TIME_DIV_MASK);
> + ctrl |= (u16) base_unit << PWM_BASE_UNIT_SHIFT;
> + ctrl |= on_time_div;
> + /* request PWM to update on next cycle */
> + ctrl |= PWM_SW_UPDATE;
> + writel(ctrl, lpwm->regs + PWM);
> +
Who handles the locking on all these functions. The pwm layer doesn't but
simnply exports stuff like pwm_config() directly to other bits of the
kernel so you are not guaranteed to be called via sysfs.
(This btw looks to be a problem with a pile of the other pwm drivers, and
with the pwm core code which doesn't properly lock its own handling of
pwm->duty_cycle and pwm->period in pwm_config(), nor pwm->polarity in
pwm_set_polarity).
I think the core config methods need some kind of locking ?
Alan
next prev parent reply other threads:[~2014-01-20 13:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-20 18:00 [PATCH] pwm: add support for Intel Low Power Subsystem PWM Chew Chiau Ee
2014-01-20 13:28 ` One Thousand Gnomes [this message]
2014-01-21 8:52 ` Mika Westerberg
2014-01-21 19:43 ` Thierry Reding
2014-01-22 9:31 ` Mika Westerberg
2014-02-18 12:05 ` Chew, Chiau Ee
2014-01-23 16:21 ` One Thousand Gnomes
2014-02-26 14:38 ` Thierry Reding
2014-02-27 9:01 ` Mika Westerberg
2014-02-27 9:03 ` Chew, Chiau Ee
2014-02-27 13:13 ` Mika Westerberg
2014-02-27 13:34 ` Chew, Chiau Ee
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=20140120132814.212929bd@alan.etchedpixels.co.uk \
--to=gnomes@lxorguk.ukuu.org.uk \
--cc=chiau.ee.chew@intel.com \
--cc=kean.ho.chew@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rebecca.swee.fun.chang@intel.com \
--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).