Skip to content

Commit 3f55ec4

Browse files
Phil Elwellpopcornmix
Phil Elwell
authored andcommitted
BCM270X_DT: Add pwm and pwm-2chan overlays
From the README entries: Legal pin,function combinations for each channel: PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0) 52,5(Alt1) PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1) N.B.: 1) Pin 18 is the only one available on all platforms, and it is the one used by the I2S audio interface. Pins 12 and 13 might be better choices on an A+, B+ or Pi2. 2) The onboard analogue audio output uses both PWM channels. 3) So be careful mixing audio and PWM. 4) Currently the clock must have been enabled and configured by other means. See: #756
1 parent b043787 commit 3f55ec4

File tree

8 files changed

+150
-1
lines changed

8 files changed

+150
-1
lines changed

arch/arm/boot/dts/bcm2708_common.dtsi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@
154154
status = "disabled";
155155
};
156156

157+
pwm: pwm@7e20c000 {
158+
compatible = "brcm,bcm2835-pwm";
159+
reg = <0x7e20c000 0x28>;
160+
clocks = <&clk_pwm>;
161+
#pwm-cells = <2>;
162+
status = "disabled";
163+
};
164+
157165
uart1: uart@7e215040 {
158166
compatible = "brcm,bcm2835-aux-uart", "ns16550";
159167
reg = <0x7e215040 0x40>;
@@ -279,6 +287,14 @@
279287
clock-output-names = "apb_pclk";
280288
clock-frequency = <126000000>;
281289
};
290+
291+
clk_pwm: clock@5 {
292+
compatible = "fixed-clock";
293+
reg = <3>;
294+
#clock-cells = <0>;
295+
clock-output-names = "pwm";
296+
clock-frequency = <100000000>;
297+
};
282298
};
283299

