Lines Matching +full:led +full:- +full:6

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Based on leds-da903x:
11 * Copyright (C) 2006-2008 Marvell International Ltd.
39 struct mc13xxx_led *led; member
55 struct mc13xxx_led *led = in mc13xxx_led_set() local
57 struct mc13xxx_leds *leds = led->leds; in mc13xxx_led_set()
60 switch (led->id) { in mc13xxx_led_set()
65 shift = 9 + (led->id - MC13783_LED_MD) * 4; in mc13xxx_led_set()
76 off = led->id - MC13783_LED_R1; in mc13xxx_led_set()
79 shift = (off - bank * 3) * 5 + 6; in mc13xxx_led_set()
84 off = led->id - MC13892_LED_MD; in mc13xxx_led_set()
86 shift = 3 + (off - reg * 2) * 12; in mc13xxx_led_set()
91 off = led->id - MC13892_LED_R; in mc13xxx_led_set()
94 shift = (off - bank * 2) * 12 + 3; in mc13xxx_led_set()
99 shift = 3 + (led->id - MC34708_LED_R) * 12; in mc13xxx_led_set()
105 return mc13xxx_reg_rmw(leds->master, leds->devtype->ledctrl_base + reg, in mc13xxx_led_set()
106 mc13xxx_max_brightness(led->id) << shift, in mc13xxx_led_set()
117 struct device *dev = &pdev->dev; in mc13xxx_led_probe_dt()
118 int i = 0, ret = -ENODATA; in mc13xxx_led_probe_dt()
122 return ERR_PTR(-ENOMEM); in mc13xxx_led_probe_dt()
124 parent = of_get_child_by_name(dev_of_node(dev->parent), "leds"); in mc13xxx_led_probe_dt()
128 ret = of_property_read_u32_array(parent, "led-control", in mc13xxx_led_probe_dt()
129 pdata->led_control, in mc13xxx_led_probe_dt()
130 leds->devtype->num_regs); in mc13xxx_led_probe_dt()
134 pdata->num_leds = of_get_available_child_count(parent); in mc13xxx_led_probe_dt()
136 pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led), in mc13xxx_led_probe_dt()
138 if (!pdata->led) { in mc13xxx_led_probe_dt()
139 ret = -ENOMEM; in mc13xxx_led_probe_dt()
149 pdata->led[i].id = leds->devtype->led_min + tmp; in mc13xxx_led_probe_dt()
152 pdata->led[i].name = str; in mc13xxx_led_probe_dt()
153 if (!of_property_read_string(child, "linux,default-trigger", in mc13xxx_led_probe_dt()
155 pdata->led[i].default_trigger = str; in mc13xxx_led_probe_dt()
160 pdata->num_leds = i; in mc13xxx_led_probe_dt()
161 ret = i > 0 ? 0 : -ENODATA; in mc13xxx_led_probe_dt()
172 return ERR_PTR(-ENOSYS); in mc13xxx_led_probe_dt()
178 struct device *dev = &pdev->dev; in mc13xxx_led_probe()
180 struct mc13xxx *mcdev = dev_get_drvdata(dev->parent); in mc13xxx_led_probe()
182 (struct mc13xxx_led_devtype *)pdev->id_entry->driver_data; in mc13xxx_led_probe()
184 int i, id, ret = -ENODATA; in mc13xxx_led_probe()
189 return -ENOMEM; in mc13xxx_led_probe()
191 leds->devtype = devtype; in mc13xxx_led_probe()
192 leds->master = mcdev; in mc13xxx_led_probe()
195 if (dev_of_node(dev->parent)) { in mc13xxx_led_probe()
200 return -ENODATA; in mc13xxx_led_probe()
202 leds->num_leds = pdata->num_leds; in mc13xxx_led_probe()
204 if ((leds->num_leds < 1) || in mc13xxx_led_probe()
205 (leds->num_leds > (devtype->led_max - devtype->led_min + 1))) { in mc13xxx_led_probe()
206 dev_err(dev, "Invalid LED count %d\n", leds->num_leds); in mc13xxx_led_probe()
207 return -EINVAL; in mc13xxx_led_probe()
210 leds->led = devm_kcalloc(dev, leds->num_leds, sizeof(*leds->led), in mc13xxx_led_probe()
212 if (!leds->led) in mc13xxx_led_probe()
213 return -ENOMEM; in mc13xxx_led_probe()
215 for (i = 0; i < devtype->num_regs; i++) { in mc13xxx_led_probe()
216 ret = mc13xxx_reg_write(mcdev, leds->devtype->ledctrl_base + i, in mc13xxx_led_probe()
217 pdata->led_control[i]); in mc13xxx_led_probe()
222 for (i = 0; i < leds->num_leds; i++) { in mc13xxx_led_probe()
225 ret = -EINVAL; in mc13xxx_led_probe()
227 id = pdata->led[i].id; in mc13xxx_led_probe()
228 name = pdata->led[i].name; in mc13xxx_led_probe()
229 trig = pdata->led[i].default_trigger; in mc13xxx_led_probe()
231 if ((id > devtype->led_max) || (id < devtype->led_min)) { in mc13xxx_led_probe()
237 dev_warn(dev, "LED %i already initialized\n", id); in mc13xxx_led_probe()
242 leds->led[i].id = id; in mc13xxx_led_probe()
243 leds->led[i].leds = leds; in mc13xxx_led_probe()
244 leds->led[i].cdev.name = name; in mc13xxx_led_probe()
245 leds->led[i].cdev.default_trigger = trig; in mc13xxx_led_probe()
246 leds->led[i].cdev.flags = LED_CORE_SUSPENDRESUME; in mc13xxx_led_probe()
247 leds->led[i].cdev.brightness_set_blocking = mc13xxx_led_set; in mc13xxx_led_probe()
248 leds->led[i].cdev.max_brightness = mc13xxx_max_brightness(id); in mc13xxx_led_probe()
250 ret = led_classdev_register(dev->parent, &leds->led[i].cdev); in mc13xxx_led_probe()
252 dev_err(dev, "Failed to register LED %i\n", id); in mc13xxx_led_probe()
258 while (--i >= 0) in mc13xxx_led_probe()
259 led_classdev_unregister(&leds->led[i].cdev); in mc13xxx_led_probe()
269 for (i = 0; i < leds->num_leds; i++) in mc13xxx_led_remove()
270 led_classdev_unregister(&leds->led[i].cdev); in mc13xxx_led_remove()
278 .num_regs = 6,
297 { "mc13783-led", (kernel_ulong_t)&mc13783_led_devtype, },
298 { "mc13892-led", (kernel_ulong_t)&mc13892_led_devtype, },
299 { "mc34708-led", (kernel_ulong_t)&mc34708_led_devtype, },
306 .name = "mc13xxx-led",