Lines Matching +full:led +full:- +full:2
2 * Driver for BCM6358 memory-mapped LEDs, based on leds-syscon.c
8 * Free Software Foundation; either version 2 of the License, or (at your
25 #define BCM6358_SLED_CLKDIV_4 2
28 #define BCM6358_SLED_POLARITY BIT(2)
35 * struct bcm6358_led - state container for bcm6358 based LEDs
36 * @cdev: LED class device for this LED
39 * @pin: LED pin number
40 * @active_low: LED is active low
82 struct bcm6358_led *led = in bcm6358_led_set() local
86 spin_lock_irqsave(led->lock, flags); in bcm6358_led_set()
87 bcm6358_led_busy(led->mem); in bcm6358_led_set()
88 val = bcm6358_led_read(led->mem + BCM6358_REG_MODE); in bcm6358_led_set()
89 if ((led->active_low && value == LED_OFF) || in bcm6358_led_set()
90 (!led->active_low && value != LED_OFF)) in bcm6358_led_set()
91 val |= BIT(led->pin); in bcm6358_led_set()
93 val &= ~(BIT(led->pin)); in bcm6358_led_set()
94 bcm6358_led_write(led->mem + BCM6358_REG_MODE, val); in bcm6358_led_set()
95 spin_unlock_irqrestore(led->lock, flags); in bcm6358_led_set()
101 struct bcm6358_led *led; in bcm6358_led() local
105 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); in bcm6358_led()
106 if (!led) in bcm6358_led()
107 return -ENOMEM; in bcm6358_led()
109 led->pin = reg; in bcm6358_led()
110 led->mem = mem; in bcm6358_led()
111 led->lock = lock; in bcm6358_led()
113 if (of_property_read_bool(nc, "active-low")) in bcm6358_led()
114 led->active_low = true; in bcm6358_led()
116 led->cdev.name = of_get_property(nc, "label", NULL) ? : nc->name; in bcm6358_led()
117 led->cdev.default_trigger = of_get_property(nc, in bcm6358_led()
118 "linux,default-trigger", in bcm6358_led()
121 if (!of_property_read_string(nc, "default-state", &state)) { in bcm6358_led()
123 led->cdev.brightness = LED_FULL; in bcm6358_led()
126 val = bcm6358_led_read(led->mem + BCM6358_REG_MODE); in bcm6358_led()
127 val &= BIT(led->pin); in bcm6358_led()
128 if ((led->active_low && !val) || in bcm6358_led()
129 (!led->active_low && val)) in bcm6358_led()
130 led->cdev.brightness = LED_FULL; in bcm6358_led()
132 led->cdev.brightness = LED_OFF; in bcm6358_led()
134 led->cdev.brightness = LED_OFF; in bcm6358_led()
137 led->cdev.brightness = LED_OFF; in bcm6358_led()
140 bcm6358_led_set(&led->cdev, led->cdev.brightness); in bcm6358_led()
142 led->cdev.brightness_set = bcm6358_led_set; in bcm6358_led()
144 rc = devm_led_classdev_register(dev, &led->cdev); in bcm6358_led()
148 dev_dbg(dev, "registered LED %s\n", led->cdev.name); in bcm6358_led()
155 struct device *dev = &pdev->dev; in bcm6358_leds_probe()
156 struct device_node *np = pdev->dev.of_node; in bcm6358_leds_probe()
166 return -EINVAL; in bcm6358_leds_probe()
174 return -ENOMEM; in bcm6358_leds_probe()
180 if (of_property_read_bool(np, "brcm,clk-dat-low")) in bcm6358_leds_probe()
182 of_property_read_u32(np, "brcm,clk-div", &clk_div); in bcm6358_leds_probe()
190 case 2: in bcm6358_leds_probe()
207 dev_err(dev, "invalid LED (%u >= %d)\n", reg, in bcm6358_leds_probe()
223 { .compatible = "brcm,bcm6358-leds", },
231 .name = "leds-bcm6358",
239 MODULE_DESCRIPTION("LED driver for BCM6358 controllers");
241 MODULE_ALIAS("platform:leds-bcm6358");