brcm2708: use BuildDTB in image/Makefile
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.18 / 0110-BCM270x_DT-Add-pwr_led-and-the-required-input-trigge.patch
1 From 5f1c4a04606c2fb2d0203bdbe364a6054b3bb0b7 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Fri, 6 Feb 2015 13:50:57 +0000
4 Subject: [PATCH 110/114] BCM270x_DT: Add pwr_led, and the required "input"
5 trigger
6
7 The "input" trigger makes the associated GPIO an input. This is to support
8 the Raspberry Pi PWR LED, which is driven by external hardware in normal use.
9
10 N.B. pwr_led is not available on Model A or B boards.
11 ---
12 arch/arm/boot/dts/bcm2708-rpi-b-plus.dts | 18 ++++++++-
13 arch/arm/boot/dts/bcm2708-rpi-b.dts | 8 +++-
14 arch/arm/boot/dts/bcm2708.dtsi | 5 ---
15 arch/arm/boot/dts/bcm2709-rpi-2-b.dts | 18 ++++++++-
16 arch/arm/boot/dts/bcm2709.dtsi | 5 ---
17 arch/arm/configs/bcm2709_defconfig | 1 +
18 arch/arm/configs/bcmrpi_defconfig | 1 +
19 drivers/leds/trigger/Kconfig | 7 ++++
20 drivers/leds/trigger/Makefile | 1 +
21 drivers/leds/trigger/ledtrig-input.c | 65 ++++++++++++++++++++++++++++++++
22 10 files changed, 113 insertions(+), 16 deletions(-)
23 create mode 100644 drivers/leds/trigger/ledtrig-input.c
24
25 --- a/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
26 +++ b/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
27 @@ -83,8 +83,18 @@
28 pinctrl-0 = <&i2s_pins>;
29 };
30
31 -&act_led {
32 - gpios = <&gpio 47 0>;
33 +&leds {
34 + act_led: act {
35 + label = "led0";
36 + linux,default-trigger = "mmc0";
37 + gpios = <&gpio 47 0>;
38 + };
39 +
40 + pwr_led: pwr {
41 + label = "led1";
42 + linux,default-trigger = "input";
43 + gpios = <&gpio 35 0>;
44 + };
45 };
46
47 / {
48 @@ -99,5 +109,9 @@
49 act_led_gpio = <&act_led>,"gpios:4";
50 act_led_activelow = <&act_led>,"gpios:8";
51 act_led_trigger = <&act_led>,"linux,default-trigger";
52 +
53 + pwr_led_gpio = <&pwr_led>,"gpios:4";
54 + pwr_led_activelow = <&pwr_led>,"gpios:8";
55 + pwr_led_trigger = <&pwr_led>,"linux,default-trigger";
56 };
57 };
58 --- a/arch/arm/boot/dts/bcm2708-rpi-b.dts
59 +++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts
60 @@ -83,8 +83,12 @@
61 pinctrl-0 = <&i2s_pins>;
62 };
63
64 -&act_led {
65 - gpios = <&gpio 16 1>;
66 +&leds {
67 + act_led: act {
68 + label = "led0";
69 + linux,default-trigger = "mmc0";
70 + gpios = <&gpio 16 1>;
71 + };
72 };
73
74 / {
75 --- a/arch/arm/boot/dts/bcm2708.dtsi
76 +++ b/arch/arm/boot/dts/bcm2708.dtsi
77 @@ -79,11 +79,6 @@
78
79 leds: leds {
80 compatible = "gpio-leds";
81 -
82 - act_led: act {
83 - label = "led0";
84 - linux,default-trigger = "mmc0";
85 - };
86 };
87 };
88
89 --- a/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
90 +++ b/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
91 @@ -83,8 +83,18 @@
92 pinctrl-0 = <&i2s_pins>;
93 };
94
95 -&act_led {
96 - gpios = <&gpio 47 0>;
97 +&leds {
98 + act_led: act {
99 + label = "led0";
100 + linux,default-trigger = "mmc0";
101 + gpios = <&gpio 47 0>;
102 + };
103 +
104 + pwr_led: pwr {
105 + label = "led1";
106 + linux,default-trigger = "input";
107 + gpios = <&gpio 35 0>;
108 + };
109 };
110
111 / {
112 @@ -99,5 +109,9 @@
113 act_led_gpio = <&act_led>,"gpios:4";
114 act_led_activelow = <&act_led>,"gpios:8";
115 act_led_trigger = <&act_led>,"linux,default-trigger";
116 +
117 + pwr_led_gpio = <&pwr_led>,"gpios:4";
118 + pwr_led_activelow = <&pwr_led>,"gpios:8";
119 + pwr_led_trigger = <&pwr_led>,"linux,default-trigger";
120 };
121 };
122 --- a/arch/arm/boot/dts/bcm2709.dtsi
123 +++ b/arch/arm/boot/dts/bcm2709.dtsi
124 @@ -79,11 +79,6 @@
125
126 leds: leds {
127 compatible = "gpio-leds";
128 -
129 - act_led: act {
130 - label = "led0";
131 - linux,default-trigger = "mmc0";
132 - };
133 };
134 };
135
136 --- a/arch/arm/configs/bcm2709_defconfig
137 +++ b/arch/arm/configs/bcm2709_defconfig
138 @@ -959,6 +959,7 @@ CONFIG_LEDS_TRIGGER_GPIO=y
139 CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
140 CONFIG_LEDS_TRIGGER_TRANSIENT=m
141 CONFIG_LEDS_TRIGGER_CAMERA=m
142 +CONFIG_LEDS_TRIGGER_INPUT=y
143 CONFIG_RTC_CLASS=y
144 # CONFIG_RTC_HCTOSYS is not set
145 CONFIG_RTC_DRV_DS1307=m
146 --- a/arch/arm/configs/bcmrpi_defconfig
147 +++ b/arch/arm/configs/bcmrpi_defconfig
148 @@ -952,6 +952,7 @@ CONFIG_LEDS_TRIGGER_GPIO=y
149 CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
150 CONFIG_LEDS_TRIGGER_TRANSIENT=m
151 CONFIG_LEDS_TRIGGER_CAMERA=m
152 +CONFIG_LEDS_TRIGGER_INPUT=y
153 CONFIG_RTC_CLASS=y
154 # CONFIG_RTC_HCTOSYS is not set
155 CONFIG_RTC_DRV_DS1307=m
156 --- a/drivers/leds/trigger/Kconfig
157 +++ b/drivers/leds/trigger/Kconfig
158 @@ -126,4 +126,11 @@ config LEDS_TRIGGER_USBDEV
159 This allows LEDs to be controlled by the presence/activity of
160 an USB device. If unsure, say N.
161
162 +config LEDS_TRIGGER_INPUT
163 + tristate "LED Input Trigger"
164 + depends on LEDS_TRIGGERS
165 + help
166 + This allows the GPIOs assigned to be LEDs to be initialised to inputs.
167 + If unsure, say Y.
168 +
169 endif # LEDS_TRIGGERS
170 --- a/drivers/leds/trigger/Makefile
171 +++ b/drivers/leds/trigger/Makefile
172 @@ -8,3 +8,4 @@ obj-$(CONFIG_LEDS_TRIGGER_CPU) += ledtr
173 obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
174 obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o
175 obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o
176 +obj-$(CONFIG_LEDS_TRIGGER_INPUT) += ledtrig-input.o
177 --- /dev/null
178 +++ b/drivers/leds/trigger/ledtrig-input.c
179 @@ -0,0 +1,65 @@
180 +/*
181 + * Set LED GPIO to Input "Trigger"
182 + *
183 + * Copyright 2015 Phil Elwell <phil@raspberrypi.org>
184 + *
185 + * Based on Nick Forbes's ledtrig-default-on.c.
186 + *
187 + * This program is free software; you can redistribute it and/or modify
188 + * it under the terms of the GNU General Public License version 2 as
189 + * published by the Free Software Foundation.
190 + *
191 + */
192 +
193 +#include <linux/module.h>
194 +#include <linux/kernel.h>
195 +#include <linux/init.h>
196 +#include <linux/leds.h>
197 +#include <linux/gpio.h>
198 +#include "../leds.h"
199 +
200 +/* This is a hack to get at the private 'gpio' member */
201 +
202 +struct gpio_led_data {
203 + struct led_classdev cdev;
204 + unsigned gpio;
205 +};
206 +
207 +static void input_trig_activate(struct led_classdev *led_cdev)
208 +{
209 + struct gpio_led_data *led_dat =
210 + container_of(led_cdev, struct gpio_led_data, cdev);
211 + if (gpio_is_valid(led_dat->gpio))
212 + gpio_direction_input(led_dat->gpio);
213 +}
214 +
215 +static void input_trig_deactivate(struct led_classdev *led_cdev)
216 +{
217 + struct gpio_led_data *led_dat =
218 + container_of(led_cdev, struct gpio_led_data, cdev);
219 + if (gpio_is_valid(led_dat->gpio))
220 + gpio_direction_output(led_dat->gpio, 0);
221 +}
222 +
223 +static struct led_trigger input_led_trigger = {
224 + .name = "input",
225 + .activate = input_trig_activate,
226 + .deactivate = input_trig_deactivate,
227 +};
228 +
229 +static int __init input_trig_init(void)
230 +{
231 + return led_trigger_register(&input_led_trigger);
232 +}
233 +
234 +static void __exit input_trig_exit(void)
235 +{
236 + led_trigger_unregister(&input_led_trigger);
237 +}
238 +
239 +module_init(input_trig_init);
240 +module_exit(input_trig_exit);
241 +
242 +MODULE_AUTHOR("Phil Elwell <phil@raspberrypi.org>");
243 +MODULE_DESCRIPTION("Set LED GPIO to Input \"trigger\"");
244 +MODULE_LICENSE("GPL");