12 #include <linux/i2c.h>
16 #include <linux/slab.h>
17 #include <linux/videodev2.h>
18 #include <linux/module.h>
30 #define SH_CSI2_TREF 0x00
31 #define SH_CSI2_SRST 0x04
32 #define SH_CSI2_PHYCNT 0x08
33 #define SH_CSI2_CHKSUM 0x0C
34 #define SH_CSI2_VCDT 0x10
47 struct v4l2_mbus_framefmt *mf)
54 else if (mf->width & 1)
57 switch (pdata->
type) {
95 struct v4l2_mbus_framefmt *mf)
101 if (mf->width > 8188 || mf->width & 1)
131 static int sh_csi2_g_mbus_config(
struct v4l2_subdev *sd,
142 static int sh_csi2_s_mbus_config(
struct v4l2_subdev *sd,
147 struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd);
155 .s_mbus_fmt = sh_csi2_s_fmt,
156 .try_mbus_fmt = sh_csi2_try_fmt,
157 .g_mbus_config = sh_csi2_g_mbus_config,
158 .s_mbus_config = sh_csi2_s_mbus_config,
161 static void sh_csi2_hwinit(
struct sh_csi2 *priv)
173 switch (pdata->
type) {
175 if (priv->
client->lanes == 1)
186 tmp |= (1 << priv->
client->lanes) - 1;
202 static int sh_csi2_client_connect(
struct sh_csi2 *priv)
206 struct v4l2_subdev *client_sd = soc_camera_to_subdev(icd);
219 dev_dbg(dev,
"%s(%p): found #%d\n", __func__, dev, i);
227 switch (pdata->
type) {
229 if (pdata->
clients[i].lanes != 1)
233 switch (pdata->
clients[i].lanes) {
246 common_flags = csi2_flags;
260 pm_runtime_get_sync(dev);
262 sh_csi2_hwinit(priv);
267 static void sh_csi2_client_disconnect(
struct sh_csi2 *priv)
274 pm_runtime_put(v4l2_get_subdevdata(&priv->
subdev));
277 static int sh_csi2_s_power(
struct v4l2_subdev *sd,
int on)
282 return sh_csi2_client_connect(priv);
284 sh_csi2_client_disconnect(priv);
289 .s_power = sh_csi2_s_power,
293 .core = &sh_csi2_subdev_core_ops,
294 .video = &sh_csi2_subdev_video_ops,
310 if (!res || (
int)irq <= 0 || !pdata) {
311 dev_err(&pdev->
dev,
"Not enough CSI2 platform resources.\n");
317 dev_err(&pdev->
dev,
"Only CSI2C supported ATM.\n");
328 dev_err(&pdev->
dev,
"CSI2 register region already claimed\n");
336 dev_err(&pdev->
dev,
"Unable to ioremap CSI2 registers.\n");
341 platform_set_drvdata(pdev, priv);
344 v4l2_set_subdevdata(&priv->
subdev, &pdev->
dev);
349 dev_dbg(&pdev->
dev,
"%s(%p): ret(register_subdev) = %d\n", __func__, priv, ret);
371 struct sh_csi2 *priv = platform_get_drvdata(pdev);
375 pm_runtime_disable(&pdev->
dev);
378 platform_set_drvdata(pdev,
NULL);
386 .probe = sh_csi2_probe,
388 .name =
"sh-mobile-csi2",