Skip to content

Commit

Permalink
BCM270X_DT: Add pwm and pwm-2chan overlays
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Phil Elwell committed Aug 19, 2015
1 parent d657cbb commit 8bbf4b5
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 1 deletion.
16 changes: 16 additions & 0 deletions arch/arm/boot/dts/bcm2708_common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@
status = "disabled";
};

pwm: pwm@7e20c000 {
compatible = "brcm,bcm2835-pwm";
reg = <0x7e20c000 0x28>;
clocks = <&clk_pwm>;
#pwm-cells = <2>;
status = "disabled";
};

uart1: uart@7e215040 {
compatible = "brcm,bcm2835-aux-uart", "ns16550";
reg = <0x7e215040 0x40>;
Expand Down Expand Up @@ -279,6 +287,14 @@
clock-output-names = "apb_pclk";
clock-frequency = <126000000>;
};

clk_pwm: clock@5 {
compatible = "fixed-clock";
reg = <3>;
#clock-cells = <0>;
clock-output-names = "pwm";
clock-frequency = <100000000>;
};
};

__overrides__ {
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/boot/dts/overlays/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ dtb-$(RPI_DT_OVERLAYS) += mz61581-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += piscreen-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += pitft28-resistive-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += pps-gpio-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += pwm-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += pwm-2chan-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += rpi-dac-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += rpi-display-overlay.dtb
dtb-$(RPI_DT_OVERLAYS) += rpi-ft5406-overlay.dtb
Expand Down
41 changes: 41 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,47 @@ Load: dtoverlay=pps-gpio,<param>=<val>
Params: gpiopin Input GPIO (default "18")


Name: pwm
Info: Configures a single PWM channel
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.
Load: dtoverlay=pwm-2chan,<param>=<val>
Load: dtoverlay=pwm,<param>=<val>
Params: pin Output pin (default 18) - see table
func Pin function (default 2 = Alt5) - see above
clock PWM clock frequency (informational)


Name: pwm-2chan
Info: Configures both PWM channels
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.
Load: dtoverlay=pwm-2chan,<param>=<val>
Params: pin Output pin (default 18) - see table
pin2 Output pin for other channel (default 19)
func Pin function (default 2 = Alt5) - see above
func2 Function for pin2 (default 2 = Alt5)
clock PWM clock frequency (informational)


Name: rpi-dac
Info: Configures the RPi DAC audio card
Load: dtoverlay=rpi-dac
Expand Down
46 changes: 46 additions & 0 deletions arch/arm/boot/dts/overlays/pwm-2chan-overlay.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/dts-v1/;
/plugin/;

/*
This is the 2-channel overlay - only use it if you need both channels.

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.
*/

/ {
fragment@0 {
target = <&gpio>;
__overlay__ {
pwm_pins: pwm_pins {
brcm,pins = <18 19>;
brcm,function = <2 2>; /* Alt5 */
};
};
};

fragment@1 {
target = <&pwm>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&pwm_pins>;
status = "okay";
};
};

__overrides__ {
pin = <&pwm_pins>,"brcm,pins:0";
pin2 = <&pwm_pins>,"brcm,pins:4";
func = <&pwm_pins>,"brcm,function:0";
func2 = <&pwm_pins>,"brcm,function:4";
clock = <&clk_pwm>,"clock-frequency:0";
};
};
42 changes: 42 additions & 0 deletions arch/arm/boot/dts/overlays/pwm-overlay.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/dts-v1/;
/plugin/;

/*
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.
*/

/ {
fragment@0 {
target = <&gpio>;
__overlay__ {
pwm_pins: pwm_pins {
brcm,pins = <18>;
brcm,function = <2>; /* Alt5 */
};
};
};

fragment@1 {
target = <&pwm>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&pwm_pins>;
status = "okay";
};
};

__overrides__ {
pin = <&pwm_pins>,"brcm,pins:0";
func = <&pwm_pins>,"brcm,function:0";
clock = <&clk_pwm>,"clock-frequency:0";
};
};
1 change: 1 addition & 0 deletions arch/arm/configs/bcm2709_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ CONFIG_IIO_BUFFER=y
CONFIG_IIO_BUFFER_CB=y
CONFIG_IIO_KFIFO_BUF=m
CONFIG_DHT11=m
CONFIG_PWM_BCM2835=m
CONFIG_RASPBERRYPI_FIRMWARE=y
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_POSIX_ACL=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/bcmrpi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ CONFIG_IIO_BUFFER=y
CONFIG_IIO_BUFFER_CB=y
CONFIG_IIO_KFIFO_BUF=m
CONFIG_DHT11=m
CONFIG_PWM_BCM2835=m
CONFIG_RASPBERRYPI_FIRMWARE=y
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_POSIX_ACL=y
Expand Down
2 changes: 1 addition & 1 deletion drivers/pwm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ config PWM_BCM_KONA

config PWM_BCM2835
tristate "BCM2835 PWM support"
depends on ARCH_BCM2835
depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
help
PWM framework driver for BCM2835 controller (Raspberry Pi)

Expand Down

0 comments on commit 8bbf4b5

Please sign in to comment.