Lines Matching +full:gpio +full:- +full:op +full:- +full:cfg

1 // SPDX-License-Identifier: GPL-2.0-only
9 * Derived from leds-lp5521.c, leds-lp5523.c
21 #include <linux/platform_data/leds-lp55xx.h>
23 #include <linux/gpio/consumer.h>
24 #include <dt-bindings/leds/leds-lp55xx.h>
26 #include "leds-lp55xx-common.h"
28 /* OP MODE require at least 153 us to clear regs */
48 #define LP55xx_MODE_ENGn_SHIFT(n, shift) ((shift) + (2 * (3 - (n))))
59 #define LP55xx_EXEC_ENGn_SHIFT(n, shift) ((shift) + (2 * (3 - (n))))
65 #define LP55xx_PAGE_OFFSET(n, pages) (((n) - 1) * (pages))
92 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_wait_opmode_done() local
101 if (cfg->engine_busy.val) { in lp55xx_wait_opmode_done()
102 read_poll_timeout(lp55xx_read, ret, !(val & cfg->engine_busy.mask), in lp55xx_wait_opmode_done()
104 chip, cfg->engine_busy.addr, &val); in lp55xx_wait_opmode_done()
112 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_stop_all_engine() local
114 lp55xx_write(chip, cfg->reg_op_mode.addr, LP55xx_MODE_DISABLE_ALL_ENG); in lp55xx_stop_all_engine()
121 enum lp55xx_engine_index idx = chip->engine_idx; in lp55xx_load_engine()
122 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_load_engine() local
125 mask = LP55xx_MODE_ENGn_MASK(idx, cfg->reg_op_mode.shift); in lp55xx_load_engine()
126 val = LP55xx_MODE_LOAD_ENG << LP55xx_MODE_ENGn_SHIFT(idx, cfg->reg_op_mode.shift); in lp55xx_load_engine()
128 lp55xx_update_bits(chip, cfg->reg_op_mode.addr, mask, val); in lp55xx_load_engine()
132 if (cfg->pages_per_engine) in lp55xx_load_engine()
134 LP55xx_PAGE_OFFSET(idx, cfg->pages_per_engine)); in lp55xx_load_engine()
140 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_run_engine_common() local
144 /* To run the engine, both OP MODE and EXEC needs to be put in RUN mode */ in lp55xx_run_engine_common()
145 ret = lp55xx_read(chip, cfg->reg_op_mode.addr, &mode); in lp55xx_run_engine_common()
149 ret = lp55xx_read(chip, cfg->reg_exec.addr, &exec); in lp55xx_run_engine_common()
155 if (LP55xx_MODE_ENGn_GET(i, mode, cfg->reg_op_mode.shift) != LP55xx_MODE_LOAD_ENG) in lp55xx_run_engine_common()
158 mode &= ~LP55xx_MODE_ENGn_MASK(i, cfg->reg_op_mode.shift); in lp55xx_run_engine_common()
159 mode |= LP55xx_MODE_RUN_ENG << LP55xx_MODE_ENGn_SHIFT(i, cfg->reg_op_mode.shift); in lp55xx_run_engine_common()
160 exec &= ~LP55xx_EXEC_ENGn_MASK(i, cfg->reg_exec.shift); in lp55xx_run_engine_common()
161 exec |= LP55xx_EXEC_RUN_ENG << LP55xx_EXEC_ENGn_SHIFT(i, cfg->reg_exec.shift); in lp55xx_run_engine_common()
164 lp55xx_write(chip, cfg->reg_op_mode.addr, mode); in lp55xx_run_engine_common()
166 lp55xx_write(chip, cfg->reg_exec.addr, exec); in lp55xx_run_engine_common()
175 enum lp55xx_engine_index idx = chip->engine_idx; in lp55xx_update_program_memory()
176 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_update_program_memory() local
178 u8 start_addr = cfg->prog_mem_base.addr; in lp55xx_update_program_memory()
183 if (cfg->pages_per_engine) in lp55xx_update_program_memory()
184 program_length *= cfg->pages_per_engine; in lp55xx_update_program_memory()
186 while ((offset < size - 1) && (i < program_length)) { in lp55xx_update_program_memory()
214 if (!cfg->pages_per_engine) in lp55xx_update_program_memory()
219 if (cfg->pages_per_engine) in lp55xx_update_program_memory()
221 LP55xx_PAGE_OFFSET(idx, cfg->pages_per_engine) + page); in lp55xx_update_program_memory()
227 return -EINVAL; in lp55xx_update_program_memory()
234 dev_err(&chip->cl->dev, "wrong pattern format\n"); in lp55xx_update_program_memory()
235 return -EINVAL; in lp55xx_update_program_memory()
241 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_firmware_loaded_cb() local
242 const struct firmware *fw = chip->fw; in lp55xx_firmware_loaded_cb()
246 if (cfg->pages_per_engine) in lp55xx_firmware_loaded_cb()
247 program_length *= cfg->pages_per_engine; in lp55xx_firmware_loaded_cb()
253 if (fw->size > program_length * 2) { in lp55xx_firmware_loaded_cb()
254 dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n", in lp55xx_firmware_loaded_cb()
255 fw->size); in lp55xx_firmware_loaded_cb()
266 lp55xx_update_program_memory(chip, fw->data, fw->size); in lp55xx_firmware_loaded_cb()
272 struct lp55xx_chip *chip = led->chip; in lp55xx_led_brightness()
273 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_led_brightness() local
276 guard(mutex)(&chip->lock); in lp55xx_led_brightness()
278 ret = lp55xx_write(chip, cfg->reg_led_pwm_base.addr + led->chan_nr, in lp55xx_led_brightness()
279 led->brightness); in lp55xx_led_brightness()
286 struct lp55xx_chip *chip = led->chip; in lp55xx_multicolor_brightness()
287 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_multicolor_brightness() local
291 guard(mutex)(&chip->lock); in lp55xx_multicolor_brightness()
293 for (i = 0; i < led->mc_cdev.num_colors; i++) { in lp55xx_multicolor_brightness()
295 cfg->reg_led_pwm_base.addr + in lp55xx_multicolor_brightness()
296 led->mc_cdev.subled_info[i].channel, in lp55xx_multicolor_brightness()
297 led->mc_cdev.subled_info[i].brightness); in lp55xx_multicolor_brightness()
308 struct lp55xx_chip *chip = led->chip; in lp55xx_set_led_current()
309 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_set_led_current() local
311 led->led_current = led_current; in lp55xx_set_led_current()
312 lp55xx_write(led->chip, cfg->reg_led_current_base.addr + led->chan_nr, in lp55xx_set_led_current()
319 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_turn_off_channels() local
322 for (i = 0; i < cfg->max_channel; i++) in lp55xx_turn_off_channels()
323 lp55xx_write(chip, cfg->reg_led_pwm_base.addr + i, 0); in lp55xx_turn_off_channels()
329 enum lp55xx_engine_index idx = chip->engine_idx; in lp55xx_stop_engine()
330 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_stop_engine() local
333 mask = LP55xx_MODE_ENGn_MASK(idx, cfg->reg_op_mode.shift); in lp55xx_stop_engine()
334 lp55xx_update_bits(chip, cfg->reg_op_mode.addr, mask, 0); in lp55xx_stop_engine()
342 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_reset_device() local
343 u8 addr = cfg->reset.addr; in lp55xx_reset_device()
344 u8 val = cfg->reset.val; in lp55xx_reset_device()
352 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_detect_device() local
353 u8 addr = cfg->enable.addr; in lp55xx_detect_device()
354 u8 val = cfg->enable.val; in lp55xx_detect_device()
367 if (val != cfg->enable.val) in lp55xx_detect_device()
368 return -ENODEV; in lp55xx_detect_device()
375 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_post_init_device() local
377 if (!cfg->post_init_device) in lp55xx_post_init_device()
380 return cfg->post_init_device(chip); in lp55xx_post_init_device()
389 return sysfs_emit(buf, "%d\n", led->led_current); in led_current_show()
397 struct lp55xx_chip *chip = led->chip; in led_current_store()
401 return -EINVAL; in led_current_store()
403 if (curr > led->max_current) in led_current_store()
404 return -EINVAL; in led_current_store()
406 if (!chip->cfg->set_led_current) in led_current_store()
409 guard(mutex)(&chip->lock); in led_current_store()
411 chip->cfg->set_led_current(led, (u8)curr); in led_current_store()
422 return sysfs_emit(buf, "%d\n", led->max_current); in max_current_show()
440 const struct lp55xx_device_config *cfg = led->chip->cfg; in lp55xx_set_mc_brightness() local
442 led_mc_calc_color_components(&led->mc_cdev, brightness); in lp55xx_set_mc_brightness()
443 return cfg->multicolor_brightness_fn(led); in lp55xx_set_mc_brightness()
451 const struct lp55xx_device_config *cfg = led->chip->cfg; in lp55xx_set_brightness() local
453 led->brightness = (u8)brightness; in lp55xx_set_brightness()
454 return cfg->brightness_fn(led); in lp55xx_set_brightness()
460 struct lp55xx_platform_data *pdata = chip->pdata; in lp55xx_init_led()
461 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_init_led() local
462 struct device *dev = &chip->cl->dev; in lp55xx_init_led()
463 int max_channel = cfg->max_channel; in lp55xx_init_led()
472 return -EINVAL; in lp55xx_init_led()
475 if (pdata->led_config[chan].led_current == 0) in lp55xx_init_led()
478 if (pdata->led_config[chan].name) { in lp55xx_init_led()
479 led->cdev.name = pdata->led_config[chan].name; in lp55xx_init_led()
482 pdata->label ? : chip->cl->name, chan); in lp55xx_init_led()
483 led->cdev.name = name; in lp55xx_init_led()
486 if (pdata->led_config[chan].num_colors > 1) { in lp55xx_init_led()
488 pdata->led_config[chan].num_colors, in lp55xx_init_led()
491 return -ENOMEM; in lp55xx_init_led()
493 led_cdev = &led->mc_cdev.led_cdev; in lp55xx_init_led()
494 led_cdev->name = led->cdev.name; in lp55xx_init_led()
495 led_cdev->brightness_set_blocking = lp55xx_set_mc_brightness; in lp55xx_init_led()
496 led->mc_cdev.num_colors = pdata->led_config[chan].num_colors; in lp55xx_init_led()
497 for (i = 0; i < led->mc_cdev.num_colors; i++) { in lp55xx_init_led()
499 pdata->led_config[chan].color_id[i]; in lp55xx_init_led()
501 pdata->led_config[chan].output_num[i]; in lp55xx_init_led()
504 led->mc_cdev.subled_info = mc_led_info; in lp55xx_init_led()
506 led->cdev.brightness_set_blocking = lp55xx_set_brightness; in lp55xx_init_led()
509 led->cdev.groups = lp55xx_led_groups; in lp55xx_init_led()
510 led->cdev.default_trigger = pdata->led_config[chan].default_trigger; in lp55xx_init_led()
511 led->led_current = pdata->led_config[chan].led_current; in lp55xx_init_led()
512 led->max_current = pdata->led_config[chan].max_current; in lp55xx_init_led()
513 led->chan_nr = pdata->led_config[chan].chan_nr; in lp55xx_init_led()
515 if (led->chan_nr >= max_channel) { in lp55xx_init_led()
517 max_channel - 1); in lp55xx_init_led()
518 return -EINVAL; in lp55xx_init_led()
521 if (pdata->led_config[chan].num_colors > 1) in lp55xx_init_led()
522 ret = devm_led_classdev_multicolor_register(dev, &led->mc_cdev); in lp55xx_init_led()
524 ret = devm_led_classdev_register(dev, &led->cdev); in lp55xx_init_led()
537 struct device *dev = &chip->cl->dev; in lp55xx_firmware_loaded()
538 enum lp55xx_engine_index idx = chip->engine_idx; in lp55xx_firmware_loaded()
546 scoped_guard(mutex, &chip->lock) { in lp55xx_firmware_loaded()
547 chip->engines[idx - 1].mode = LP55XX_ENGINE_LOAD; in lp55xx_firmware_loaded()
548 chip->fw = fw; in lp55xx_firmware_loaded()
549 if (chip->cfg->firmware_cb) in lp55xx_firmware_loaded()
550 chip->cfg->firmware_cb(chip); in lp55xx_firmware_loaded()
554 release_firmware(chip->fw); in lp55xx_firmware_loaded()
555 chip->fw = NULL; in lp55xx_firmware_loaded()
560 const char *name = chip->cl->name; in lp55xx_request_firmware()
561 struct device *dev = &chip->cl->dev; in lp55xx_request_firmware()
572 struct lp55xx_chip *chip = led->chip; in select_engine_show()
574 return sprintf(buf, "%d\n", chip->engine_idx); in select_engine_show()
582 struct lp55xx_chip *chip = led->chip; in select_engine_store()
587 return -EINVAL; in select_engine_store()
595 scoped_guard(mutex, &chip->lock) { in select_engine_store()
596 chip->engine_idx = val; in select_engine_store()
602 return -EINVAL; in select_engine_store()
615 if (chip->cfg->run_engine) in lp55xx_run_engine()
616 chip->cfg->run_engine(chip, start); in lp55xx_run_engine()
624 struct lp55xx_chip *chip = led->chip; in run_engine_store()
628 return -EINVAL; in run_engine_store()
637 guard(mutex)(&chip->lock); in run_engine_store()
652 struct lp55xx_chip *chip = led->chip; in lp55xx_show_engine_mode()
653 enum lp55xx_engine_mode mode = chip->engines[nr - 1].mode; in lp55xx_show_engine_mode()
672 struct lp55xx_chip *chip = led->chip; in lp55xx_store_engine_mode()
673 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_store_engine_mode() local
674 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in lp55xx_store_engine_mode()
676 guard(mutex)(&chip->lock); in lp55xx_store_engine_mode()
678 chip->engine_idx = nr; in lp55xx_store_engine_mode()
681 cfg->run_engine(chip, true); in lp55xx_store_engine_mode()
682 engine->mode = LP55XX_ENGINE_RUN; in lp55xx_store_engine_mode()
686 engine->mode = LP55XX_ENGINE_LOAD; in lp55xx_store_engine_mode()
689 engine->mode = LP55XX_ENGINE_DISABLED; in lp55xx_store_engine_mode()
701 struct lp55xx_chip *chip = led->chip; in lp55xx_store_engine_load()
704 guard(mutex)(&chip->lock); in lp55xx_store_engine_load()
706 chip->engine_idx = nr; in lp55xx_store_engine_load()
717 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_mux_parse() local
721 len = min_t(int, len, cfg->max_channel); in lp55xx_mux_parse()
734 return -1; in lp55xx_mux_parse()
747 struct lp55xx_chip *chip = led->chip; in lp55xx_show_engine_leds()
748 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_show_engine_leds() local
752 for (i = 0; i < cfg->max_channel; i++) { in lp55xx_show_engine_leds()
753 led_active = LED_ACTIVE(chip->engines[nr - 1].led_mux, i); in lp55xx_show_engine_leds()
765 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in lp55xx_load_mux()
766 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_load_mux() local
773 mux_page = cfg->pages_per_engine * LP55XX_ENGINE_MAX + (nr - 1); in lp55xx_load_mux()
778 ret = lp55xx_write(chip, cfg->prog_mem_base.addr, (u8)(mux >> 8)); in lp55xx_load_mux()
782 ret = lp55xx_write(chip, cfg->prog_mem_base.addr + 1, (u8)(mux)); in lp55xx_load_mux()
786 engine->led_mux = mux; in lp55xx_load_mux()
795 struct lp55xx_chip *chip = led->chip; in lp55xx_store_engine_leds()
796 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in lp55xx_store_engine_leds()
800 return -EINVAL; in lp55xx_store_engine_leds()
802 guard(mutex)(&chip->lock); in lp55xx_store_engine_leds()
804 chip->engine_idx = nr; in lp55xx_store_engine_leds()
806 if (engine->mode != LP55XX_ENGINE_LOAD) in lp55xx_store_engine_leds()
807 return -EINVAL; in lp55xx_store_engine_leds()
810 return -EINVAL; in lp55xx_store_engine_leds()
821 struct lp55xx_chip *chip = led->chip; in lp55xx_show_master_fader()
822 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_show_master_fader() local
826 guard(mutex)(&chip->lock); in lp55xx_show_master_fader()
828 ret = lp55xx_read(chip, cfg->reg_master_fader_base.addr + nr - 1, &val); in lp55xx_show_master_fader()
839 struct lp55xx_chip *chip = led->chip; in lp55xx_store_master_fader()
840 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_store_master_fader() local
845 return -EINVAL; in lp55xx_store_master_fader()
848 return -EINVAL; in lp55xx_store_master_fader()
850 guard(mutex)(&chip->lock); in lp55xx_store_master_fader()
852 ret = lp55xx_write(chip, cfg->reg_master_fader_base.addr + nr - 1, in lp55xx_store_master_fader()
864 struct lp55xx_chip *chip = led->chip; in lp55xx_show_master_fader_leds()
865 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_show_master_fader_leds() local
869 guard(mutex)(&chip->lock); in lp55xx_show_master_fader_leds()
871 for (i = 0; i < cfg->max_channel; i++) { in lp55xx_show_master_fader_leds()
872 ret = lp55xx_read(chip, cfg->reg_led_ctrl_base.addr + i, &val); in lp55xx_show_master_fader_leds()
878 return -EINVAL; in lp55xx_show_master_fader_leds()
893 struct lp55xx_chip *chip = led->chip; in lp55xx_store_master_fader_leds()
894 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_store_master_fader_leds() local
898 n = min_t(int, len, cfg->max_channel); in lp55xx_store_master_fader_leds()
900 guard(mutex)(&chip->lock); in lp55xx_store_master_fader_leds()
904 val = (buf[i] - '0') << __bf_shf(LP55xx_FADER_MAPPING_MASK); in lp55xx_store_master_fader_leds()
906 cfg->reg_led_ctrl_base.addr + i, in lp55xx_store_master_fader_leds()
912 return -EINVAL; in lp55xx_store_master_fader_leds()
932 return i2c_smbus_write_byte_data(chip->cl, reg, val); in lp55xx_write()
940 ret = i2c_smbus_read_byte_data(chip->cl, reg); in lp55xx_read()
969 clk = devm_clk_get_enabled(&chip->cl->dev, "32k_clk"); in lp55xx_is_extclk_used()
976 dev_info(&chip->cl->dev, "%dHz external clock used\n", LP55XX_CLK_32K); in lp55xx_is_extclk_used()
981 dev_info(&chip->cl->dev, "internal clock used\n"); in lp55xx_is_extclk_used()
988 struct lp55xx_platform_data *pdata = chip->pdata; in lp55xx_deinit_device()
990 if (pdata->enable_gpiod) in lp55xx_deinit_device()
991 gpiod_set_value(pdata->enable_gpiod, 0); in lp55xx_deinit_device()
997 const struct lp55xx_device_config *cfg; in lp55xx_init_device() local
998 struct device *dev = &chip->cl->dev; in lp55xx_init_device()
1003 pdata = chip->pdata; in lp55xx_init_device()
1004 cfg = chip->cfg; in lp55xx_init_device()
1006 if (!pdata || !cfg) in lp55xx_init_device()
1007 return -EINVAL; in lp55xx_init_device()
1009 if (pdata->enable_gpiod) { in lp55xx_init_device()
1010 gpiod_direction_output(pdata->enable_gpiod, 0); in lp55xx_init_device()
1012 gpiod_set_consumer_name(pdata->enable_gpiod, "LP55xx enable"); in lp55xx_init_device()
1013 gpiod_set_value_cansleep(pdata->enable_gpiod, 0); in lp55xx_init_device()
1015 gpiod_set_value_cansleep(pdata->enable_gpiod, 1); in lp55xx_init_device()
1022 * Exact value is not available. 10 - 20ms in lp55xx_init_device()
1050 struct lp55xx_platform_data *pdata = chip->pdata; in lp55xx_register_leds()
1051 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_register_leds() local
1052 int num_channels = pdata->num_channels; in lp55xx_register_leds()
1058 if (!cfg->brightness_fn) { in lp55xx_register_leds()
1059 dev_err(&chip->cl->dev, "empty brightness configuration\n"); in lp55xx_register_leds()
1060 return -EINVAL; in lp55xx_register_leds()
1066 if (pdata->led_config[i].led_current == 0) in lp55xx_register_leds()
1069 led_current = pdata->led_config[i].led_current; in lp55xx_register_leds()
1075 chip->num_leds++; in lp55xx_register_leds()
1076 each->chip = chip; in lp55xx_register_leds()
1079 if (cfg->set_led_current) in lp55xx_register_leds()
1080 cfg->set_led_current(each, led_current); in lp55xx_register_leds()
1091 struct device *dev = &chip->cl->dev; in lp55xx_register_sysfs()
1092 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_register_sysfs() local
1095 if (!cfg->run_engine || !cfg->firmware_cb) in lp55xx_register_sysfs()
1098 ret = sysfs_create_group(&dev->kobj, &lp55xx_engine_attr_group); in lp55xx_register_sysfs()
1103 return cfg->dev_attr_group ? in lp55xx_register_sysfs()
1104 sysfs_create_group(&dev->kobj, cfg->dev_attr_group) : 0; in lp55xx_register_sysfs()
1109 struct device *dev = &chip->cl->dev; in lp55xx_unregister_sysfs()
1110 const struct lp55xx_device_config *cfg = chip->cfg; in lp55xx_unregister_sysfs() local
1112 if (cfg->dev_attr_group) in lp55xx_unregister_sysfs()
1113 sysfs_remove_group(&dev->kobj, cfg->dev_attr_group); in lp55xx_unregister_sysfs()
1115 sysfs_remove_group(&dev->kobj, &lp55xx_engine_attr_group); in lp55xx_unregister_sysfs()
1119 struct lp55xx_led_config *cfg, in lp55xx_parse_common_child() argument
1124 of_property_read_string(np, "chan-name", in lp55xx_parse_common_child()
1125 &cfg[led_number].name); in lp55xx_parse_common_child()
1126 of_property_read_u8(np, "led-cur", in lp55xx_parse_common_child()
1127 &cfg[led_number].led_current); in lp55xx_parse_common_child()
1128 of_property_read_u8(np, "max-cur", in lp55xx_parse_common_child()
1129 &cfg[led_number].max_current); in lp55xx_parse_common_child()
1135 if (*chan_nr < 0 || *chan_nr > cfg->max_channel) in lp55xx_parse_common_child()
1136 return -EINVAL; in lp55xx_parse_common_child()
1142 struct lp55xx_led_config *cfg, in lp55xx_parse_multi_led_child() argument
1147 ret = lp55xx_parse_common_child(child, cfg, child_number, &chan_nr); in lp55xx_parse_multi_led_child()
1155 cfg[child_number].color_id[color_number] = color_id; in lp55xx_parse_multi_led_child()
1156 cfg[child_number].output_num[color_number] = chan_nr; in lp55xx_parse_multi_led_child()
1162 struct lp55xx_led_config *cfg, in lp55xx_parse_multi_led() argument
1168 ret = lp55xx_parse_multi_led_child(child, cfg, child_number, in lp55xx_parse_multi_led()
1175 cfg[child_number].num_colors = num_colors; in lp55xx_parse_multi_led()
1181 struct lp55xx_led_config *cfg, in lp55xx_parse_logical_led() argument
1187 cfg[child_number].default_trigger = in lp55xx_parse_logical_led()
1188 of_get_property(np, "linux,default-trigger", NULL); in lp55xx_parse_logical_led()
1195 return lp55xx_parse_multi_led(np, cfg, child_number); in lp55xx_parse_logical_led()
1197 ret = lp55xx_parse_common_child(np, cfg, child_number, &chan_nr); in lp55xx_parse_logical_led()
1201 cfg[child_number].chan_nr = chan_nr; in lp55xx_parse_logical_led()
1212 struct lp55xx_led_config *cfg; in lp55xx_of_populate_pdata() local
1219 return ERR_PTR(-ENOMEM); in lp55xx_of_populate_pdata()
1224 return ERR_PTR(-EINVAL); in lp55xx_of_populate_pdata()
1227 cfg = devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL); in lp55xx_of_populate_pdata()
1228 if (!cfg) in lp55xx_of_populate_pdata()
1229 return ERR_PTR(-ENOMEM); in lp55xx_of_populate_pdata()
1231 pdata->led_config = &cfg[0]; in lp55xx_of_populate_pdata()
1232 pdata->num_channels = num_channels; in lp55xx_of_populate_pdata()
1233 cfg->max_channel = chip->cfg->max_channel; in lp55xx_of_populate_pdata()
1236 ret = lp55xx_parse_logical_led(child, cfg, i); in lp55xx_of_populate_pdata()
1239 return ERR_PTR(-EINVAL); in lp55xx_of_populate_pdata()
1244 if (of_property_read_u32(np, "ti,charge-pump-mode", &pdata->charge_pump_mode)) in lp55xx_of_populate_pdata()
1245 pdata->charge_pump_mode = LP55XX_CP_AUTO; in lp55xx_of_populate_pdata()
1247 if (pdata->charge_pump_mode > LP55XX_CP_AUTO) { in lp55xx_of_populate_pdata()
1248 dev_err(dev, "invalid charge pump mode %d\n", pdata->charge_pump_mode); in lp55xx_of_populate_pdata()
1249 return ERR_PTR(-EINVAL); in lp55xx_of_populate_pdata()
1252 of_property_read_string(np, "label", &pdata->label); in lp55xx_of_populate_pdata()
1253 of_property_read_u8(np, "clock-mode", &pdata->clock_mode); in lp55xx_of_populate_pdata()
1255 pdata->enable_gpiod = devm_gpiod_get_optional(dev, "enable", in lp55xx_of_populate_pdata()
1257 if (IS_ERR(pdata->enable_gpiod)) in lp55xx_of_populate_pdata()
1258 return ERR_CAST(pdata->enable_gpiod); in lp55xx_of_populate_pdata()
1261 of_property_read_u8(np, "pwr-sel", (u8 *)&pdata->pwr_sel); in lp55xx_of_populate_pdata()
1272 struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); in lp55xx_probe()
1273 struct device_node *np = dev_of_node(&client->dev); in lp55xx_probe()
1275 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); in lp55xx_probe()
1277 return -ENOMEM; in lp55xx_probe()
1279 chip->cfg = i2c_get_match_data(client); in lp55xx_probe()
1283 pdata = lp55xx_of_populate_pdata(&client->dev, np, in lp55xx_probe()
1288 dev_err(&client->dev, "no platform data\n"); in lp55xx_probe()
1289 return -EINVAL; in lp55xx_probe()
1295 if (chip->cfg->pages_per_engine) in lp55xx_probe()
1296 program_length *= chip->cfg->pages_per_engine; in lp55xx_probe()
1300 dev_err(&client->dev, "invalid pages_per_engine configured\n"); in lp55xx_probe()
1301 return -EINVAL; in lp55xx_probe()
1304 led = devm_kcalloc(&client->dev, in lp55xx_probe()
1305 pdata->num_channels, sizeof(*led), GFP_KERNEL); in lp55xx_probe()
1307 return -ENOMEM; in lp55xx_probe()
1309 chip->cl = client; in lp55xx_probe()
1310 chip->pdata = pdata; in lp55xx_probe()
1312 mutex_init(&chip->lock); in lp55xx_probe()
1320 dev_info(&client->dev, "%s Programmable led chip found\n", id->name); in lp55xx_probe()
1328 dev_err(&client->dev, "registering sysfs failed\n"); in lp55xx_probe()
1344 struct lp55xx_chip *chip = led->chip; in lp55xx_remove()