pwm: add BCM2835 PWM driver
Subsystems (4)
PATCH v7 1/1 pwm: add BCM2835 PWM driver
Add pwm driver for Broadcom BCM2835 processor (Raspberry Pi)
---
Changed in v7:
- clean up the shameful clk_enable error handling introduced in v6
- clean up the code nits
Documentation/devicetree/bindings/pwm/pwm-bcm2835.txt new file +27 -0
@@ -0,0 +1,27 @@ +BCM2835 PWM controller (Raspberry Pi controller) + +Required properties: +- compatible: should be "brcm,bcm2835-pwm" +- reg: physical base address and length of the controller's registers +- clock: this clock defines the base clock frequency of the pwm +hardware system, the period and the duty_cycle of the pwm signal is a +multiple of the base period + +Examples: + +pwm@2020c000 { + compatible = "brcm,bcm2835-pwm"; + reg = <0x2020c000 0x28>; + clocks = <&clk_pwm>; +}; + +clocks { + .... + clk_pwm: pwm { + compatible = "fixed-clock"; + reg = <3>; + #clock-cells = <0>; + clock-frequency = <9200000>; + }; + .... +};
drivers/pwm/Kconfig +9 -0
@@ -29,6 +29,15 @@ menuconfig PWM if PWM +config PWM_BCM2835 + tristate "BCM2835 PWM support" + depends on ARCH_BCM2835 + help + PWM framework driver for BCM2835 controller (Raspberry Pi) + + To compile this driver as a module, choose M here: the module + will be called pwm-bcm2835 + config PWM_BFIN tristate "Blackfin PWM support" depends on BFIN_GPTIMERS
drivers/pwm/pwm-bcm2835.c new file +202 -0
202 lines not on this page · raw message
Quoted 14 lines · Bart Tanghe
Add pwm driver for Broadcom BCM2835 processor (Raspberry Pi)
Signed-off-by Bart Tanghe <[email protected]>---
Changed in v7:
- clean up the shamefulclk_enableerror handling introduced in v6
- clean up the code nitsDocumentation/devicetree/bindings/pwm/pwm-bcm2835.txt new file +0
-0
Documentation/devicetree/bindings/pwm/pwm-bcm2835.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/pwm/pwm-bcm2835.txt new file +8
-0@@ -0,0 +1,27 @@ +BCM2835 PWM controller (Raspberry Pi controller) + +Required properties: +- compatible: should be "brcm,bcm2835-pwm" +- reg: physical base address and length of the controller's registers +- clock: this clock defines the base clock frequency of the pwm +hardware system, the period and the duty_cycle of the pwm signal is a +multiple of the base period
This needs to document the #pwm-cells property. I can fix that up when applying, though.
Let's give Stephen and others a chance to give this another look.
Thierry
Quoted 27 lines · Thierry Reding
Quoted 14 lines · Bart Tanghe
Add pwm driver for Broadcom BCM2835 processor (Raspberry Pi)
Signed-off-by Bart Tanghe <[email protected]>---
Changed in v7:
- clean up the shamefulclk_enableerror handling introduced in v6
- clean up the code nitsDocumentation/devicetree/bindings/pwm/pwm-bcm2835.txt new file +0
-0Documentation/devicetree/bindings/pwm/pwm-bcm2835.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/pwm/pwm-bcm2835.txt new file +8
-0@@ -0,0 +1,27 @@ +BCM2835 PWM controller (Raspberry Pi controller) + +Required properties: +- compatible: should be "brcm,bcm2835-pwm" +- reg: physical base address and length of the controller's registers +- clock: this clock defines the base clock frequency of the pwm +hardware system, the period and the duty_cycle of the pwm signal is a +multiple of the base periodThis needs to document the #pwm-cells property. I can fix that up when applying, though.
Quoted 4 lines
Let's give Stephen and others a chance to give this another look.
Thierry
Perfect, thanks.
Bart
Quoted 1 line · Bart Tanghe
Add pwm driver for Broadcom BCM2835 processor (Raspberry Pi)
On Wed, Oct 08, 2014 at 12:14:32PM +0200, Bart Tanghe wrote:
[...]
Quoted 1 line
drivers/pwm/pwm-bcm2835.c +0
-0
[...]
drivers/pwm/pwm-bcm2835.c line 62
Quoted 7 lines
drivers/pwm/pwm-bcm2835.c +7
-0+static void bcm2835_pwm_free (struct pwm_chip *chip,struct pwm_device *pwm) +{ +struct bcm2835_pwm *pc =to_bcm2835_pwm (chip); +u32 value; + + value =readl (pc->base); + value &= (~DEFAULT_PWM_MODE << (PWM_CONTROL_STRIDE * pwm->hwpwm));
While applying I noticed this oddity. Is this meant to be:
value &= ~(DEFAULT_PWM_MODE << (PWM_CONTROL_STRIDE * pwm->hwpwm));
? That would match what's in bcm2835_pwm_request(). If so, what's the difference between DEFAULT_PWM_MODE and PWM_CONTROL_MASK? Is the value of a channel's field 0xff or 0x00 in the default mode?
The above indicates that it would be 0x00, in which case it might be better to just do...
value &= ~(PWM_CONTROL_MASK << (PWM_CONTROL_STRIDE * pwm->hwpwm));
... and get rid of DEFAULT_PWM_MODE.
No need to respin, I can fix this up when applying. Just let me know if that's actually the right thing to do.
Thierry
Quoted 6 lines · Thierry Reding
The above indicates that it would be
0x00, in which case it might be better to just do...value &= ~(PWM_CONTROL_MASK << (PWM_CONTROL_STRIDE * pwm->hwpwm));... and get rid of
DEFAULT_PWM_MODE.
Indeed, this has to be 0x00. PWM_CONTROL_MASK and DEFAULT_PWM_MODE are the same. I've declared DEFAULT_PWM_MODE because they have another meaning but the values are the same. You can definetly use
value &= ~(PWM_CONTROL_MASK << (PWM_CONTROL_STRIDE * pwm->hwpwm));
Bart