Device Driver --->
[*] LED Support --->
[*] LED Trigger support
在 LED 設定的 struct 中,有一個變數為 def_trigger
表示控制 led 的名稱
static struct s3c24xx_led_platdata smdk_pdata_led_blue = {
.gpio = S3C2410_GPB1,
.flags = S3C24XX_LEDF_TRISTATE,
.name = "led-blue",
.def_trigger = "nand-disk",
}
表示控制 LED 藍燈的名稱是 "nand-disk"
在 linxu/drivers/mtd/nand/nand_base.c
註冊: led_trigger_register_simple("nand-disk", &nand_led_trigger);
取消註冊: led_trigger_unregister_simple(nand_led_trigger);
控制: led_trigger_event(nand_led_trigger, LED_FULL);
現在 只要對 nand flash 操作,藍燈就會亮
在 linux/drivers/leds/leds-s3c24xx.c 中
會呼叫
static void s3c24xx_led_set(struct led_classdev *led_cdev, enum led_brightness value)
{
struct s3c24xx_gpio_led *led = to_gpio(led_cdev);
struct s3c24xx_led_platdata *pd = led->pdata;
/* there will be a short delay between setting the output and
* going from output to input when using tristate. */
s3c2410_gpio_setpin(pd->gpio, (value ? 1 : 0) ^(pd->flags & S3C24XX_LEDF_ACTLOW));
if (pd->flags & S3C24XX_LEDF_TRISTATE)
s3c2410_gpio_cfgpin(pd->gpio,value ? S3C2410_GPIO_OUTPUT : S3C2410_GPIO_INPUT);
}
** 備註 **
- #define DEFINE_LED_TRIGGER(x) static struct
led_trigger *x;
定義在 linxu/include/linux/leds.h - led brightness 是濠洨的 (只有亮跟不亮)
- LED 相關設定可以參考 LED Driver 筆記