-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
leds: Add the "input" trigger, for pwr_led
commit f4853446bd5a614678fd7dffb4f8c91c6ecf61dc from https://github.com/raspberrypi/linux.git rpi-6.6.y The "input" trigger makes the associated GPIO an input. This is to support the Raspberry Pi PWR LED, which is driven by external hardware in normal use. N.B. pwr_led is not available on Model A or B boards. leds-gpio: Implement the brightness_get method The power LED uses some clever logic that means it is driven by a voltage measuring circuit when configured as input, otherwise it is driven by the GPIO output value. This patch wires up the brightness_get method for leds-gpio so that user-space can monitor the LED value via /sys/class/gpio/led1/brightness. Using the input trigger this returns an indication of the system power health, otherwise it is just whatever value the trigger has written most recently. See: raspberrypi/linux#1064 Signed-off-by: Rajeshkumar Ramasamy <rajeshkumar.ramasamy@windriver.com>
- Loading branch information
1 parent
b6c7786
commit c5fa4db
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Set LED GPIO to Input "Trigger" | ||
* | ||
* Copyright 2015 Phil Elwell <phil@raspberrypi.org> | ||
* | ||
* Based on Nick Forbes's ledtrig-default-on.c. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/kernel.h> | ||
#include <linux/init.h> | ||
#include <linux/leds.h> | ||
#include <linux/gpio.h> | ||
#include "../leds.h" | ||
|
||
static int input_trig_activate(struct led_classdev *led_cdev) | ||
{ | ||
led_cdev->flags |= SET_GPIO_INPUT; | ||
led_set_brightness(led_cdev, 0); | ||
return 0; | ||
} | ||
|
||
static void input_trig_deactivate(struct led_classdev *led_cdev) | ||
{ | ||
led_cdev->flags |= SET_GPIO_OUTPUT; | ||
led_set_brightness(led_cdev, 0); | ||
} | ||
|
||
static struct led_trigger input_led_trigger = { | ||
.name = "input", | ||
.activate = input_trig_activate, | ||
.deactivate = input_trig_deactivate, | ||
}; | ||
|
||
static int __init input_trig_init(void) | ||
{ | ||
return led_trigger_register(&input_led_trigger); | ||
} | ||
|
||
static void __exit input_trig_exit(void) | ||
{ | ||
led_trigger_unregister(&input_led_trigger); | ||
} | ||
|
||
module_init(input_trig_init); | ||
module_exit(input_trig_exit); | ||
|
||
MODULE_AUTHOR("Phil Elwell <phil@raspberrypi.org>"); | ||
MODULE_DESCRIPTION("Set LED GPIO to Input \"trigger\""); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters