devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Thierry Reding <thierry.reding@avionic-design.de>
Cc: Grant Likely <grant.likely@secretlab.ca>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Rob Landley <rob@landley.net>,
	devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	linux-omap@vger.kernel.org
Subject: Re: [PATCH] gpio: New driver for GPO emulation using PWM generators
Date: Thu, 29 Nov 2012 13:18:11 +0100	[thread overview]
Message-ID: <50B75283.6010207@ti.com> (raw)
In-Reply-To: <20121128193006.GB23444@avionic-0098.adnet.avionic-design.de>

On 11/28/2012 08:30 PM, Thierry Reding wrote:
> I must say I'm not terribly thrilled to integrate something like this
> into the PWM subsystem.

I agree. I would not really want to add my name to something like this either...

> I wish hardware engineers wouldn't come up with such designs.

I have checked and rechecked the schematics and datasheets. Still can not
understand how anyone would come to this HW solution (when the twl4030 have at
least 4 unused GPIO line left unconnected).

> But since this seems to be a real use-case, if we want to
> support it we should try and find the "right" solution.
> 
> Reading the above sounds overly complicated. Couldn't we, instead of
> instantiating an extra driver, just register a GPIO chip if a chip wants
> to support this functionality? Where the GPIO chip's request callback
> requests the given PWM so that it cannot be used elsewhere? The
> direction_input callback would need to always fail and the set callback
> can configure the PWM either to 0% or 100% duty-cycle depending on the
> desired output value.

The original driver was doing exactly this. Basically I have added a GPO chip
(which was just a translator from PWM to GPO). In DT it looked like this:

twl_pwm: pwm {
	compatible = "ti,twl4030-pwmled";
	#pwm-cells = <2>;
};

pwm_gpo1: gpo1 {
	compatible = "pwm-gpo";
	#gpio-cells = <1>;
	gpio-controller;
	pwms = <&twl_pwm 0 7812500>;
	pwm-names = "nUSBHOST_PWR_EN";
};

user@1 {
	compatible = "example,testuser";
	gpios = <&pwm_gpo1 0>;
};

When we boot with DT the pwm_get() needs pwms phandle from the device you are
calling it in order to find the PWM in question. If we do not have DT entry
for the GPO driver, we need to build up a pwm_lookup table to ensure that the
pwm_get() will find the PWM we want to handle.

We could implement the GPIO related code under for example
drivers/pwm/pwm-as-gpo.c
But then I should merge the code from drivers/gpio/gpio-pwm.c inside.
This is not nice either since we will have a GPIO driver living under pwm/
directory and I'm not sure how this would use the pwm API when the GPO
functionality is requested.

-- 
Péter

  reply	other threads:[~2012-11-29 12:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-22 13:42 [PATCH] gpio: New driver for GPO emulation using PWM generators Peter Ujfalusi
2012-11-23  7:55 ` Grant Likely
2012-11-23  9:13   ` Peter Ujfalusi
2012-11-23  9:44     ` Peter Ujfalusi
2012-11-26 10:30       ` Lars-Peter Clausen
2012-11-26 11:36         ` Peter Ujfalusi
2012-11-26 15:46       ` Grant Likely
2012-11-28  8:54         ` Peter Ujfalusi
     [not found]           ` <50B5D161.6010200-l0cyMroinI0@public.gmane.org>
2012-11-28 19:30             ` Thierry Reding
2012-11-29 12:18               ` Peter Ujfalusi [this message]
2012-11-28 21:02           ` Lars-Peter Clausen
2012-11-29 16:10           ` Grant Likely
2012-11-30  6:47             ` Thierry Reding
2012-11-30 10:20               ` Grant Likely
2012-11-30 10:47                 ` Peter Ujfalusi
2012-11-30 11:04                 ` Thierry Reding
2012-11-30 11:09                   ` Grant Likely
2012-11-30 11:00             ` Peter Ujfalusi

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=50B75283.6010207@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=rob@landley.net \
    --cc=thierry.reding@avionic-design.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 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).