From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F4EAC5479D for ; Fri, 6 Jan 2023 14:11:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234786AbjAFOLq (ORCPT ); Fri, 6 Jan 2023 09:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233923AbjAFOLo (ORCPT ); Fri, 6 Jan 2023 09:11:44 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7C877D36 for ; Fri, 6 Jan 2023 06:11:43 -0800 (PST) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDnRd-0004Qm-I6; Fri, 06 Jan 2023 15:11:41 +0100 Received: from mtr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pDnRd-0004ck-5w; Fri, 06 Jan 2023 15:11:41 +0100 Date: Fri, 6 Jan 2023 15:11:41 +0100 From: Michael Tretter To: Laurent Pinchart Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 6/8] media: imx-pxp: make data_path_ctrl0 platform dependent Message-ID: <20230106141141.GE24101@pengutronix.de> Mail-Followup-To: Michael Tretter , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org References: <20230105134729.59542-1-m.tretter@pengutronix.de> <20230105134729.59542-7-m.tretter@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: devicetree@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Fri, 06 Jan 2023 14:30:52 +0200, Laurent Pinchart wrote: > On Thu, Jan 05, 2023 at 02:47:27PM +0100, Michael Tretter wrote: > > Unfortunately, the PXP_HW_VERSION register reports the PXP on the i.MX7D > > and on the i.MX6ULL as version 3.0, although the PXP versions on these > > SoCs have significant differences. > > > > Use the compatible to configure the ctrl0 register as required dependent > > on the platform. > > > > Signed-off-by: Michael Tretter > > --- > > drivers/media/platform/nxp/imx-pxp.c | 27 +++++++++++++++++++++++++-- > > 1 file changed, 25 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c > > index 1d649b9cadad..4e182f80a36b 100644 > > --- a/drivers/media/platform/nxp/imx-pxp.c > > +++ b/drivers/media/platform/nxp/imx-pxp.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -191,6 +192,11 @@ static struct pxp_fmt *find_format(struct v4l2_format *f) > > return &formats[k]; > > } > > > > +struct pxp_ctx; > > Please add a blank line here. > > > +struct pxp_pdata { > > + u32 (*data_path_ctrl0)(struct pxp_ctx *ctx); > > +}; > > + > > struct pxp_dev { > > struct v4l2_device v4l2_dev; > > struct video_device vfd; > > @@ -199,6 +205,7 @@ struct pxp_dev { > > void __iomem *mmio; > > > > u32 hw_version; > > + const struct pxp_pdata *pdata; > > > > atomic_t num_inst; > > struct mutex dev_mutex; > > @@ -726,7 +733,7 @@ static void pxp_setup_csc(struct pxp_ctx *ctx) > > } > > } > > > > -static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > +static u32 pxp_imx6ull_data_path_ctrl0(struct pxp_ctx *ctx) > > { > > u32 ctrl0; > > > > @@ -756,6 +763,16 @@ static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > return ctrl0; > > } > > > > +static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > +{ > > + struct pxp_dev *dev = ctx->dev; > > + > > + if (dev->pdata && dev->pdata->data_path_ctrl0) > > + return dev->pdata->data_path_ctrl0(ctx); > > + > > + return pxp_imx6ull_data_path_ctrl0(ctx); > > Do you need this fallback, given that all compatible strings give you > valid pdata ? I'd rather be explicit. > > This function then becomes so small that I would inline it in the > caller. I was a bit paranoid that there may be cases in which pdata is not set. I will change this to assume that pdata is always valid and just be explicit. Michael > > > +} > > + > > static void pxp_set_data_path(struct pxp_ctx *ctx) > > { > > struct pxp_dev *dev = ctx->dev; > > @@ -1711,6 +1728,8 @@ static int pxp_probe(struct platform_device *pdev) > > if (!dev) > > return -ENOMEM; > > > > + dev->pdata = of_device_get_match_data(&pdev->dev); > > + > > dev->clk = devm_clk_get(&pdev->dev, "axi"); > > if (IS_ERR(dev->clk)) { > > ret = PTR_ERR(dev->clk); > > @@ -1811,8 +1830,12 @@ static int pxp_remove(struct platform_device *pdev) > > return 0; > > } > > > > +static const struct pxp_pdata pxp_imx6ull_pdata = { > > + .data_path_ctrl0 = pxp_imx6ull_data_path_ctrl0, > > +}; > > + > > static const struct of_device_id pxp_dt_ids[] = { > > - { .compatible = "fsl,imx6ull-pxp", .data = NULL }, > > + { .compatible = "fsl,imx6ull-pxp", .data = &pxp_imx6ull_pdata }, > > { }, > > }; > > MODULE_DEVICE_TABLE(of, pxp_dt_ids); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 692ABC3DA7A for ; Fri, 6 Jan 2023 14:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pGcm8bx0R/ItZsSkwHc02RKdqCTxntk2BKgF9AAm7dM=; b=Rg6EYwqLiZAzfv cbX94bA062pXPdTA6kzhRc2cM2avdVrgOay5b2o8BYDoBS47XVzBqwHsPAKMZs4S4ZF00JTg8C2SX T70W/S5b4DTNsHOh+uTibOzy5UOrrhA8Q0FwNnDKSMEZUuHJlt4cBV963Ynxm4540wIbd5svxl5dY hhn6qTZ1+MDxL8hle3iKbxNL6RGakO/76rwrEqr8CqwO4hX0xPANH8BaFX3EApLsDuqRJadcetYAe aITjWDj40sWJL+R5HZV7xbMAPfmpw6+ZH7zrijIVszfV2o4JKCfm6LZqAA18iZ9MPWXbx+8UKsQv1 5lDOhdZuu4IxsqJsVYdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDnRr-008iKX-9O; Fri, 06 Jan 2023 14:11:55 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDnRn-008iJ9-FV for linux-arm-kernel@lists.infradead.org; Fri, 06 Jan 2023 14:11:52 +0000 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pDnRd-0004Qm-I6; Fri, 06 Jan 2023 15:11:41 +0100 Received: from mtr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pDnRd-0004ck-5w; Fri, 06 Jan 2023 15:11:41 +0100 Date: Fri, 6 Jan 2023 15:11:41 +0100 From: Michael Tretter To: Laurent Pinchart Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 6/8] media: imx-pxp: make data_path_ctrl0 platform dependent Message-ID: <20230106141141.GE24101@pengutronix.de> Mail-Followup-To: Michael Tretter , Laurent Pinchart , linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org References: <20230105134729.59542-1-m.tretter@pengutronix.de> <20230105134729.59542-7-m.tretter@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: mtr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230106_061151_539464_670A792F X-CRM114-Status: GOOD ( 30.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 06 Jan 2023 14:30:52 +0200, Laurent Pinchart wrote: > On Thu, Jan 05, 2023 at 02:47:27PM +0100, Michael Tretter wrote: > > Unfortunately, the PXP_HW_VERSION register reports the PXP on the i.MX7D > > and on the i.MX6ULL as version 3.0, although the PXP versions on these > > SoCs have significant differences. > > > > Use the compatible to configure the ctrl0 register as required dependent > > on the platform. > > > > Signed-off-by: Michael Tretter > > --- > > drivers/media/platform/nxp/imx-pxp.c | 27 +++++++++++++++++++++++++-- > > 1 file changed, 25 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c > > index 1d649b9cadad..4e182f80a36b 100644 > > --- a/drivers/media/platform/nxp/imx-pxp.c > > +++ b/drivers/media/platform/nxp/imx-pxp.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > > > @@ -191,6 +192,11 @@ static struct pxp_fmt *find_format(struct v4l2_format *f) > > return &formats[k]; > > } > > > > +struct pxp_ctx; > > Please add a blank line here. > > > +struct pxp_pdata { > > + u32 (*data_path_ctrl0)(struct pxp_ctx *ctx); > > +}; > > + > > struct pxp_dev { > > struct v4l2_device v4l2_dev; > > struct video_device vfd; > > @@ -199,6 +205,7 @@ struct pxp_dev { > > void __iomem *mmio; > > > > u32 hw_version; > > + const struct pxp_pdata *pdata; > > > > atomic_t num_inst; > > struct mutex dev_mutex; > > @@ -726,7 +733,7 @@ static void pxp_setup_csc(struct pxp_ctx *ctx) > > } > > } > > > > -static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > +static u32 pxp_imx6ull_data_path_ctrl0(struct pxp_ctx *ctx) > > { > > u32 ctrl0; > > > > @@ -756,6 +763,16 @@ static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > return ctrl0; > > } > > > > +static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > +{ > > + struct pxp_dev *dev = ctx->dev; > > + > > + if (dev->pdata && dev->pdata->data_path_ctrl0) > > + return dev->pdata->data_path_ctrl0(ctx); > > + > > + return pxp_imx6ull_data_path_ctrl0(ctx); > > Do you need this fallback, given that all compatible strings give you > valid pdata ? I'd rather be explicit. > > This function then becomes so small that I would inline it in the > caller. I was a bit paranoid that there may be cases in which pdata is not set. I will change this to assume that pdata is always valid and just be explicit. Michael > > > +} > > + > > static void pxp_set_data_path(struct pxp_ctx *ctx) > > { > > struct pxp_dev *dev = ctx->dev; > > @@ -1711,6 +1728,8 @@ static int pxp_probe(struct platform_device *pdev) > > if (!dev) > > return -ENOMEM; > > > > + dev->pdata = of_device_get_match_data(&pdev->dev); > > + > > dev->clk = devm_clk_get(&pdev->dev, "axi"); > > if (IS_ERR(dev->clk)) { > > ret = PTR_ERR(dev->clk); > > @@ -1811,8 +1830,12 @@ static int pxp_remove(struct platform_device *pdev) > > return 0; > > } > > > > +static const struct pxp_pdata pxp_imx6ull_pdata = { > > + .data_path_ctrl0 = pxp_imx6ull_data_path_ctrl0, > > +}; > > + > > static const struct of_device_id pxp_dt_ids[] = { > > - { .compatible = "fsl,imx6ull-pxp", .data = NULL }, > > + { .compatible = "fsl,imx6ull-pxp", .data = &pxp_imx6ull_pdata }, > > { }, > > }; > > MODULE_DEVICE_TABLE(of, pxp_dt_ids); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel