Lines Matching +full:strobe +full:- +full:pos
1 // SPDX-License-Identifier: GPL-2.0-only
5 * TI OMAP3 ISP - CSI PHY module
30 regmap_read(phy->isp->syscon, phy->isp->syscon_offset, ®); in csiphy_routing_cfg_3630()
54 /* Select data/clock or data/strobe mode for CCP2 */ in csiphy_routing_cfg_3630()
66 regmap_write(phy->isp->syscon, phy->isp->syscon_offset, reg); in csiphy_routing_cfg_3630()
80 regmap_write(phy->isp->syscon, phy->isp->syscon_offset, 0); in csiphy_routing_cfg_3430()
87 regmap_write(phy->isp->syscon, phy->isp->syscon_offset, csirxfe); in csiphy_routing_cfg_3430()
95 * @ccp2_strobe: false: data/clock, true: data/strobe
99 * and 3630, so they will not hold their contents in off-mode. This isn't an
106 if (phy->isp->phy_type == ISP_PHY_TYPE_3630 && on) in csiphy_routing_cfg()
108 if (phy->isp->phy_type == ISP_PHY_TYPE_3430) in csiphy_routing_cfg()
118 isp_reg_clr_set(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG, in csiphy_power_autoswitch_enable()
127 * Returns 0 if successful, or -EBUSY if the retry count is exceeded.
134 isp_reg_clr_set(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG, in csiphy_set_power()
140 reg = isp_reg_readl(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG) & in csiphy_set_power()
149 dev_err(phy->isp->dev, "CSI2 CIO set power failed!\n"); in csiphy_set_power()
150 return -EBUSY; in csiphy_set_power()
165 struct isp_pipeline *pipe = to_isp_pipeline(phy->entity); in omap3isp_csiphy_config()
173 buscfg = v4l2_subdev_to_bus_cfg(pipe->external); in omap3isp_csiphy_config()
175 return -EPIPE; in omap3isp_csiphy_config()
177 if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1 in omap3isp_csiphy_config()
178 || buscfg->interface == ISP_INTERFACE_CCP2B_PHY2) { in omap3isp_csiphy_config()
179 lanes = &buscfg->bus.ccp2.lanecfg; in omap3isp_csiphy_config()
182 lanes = &buscfg->bus.csi2.lanecfg; in omap3isp_csiphy_config()
183 num_data_lanes = buscfg->bus.csi2.num_data_lanes; in omap3isp_csiphy_config()
186 if (num_data_lanes > phy->num_data_lanes) in omap3isp_csiphy_config()
187 return -EINVAL; in omap3isp_csiphy_config()
191 if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3) in omap3isp_csiphy_config()
192 return -EINVAL; in omap3isp_csiphy_config()
194 if (used_lanes & (1 << lanes->data[i].pos)) in omap3isp_csiphy_config()
195 return -EINVAL; in omap3isp_csiphy_config()
197 used_lanes |= 1 << lanes->data[i].pos; in omap3isp_csiphy_config()
200 if (lanes->clk.pol > 1 || lanes->clk.pos > 3) in omap3isp_csiphy_config()
201 return -EINVAL; in omap3isp_csiphy_config()
203 if (lanes->clk.pos == 0 || used_lanes & (1 << lanes->clk.pos)) in omap3isp_csiphy_config()
204 return -EINVAL; in omap3isp_csiphy_config()
211 csiphy_routing_cfg(phy, buscfg->interface, true, in omap3isp_csiphy_config()
212 buscfg->bus.ccp2.phy_layer); in omap3isp_csiphy_config()
215 /* CSI-2 is DDR and we only count used lanes. */ in omap3isp_csiphy_config()
216 csi2_ddrclk_khz = pipe->external_rate / 1000 in omap3isp_csiphy_config()
217 / (2 * hweight32(used_lanes)) * pipe->external_width; in omap3isp_csiphy_config()
219 reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG0); in omap3isp_csiphy_config()
223 /* THS_TERM: Programmed value = ceil(12.5 ns/DDRClk period) - 1. */ in omap3isp_csiphy_config()
224 reg |= (DIV_ROUND_UP(25 * csi2_ddrclk_khz, 2000000) - 1) in omap3isp_csiphy_config()
230 isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG0); in omap3isp_csiphy_config()
232 reg = isp_reg_readl(phy->isp, phy->phy_regs, ISPCSIPHY_REG1); in omap3isp_csiphy_config()
241 isp_reg_writel(phy->isp, reg, phy->phy_regs, ISPCSIPHY_REG1); in omap3isp_csiphy_config()
244 reg = isp_reg_readl(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG); in omap3isp_csiphy_config()
249 reg |= (lanes->data[i].pol << in omap3isp_csiphy_config()
251 reg |= (lanes->data[i].pos << in omap3isp_csiphy_config()
257 reg |= lanes->clk.pol << ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT; in omap3isp_csiphy_config()
258 reg |= lanes->clk.pos << ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT; in omap3isp_csiphy_config()
260 isp_reg_writel(phy->isp, reg, phy->cfg_regs, ISPCSI2_PHY_CFG); in omap3isp_csiphy_config()
269 if (phy->vdd == NULL) { in omap3isp_csiphy_acquire()
270 dev_err(phy->isp->dev, in omap3isp_csiphy_acquire()
272 return -ENODEV; in omap3isp_csiphy_acquire()
275 mutex_lock(&phy->mutex); in omap3isp_csiphy_acquire()
277 rval = regulator_enable(phy->vdd); in omap3isp_csiphy_acquire()
281 rval = omap3isp_csi2_reset(phy->csi2); in omap3isp_csiphy_acquire()
285 phy->entity = entity; in omap3isp_csiphy_acquire()
291 if (phy->isp->revision == ISP_REVISION_15_0) { in omap3isp_csiphy_acquire()
294 regulator_disable(phy->vdd); in omap3isp_csiphy_acquire()
302 phy->entity = NULL; in omap3isp_csiphy_acquire()
304 mutex_unlock(&phy->mutex); in omap3isp_csiphy_acquire()
310 mutex_lock(&phy->mutex); in omap3isp_csiphy_release()
311 if (phy->entity) { in omap3isp_csiphy_release()
312 struct isp_pipeline *pipe = to_isp_pipeline(phy->entity); in omap3isp_csiphy_release()
315 buscfg = v4l2_subdev_to_bus_cfg(pipe->external); in omap3isp_csiphy_release()
317 mutex_unlock(&phy->mutex); in omap3isp_csiphy_release()
321 csiphy_routing_cfg(phy, buscfg->interface, false, in omap3isp_csiphy_release()
322 buscfg->bus.ccp2.phy_layer); in omap3isp_csiphy_release()
323 if (phy->isp->revision == ISP_REVISION_15_0) { in omap3isp_csiphy_release()
327 regulator_disable(phy->vdd); in omap3isp_csiphy_release()
328 phy->entity = NULL; in omap3isp_csiphy_release()
330 mutex_unlock(&phy->mutex); in omap3isp_csiphy_release()
334 * omap3isp_csiphy_init - Initialize the CSI PHY frontends
338 struct isp_csiphy *phy1 = &isp->isp_csiphy1; in omap3isp_csiphy_init()
339 struct isp_csiphy *phy2 = &isp->isp_csiphy2; in omap3isp_csiphy_init()
341 phy2->isp = isp; in omap3isp_csiphy_init()
342 phy2->csi2 = &isp->isp_csi2a; in omap3isp_csiphy_init()
343 phy2->num_data_lanes = ISP_CSIPHY2_NUM_DATA_LANES; in omap3isp_csiphy_init()
344 phy2->cfg_regs = OMAP3_ISP_IOMEM_CSI2A_REGS1; in omap3isp_csiphy_init()
345 phy2->phy_regs = OMAP3_ISP_IOMEM_CSIPHY2; in omap3isp_csiphy_init()
346 mutex_init(&phy2->mutex); in omap3isp_csiphy_init()
348 phy1->isp = isp; in omap3isp_csiphy_init()
349 mutex_init(&phy1->mutex); in omap3isp_csiphy_init()
351 if (isp->revision == ISP_REVISION_15_0) { in omap3isp_csiphy_init()
352 phy1->csi2 = &isp->isp_csi2c; in omap3isp_csiphy_init()
353 phy1->num_data_lanes = ISP_CSIPHY1_NUM_DATA_LANES; in omap3isp_csiphy_init()
354 phy1->cfg_regs = OMAP3_ISP_IOMEM_CSI2C_REGS1; in omap3isp_csiphy_init()
355 phy1->phy_regs = OMAP3_ISP_IOMEM_CSIPHY1; in omap3isp_csiphy_init()
363 mutex_destroy(&isp->isp_csiphy1.mutex); in omap3isp_csiphy_cleanup()
364 mutex_destroy(&isp->isp_csiphy2.mutex); in omap3isp_csiphy_cleanup()