Lines Matching refs:rt
66 static void rt8515_gpio_led_off(struct rt8515 *rt) in rt8515_gpio_led_off() argument
68 gpiod_set_value(rt->enable_flash, 0); in rt8515_gpio_led_off()
69 gpiod_set_value(rt->enable_torch, 0); in rt8515_gpio_led_off()
94 struct rt8515 *rt = to_rt8515(fled); in rt8515_led_brightness_set() local
96 mutex_lock(&rt->lock); in rt8515_led_brightness_set()
100 rt8515_gpio_led_off(rt); in rt8515_led_brightness_set()
103 rt8515_gpio_brightness_commit(rt->enable_torch, brightness); in rt8515_led_brightness_set()
106 gpiod_set_value(rt->enable_torch, 1); in rt8515_led_brightness_set()
109 mutex_unlock(&rt->lock); in rt8515_led_brightness_set()
117 struct rt8515 *rt = to_rt8515(fled); in rt8515_led_flash_strobe_set() local
119 int brightness = rt->flash_max_intensity; in rt8515_led_flash_strobe_set()
121 mutex_lock(&rt->lock); in rt8515_led_flash_strobe_set()
125 rt8515_gpio_brightness_commit(rt->enable_flash, brightness); in rt8515_led_flash_strobe_set()
127 mod_timer(&rt->powerdown_timer, in rt8515_led_flash_strobe_set()
130 del_timer_sync(&rt->powerdown_timer); in rt8515_led_flash_strobe_set()
132 rt8515_gpio_led_off(rt); in rt8515_led_flash_strobe_set()
138 mutex_unlock(&rt->lock); in rt8515_led_flash_strobe_set()
146 struct rt8515 *rt = to_rt8515(fled); in rt8515_led_flash_strobe_get() local
148 *state = timer_pending(&rt->powerdown_timer); in rt8515_led_flash_strobe_get()
168 struct rt8515 *rt = from_timer(rt, t, powerdown_timer); in rt8515_powerdown_timer() local
171 rt8515_gpio_led_off(rt); in rt8515_powerdown_timer()
174 static void rt8515_init_flash_timeout(struct rt8515 *rt) in rt8515_init_flash_timeout() argument
176 struct led_classdev_flash *fled = &rt->fled; in rt8515_init_flash_timeout()
182 s->max = rt->max_timeout; in rt8515_init_flash_timeout()
188 s->val = min(rt->max_timeout, RT8515_TIMEOUT_US); in rt8515_init_flash_timeout()
193 static void rt8515_init_v4l2_flash_config(struct rt8515 *rt, in rt8515_init_v4l2_flash_config() argument
196 struct led_classdev *led = &rt->fled.led_cdev; in rt8515_init_v4l2_flash_config()
209 s->max = rt->flash_max_intensity; in rt8515_init_v4l2_flash_config()
214 static void rt8515_v4l2_flash_release(struct rt8515 *rt) in rt8515_v4l2_flash_release() argument
216 v4l2_flash_release(rt->v4l2_flash); in rt8515_v4l2_flash_release()
220 static void rt8515_init_v4l2_flash_config(struct rt8515 *rt, in rt8515_init_v4l2_flash_config() argument
225 static void rt8515_v4l2_flash_release(struct rt8515 *rt) in rt8515_v4l2_flash_release() argument
230 static void rt8515_determine_max_intensity(struct rt8515 *rt, in rt8515_determine_max_intensity() argument
242 fwnode_property_read_u32(rt->dev->fwnode, resistance, &res); in rt8515_determine_max_intensity()
247 dev_err(rt->dev, in rt8515_determine_max_intensity()
266 dev_info(rt->dev, in rt8515_determine_max_intensity()
271 dev_info(rt->dev, "max intensity %d/%d = %d mA\n", in rt8515_determine_max_intensity()
280 struct rt8515 *rt; in rt8515_probe() local
287 rt = devm_kzalloc(dev, sizeof(*rt), GFP_KERNEL); in rt8515_probe()
288 if (!rt) in rt8515_probe()
291 rt->dev = dev; in rt8515_probe()
292 fled = &rt->fled; in rt8515_probe()
296 rt->enable_flash = devm_gpiod_get(dev, "enf", GPIOD_OUT_LOW); in rt8515_probe()
297 if (IS_ERR(rt->enable_flash)) in rt8515_probe()
298 return dev_err_probe(dev, PTR_ERR(rt->enable_flash), in rt8515_probe()
302 rt->enable_torch = devm_gpiod_get(dev, "ent", GPIOD_OUT_LOW); in rt8515_probe()
303 if (IS_ERR(rt->enable_torch)) in rt8515_probe()
304 return dev_err_probe(dev, PTR_ERR(rt->enable_torch), in rt8515_probe()
315 rt8515_determine_max_intensity(rt, child, "richtek,rfs-ohms", in rt8515_probe()
318 &rt->flash_max_intensity); in rt8515_probe()
319 rt8515_determine_max_intensity(rt, child, "richtek,rts-ohms", in rt8515_probe()
322 &rt->torch_max_intensity); in rt8515_probe()
325 &rt->max_timeout); in rt8515_probe()
327 rt->max_timeout = RT8515_MAX_TIMEOUT_US; in rt8515_probe()
331 timer_setup(&rt->powerdown_timer, rt8515_powerdown_timer, 0); in rt8515_probe()
332 rt8515_init_flash_timeout(rt); in rt8515_probe()
336 led->max_brightness = rt->torch_max_intensity; in rt8515_probe()
340 mutex_init(&rt->lock); in rt8515_probe()
342 platform_set_drvdata(pdev, rt); in rt8515_probe()
347 mutex_destroy(&rt->lock); in rt8515_probe()
352 rt8515_init_v4l2_flash_config(rt, &v4l2_sd_cfg); in rt8515_probe()
355 rt->v4l2_flash = v4l2_flash_init(dev, child, fled, NULL, &v4l2_sd_cfg); in rt8515_probe()
356 if (IS_ERR(rt->v4l2_flash)) { in rt8515_probe()
357 ret = PTR_ERR(rt->v4l2_flash); in rt8515_probe()
372 struct rt8515 *rt = platform_get_drvdata(pdev); in rt8515_remove() local
374 rt8515_v4l2_flash_release(rt); in rt8515_remove()
375 del_timer_sync(&rt->powerdown_timer); in rt8515_remove()
376 mutex_destroy(&rt->lock); in rt8515_remove()