Lines Matching +full:mmp2 +full:- +full:ccic
1 // SPDX-License-Identifier: GPL-2.0-only
17 #include <media/v4l2-device.h>
18 #include <linux/platform_data/media/mmp-camera.h>
29 #include "mcam-core.h"
31 MODULE_ALIAS("platform:mmp-camera");
54 * dphy[0] - CSI2_DPHY3
55 * dphy[1] - CSI2_DPHY5
56 * dphy[2] - CSI2_DPHY6
63 struct mmp_camera_platform_data *pdata = cam->pdev->dev.platform_data; in mmpcam_calc_dphy()
64 struct device *dev = &cam->pdev->dev; in mmpcam_calc_dphy()
69 * pdata->lane_clk should be already set in mmpcam_calc_dphy()
74 * dphy[0] - CSI2_DPHY3: in mmpcam_calc_dphy()
82 * (Max T(D_TERM_EN)/Period(DDR)) - 1 in mmpcam_calc_dphy()
91 * MIPI Alliance Spectification for D-PHY in mmpcam_calc_dphy()
92 * document for explanation of HS-SETTLE in mmpcam_calc_dphy()
93 * and D-TERM-EN. in mmpcam_calc_dphy()
95 switch (pdata->dphy3_algo) { in mmpcam_calc_dphy()
100 pdata->dphy[0] = in mmpcam_calc_dphy()
101 (((1 + (pdata->lane_clk * 80) / 1000) & 0xff) << 8) in mmpcam_calc_dphy()
102 | (1 + pdata->lane_clk * 35 / 1000); in mmpcam_calc_dphy()
108 pdata->dphy[0] = in mmpcam_calc_dphy()
109 (((2 + (pdata->lane_clk * 110) / 1000) & 0xff) << 8) in mmpcam_calc_dphy()
110 | (1 + pdata->lane_clk * 35 / 1000); in mmpcam_calc_dphy()
122 if (IS_ERR(cam->mipi_clk)) in mmpcam_calc_dphy()
126 clk_prepare_enable(cam->mipi_clk); in mmpcam_calc_dphy()
127 tx_clk_esc = (clk_get_rate(cam->mipi_clk) / 1000000) / 12; in mmpcam_calc_dphy()
128 clk_disable_unprepare(cam->mipi_clk); in mmpcam_calc_dphy()
130 * dphy[2] - CSI2_DPHY6: in mmpcam_calc_dphy()
140 pdata->dphy[2] = in mmpcam_calc_dphy()
141 ((((534 * tx_clk_esc) / 2000 - 1) & 0xff) << 8) in mmpcam_calc_dphy()
142 | (((38 * tx_clk_esc) / 1000 - 1) & 0xff); in mmpcam_calc_dphy()
145 pdata->dphy[0], pdata->dphy[1], pdata->dphy[2]); in mmpcam_calc_dphy()
153 spin_lock(&mcam->dev_lock); in mmpcam_irq()
156 spin_unlock(&mcam->dev_lock); in mmpcam_irq()
169 mcam->clk[i] = devm_clk_get(mcam->dev, mcam_clks[i]); in mcam_init_clk()
170 if (IS_ERR(mcam->clk[i])) in mcam_init_clk()
171 dev_warn(mcam->dev, "Could not get clk: %s\n", in mcam_init_clk()
187 cam = devm_kzalloc(&pdev->dev, sizeof(*cam), GFP_KERNEL); in mmpcam_probe()
189 return -ENOMEM; in mmpcam_probe()
191 cam->pdev = pdev; in mmpcam_probe()
192 INIT_LIST_HEAD(&cam->devlist); in mmpcam_probe()
194 mcam = &cam->mcam; in mmpcam_probe()
195 mcam->calc_dphy = mmpcam_calc_dphy; in mmpcam_probe()
196 mcam->dev = &pdev->dev; in mmpcam_probe()
197 pdata = pdev->dev.platform_data; in mmpcam_probe()
199 mcam->mclk_src = pdata->mclk_src; in mmpcam_probe()
200 mcam->mclk_div = pdata->mclk_div; in mmpcam_probe()
201 mcam->bus_type = pdata->bus_type; in mmpcam_probe()
202 mcam->dphy = pdata->dphy; in mmpcam_probe()
203 mcam->lane = pdata->lane; in mmpcam_probe()
206 * These are values that used to be hardcoded in mcam-core and in mmpcam_probe()
211 mcam->mclk_src = 3; in mmpcam_probe()
212 mcam->mclk_div = 2; in mmpcam_probe()
214 if (mcam->bus_type == V4L2_MBUS_CSI2_DPHY) { in mmpcam_probe()
215 cam->mipi_clk = devm_clk_get(mcam->dev, "mipi"); in mmpcam_probe()
216 if ((IS_ERR(cam->mipi_clk) && mcam->dphy[2] == 0)) in mmpcam_probe()
217 return PTR_ERR(cam->mipi_clk); in mmpcam_probe()
219 mcam->mipi_enabled = false; in mmpcam_probe()
220 mcam->chip_id = MCAM_ARMADA610; in mmpcam_probe()
221 mcam->buffer_mode = B_DMA_sg; in mmpcam_probe()
222 strscpy(mcam->bus_info, "platform:mmp-camera", sizeof(mcam->bus_info)); in mmpcam_probe()
223 spin_lock_init(&mcam->dev_lock); in mmpcam_probe()
227 mcam->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in mmpcam_probe()
228 if (IS_ERR(mcam->regs)) in mmpcam_probe()
229 return PTR_ERR(mcam->regs); in mmpcam_probe()
230 mcam->regs_size = resource_size(res); in mmpcam_probe()
237 ep = fwnode_graph_get_next_endpoint(of_fwnode_handle(pdev->dev.of_node), in mmpcam_probe()
240 return -ENODEV; in mmpcam_probe()
242 v4l2_async_nf_init(&mcam->notifier, &mcam->v4l2_dev); in mmpcam_probe()
244 asd = v4l2_async_nf_add_fwnode_remote(&mcam->notifier, ep, in mmpcam_probe()
262 ret = of_clk_add_provider(pdev->dev.of_node, of_clk_src_simple_get, in mmpcam_probe()
263 mcam->mclk); in mmpcam_probe()
265 dev_err(&pdev->dev, "can't add DT clock provider\n"); in mmpcam_probe()
276 cam->irq = ret; in mmpcam_probe()
277 ret = devm_request_irq(&pdev->dev, cam->irq, mmpcam_irq, IRQF_SHARED, in mmpcam_probe()
278 "mmp-camera", mcam); in mmpcam_probe()
282 pm_runtime_enable(&pdev->dev); in mmpcam_probe()
293 struct mcam_camera *mcam = &cam->mcam; in mmpcam_remove()
296 pm_runtime_force_suspend(mcam->dev); in mmpcam_remove()
306 struct mcam_camera *mcam = &cam->mcam; in mmpcam_runtime_resume()
310 if (!IS_ERR(mcam->clk[i])) in mmpcam_runtime_resume()
311 clk_prepare_enable(mcam->clk[i]); in mmpcam_runtime_resume()
320 struct mcam_camera *mcam = &cam->mcam; in mmpcam_runtime_suspend()
323 for (i = NR_MCAM_CLK - 1; i >= 0; i--) { in mmpcam_runtime_suspend()
324 if (!IS_ERR(mcam->clk[i])) in mmpcam_runtime_suspend()
325 clk_disable_unprepare(mcam->clk[i]); in mmpcam_runtime_suspend()
336 mccic_suspend(&cam->mcam); in mmpcam_suspend()
345 return mccic_resume(&cam->mcam); in mmpcam_resume()
355 { .compatible = "marvell,mmp2-ccic", },
364 .name = "mmp-camera",