首先定义响应LED的IO接口与功能描述:
static struct gpio_led mini6410_leds[]={
[0] = {
.name = "LED1",
.gpio = S3C64XX_GPK(4),
},
[1] = {
.name = "LED2",
.gpio = S3C64XX_GPK(5),
},
[3] = {
.name = "LED3",
.gpio = S3C64XX_GPK(6),
},
[4] = {
.name = "LED4",
.gpio = S3C64XX_GPK(7),
},
};
static struct gpio_led_platform_datamini6410_gpio_led_pdata = {
.leds = mini6410_leds,
.num_leds = ARRAY_SIZE(mini6410_leds),
};
static struct platform_device mini6410_device_led = {
.name = "gpio-leds",
.id = -1,
.dev = {
.platform_data = &mini6410_gpio_led_pdata,
}
};
最后将mini6410_device_button填入到板文件的初始化函数staticvoid __init mini6410_machine_init(void),实现gpio的初始化启动过程。
测试:
确认leds的事件是否创建成功,打开/sys/class/leds/文件夹,可以看到创建的对应leds文件。
简单的测试方法:
#echo 1>/sys/class/leds/brightless