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 5A403C4708D for ; Fri, 6 Jan 2023 14:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234766AbjAFOCT (ORCPT ); Fri, 6 Jan 2023 09:02:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235089AbjAFOBy (ORCPT ); Fri, 6 Jan 2023 09:01:54 -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 9A5417BDF8 for ; Fri, 6 Jan 2023 06:01:44 -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 1pDnHy-0002wo-A9; Fri, 06 Jan 2023 15:01:42 +0100 Received: from mtr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pDnHx-0003Um-H1; Fri, 06 Jan 2023 15:01:41 +0100 Date: Fri, 6 Jan 2023 15:01: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 2/8] media: imx-pxp: detect PXP version Message-ID: <20230106140141.GC24101@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-3-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:28:47 +0200, Laurent Pinchart wrote: > On Fri, Jan 06, 2023 at 01:47:32PM +0200, Laurent Pinchart wrote: > > Thank you for the patch. > > > > On Thu, Jan 05, 2023 at 02:47:23PM +0100, Michael Tretter wrote: > > > Different versions of the Pixel Pipeline have different blocks and their > > > routing may be different. Read the PXP_HW_VERSION register to determine > > > the version of the PXP and print it to the log for debugging purposes. > > > > Is there a specific reason you chose to read the version register > > instead of basing the decision on the compatible string ? > > Reading the rest of the series, you use the compatible strings later, > and never use the hw_version field. I'm tempted to propose dropping this > patch. My first try was to use the version register, but it turned out that the version is the same at least on i.MX6ULL and i.MX7D. I kept it to avoid that others fall into the same trap. > > > > Signed-off-by: Michael Tretter > > > --- > > > drivers/media/platform/nxp/imx-pxp.c | 18 ++++++++++++++++++ > > > 1 file changed, 18 insertions(+) > > > > > > diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c > > > index 689ae5e6ac62..05abe40558b0 100644 > > > --- a/drivers/media/platform/nxp/imx-pxp.c > > > +++ b/drivers/media/platform/nxp/imx-pxp.c > > > @@ -10,6 +10,7 @@ > > > * Pawel Osciak, > > > * Marek Szyprowski, > > > */ > > > +#include > > > #include > > > #include > > > #include > > > @@ -52,6 +53,11 @@ MODULE_PARM_DESC(debug, "activates debug info"); > > > #define MEM2MEM_HFLIP (1 << 0) > > > #define MEM2MEM_VFLIP (1 << 1) > > > > > > +#define PXP_VERSION_MAJOR(version) \ > > > + FIELD_GET(BM_PXP_VERSION_MAJOR, version) > > > +#define PXP_VERSION_MINOR(version) \ > > > + FIELD_GET(BM_PXP_VERSION_MINOR, version) > > > + > > > #define dprintk(dev, fmt, arg...) \ > > > v4l2_dbg(1, debug, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg) > > > > > > @@ -192,6 +198,8 @@ struct pxp_dev { > > > struct clk *clk; > > > void __iomem *mmio; > > > > > > + u32 hw_version; > > > + > > > atomic_t num_inst; > > > struct mutex dev_mutex; > > > spinlock_t irqlock; > > > @@ -1660,6 +1668,11 @@ static int pxp_soft_reset(struct pxp_dev *dev) > > > return 0; > > > } > > > > > > +static u32 pxp_read_version(struct pxp_dev *dev) > > > +{ > > > + return readl(dev->mmio + HW_PXP_VERSION); > > > +} > > > + > > > static int pxp_probe(struct platform_device *pdev) > > > { > > > struct pxp_dev *dev; > > > @@ -1705,6 +1718,11 @@ static int pxp_probe(struct platform_device *pdev) > > > goto err_clk; > > > } > > > > > > + dev->hw_version = pxp_read_version(dev); > > > + dev_info(&pdev->dev, "PXP Version %d.%d\n", > > > > As the version can't be negative, I'd use %u.%u. > > > > > + PXP_VERSION_MAJOR(dev->hw_version), > > > + PXP_VERSION_MINOR(dev->hw_version)); > > > + > > > > The driver now prints two messages at probe time, it would be nice to > > combine them, or remove the other one. That's a candidate for a future > > patch though. I would reduce the level to dev_debug. Then the version is not always printed, but it can be easily enabled if necessary for the bringup on another platform. Michael > > > > > ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); > > > if (ret) > > > goto err_clk; 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 A7AA5C3DA7A for ; Fri, 6 Jan 2023 14:03:09 +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=zIzO4N5CRkr6xJ12tgwiByQOu9cr0rJeg2v24rorjHM=; b=Qqs9amIdCc+eFy 2s2sumG3U4LJKUeRiaSA8GYhr9aOgxuufFrpF3MeW7tyq3MJOCFRIixTCp6DR4rmH+WPmJAGX2VAD A/Wq2M4BOhqUHtL3dHk5Q9eWwwsvQho/jn8wMqdhP13apEpd9rD2W6rYqj4LTiPMQHJXxjRFwYRWM msjHcwf9DdlUhbIA/Xm3y2D3DNF2BSAeDuhCFX1SgCpOecz3HT/bxaTiZ1DBs4xQW+rZsfHiEOlJA 39pVihfSdbCcOuzD2t3vktl3xSkbsGEovHLCVEeFpdTw+rtXF6O7KrdvPzwTQkDUbJNmVBtfx5jJy qxqNp105PIxK5sE3QjXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDnIQ-008e1X-Qg; Fri, 06 Jan 2023 14:02:11 +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 1pDnIN-008dtS-1D for linux-arm-kernel@lists.infradead.org; Fri, 06 Jan 2023 14:02:08 +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 1pDnHy-0002wo-A9; Fri, 06 Jan 2023 15:01:42 +0100 Received: from mtr by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pDnHx-0003Um-H1; Fri, 06 Jan 2023 15:01:41 +0100 Date: Fri, 6 Jan 2023 15:01: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 2/8] media: imx-pxp: detect PXP version Message-ID: <20230106140141.GC24101@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-3-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_060207_099533_10DCF9D7 X-CRM114-Status: GOOD ( 38.41 ) 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:28:47 +0200, Laurent Pinchart wrote: > On Fri, Jan 06, 2023 at 01:47:32PM +0200, Laurent Pinchart wrote: > > Thank you for the patch. > > > > On Thu, Jan 05, 2023 at 02:47:23PM +0100, Michael Tretter wrote: > > > Different versions of the Pixel Pipeline have different blocks and their > > > routing may be different. Read the PXP_HW_VERSION register to determine > > > the version of the PXP and print it to the log for debugging purposes. > > > > Is there a specific reason you chose to read the version register > > instead of basing the decision on the compatible string ? > > Reading the rest of the series, you use the compatible strings later, > and never use the hw_version field. I'm tempted to propose dropping this > patch. My first try was to use the version register, but it turned out that the version is the same at least on i.MX6ULL and i.MX7D. I kept it to avoid that others fall into the same trap. > > > > Signed-off-by: Michael Tretter > > > --- > > > drivers/media/platform/nxp/imx-pxp.c | 18 ++++++++++++++++++ > > > 1 file changed, 18 insertions(+) > > > > > > diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c > > > index 689ae5e6ac62..05abe40558b0 100644 > > > --- a/drivers/media/platform/nxp/imx-pxp.c > > > +++ b/drivers/media/platform/nxp/imx-pxp.c > > > @@ -10,6 +10,7 @@ > > > * Pawel Osciak, > > > * Marek Szyprowski, > > > */ > > > +#include > > > #include > > > #include > > > #include > > > @@ -52,6 +53,11 @@ MODULE_PARM_DESC(debug, "activates debug info"); > > > #define MEM2MEM_HFLIP (1 << 0) > > > #define MEM2MEM_VFLIP (1 << 1) > > > > > > +#define PXP_VERSION_MAJOR(version) \ > > > + FIELD_GET(BM_PXP_VERSION_MAJOR, version) > > > +#define PXP_VERSION_MINOR(version) \ > > > + FIELD_GET(BM_PXP_VERSION_MINOR, version) > > > + > > > #define dprintk(dev, fmt, arg...) \ > > > v4l2_dbg(1, debug, &dev->v4l2_dev, "%s: " fmt, __func__, ## arg) > > > > > > @@ -192,6 +198,8 @@ struct pxp_dev { > > > struct clk *clk; > > > void __iomem *mmio; > > > > > > + u32 hw_version; > > > + > > > atomic_t num_inst; > > > struct mutex dev_mutex; > > > spinlock_t irqlock; > > > @@ -1660,6 +1668,11 @@ static int pxp_soft_reset(struct pxp_dev *dev) > > > return 0; > > > } > > > > > > +static u32 pxp_read_version(struct pxp_dev *dev) > > > +{ > > > + return readl(dev->mmio + HW_PXP_VERSION); > > > +} > > > + > > > static int pxp_probe(struct platform_device *pdev) > > > { > > > struct pxp_dev *dev; > > > @@ -1705,6 +1718,11 @@ static int pxp_probe(struct platform_device *pdev) > > > goto err_clk; > > > } > > > > > > + dev->hw_version = pxp_read_version(dev); > > > + dev_info(&pdev->dev, "PXP Version %d.%d\n", > > > > As the version can't be negative, I'd use %u.%u. > > > > > + PXP_VERSION_MAJOR(dev->hw_version), > > > + PXP_VERSION_MINOR(dev->hw_version)); > > > + > > > > The driver now prints two messages at probe time, it would be nice to > > combine them, or remove the other one. That's a candidate for a future > > patch though. I would reduce the level to dev_debug. Then the version is not always printed, but it can be easily enabled if necessary for the bringup on another platform. Michael > > > > > ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); > > > if (ret) > > > goto err_clk; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel