linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Determining wich PWM to use
@ 2013-07-27 10:18 Johannes Thumshirn
  2013-08-04 11:03 ` Thierry Reding
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2013-07-27 10:18 UTC (permalink / raw)
  To: linux-pwm; +Cc: Johannes Thumshirn

Hi list,

I'm currently working on a pwm driver for the BCM2853 (the SoC used on the
RaspberryPi). It has two PWM modules, so my question is, how do I determine
which PWM to use in the .enable, .disable and .configure functions?

If someone wants to have have a look at the preliminary code (far from being
submittable and only compile tested) it can be found here:

https://github.com/morbidrsa/linux/blob/rpi-pwm/drivers/pwm/pwm-bcm2835.c

2nd short question, is it considered good practice to encapsulate registers in
structs? I've seen this a lot on powerpc code.

Thanks for your help.

Johannes

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Determining wich PWM to use
  2013-07-27 10:18 Determining wich PWM to use Johannes Thumshirn
@ 2013-08-04 11:03 ` Thierry Reding
  2013-08-04 18:51   ` Johannes Thumshirn
  0 siblings, 1 reply; 3+ messages in thread
From: Thierry Reding @ 2013-08-04 11:03 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: linux-pwm

[-- Attachment #1: Type: text/plain, Size: 1390 bytes --]

On Sat, Jul 27, 2013 at 12:18:24PM +0200, Johannes Thumshirn wrote:
> Hi list,
> 
> I'm currently working on a pwm driver for the BCM2853 (the SoC used on the
> RaspberryPi). It has two PWM modules, so my question is, how do I determine
> which PWM to use in the .enable, .disable and .configure functions?

It depends on what you mean by "two PWM modules". Does it have one
controller with two PWM outputs or does it have two controllers with one
or more outputs?

If you have one controller with multiple outputs, which seems to be the
case looking at the driver, then the struct pwm_device's .hwpwm field
contains the per-chip index of the PWM channel.

> If someone wants to have have a look at the preliminary code (far from being
> submittable and only compile tested) it can be found here:
> 
> https://github.com/morbidrsa/linux/blob/rpi-pwm/drivers/pwm/pwm-bcm2835.c

From a quick glance that looks pretty good already. Feel free to send it
to the mailing list for review anytime.

> 2nd short question, is it considered good practice to encapsulate registers in
> structs? I've seen this a lot on powerpc code.

It's not very common. I certainly prefer the standard way of using
writel(value, base + offset) and readl(base + offset), or a variation of
that using driver-specific accessors such as you've done in the above-
mentioned code.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Determining wich PWM to use
  2013-08-04 11:03 ` Thierry Reding
@ 2013-08-04 18:51   ` Johannes Thumshirn
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2013-08-04 18:51 UTC (permalink / raw)
  To: Thierry Reding; +Cc: linux-pwm

On Sun, Aug 04, 2013 at 01:03:47PM +0200, Thierry Reding wrote:
> On Sat, Jul 27, 2013 at 12:18:24PM +0200, Johannes Thumshirn wrote:
> > Hi list,
> > 
> > I'm currently working on a pwm driver for the BCM2853 (the SoC used on the
> > RaspberryPi). It has two PWM modules, so my question is, how do I determine
> > which PWM to use in the .enable, .disable and .configure functions?
> 
> It depends on what you mean by "two PWM modules". Does it have one
> controller with two PWM outputs or does it have two controllers with one
> or more outputs?
> 
> If you have one controller with multiple outputs, which seems to be the
> case looking at the driver, then the struct pwm_device's .hwpwm field
> contains the per-chip index of the PWM channel.
> 
> > If someone wants to have have a look at the preliminary code (far from being
> > submittable and only compile tested) it can be found here:
> > 
> > https://github.com/morbidrsa/linux/blob/rpi-pwm/drivers/pwm/pwm-bcm2835.c
> 
> From a quick glance that looks pretty good already. Feel free to send it
> to the mailing list for review anytime.
> 
> > 2nd short question, is it considered good practice to encapsulate registers in
> > structs? I've seen this a lot on powerpc code.
> 
> It's not very common. I certainly prefer the standard way of using
> writel(value, base + offset) and readl(base + offset), or a variation of
> that using driver-specific accessors such as you've done in the above-
> mentioned code.
> 
> Thierry


Thanks. I'll try to get the code submittable till the end of the moth.

Johannes

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-04 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-27 10:18 Determining wich PWM to use Johannes Thumshirn
2013-08-04 11:03 ` Thierry Reding
2013-08-04 18:51   ` Johannes Thumshirn

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).