Lines Matching +full:led +full:- +full:7

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for BCM6328 memory-mapped LEDs, based on leds-syscon.c
59 * struct bcm6328_led - state container for bcm6328 based LEDs
60 * @cdev: LED class device for this LED
63 * @pin: LED pin number
66 * @active_low: LED is active low
98 * bits [31:0] -> LEDs 8-23
99 * bits [47:32] -> LEDs 0-7
100 * bits [63:48] -> unused
105 return pin + 16; /* LEDs 0-7 (bits 47:32) */ in bcm6328_pin2shift()
107 return pin - 8; /* LEDs 8-23 (bits 31:0) */ in bcm6328_pin2shift()
110 static void bcm6328_led_mode(struct bcm6328_led *led, unsigned long value) in bcm6328_led_mode() argument
115 shift = bcm6328_pin2shift(led->pin); in bcm6328_led_mode()
117 mode = led->mem + BCM6328_REG_MODE_HI; in bcm6328_led_mode()
119 mode = led->mem + BCM6328_REG_MODE_LO; in bcm6328_led_mode()
130 struct bcm6328_led *led = in bcm6328_led_set() local
134 spin_lock_irqsave(led->lock, flags); in bcm6328_led_set()
136 /* Remove LED from cached HW blinking intervals */ in bcm6328_led_set()
137 led->blink_leds[0] &= ~BIT(led->pin); in bcm6328_led_set()
138 led->blink_leds[1] &= ~BIT(led->pin); in bcm6328_led_set()
140 /* Set LED on/off */ in bcm6328_led_set()
141 if ((led->active_low && value == LED_OFF) || in bcm6328_led_set()
142 (!led->active_low && value != LED_OFF)) in bcm6328_led_set()
143 bcm6328_led_mode(led, BCM6328_LED_MODE_ON); in bcm6328_led_set()
145 bcm6328_led_mode(led, BCM6328_LED_MODE_OFF); in bcm6328_led_set()
147 spin_unlock_irqrestore(led->lock, flags); in bcm6328_led_set()
165 struct bcm6328_led *led = in bcm6328_blink_set() local
177 dev_dbg(led_cdev->dev, in bcm6328_blink_set()
179 return -EINVAL; in bcm6328_blink_set()
183 dev_dbg(led_cdev->dev, in bcm6328_blink_set()
186 return -EINVAL; in bcm6328_blink_set()
189 spin_lock_irqsave(led->lock, flags); in bcm6328_blink_set()
194 * 2. Only this LED is assigned to the HW blinking interval. in bcm6328_blink_set()
197 if (led->blink_leds[0] == 0 || in bcm6328_blink_set()
198 led->blink_leds[0] == BIT(led->pin) || in bcm6328_blink_set()
199 led->blink_delay[0] == delay) { in bcm6328_blink_set()
202 /* Add LED to the first HW blinking interval cache */ in bcm6328_blink_set()
203 led->blink_leds[0] |= BIT(led->pin); in bcm6328_blink_set()
205 /* Remove LED from the second HW blinking interval cache */ in bcm6328_blink_set()
206 led->blink_leds[1] &= ~BIT(led->pin); in bcm6328_blink_set()
209 led->blink_delay[0] = delay; in bcm6328_blink_set()
212 val = bcm6328_led_read(led->mem + BCM6328_REG_INIT); in bcm6328_blink_set()
215 bcm6328_led_write(led->mem + BCM6328_REG_INIT, val); in bcm6328_blink_set()
217 /* Set the LED to first HW blinking interval */ in bcm6328_blink_set()
218 bcm6328_led_mode(led, BCM6328_LED_MODE_BLINK1); in bcm6328_blink_set()
221 } else if (led->blink_leds[1] == 0 || in bcm6328_blink_set()
222 led->blink_leds[1] == BIT(led->pin) || in bcm6328_blink_set()
223 led->blink_delay[1] == delay) { in bcm6328_blink_set()
226 /* Remove LED from the first HW blinking interval */ in bcm6328_blink_set()
227 led->blink_leds[0] &= ~BIT(led->pin); in bcm6328_blink_set()
229 /* Add LED to the second HW blinking interval */ in bcm6328_blink_set()
230 led->blink_leds[1] |= BIT(led->pin); in bcm6328_blink_set()
233 led->blink_delay[1] = delay; in bcm6328_blink_set()
236 val = bcm6328_led_read(led->mem + BCM6328_REG_INIT); in bcm6328_blink_set()
239 bcm6328_led_write(led->mem + BCM6328_REG_INIT, val); in bcm6328_blink_set()
241 /* Set the LED to second HW blinking interval */ in bcm6328_blink_set()
242 bcm6328_led_mode(led, BCM6328_LED_MODE_BLINK2); in bcm6328_blink_set()
246 dev_dbg(led_cdev->dev, in bcm6328_blink_set()
248 rc = -EINVAL; in bcm6328_blink_set()
250 spin_unlock_irqrestore(led->lock, flags); in bcm6328_blink_set()
267 /* Only LEDs 0-7 can be activity/link controlled */ in bcm6328_hwled()
271 cnt = of_property_count_elems_of_size(nc, "brcm,link-signal-sources", in bcm6328_hwled()
282 of_property_read_u32_index(nc, "brcm,link-signal-sources", i, in bcm6328_hwled()
298 "brcm,activity-signal-sources", in bcm6328_hwled()
309 of_property_read_u32_index(nc, "brcm,activity-signal-sources", in bcm6328_hwled()
332 struct bcm6328_led *led; in bcm6328_led() local
336 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); in bcm6328_led()
337 if (!led) in bcm6328_led()
338 return -ENOMEM; in bcm6328_led()
340 led->pin = reg; in bcm6328_led()
341 led->mem = mem; in bcm6328_led()
342 led->lock = lock; in bcm6328_led()
343 led->blink_leds = blink_leds; in bcm6328_led()
344 led->blink_delay = blink_delay; in bcm6328_led()
346 if (of_property_read_bool(nc, "active-low")) in bcm6328_led()
347 led->active_low = true; in bcm6328_led()
349 if (!of_property_read_string(nc, "default-state", &state)) { in bcm6328_led()
351 led->cdev.brightness = LED_FULL; in bcm6328_led()
356 shift = bcm6328_pin2shift(led->pin); in bcm6328_led()
365 if ((led->active_low && val == BCM6328_LED_MODE_OFF) || in bcm6328_led()
366 (!led->active_low && val == BCM6328_LED_MODE_ON)) in bcm6328_led()
367 led->cdev.brightness = LED_FULL; in bcm6328_led()
369 led->cdev.brightness = LED_OFF; in bcm6328_led()
371 led->cdev.brightness = LED_OFF; in bcm6328_led()
374 led->cdev.brightness = LED_OFF; in bcm6328_led()
377 bcm6328_led_set(&led->cdev, led->cdev.brightness); in bcm6328_led()
379 led->cdev.brightness_set = bcm6328_led_set; in bcm6328_led()
380 led->cdev.blink_set = bcm6328_blink_set; in bcm6328_led()
383 rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); in bcm6328_led()
387 dev_dbg(dev, "registered LED %s\n", led->cdev.name); in bcm6328_led()
394 struct device *dev = &pdev->dev; in bcm6328_leds_probe()
395 struct device_node *np = dev_of_node(&pdev->dev); in bcm6328_leds_probe()
407 return -ENOMEM; in bcm6328_leds_probe()
412 return -ENOMEM; in bcm6328_leds_probe()
417 return -ENOMEM; in bcm6328_leds_probe()
427 if (of_property_read_bool(np, "brcm,serial-leds")) in bcm6328_leds_probe()
429 if (of_property_read_bool(np, "brcm,serial-mux")) in bcm6328_leds_probe()
431 if (of_property_read_bool(np, "brcm,serial-clk-low")) in bcm6328_leds_probe()
433 if (!of_property_read_bool(np, "brcm,serial-dat-low")) in bcm6328_leds_probe()
435 if (!of_property_read_bool(np, "brcm,serial-shift-inv")) in bcm6328_leds_probe()
447 dev_err(dev, "invalid LED (%u >= %d)\n", reg, in bcm6328_leds_probe()
452 if (of_property_read_bool(child, "brcm,hardware-controlled")) in bcm6328_leds_probe()
468 { .compatible = "brcm,bcm6328-leds", },
476 .name = "leds-bcm6328",
485 MODULE_DESCRIPTION("LED driver for BCM6328 controllers");
487 MODULE_ALIAS("platform:leds-bcm6328");