2 * Driver model for leds and led triggers
4 * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
5 * Copyright (C) 2005 Richard Purdie <rpurdie@openedhand.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #ifndef __LINUX_LEDS_H_INCLUDED
13 #define __LINUX_LEDS_H_INCLUDED
15 #include <linux/list.h>
16 #include <linux/spinlock.h>
17 #include <linux/rwsem.h>
35 /* Lower 16 bits reflect status */
36 #define LED_SUSPENDED (1 << 0)
37 /* Upper 16 bits reflect control information */
38 #define LED_CORE_SUSPENDRESUME (1 << 16)
40 /* Set LED brightness level */
41 /* Must not sleep, use a workqueue if needed */
42 void (*brightness_set
)(struct led_classdev
*led_cdev
,
43 enum led_brightness brightness
);
44 /* Get LED brightness level */
45 enum led_brightness (*brightness_get
)(struct led_classdev
*led_cdev
);
47 /* Activate hardware accelerated blink */
48 int (*blink_set
)(struct led_classdev
*led_cdev
,
49 unsigned long *delay_on
,
50 unsigned long *delay_off
);
53 struct list_head node
; /* LED Device list */
54 const char *default_trigger
; /* Trigger to use */
56 #ifdef CONFIG_LEDS_TRIGGERS
57 /* Protects the trigger data below */
58 struct rw_semaphore trigger_lock
;
60 struct led_trigger
*trigger
;
61 struct list_head trig_list
;
66 extern int led_classdev_register(struct device
*parent
,
67 struct led_classdev
*led_cdev
);
68 extern void led_classdev_unregister(struct led_classdev
*led_cdev
);
69 extern void led_classdev_suspend(struct led_classdev
*led_cdev
);
70 extern void led_classdev_resume(struct led_classdev
*led_cdev
);
75 #ifdef CONFIG_LEDS_TRIGGERS
77 #define TRIG_NAME_MAX 50
80 /* Trigger Properties */
82 void (*activate
)(struct led_classdev
*led_cdev
);
83 void (*deactivate
)(struct led_classdev
*led_cdev
);
85 /* LEDs under control by this trigger (for simple triggers) */
86 rwlock_t leddev_list_lock
;
87 struct list_head led_cdevs
;
89 /* Link to next registered trigger */
90 struct list_head next_trig
;
93 /* Registration functions for complex triggers */
94 extern int led_trigger_register(struct led_trigger
*trigger
);
95 extern void led_trigger_unregister(struct led_trigger
*trigger
);
97 /* Registration functions for simple triggers */
98 #define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
99 #define DEFINE_LED_TRIGGER_GLOBAL(x) struct led_trigger *x;
100 extern void led_trigger_register_simple(const char *name
,
101 struct led_trigger
**trigger
);
102 extern void led_trigger_unregister_simple(struct led_trigger
*trigger
);
103 extern void led_trigger_event(struct led_trigger
*trigger
,
104 enum led_brightness event
);
108 /* Triggers aren't active - null macros */
109 #define DEFINE_LED_TRIGGER(x)
110 #define DEFINE_LED_TRIGGER_GLOBAL(x)
111 #define led_trigger_register_simple(x, y) do {} while(0)
112 #define led_trigger_unregister_simple(x) do {} while(0)
113 #define led_trigger_event(x, y) do {} while(0)
117 /* Trigger specific functions */
118 #ifdef CONFIG_LEDS_TRIGGER_IDE_DISK
119 extern void ledtrig_ide_activity(void);
121 #define ledtrig_ide_activity() do {} while(0)
125 * Generic LED platform data for describing LED names and default triggers.
129 const char *default_trigger
;
133 struct led_platform_data
{
135 struct led_info
*leds
;
138 /* For the leds-gpio driver */
141 const char *default_trigger
;
146 struct gpio_led_platform_data
{
148 struct gpio_led
*leds
;
149 int (*gpio_blink_set
)(unsigned gpio
,
150 unsigned long *delay_on
,
151 unsigned long *delay_off
);
155 #endif /* __LINUX_LEDS_H_INCLUDED */