Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f6c968e authored by Shravan Nevatia's avatar Shravan Nevatia
Browse files

msm: camera: csiphy: Add concurrent DPHY-DPHY combo support



Add support for concurrent DPHY-DPHY combo-mode operation
in the CSIPHY KMD driver.

CRs-Fixed: 2736507
Change-Id: Id65d0964e91286f69fea05a5d4df025af93d3f06
Signed-off-by: default avatarShravan Nevatia <snevatia@codeaurora.org>
parent 03528467
Loading
Loading
Loading
Loading
+508 −255

File changed.

Preview size limit exceeded, changes collapsed.

+16 −9
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
	struct cam_cpas_register_params cpas_parms;
	struct csiphy_device *new_csiphy_dev;
	int32_t              rc = 0;
	int i;

	new_csiphy_dev = devm_kzalloc(&pdev->dev,
		sizeof(struct csiphy_device), GFP_KERNEL);
@@ -208,18 +209,24 @@ static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)

	platform_set_drvdata(pdev, &(new_csiphy_dev->v4l2_dev_str.sd));

	new_csiphy_dev->bridge_intf.device_hdl[0] = -1;
	new_csiphy_dev->bridge_intf.device_hdl[1] = -1;
	new_csiphy_dev->bridge_intf.ops.get_dev_info =
		NULL;
	new_csiphy_dev->bridge_intf.ops.link_setup =
		NULL;
	new_csiphy_dev->bridge_intf.ops.apply_req =
		NULL;
	for (i = 0; i < CSIPHY_MAX_INSTANCES_PER_PHY; i++) {
		new_csiphy_dev->csiphy_info[i].hdl_data.device_hdl = -1;
		new_csiphy_dev->csiphy_info[i].hdl_data.session_hdl = -1;
		new_csiphy_dev->csiphy_info[i].csiphy_3phase = -1;
		new_csiphy_dev->csiphy_info[i].data_rate = 0;
		new_csiphy_dev->csiphy_info[i].settle_time = 0;
		new_csiphy_dev->csiphy_info[i].lane_cnt = 0;
		new_csiphy_dev->csiphy_info[i].lane_assign = 0;
		new_csiphy_dev->csiphy_info[i].lane_enable = 0;
		new_csiphy_dev->csiphy_info[i].mipi_flags = 0;
	}

	new_csiphy_dev->ops.get_dev_info = NULL;
	new_csiphy_dev->ops.link_setup = NULL;
	new_csiphy_dev->ops.apply_req = NULL;

	new_csiphy_dev->acquire_count = 0;
	new_csiphy_dev->start_dev_count = 0;
	new_csiphy_dev->is_acquired_dev_combo_mode = 0;
	new_csiphy_dev->open_cnt = 0;

	cpas_parms.cam_cpas_client_cb = NULL;
+77 −68
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@
#include "cam_context.h"

#define MAX_CSIPHY                  6
#define MAX_DPHY_DATA_LN            4

#define MAX_LRME_V4l2_EVENTS        30
#define CSIPHY_NUM_CLK_MAX          16
#define MAX_CSIPHY_REG_ARRAY        70
@@ -55,7 +55,7 @@
#define CSIPHY_3PH_REGS                  6
#define CSIPHY_SKEW_CAL                  7

#define CSIPHY_MAX_INSTANCES     2
#define CSIPHY_MAX_INSTANCES_PER_PHY     2

#define CAM_CSIPHY_MAX_DPHY_LANES    4
#define CAM_CSIPHY_MAX_CPHY_LANES    3
@@ -69,6 +69,17 @@
#define CDBG(fmt, args...) pr_debug(fmt, ##args)
#endif

#define DPHY_LANE_0    BIT(0)
#define CPHY_LANE_0    BIT(1)
#define DPHY_LANE_1    BIT(2)
#define CPHY_LANE_1    BIT(3)
#define DPHY_LANE_2    BIT(4)
#define CPHY_LANE_2    BIT(5)
#define DPHY_LANE_3    BIT(6)
#define DPHY_CLK_LN    BIT(7)



