34 #include <linux/module.h>
35 #include <linux/i2c.h>
36 #include <linux/slab.h>
40 #define TIMEOUT_MAX 820000
41 #define TIMEOUT_STEP 54600
42 #define TIMEOUT_MIN (TIMEOUT_MAX - ADP1653_REG_CONFIG_TMR_SET_MAX \
44 #define TIMEOUT_US_TO_CODE(t) ((TIMEOUT_MAX + (TIMEOUT_STEP / 2) - (t)) \
46 #define TIMEOUT_CODE_TO_US(c) (TIMEOUT_MAX - (c) * TIMEOUT_STEP)
98 flash->
fault |= fault;
110 rval = adp1653_update_hw(flash);
157 rval = adp1653_get_fault(flash);
177 static int adp1653_set_ctrl(
struct v4l2_ctrl *ctrl)
183 rval = adp1653_get_fault(flash);
196 return adp1653_strobe(flash, 1);
198 return adp1653_strobe(flash, 0);
201 return adp1653_update_hw(flash);
205 .g_volatile_ctrl = adp1653_get_ctrl,
206 .s_ctrl = adp1653_set_ctrl,
209 static int adp1653_init_controls(
struct adp1653_flash *flash)
258 if (flash->
ctrls.error)
259 return flash->
ctrls.error;
280 dev_err(&client->
dev,
"failed writing fault register\n");
287 rval = adp1653_get_fault(flash);
290 dev_err(&client->
dev,
"faults detected: 0x%1.1x\n", rval);
295 rval = adp1653_update_hw(flash);
299 "adp1653_update_hw failed at %s\n", __func__);
318 ret = adp1653_init_device(flash);
337 ret = __adp1653_set_power(flash, !!on);
353 return adp1653_set_power(sd, 1);
358 return adp1653_set_power(sd, 0);
362 .s_power = adp1653_set_power,
366 .core = &adp1653_core_ops,
370 .open = adp1653_open,
371 .close = adp1653_close,
382 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
388 return __adp1653_set_power(flash, 0);
394 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
400 return __adp1653_set_power(flash, 1);
405 #define adp1653_suspend NULL
406 #define adp1653_resume NULL
410 static int adp1653_probe(
struct i2c_client *client,
417 if (client->
dev.platform_data ==
NULL)
429 flash->
subdev.internal_ops = &adp1653_internal_ops;
432 ret = adp1653_init_controls(flash);
452 struct v4l2_subdev *subdev = i2c_get_clientdata(client);
473 static struct i2c_driver adp1653_i2c_driver = {
476 .pm = &adp1653_pm_ops,
478 .probe = adp1653_probe,
480 .id_table = adp1653_id_table,