Lines Matching +full:led +full:- +full:s
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * PowerNV LED Driver
20 /* Map LED type to description. */
29 {-1, NULL},
35 * platform we want to retain LED state across reboot as these
42 /* Max supported LED type */
49 /* PowerNV LED data */
52 char *loc_code; /* LED location code */
59 /* Returns OPAL_SLOT_LED_TYPE_* for given led type string */
68 return -1; in powernv_get_led_type()
72 * This commits the state change of the requested LED through an OPAL call.
83 struct device *dev = powernv_led->cdev.dev; in powernv_led_set()
84 struct powernv_led_common *powernv_led_common = powernv_led->common; in powernv_led_set()
87 max_type = powernv_led_common->max_led_type; in powernv_led_set()
88 led_mask = OPAL_SLOT_LED_STATE_ON << powernv_led->led_type; in powernv_led_set()
95 if (token != -ERESTARTSYS) in powernv_led_set()
96 dev_err(dev, "%s: Couldn't get OPAL async token\n", in powernv_led_set()
101 rc = opal_leds_set_ind(token, powernv_led->loc_code, in powernv_led_set()
104 dev_err(dev, "%s: OPAL set LED call failed for %s [rc=%d]\n", in powernv_led_set()
105 __func__, powernv_led->loc_code, rc); in powernv_led_set()
112 "%s: Failed to wait for the async response [rc=%d]\n", in powernv_led_set()
119 dev_err(dev, "%s : OAPL async call returned failed [rc=%d]\n", in powernv_led_set()
128 * This function fetches the LED state for a given LED type for
129 * mentioned LED classdev structure.
136 struct device *dev = powernv_led->cdev.dev; in powernv_led_get()
137 struct powernv_led_common *powernv_led_common = powernv_led->common; in powernv_led_get()
139 /* Fetch all LED status */ in powernv_led_get()
142 max_type = powernv_led_common->max_led_type; in powernv_led_get()
144 rc = opal_leds_get_ind(powernv_led->loc_code, in powernv_led_get()
147 dev_err(dev, "%s: OPAL get led call failed [rc=%d]\n", in powernv_led_get()
155 /* LED status available */ in powernv_led_get()
156 if (!((led_mask >> powernv_led->led_type) & OPAL_SLOT_LED_STATE_ON)) { in powernv_led_get()
157 dev_err(dev, "%s: LED status not available for %s\n", in powernv_led_get()
158 __func__, powernv_led->cdev.name); in powernv_led_get()
162 /* LED status value */ in powernv_led_get()
163 if ((led_value >> powernv_led->led_type) & OPAL_SLOT_LED_STATE_ON) in powernv_led_get()
170 * LED classdev 'brightness_get' function. This schedules work
171 * to update LED state.
178 struct powernv_led_common *powernv_led_common = powernv_led->common; in powernv_brightness_set()
181 /* Do not modify LED in unload path */ in powernv_brightness_set()
182 if (powernv_led_common->led_disabled) in powernv_brightness_set()
185 mutex_lock(&powernv_led_common->lock); in powernv_brightness_set()
187 mutex_unlock(&powernv_led_common->lock); in powernv_brightness_set()
192 /* LED classdev 'brightness_get' function */
202 * This function registers classdev structure for any given type of LED on
203 * a given child LED device node.
211 /* Make sure LED type is supported */ in powernv_led_create()
212 powernv_led->led_type = powernv_get_led_type(led_type_desc); in powernv_led_create()
213 if (powernv_led->led_type == -1) { in powernv_led_create()
214 dev_warn(dev, "%s: No support for led type : %s\n", in powernv_led_create()
216 return -EINVAL; in powernv_led_create()
220 powernv_led->cdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s", in powernv_led_create()
221 powernv_led->loc_code, in powernv_led_create()
223 if (!powernv_led->cdev.name) in powernv_led_create()
224 return -ENOMEM; in powernv_led_create()
226 powernv_led->cdev.brightness_set_blocking = powernv_brightness_set; in powernv_led_create()
227 powernv_led->cdev.brightness_get = powernv_brightness_get; in powernv_led_create()
228 powernv_led->cdev.brightness = LED_OFF; in powernv_led_create()
229 powernv_led->cdev.max_brightness = LED_FULL; in powernv_led_create()
232 rc = devm_led_classdev_register(dev, &powernv_led->cdev); in powernv_led_create()
234 dev_err(dev, "%s: Classdev registration failed for %s\n", in powernv_led_create()
235 __func__, powernv_led->cdev.name); in powernv_led_create()
241 /* Go through LED device tree node and register LED classdev structure */
247 int rc = -1; in powernv_led_classdev()
250 struct device *dev = &pdev->dev; in powernv_led_classdev()
253 p = of_find_property(np, "led-types", NULL); in powernv_led_classdev()
259 return -ENOMEM; in powernv_led_classdev()
261 powernv_led->common = powernv_led_common; in powernv_led_classdev()
262 powernv_led->loc_code = (char *)np->name; in powernv_led_classdev()
278 struct device *dev = &pdev->dev; in powernv_led_probe()
283 dev_err(dev, "%s: LED parent device node not found\n", in powernv_led_probe()
285 return -EINVAL; in powernv_led_probe()
291 return -ENOMEM; in powernv_led_probe()
293 mutex_init(&powernv_led_common->lock); in powernv_led_probe()
294 powernv_led_common->max_led_type = cpu_to_be64(OPAL_SLOT_LED_TYPE_MAX); in powernv_led_probe()
306 /* Disable LED operation */ in powernv_led_remove()
308 powernv_led_common->led_disabled = true; in powernv_led_remove()
311 mutex_destroy(&powernv_led_common->lock); in powernv_led_remove()
313 dev_info(&pdev->dev, "PowerNV led module unregistered\n"); in powernv_led_remove()
319 .compatible = "ibm,opal-v3-led",
329 .name = "powernv-led-driver",
337 MODULE_DESCRIPTION("PowerNV LED driver");