From patchwork Fri Jan 13 09:54:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 13100414 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 3C262C54EBE for ; Fri, 13 Jan 2023 09:57:57 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ucjhHAwEqevyvMEvmhPIR3JUhaUGWhNkan/L2Luy9t4=; b=aYnkQdtfrFM/t3 e9mGniQNDWVVycoimHX5WyD6RqS2m3YHm0naabOJEttBNRc83RMC26X0x/5SM/Y9KIgmhm+E9/U3I 3YTD+srormVd4qi0TKvv7g5MrDqSbFkRAXmu267peO/jJfE7fjVzIeJjRmPFCxXu7PrBaR7UO+Ywz pPO998/qZYxJuyiDSk/iSTDvZZ6LJee5PqrSDVFQq3PEwpQ3HVysqtb7aW1wEQBNXVDZLRodwKmKn /CzBVoFwJnXvXpBeazM5Q9YLcWoaXoRTKnpStmk41XB7T9/eyz7Es3xxeEAMBynBzB+Fs08muBq/V pzPK+Cjf0VLERMXhOS1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGGnq-001b2g-6R; Fri, 13 Jan 2023 09:56:50 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGGla-001Zxr-C6 for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Jan 2023 09:54:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=WGGy0yYyllhEk1GJ790BUB5V9Q5qgw2bIDutQ9YCmbQ=; b=qauY/oOaBfP5quY7KFHzs9RRL6 0IB/x4Bc+aEeVrCi8nvIzZt7GMW+B7SSuQtfrfaxdbglx/Uko2IpBFW5BAO5vWp9aaNbBUhmqkDOo q4eGqOR7AvogUqnhYN7kucL7u6hX2lEQiUdPr5YHIZY7K5bHMNIFJ5Ymr3y9fiDOjrCbjg29X/GvS IGCm9Qgz1EFGAzYynWqhOuf1wtKPHkPzkTmpBA/9Pi/v73pY492TBZFIDhTi3IaXFdsbVyEidKRJ6 rOAh0RmMdIbCgp1G8rGX8yDKkepDv+Ohn2ovAVDFjLXzYgXWhzjVFnMK0V+a01onpSWM5JNrkUv7m bOponU2A==; Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pGGlN-004JW2-1L for linux-arm-kernel@lists.infradead.org; Fri, 13 Jan 2023 09:54:20 +0000 Received: from dude05.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::54]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1pGGlO-0003cp-Ji; Fri, 13 Jan 2023 10:54:18 +0100 From: Michael Tretter Date: Fri, 13 Jan 2023 10:54:22 +0100 Subject: [PATCH v2 16/16] media: imx-pxp: convert to regmap MIME-Version: 1.0 Message-Id: <20230112-imx-pxp-v2-16-e2281da1db55@pengutronix.de> References: <20230112-imx-pxp-v2-0-e2281da1db55@pengutronix.de> In-Reply-To: <20230112-imx-pxp-v2-0-e2281da1db55@pengutronix.de> To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Laurent Pinchart Cc: Michael Tretter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , Alexander Stein , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.11.2 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::54 X-SA-Exim-Mail-From: m.tretter@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-20230113_095417_561095_1F5FF3F3 X-CRM114-Status: GOOD ( 16.33 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace the readl and writel with regmap to ease debugging the registers from userspace. Suggested-by: Alexander Stein Signed-off-by: Michael Tretter Reviewed-by: Philipp Zabel --- Changelog v2: - new patch --- drivers/media/platform/nxp/imx-pxp.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c index b8a7e49cbc08..f2e9608a7d2d 100644 --- a/drivers/media/platform/nxp/imx-pxp.c +++ b/drivers/media/platform/nxp/imx-pxp.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -176,6 +177,13 @@ enum { V4L2_M2M_DST = 1, }; +static const struct regmap_config pxp_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = HW_PXP_VERSION, +}; + static struct pxp_fmt *find_format(unsigned int pixelformat) { struct pxp_fmt *fmt; @@ -207,7 +215,7 @@ struct pxp_dev { #endif struct clk *clk; - void __iomem *mmio; + struct regmap *regmap; const struct pxp_pdata *pdata; @@ -255,12 +263,16 @@ static struct pxp_q_data *get_q_data(struct pxp_ctx *ctx, static inline u32 pxp_read(struct pxp_dev *dev, u32 reg) { - return readl(dev->mmio + reg); + u32 value; + + regmap_read(dev->regmap, reg, &value); + + return value; } static inline void pxp_write(struct pxp_dev *dev, u32 reg, u32 value) { - writel(value, dev->mmio + reg); + regmap_write(dev->regmap, reg, value); } static u32 pxp_v4l2_pix_fmt_to_ps_format(u32 v4l2_pix_fmt) @@ -1756,8 +1768,8 @@ static int pxp_soft_reset(struct pxp_dev *dev) pxp_write(dev, HW_PXP_CTRL_SET, BM_PXP_CTRL_SFTRST); - ret = readl_poll_timeout(dev->mmio + HW_PXP_CTRL, val, - val & BM_PXP_CTRL_CLKGATE, 0, 100); + ret = regmap_read_poll_timeout(dev->regmap, HW_PXP_CTRL, val, + val & BM_PXP_CTRL_CLKGATE, 0, 100); if (ret < 0) return ret; @@ -1774,6 +1786,7 @@ static int pxp_probe(struct platform_device *pdev) int irq; u32 hw_version; int ret; + void __iomem *mmio; dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) @@ -1788,9 +1801,11 @@ static int pxp_probe(struct platform_device *pdev) return ret; } - dev->mmio = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(dev->mmio)) - return PTR_ERR(dev->mmio); + mmio = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(mmio)) + return PTR_ERR(mmio); + dev->regmap = devm_regmap_init_mmio(&pdev->dev, mmio, + &pxp_regmap_config); irq = platform_get_irq(pdev, 0); if (irq < 0)