Lines Matching refs:led

59 static inline int lm3533_led_get_ctrlbank_id(struct lm3533_led *led)  in lm3533_led_get_ctrlbank_id()  argument
61 return led->id + 2; in lm3533_led_get_ctrlbank_id()
64 static inline u8 lm3533_led_get_lv_reg(struct lm3533_led *led, u8 base) in lm3533_led_get_lv_reg() argument
66 return base + led->id; in lm3533_led_get_lv_reg()
69 static inline u8 lm3533_led_get_pattern(struct lm3533_led *led) in lm3533_led_get_pattern() argument
71 return led->id; in lm3533_led_get_pattern()
74 static inline u8 lm3533_led_get_pattern_reg(struct lm3533_led *led, in lm3533_led_get_pattern_reg() argument
77 return base + lm3533_led_get_pattern(led) * LM3533_REG_PATTERN_STEP; in lm3533_led_get_pattern_reg()
80 static int lm3533_led_pattern_enable(struct lm3533_led *led, int enable) in lm3533_led_pattern_enable() argument
88 dev_dbg(led->cdev.dev, "%s - %d\n", __func__, enable); in lm3533_led_pattern_enable()
90 mutex_lock(&led->mutex); in lm3533_led_pattern_enable()
92 state = test_bit(LM3533_LED_FLAG_PATTERN_ENABLE, &led->flags); in lm3533_led_pattern_enable()
96 pattern = lm3533_led_get_pattern(led); in lm3533_led_pattern_enable()
104 ret = lm3533_update(led->lm3533, LM3533_REG_PATTERN_ENABLE, val, mask); in lm3533_led_pattern_enable()
106 dev_err(led->cdev.dev, "failed to enable pattern %d (%d)\n", in lm3533_led_pattern_enable()
111 __change_bit(LM3533_LED_FLAG_PATTERN_ENABLE, &led->flags); in lm3533_led_pattern_enable()
113 mutex_unlock(&led->mutex); in lm3533_led_pattern_enable()
121 struct lm3533_led *led = to_lm3533_led(cdev); in lm3533_led_set() local
123 dev_dbg(led->cdev.dev, "%s - %d\n", __func__, value); in lm3533_led_set()
126 lm3533_led_pattern_enable(led, 0); /* disable blink */ in lm3533_led_set()
128 return lm3533_ctrlbank_set_brightness(&led->cb, value); in lm3533_led_set()
133 struct lm3533_led *led = to_lm3533_led(cdev); in lm3533_led_get() local
137 ret = lm3533_ctrlbank_get_brightness(&led->cb, &val); in lm3533_led_get()
141 dev_dbg(led->cdev.dev, "%s - %u\n", __func__, val); in lm3533_led_get()
243 static u8 lm3533_led_delay_set(struct lm3533_led *led, u8 base, in lm3533_led_delay_set() argument
259 dev_dbg(led->cdev.dev, "%s - %lu: %u (0x%02x)\n", __func__, in lm3533_led_delay_set()
261 reg = lm3533_led_get_pattern_reg(led, base); in lm3533_led_delay_set()
262 ret = lm3533_write(led->lm3533, reg, val); in lm3533_led_delay_set()
264 dev_err(led->cdev.dev, "failed to set delay (%02x)\n", reg); in lm3533_led_delay_set()
271 static int lm3533_led_delay_on_set(struct lm3533_led *led, unsigned long *t) in lm3533_led_delay_on_set() argument
273 return lm3533_led_delay_set(led, LM3533_REG_PATTERN_HIGH_TIME_BASE, t); in lm3533_led_delay_on_set()
276 static int lm3533_led_delay_off_set(struct lm3533_led *led, unsigned long *t) in lm3533_led_delay_off_set() argument
278 return lm3533_led_delay_set(led, LM3533_REG_PATTERN_LOW_TIME_BASE, t); in lm3533_led_delay_off_set()
285 struct lm3533_led *led = to_lm3533_led(cdev); in lm3533_led_blink_set() local
288 dev_dbg(led->cdev.dev, "%s - on = %lu, off = %lu\n", __func__, in lm3533_led_blink_set()
300 ret = lm3533_led_delay_on_set(led, delay_on); in lm3533_led_blink_set()
304 ret = lm3533_led_delay_off_set(led, delay_off); in lm3533_led_blink_set()
308 return lm3533_led_pattern_enable(led, 1); in lm3533_led_blink_set()
315 struct lm3533_led *led = to_lm3533_led(led_cdev); in show_id() local
317 return sysfs_emit(buf, "%d\n", led->id); in show_id()
337 struct lm3533_led *led = to_lm3533_led(led_cdev); in show_risefalltime() local
342 reg = lm3533_led_get_pattern_reg(led, base); in show_risefalltime()
343 ret = lm3533_read(led->lm3533, reg, &val); in show_risefalltime()
369 struct lm3533_led *led = to_lm3533_led(led_cdev); in store_risefalltime() local
377 reg = lm3533_led_get_pattern_reg(led, base); in store_risefalltime()
378 ret = lm3533_write(led->lm3533, reg, val); in store_risefalltime()
405 struct lm3533_led *led = to_lm3533_led(led_cdev); in show_als_channel() local
411 reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); in show_als_channel()
412 ret = lm3533_read(led->lm3533, reg, &val); in show_als_channel()
426 struct lm3533_led *led = to_lm3533_led(led_cdev); in store_als_channel() local
440 reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); in store_als_channel()
444 ret = lm3533_update(led->lm3533, reg, val, mask); in store_als_channel()
455 struct lm3533_led *led = to_lm3533_led(led_cdev); in show_als_en() local
461 reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); in show_als_en()
462 ret = lm3533_read(led->lm3533, reg, &val); in show_als_en()
476 struct lm3533_led *led = to_lm3533_led(led_cdev); in store_als_en() local
486 reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); in store_als_en()
494 ret = lm3533_update(led->lm3533, reg, val, mask); in store_als_en()
505 struct lm3533_led *led = to_lm3533_led(led_cdev); in show_linear() local
511 reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); in show_linear()
512 ret = lm3533_read(led->lm3533, reg, &val); in show_linear()
529 struct lm3533_led *led = to_lm3533_led(led_cdev); in store_linear() local
539 reg = lm3533_led_get_lv_reg(led, LM3533_REG_CTRLBANK_BCONF_BASE); in store_linear()
547 ret = lm3533_update(led->lm3533, reg, val, mask); in store_linear()
559 struct lm3533_led *led = to_lm3533_led(led_cdev); in show_pwm() local
563 ret = lm3533_ctrlbank_get_pwm(&led->cb, &val); in show_pwm()
575 struct lm3533_led *led = to_lm3533_led(led_cdev); in store_pwm() local
582 ret = lm3533_ctrlbank_set_pwm(&led->cb, val); in store_pwm()
613 struct lm3533_led *led = to_lm3533_led(led_cdev); in lm3533_led_attr_is_visible() local
618 if (!led->lm3533->have_als) in lm3533_led_attr_is_visible()
635 static int lm3533_led_setup(struct lm3533_led *led, in lm3533_led_setup() argument
640 ret = lm3533_ctrlbank_set_max_current(&led->cb, pdata->max_current); in lm3533_led_setup()
644 return lm3533_ctrlbank_set_pwm(&led->cb, pdata->pwm); in lm3533_led_setup()
651 struct lm3533_led *led; in lm3533_led_probe() local
671 led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); in lm3533_led_probe()
672 if (!led) in lm3533_led_probe()
675 led->lm3533 = lm3533; in lm3533_led_probe()
676 led->cdev.name = pdata->name; in lm3533_led_probe()
677 led->cdev.default_trigger = pdata->default_trigger; in lm3533_led_probe()
678 led->cdev.brightness_set_blocking = lm3533_led_set; in lm3533_led_probe()
679 led->cdev.brightness_get = lm3533_led_get; in lm3533_led_probe()
680 led->cdev.blink_set = lm3533_led_blink_set; in lm3533_led_probe()
681 led->cdev.brightness = LED_OFF; in lm3533_led_probe()
682 led->cdev.groups = lm3533_led_attribute_groups; in lm3533_led_probe()
683 led->id = pdev->id; in lm3533_led_probe()
685 mutex_init(&led->mutex); in lm3533_led_probe()
691 led->cb.lm3533 = lm3533; in lm3533_led_probe()
692 led->cb.id = lm3533_led_get_ctrlbank_id(led); in lm3533_led_probe()
693 led->cb.dev = lm3533->dev; in lm3533_led_probe()
695 platform_set_drvdata(pdev, led); in lm3533_led_probe()
697 ret = led_classdev_register(pdev->dev.parent, &led->cdev); in lm3533_led_probe()
703 led->cb.dev = led->cdev.dev; in lm3533_led_probe()
705 ret = lm3533_led_setup(led, pdata); in lm3533_led_probe()
709 ret = lm3533_ctrlbank_enable(&led->cb); in lm3533_led_probe()
716 led_classdev_unregister(&led->cdev); in lm3533_led_probe()
723 struct lm3533_led *led = platform_get_drvdata(pdev); in lm3533_led_remove() local
727 lm3533_ctrlbank_disable(&led->cb); in lm3533_led_remove()
728 led_classdev_unregister(&led->cdev); in lm3533_led_remove()
736 struct lm3533_led *led = platform_get_drvdata(pdev); in lm3533_led_shutdown() local
740 lm3533_ctrlbank_disable(&led->cb); in lm3533_led_shutdown()
741 lm3533_led_set(&led->cdev, LED_OFF); /* disable blink */ in lm3533_led_shutdown()