[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121008135008.GB26525@avionic-0098.mockup.avionic-design.de>
Date: Mon, 8 Oct 2012 15:50:08 +0200
From: Thierry Reding <thierry.reding@...onic-design.de>
To: "Philip, Avinash" <avinashphilip@...com>
Cc: "grant.likely@...retlab.ca" <grant.likely@...retlab.ca>,
"rob.herring@...xeda.com" <rob.herring@...xeda.com>,
"rob@...dley.net" <rob@...dley.net>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"devicetree-discuss@...ts.ozlabs.org"
<devicetree-discuss@...ts.ozlabs.org>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"Nori, Sekhar" <nsekhar@...com>,
"Hebbar, Gururaja" <gururaja.hebbar@...com>
Subject: Re: [PATCH 2/2] pwm: pwm-tiehrpwm: Add device-tree binding support
for EHRPWM driver
On Mon, Oct 08, 2012 at 01:31:20PM +0000, Philip, Avinash wrote:
> On Tue, Oct 02, 2012 at 11:41:43, Thierry Reding wrote:
> > On Wed, Sep 26, 2012 at 04:57:43PM +0530, Philip, Avinash wrote:
[...]
> > > +- reg: physical base address and size of the registers map. For am33xx,
> > > + 2 register maps are present (EHRPWM register space & PWM subsystem common
> > > + config space). Order should be maintained with EHRPWM register map as first
> > > + entry & PWM subsystem common config space as second entry.
> > > +
> > > +Optional properties:
> > > +- ti,hwmods: Name of the hwmod associated to the EHRPWM:
> > > + "ehrpwm<x>", <x> being the 0-based instance number from the HW spec
> >
> > I don't see where this property is used. There is no code in this patch
> > that parses it.
>
> This data used by omap_hwmod layer to create platform devices. This is part
> of omap hwmod implementation.
Okay. I've heard about hwmod but I wasn't aware of how it was used in
the context of device tree.
> > > +static struct pwm_device *of_ehrpwm_xlate(struct pwm_chip *chip,
> > > + const struct of_phandle_args *args)
> > > +{
> > > + struct pwm_device *pwm;
> > > +
> > > + if (chip->of_pwm_n_cells < PWM_CELL_SIZE)
> > > + return ERR_PTR(-EINVAL);
> > > +
> > > + if (args->args[0] >= chip->npwm)
> > > + return ERR_PTR(-EINVAL);
> > > +
> > > + pwm = pwm_request_from_chip(chip, args->args[0], NULL);
> > > + if (IS_ERR(pwm))
> > > + return pwm;
> > > +
> > > + pwm_set_period(pwm, args->args[1]);
> > > + pwm_set_polarity(pwm, args->args[2]);
> > > + return pwm;
> > > +}
> >
> > This is an exact duplicate of the ECAP's of_xlate(). Maybe we should
> > make this part of the PWM core. If so it is probably safer to define the
> > values for the third cell as flags, where the polarity is encoded in bit
> > 0, and make the function handle this accordingly to allow other bits to
> > be added in the future.
>
> Custom of_xlate support is provided as suggested while the discussion of
> "Adding support for configuring polarity in PWM framework".
> https://lkml.org/lkml/2012/7/16/177
>
> without custom of_xlate() support, PWM drivers has to populate
> chip->of_pwm_n_cells = x;
> as this is hard coded to 2 in pwm/core.c.
>
> if (!chip->of_xlate) {
> chip->of_xlate = of_pwm_simple_xlate;
> chip->of_pwm_n_cells = 2;
It's absolutely fine to provide a custom implementation. All I'm saying
is that we should add a 3-cell variant of of_pwm_simple_xlate() instead
of having to duplicate it for every chip that supports inversion of the
polarity.
Maybe something like of_pwm_xlate_with_flags()?
Thierry
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists