msm: camera: sensor: Move cci master index to dt-bindings
Master specific index is moved to dt bindings to share across dtsi and driver for the same referencing. This will help to align indexing and controlling of pinctrl with master specific slaves. CRs-Fixed: 2907475, 2954556 Change-Id: Ic5b5537b44af583cb7623ef38a19e67ffe95e95d Signed-off-by: Jigarkumar Zala <jzala@codeaurora.org>
This commit is contained in:
@ -94,6 +94,35 @@ int32_t cam_sensor_get_sub_module_index(struct device_node *of_node,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int32_t cam_sensor_init_bus_params(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
{
|
||||
/* Validate input parameters */
|
||||
if (!s_ctrl) {
|
||||
CAM_ERR(CAM_SENSOR, "failed: invalid params s_ctrl %pK",
|
||||
s_ctrl);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_SENSOR,
|
||||
"master_type: %d", s_ctrl->io_master_info.master_type);
|
||||
/* Initialize cci_client */
|
||||
if (s_ctrl->io_master_info.master_type == CCI_MASTER) {
|
||||
s_ctrl->io_master_info.cci_client = kzalloc(sizeof(
|
||||
struct cam_sensor_cci_client), GFP_KERNEL);
|
||||
if (!(s_ctrl->io_master_info.cci_client))
|
||||
return -ENOMEM;
|
||||
} else if (s_ctrl->io_master_info.master_type == I2C_MASTER) {
|
||||
if (!(s_ctrl->io_master_info.client))
|
||||
return -EINVAL;
|
||||
} else {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"Invalid master / Master type Not supported");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
{
|
||||
int32_t rc = 0;
|
||||
@ -166,6 +195,13 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
goto FREE_SENSOR_DATA;
|
||||
}
|
||||
|
||||
rc = cam_sensor_init_bus_params(s_ctrl);
|
||||
if (rc < 0) {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"Failed in Initialize Bus params, rc %d", rc);
|
||||
goto FREE_SENSOR_DATA;
|
||||
}
|
||||
|
||||
if (s_ctrl->io_master_info.master_type == CCI_MASTER) {
|
||||
/* Get CCI master */
|
||||
rc = of_property_read_u32(of_node, "cci-master",
|
||||
@ -184,6 +220,9 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
/* Set default master 0 */
|
||||
s_ctrl->cci_num = CCI_DEVICE_0;
|
||||
|
||||
s_ctrl->io_master_info.cci_client->cci_device
|
||||
= s_ctrl->cci_num;
|
||||
|
||||
CAM_DBG(CAM_SENSOR, "cci-index %d", s_ctrl->cci_num);
|
||||
}
|
||||
|
||||
@ -219,41 +258,11 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
|
||||
FREE_SENSOR_DATA:
|
||||
kfree(sensordata);
|
||||
s_ctrl->sensordata = NULL;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int32_t msm_sensor_init_default_params(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
{
|
||||
/* Validate input parameters */
|
||||
if (!s_ctrl) {
|
||||
CAM_ERR(CAM_SENSOR, "failed: invalid params s_ctrl %pK",
|
||||
s_ctrl);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
CAM_DBG(CAM_SENSOR,
|
||||
"master_type: %d", s_ctrl->io_master_info.master_type);
|
||||
/* Initialize cci_client */
|
||||
if (s_ctrl->io_master_info.master_type == CCI_MASTER) {
|
||||
s_ctrl->io_master_info.cci_client = kzalloc(sizeof(
|
||||
struct cam_sensor_cci_client), GFP_KERNEL);
|
||||
if (!(s_ctrl->io_master_info.cci_client))
|
||||
return -ENOMEM;
|
||||
|
||||
s_ctrl->io_master_info.cci_client->cci_device
|
||||
= s_ctrl->cci_num;
|
||||
} else if (s_ctrl->io_master_info.master_type == I2C_MASTER) {
|
||||
if (!(s_ctrl->io_master_info.client))
|
||||
return -EINVAL;
|
||||
} else {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"Invalid master / Master type Not supported");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t cam_sensor_parse_dt(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
{
|
||||
int32_t i, rc = 0;
|
||||
@ -295,18 +304,5 @@ int32_t cam_sensor_parse_dt(struct cam_sensor_ctrl_t *s_ctrl)
|
||||
soc_info->rgltr_name[i]);
|
||||
}
|
||||
|
||||
rc = msm_sensor_init_default_params(s_ctrl);
|
||||
if (rc < 0) {
|
||||
CAM_ERR(CAM_SENSOR,
|
||||
"failed: msm_sensor_init_default_params rc %d", rc);
|
||||
goto FREE_DT_DATA;
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
||||
FREE_DT_DATA:
|
||||
kfree(s_ctrl->sensordata);
|
||||
s_ctrl->sensordata = NULL;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _CAM_SENSOR_CMN_HEADER_
|
||||
@ -13,6 +13,8 @@
|
||||
#include <linux/timer.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/list.h>
|
||||
|
||||
#include <dt-bindings/msm-camera.h>
|
||||
#include <media/cam_sensor.h>
|
||||
#include <media/cam_req_mgr.h>
|
||||
|
||||
@ -133,9 +135,9 @@ enum cam_flash_device_type {
|
||||
};
|
||||
|
||||
enum cci_i2c_master_t {
|
||||
MASTER_0,
|
||||
MASTER_1,
|
||||
MASTER_MAX,
|
||||
MASTER_0 = CCI_MASTER_0,
|
||||
MASTER_1 = CCI_MASTER_1,
|
||||
MASTER_MAX = CCI_MASTER_MAX,
|
||||
};
|
||||
|
||||
enum cci_device_num {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __MSM_CAMERA_H
|
||||
@ -90,4 +90,8 @@
|
||||
#define CAM_CPAS_ISP_PIX_FUSE 5
|
||||
#define CAM_CPAS_FUSE_FEATURE_MAX 6
|
||||
|
||||
#define CCI_MASTER_0 0
|
||||
#define CCI_MASTER_1 1
|
||||
#define CCI_MASTER_MAX 2
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user