All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"Bartosz Golaszewski" <bgolaszewski@baylibre.com>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	linux-pwm@vger.kernel.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH] gpio: pca953x: Add Maxim MAX7313 PWM support
Date: Mon, 4 Nov 2019 16:11:03 +0100	[thread overview]
Message-ID: <20191104161103.64995b8a@xps13> (raw)
In-Reply-To: <CAHp75VemkA7kap0O7=iACX4cD5_r6QXaLF6nS8R94ErStK0DwA@mail.gmail.com>

Hi Linus,

Andy Shevchenko <andy.shevchenko@gmail.com> wrote on Tue, 15 Oct 2019
17:55:33 +0300:

> On Tue, Oct 15, 2019 at 5:30 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >
> > Hi Andy,
> >
> > Thanks for the feedback.
> >
> > Andy Shevchenko <andy.shevchenko@gmail.com> wrote on Mon, 14 Oct 2019
> > 20:59:01 +0300:
> >  
> > > On Mon, Oct 14, 2019 at 4:09 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:  
> > > >
> > > > The MAX7313 chip is fully compatible with the PCA9535 on its basic
> > > > functions but can also manage the intensity on each of its ports with
> > > > PWM. Each output is independent and may be tuned with 16 values (4
> > > > bits per output). The period is always 32kHz, only the duty-cycle may
> > > > be changed. One can use any output as GPIO or PWM.  
> > >
> > > Can we rather not contaminate driver with this?
> > >
> > > Just register a separate PWM driver and export its functionality to
> > > GPIO, or other way around (in the latter case we actually have PCA8685
> > > which provides a GPIO fgunctionality).
> > >  
> >
> > I understand your concern but I am not sure to understand which
> > solution you have in mind. In the former case, could you explain a bit
> > more what you are thinking about? Would linking the PWM support with
> > the GPIO driver (code would be located in another .c file) work for
> > you? Or maybe you would prefer an MFD on top of the GPIO driver?
> >
> > As for the later case, I am not willing to re-implement GPIO support in
> > an alternate driver for an already supported chip, it is too much work
> > for the time I can spend on it.  
> 
> 
> drivers/pwm/pwm-max7313.c:
> 
> probe(platform_device)
> {
>   struct regmap = pdata;
>   ...
> }
> 
> --- 8< --- 8< ---
> drivers/gpio/gpio-pca953x.c:
> 
> probe()
> {
>   struct regmap rm;
> ...
>   if (dev_has_pwm)
>    pca953x_register_pwm_driver(rm);
> ...
> }
> 
> In the above regmap may be replaced with some (shared) container.
> 
> Or other way around. PWM registers GPIO (which actually I prefer since
> we have PCA9685 case where PWM provides GPIO functionality, though via
> different means)
> 

Can I have your input on this proposal?

On one hand I agree that the GPIO driver is already quite big due to
its genericity and the amount of controllers it supports, on the other
hand:
1/ Registering a PWM driver from the GPIO core seems strange. Maybe
registering a platform device could do the trick but I am not convinced
it is worth the trouble.
2/ Putting the PWM logic in the drivers/pwm/ directory is not very
convenient as the object file will have to be embedded within the GPIO
one; this line in drivers/gpio/Makefile would be horrible:
... += gpio-pca953x.o ../pwm/pwm-max7313.o (not even sure it works)
3/ In any cases, the regmap's ->readable_reg(), ->writable_reg()
callbacks shall be tweaked to turn the PWM registers accessible, so we
would still have PWM related code in the PCA953x GPIO driver.

In the end, I wonder if keeping everything in one file is not better?
Eventually I can create a separate file and fill it with just the PWM
helpers/hooks. Please advise on the better solution for you, I'll wait
your feedback before addressing Thierry Reding's other review and
resubmit.


Thanks,
Miquèl

  reply	other threads:[~2019-11-04 15:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 12:48 [PATCH] gpio: pca953x: Add Maxim MAX7313 PWM support Miquel Raynal
2019-10-14 13:10 ` Thierry Reding
2019-10-14 15:53 ` kbuild test robot
2019-10-14 15:53   ` kbuild test robot
2019-10-14 15:53   ` kbuild test robot
2019-10-14 17:59 ` Andy Shevchenko
2019-10-15 14:30   ` Miquel Raynal
2019-10-15 14:55     ` Andy Shevchenko
2019-11-04 15:11       ` Miquel Raynal [this message]
2019-11-04 15:32         ` Bartosz Golaszewski
2019-11-04 20:33           ` Uwe Kleine-König
2019-11-05  7:06             ` Andy Shevchenko
2019-11-05  9:01               ` Miquel Raynal
2019-11-05  9:08                 ` Andy Shevchenko
2019-11-05 14:44                   ` Miquel Raynal

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=20191104161103.64995b8a@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.