Lines Matching +full:led +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 #include <linux/mfd/motorola-cpcap.h>
52 /* camera privacy led */
62 struct led_classdev led; member
81 static int cpcap_led_set_power(struct cpcap_led *led, bool status) in cpcap_led_set_power() argument
85 if (status == led->powered) in cpcap_led_set_power()
89 err = regulator_enable(led->vdd); in cpcap_led_set_power()
91 err = regulator_disable(led->vdd); in cpcap_led_set_power()
94 dev_err(led->dev, "regulator failure: %d", err); in cpcap_led_set_power()
98 led->powered = status; in cpcap_led_set_power()
105 struct cpcap_led *led = container_of(ledc, struct cpcap_led, led); in cpcap_led_set() local
109 mutex_lock(&led->update_lock); in cpcap_led_set()
112 err = cpcap_led_set_power(led, true); in cpcap_led_set()
119 err = regmap_update_bits(led->regmap, in cpcap_led_set()
120 led->info->reg, led->info->mask, CPCAP_LED_NO_CURRENT); in cpcap_led_set()
122 dev_err(led->dev, "regmap failed: %d", err); in cpcap_led_set()
131 err = regmap_update_bits(led->regmap, led->info->reg, led->info->mask, in cpcap_led_set()
134 dev_err(led->dev, "regmap failed: %d", err); in cpcap_led_set()
139 err = cpcap_led_set_power(led, false); in cpcap_led_set()
145 mutex_unlock(&led->update_lock); in cpcap_led_set()
150 { .compatible = "motorola,cpcap-led-red", .data = &cpcap_led_red },
151 { .compatible = "motorola,cpcap-led-green", .data = &cpcap_led_green },
152 { .compatible = "motorola,cpcap-led-blue", .data = &cpcap_led_blue },
153 { .compatible = "motorola,cpcap-led-adl", .data = &cpcap_led_adl },
154 { .compatible = "motorola,cpcap-led-cp", .data = &cpcap_led_cp },
161 struct cpcap_led *led; in cpcap_led_probe() local
164 led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); in cpcap_led_probe()
165 if (!led) in cpcap_led_probe()
166 return -ENOMEM; in cpcap_led_probe()
167 platform_set_drvdata(pdev, led); in cpcap_led_probe()
168 led->info = device_get_match_data(&pdev->dev); in cpcap_led_probe()
169 led->dev = &pdev->dev; in cpcap_led_probe()
171 if (led->info->reg == 0x0000) { in cpcap_led_probe()
172 dev_err(led->dev, "Unsupported LED"); in cpcap_led_probe()
173 return -ENODEV; in cpcap_led_probe()
176 led->regmap = dev_get_regmap(pdev->dev.parent, NULL); in cpcap_led_probe()
177 if (!led->regmap) in cpcap_led_probe()
178 return -ENODEV; in cpcap_led_probe()
180 led->vdd = devm_regulator_get(&pdev->dev, "vdd"); in cpcap_led_probe()
181 if (IS_ERR(led->vdd)) { in cpcap_led_probe()
182 err = PTR_ERR(led->vdd); in cpcap_led_probe()
183 dev_err(led->dev, "Couldn't get regulator: %d", err); in cpcap_led_probe()
187 err = device_property_read_string(&pdev->dev, "label", &led->led.name); in cpcap_led_probe()
189 dev_err(led->dev, "Couldn't read LED label: %d", err); in cpcap_led_probe()
193 if (led->info->init_mask) { in cpcap_led_probe()
194 err = regmap_update_bits(led->regmap, led->info->reg, in cpcap_led_probe()
195 led->info->init_mask, led->info->init_val); in cpcap_led_probe()
197 dev_err(led->dev, "regmap failed: %d", err); in cpcap_led_probe()
202 mutex_init(&led->update_lock); in cpcap_led_probe()
204 led->led.max_brightness = led->info->limit; in cpcap_led_probe()
205 led->led.brightness_set_blocking = cpcap_led_set; in cpcap_led_probe()
206 err = devm_led_classdev_register(&pdev->dev, &led->led); in cpcap_led_probe()
208 dev_err(led->dev, "Couldn't register LED: %d", err); in cpcap_led_probe()
218 .name = "cpcap-led",
224 MODULE_DESCRIPTION("CPCAP LED driver");