make menuconfig 设置
1.
2.
3.![](https://i-blog.csdnimg.cn/blog_migrate/c50185f34fba52234b292cb99e282eef.png)
4.![](https://i-blog.csdnimg.cn/blog_migrate/c96538f677289951ef86b065994a9ea7.png)
文件位置:
arch ->arm -> Mach-nuc980 下的dev.c
头文件:
#include <linux/leds.h>
代码:
#if defined(CONFIG_LEDS_GPIO)
static struct gpio_led nuc980_leds_gpio] = {
[0] = {
.name = "led_heartbeat",
/* 引脚设置 */
.gpio = NUC980_PB8,
/* 触发电平 默认是高还是低 根据原理图 */
.active_low = 1,
/* 触发方式 心跳触发 */
.default_trigger = "heartbeat",
},
};
static struct gpio_led_platform_data leds_data = {
.num_leds = ARRAY_SIZE(nuc980_leds_gpio),
.leds = nuc980_leds_gpio,
};
static struct platform_device nuc980_gpio_leds_device = {
/* 根据这个name匹配驱动 */
.name = "leds-gpio",
.id = -1,
.dev.platform_data = &leds_data,
};
#endif
驱动文件(系统自带):
\drivers\leds\leds-gpio.c
注册方式是平台驱动