media: imx7-media-csi: Acquire a single clock
Subsystems (5)
Fabio Estevam
reviewerPATCH 2/8 media: imx7-media-csi: Acquire a single clock
As per the i.MX7D Reference Manual only the MCLK is used for the CSI block, so only handle this single clock.
--- drivers/staging/media/imx/imx7-media-csi.c | 51 ++++------------------ 1 file changed, 8 insertions(+), 43 deletions(-)
drivers/staging/media/imx/imx7-media-csi.c +8 -43
@@ -152,8 +152,6 @@#define CSI_CSICR18 0x48#define CSI_CSICR19 0x4c -static const char *const imx7_csi_clk_id[] = {"axi" ,"dcic" ,"mclk" }; -struct imx7_csi {struct device *dev;struct v4l2_subdev sd;
@@ -180,9 +178,7 @@ struct imx7_csi {void __iomem *regbase;int irq; - -int num_clks; -struct clk_bulk_data *clks; +struct clk *mclk;/* active vb2 buffers to send to video dev sink */ struct imx_media_buffer *active_vb2_buf[2 ];
@@ -204,20 +200,6 @@ struct imx7_csi {#define imx7_csi_reg_write (_csi, _val, _offset) \ __raw_writel(_val, (_csi)->regbase + (_offset)) -static void imx7_csi_clk_enable (struct imx7_csi *csi) -{ -int ret; - - ret =clk_bulk_prepare_enable (csi->num_clks, csi->clks); -if (ret <0 ) -dev_err (csi->dev,"failed to enable clocks\n" ); -} - -static void imx7_csi_clk_disable (struct imx7_csi *csi) -{ -clk_bulk_disable_unprepare (csi->num_clks, csi->clks); -} -static void imx7_csi_hw_reset (struct imx7_csi *csi) { imx7_csi_reg_write(csi,
@@ -413,7 +395,7 @@ static void imx7_csi_init(struct imx7_csi *csi)if (csi->is_init)return ; -imx7_csi_clk_enable (csi); +clk_prepare_enable (csi->mclk);imx7_csi_hw_reset (csi);imx7_csi_init_interface (csi);imx7_csi_dmareq_rff_enable (csi);
@@ -429,7 +411,7 @@ static void imx7_csi_deinit(struct imx7_csi *csi)imx7_csi_hw_reset (csi);imx7_csi_init_interface (csi);imx7_csi_dmareq_rff_disable (csi); -imx7_csi_clk_disable (csi); +clk_disable_unprepare (csi->mclk); csi->is_init = false; }
@@ -1200,24 +1182,6 @@ static int imx7_csi_parse_endpoint(struct device *dev,return fwnode_device_is_available (asd->match.fwnode) ?0 : -EINVAL ; } -static int imx7_csi_clocks_get (struct imx7_csi *csi) -{ -struct device *dev = csi->dev; -int i; - - csi->num_clks =ARRAY_SIZE (imx7_csi_clk_id); - csi->clks =devm_kcalloc (dev, csi->num_clks,sizeof (*csi->clks), -GFP_KERNEL ); - -if (!csi->clks) -return -ENOMEM ; - -for (i =0 ; i < csi->num_clks; i++) - csi->clks[i].id = imx7_csi_clk_id[i]; - -return devm_clk_bulk_get (dev, csi->num_clks, csi->clks); -} -static int imx7_csi_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -1233,10 +1197,11 @@ static int imx7_csi_probe(struct platform_device *pdev) csi->dev = dev; - ret =imx7_csi_clocks_get (csi); -if (ret <0 ) { -dev_err (dev,"Failed to get clocks" ); -return -ENODEV ; + csi->mclk =devm_clk_get (&pdev->dev,"mclk" ); +if (IS_ERR (csi->mclk)) { + ret =PTR_ERR (csi->mclk); +dev_err (dev,"Failed to get mclk: %d" , ret); +return ret; } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 3/8 media: imx7-media-csi: Use devm_platform_ioremap_resource()
Use devm_platform_ioremap_resource() to simplify the code a bit.
While at it, propagate the real error value in case of devm_platform_ioremap_resource() failure.
--- drivers/staging/media/imx/imx7-media-csi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/media/imx/imx7-media-csi.c +3 -5
@@ -1188,7 +1188,6 @@ static int imx7_csi_probe(struct platform_device *pdev)struct device_node *node = dev->of_node;struct imx_media_dev *imxmd;struct imx7_csi *csi; -struct resource *res;int ret; csi =devm_kzalloc (&pdev->dev,sizeof (*csi),GFP_KERNEL );
@@ -1204,17 +1203,16 @@ static int imx7_csi_probe(struct platform_device *pdev)return ret; } - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); csi->irq =platform_get_irq (pdev,0 ); -if (!res || csi->irq <0 ) { +if (csi->irq <0 ) {dev_err (dev,"Missing platform resources data\n" );return -ENODEV ; } - csi->regbase =devm_ioremap_resource (dev, res); + csi->regbase =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (csi->regbase)) {dev_err (dev,"Failed platform resources map\n" ); -return -ENODEV ; +return PTR_ERR (csi->regbase); }spin_lock_init (&csi->irqlock);
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 4/8 media: imx7-media-csi: Propagate the correct error for platform_get_irq()
In reply to Fabio EstevamIn the case of platform_get_irq() failure, let's propagate the real error code instead of a fake one.
--- drivers/staging/media/imx/imx7-media-csi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx7-media-csi.c +1 -1
@@ -1206,7 +1206,7 @@ static int imx7_csi_probe(struct platform_device *pdev) csi->irq =platform_get_irq (pdev,0 );if (csi->irq <0 ) {dev_err (dev,"Missing platform resources data\n" ); -return -ENODEV ; +return csi->irq; } csi->regbase =devm_platform_ioremap_resource (pdev,0 );
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 6/8 media: imx7-media-csi: Remove unneeded break
In reply to Fabio EstevamRemove unneeded 'break' right after the 'return' statement as pointed out by checkpatch.
--- drivers/staging/media/imx/imx7-media-csi.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/media/imx/imx7-media-csi.c +0 -1
@@ -1003,7 +1003,6 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi,break ;default :return -EINVAL ; -break ; }return 0 ; }
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 1/8 media: dt-bindings: imx7-csi: Document a single CSI clock
In reply to Fabio EstevamAs per the i.MX7D Reference Manual only the MCLK is used for the CSI block, so only document this single clock.
--- Documentation/devicetree/bindings/media/imx7-csi.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/media/imx7-csi.txt +3 -6
@@ -14,8 +14,7 @@ Required properties: - interrupts : should contain CSI interrupt; - clocks : list of clock specifiers, see Documentation/devicetree/bindings/clock/clock-bindings.txt for details; -- clock-names : must contain "axi", "mclk" and "dcic" entries, matching - entries in the clock property; +- clock-names : must contain "mclk"; The device node shall contain one 'port' child node with one child 'endpoint' node, according to the bindings defined in:
@@ -32,10 +31,8 @@ example: compatible = "fsl,imx7-csi"; reg = <0x30710000 0x10000>; interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clks IMX7D_CLK_DUMMY>, - <&clks IMX7D_CSI_MCLK_ROOT_CLK>, - <&clks IMX7D_CLK_DUMMY>; - clock-names = "axi", "mclk", "dcic"; + clocks = <&clks IMX7D_CSI_MCLK_ROOT_CLK>; + clock-names = "mclk"; port { csi_from_csi_mux: endpoint {
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 7/8 media: imx7-media-csi: Check the return value from clk_prepare_enable()
In reply to Fabio Estevamclk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of error.
--- drivers/staging/media/imx/imx7-media-csi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/staging/media/imx/imx7-media-csi.c +10 -4
@@ -390,17 +390,23 @@ static void imx7_csi_error_recovery(struct imx7_csi *csi)imx7_csi_hw_enable (csi); } -static void imx7_csi_init (struct imx7_csi *csi) +static int imx7_csi_init (struct imx7_csi *csi) { +int ret; +if (csi->is_init) -return ; +return 0 ; -clk_prepare_enable (csi->mclk); + ret =clk_prepare_enable (csi->mclk); +if (ret <0 ) +return ret;imx7_csi_hw_reset (csi);imx7_csi_init_interface (csi);imx7_csi_dmareq_rff_enable (csi); csi->is_init = true; + +return 0 ; }static void imx7_csi_deinit (struct imx7_csi *csi)
@@ -513,7 +519,7 @@ static int imx7_csi_link_setup(struct media_entity *entity, init:if (csi->sink || csi->src_sd) -imx7_csi_init (csi); + ret =imx7_csi_init (csi);else imx7_csi_deinit (csi);
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 8/8 media: imx7-media-csi: Change imx7_csi_enable() to void
In reply to Fabio Estevamimx7_csi_enable() always return 0 and its return value is never checked, so convert it to void.
--- drivers/staging/media/imx/imx7-media-csi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/media/imx/imx7-media-csi.c +1 -4
@@ -799,7 +799,7 @@ static int imx7_csi_configure(struct imx7_csi *csi)return 0 ; } -static int imx7_csi_enable (struct imx7_csi *csi) +static void imx7_csi_enable (struct imx7_csi *csi) {imx7_csi_sw_reset (csi);
@@ -807,10 +807,7 @@ static int imx7_csi_enable(struct imx7_csi *csi)imx7_csi_dmareq_rff_enable (csi);imx7_csi_hw_enable_irq (csi);imx7_csi_hw_enable (csi); -return 0 ; } - -return 0 ; }static void imx7_csi_disable (struct imx7_csi *csi)
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 5/8 media: imx7-media-csi: Propagate the correct error for devm_request_irq()
In reply to Fabio EstevamIn the case of devm_request_irq() failure, let's propagate the real error code instead of a fake one.
--- drivers/staging/media/imx/imx7-media-csi.c | 1 - 1 file changed, 1 deletion(-)
drivers/staging/media/imx/imx7-media-csi.c +0 -1
@@ -1223,7 +1223,6 @@ static int imx7_csi_probe(struct platform_device *pdev) (void *)csi);if (ret <0 ) {dev_err (dev,"Request CSI IRQ failed.\n" ); - ret = -ENODEV ; goto destroy_mutex; }
Signature · 1 line
2.17.1
Re: [PATCH 1/8] media: dt-bindings: imx7-csi: Document a single CSI clock
In reply to Fabio EstevamOi Fabio,
Quoted 4 lines · Fabio Estevam
As per the i.MX7D Reference Manual only the MCLK is used for the CSI block, so only document this single clock.
Signed-off-by Fabio Estevam <[email protected]>
You missed to add a cover-letter to the series, but I have tested it and reviewed on top of Steve series [0] and everything looks good.
Thanks for fixes.
For the all series:
---
Cheers,
Rui
[0]: https://lore.kernel.org/linux-media/[email protected]/
Quoted 31 lines
--- Documentation/devicetree/bindings/media/imx7-csi.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/media/imx7-csi.txt +3
-6@@ -14,8 +14,7 @@ Required properties: - interrupts : should contain CSI interrupt; - clocks : list of clock specifiers, see Documentation/devicetree/bindings/clock/clock-bindings.txt for details; -- clock-names : must contain "axi", "mclk" and "dcic" entries, matching - entries in the clock property; +- clock-names : must contain "mclk"; The device node shall contain one 'port' child node with one child 'endpoint' node, according to the bindings defined in:@@ -32,10 +31,8 @@ example: compatible = "fsl,imx7-csi"; reg = <0x30710000 0x10000>; interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clks IMX7D_CLK_DUMMY>, - <&clks IMX7D_CSI_MCLK_ROOT_CLK>, - <&clks IMX7D_CLK_DUMMY>; - clock-names = "axi", "mclk", "dcic"; + clocks = <&clks IMX7D_CSI_MCLK_ROOT_CLK>; + clock-names = "mclk"; port { csi_from_csi_mux: endpoint {
Fabio Estevam
reviewerRe: [PATCH 1/8] media: dt-bindings: imx7-csi: Document a single CSI clock
In reply to Fabio EstevamHi Rob,
Quoted 24 lines · Fabio Estevam
As per the i.MX7D Reference Manual only the MCLK is used for the CSI block, so only document this single clock.
Signed-off-by Fabio Estevam <[email protected]>--- Documentation/devicetree/bindings/media/imx7-csi.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/media/imx7-csi.txt +1
-2@@ -14,8 +14,7 @@ Required properties: - interrupts : should contain CSI interrupt; - clocks : list of clock specifiers, see Documentation/devicetree/bindings/clock/clock-bindings.txt for details; -- clock-names : must contain "axi", "mclk" and "dcic" entries, matching - entries in the clock property; +- clock-names : must contain "mclk"; The device node shall contain one 'port' child node with one child 'endpoint' node, according to the bindings defined in:
Documentation/devicetree/bindings/media/imx7-csi.txt example: · line 35
Quoted 9 lines
Documentation/devicetree/bindings/media/imx7-csi.txt +2
-4@@ -32,10 +31,8 @@ example: compatible = "fsl,imx7-csi"; reg = <0x30710000 0x10000>; interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&clks IMX7D_CLK_DUMMY>, - <&clks IMX7D_CSI_MCLK_ROOT_CLK>, - <&clks IMX7D_CLK_DUMMY>; - clock-names = "axi", "mclk", "dcic"; + clocks = <&clks IMX7D_CSI_MCLK_ROOT_CLK>; + clock-names = "mclk";
Any comments, please?
Thanks
Re: [PATCH 1/8] media: dt-bindings: imx7-csi: Document a single CSI clock
In reply to Fabio EstevamQuoted 8 lines · Fabio Estevam
As per the i.MX7D Reference Manual only the MCLK is used for the CSI block, so only document this single clock.
Signed-off-by Fabio Estevam <[email protected]>--- Documentation/devicetree/bindings/media/imx7-csi.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)