日期:2014-05-16 浏览次数:20645 次
内核中带有GPIO控制LED的驱动,驱动文件为:drivers/leds/leds-gpio.c ;实现了一个体系结构无关的GPIO LED驱动,使用此LED 驱动,开发者不需要修改一行代码,只需要在 BSP 的板文件(对于idea6410 为arch/arm/mach--s3c64xx/mach--smdk6410.c)中定义相关的platform设备和数据。在 idea6410开发板上,GPM0~GPM3 实现了四个 LED
1、其对应的platform 信息如下:
static struct gpio_led smdk6410_leds[] ={
[0]= {
.name = "LED1",
.gpio = S3C64XX_GPM(0),
},
[1]= {
.name = "LED2",
.gpio = S3C64XX_GPM(1),
},
[2]= {
.name = "LED3",
.gpio = S3C64XX_GPM(2),
},
[3]= {
.name = "LED4",
.gpio = S3C64XX_GPM(3),
},
};
static struct gpio_led_platform_data smdk6410_gpio_led_pdata ={
.num_leds = ARRAY_SIZE(smdk6410_leds),
.leds =smdk6410_leds,
};
static struct platform_device smdk6410_device_led ={
.name = "leds-gpio",
.id = -1,
.dev ={
.platform_data = &smdk6410_gpio_led_pdata,
},
};
2、加入必要的头文件:
#include <linux/leds.h>
3、在static struct platform_device *smdk6410_devices[] __initdata中加入
&smdk6410_device_led,
4、配置内核,支持LED驱动:
Device Drivers --->
[*] LED Support --->
<*> LED Class Support
<*> LED Support for GPIO connected LEDs