Lines Matching +full:led +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Christian Mauderer <oss@c-mauderer.de>
6 * - one LED is controlled by a single byte on MOSI
7 * - the value of the byte gives the brightness between two values (lowest to
9 * - no return value is necessary (no MISO signal)
15 * - "ubnt,acb-spi-led": Microcontroller (SONiX 8F26E611LA) based device used
18 * * Higher two bits set a mode. Lower six bits are a parameter.
19 * * Mode: 00 -> set brightness between 0x00 (min) and 0x3F (max)
20 * * Mode: 01 -> pulsing pattern (min -> max -> min) with an interval. From
24 * * Mode: 10 -> same as 01 but with only a ramp from min to max. Again a
26 * * Mode: 11 -> blinking (off -> 25% -> off -> 25% -> ...) with a period of
28 * NOTE: This driver currently only supports mode 00.
40 /* SPI byte that will be send to switch the LED off */
42 /* SPI byte that will be send to switch the LED to maximum brightness */
62 struct spi_byte_led *led = container_of(dev, struct spi_byte_led, ldev); in spi_byte_brightness_set_blocking() local
66 value = (u8) brightness + led->cdef->off_value; in spi_byte_brightness_set_blocking()
68 mutex_lock(&led->mutex); in spi_byte_brightness_set_blocking()
69 ret = spi_write(led->spi, &value, sizeof(value)); in spi_byte_brightness_set_blocking()
70 mutex_unlock(&led->mutex); in spi_byte_brightness_set_blocking()
78 struct device *dev = &spi->dev; in spi_byte_probe()
79 struct spi_byte_led *led; in spi_byte_probe() local
85 dev_err(dev, "Device must have exactly one LED sub-node."); in spi_byte_probe()
86 return -EINVAL; in spi_byte_probe()
89 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); in spi_byte_probe()
90 if (!led) in spi_byte_probe()
91 return -ENOMEM; in spi_byte_probe()
93 ret = devm_mutex_init(dev, &led->mutex); in spi_byte_probe()
97 led->spi = spi; in spi_byte_probe()
98 led->cdef = device_get_match_data(dev); in spi_byte_probe()
99 led->ldev.brightness = LED_OFF; in spi_byte_probe()
100 led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value; in spi_byte_probe()
101 led->ldev.brightness_set_blocking = spi_byte_brightness_set_blocking; in spi_byte_probe()
107 led->ldev.brightness = led->ldev.max_brightness; in spi_byte_probe()
108 spi_byte_brightness_set_blocking(&led->ldev, in spi_byte_probe()
109 led->ldev.brightness); in spi_byte_probe()
112 init_data.devicename = "leds-spi-byte"; in spi_byte_probe()
115 return devm_led_classdev_register_ext(dev, &led->ldev, &init_data); in spi_byte_probe()
119 { .compatible = "ubnt,acb-spi-led", .data = &ubnt_acb_spi_led_cdef },
133 MODULE_AUTHOR("Christian Mauderer <oss@c-mauderer.de>");
134 MODULE_DESCRIPTION("single byte SPI LED driver");
136 MODULE_ALIAS("spi:leds-spi-byte");