[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190117072841.e57tilkbrtnifss4@pengutronix.de>
Date: Thu, 17 Jan 2019 08:28:41 +0100
From: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
To: Yash Shah <yash.shah@...ive.com>
Cc: mark.rutland@....com, linux-pwm@...r.kernel.org,
devicetree@...r.kernel.org, Palmer Dabbelt <palmer@...ive.com>,
linux-kernel@...r.kernel.org, robh+dt@...nel.org,
Sachin Ghadi <sachin.ghadi@...ive.com>,
Thierry Reding <thierry.reding@...il.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
linux-riscv@...ts.infradead.org
Subject: Re: [PATCH 2/2] pwm: sifive: Add a driver for SiFive SoC PWM
Hello,
On Thu, Jan 17, 2019 at 12:15:38PM +0530, Yash Shah wrote:
> On Wed, Jan 16, 2019 at 10:16 PM Uwe Kleine-König
> <u.kleine-koenig@...gutronix.de> wrote:
> >
> > Hello,
> >
> > On Wed, Jan 16, 2019 at 04:40:42PM +0530, Yash Shah wrote:
> > > On Wed, Jan 16, 2019 at 3:30 AM Uwe Kleine-König
> > > <u.kleine-koenig@...gutronix.de> wrote:
> > > > On Fri, Jan 11, 2019 at 01:52:44PM +0530, Yash Shah wrote:
> > > > > Adds a PWM driver for PWM chip present in SiFive's HiFive Unleashed SoC.
> > > > >
> > > > > Signed-off-by: Wesley W. Terpstra <wesley@...ive.com>
> > > > > [Atish: Various fixes and code cleanup]
> > > > > Signed-off-by: Atish Patra <atish.patra@....com>
> > > > > Signed-off-by: Yash Shah <yash.shah@...ive.com>
> > > > > ---
> > > > > drivers/pwm/Kconfig | 10 ++
> > > > > drivers/pwm/Makefile | 1 +
> > > > > drivers/pwm/pwm-sifive.c | 246 +++++++++++++++++++++++++++++++++++++++++++++++
> > > > > 3 files changed, 257 insertions(+)
> > > > > create mode 100644 drivers/pwm/pwm-sifive.c
> > > > >
> > > > > diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> > > > > index a8f47df..3bcaf6a 100644
> > > > > --- a/drivers/pwm/Kconfig
> > > > > +++ b/drivers/pwm/Kconfig
> > > > > @@ -380,6 +380,16 @@ config PWM_SAMSUNG
> > > > > To compile this driver as a module, choose M here: the module
> > > > > will be called pwm-samsung.
> > > > >
> > > > > +config PWM_SIFIVE
> > > > > + tristate "SiFive PWM support"
> > > > > + depends on OF
> > > > > + depends on COMMON_CLK
> > > >
> > > > I'd say add:
> > > >
> > > > depends on MACH_SIFIVE || COMPILE_TEST
> > > >
> > > > (I guess "MACH_SIFIVE" is wrong, but I assume you get what I mean.)
> > >
> > > As of now, MACH_SIFIVE/ARCH_SIFIVE isn't available.
> > > @Paul, Do you have any comments on this?
> >
> > If this is not going to be available at least protect it by
> >
> > depends RISCV || COMPILE_TEST
> >
> > > > I wonder if such an instance should be only a single PWM instead of
> > > > four. Then you were more flexible with the period lengths (using
> > > > pwmcfg.pwmzerocmp) and could do stuff like inverted and uninverted mode.
> > > >
> > > > I didn't understand how the deglitch logic works yet. Currently it is
> > > > not used which might result in four edges in a single period (which is
> > > > bad).
> > >
> > > I can enable deglitch logic by just setting a bit (BIT_PWM_DEGLITCH) in
> > > REG_PWMCFG. Will do that.
> >
> > This only works for the first pwm output though.
I mixed this up with pwmzerocmp; deglitch should work on all four
outputs.
> > > > > +struct sifive_pwm_device {
> > > > > + struct pwm_chip chip;
> > > > > + struct notifier_block notifier;
> > > > > + struct clk *clk;
> > > > > + void __iomem *regs;
> > > > > + unsigned int approx_period;
> >
> > When thinking about this a bit more, I think the better approach would
> > be to let the consumer change the period iff there is only one consumer.
> > Then you can drop that approx-period stuff and the result is more
> > flexible. (Having said that I still prefer making the driver provide
> > only a single PWM with the ability to have periods other than powers of
> > two.)
> >
>
> I am not confident about the implementation of the way you are suggesting.
> As of now, I am going to stick with the current implementation.
The idea is to count the users using the .request and .free callbacks.
Iff there is exactly one, allow changes to period.
But please consider moving to an abstraction that only provides a single
pwm instead.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Powered by blists - more mailing lists