enum cam_csiphy_state {
	CAM_CSIPHY_INIT,
	CAM_CSIPHY_ACQUIRE,
@@ -123,18 +134,13 @@ struct csiphy_reg_parms_t {
};

/**
 * struct intf_params
 * struct csiphy_hdl_tbl
 * @device_hdl: Device Handle
 * @session_hdl: Session Handle
 * @ops: KMD operations
 * @crm_cb: Callback API pointers
 */
struct intf_params {
	int32_t device_hdl[CSIPHY_MAX_INSTANCES];
	int32_t session_hdl[CSIPHY_MAX_INSTANCES];
	int32_t link_hdl[CSIPHY_MAX_INSTANCES];
	struct cam_req_mgr_kmd_ops ops;
	struct cam_req_mgr_crm_cb *crm_cb;
struct csiphy_hdl_tbl {
	int32_t device_hdl;
	int32_t session_hdl;
};

/**
@@ -204,38 +210,34 @@ struct csiphy_ctrl_t {
	struct csiphy_reg_t (*csiphy_2ph_combo_mode_reg)[MAX_SETTINGS_PER_LANE];
	struct csiphy_reg_t (*csiphy_3ph_reg)[MAX_SETTINGS_PER_LANE];
	struct csiphy_reg_t (*csiphy_2ph_3ph_mode_reg)[MAX_SETTINGS_PER_LANE];
	enum   cam_vote_level (*getclockvoting)(struct csiphy_device *phy_dev);
	enum   cam_vote_level (*getclockvoting)(struct csiphy_device *phy_dev,
		int32_t index);
	struct data_rate_settings_t *data_rates_settings_table;
};

/**
 * cam_csiphy_param: Provides cmdbuffer structre
 * @lane_mask     :  Lane mask details
/*
 * cam_csiphy_param            :  Provides cmdbuffer structure
 * @lane_assign                :  Lane sensor will be using
 * @csiphy_3phase :  Mentions DPHY or CPHY
 * @combo_mode    :  Info regarding combo_mode is enable / disable
 * @lane_cnt                   :  Total number of lanes
 * @reserved
 * @3phase        :  Details whether 3Phase / 2Phase operation
 * @lane_enable                :  Data Lane selection
 * @settle_time                :  Settling time in ms
 * @settle_time_combo_sensor   :  Settling time in ms
 * @data_rate                  :  Data rate in mbps
 * @data_rate_combo_sensor: data rate of combo sensor
 *                          in the the same phy
 * @csiphy_cpas_cp_reg_mask    :  CP reg mask for phy instance
 * @hdl_data                   :  CSIPHY handle table
 * @mipi_flags                 :  Mipi flags
 */
struct cam_csiphy_param {
	uint16_t    lane_mask;
	uint16_t                   lane_assign;
	uint8_t     csiphy_3phase;
	uint8_t     combo_mode;
	int                        csiphy_3phase;
	uint8_t                    lane_cnt;
	uint8_t     secure_mode[CSIPHY_MAX_INSTANCES];
	uint8_t                    secure_mode;
	uint32_t                   lane_enable;
	uint64_t                   settle_time;
	uint64_t    settle_time_combo_sensor;
	uint64_t                   data_rate;
	uint64_t    data_rate_combo_sensor;
	uint32_t                   mipi_flags;
	uint64_t                   csiphy_cpas_cp_reg_mask;
	struct csiphy_hdl_tbl      hdl_data;
};

/**
@@ -261,12 +263,14 @@ struct cam_csiphy_param {
 * @clk_lane:                   Clock lane
 * @acquire_count:              Acquire device count
 * @start_dev_count:            Start count
 * @is_acquired_dev_combo_mode: Flag that mentions whether already acquired
 *                              device is for combo mode
 * @soc_info:                   SOC information
 * @cpas_handle:                CPAS handle
 * @config_count:               Config reg count
 * @csiphy_cpas_cp_reg_mask:    CP reg mask for phy instance
 * @current_data_rate:          Data rate in mbps
 * @csiphy_3phase:              To identify DPHY or CPHY at top level
 * @combo_mode:                 Info regarding combo_mode is enable / disable
 * @ops:                        KMD operations
 * @crm_cb:                     Callback API pointers
 */
struct csiphy_device {
	char                           device_name[CAM_CTX_DEV_NAME_MAX_LENGTH];
@@ -284,17 +288,22 @@ struct csiphy_device {
	uint8_t                        is_divisor_32_comp;
	uint8_t                        num_irq_registers;
	struct cam_subdev              v4l2_dev_str;
	struct cam_csiphy_param csiphy_info;
	struct intf_params bridge_intf;
	struct cam_csiphy_param        csiphy_info[
					CSIPHY_MAX_INSTANCES_PER_PHY];
	uint32_t                       clk_lane;
	uint32_t                       acquire_count;
	uint32_t                       start_dev_count;
	uint32_t is_acquired_dev_combo_mode;
	struct cam_hw_soc_info         soc_info;
	uint32_t                       cpas_handle;
	uint32_t                       config_count;
	uint32_t                       open_cnt;
	uint64_t csiphy_cpas_cp_reg_mask[CSIPHY_MAX_INSTANCES];
	uint64_t                       csiphy_cpas_cp_reg_mask[
					CSIPHY_MAX_INSTANCES_PER_PHY];
	uint64_t                       current_data_rate;
	uint8_t                        session_max_device_support;
	uint8_t                        combo_mode;
	struct cam_req_mgr_kmd_ops     ops;
	struct cam_req_mgr_crm_cb     *crm_cb;
};

#endif /* _CAM_CSIPHY_DEV_H_ */
+11 −11
Original line number Diff line number Diff line
@@ -125,26 +125,25 @@ int32_t cam_csiphy_status_dmp(struct csiphy_device *csiphy_dev)
	return rc;
}

enum cam_vote_level get_clk_vote_default(struct csiphy_device *csiphy_dev)
enum cam_vote_level get_clk_vote_default(struct csiphy_device *csiphy_dev,
	int32_t index)
{
	CAM_DBG(CAM_CSIPHY, "voting for SVS");
	return CAM_SVS_VOTE;
}

enum cam_vote_level get_clk_voting_dynamic(struct csiphy_device *csiphy_dev)
enum cam_vote_level get_clk_voting_dynamic(
	struct csiphy_device *csiphy_dev, int32_t index)
{
	uint32_t cam_vote_level = 0;
	uint32_t last_valid_vote = 0;
	struct cam_hw_soc_info *soc_info;
	uint64_t phy_data_rate = csiphy_dev->csiphy_info.data_rate;
	uint64_t phy_data_rate = csiphy_dev->csiphy_info[index].data_rate;

