All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill Gatliff <bgat@billgatliff.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: linux-embedded@vger.kernel.org,
	Mike Frysinger <vapier.adi@gmail.com>,
	David Brownell <dbrownell@users.sourceforge.net>
Subject: Re: [PATCH 0/6] Generic PWM API implementation
Date: Tue, 17 Nov 2009 09:39:18 -0600	[thread overview]
Message-ID: <4B02C3A6.5030000@billgatliff.com> (raw)
In-Reply-To: <fa686aa40911131108o301efa1ew5c0ab31184aa7f75@mail.gmail.com>

Grant Likely wrote:
> Hi Bill
>
> On Wed, Oct 15, 2008 at 11:14 AM, Bill Gatliff <bgat@billgatliff.com> wrote:
>   
>> This series implements a Generic PWM Device API, including reference
>> implementations for the Atmel PWMC device, an LED device, and an LED
>> trigger.  It is based on linux-2.6.27.
>>     
> [...]
>   
>> The implementation of the Generic PWM Device API is structurally
>> similar to the generic GPIO API, except that the PWM code uses
>> platform bus_id strings instead of integers to identify target
>> deviices.  A configuration structure is also provided, both to
>> facilitate atomic hardware state changes and so that the API can be
>> extended in a source-code-compatible way to accomodate devices with
>> features not anticipated by the current code.
>>     
>
> Hey Bill,
>
> I'm concerned about the approach taken here.  As I understand it, the
> PWM signals are very similar to GPIOs in that each PWM device controls
> an external signal line, just like GPIO lines.  The difference being
> that PWMs cannot do input, and has additional capabilities (can be
> programmed with a signal; not just on/off/tristate).  Actually, many
> GPIOs have these properties too.  I've got a part with output-only
> gpios, and gpio devices that also have a PWM.
>   


It's true that PWM signals can be emitted via GPIO pins, and in fact the
API code I submitted uses the GPIO API combined with an hrtimer to
generate a low-speed PWM output.

It's also true that things like LEDs might want to be driven by PWM
signals, and indeed LEDs can also be driven by GPIO pins.

Finally, it's accurate to say that a lot of microcontrollers multiplex
GPIO functions onto pins that also provide PWM functionality.

But in my opinion, none of the above means that the PWM API and GPIO API
should be coupled at the interface abstraction.  All it means is that in
some cases, one implementation might be able to "stand in" as an
embodiment of the other's interface.  And we all agree on that for PWM
and GPIO.

The reason I think that PWM merits its own API is because I want the
users of the interface to be able to treat it as a PWM-only metaphor. 
Behind the scenes, we may in fact have a connection with the GPIO
interface--- and in fact we already do with my code.  But PWM generation
can also come from timer/counter peripherals having a compare/match
capability, from true PWM generation hardware (which are in most cases
just three tightly-coupled timer/counters with compare/match hardware),
as well as from standalone chips that are controlled over an I2C or SPI
interface.  The latter example is in fact the initial motivation for the
code, even though at the moment I don't have any patches available to
submit because the devices in question are 8-bit microcontrollers
running custom firmware.

Given a PWM-capable chip that you control over an I2C or SPI interface,
I don't think anyone would argue that such chips should be viewed as an
extension of the SPI or I2C APIs just because the chips use those
communications protocols.  I think it's a similar argument for PWM and GPIO.

Overall, I think your question is a very good one and it's one that I
asked myself early on.  And it's a question that we should ask for EVERY
new interface abstraction that's developed for kernel-facing or
application-facing users.


> What is the reason for bringing in an entirely new framework instead
> of extending the GPIO API or gpiolib?  I'm not too excited about
> having two entirely different frameworks for what basically boils down
> to "numbered signal pins".
>   

I hope my reasoning is clear.  I might not be right, but at least you
know what my thoughts are.  Questions, comments and flames welcome!


b.g.

-- 
Bill Gatliff
bgat@billgatliff.com


  parent reply	other threads:[~2009-11-17 15:39 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-15 18:14 [PATCH 0/6] Generic PWM API implementation Bill Gatliff
2008-10-15 18:14 ` [PATCH 1/6] [PWM] " Bill Gatliff
2008-10-17 15:59   ` Mike Frysinger
2008-11-04 20:16     ` Bill Gatliff
2008-11-04 20:51       ` Mike Frysinger
2008-11-04 23:55       ` David Brownell
2008-11-05  0:17         ` Mike Frysinger
2008-11-05  2:59           ` Bill Gatliff
2008-11-05  5:08           ` David Brownell
2008-11-05  2:56         ` Bill Gatliff
2008-10-15 18:14 ` [PATCH 2/6] [PWM] Changes to existing include/linux/pwm.h to adapt to generic PWM API Bill Gatliff
2008-10-15 18:14 ` [PATCH 3/6] [PWM] Documentation Bill Gatliff
2008-10-15 18:14 ` [PATCH 4/6] [PWM] Driver for Atmel PWMC peripheral Bill Gatliff
2008-10-15 18:14 ` [PATCH 5/6] [PWM] Install new Atmel PWMC driver in Kconfig, expunge old one Bill Gatliff
2008-10-15 18:14 ` [PATCH 6/6] [PWM] New LED driver and trigger that use PWM API Bill Gatliff
2009-11-13 19:08 ` [PATCH 0/6] Generic PWM API implementation Grant Likely
2009-11-14  4:22   ` Mike Frysinger
2009-11-14  7:55     ` Grant Likely
2009-11-17  7:47       ` David Brownell
2009-11-17 15:48         ` Bill Gatliff
2009-11-17 16:53           ` David Brownell
2009-11-20 22:51             ` Grant Likely
2009-11-20 22:14         ` Grant Likely
2009-11-23 14:12           ` Bill Gatliff
2009-11-23 17:39             ` Grant Likely
2009-11-23 20:51               ` Albrecht Dreß
2009-11-28 21:38               ` David Brownell
2009-11-28 21:59               ` David Brownell
2009-11-17 15:45       ` Bill Gatliff
2009-11-17  8:27   ` David Brownell
2009-11-17 15:54     ` Bill Gatliff
2009-11-20 22:21     ` Grant Likely
2009-11-23 14:13       ` Bill Gatliff
2009-11-23 17:40         ` Grant Likely
2009-11-23 15:29       ` Mark Brown
2009-11-23 17:44         ` Grant Likely
2009-11-23 18:09           ` Mark Brown
2009-11-28 21:54             ` David Brownell
2009-11-17 15:39   ` Bill Gatliff [this message]
2009-11-20 22:49     ` Grant Likely
2009-11-28 21:28       ` David Brownell

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=4B02C3A6.5030000@billgatliff.com \
    --to=bgat@billgatliff.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-embedded@vger.kernel.org \
    --cc=vapier.adi@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.