Lines Matching +full:led +full:-
1 // SPDX-License-Identifier: GPL-2.0
14 * +-----+---------+
15 * | LED | COMMAND |
16 * +-----+---------+
18 * +-----+---------+
22 * +----------+--------------+-------------------------------------------+
24 * +----------+--------------+-------------------------------------------+
26 * +----------+--------------+-------------------------------------------+
28 * +----------+--------------+-------------------------------------------+
30 * +----------+--------------+-------------------------------------------+
33 * +----------+-----------------+--------------+--------------+
35 * +----------+-----------------+--------------+--------------+
37 * +----------+-----------------------------------------------+
39 * +----------+-----------------+--------------+--------------+
41 * +----------+-----------------+--------------+
43 * +----------+-----------------+
45 * +----------+-----------------+
47 * +----------+-----------------+
61 /* for Screen LED */
64 /* for Pipe LED */
88 static int el15203000_cmd(struct el15203000_led *led, u8 brightness) in el15203000_cmd() argument
94 mutex_lock(&led->priv->lock); in el15203000_cmd()
96 dev_dbg(led->priv->dev, "Set brightness of 0x%02x(%c) to 0x%02x(%c)", in el15203000_cmd()
97 led->reg, led->reg, brightness, brightness); in el15203000_cmd()
100 if (time_after(led->priv->delay, jiffies)) { in el15203000_cmd()
101 dev_dbg(led->priv->dev, "Wait %luus to sync", in el15203000_cmd()
108 cmd[0] = led->reg; in el15203000_cmd()
116 ret = spi_write(led->priv->spi, &cmd[i], sizeof(cmd[i])); in el15203000_cmd()
118 dev_err(led->priv->dev, in el15203000_cmd()
124 led->priv->delay = jiffies + usecs_to_jiffies(EL_FW_DELAY_USEC); in el15203000_cmd()
126 mutex_unlock(&led->priv->lock); in el15203000_cmd()
134 struct el15203000_led *led = to_el15203000_led(ldev); in el15203000_set_blocking() local
136 return el15203000_cmd(led, brightness == LED_OFF ? EL_OFF : EL_ON); in el15203000_set_blocking()
143 struct el15203000_led *led = to_el15203000_led(ldev); in el15203000_pattern_set_S() local
148 return -EINVAL; in el15203000_pattern_set_S()
150 dev_dbg(led->priv->dev, "Breathing mode for 0x%02x(%c)", in el15203000_pattern_set_S()
151 led->reg, led->reg); in el15203000_pattern_set_S()
153 return el15203000_cmd(led, EL_SCREEN_BREATHING); in el15203000_pattern_set_S()
194 struct el15203000_led *led = to_el15203000_led(ldev); in el15203000_pattern_set_P() local
198 return -EINVAL; in el15203000_pattern_set_P()
201 dev_dbg(led->priv->dev, "Cascade mode for 0x%02x(%c)", in el15203000_pattern_set_P()
202 led->reg, led->reg); in el15203000_pattern_set_P()
206 dev_dbg(led->priv->dev, "Inverse cascade mode for 0x%02x(%c)", in el15203000_pattern_set_P()
207 led->reg, led->reg); in el15203000_pattern_set_P()
211 dev_dbg(led->priv->dev, "Bounce mode for 0x%02x(%c)", in el15203000_pattern_set_P()
212 led->reg, led->reg); in el15203000_pattern_set_P()
216 dev_dbg(led->priv->dev, "Inverse bounce mode for 0x%02x(%c)", in el15203000_pattern_set_P()
217 led->reg, led->reg); in el15203000_pattern_set_P()
221 dev_err(led->priv->dev, "Invalid hw_pattern for 0x%02x(%c)!", in el15203000_pattern_set_P()
222 led->reg, led->reg); in el15203000_pattern_set_P()
224 return -EINVAL; in el15203000_pattern_set_P()
227 return el15203000_cmd(led, cmd); in el15203000_pattern_set_P()
232 struct el15203000_led *led = to_el15203000_led(ldev); in el15203000_pattern_clear() local
234 return el15203000_cmd(led, EL_OFF); in el15203000_pattern_clear()
239 struct el15203000_led *led = priv->leds; in el15203000_probe_dt() local
243 device_for_each_child_node(priv->dev, child) { in el15203000_probe_dt()
246 ret = fwnode_property_read_u32(child, "reg", &led->reg); in el15203000_probe_dt()
248 dev_err(priv->dev, "LED without ID number"); in el15203000_probe_dt()
252 if (led->reg > U8_MAX) { in el15203000_probe_dt()
253 dev_err(priv->dev, "LED value %d is invalid", led->reg); in el15203000_probe_dt()
254 ret = -EINVAL; in el15203000_probe_dt()
258 led->priv = priv; in el15203000_probe_dt()
259 led->ldev.max_brightness = LED_ON; in el15203000_probe_dt()
260 led->ldev.brightness_set_blocking = el15203000_set_blocking; in el15203000_probe_dt()
262 if (led->reg == 'S') { in el15203000_probe_dt()
263 led->ldev.pattern_set = el15203000_pattern_set_S; in el15203000_probe_dt()
264 led->ldev.pattern_clear = el15203000_pattern_clear; in el15203000_probe_dt()
265 } else if (led->reg == 'P') { in el15203000_probe_dt()
266 led->ldev.pattern_set = el15203000_pattern_set_P; in el15203000_probe_dt()
267 led->ldev.pattern_clear = el15203000_pattern_clear; in el15203000_probe_dt()
271 ret = devm_led_classdev_register_ext(priv->dev, &led->ldev, in el15203000_probe_dt()
274 dev_err(priv->dev, in el15203000_probe_dt()
275 "failed to register LED device %s, err %d", in el15203000_probe_dt()
276 led->ldev.name, ret); in el15203000_probe_dt()
280 led++; in el15203000_probe_dt()
295 count = device_get_child_node_count(&spi->dev); in el15203000_probe()
297 dev_err(&spi->dev, "LEDs are not defined in device tree!"); in el15203000_probe()
298 return -ENODEV; in el15203000_probe()
301 priv = devm_kzalloc(&spi->dev, struct_size(priv, leds, count), in el15203000_probe()
304 return -ENOMEM; in el15203000_probe()
306 mutex_init(&priv->lock); in el15203000_probe()
307 priv->count = count; in el15203000_probe()
308 priv->dev = &spi->dev; in el15203000_probe()
309 priv->spi = spi; in el15203000_probe()
310 priv->delay = jiffies - in el15203000_probe()
322 mutex_destroy(&priv->lock); in el15203000_remove()
344 MODULE_DESCRIPTION("el15203000 LED driver");