	soc_info = &csiphy_dev->soc_info;
	phy_data_rate = max(phy_data_rate, csiphy_dev->current_data_rate);

	if (csiphy_dev->is_acquired_dev_combo_mode)
		phy_data_rate = max(phy_data_rate,
			csiphy_dev->csiphy_info.data_rate_combo_sensor);

	if (csiphy_dev->csiphy_info.csiphy_3phase) {
	if (csiphy_dev->csiphy_info[index].csiphy_3phase) {
		if (csiphy_dev->is_divisor_32_comp)
			do_div(phy_data_rate, CSIPHY_DIVISOR_32);
		else
@@ -155,6 +154,7 @@ enum cam_vote_level get_clk_voting_dynamic(struct csiphy_device *csiphy_dev)

	 /* round off to next integer */
	phy_data_rate += 1;
	csiphy_dev->current_data_rate = phy_data_rate;

	for (cam_vote_level = 0;
			cam_vote_level < CAM_MAX_VOTE; cam_vote_level++) {
@@ -176,7 +176,7 @@ enum cam_vote_level get_clk_voting_dynamic(struct csiphy_device *csiphy_dev)
	return last_valid_vote;
}

int32_t cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev)
int32_t cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev, int32_t index)
{
	int32_t rc = 0;
	struct cam_hw_soc_info   *soc_info;
@@ -190,7 +190,7 @@ int32_t cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev)
		return rc;
	}

	vote_level = csiphy_dev->ctrl_reg->getclockvoting(csiphy_dev);
	vote_level = csiphy_dev->ctrl_reg->getclockvoting(csiphy_dev, index);
	rc = cam_soc_util_enable_platform_resource(soc_info, true,
		vote_level, ENABLE_IRQ);
	if (rc < 0) {
@@ -396,7 +396,7 @@ int32_t cam_csiphy_parse_dt_info(struct platform_device *pdev,
		csiphy_dev->ctrl_reg->csiphy_reg = csiphy_v1_2_3;
		csiphy_dev->is_csiphy_3phase_hw = CSI_3PHASE_HW;
		csiphy_dev->is_divisor_32_comp = true;
		csiphy_dev->hw_version = CSIPHY_VERSION_V12;
		csiphy_dev->hw_version = CSIPHY_VERSION_V123;
		csiphy_dev->clk_lane = 0;
		csiphy_dev->ctrl_reg->data_rates_settings_table = NULL;
	} else if (of_device_is_compatible(soc_info->dev->of_node,
+2 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#define CSIPHY_VERSION_V11                        0x11
#define CSIPHY_VERSION_V12                        0x12
#define CSIPHY_VERSION_V121                       0x121
#define CSIPHY_VERSION_V123                       0x123
#define CSIPHY_VERSION_V20                        0x20

/**
@@ -53,7 +54,7 @@ int cam_csiphy_parse_dt_info(struct platform_device *pdev,
 *
 * This API enables SOC related parameters
 */
int cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev);
int cam_csiphy_enable_hw(struct csiphy_device *csiphy_dev, int32_t index);

/**
 * @csiphy_dev: CSIPhy device structure