[PATCH v7 2/3] media: synopsys: add driver for the designware mipi csi-2 receiver

Frank Li Frank.li at nxp.com
Mon Jan 19 11:48:20 PST 2026


On Mon, Jan 19, 2026 at 11:43:36AM +0100, Michael Riesch via B4 Relay wrote:
> From: Michael Riesch <michael.riesch at collabora.com>
>
> The Synopsys DesignWare MIPI CSI-2 Receiver is a CSI-2 bridge with
> one input port and one output port. It receives the data with the
> help of an external MIPI PHY (C-PHY or D-PHY) and passes it to e.g.,
> the Rockchip Video Capture (VICAP) block on recent Rockchip SoCs.
>
> Add a V4L2 subdevice driver for this unit.
>
> Signed-off-by: Michael Riesch <michael.riesch at wolfvision.net>
> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue at linaro.org>
> Reviewed-by: Mehdi Djait <mehdi.djait at linux.intel.com>
> Signed-off-by: Michael Riesch <michael.riesch at collabora.com>
> ---
...
> +
> +static int dw_mipi_csi2rx_register_notifier(struct dw_mipi_csi2rx_device *csi2)
> +{
> +	struct fwnode_handle *ep __free(fwnode_handle) = NULL;
> +	struct v4l2_async_notifier *ntf = &csi2->notifier;
> +	struct v4l2_async_connection *asd;
> +	struct v4l2_fwnode_endpoint vep;
> +	struct v4l2_subdev *sd = &csi2->sd;
> +	struct device *dev = csi2->dev;
> +	int ret;
> +
> +	ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), 0, 0, 0);

cleanup.h prefer set value at declear.
	struct fwnode_handle *ep __free(fwnode_handle) =
		fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), 0, 0, 0);

Krzysztof Kozlowski did many work to cleanup pattern '__free(*) = NULL',
ref https://lore.kernel.org/all/20251208020844.5310-4-krzysztof.kozlowski@oss.qualcomm.com/

> +	if (!ep)
> +		return dev_err_probe(dev, -ENODEV, "failed to get endpoint\n");
> +
> +	vep.bus_type = V4L2_MBUS_UNKNOWN;
> +	ret = v4l2_fwnode_endpoint_parse(ep, &vep);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "failed to parse endpoint\n");
> +
...
> +
> +static int dw_mipi_csi2rx_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct dw_mipi_csi2rx_device *csi2;
> +	int ret;
> +
> +	csi2 = devm_kzalloc(dev, sizeof(*csi2), GFP_KERNEL);
> +	if (!csi2)
> +		return -ENOMEM;
> +	csi2->dev = dev;
> +	dev_set_drvdata(dev, csi2);
> +
> +	csi2->base_addr = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(csi2->base_addr))
> +		return PTR_ERR(csi2->base_addr);
> +
> +	ret = devm_clk_bulk_get_all(dev, &csi2->clks);
> +	if (ret != DW_MIPI_CSI2RX_CLKS_MAX)
> +		return dev_err_probe(dev, -ENODEV, "failed to get clocks\n");
> +	csi2->clks_num = ret;
> +
> +	csi2->phy = devm_phy_get(dev, NULL);
> +	if (IS_ERR(csi2->phy))
> +		return dev_err_probe(dev, PTR_ERR(csi2->phy),
> +				     "failed to get MIPI CSI-2 PHY\n");
> +
> +	csi2->reset = devm_reset_control_get_exclusive(dev, NULL);
> +	if (IS_ERR(csi2->reset))
> +		return dev_err_probe(dev, PTR_ERR(csi2->reset),
> +				     "failed to get reset\n");
> +
> +	csi2->formats = formats;
> +	csi2->formats_num = ARRAY_SIZE(formats);
> +
> +	devm_pm_runtime_enable(dev);

Need check return value

> +
> +	ret = phy_init(csi2->phy);
> +	if (ret)
> +		return dev_err_probe(dev, ret,
> +				     "failed to initialize MIPI CSI-2 PHY\n");
> +
> +	ret = dw_mipi_csi2rx_register(csi2);
> +	if (ret)
> +		goto err_phy_exit;
> +
> +	return 0;
> +
> +err_phy_exit:
> +	phy_exit(csi2->phy);
> +
> +	return ret;
> +}
> +
...
> +
> +static DEFINE_RUNTIME_DEV_PM_OPS(dw_mipi_csi2rx_pm_ops,
> +				 dw_mipi_csi2rx_runtime_suspend,
> +				 dw_mipi_csi2rx_runtime_resume, NULL);
> +
> +static struct platform_driver dw_mipi_csi2rx_drv = {
> +	.driver = {
> +		.name = "dw-mipi-csi2rx",
> +		.of_match_table = dw_mipi_csi2rx_of_match,
> +		.pm = &dw_mipi_csi2rx_pm_ops,

still prefer add pm_ptr() to avoid some static scan tool report problem,
or some contributor send out small patches, which just add pm_ptr()

Frank

> +	},
> +	.probe = dw_mipi_csi2rx_probe,
> +	.remove = dw_mipi_csi2rx_remove,
> +};
> +module_platform_driver(dw_mipi_csi2rx_drv);
> +
> +MODULE_DESCRIPTION("Synopsys DesignWare MIPI CSI-2 Receiver platform driver");
> +MODULE_LICENSE("GPL");
>
> --
> 2.39.5
>
>



More information about the Linux-rockchip mailing list