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"
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.
10 N.B. pwr_led is not available on Model A or B boards.
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
25 --- a/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
26 +++ b/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
28 pinctrl-0 = <&i2s_pins>;
32 - gpios = <&gpio 47 0>;
36 + linux,default-trigger = "mmc0";
37 + gpios = <&gpio 47 0>;
42 + linux,default-trigger = "input";
43 + gpios = <&gpio 35 0>;
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";
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";
58 --- a/arch/arm/boot/dts/bcm2708-rpi-b.dts
59 +++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts
61 pinctrl-0 = <&i2s_pins>;
65 - gpios = <&gpio 16 1>;
69 + linux,default-trigger = "mmc0";
70 + gpios = <&gpio 16 1>;
75 --- a/arch/arm/boot/dts/bcm2708.dtsi
76 +++ b/arch/arm/boot/dts/bcm2708.dtsi
80 compatible = "gpio-leds";
84 - linux,default-trigger = "mmc0";
89 --- a/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
90 +++ b/arch/arm/boot/dts/bcm2709-rpi-2-b.dts
92 pinctrl-0 = <&i2s_pins>;
96 - gpios = <&gpio 47 0>;
100 + linux,default-trigger = "mmc0";
101 + gpios = <&gpio 47 0>;
106 + linux,default-trigger = "input";
107 + gpios = <&gpio 35 0>;
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";
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";
122 --- a/arch/arm/boot/dts/bcm2709.dtsi
123 +++ b/arch/arm/boot/dts/bcm2709.dtsi
127 compatible = "gpio-leds";
131 - linux,default-trigger = "mmc0";
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
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
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.
162 +config LEDS_TRIGGER_INPUT
163 + tristate "LED Input Trigger"
164 + depends on LEDS_TRIGGERS
166 + This allows the GPIOs assigned to be LEDs to be initialised to inputs.
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
178 +++ b/drivers/leds/trigger/ledtrig-input.c
181 + * Set LED GPIO to Input "Trigger"
183 + * Copyright 2015 Phil Elwell <phil@raspberrypi.org>
185 + * Based on Nick Forbes's ledtrig-default-on.c.
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.
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"
200 +/* This is a hack to get at the private 'gpio' member */
202 +struct gpio_led_data {
203 + struct led_classdev cdev;
207 +static void input_trig_activate(struct led_classdev *led_cdev)
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);
215 +static void input_trig_deactivate(struct led_classdev *led_cdev)
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);
223 +static struct led_trigger input_led_trigger = {
225 + .activate = input_trig_activate,
226 + .deactivate = input_trig_deactivate,
229 +static int __init input_trig_init(void)
231 + return led_trigger_register(&input_led_trigger);
234 +static void __exit input_trig_exit(void)
236 + led_trigger_unregister(&input_led_trigger);
239 +module_init(input_trig_init);
240 +module_exit(input_trig_exit);
242 +MODULE_AUTHOR("Phil Elwell <phil@raspberrypi.org>");
243 +MODULE_DESCRIPTION("Set LED GPIO to Input \"trigger\"");
244 +MODULE_LICENSE("GPL");