284300
__overrides__ {

arch/arm/boot/dts/overlays/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ dtb-$(RPI_DT_OVERLAYS) += mz61581-overlay.dtb
3535
dtb-$(RPI_DT_OVERLAYS) += piscreen-overlay.dtb
3636
dtb-$(RPI_DT_OVERLAYS) += pitft28-resistive-overlay.dtb
3737
dtb-$(RPI_DT_OVERLAYS) += pps-gpio-overlay.dtb
38+
dtb-$(RPI_DT_OVERLAYS) += pwm-overlay.dtb
39+
dtb-$(RPI_DT_OVERLAYS) += pwm-2chan-overlay.dtb
3840
dtb-$(RPI_DT_OVERLAYS) += rpi-dac-overlay.dtb
3941
dtb-$(RPI_DT_OVERLAYS) += rpi-display-overlay.dtb
4042
dtb-$(RPI_DT_OVERLAYS) += rpi-ft5406-overlay.dtb

arch/arm/boot/dts/overlays/README

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,47 @@ Load: dtoverlay=pps-gpio,<param>=<val>
410410
Params: gpiopin Input GPIO (default "18")
411411

412412

413+
Name: pwm
414+
Info: Configures a single PWM channel
415+
Legal pin,function combinations for each channel:
416+
PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0) 52,5(Alt1)
417+
PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
418+
N.B.:
419+
1) Pin 18 is the only one available on all platforms, and
420+
it is the one used by the I2S audio interface.
421+
Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
422+
2) The onboard analogue audio output uses both PWM channels.
423+
3) So be careful mixing audio and PWM.
424+
4) Currently the clock must have been enabled and configured
425+
by other means.
426+
Load: dtoverlay=pwm-2chan,<param>=<val>
427+
Load: dtoverlay=pwm,<param>=<val>
428+
Params: pin Output pin (default 18) - see table
429+
func Pin function (default 2 = Alt5) - see above
430+
clock PWM clock frequency (informational)
431+
432+
433+
Name: pwm-2chan
434+
Info: Configures both PWM channels
435+
Legal pin,function combinations for each channel:
436+
PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0) 52,5(Alt1)
437+
PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
438+
N.B.:
439+
1) Pin 18 is the only one available on all platforms, and
440+
it is the one used by the I2S audio interface.
441+
Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
442+
2) The onboard analogue audio output uses both PWM channels.
443+
3) So be careful mixing audio and PWM.
444+
4) Currently the clock must have been enabled and configured
445+
by other means.
446+
Load: dtoverlay=pwm-2chan,<param>=<val>
447+
Params: pin Output pin (default 18) - see table
448+
pin2 Output pin for other channel (default 19)
449+
func Pin function (default 2 = Alt5) - see above
450+
func2 Function for pin2 (default 2 = Alt5)
451+
clock PWM clock frequency (informational)
452+
453+
413454
Name: rpi-dac
414455
Info: Configures the RPi DAC audio card
415456
Load: dtoverlay=rpi-dac
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/dts-v1/;
2+
/plugin/;
3+
4+
/*
5+
This is the 2-channel overlay - only use it if you need both channels.
6+
7+
Legal pin,function combinations for each channel:
8+
PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0) 52,5(Alt1)
9+
PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
10+
11+
N.B.:
12+
1) Pin 18 is the only one available on all platforms, and
13+
it is the one used by the I2S audio interface.
14+
Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
15+
2) The onboard analogue audio output uses both PWM channels.
16+
3) So be careful mixing audio and PWM.
17+
*/
18+
19+
/ {
20+
fragment@0 {
21+
target = <&gpio>;
22+
__overlay__ {
23+
pwm_pins: pwm_pins {
24+
brcm,pins = <18 19>;
25+
brcm,function = <2 2>; /* Alt5 */
26+
};
27+
};
28+
};
29+
30+
fragment@1 {
31+
target = <&pwm>;
32+
__overlay__ {
33+
pinctrl-names = "default";
34+
pinctrl-0 = <&pwm_pins>;
35+
status = "okay";
36+
};
37+
};
38+
39+
__overrides__ {
40+
pin = <&pwm_pins>,"brcm,pins:0";
41+
pin2 = <&pwm_pins>,"brcm,pins:4";
42+
func = <&pwm_pins>,"brcm,function:0";
43+
func2 = <&pwm_pins>,"brcm,function:4";
44+
clock = <&clk_pwm>,"clock-frequency:0";
45+
};
46+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/dts-v1/;
2+
/plugin/;
3+
4+
/*
5+
Legal pin,function combinations for each channel:
6+
PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0) 52,5(Alt1)
7+
PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
8+
9+
N.B.:
10+
1) Pin 18 is the only one available on all platforms, and
11+
it is the one used by the I2S audio interface.
12+
Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
13+
2) The onboard analogue audio output uses both PWM channels.
14+
3) So be careful mixing audio and PWM.
15+
*/
16+
17+
/ {
18+
fragment@0 {
19+
target = <&gpio>;
20+
__overlay__ {
21+
pwm_pins: pwm_pins {
22+
brcm,pins = <18>;
23+
brcm,function = <2>; /* Alt5 */
24+
};
25+
};
26+
};
27+
28+
fragment@1 {
29+
target = <&pwm>;
30+
__overlay__ {
31+
pinctrl-names = "default";
32+
pinctrl-0 = <&pwm_pins>;
33+
status = "okay";
34+
};
35+
};
36+
37+
__overrides__ {
38+
pin = <&pwm_pins>,"brcm,pins:0";
39+
func = <&pwm_pins>,"brcm,function:0";
40+
clock = <&clk_pwm>,"clock-frequency:0";
41+
};
42+
};

arch/arm/configs/bcm2709_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ CONFIG_IIO_BUFFER=y
10871087
CONFIG_IIO_BUFFER_CB=y
10881088
CONFIG_IIO_KFIFO_BUF=m
10891089
CONFIG_DHT11=m
1090+
CONFIG_PWM_BCM2835=m
10901091
CONFIG_RASPBERRYPI_FIRMWARE=y
10911092
CONFIG_EXT4_FS=y
10921093
CONFIG_EXT4_FS_POSIX_ACL=y

arch/arm/configs/bcmrpi_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,7 @@ CONFIG_IIO_BUFFER=y
10801080
CONFIG_IIO_BUFFER_CB=y
10811081
CONFIG_IIO_KFIFO_BUF=m
10821082
CONFIG_DHT11=m
1083+
CONFIG_PWM_BCM2835=m
10831084
CONFIG_RASPBERRYPI_FIRMWARE=y
10841085
CONFIG_EXT4_FS=y
10851086
CONFIG_EXT4_FS_POSIX_ACL=y

drivers/pwm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ config PWM_BCM_KONA
8585

8686
config PWM_BCM2835
8787
tristate "BCM2835 PWM support"
88-
depends on ARCH_BCM2835
88+
depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
8989
help
9090
PWM framework driver for BCM2835 controller (Raspberry Pi)
9191

0 commit comments

Comments
 (0)