Lines Matching +full:leds +full:- +full:active +full:- +full:low
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for BCM6358 memory-mapped LEDs, based on leds-syscon.c
9 #include <linux/leds.h>
31 * struct bcm6358_led - state container for bcm6358 based LEDs
36 * @active_low: LED is active low
82 spin_lock_irqsave(led->lock, flags); in bcm6358_led_set()
83 bcm6358_led_busy(led->mem); in bcm6358_led_set()
84 val = bcm6358_led_read(led->mem + BCM6358_REG_MODE); in bcm6358_led_set()
85 if ((led->active_low && value == LED_OFF) || in bcm6358_led_set()
86 (!led->active_low && value != LED_OFF)) in bcm6358_led_set()
87 val |= BIT(led->pin); in bcm6358_led_set()
89 val &= ~(BIT(led->pin)); in bcm6358_led_set()
90 bcm6358_led_write(led->mem + BCM6358_REG_MODE, val); in bcm6358_led_set()
91 spin_unlock_irqrestore(led->lock, flags); in bcm6358_led_set()
104 return -ENOMEM; in bcm6358_led()
106 led->pin = reg; in bcm6358_led()
107 led->mem = mem; in bcm6358_led()
108 led->lock = lock; in bcm6358_led()
110 if (of_property_read_bool(nc, "active-low")) in bcm6358_led()
111 led->active_low = true; in bcm6358_led()
113 if (!of_property_read_string(nc, "default-state", &state)) { in bcm6358_led()
115 led->cdev.brightness = LED_FULL; in bcm6358_led()
118 val = bcm6358_led_read(led->mem + BCM6358_REG_MODE); in bcm6358_led()
119 val &= BIT(led->pin); in bcm6358_led()
120 if ((led->active_low && !val) || in bcm6358_led()
121 (!led->active_low && val)) in bcm6358_led()
122 led->cdev.brightness = LED_FULL; in bcm6358_led()
124 led->cdev.brightness = LED_OFF; in bcm6358_led()
126 led->cdev.brightness = LED_OFF; in bcm6358_led()
129 led->cdev.brightness = LED_OFF; in bcm6358_led()
132 bcm6358_led_set(&led->cdev, led->cdev.brightness); in bcm6358_led()
134 led->cdev.brightness_set = bcm6358_led_set; in bcm6358_led()
137 rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); in bcm6358_led()
141 dev_dbg(dev, "registered LED %s\n", led->cdev.name); in bcm6358_led()
148 struct device *dev = &pdev->dev; in bcm6358_leds_probe()
149 struct device_node *np = dev_of_node(&pdev->dev); in bcm6358_leds_probe()
162 return -ENOMEM; in bcm6358_leds_probe()
168 if (of_property_read_bool(np, "brcm,clk-dat-low")) in bcm6358_leds_probe()
170 of_property_read_u32(np, "brcm,clk-div", &clk_div); in bcm6358_leds_probe()
211 { .compatible = "brcm,bcm6358-leds", },
219 .name = "leds-bcm6358",
229 MODULE_ALIAS("platform:leds-bcm6358");