Lines Matching +full:leds +full:- +full:active +full:- +full:low
1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/leds-pwm.c
9 * based on leds-gpio.c by Raphael Assenat <raph@8d.com>
16 #include <linux/leds.h>
36 struct led_pwm_data leds[]; member
44 unsigned int max = led_dat->cdev.max_brightness; in led_pwm_set()
45 unsigned long long duty = led_dat->pwmstate.period; in led_pwm_set()
50 if (led_dat->active_low) in led_pwm_set()
51 duty = led_dat->pwmstate.period - duty; in led_pwm_set()
53 led_dat->pwmstate.duty_cycle = duty; in led_pwm_set()
54 led_dat->pwmstate.enabled = duty > 0; in led_pwm_set()
55 return pwm_apply_state(led_dat->pwm, &led_dat->pwmstate); in led_pwm_set()
62 struct led_pwm_data *led_data = &priv->leds[priv->num_leds]; in led_pwm_add()
66 led_data->active_low = led->active_low; in led_pwm_add()
67 led_data->cdev.name = led->name; in led_pwm_add()
68 led_data->cdev.brightness = LED_OFF; in led_pwm_add()
69 led_data->cdev.max_brightness = led->max_brightness; in led_pwm_add()
70 led_data->cdev.flags = LED_CORE_SUSPENDRESUME; in led_pwm_add()
72 led_data->pwm = devm_fwnode_pwm_get(dev, fwnode, NULL); in led_pwm_add()
73 if (IS_ERR(led_data->pwm)) in led_pwm_add()
74 return dev_err_probe(dev, PTR_ERR(led_data->pwm), in led_pwm_add()
76 led->name); in led_pwm_add()
78 led_data->cdev.brightness_set_blocking = led_pwm_set; in led_pwm_add()
80 pwm_init_state(led_data->pwm, &led_data->pwmstate); in led_pwm_add()
82 ret = devm_led_classdev_register_ext(dev, &led_data->cdev, &init_data); in led_pwm_add()
85 led->name, ret); in led_pwm_add()
89 ret = led_pwm_set(&led_data->cdev, led_data->cdev.brightness); in led_pwm_add()
92 led->name, ret); in led_pwm_add()
96 priv->num_leds++; in led_pwm_add()
111 led.name = to_of_node(fwnode)->name; in led_pwm_create_fwnode()
115 return -EINVAL; in led_pwm_create_fwnode()
119 "active-low"); in led_pwm_create_fwnode()
120 fwnode_property_read_u32(fwnode, "max-brightness", in led_pwm_create_fwnode()
139 count = device_get_child_node_count(&pdev->dev); in led_pwm_probe()
142 return -EINVAL; in led_pwm_probe()
144 priv = devm_kzalloc(&pdev->dev, struct_size(priv, leds, count), in led_pwm_probe()
147 return -ENOMEM; in led_pwm_probe()
149 ret = led_pwm_create_fwnode(&pdev->dev, priv); in led_pwm_probe()
160 { .compatible = "pwm-leds", },
178 MODULE_ALIAS("platform:leds-pwm");