omap_hsmmc: Do not prefix slot name
[linux-ginger.git] / include / linux / leds.h
blob24489da701e331b1a4d1810b40afd7209775e265
1 /*
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>
19 struct device;
21 * LED Core
24 enum led_brightness {
25 LED_OFF = 0,
26 LED_HALF = 127,
27 LED_FULL = 255,
30 struct led_classdev {
31 const char *name;
32 int brightness;
33 int flags;
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);
52 struct device *dev;
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;
62 void *trigger_data;
63 #endif
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);
73 * LED Triggers
75 #ifdef CONFIG_LEDS_TRIGGERS
77 #define TRIG_NAME_MAX 50
79 struct led_trigger {
80 /* Trigger Properties */
81 const char *name;
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);
106 #else
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)
115 #endif
117 /* Trigger specific functions */
118 #ifdef CONFIG_LEDS_TRIGGER_IDE_DISK
119 extern void ledtrig_ide_activity(void);
120 #else
121 #define ledtrig_ide_activity() do {} while(0)
122 #endif
125 * Generic LED platform data for describing LED names and default triggers.
127 struct led_info {
128 const char *name;
129 const char *default_trigger;
130 int flags;
133 struct led_platform_data {
134 int num_leds;
135 struct led_info *leds;
138 /* For the leds-gpio driver */
139 struct gpio_led {
140 const char *name;
141 const char *default_trigger;
142 unsigned gpio;
143 u8 active_low;
146 struct gpio_led_platform_data {
147 int num_leds;
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 */