From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ajit Pal <ajitpal.singh-qxv4g6HH51o@public.gmane.org>
Cc: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"kernel-F5mvAk5X5gdBDgjK7y7TUQ@public.gmane.org"
<kernel-F5mvAk5X5gdBDgjK7y7TUQ@public.gmane.org>,
"linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Maxime COQUELIN <maxime.coquelin-qxv4g6HH51o@public.gmane.org>,
Patrice CHOTARD <patrice.chotard-qxv4g6HH51o@public.gmane.org>,
"srinivas.kandagatla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<srinivas.kandagatla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 6/7] pwm: st: Add new driver for ST's PWM IP
Date: Sat, 21 Jun 2014 00:27:13 +0200 [thread overview]
Message-ID: <20140620222712.GB29400@mithrandir> (raw)
In-Reply-To: <53A2F342.7030606-qxv4g6HH51o@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 4076 bytes --]
On Thu, Jun 19, 2014 at 07:57:14PM +0530, Ajit Pal wrote:
> On Thursday 19 June 2014 02:14 PM, Lee Jones wrote:
> >On Thu, 19 Jun 2014, Thierry Reding wrote:
> >>On Wed, Jun 18, 2014 at 03:52:51PM +0100, Lee Jones wrote:
[...]
> >>>+ cdata->max_prescale + 1, sizeof(unsigned long),
> >>>+ st_pwm_cmp_periods);
> >>>+ if (!found) {
> >>>+ dev_err(dev, "failed to find matching period\n");
> >>>+ return -EINVAL;
> >>>+ }
> >>>+
> >>>+ prescale = found - &pc->pwm_periods[0];
> >>
> >>This is somewhat unconventional. None of the other drivers precompute
> >>possible periods and I'm not convinced that it's an advantage. Setting
> >>the period (and configuring the PWM in general) is a fairly uncommon
> >>operation.
> >
> >Another one for Ajit I feel.
>
> For ST PWM IP, the PWM period is fixed to 256 local clock pulses.There is no
> register interface to select PWM periods.To change the period we have to
> change the prescaler.
> We precompute the possible periods, so as to avoid the calculations
> everytime the .config function is called. Based upon a matching period we
> then select the prescaler.
> Sorry but why do you think precomputing is not helpful ?
Mostly I dislike it here because it sticks out as nobody else is doing
it. Secondly I'm not convinced that it gives you much of a performance
gain since the computations aren't that involved and typically the
period isn't changed all that often.
Also computing the value directly in .config() makes the code much
easier to follow.
> >>>+static int st_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
> >>>+{
> >>>+ struct st_pwm_chip *pc = to_st_pwmchip(chip);
> >>>+ struct device *dev = pc->dev;
> >>>+ int ret;
> >>>+
> >>>+ ret = clk_enable(pc->clk);
> >>>+ if (ret)
> >>>+ return ret;
> >>>+
> >>>+ ret = regmap_field_write(pc->pwm_en, 1);
> >>>+ if (ret)
> >>>+ dev_err(dev, "%s,pwm_en write failed\n", __func__);
>
> >>
> >>This error message is somewhat cryptic, perhaps:
> >>
> >> "failed to enable PWM"
> >
> >Agreed. I also can't believe I missed that nasty __func__ too.
> >
> >>? Also what implications does this have on controllers with multiple
> >>channels?
> >
> >I believe this enables both channels, but I'm sure Ajit will correct
> >me if I'm wrong.
>
> Yes it enables all channels.Unfortunately we do not have the facility to
> enable/disable individual channels on the ST PWM IP.
That's bad. If you can't control them separately then there's no way you
can guarantee the semantics of the PWM framework.
> >>>+ dev_dbg(dev, "pwm counter :%u\n", val);
> >>>+
> >>>+ clk_disable(pc->clk);
> >>>+}
> >>>+
> >>>+static const struct pwm_ops st_pwm_ops = {
> >>>+ .config = st_pwm_config,
> >>>+ .enable = st_pwm_enable,
> >>>+ .disable = st_pwm_disable,
> >>>+ .owner = THIS_MODULE,
> >>>+};
> >>>+
> >>>+static int st_pwm_probe_dt(struct st_pwm_chip *pc)
> >>>+{
> >>>+ struct device *dev = pc->dev;
> >>>+ const struct reg_field *reg_fields;
> >>>+ struct device_node *np = dev->of_node;
> >>>+ struct st_pwm_compat_data *cdata = pc->cdata;
> >>>+ u32 num_chan;
> >>>+
> >>>+ of_property_read_u32(np, "st,pwm-num-chan", &num_chan);
> >>>+ if (num_chan)
> >>>+ cdata->num_chan = num_chan;
> >>
> >>I don't like this very much. What influences the number of channels? Is
> >>it that specific SoC revisions have one and others have two?
> >
> >Ajit?
> >
> Depends on the board type on which the SoC is used.
I don't understand. How can the board influence the number of PWM
channels that the SoC supports? It does make sense for a board to define
how many of them are actually *used*, but that's nothing that DT should
contain nor that the driver should care about. The driver (and DT for
that matter) should expose the hardware block's full capabilities. The
use-case is what should determine what's used and what not.
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-06-20 22:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 14:52 [PATCH 1/7] ARM: stih407: Add DT nodes for for PWM Lee Jones
2014-06-18 14:52 ` [PATCH 2/7] ARM: stih416: Add Pinctrl settings " Lee Jones
2014-06-18 14:52 ` [PATCH 3/7] ARM: stih416: Add DT nodes " Lee Jones
2014-06-18 15:08 ` Gabriel Fernandez
2014-06-18 15:17 ` Lee Jones
2014-06-18 15:28 ` [PATCH v2 " Lee Jones
2014-06-18 14:52 ` [PATCH 4/7] ARM: stih416-b2020e: Enable PWM on the B2020 Rev-E Lee Jones
2014-06-19 9:05 ` [STLinux Kernel] " Peter Griffin
2014-06-19 9:20 ` Lee Jones
2014-06-19 10:12 ` Peter Griffin
2014-06-19 10:59 ` Maxime Coquelin
2014-06-19 11:22 ` Lee Jones
2014-06-19 13:29 ` Peter Griffin
2014-06-18 14:52 ` [PATCH 5/7] ARM: multi_v7_defconfig: Enable ST's PWM driver Lee Jones
2014-06-18 14:52 ` [PATCH 6/7] pwm: st: Add new driver for ST's PWM IP Lee Jones
2014-06-18 23:11 ` Thierry Reding
2014-06-19 8:44 ` Lee Jones
2014-06-19 11:32 ` Russell King - ARM Linux
2014-06-19 14:27 ` Ajit Pal
[not found] ` <53A2F342.7030606-qxv4g6HH51o@public.gmane.org>
2014-06-20 22:27 ` Thierry Reding [this message]
2014-06-20 22:16 ` Thierry Reding
2014-06-18 14:52 ` [PATCH 7/7] pwm: st: Supply Device Tree binding documentation " Lee Jones
2014-06-18 15:08 ` Gabriel Fernandez
2014-06-18 15:16 ` Lee Jones
2014-06-18 15:29 ` [PATCH v2 " Lee Jones
2014-06-18 15:07 ` [PATCH 1/7] ARM: stih407: Add DT nodes for for PWM Gabriel Fernandez
2014-06-18 15:16 ` Lee Jones
2014-06-18 15:26 ` [PATCH v2 " Lee Jones
2014-06-19 8:38 ` [STLinux Kernel] [PATCH " Peter Griffin
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=20140620222712.GB29400@mithrandir \
--to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=ajitpal.singh-qxv4g6HH51o@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=kernel-F5mvAk5X5gdBDgjK7y7TUQ@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pwm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=maxime.coquelin-qxv4g6HH51o@public.gmane.org \
--cc=patrice.chotard-qxv4g6HH51o@public.gmane.org \
--cc=srinivas.kandagatla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).