static int stmvl6180_probe(struct i2c_client *client, const struct i2c_device_id *id) { int rc = 0; struct stmvl6180_data *vl6180_data = NULL; struct i2c_data *data = NULL; vl6180_dbgmsg("Enter\n"); if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { rc = -EIO; return rc; } vl6180_data = stmvl6180_getobject(); if (vl6180_data) data = &(vl6180_data->client_object); data->client = client; /* setup regulator */ stmvl6180_parse_vdd(&data->client->dev, data); /* setup client data */ i2c_set_clientdata(client, vl6180_data); /* setup platform i2c client */ i2c_setclient((void *)client); vl6180_dbgmsg("End\n"); return rc; }
static int32_t stmvl6180_platform_probe(struct platform_device *pdev) { struct stmvl6180_data *vl6180_data = NULL; struct cci_data *data = NULL; int32_t rc = 0; vl6180_dbgmsg("Enter\n"); if (!pdev->dev.of_node) { vl6180_errmsg("of_node NULL\n"); return -EINVAL; } vl6180_data = stmvl6180_getobject(); if (NULL == vl6180_data) { vl6180_errmsg("Object not found!\n"); return -EINVAL; } data = &(vl6180_data->client_object); if (!data) { vl6180_errmsg("data NULL\n"); return -EINVAL; } data->client = (struct msm_camera_i2c_client *)&data->g_client; /* setup platform i2c client */ i2c_setclient((void *)data->client); /* Set platform device handle */ data->subdev_ops = &msm_tof_subdev_ops; data->pdev = pdev; rc = stmvl6180_get_dt_data(&pdev->dev, data); if (rc < 0) { vl6180_errmsg("%d, failed rc %d\n", __LINE__, rc); return rc; } data->subdev_id = pdev->id; rc = gpio_request_one(data->en_gpio,GPIOF_OUT_INIT_LOW, "stmvl6180_ldaf_en_gpio"); if(rc) { vl6180_errmsg("failed gpio request %u\n",data->en_gpio); return -EINVAL; } /* ldaf_int not used */ data->int_gpio = -1; /* Set device type as platform device */ data->device_type = MSM_CAMERA_PLATFORM_DEVICE; data->subdev_initialized = FALSE; vl6180_dbgmsg("End\n"); return rc; }
static int stmvl6180_remove(struct i2c_client *client) { struct stmvl6180_data *data = stmvl6180_getobject(); vl6180_dbgmsg("Enter\n"); /* Power down the device */ stmvl6180_power_down_i2c((void *)&data->client_object); vl6180_dbgmsg("End\n"); return 0; }
static int32_t msm_tof_power(struct v4l2_subdev *sd, int on) { struct stmvl6180_data *stmdata = stmvl6180_getobject(); if(stmdata) { mutex_lock(&stmdata->work_mutex); if(on) { if(stmdata->tof_start && stmdata->enable_ps_sensor == 0) stmdata->tof_start(stmdata, 3, NORMAL_MODE); } else { if(stmdata->tof_stop && stmdata->enable_ps_sensor == 1) { stmdata->enable_ps_sensor = 0; stmdata->tof_stop(stmdata); } } mutex_unlock(&stmdata->work_mutex); } vl6180_dbgmsg("TOF power called %d\n", on); return 0; }