Lines Matching full:csi

47 	struct sun4i_csi *csi = container_of(notifier, struct sun4i_csi,  in sun4i_csi_notify_bound()  local
50 csi->src_subdev = subdev; in sun4i_csi_notify_bound()
51 csi->src_pad = media_entity_get_fwnode_pad(&subdev->entity, in sun4i_csi_notify_bound()
54 if (csi->src_pad < 0) { in sun4i_csi_notify_bound()
55 dev_err(csi->dev, "Couldn't find output pad for subdev %s\n", in sun4i_csi_notify_bound()
57 return csi->src_pad; in sun4i_csi_notify_bound()
60 dev_dbg(csi->dev, "Bound %s pad: %d\n", subdev->name, csi->src_pad); in sun4i_csi_notify_bound()
66 struct sun4i_csi *csi = container_of(notifier, struct sun4i_csi, in sun4i_csi_notify_complete() local
68 struct v4l2_subdev *subdev = &csi->subdev; in sun4i_csi_notify_complete()
69 struct video_device *vdev = &csi->vdev; in sun4i_csi_notify_complete()
72 ret = v4l2_device_register_subdev(&csi->v4l, subdev); in sun4i_csi_notify_complete()
76 ret = sun4i_csi_v4l2_register(csi); in sun4i_csi_notify_complete()
80 ret = media_device_register(&csi->mdev); in sun4i_csi_notify_complete()
92 ret = media_create_pad_link(&csi->src_subdev->entity, csi->src_pad, in sun4i_csi_notify_complete()
99 ret = v4l2_device_register_subdev_nodes(&csi->v4l); in sun4i_csi_notify_complete()
106 media_device_unregister(&csi->mdev); in sun4i_csi_notify_complete()
116 static int sun4i_csi_notifier_init(struct sun4i_csi *csi) in sun4i_csi_notifier_init() argument
124 v4l2_async_notifier_init(&csi->notifier); in sun4i_csi_notifier_init()
126 ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi->dev), 0, 0, in sun4i_csi_notifier_init()
135 csi->bus = vep.bus.parallel; in sun4i_csi_notifier_init()
137 ret = v4l2_async_notifier_add_fwnode_remote_subdev(&csi->notifier, in sun4i_csi_notifier_init()
138 ep, &csi->asd); in sun4i_csi_notifier_init()
142 csi->notifier.ops = &sun4i_csi_notify_ops; in sun4i_csi_notifier_init()
153 struct sun4i_csi *csi; in sun4i_csi_probe() local
158 csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); in sun4i_csi_probe()
159 if (!csi) in sun4i_csi_probe()
161 platform_set_drvdata(pdev, csi); in sun4i_csi_probe()
162 csi->dev = &pdev->dev; in sun4i_csi_probe()
163 subdev = &csi->subdev; in sun4i_csi_probe()
164 vdev = &csi->vdev; in sun4i_csi_probe()
166 csi->traits = of_device_get_match_data(&pdev->dev); in sun4i_csi_probe()
167 if (!csi->traits) in sun4i_csi_probe()
181 if (of_find_property(csi->dev->of_node, "interconnects", NULL)) { in sun4i_csi_probe()
182 ret = of_dma_configure(csi->dev, csi->dev->of_node, true); in sun4i_csi_probe()
191 ret = dma_direct_set_offset(csi->dev, PHYS_OFFSET, 0, SZ_4G); in sun4i_csi_probe()
197 csi->mdev.dev = csi->dev; in sun4i_csi_probe()
198 strscpy(csi->mdev.model, "Allwinner Video Capture Device", in sun4i_csi_probe()
199 sizeof(csi->mdev.model)); in sun4i_csi_probe()
200 csi->mdev.hw_revision = 0; in sun4i_csi_probe()
201 snprintf(csi->mdev.bus_info, sizeof(csi->mdev.bus_info), "platform:%s", in sun4i_csi_probe()
202 dev_name(csi->dev)); in sun4i_csi_probe()
203 media_device_init(&csi->mdev); in sun4i_csi_probe()
204 csi->v4l.mdev = &csi->mdev; in sun4i_csi_probe()
207 csi->regs = devm_ioremap_resource(&pdev->dev, res); in sun4i_csi_probe()
208 if (IS_ERR(csi->regs)) in sun4i_csi_probe()
209 return PTR_ERR(csi->regs); in sun4i_csi_probe()
215 csi->bus_clk = devm_clk_get(&pdev->dev, "bus"); in sun4i_csi_probe()
216 if (IS_ERR(csi->bus_clk)) { in sun4i_csi_probe()
218 return PTR_ERR(csi->bus_clk); in sun4i_csi_probe()
221 if (csi->traits->has_isp) { in sun4i_csi_probe()
222 csi->isp_clk = devm_clk_get(&pdev->dev, "isp"); in sun4i_csi_probe()
223 if (IS_ERR(csi->isp_clk)) { in sun4i_csi_probe()
225 return PTR_ERR(csi->isp_clk); in sun4i_csi_probe()
229 csi->ram_clk = devm_clk_get(&pdev->dev, "ram"); in sun4i_csi_probe()
230 if (IS_ERR(csi->ram_clk)) { in sun4i_csi_probe()
232 return PTR_ERR(csi->ram_clk); in sun4i_csi_probe()
235 csi->rst = devm_reset_control_get(&pdev->dev, NULL); in sun4i_csi_probe()
236 if (IS_ERR(csi->rst)) { in sun4i_csi_probe()
238 return PTR_ERR(csi->rst); in sun4i_csi_probe()
246 snprintf(subdev->name, sizeof(subdev->name), "sun4i-csi-0"); in sun4i_csi_probe()
247 v4l2_set_subdevdata(subdev, csi); in sun4i_csi_probe()
249 csi->subdev_pads[CSI_SUBDEV_SINK].flags = in sun4i_csi_probe()
251 csi->subdev_pads[CSI_SUBDEV_SOURCE].flags = MEDIA_PAD_FL_SOURCE; in sun4i_csi_probe()
253 csi->subdev_pads); in sun4i_csi_probe()
257 csi->vdev_pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; in sun4i_csi_probe()
259 ret = media_entity_pads_init(&vdev->entity, 1, &csi->vdev_pad); in sun4i_csi_probe()
263 ret = sun4i_csi_dma_register(csi, irq); in sun4i_csi_probe()
267 ret = sun4i_csi_notifier_init(csi); in sun4i_csi_probe()
271 ret = v4l2_async_notifier_register(&csi->v4l, &csi->notifier); in sun4i_csi_probe()
273 dev_err(csi->dev, "Couldn't register our notifier.\n"); in sun4i_csi_probe()
282 media_device_unregister(&csi->mdev); in sun4i_csi_probe()
283 sun4i_csi_dma_unregister(csi); in sun4i_csi_probe()
286 media_device_cleanup(&csi->mdev); in sun4i_csi_probe()
293 struct sun4i_csi *csi = platform_get_drvdata(pdev); in sun4i_csi_remove() local
295 v4l2_async_notifier_unregister(&csi->notifier); in sun4i_csi_remove()
296 v4l2_async_notifier_cleanup(&csi->notifier); in sun4i_csi_remove()
297 vb2_video_unregister_device(&csi->vdev); in sun4i_csi_remove()
298 media_device_unregister(&csi->mdev); in sun4i_csi_remove()
299 sun4i_csi_dma_unregister(csi); in sun4i_csi_remove()
300 media_device_cleanup(&csi->mdev); in sun4i_csi_remove()
326 struct sun4i_csi *csi = dev_get_drvdata(dev); in sun4i_csi_runtime_resume() local
328 reset_control_deassert(csi->rst); in sun4i_csi_runtime_resume()
329 clk_prepare_enable(csi->bus_clk); in sun4i_csi_runtime_resume()
330 clk_prepare_enable(csi->ram_clk); in sun4i_csi_runtime_resume()
331 clk_set_rate(csi->isp_clk, 80000000); in sun4i_csi_runtime_resume()
332 clk_prepare_enable(csi->isp_clk); in sun4i_csi_runtime_resume()
334 writel(1, csi->regs + CSI_EN_REG); in sun4i_csi_runtime_resume()
341 struct sun4i_csi *csi = dev_get_drvdata(dev); in sun4i_csi_runtime_suspend() local
343 clk_disable_unprepare(csi->isp_clk); in sun4i_csi_runtime_suspend()
344 clk_disable_unprepare(csi->ram_clk); in sun4i_csi_runtime_suspend()
345 clk_disable_unprepare(csi->bus_clk); in sun4i_csi_runtime_suspend()
347 reset_control_assert(csi->rst); in sun4i_csi_runtime_suspend()
362 .name = "sun4i-csi",