Lines Matching +full:spi +full:- +full:controlled
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Christian Mauderer <oss@c-mauderer.de>
5 * The driver supports controllers with a very simple SPI protocol:
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
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
36 #include <linux/spi/spi.h>
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 */
48 struct spi_device *spi; member
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()
75 static int spi_byte_probe(struct spi_device *spi) in spi_byte_probe() argument
78 struct device *dev = &spi->dev; in spi_byte_probe()
85 dev_err(dev, "Device must have exactly one LED sub-node."); in spi_byte_probe()
86 return -EINVAL; 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");