brcm2708: switch to linux 4.4 and update patches
[openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0154-BCM270X_DT-Add-pwm-and-pwm-2chan-overlays.patch
1 From 4eac708a344a2fc86a1cacebedc7cd5650d83231 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Mon, 17 Aug 2015 10:49:44 +0100
4 Subject: [PATCH 154/222] BCM270X_DT: Add pwm and pwm-2chan overlays
5
6 From the README entries:
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   N.B.:
11     1) Pin 18 is the only one available on all platforms, and
12        it is the one used by the I2S audio interface.
13        Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
14     2) The onboard analogue audio output uses both PWM channels.
15     3) So be careful mixing audio and PWM.
16     4) Currently the clock must have been enabled and configured
17        by other means.
18
19 See: https://github.com/raspberrypi/linux/issues/756
20 ---
21  arch/arm/boot/dts/bcm2708_common.dtsi            | 16 +++++++++
22  arch/arm/boot/dts/overlays/Makefile              |  2 ++
23  arch/arm/boot/dts/overlays/README                | 41 +++++++++++++++++++++
24  arch/arm/boot/dts/overlays/pwm-2chan-overlay.dts | 46 ++++++++++++++++++++++++
25  arch/arm/boot/dts/overlays/pwm-overlay.dts       | 42 ++++++++++++++++++++++
26  arch/arm/configs/bcm2709_defconfig               |  1 +
27  arch/arm/configs/bcmrpi_defconfig                |  1 +
28  drivers/pwm/Kconfig                              |  2 +-
29  8 files changed, 150 insertions(+), 1 deletion(-)
30  create mode 100644 arch/arm/boot/dts/overlays/pwm-2chan-overlay.dts
31  create mode 100644 arch/arm/boot/dts/overlays/pwm-overlay.dts
32
33 --- a/arch/arm/boot/dts/bcm2708_common.dtsi
34 +++ b/arch/arm/boot/dts/bcm2708_common.dtsi
35 @@ -154,6 +154,14 @@
36                         status = "disabled";
37                 };
38  
39 +               pwm: pwm@7e20c000 {
40 +                       compatible = "brcm,bcm2835-pwm";
41 +                       reg = <0x7e20c000 0x28>;
42 +                       clocks = <&clk_pwm>;
43 +                       #pwm-cells = <2>;
44 +                       status = "disabled";
45 +               };
46 +
47                 uart1: uart@7e215040 {
48                         compatible = "brcm,bcm2835-aux-uart", "ns16550";
49                         reg = <0x7e215040 0x40>;
50 @@ -279,6 +287,14 @@
51                         clock-output-names = "apb_pclk";
52                         clock-frequency = <126000000>;
53                 };
54 +
55 +               clk_pwm: clock@5 {
56 +                        compatible = "fixed-clock";
57 +                        reg = <3>;
58 +                        #clock-cells = <0>;
59 +                        clock-output-names = "pwm";
60 +                        clock-frequency = <100000000>;
61 +               };
62         };
63  
64         __overrides__ {
65 --- a/arch/arm/boot/dts/overlays/Makefile
66 +++ b/arch/arm/boot/dts/overlays/Makefile
67 @@ -35,6 +35,8 @@ dtb-$(RPI_DT_OVERLAYS) += mz61581-overla
68  dtb-$(RPI_DT_OVERLAYS) += piscreen-overlay.dtb
69  dtb-$(RPI_DT_OVERLAYS) += pitft28-resistive-overlay.dtb
70  dtb-$(RPI_DT_OVERLAYS) += pps-gpio-overlay.dtb
71 +dtb-$(RPI_DT_OVERLAYS) += pwm-overlay.dtb
72 +dtb-$(RPI_DT_OVERLAYS) += pwm-2chan-overlay.dtb
73  dtb-$(RPI_DT_OVERLAYS) += rpi-dac-overlay.dtb
74  dtb-$(RPI_DT_OVERLAYS) += rpi-display-overlay.dtb
75  dtb-$(RPI_DT_OVERLAYS) += rpi-ft5406-overlay.dtb
76 --- a/arch/arm/boot/dts/overlays/README
77 +++ b/arch/arm/boot/dts/overlays/README
78 @@ -410,6 +410,47 @@ Load:   dtoverlay=pps-gpio,<param>=<val>
79  Params: gpiopin                  Input GPIO (default "18")
80  
81  
82 +Name:   pwm
83 +Info:   Configures a single PWM channel
84 +        Legal pin,function combinations for each channel:
85 +          PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0)            52,5(Alt1)
86 +          PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
87 +        N.B.:
88 +          1) Pin 18 is the only one available on all platforms, and
89 +             it is the one used by the I2S audio interface.
90 +             Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
91 +          2) The onboard analogue audio output uses both PWM channels.
92 +          3) So be careful mixing audio and PWM.
93 +          4) Currently the clock must have been enabled and configured
94 +             by other means.
95 +Load:   dtoverlay=pwm-2chan,<param>=<val>
96 +Load:   dtoverlay=pwm,<param>=<val>
97 +Params: pin                      Output pin (default 18) - see table
98 +        func                     Pin function (default 2 = Alt5) - see above
99 +        clock                    PWM clock frequency (informational)
100 +
101 +
102 +Name:   pwm-2chan
103 +Info:   Configures both PWM channels
104 +        Legal pin,function combinations for each channel:
105 +          PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0)            52,5(Alt1)
106 +          PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
107 +        N.B.:
108 +          1) Pin 18 is the only one available on all platforms, and
109 +             it is the one used by the I2S audio interface.
110 +             Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
111 +          2) The onboard analogue audio output uses both PWM channels.
112 +          3) So be careful mixing audio and PWM.
113 +          4) Currently the clock must have been enabled and configured
114 +             by other means.
115 +Load:   dtoverlay=pwm-2chan,<param>=<val>
116 +Params: pin                      Output pin (default 18) - see table
117 +        pin2                     Output pin for other channel (default 19)
118 +        func                     Pin function (default 2 = Alt5) - see above
119 +        func2                    Function for pin2 (default 2 = Alt5)
120 +        clock                    PWM clock frequency (informational)
121 +
122 +
123  Name:   rpi-dac
124  Info:   Configures the RPi DAC audio card
125  Load:   dtoverlay=rpi-dac
126 --- /dev/null
127 +++ b/arch/arm/boot/dts/overlays/pwm-2chan-overlay.dts
128 @@ -0,0 +1,46 @@
129 +/dts-v1/;
130 +/plugin/;
131 +
132 +/*
133 +This is the 2-channel overlay - only use it if you need both channels.
134 +
135 +Legal pin,function combinations for each channel:
136 +  PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0)            52,5(Alt1)
137 +  PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
138 +
139 +N.B.:
140 +  1) Pin 18 is the only one available on all platforms, and
141 +     it is the one used by the I2S audio interface.
142 +     Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
143 +  2) The onboard analogue audio output uses both PWM channels.
144 +  3) So be careful mixing audio and PWM.
145 +*/
146 +
147 +/ {
148 +       fragment@0 {
149 +               target = <&gpio>;
150 +               __overlay__ {
151 +                       pwm_pins: pwm_pins {
152 +                               brcm,pins = <18 19>;
153 +                               brcm,function = <2 2>; /* Alt5 */
154 +                       };
155 +               };
156 +       };
157 +
158 +       fragment@1 {
159 +               target = <&pwm>;
160 +               __overlay__ {
161 +                       pinctrl-names = "default";
162 +                       pinctrl-0 = <&pwm_pins>;
163 +                       status = "okay";
164 +               };
165 +       };
166 +
167 +       __overrides__ {
168 +               pin   = <&pwm_pins>,"brcm,pins:0";
169 +               pin2  = <&pwm_pins>,"brcm,pins:4";
170 +               func  = <&pwm_pins>,"brcm,function:0";
171 +               func2 = <&pwm_pins>,"brcm,function:4";
172 +               clock = <&clk_pwm>,"clock-frequency:0";
173 +       };
174 +};
175 --- /dev/null
176 +++ b/arch/arm/boot/dts/overlays/pwm-overlay.dts
177 @@ -0,0 +1,42 @@
178 +/dts-v1/;
179 +/plugin/;
180 +
181 +/*
182 +Legal pin,function combinations for each channel:
183 +  PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0)            52,5(Alt1)
184 +  PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1)
185 +
186 +N.B.:
187 +  1) Pin 18 is the only one available on all platforms, and
188 +     it is the one used by the I2S audio interface.
189 +     Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
190 +  2) The onboard analogue audio output uses both PWM channels.
191 +  3) So be careful mixing audio and PWM.
192 +*/
193 +
194 +/ {
195 +       fragment@0 {
196 +               target = <&gpio>;
197 +               __overlay__ {
198 +                       pwm_pins: pwm_pins {
199 +                               brcm,pins = <18>;
200 +                               brcm,function = <2>; /* Alt5 */
201 +                       };
202 +               };
203 +       };
204 +
205 +       fragment@1 {
206 +               target = <&pwm>;
207 +               __overlay__ {
208 +                       pinctrl-names = "default";
209 +                       pinctrl-0 = <&pwm_pins>;
210 +                       status = "okay";
211 +               };
212 +       };
213 +
214 +       __overrides__ {
215 +               pin   = <&pwm_pins>,"brcm,pins:0";
216 +               func  = <&pwm_pins>,"brcm,function:0";
217 +               clock = <&clk_pwm>,"clock-frequency:0";
218 +       };
219 +};
220 --- a/arch/arm/configs/bcm2709_defconfig
221 +++ b/arch/arm/configs/bcm2709_defconfig
222 @@ -1089,6 +1089,7 @@ CONFIG_IIO_BUFFER=y
223  CONFIG_IIO_BUFFER_CB=y
224  CONFIG_IIO_KFIFO_BUF=m
225  CONFIG_DHT11=m
226 +CONFIG_PWM_BCM2835=m
227  CONFIG_RASPBERRYPI_FIRMWARE=y
228  CONFIG_EXT4_FS=y
229  CONFIG_EXT4_FS_POSIX_ACL=y
230 --- a/arch/arm/configs/bcmrpi_defconfig
231 +++ b/arch/arm/configs/bcmrpi_defconfig
232 @@ -1082,6 +1082,7 @@ CONFIG_IIO_BUFFER=y
233  CONFIG_IIO_BUFFER_CB=y
234  CONFIG_IIO_KFIFO_BUF=m
235  CONFIG_DHT11=m
236 +CONFIG_PWM_BCM2835=m
237  CONFIG_RASPBERRYPI_FIRMWARE=y
238  CONFIG_EXT4_FS=y
239  CONFIG_EXT4_FS_POSIX_ACL=y
240 --- a/drivers/pwm/Kconfig
241 +++ b/drivers/pwm/Kconfig
242 @@ -85,7 +85,7 @@ config PWM_BCM_KONA
243  
244  config PWM_BCM2835
245         tristate "BCM2835 PWM support"
246 -       depends on ARCH_BCM2835
247 +       depends on ARCH_BCM2835 || ARCH_BCM2708 || ARCH_BCM2709
248         help
249           PWM framework driver for BCM2835 controller (Raspberry Pi)
250