Lines Matching +full:led +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0
9 #include <linux/led-class-multicolor.h>
46 u8 buf[2] = { cmd, val }; in omnia_cmd_write_u8()
53 struct i2c_msg msgs[2]; in omnia_cmd_read_u8()
57 msgs[0].addr = client->addr; in omnia_cmd_read_u8()
61 msgs[1].addr = client->addr; in omnia_cmd_read_u8()
66 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in omnia_cmd_read_u8()
72 return -EIO; in omnia_cmd_read_u8()
79 struct omnia_leds *leds = dev_get_drvdata(cdev->dev->parent); in omnia_led_brightness_set_blocking()
80 struct omnia_led *led = to_omnia_led(mc_cdev); in omnia_led_brightness_set_blocking() local
84 mutex_lock(&leds->lock); in omnia_led_brightness_set_blocking()
86 led_mc_calc_color_components(&led->mc_cdev, brightness); in omnia_led_brightness_set_blocking()
89 buf[1] = led->reg; in omnia_led_brightness_set_blocking()
90 buf[2] = mc_cdev->subled_info[0].brightness; in omnia_led_brightness_set_blocking()
91 buf[3] = mc_cdev->subled_info[1].brightness; in omnia_led_brightness_set_blocking()
92 buf[4] = mc_cdev->subled_info[2].brightness; in omnia_led_brightness_set_blocking()
94 state = CMD_LED_STATE_LED(led->reg); in omnia_led_brightness_set_blocking()
95 if (buf[2] || buf[3] || buf[4]) in omnia_led_brightness_set_blocking()
98 ret = omnia_cmd_write_u8(leds->client, CMD_LED_STATE, state); in omnia_led_brightness_set_blocking()
100 ret = i2c_master_send(leds->client, buf, 5); in omnia_led_brightness_set_blocking()
102 mutex_unlock(&leds->lock); in omnia_led_brightness_set_blocking()
107 static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, in omnia_led_register() argument
111 struct device *dev = &client->dev; in omnia_led_register()
115 ret = of_property_read_u32(np, "reg", &led->reg); in omnia_led_register()
116 if (ret || led->reg >= OMNIA_BOARD_LEDS) { in omnia_led_register()
119 np, OMNIA_BOARD_LEDS - 1); in omnia_led_register()
131 led->subled_info[0].color_index = LED_COLOR_ID_RED; in omnia_led_register()
132 led->subled_info[0].channel = 0; in omnia_led_register()
133 led->subled_info[1].color_index = LED_COLOR_ID_GREEN; in omnia_led_register()
134 led->subled_info[1].channel = 1; in omnia_led_register()
135 led->subled_info[2].color_index = LED_COLOR_ID_BLUE; in omnia_led_register()
136 led->subled_info[2].channel = 2; in omnia_led_register()
138 led->mc_cdev.subled_info = led->subled_info; in omnia_led_register()
139 led->mc_cdev.num_colors = OMNIA_LED_NUM_CHANNELS; in omnia_led_register()
141 init_data.fwnode = &np->fwnode; in omnia_led_register()
143 cdev = &led->mc_cdev.led_cdev; in omnia_led_register()
144 cdev->max_brightness = 255; in omnia_led_register()
145 cdev->brightness_set_blocking = omnia_led_brightness_set_blocking; in omnia_led_register()
147 /* put the LED into software mode */ in omnia_led_register()
149 CMD_LED_MODE_LED(led->reg) | in omnia_led_register()
152 dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np, in omnia_led_register()
157 /* disable the LED */ in omnia_led_register()
159 CMD_LED_STATE_LED(led->reg)); in omnia_led_register()
161 dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret); in omnia_led_register()
165 ret = devm_led_classdev_multicolor_register_ext(dev, &led->mc_cdev, in omnia_led_register()
168 dev_err(dev, "Cannot register LED %pOF: %i\n", np, ret); in omnia_led_register()
183 * file lives in the device directory of the LED controller, not an individual
184 * LED, so it should not confuse users.
208 return -EINVAL; in brightness_store()
211 return -EINVAL; in brightness_store()
227 struct device *dev = &client->dev; in omnia_leds_probe()
230 struct omnia_led *led; in omnia_leds_probe() local
236 return -ENODEV; in omnia_leds_probe()
239 return -EINVAL; in omnia_leds_probe()
244 return -ENOMEM; in omnia_leds_probe()
246 leds->client = client; in omnia_leds_probe()
249 mutex_init(&leds->lock); in omnia_leds_probe()
251 led = &leds->leds[0]; in omnia_leds_probe()
253 ret = omnia_led_register(client, led, child); in omnia_leds_probe()
259 led += ret; in omnia_leds_probe()
276 buf[2] = 255; in omnia_leds_remove()
284 { .compatible = "cznic,turris-omnia-leds", },
299 .name = "leds-turris-omnia",