On Di, 2024-11-05 at 08:49 +0100, Alain Volmat wrote: > The STM32 CSI controller is tightly coupled with the DCMIPP and act as an > input stage to receive data coming from the sensor and transferring > them into the DCMIPP. > > Signed-off-by: Alain Volmat <alain.volmat@xxxxxxxxxxx> > > --- > v2: correct data-lanes handling, using values 1 & 2 > update yaml filename in MAINTAINERS > --- > MAINTAINERS | 8 + > drivers/media/platform/st/stm32/Kconfig | 14 + > drivers/media/platform/st/stm32/Makefile | 1 + > drivers/media/platform/st/stm32/stm32-csi.c | 1144 +++++++++++++++++++++++++++ > 4 files changed, 1167 insertions(+) > [...] > diff --git a/drivers/media/platform/st/stm32/stm32-csi.c b/drivers/media/platform/st/stm32/stm32-csi.c > new file mode 100644 > index 0000000000000000000000000000000000000000..c7f47472c6b3699e94113ce0f38b280a2e45ce15 > --- /dev/null > +++ b/drivers/media/platform/st/stm32/stm32-csi.c > @@ -0,0 +1,1144 @@ [...] > +static int stm32_csi_get_resources(struct stm32_csi_dev *csidev, > + struct platform_device *pdev) > +{ > + int irq, ret; > + > + csidev->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); > + if (IS_ERR(csidev->base)) > + return dev_err_probe(&pdev->dev, PTR_ERR(csidev->base), > + "Failed to ioremap resource\n"); > + > + csidev->pclk = devm_clk_get(&pdev->dev, "pclk"); > + if (IS_ERR(csidev->pclk)) > + return dev_err_probe(&pdev->dev, PTR_ERR(csidev->pclk), > + "Couldn't get pclk\n"); > + > + csidev->txesc = devm_clk_get(&pdev->dev, "txesc"); > + if (IS_ERR(csidev->txesc)) > + return dev_err_probe(&pdev->dev, PTR_ERR(csidev->txesc), > + "Couldn't get txesc\n"); > + > + csidev->csi2phy = devm_clk_get(&pdev->dev, "csi2phy"); > + if (IS_ERR(csidev->csi2phy)) > + return dev_err_probe(&pdev->dev, PTR_ERR(csidev->csi2phy), > + "Couldn't get csi2phy\n"); Consider using devm_clk_bulk_get(). > + csidev->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); > + if (IS_ERR(csidev->rstc)) > + return dev_err_probe(&pdev->dev, PTR_ERR(csidev->rstc), > + "Couldn't get reset control\n"); If this wasn't in a separate function, rstc wouldn't have to be stored on csidev as it's only ever used in stm32_csi_probe(). > + > + csidev->supplies[0].supply = "vdd"; > + csidev->supplies[1].supply = "vdda18"; > + ret = devm_regulator_bulk_get(&pdev->dev, ARRAY_SIZE(csidev->supplies), > + csidev->supplies); > + if (ret) > + return dev_err_probe(&pdev->dev, ret, > + "Failed to request regulator vdd\n"); > + > + irq = platform_get_irq(pdev, 0); > + if (irq < 0) > + return irq; > + > + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, > + stm32_csi_irq_thread, IRQF_ONESHOT, > + dev_name(&pdev->dev), csidev); > + if (ret) > + return dev_err_probe(&pdev->dev, ret, > + "Unable to request irq"); > + > + return 0; > +} regards Philipp