int msm_flash_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int rc = 0; struct msm_led_flash_ctrl_t *fctrl = NULL; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; #endif if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("i2c_check_functionality failed\n"); goto probe_failure; } fctrl = (struct msm_led_flash_ctrl_t *)(id->driver_data); if (fctrl->flash_i2c_client) fctrl->flash_i2c_client->client = client; fctrl->flash_device_type = MSM_CAMERA_I2C_DEVICE; snprintf(fctrl->msm_sd.sd.name, sizeof(fctrl->msm_sd.sd.name), "%s", id->name); rc = msm_led_get_dt_data(client->dev.of_node, fctrl); if (rc < 0) { pr_err("%s failed line %d\n", __func__, __LINE__); return rc; } if (fctrl->flash_i2c_client != NULL) { fctrl->flash_i2c_client->client = client; if (fctrl->flashdata->slave_info->sensor_slave_addr) fctrl->flash_i2c_client->client->addr = fctrl->flashdata->slave_info-> sensor_slave_addr; } else { pr_err("%s %s sensor_i2c_client NULL\n", __func__, client->name); rc = -EFAULT; return rc; } if (!fctrl->flash_i2c_client->i2c_func_tbl) fctrl->flash_i2c_client->i2c_func_tbl = &msm_sensor_qup_func_tbl; rc = msm_led_i2c_flash_create_v4lsubdev(fctrl); #ifdef CONFIG_DEBUG_FS dentry = debugfs_create_file("ledflash", S_IRUGO, NULL, (void *)fctrl, &ledflashdbg_fops); if (!dentry) pr_err("Failed to create the debugfs ledflash file"); #endif CDBG("%s:%d probe success\n", __func__, __LINE__); return 0; probe_failure: CDBG("%s:%d probe failed\n", __func__, __LINE__); return rc; }
int msm_flash_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int rc = 0; #ifdef CONFIG_HUAWEI_HW_DEV_DCT uint16_t tmp_data = 0; #endif struct msm_led_flash_ctrl_t *fctrl = NULL; #ifdef CONFIG_DEBUG_FS struct dentry *dentry; #endif if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("i2c_check_functionality failed\n"); goto probe_failure; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { pr_err("i2c_check_functionality failed I2C_FUNC_SMBUS_I2C_BLOCK\n"); goto probe_failure; } fctrl = (struct msm_led_flash_ctrl_t *)(id->driver_data); if (fctrl->flash_i2c_client) fctrl->flash_i2c_client->client = client; /* Set device type as I2C */ fctrl->flash_device_type = MSM_CAMERA_I2C_DEVICE; /* Assign name for sub device */ snprintf(fctrl->msm_sd.sd.name, sizeof(fctrl->msm_sd.sd.name), "%s", id->name); rc = msm_led_get_dt_data(client->dev.of_node, fctrl); if (rc < 0) { pr_err("%s failed line %d\n", __func__, __LINE__); return rc; } if (fctrl->flash_i2c_client != NULL) { fctrl->flash_i2c_client->client = client; if (fctrl->flashdata->slave_info->sensor_slave_addr) fctrl->flash_i2c_client->client->addr = fctrl->flashdata->slave_info-> sensor_slave_addr; } else { pr_err("%s %s sensor_i2c_client NULL\n", __func__, client->name); rc = -EFAULT; return rc; } fctrl->flash_i2c_client->client->addr = fctrl->flash_i2c_client->client->addr<<1; if (!fctrl->flash_i2c_client->i2c_func_tbl) fctrl->flash_i2c_client->i2c_func_tbl = &msm_sensor_qup_func_tbl; #ifdef CONFIG_HUAWEI_HW_DEV_DCT /* read chip id */ //clear the err and unlock IC, this function must be called before read and write register msm_flash_clear_err_and_unlock(fctrl); rc = fctrl->flash_i2c_client->i2c_func_tbl->i2c_read( fctrl->flash_i2c_client,0x00,&tmp_data, MSM_CAMERA_I2C_BYTE_DATA); if(rc < 0) { pr_err("%s: FLASHCHIP READ I2C error!\n", __func__); goto probe_failure; } if ( FLASH_CHIP_ID == (tmp_data & FLASH_CHIP_ID_MASK) ) { pr_err("%s : Read chip id ok!Chip ID is %d.\n", __func__, tmp_data); /* detect current device successful, set the flag as present */ set_hw_dev_flag(DEV_I2C_FLASH); pr_err("%s : LM3642 probe succeed!\n", __func__); } else { pr_err("%s : read chip id error!Chip ID is %d.\n", __func__, tmp_data); rc = -ENODEV; goto probe_failure; } #endif rc = msm_led_i2c_flash_create_v4lsubdev(fctrl); #ifdef CONFIG_DEBUG_FS dentry = debugfs_create_file("ledflash", S_IRUGO, NULL, (void *)fctrl, &ledflashdbg_fops); if (!dentry) pr_err("Failed to create the debugfs ledflash file"); #endif CDBG("%s:%d probe success\n", __func__, __LINE__); return 0; probe_failure: CDBG("%s:%d probe failed\n", __func__, __LINE__); return rc; }