Lines Matching full:led
60 * @cdev: LED class device for this LED
63 * @pin: LED pin number
66 * @active_low: LED is active low
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
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()
250 spin_unlock_irqrestore(led->lock, flags); in bcm6328_blink_set()
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()
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()
347 led->active_low = true; 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()
447 dev_err(dev, "invalid LED (%u >= %d)\n", reg, in bcm6328_leds_probe()
485 MODULE_DESCRIPTION("LED driver for BCM6328 controllers");