Lines Matching +full:bcm6328 +full:- +full:leds

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for BCM6328 memory-mapped LEDs, based on leds-syscon.c
9 #include <linux/leds.h>
59 * struct bcm6328_led - state container for bcm6328 based LEDs
64 * @blink_leds: blinking LEDs
97 * LEDMode 64 bits / 24 LEDs
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()
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()
134 spin_lock_irqsave(led->lock, flags); 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()
141 if ((led->active_low && value == LED_OFF) || in bcm6328_led_set()
142 (!led->active_low && value != LED_OFF)) in bcm6328_led_set()
147 spin_unlock_irqrestore(led->lock, flags); in bcm6328_led_set()
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()
193 * 1. No LEDs assigned to the HW blinking interval. in bcm6328_blink_set()
195 * 3. LEDs with the same delay assigned. 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()
203 led->blink_leds[0] |= BIT(led->pin); 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()
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()
227 led->blink_leds[0] &= ~BIT(led->pin); 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()
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()
340 return -ENOMEM; in bcm6328_led()
342 led->pin = reg; in bcm6328_led()
343 led->mem = mem; in bcm6328_led()
344 led->lock = lock; in bcm6328_led()
345 led->blink_leds = blink_leds; in bcm6328_led()
346 led->blink_delay = blink_delay; in bcm6328_led()
348 if (of_property_read_bool(nc, "active-low")) in bcm6328_led()
349 led->active_low = true; in bcm6328_led()
356 led->cdev.brightness = LED_FULL; in bcm6328_led()
359 shift = bcm6328_pin2shift(led->pin); in bcm6328_led()
367 if ((led->active_low && val == BCM6328_LED_MODE_OFF) || in bcm6328_led()
368 (!led->active_low && val == BCM6328_LED_MODE_ON)) in bcm6328_led()
369 led->cdev.brightness = LED_FULL; 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()
382 rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); in bcm6328_led()
386 dev_dbg(dev, "registered LED %s\n", led->cdev.name); in bcm6328_led()
393 struct device *dev = &pdev->dev; in bcm6328_leds_probe()
394 struct device_node *np = dev_of_node(&pdev->dev); in bcm6328_leds_probe()
405 return -ENOMEM; in bcm6328_leds_probe()
410 return -ENOMEM; in bcm6328_leds_probe()
415 return -ENOMEM; in bcm6328_leds_probe()
425 if (of_property_read_bool(np, "brcm,serial-leds")) in bcm6328_leds_probe()
427 if (of_property_read_bool(np, "brcm,serial-mux")) in bcm6328_leds_probe()
429 if (of_property_read_bool(np, "brcm,serial-clk-low")) in bcm6328_leds_probe()
431 if (!of_property_read_bool(np, "brcm,serial-dat-low")) in bcm6328_leds_probe()
433 if (!of_property_read_bool(np, "brcm,serial-shift-inv")) in bcm6328_leds_probe()
450 if (of_property_read_bool(child, "brcm,hardware-controlled")) in bcm6328_leds_probe()
464 { .compatible = "brcm,bcm6328-leds", },
472 .name = "leds-bcm6328",
481 MODULE_DESCRIPTION("LED driver for BCM6328 controllers");
483 MODULE_ALIAS("platform:leds-bcm6328");