All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Clemens Gruber <clemens.gruber@pqgruber.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH] pwm-pca9685: Allow any of the 16 PWMs to be used as a GPIO
Date: Thu, 20 Oct 2016 11:07:59 +0300	[thread overview]
Message-ID: <20161020080759.GU1722@lahna.fi.intel.com> (raw)
In-Reply-To: <20161019225902.GA373@archie.localdomain>

On Thu, Oct 20, 2016 at 12:59:02AM +0200, Clemens Gruber wrote:
> It could be useful for boards that have a PWM chip but only need a few
> of its PWM channels for PWM output. Then they could use the others as
> GPOs. This issue has not come up in any of my projects yet, but I just
> found out that this topic did come up once before, about 4 years ago:
> http://www.spinics.net/lists/linux-omap/msg82913.html
> 
> So there are (at least) two problems if we move it to pwm core:
> 
> 1) Which period to use?
> 
> If we can't get a default period from the hardware or the driver, do we
> need something like the following in the devicetree:
> 
> mypwmgpios: pwm-as-gpio {
> 	compatible = "pwm-as-gpio";
> 	pwms = <&pwmchip1 0 PERIOD>, <&pwmchip1 1 PERIOD>;
> };
> 
> And then use it as follows:
> gpio-foo = <&mypwmgpios 0 GPIO_ACTIVE_HIGH>;
> gpio-bar = <&mypwmgpios 1 GPIO_ACTIVE_HIGH>;
> 
> ?

How about adding a callback to struct pwm_ops: gpio_set() and if that is
implemented by the driver, the core will export a GPIO chip and expects
the driver to be able to set the default period (or better override the
whole PWM functionality as PCA9685 can do).

That also is not tied to DT (Galileo is an ACPI system).

> 2) Are there PWM chips that toggle one time before keeping the level?
> 
> This would be pretty bad. One possibility would be a blacklist for the
> known pwm chips with this behavior?

..or do the above and let each driver to implement that hook only if it
is actually capable of doing that.

> The more I think about it, the more I like your pca9685-specific
> solution, where we can use: gpio-foo = <&pwmchip1 0 GPIO_ACTIVE_HIGH>;
> And the period is not even needed for the PCA9685 because the PWM
> control is elegantly bypassed.

Indeed :)

> Maybe there is a way to keep it as simple to use in the devicetree and
> allow other PWM drivers to use it iff they have a known default period
> and do not toggle? So the driver tells the pwm core the default period
> and if he can act as gpio controller, but the pwm core creates it?

Unfortunately we can't use DT in Galileo but that gpio_set() callback, I
suggest above, should work regardless of the underlying firmware
interface.

  reply	other threads:[~2016-10-20  8:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 14:40 [PATCH] pwm-pca9685: Allow any of the 16 PWMs to be used as a GPIO Mika Westerberg
2016-09-20 21:46 ` Linus Walleij
2016-10-19 18:56 ` Mika Westerberg
2016-10-19 20:05   ` Clemens Gruber
2016-10-19 20:28     ` Mika Westerberg
2016-10-19 22:59       ` Clemens Gruber
2016-10-20  8:07         ` Mika Westerberg [this message]
2016-10-20 10:45   ` Thierry Reding
2016-10-20 11:18     ` Mika Westerberg
2016-10-20 12:51       ` Thierry Reding
2016-10-20 12:56         ` Andy Shevchenko
2016-10-20 13:01         ` Mika Westerberg
2016-10-20 21:50           ` Thierry Reding
2016-10-21 12:23             ` Mika Westerberg
2016-10-31 11:42               ` Mika Westerberg
2016-12-01  7:28                 ` Mika Westerberg
2016-10-20 13:08         ` Clemens Gruber
2016-10-20 21:52           ` Thierry Reding
2016-10-23 10:23     ` Linus Walleij
2017-01-18 10:41 ` Thierry Reding

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=20161020080759.GU1722@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=clemens.gruber@pqgruber.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-pwm@vger.kernel.org \
    --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 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.