Skip to contentSkip to conversation

Determining wich PWM to use

DISCUSSION Johannes Thumshirn 2 participants 3 messages Jul 27, 2013 – Aug 4, 2013 PWM

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 5 lines · 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?

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.

Quoted 4 lines

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.

Quoted 2 lines

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

#2 lore raw
Quoted 26 lines · Thierry Reding
Quoted 5 lines · 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?

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.

Quoted 4 lines

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.

Quoted 2 lines

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

Quoted 6 lines

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