|
@@ -35,9 +35,19 @@
|
|
/* Mask to enable skew calibration registers */
|
|
/* Mask to enable skew calibration registers */
|
|
#define SKEW_CAL_MASK 0x2
|
|
#define SKEW_CAL_MASK 0x2
|
|
|
|
|
|
|
|
+static DEFINE_MUTEX(active_csiphy_cnt_mutex);
|
|
|
|
+
|
|
static int csiphy_dump;
|
|
static int csiphy_dump;
|
|
module_param(csiphy_dump, int, 0644);
|
|
module_param(csiphy_dump, int, 0644);
|
|
|
|
|
|
|
|
+struct g_csiphy_data {
|
|
|
|
+ void __iomem *base_address;
|
|
|
|
+ uint8_t is_3phase;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+static struct g_csiphy_data g_phy_data[MAX_CSIPHY] = {{0, 0}};
|
|
|
|
+static int active_csiphy_hw_cnt;
|
|
|
|
+
|
|
int32_t cam_csiphy_get_instance_offset(
|
|
int32_t cam_csiphy_get_instance_offset(
|
|
struct csiphy_device *csiphy_dev,
|
|
struct csiphy_device *csiphy_dev,
|
|
int32_t dev_handle)
|
|
int32_t dev_handle)
|
|
@@ -109,6 +119,59 @@ void cam_csiphy_reset(struct csiphy_device *csiphy_dev)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void cam_csiphy_prgm_cmn_data(
|
|
|
|
+ struct csiphy_device *csiphy_dev,
|
|
|
|
+ bool reset)
|
|
|
|
+{
|
|
|
|
+ int csiphy_idx = 0;
|
|
|
|
+ uint32_t size = 0;
|
|
|
|
+ int i = 0;
|
|
|
|
+ void __iomem *csiphybase;
|
|
|
|
+ bool is_3phase = false;
|
|
|
|
+ struct csiphy_reg_t *csiphy_common_reg = NULL;
|
|
|
|
+
|
|
|
|
+ size = csiphy_dev->ctrl_reg->csiphy_reg.csiphy_common_array_size;
|
|
|
|
+
|
|
|
|
+ if (active_csiphy_hw_cnt < 0 || active_csiphy_hw_cnt >= MAX_CSIPHY) {
|
|
|
|
+ CAM_WARN(CAM_CSIPHY,
|
|
|
|
+ "MisMatched in active phy hw: %d and Max supported: %d",
|
|
|
|
+ active_csiphy_hw_cnt, MAX_CSIPHY);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (active_csiphy_hw_cnt == 0) {
|
|
|
|
+ CAM_DBG(CAM_CSIPHY, "CSIPHYs HW state needs to be %s",
|
|
|
|
+ reset ? "reset" : "set");
|
|
|
|
+ } else {
|
|
|
|
+ CAM_DBG(CAM_CSIPHY, "Active CSIPHY hws are %d",
|
|
|
|
+ active_csiphy_hw_cnt);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (csiphy_idx = 0; csiphy_idx < MAX_CSIPHY; csiphy_idx++) {
|
|
|
|
+ csiphybase = g_phy_data[csiphy_idx].base_address;
|
|
|
|
+ is_3phase = g_phy_data[csiphy_idx].is_3phase;
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < size; i++) {
|
|
|
|
+ csiphy_common_reg =
|
|
|
|
+ &csiphy_dev->ctrl_reg->csiphy_common_reg[i];
|
|
|
|
+ switch (csiphy_common_reg->csiphy_param_type) {
|
|
|
|
+ case CSIPHY_DEFAULT_PARAMS:
|
|
|
|
+ cam_io_w_mb(reset ? 0x00 :
|
|
|
|
+ csiphy_common_reg->reg_data,
|
|
|
|
+ csiphybase +
|
|
|
|
+ csiphy_common_reg->reg_addr);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if (csiphy_common_reg->delay > 0)
|
|
|
|
+ usleep_range(csiphy_common_reg->delay,
|
|
|
|
+ csiphy_common_reg->delay + 5);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
static int32_t cam_csiphy_update_secure_info(
|
|
static int32_t cam_csiphy_update_secure_info(
|
|
struct csiphy_device *csiphy_dev, int32_t index)
|
|
struct csiphy_device *csiphy_dev, int32_t index)
|
|
{
|
|
{
|
|
@@ -1132,6 +1195,15 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
|
|
goto release_mutex;
|
|
goto release_mutex;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (!csiphy_dev->acquire_count) {
|
|
|
|
+ g_phy_data[csiphy_dev->soc_info.index].is_3phase =
|
|
|
|
+ csiphy_acq_params.csiphy_3phase;
|
|
|
|
+ CAM_DBG(CAM_CSIPHY,
|
|
|
|
+ "g_csiphy data is updated for index: %d is_3phase: %u",
|
|
|
|
+ csiphy_dev->soc_info.index,
|
|
|
|
+ g_phy_data[csiphy_dev->soc_info.index].is_3phase);
|
|
|
|
+ }
|
|
|
|
+
|
|
csiphy_dev->acquire_count++;
|
|
csiphy_dev->acquire_count++;
|
|
CAM_DBG(CAM_CSIPHY, "ACQUIRE_CNT: %d",
|
|
CAM_DBG(CAM_CSIPHY, "ACQUIRE_CNT: %d",
|
|
csiphy_dev->acquire_count);
|
|
csiphy_dev->acquire_count);
|
|
@@ -1209,6 +1281,15 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
|
|
|
|
|
|
csiphy_dev->csiphy_info[offset].csiphy_cpas_cp_reg_mask = 0x0;
|
|
csiphy_dev->csiphy_info[offset].csiphy_cpas_cp_reg_mask = 0x0;
|
|
|
|
|
|
|
|
+ if (csiphy_dev->ctrl_reg->csiphy_reg
|
|
|
|
+ .prgm_cmn_reg_across_csiphy) {
|
|
|
|
+ mutex_lock(&active_csiphy_cnt_mutex);
|
|
|
|
+ active_csiphy_hw_cnt--;
|
|
|
|
+ mutex_unlock(&active_csiphy_cnt_mutex);
|
|
|
|
+
|
|
|
|
+ cam_csiphy_prgm_cmn_data(csiphy_dev, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
rc = cam_csiphy_disable_hw(csiphy_dev);
|
|
rc = cam_csiphy_disable_hw(csiphy_dev);
|
|
if (rc < 0)
|
|
if (rc < 0)
|
|
CAM_ERR(CAM_CSIPHY, "Failed in csiphy release");
|
|
CAM_ERR(CAM_CSIPHY, "Failed in csiphy release");
|
|
@@ -1451,6 +1532,16 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
|
|
goto release_mutex;
|
|
goto release_mutex;
|
|
}
|
|
}
|
|
csiphy_dev->start_dev_count++;
|
|
csiphy_dev->start_dev_count++;
|
|
|
|
+
|
|
|
|
+ if (csiphy_dev->ctrl_reg->csiphy_reg
|
|
|
|
+ .prgm_cmn_reg_across_csiphy) {
|
|
|
|
+ cam_csiphy_prgm_cmn_data(csiphy_dev, false);
|
|
|
|
+
|
|
|
|
+ mutex_lock(&active_csiphy_cnt_mutex);
|
|
|
|
+ active_csiphy_hw_cnt++;
|
|
|
|
+ mutex_unlock(&active_csiphy_cnt_mutex);
|
|
|
|
+ }
|
|
|
|
+
|
|
CAM_DBG(CAM_CSIPHY, "START DEV CNT: %d",
|
|
CAM_DBG(CAM_CSIPHY, "START DEV CNT: %d",
|
|
csiphy_dev->start_dev_count);
|
|
csiphy_dev->start_dev_count);
|
|
csiphy_dev->csiphy_state = CAM_CSIPHY_START;
|
|
csiphy_dev->csiphy_state = CAM_CSIPHY_START;
|
|
@@ -1480,3 +1571,20 @@ release_mutex:
|
|
|
|
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+void cam_csiphy_register_baseaddress(struct csiphy_device *csiphy_dev)
|
|
|
|
+{
|
|
|
|
+ if (!csiphy_dev) {
|
|
|
|
+ CAM_WARN(CAM_CSIPHY, "Data is NULL");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (csiphy_dev->soc_info.index >= MAX_CSIPHY) {
|
|
|
|
+ CAM_ERR(CAM_CSIPHY, "Invalid soc index: %u Max soc index: %u",
|
|
|
|
+ csiphy_dev->soc_info.index, MAX_CSIPHY);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ g_phy_data[csiphy_dev->soc_info.index].base_address =
|
|
|
|
+ csiphy_dev->soc_info.reg_map[0].mem_base;
|
|
|
|
+}
|