Lines Matching +full:default +full:- +full:brightness

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)
11 * The value for minimum and maximum brightness depends on the device
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
41 /* SPI byte that will be send to switch the LED to maximum brightness */
59 { .compatible = "ubnt,acb-spi-led", .data = &ubnt_acb_spi_led_cdef },
66 enum led_brightness brightness) in spi_byte_brightness_set_blocking() argument
72 value = (u8) brightness + led->cdef->off_value; in spi_byte_brightness_set_blocking()
74 mutex_lock(&led->mutex); in spi_byte_brightness_set_blocking()
75 ret = spi_write(led->spi, &value, sizeof(value)); in spi_byte_brightness_set_blocking()
76 mutex_unlock(&led->mutex); in spi_byte_brightness_set_blocking()
84 struct device *dev = &spi->dev; in spi_byte_probe()
86 const char *name = "leds-spi-byte::"; in spi_byte_probe()
91 dev_err(dev, "Device must have exactly one LED sub-node."); in spi_byte_probe()
92 return -EINVAL; in spi_byte_probe()
98 return -ENOMEM; in spi_byte_probe()
101 strlcpy(led->name, name, sizeof(led->name)); in spi_byte_probe()
102 led->spi = spi; in spi_byte_probe()
103 mutex_init(&led->mutex); in spi_byte_probe()
104 led->cdef = device_get_match_data(dev); in spi_byte_probe()
105 led->ldev.name = led->name; in spi_byte_probe()
106 led->ldev.brightness = LED_OFF; in spi_byte_probe()
107 led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value; in spi_byte_probe()
108 led->ldev.brightness_set_blocking = spi_byte_brightness_set_blocking; in spi_byte_probe()
110 state = of_get_property(child, "default-state", NULL); in spi_byte_probe()
113 led->ldev.brightness = led->ldev.max_brightness; in spi_byte_probe()
116 dev_err(dev, "default-state can only be 'on' or 'off'"); in spi_byte_probe()
117 return -EINVAL; in spi_byte_probe()
120 spi_byte_brightness_set_blocking(&led->ldev, in spi_byte_probe()
121 led->ldev.brightness); in spi_byte_probe()
123 ret = devm_led_classdev_register(&spi->dev, &led->ldev); in spi_byte_probe()
125 mutex_destroy(&led->mutex); in spi_byte_probe()
137 mutex_destroy(&led->mutex); in spi_byte_remove()
151 MODULE_AUTHOR("Christian Mauderer <oss@c-mauderer.de>");
154 MODULE_ALIAS("spi:leds-spi-byte");