18446744073709551615 !ˆÀÎ „ZŸÅ¿Ñ?÷!/* SPDX-License-Identifier: GPL-2.0-only */ /* * Driver model for leds and led triggers * * Copyright (C) 2005 John Lenz * Copyright (C) 2005 Richard Purdie */ #ifndef __LINUX_LEDS_H_INCLUDED #define __LINUX_LEDS_H_INCLUDED #include #include #include #include #include #include #include #include #include struct device; struct led_pattern; struct device_node; /* * LED Core */ /* This is obsolete/useless. We now support variable maximum brightness. */ enum led_brightness { LED_OFF = 0, LED_ON = 1, LED_HALF = 127, LED_FULL = 255, }; enum led_default_state { LEDS_DEFSTATE_OFF = 0, LEDS_DEFSTATE_ON = 1, LEDS_DEFSTATE_KEEP = 2, }; struct led_init_data { /* device fwnode handle */ struct fwnode_handle *fwnode; /* * default tuple, for backward compatibility * with in-driver hard-coded LED names used as a fallback when * DT "label" property is absent; it should be set to NULL * in new LED class drivers. */ const char *default_label; /* * string to be used for devicename section of LED class device * either for label based LED name composition path or for fwnode * based when devname_mandatory is true */ const char *devicename; /* * indicates if LED name should always comprise devicename section; * only LEDs exposed by drivers of hot-pluggable devices should * set it to true */ bool devname_mandatory; }; struct led_hw_trigger_type { int dummy; }; struct led_classdev { const char *name; unsigned int brightness; unsigned int max_brightness; int flags; /* Lower 16 bits reflect status */ #define LED_SUSPENDED BIT(0) #define LED_UNREGISTERING BIT(1) /* Upper 16 bits reflect control information */ #define LED_CORE_SUSPENDRESUME BIT(16) #define LED_SYSFS_DISABLE BIT(17) #define LED_DEV_CAP_FLASH BIT(18) #define LED_HW_PLUGGABLE BIT(19) #define LED_PANIC_INDICATOR BIT(20) #define LED_BRIGHT_HW_CHANGED BIT(21) #define LED_RETAIN_AT_SHUTDOWN BIT(22) #define LED_INIT_DEFAULT_TRIGGER BIT(23) /* set_brightness_work / blink_timer flags, atomic, private. */ unsigned long work_flags; #define LED_BLINK_SW 0 #define LED_BLINK_ONESHOT 1 #define LED_BLINK_ONESHOT_STOP 2 #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 * that can sleep while setting brightness. */ void (*brightness_set)(struct led_classdev *led_cdev, enum led_brightness brightness); /* * Set LED brightness level immediately - it can block the caller for * the time required for accessing a LED device register. */ int (*brightness_set_blocking)(struct led_classdev *led_cdev, enum led_brightness brightness); /* Get LED brightness level */ enum led_brightness (*brightness_get)(struct led_classdev *led_cdev); /* * Activate hardware accelerated blink, delays are in milliseconds * and if both are zero then a sensible default should be chosen. * The call should adjust the timings in that case and if it can't * 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, unsigned long *delay_off); int (*pattern_set)(struct led_classdev *led_cdev, struct led_pattern *pattern, u32 len,