Lines Matching +full:leds +full:- +full:active +full:- +full:low

1 // SPDX-License-Identifier: GPL-2.0
4 #include <linux/leds.h>
52 bool active; member
56 struct sc27xx_led leds[SC27XX_LEDS_MAX]; member
82 static u32 sc27xx_led_get_offset(struct sc27xx_led *leds) in sc27xx_led_get_offset() argument
84 return leds->priv->base + SC27XX_LEDS_OFFSET * leds->line; in sc27xx_led_get_offset()
87 static int sc27xx_led_enable(struct sc27xx_led *leds, enum led_brightness value) in sc27xx_led_enable() argument
89 u32 base = sc27xx_led_get_offset(leds); in sc27xx_led_enable()
90 u32 ctrl_base = leds->priv->base + SC27XX_LEDS_CTRL; in sc27xx_led_enable()
91 u8 ctrl_shift = SC27XX_CTRL_SHIFT * leds->line; in sc27xx_led_enable()
92 struct regmap *regmap = leds->priv->regmap; in sc27xx_led_enable()
107 static int sc27xx_led_disable(struct sc27xx_led *leds) in sc27xx_led_disable() argument
109 struct regmap *regmap = leds->priv->regmap; in sc27xx_led_disable()
110 u32 ctrl_base = leds->priv->base + SC27XX_LEDS_CTRL; in sc27xx_led_disable()
111 u8 ctrl_shift = SC27XX_CTRL_SHIFT * leds->line; in sc27xx_led_disable()
119 struct sc27xx_led *leds = to_sc27xx_led(ldev); in sc27xx_led_set() local
122 mutex_lock(&leds->priv->lock); in sc27xx_led_set()
125 err = sc27xx_led_disable(leds); in sc27xx_led_set()
127 err = sc27xx_led_enable(leds, value); in sc27xx_led_set()
129 mutex_unlock(&leds->priv->lock); in sc27xx_led_set()
140 offset = v - SC27XX_DELTA_T_MIN; in sc27xx_led_clamp_align_delta_t()
148 struct sc27xx_led *leds = to_sc27xx_led(ldev); in sc27xx_led_pattern_clear() local
149 struct regmap *regmap = leds->priv->regmap; in sc27xx_led_pattern_clear()
150 u32 base = sc27xx_led_get_offset(leds); in sc27xx_led_pattern_clear()
151 u32 ctrl_base = leds->priv->base + SC27XX_LEDS_CTRL; in sc27xx_led_pattern_clear()
152 u8 ctrl_shift = SC27XX_CTRL_SHIFT * leds->line; in sc27xx_led_pattern_clear()
155 mutex_lock(&leds->priv->lock); in sc27xx_led_pattern_clear()
157 /* Reset the rise, high, fall and low time to zero. */ in sc27xx_led_pattern_clear()
164 ldev->brightness = LED_OFF; in sc27xx_led_pattern_clear()
166 mutex_unlock(&leds->priv->lock); in sc27xx_led_pattern_clear()
175 struct sc27xx_led *leds = to_sc27xx_led(ldev); in sc27xx_led_pattern_set() local
176 u32 base = sc27xx_led_get_offset(leds); in sc27xx_led_pattern_set()
177 u32 ctrl_base = leds->priv->base + SC27XX_LEDS_CTRL; in sc27xx_led_pattern_set()
178 u8 ctrl_shift = SC27XX_CTRL_SHIFT * leds->line; in sc27xx_led_pattern_set()
179 struct regmap *regmap = leds->priv->regmap; in sc27xx_led_pattern_set()
184 * time and low time to enable the breathing mode. in sc27xx_led_pattern_set()
187 return -EINVAL; in sc27xx_led_pattern_set()
189 mutex_lock(&leds->priv->lock); in sc27xx_led_pattern_set()
233 ldev->brightness = pattern[1].brightness; in sc27xx_led_pattern_set()
236 mutex_unlock(&leds->priv->lock); in sc27xx_led_pattern_set()
245 err = sc27xx_led_init(priv->regmap); in sc27xx_led_register()
250 struct sc27xx_led *led = &priv->leds[i]; in sc27xx_led_register()
253 if (!led->active) in sc27xx_led_register()
256 led->line = i; in sc27xx_led_register()
257 led->priv = priv; in sc27xx_led_register()
258 led->ldev.brightness_set_blocking = sc27xx_led_set; in sc27xx_led_register()
259 led->ldev.pattern_set = sc27xx_led_pattern_set; in sc27xx_led_register()
260 led->ldev.pattern_clear = sc27xx_led_pattern_clear; in sc27xx_led_register()
261 led->ldev.default_trigger = "pattern"; in sc27xx_led_register()
263 init_data.fwnode = led->fwnode; in sc27xx_led_register()
267 err = devm_led_classdev_register_ext(dev, &led->ldev, in sc27xx_led_register()
278 struct device *dev = &pdev->dev; in sc27xx_led_probe()
286 return -EINVAL; in sc27xx_led_probe()
296 return -ENOMEM; in sc27xx_led_probe()
299 mutex_init(&priv->lock); in sc27xx_led_probe()
300 priv->base = base; in sc27xx_led_probe()
301 priv->regmap = dev_get_regmap(dev->parent, NULL); in sc27xx_led_probe()
302 if (!priv->regmap) { in sc27xx_led_probe()
303 err = -ENODEV; in sc27xx_led_probe()
312 mutex_destroy(&priv->lock); in sc27xx_led_probe()
316 if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) { in sc27xx_led_probe()
318 mutex_destroy(&priv->lock); in sc27xx_led_probe()
319 return -EINVAL; in sc27xx_led_probe()
322 priv->leds[reg].fwnode = of_fwnode_handle(child); in sc27xx_led_probe()
323 priv->leds[reg].active = true; in sc27xx_led_probe()
328 mutex_destroy(&priv->lock); in sc27xx_led_probe()
337 mutex_destroy(&priv->lock); in sc27xx_led_remove()
342 { .compatible = "sprd,sc2731-bltc", },
349 .name = "sprd-bltc",