Lines Matching +full:led +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0
13 * +-----+---------+
14 * | LED | COMMAND |
15 * +-----+---------+
16 * | 1 | 1 |
17 * +-----+---------+
21 * +----------+--------------+-------------------------------------------+
23 * +----------+--------------+-------------------------------------------+
25 * +----------+--------------+-------------------------------------------+
27 * +----------+--------------+-------------------------------------------+
29 * +----------+--------------+-------------------------------------------+
32 * +----------+-----------------+--------------+--------------+
34 * +----------+-----------------+--------------+--------------+
36 * +----------+-----------------------------------------------+
37 * | '1' 0x31 | On |
38 * +----------+-----------------+--------------+--------------+
40 * +----------+-----------------+--------------+
42 * +----------+-----------------+
44 * +----------+-----------------+
46 * +----------+-----------------+
58 EL_ON = '1',
60 /* for Screen LED */
63 /* for Pipe LED */
85 static int el15203000_cmd(struct el15203000_led *led, u8 brightness) in el15203000_cmd() argument
91 mutex_lock(&led->priv->lock); in el15203000_cmd()
93 dev_dbg(led->priv->dev, "Set brightness of 0x%02x(%c) to 0x%02x(%c)", in el15203000_cmd()
94 led->reg, led->reg, brightness, brightness); in el15203000_cmd()
97 if (time_after(led->priv->delay, jiffies)) { in el15203000_cmd()
98 dev_dbg(led->priv->dev, "Wait %luus to sync", in el15203000_cmd()
102 EL_FW_DELAY_USEC + 1); in el15203000_cmd()
105 cmd[0] = led->reg; in el15203000_cmd()
106 cmd[1] = brightness; in el15203000_cmd()
111 EL_FW_DELAY_USEC + 1); in el15203000_cmd()
113 ret = spi_write(led->priv->spi, &cmd[i], sizeof(cmd[i])); in el15203000_cmd()
115 dev_err(led->priv->dev, in el15203000_cmd()
121 led->priv->delay = jiffies + usecs_to_jiffies(EL_FW_DELAY_USEC); in el15203000_cmd()
123 mutex_unlock(&led->priv->lock); in el15203000_cmd()
131 struct el15203000_led *led = container_of(ldev, in el15203000_set_blocking() local
135 return el15203000_cmd(led, brightness == LED_OFF ? EL_OFF : EL_ON); in el15203000_set_blocking()
142 struct el15203000_led *led = container_of(ldev, in el15203000_pattern_set_S() local
148 pattern[1].delta_t != 4000 || pattern[1].brightness != 1) in el15203000_pattern_set_S()
149 return -EINVAL; in el15203000_pattern_set_S()
151 dev_dbg(led->priv->dev, "Breathing mode for 0x%02x(%c)", in el15203000_pattern_set_S()
152 led->reg, led->reg); in el15203000_pattern_set_S()
154 return el15203000_cmd(led, EL_SCREEN_BREATHING); in el15203000_pattern_set_S()
175 val = right ? val >> 1 : val << 1; in is_cascade()
196 struct el15203000_led *led = container_of(ldev, in el15203000_pattern_set_P() local
201 return -EINVAL; in el15203000_pattern_set_P()
204 dev_dbg(led->priv->dev, "Cascade mode for 0x%02x(%c)", in el15203000_pattern_set_P()
205 led->reg, led->reg); in el15203000_pattern_set_P()
209 dev_dbg(led->priv->dev, "Inverse cascade mode for 0x%02x(%c)", in el15203000_pattern_set_P()
210 led->reg, led->reg); in el15203000_pattern_set_P()
214 dev_dbg(led->priv->dev, "Bounce mode for 0x%02x(%c)", in el15203000_pattern_set_P()
215 led->reg, led->reg); in el15203000_pattern_set_P()
219 dev_dbg(led->priv->dev, "Inverse bounce mode for 0x%02x(%c)", in el15203000_pattern_set_P()
220 led->reg, led->reg); in el15203000_pattern_set_P()
224 dev_err(led->priv->dev, "Invalid hw_pattern for 0x%02x(%c)!", in el15203000_pattern_set_P()
225 led->reg, led->reg); in el15203000_pattern_set_P()
227 return -EINVAL; in el15203000_pattern_set_P()
230 return el15203000_cmd(led, cmd); in el15203000_pattern_set_P()
235 struct el15203000_led *led = container_of(ldev, in el15203000_pattern_clear() local
239 return el15203000_cmd(led, EL_OFF); in el15203000_pattern_clear()
244 struct el15203000_led *led = priv->leds; in el15203000_probe_dt() local
248 device_for_each_child_node(priv->dev, child) { in el15203000_probe_dt()
251 ret = fwnode_property_read_u32(child, "reg", &led->reg); in el15203000_probe_dt()
253 dev_err(priv->dev, "LED without ID number"); in el15203000_probe_dt()
259 if (led->reg > U8_MAX) { in el15203000_probe_dt()
260 dev_err(priv->dev, "LED value %d is invalid", led->reg); in el15203000_probe_dt()
263 return -EINVAL; in el15203000_probe_dt()
266 led->priv = priv; in el15203000_probe_dt()
267 led->ldev.max_brightness = LED_ON; in el15203000_probe_dt()
268 led->ldev.brightness_set_blocking = el15203000_set_blocking; in el15203000_probe_dt()
270 if (led->reg == 'S') { in el15203000_probe_dt()
271 led->ldev.pattern_set = el15203000_pattern_set_S; in el15203000_probe_dt()
272 led->ldev.pattern_clear = el15203000_pattern_clear; in el15203000_probe_dt()
273 } else if (led->reg == 'P') { in el15203000_probe_dt()
274 led->ldev.pattern_set = el15203000_pattern_set_P; in el15203000_probe_dt()
275 led->ldev.pattern_clear = el15203000_pattern_clear; in el15203000_probe_dt()
279 ret = devm_led_classdev_register_ext(priv->dev, &led->ldev, in el15203000_probe_dt()
282 dev_err(priv->dev, in el15203000_probe_dt()
283 "failed to register LED device %s, err %d", in el15203000_probe_dt()
284 led->ldev.name, ret); in el15203000_probe_dt()
290 led++; in el15203000_probe_dt()
301 count = device_get_child_node_count(&spi->dev); in el15203000_probe()
303 dev_err(&spi->dev, "LEDs are not defined in device tree!"); in el15203000_probe()
304 return -ENODEV; in el15203000_probe()
307 priv = devm_kzalloc(&spi->dev, struct_size(priv, leds, count), in el15203000_probe()
310 return -ENOMEM; in el15203000_probe()
312 mutex_init(&priv->lock); in el15203000_probe()
313 priv->count = count; in el15203000_probe()
314 priv->dev = &spi->dev; in el15203000_probe()
315 priv->spi = spi; in el15203000_probe()
316 priv->delay = jiffies - in el15203000_probe()
328 mutex_destroy(&priv->lock); in el15203000_remove()
352 MODULE_DESCRIPTION("el15203000 LED driver");