Lines Matching +full:power +full:- +full:up +full:- +full:delay +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0
4 #include <linux/delay.h>
9 #include <media/v4l2-async.h>
10 #include <media/v4l2-ctrls.h>
11 #include <media/v4l2-device.h>
12 #include <media/v4l2-fwnode.h>
13 #include <media/v4l2-subdev.h>
16 #define DW9768_MAX_FOCUS_POS (1024 - 1)
24 * Ring control and Power control register
30 * 1: Power down mode
71 * Tvib = (6.3ms + AACT[5:0] * 0.1ms) * Dividing Rate
78 * DW9768 requires waiting time (delay time) of t_OPR after power-up,
82 #define DW9768_TVIB_MS_BASE10 (64 - 1)
89 * Keep this value power of 2, so the control steps can be
96 "vin", /* Digital I/O power */
97 "vdd", /* Digital core power */
177 * Tvib = (6.3ms + AACT[5:0] * 0.1MS) * Dividing Rate.
178 * Below is calculation of the operation delay for each step.
199 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_mod_reg()
213 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_set_dac()
221 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_init()
231 * DW9769 requires waiting delay time of t_OPR in dw9768_init()
245 dw9768->aac_mode << 5); in dw9768_init()
250 if (dw9768->clock_presc != DW9768_CLOCK_PRE_SCALE_DEFAULT) { in dw9768_init()
253 dw9768->clock_presc); in dw9768_init()
259 if (dw9768->aac_timing != DW9768_AAC_TIME_DEFAULT) { in dw9768_init()
261 dw9768->aac_timing); in dw9768_init()
266 for (val = dw9768->focus->val % DW9768_MOVE_STEPS; in dw9768_init()
267 val <= dw9768->focus->val; in dw9768_init()
271 dev_err(&client->dev, "I2C failure: %d", ret); in dw9768_init()
274 usleep_range(dw9768->move_delay_us, in dw9768_init()
275 dw9768->move_delay_us + 1000); in dw9768_init()
283 struct i2c_client *client = v4l2_get_subdevdata(&dw9768->sd); in dw9768_release()
286 val = round_down(dw9768->focus->val, DW9768_MOVE_STEPS); in dw9768_release()
287 for ( ; val >= 0; val -= DW9768_MOVE_STEPS) { in dw9768_release()
290 dev_err(&client->dev, "I2C write fail: %d", ret); in dw9768_release()
293 usleep_range(dw9768->move_delay_us, in dw9768_release()
294 dw9768->move_delay_us + 1000); in dw9768_release()
303 * DW9769 requires waiting delay time of t_OPR in dw9768_release()
318 dw9768->supplies); in dw9768_runtime_suspend()
330 dw9768->supplies); in dw9768_runtime_resume()
338 * I2C commands after power-up. in dw9768_runtime_resume()
350 dw9768->supplies); in dw9768_runtime_resume()
357 struct dw9768 *dw9768 = container_of(ctrl->handler, in dw9768_set_ctrl()
360 if (ctrl->id == V4L2_CID_FOCUS_ABSOLUTE) in dw9768_set_ctrl()
361 return dw9768_set_dac(dw9768, ctrl->val); in dw9768_set_ctrl()
372 return pm_runtime_resume_and_get(sd->dev); in dw9768_open()
377 pm_runtime_put(sd->dev); in dw9768_close()
391 struct v4l2_ctrl_handler *hdl = &dw9768->ctrls; in dw9768_init_controls()
396 dw9768->focus = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FOCUS_ABSOLUTE, 0, in dw9768_init_controls()
400 if (hdl->error) in dw9768_init_controls()
401 return hdl->error; in dw9768_init_controls()
403 dw9768->sd.ctrl_handler = hdl; in dw9768_init_controls()
410 struct device *dev = &client->dev; in dw9768_probe()
418 return -ENOMEM; in dw9768_probe()
421 v4l2_i2c_subdev_init(&dw9768->sd, client, &dw9768_ops); in dw9768_probe()
423 dw9768->aac_mode = DW9768_AAC_MODE_DEFAULT; in dw9768_probe()
424 dw9768->aac_timing = DW9768_AAC_TIME_DEFAULT; in dw9768_probe()
425 dw9768->clock_presc = DW9768_CLOCK_PRE_SCALE_DEFAULT; in dw9768_probe()
428 fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-mode", in dw9768_probe()
429 &dw9768->aac_mode); in dw9768_probe()
431 /* Optional indication of clock pre-scale select */ in dw9768_probe()
432 fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,clock-presc", in dw9768_probe()
433 &dw9768->clock_presc); in dw9768_probe()
436 fwnode_property_read_u32(dev_fwnode(dev), "dongwoon,aac-timing", in dw9768_probe()
437 &dw9768->aac_timing); in dw9768_probe()
439 dw9768->move_delay_us = dw9768_cal_move_delay(dw9768->aac_mode, in dw9768_probe()
440 dw9768->clock_presc, in dw9768_probe()
441 dw9768->aac_timing); in dw9768_probe()
444 dw9768->supplies[i].supply = dw9768_supply_names[i]; in dw9768_probe()
447 dw9768->supplies); in dw9768_probe()
459 dw9768->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in dw9768_probe()
460 dw9768->sd.internal_ops = &dw9768_int_ops; in dw9768_probe()
462 ret = media_entity_pads_init(&dw9768->sd.entity, 0, NULL); in dw9768_probe()
466 dw9768->sd.entity.function = MEDIA_ENT_F_LENS; in dw9768_probe()
469 * Figure out whether we're going to power up the device here. Generally in dw9768_probe()
471 * to be powered on in an ACPI system. Similarly for power off in in dw9768_probe()
481 dev_err(dev, "failed to power on: %d\n", ret); in dw9768_probe()
487 ret = v4l2_async_register_subdev(&dw9768->sd); in dw9768_probe()
504 media_entity_cleanup(&dw9768->sd.entity); in dw9768_probe()
506 v4l2_ctrl_handler_free(&dw9768->ctrls); in dw9768_probe()
515 struct device *dev = &client->dev; in dw9768_remove()
517 v4l2_async_unregister_subdev(&dw9768->sd); in dw9768_remove()
518 v4l2_ctrl_handler_free(&dw9768->ctrls); in dw9768_remove()
519 media_entity_cleanup(&dw9768->sd.entity); in dw9768_remove()