Lines Matching +full:led +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
31 * struct bcm6358_led - state container for bcm6358 based LEDs
32 * @cdev: LED class device for this LED
35 * @pin: LED pin number
36 * @active_low: LED is active low
78 struct bcm6358_led *led = in bcm6358_led_set() local
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()
98 struct bcm6358_led *led; in bcm6358_led() local
103 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); in bcm6358_led()
104 if (!led) in bcm6358_led()
105 return -ENOMEM; in bcm6358_led()
107 led->pin = reg; in bcm6358_led()
108 led->mem = mem; in bcm6358_led()
109 led->lock = lock; in bcm6358_led()
111 if (of_property_read_bool(nc, "active-low")) in bcm6358_led()
112 led->active_low = true; in bcm6358_led()
119 led->cdev.brightness = LED_FULL; in bcm6358_led()
122 val = bcm6358_led_read(led->mem + BCM6358_REG_MODE); in bcm6358_led()
123 val &= BIT(led->pin); in bcm6358_led()
124 if ((led->active_low && !val) || (!led->active_low && val)) in bcm6358_led()
125 led->cdev.brightness = LED_FULL; in bcm6358_led()
127 led->cdev.brightness = LED_OFF; in bcm6358_led()
130 led->cdev.brightness = LED_OFF; in bcm6358_led()
133 bcm6358_led_set(&led->cdev, led->cdev.brightness); in bcm6358_led()
135 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()
161 return -ENOMEM; in bcm6358_leds_probe()
167 if (of_property_read_bool(np, "brcm,clk-dat-low")) in bcm6358_leds_probe()
169 of_property_read_u32(np, "brcm,clk-div", &clk_div); in bcm6358_leds_probe()
194 dev_err(dev, "invalid LED (%u >= %d)\n", reg, in bcm6358_leds_probe()
208 { .compatible = "brcm,bcm6358-leds", },
216 .name = "leds-bcm6358",
224 MODULE_DESCRIPTION("LED driver for BCM6358 controllers");
226 MODULE_ALIAS("platform:leds-bcm6358");