sysfs
1.以下是在原有添加button支持后的mach-mini6410-button.c diff出来的,行数会和标准的mach-mini6410.c不同,不能靠打补丁的方式添加。但是可以看出哪些是添加的,若要修改,可自行添加。压缩包里是我现在正在用的mach-mini6410.c的修改版。
- --- mach-mini6410-button.c 2011-12-06 18:47:19.263062596 +0800
-
+++ mach-mini6410-button-led.c 2011-12-06 16:18:30.000000000 +0800
-
@@ -34,6 +34,7 @@
-
#include <linux/proc_fs.h>
-
#include <linux/gpio_keys.h> //add by Jason
-
#include <linux/input.h> //add by Jason
-
+#include <linux/leds.h> //add by Jason
-
-
#include <video/platform_lcd.h>
-
-
@@ -402,8 +403,51 @@
-
}
-
};
-
-
+/* Tiny6410 Leds */
-
+static struct gpio_led tiny6410_leds[] = { //add by Jason
-
+ [0] = {
-
+ .name = "LED1",
-
+ .default_trigger= "heartbeat",
-
+ .gpio = S3C64XX_GPK(4),
-
+ .active_low = 1,
-
+ .default_state = LEDS_GPIO_DEFSTATE_OFF,
-
+ },
-
+ [1] = {
-
+ .name = "LED2",
-
+ .gpio = S3C64XX_GPK(5),
-
+ .active_low = 1,
-
+ .default_state = LEDS_GPIO_DEFSTATE_OFF,
-
+ },
-
+ [2] = {
-
+ .name = "LED3",
-
+ .gpio = S3C64XX_GPK(6),
-
+ .active_low = 1,
-
+ .default_state = LEDS_GPIO_DEFSTATE_OFF,
-
+ },
-
+ [3] = {
-
+ .name = "LED4",
-
+ .gpio = S3C64XX_GPK(7),
-
+ .active_low = 1,
-
+ .default_state = LEDS_GPIO_DEFSTATE_OFF,
-
+ },
-
+};
-
+
-
+static struct gpio_led_platform_data tiny6410_gpio_led_data = { //add by Jason
-
+ .leds = tiny6410_leds,
-
+ .num_leds = ARRAY_SIZE(tiny6410_leds),
-
+};
-
+
-
+static struct platform_device tiny6410_device_led = { //add by Jason
-
+ .name = "leds-gpio",
-
+ .id = -1,
-
+ .dev = {
-
+ .platform_data = &tiny6410_gpio_led_data,
-
+ },
-
+};
-
+
-
static struct platform_device *mini6410_devices[] __initdata = {
-
&tiny6410_device_button, //add by Jason
-
+ &tiny6410_device_led, //add by Jason
-
#ifdef CONFIG_MINI6410_SD_CH0
-
&s3c_device_hsmmc0,
-
#endif
2.驱动配置在图形化配置菜单里选:
Device Driver ---> Led Support
如下图配置
3.重新烧写新的内核,启动后,会看到led0在闪烁,因为配置了heartbeat,要控制其余几个led灯,可以如下输入:
a.点灯
- echo 1 > /sys/devices/platform/leds-gpio/leds/LED3/brightness
b.熄灯
- echo 0 > /sys/devices/platform/leds-gpio/leds/LED3/brightness
阅读(3647) | 评论(0) | 转发(0) |