Lines Matching +full:led +full:- +full:3

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Based on leds-da903x:
11 * Copyright (C) 2006-2008 Marvell International Ltd.
40 struct mc13xxx_led *led; member
56 struct mc13xxx_led *led = in mc13xxx_led_set() local
58 struct mc13xxx_leds *leds = led->leds; in mc13xxx_led_set()
61 switch (led->id) { in mc13xxx_led_set()
66 shift = 9 + (led->id - MC13783_LED_MD) * 4; in mc13xxx_led_set()
77 off = led->id - MC13783_LED_R1; in mc13xxx_led_set()
78 bank = off / 3; in mc13xxx_led_set()
79 reg = 3 + bank; in mc13xxx_led_set()
80 shift = (off - bank * 3) * 5 + 6; in mc13xxx_led_set()
85 off = led->id - MC13892_LED_MD; in mc13xxx_led_set()
87 shift = 3 + (off - reg * 2) * 12; in mc13xxx_led_set()
92 off = led->id - MC13892_LED_R; in mc13xxx_led_set()
95 shift = (off - bank * 2) * 12 + 3; in mc13xxx_led_set()
100 shift = 3 + (led->id - MC34708_LED_R) * 12; in mc13xxx_led_set()
106 return mc13xxx_reg_rmw(leds->master, leds->devtype->ledctrl_base + reg, in mc13xxx_led_set()
107 mc13xxx_max_brightness(led->id) << shift, in mc13xxx_led_set()
118 struct device *dev = &pdev->dev; in mc13xxx_led_probe_dt()
119 int i = 0, ret = -ENODATA; in mc13xxx_led_probe_dt()
123 return ERR_PTR(-ENOMEM); in mc13xxx_led_probe_dt()
126 of_get_child_by_name(dev_of_node(dev->parent), "leds"); in mc13xxx_led_probe_dt()
128 return ERR_PTR(-ENODATA); in mc13xxx_led_probe_dt()
130 ret = of_property_read_u32_array(parent, "led-control", in mc13xxx_led_probe_dt()
131 pdata->led_control, in mc13xxx_led_probe_dt()
132 leds->devtype->num_regs); in mc13xxx_led_probe_dt()
136 pdata->num_leds = of_get_available_child_count(parent); in mc13xxx_led_probe_dt()
138 pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led), in mc13xxx_led_probe_dt()
140 if (!pdata->led) in mc13xxx_led_probe_dt()
141 return ERR_PTR(-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()
162 return ERR_PTR(-ENODATA); in mc13xxx_led_probe_dt()
170 return ERR_PTR(-ENOSYS); in mc13xxx_led_probe_dt()
176 struct device *dev = &pdev->dev; in mc13xxx_led_probe()
178 struct mc13xxx *mcdev = dev_get_drvdata(dev->parent); in mc13xxx_led_probe()
180 (struct mc13xxx_led_devtype *)pdev->id_entry->driver_data; in mc13xxx_led_probe()
182 int i, id, ret = -ENODATA; in mc13xxx_led_probe()
187 return -ENOMEM; in mc13xxx_led_probe()
189 leds->devtype = devtype; in mc13xxx_led_probe()
190 leds->master = mcdev; in mc13xxx_led_probe()
193 if (dev_of_node(dev->parent)) { in mc13xxx_led_probe()
198 return -ENODATA; in mc13xxx_led_probe()
200 leds->num_leds = pdata->num_leds; in mc13xxx_led_probe()
202 if ((leds->num_leds < 1) || in mc13xxx_led_probe()
203 (leds->num_leds > (devtype->led_max - devtype->led_min + 1))) { in mc13xxx_led_probe()
204 dev_err(dev, "Invalid LED count %d\n", leds->num_leds); in mc13xxx_led_probe()
205 return -EINVAL; in mc13xxx_led_probe()
208 leds->led = devm_kcalloc(dev, leds->num_leds, sizeof(*leds->led), in mc13xxx_led_probe()
210 if (!leds->led) in mc13xxx_led_probe()
211 return -ENOMEM; in mc13xxx_led_probe()
213 for (i = 0; i < devtype->num_regs; i++) { in mc13xxx_led_probe()
214 ret = mc13xxx_reg_write(mcdev, leds->devtype->ledctrl_base + i, in mc13xxx_led_probe()
215 pdata->led_control[i]); in mc13xxx_led_probe()
220 for (i = 0; i < leds->num_leds; i++) { in mc13xxx_led_probe()
223 ret = -EINVAL; in mc13xxx_led_probe()
225 id = pdata->led[i].id; in mc13xxx_led_probe()
226 name = pdata->led[i].name; in mc13xxx_led_probe()
227 trig = pdata->led[i].default_trigger; in mc13xxx_led_probe()
229 if ((id > devtype->led_max) || (id < devtype->led_min)) { in mc13xxx_led_probe()
235 dev_warn(dev, "LED %i already initialized\n", id); in mc13xxx_led_probe()
240 leds->led[i].id = id; in mc13xxx_led_probe()
241 leds->led[i].leds = leds; in mc13xxx_led_probe()
242 leds->led[i].cdev.name = name; in mc13xxx_led_probe()
243 leds->led[i].cdev.default_trigger = trig; in mc13xxx_led_probe()
244 leds->led[i].cdev.flags = LED_CORE_SUSPENDRESUME; in mc13xxx_led_probe()
245 leds->led[i].cdev.brightness_set_blocking = mc13xxx_led_set; in mc13xxx_led_probe()
246 leds->led[i].cdev.max_brightness = mc13xxx_max_brightness(id); in mc13xxx_led_probe()
248 ret = led_classdev_register(dev->parent, &leds->led[i].cdev); in mc13xxx_led_probe()
250 dev_err(dev, "Failed to register LED %i\n", id); in mc13xxx_led_probe()
256 while (--i >= 0) in mc13xxx_led_probe()
257 led_classdev_unregister(&leds->led[i].cdev); in mc13xxx_led_probe()
267 for (i = 0; i < leds->num_leds; i++) in mc13xxx_led_remove()
268 led_classdev_unregister(&leds->led[i].cdev); in mc13xxx_led_remove()
293 { "mc13783-led", (kernel_ulong_t)&mc13783_led_devtype, },
294 { "mc13892-led", (kernel_ulong_t)&mc13892_led_devtype, },
295 { "mc34708-led", (kernel_ulong_t)&mc34708_led_devtype, },
302 .name = "mc13xxx-led",