diff options
Diffstat (limited to 'include/linux/leds.h')
| -rw-r--r-- | include/linux/leds.h | 101 | 
1 files changed, 93 insertions, 8 deletions
| diff --git a/include/linux/leds.h b/include/linux/leds.h index c39bbf17a25b..7d428100b42b 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -124,6 +124,10 @@ struct led_classdev {  #define LED_BLINK_INVERT		3  #define LED_BLINK_BRIGHTNESS_CHANGE 	4  #define LED_BLINK_DISABLE		5 +	/* Brightness off also disables hw-blinking so it is a separate action */ +#define LED_SET_BRIGHTNESS_OFF		6 +#define LED_SET_BRIGHTNESS		7 +#define LED_SET_BLINK			8  	/* Set LED brightness level  	 * Must not sleep. Use brightness_set_blocking for drivers @@ -147,6 +151,10 @@ struct led_classdev {  	 * match the values specified exactly.  	 * Deactivate blinking again when the brightness is set to LED_OFF  	 * via the brightness_set() callback. +	 * For led_blink_set_nosleep() the LED core assumes that blink_set +	 * implementations, of drivers which do not use brightness_set_blocking, +	 * will not sleep. Therefor if brightness_set_blocking is not set +	 * this function must not sleep!  	 */  	int		(*blink_set)(struct led_classdev *led_cdev,  				     unsigned long *delay_on, @@ -170,6 +178,8 @@ struct led_classdev {  	struct work_struct	set_brightness_work;  	int			delayed_set_value; +	unsigned long		delayed_delay_on; +	unsigned long		delayed_delay_off;  #ifdef CONFIG_LEDS_TRIGGERS  	/* Protects the trigger data below */ @@ -183,6 +193,49 @@ struct led_classdev {  	/* LEDs that have private triggers have this set */  	struct led_hw_trigger_type	*trigger_type; + +	/* Unique trigger name supported by LED set in hw control mode */ +	const char		*hw_control_trigger; +	/* +	 * Check if the LED driver supports the requested mode provided by the +	 * defined supported trigger to setup the LED to hw control mode. +	 * +	 * Return 0 on success. Return -EOPNOTSUPP when the passed flags are not +	 * supported and software fallback needs to be used. +	 * Return a negative error number on any other case  for check fail due +	 * to various reason like device not ready or timeouts. +	 */ +	int			(*hw_control_is_supported)(struct led_classdev *led_cdev, +							   unsigned long flags); +	/* +	 * Activate hardware control, LED driver will use the provided flags +	 * from the supported trigger and setup the LED to be driven by hardware +	 * following the requested mode from the trigger flags. +	 * Deactivate hardware blink control by setting brightness to LED_OFF via +	 * the brightness_set() callback. +	 * +	 * Return 0 on success, a negative error number on flags apply fail. +	 */ +	int			(*hw_control_set)(struct led_classdev *led_cdev, +						  unsigned long flags); +	/* +	 * Get from the LED driver the current mode that the LED is set in hw +	 * control mode and put them in flags. +	 * Trigger can use this to get the initial state of a LED already set in +	 * hardware blink control. +	 * +	 * Return 0 on success, a negative error number on failing parsing the +	 * initial mode. Error from this function is NOT FATAL as the device +	 * may be in a not supported initial state by the attached LED trigger. +	 */ +	int			(*hw_control_get)(struct led_classdev *led_cdev, +						  unsigned long *flags); +	/* +	 * Get the device this LED blinks in response to. +	 * e.g. for a PHY LED, it is the network device. If the LED is +	 * not yet associated to a device, return NULL. +	 */ +	struct device		*(*hw_control_get_device)(struct led_classdev *led_cdev);  #endif  #ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED @@ -272,12 +325,27 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev,   * software blinking if there is no hardware blinking or if   * the LED refuses the passed values.   * + * This function may sleep! + *   * Note that if software blinking is active, simply calling   * led_cdev->brightness_set() will not stop the blinking,   * use led_set_brightness() instead.   */  void led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on,  		   unsigned long *delay_off); + +/** + * led_blink_set_nosleep - set blinking, guaranteed to not sleep + * @led_cdev: the LED to start blinking + * @delay_on: the time it should be on (in ms) + * @delay_off: the time it should ble off (in ms) + * + * This function makes the LED blink and is guaranteed to not sleep. Otherwise + * this is the same as led_blink_set(), see led_blink_set() for details. + */ +void led_blink_set_nosleep(struct led_classdev *led_cdev, unsigned long delay_on, +			   unsigned long delay_off); +  /**   * led_blink_set_oneshot - do a oneshot software blink   * @led_cdev: the LED to start blinking @@ -291,6 +359,8 @@ void led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on,   *   * If invert is set, led blinks for delay_off first, then for   * delay_on and leave the led on after the on-off cycle. + * + * This function is guaranteed not to sleep.   */  void led_blink_set_oneshot(struct led_classdev *led_cdev,  			   unsigned long *delay_on, unsigned long *delay_off, @@ -433,11 +503,11 @@ void led_trigger_register_simple(const char *name,  				struct led_trigger **trigger);  void led_trigger_unregister_simple(struct led_trigger *trigger);  void led_trigger_event(struct led_trigger *trigger,  enum led_brightness event); -void led_trigger_blink(struct led_trigger *trigger, unsigned long *delay_on, -		       unsigned long *delay_off); +void led_trigger_blink(struct led_trigger *trigger, unsigned long delay_on, +		       unsigned long delay_off);  void led_trigger_blink_oneshot(struct led_trigger *trigger, -			       unsigned long *delay_on, -			       unsigned long *delay_off, +			       unsigned long delay_on, +			       unsigned long delay_off,  			       int invert);  void led_trigger_set_default(struct led_classdev *led_cdev);  int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger); @@ -487,11 +557,11 @@ static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {}  static inline void led_trigger_event(struct led_trigger *trigger,  				enum led_brightness event) {}  static inline void led_trigger_blink(struct led_trigger *trigger, -				      unsigned long *delay_on, -				      unsigned long *delay_off) {} +				      unsigned long delay_on, +				      unsigned long delay_off) {}  static inline void led_trigger_blink_oneshot(struct led_trigger *trigger, -				      unsigned long *delay_on, -				      unsigned long *delay_off, +				      unsigned long delay_on, +				      unsigned long delay_off,  				      int invert) {}  static inline void led_trigger_set_default(struct led_classdev *led_cdev) {}  static inline int led_trigger_set(struct led_classdev *led_cdev, @@ -509,6 +579,21 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev)  #endif /* CONFIG_LEDS_TRIGGERS */ +/* Trigger specific enum */ +enum led_trigger_netdev_modes { +	TRIGGER_NETDEV_LINK = 0, +	TRIGGER_NETDEV_LINK_10, +	TRIGGER_NETDEV_LINK_100, +	TRIGGER_NETDEV_LINK_1000, +	TRIGGER_NETDEV_HALF_DUPLEX, +	TRIGGER_NETDEV_FULL_DUPLEX, +	TRIGGER_NETDEV_TX, +	TRIGGER_NETDEV_RX, + +	/* Keep last */ +	__TRIGGER_NETDEV_MAX, +}; +  /* Trigger specific functions */  #ifdef CONFIG_LEDS_TRIGGER_DISK  void ledtrig_disk_activity(bool write); |