All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Michael Tretter <m.tretter@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Fabio Estevam <festevam@gmail.com>,
	Alexander Stein <alexander.stein@ew.tq-group.com>,
	kernel@pengutronix.de, linux-imx@nxp.com,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 16/16] media: imx-pxp: convert to regmap
Date: Fri, 13 Jan 2023 10:54:22 +0100	[thread overview]
Message-ID: <20230112-imx-pxp-v2-16-e2281da1db55@pengutronix.de> (raw)
In-Reply-To: <20230112-imx-pxp-v2-0-e2281da1db55@pengutronix.de>

Replace the readl and writel with regmap to ease debugging the registers
from userspace.

Suggested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
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 <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 
@@ -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)

-- 
2.30.2

WARNING: multiple messages have this Message-ID (diff)
From: Michael Tretter <m.tretter@pengutronix.de>
To: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Michael Tretter <m.tretter@pengutronix.de>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Fabio Estevam <festevam@gmail.com>,
	Alexander Stein <alexander.stein@ew.tq-group.com>,
	kernel@pengutronix.de, linux-imx@nxp.com,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 16/16] media: imx-pxp: convert to regmap
Date: Fri, 13 Jan 2023 10:54:22 +0100	[thread overview]
Message-ID: <20230112-imx-pxp-v2-16-e2281da1db55@pengutronix.de> (raw)
In-Reply-To: <20230112-imx-pxp-v2-0-e2281da1db55@pengutronix.de>

Replace the readl and writel with regmap to ease debugging the registers
from userspace.

Suggested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
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 <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 
@@ -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)

-- 
2.30.2

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-01-13  9:57 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13  9:54 [PATCH v2 00/16] media: imx-pxp: add support for i.MX7D Michael Tretter
2023-01-13  9:54 ` Michael Tretter
2023-01-13  9:54 ` [PATCH v2 01/16] dt-bindings: media: fsl-pxp: convert to yaml Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 10:41   ` Laurent Pinchart
2023-01-13 10:41     ` Laurent Pinchart
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13 11:56   ` Krzysztof Kozlowski
2023-01-13 11:56     ` Krzysztof Kozlowski
2023-01-13 15:09     ` Michael Tretter
2023-01-13 15:09       ` Michael Tretter
2023-01-13 16:51       ` Krzysztof Kozlowski
2023-01-13 16:51         ` Krzysztof Kozlowski
2023-01-13 15:26   ` Rob Herring
2023-01-13 15:26     ` Rob Herring
2023-01-16 11:38   ` [PATCH v2.1 02/17] " Michael Tretter
2023-01-16 11:38     ` Michael Tretter
2023-01-16 11:59     ` Krzysztof Kozlowski
2023-01-16 11:59       ` Krzysztof Kozlowski
2023-01-16 16:11       ` Laurent Pinchart
2023-01-16 16:11         ` Laurent Pinchart
2023-01-13  9:54 ` [PATCH v2 02/16] media: imx-pxp: detect PXP version Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 10:44   ` Laurent Pinchart
2023-01-13 10:44     ` Laurent Pinchart
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 03/16] media: imx-pxp: extract helper function to setup data path Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 04/16] media: imx-pxp: explicitly disable unused blocks Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 05/16] media: imx-pxp: disable LUT block Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 06/16] media: imx-pxp: make data_path_ctrl0 platform dependent Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13 12:03   ` Laurent Pinchart
2023-01-13 12:03     ` Laurent Pinchart
2023-01-13  9:54 ` [PATCH v2 07/16] media: imx-pxp: add support for i.MX7D Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 08/16] ARM: dts: imx7d: add node for PXP Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-16 16:26   ` Laurent Pinchart
2023-01-16 16:26     ` Laurent Pinchart
2023-01-20  9:06     ` Michael Tretter
2023-01-20  9:06       ` Michael Tretter
2023-01-20  9:20       ` Laurent Pinchart
2023-01-20  9:20         ` Laurent Pinchart
2023-02-09 14:02         ` Michael Tretter
2023-02-09 14:02           ` Michael Tretter
2023-03-06  1:19           ` Shawn Guo
2023-03-06  1:19             ` Shawn Guo
2023-01-13  9:54 ` [PATCH v2 09/16] media: imx-pxp: Sort headers alphabetically Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 10/16] media: imx-pxp: Don't set bus_info manually in .querycap() Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 11/16] media: imx-pxp: Add media controller support Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 12/16] media: imx-pxp: Pass pixel format value to find_format() Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:46   ` Philipp Zabel
2023-01-13 11:46     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 13/16] media: imx-pxp: Implement frame size enumeration Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:49   ` Philipp Zabel
2023-01-13 11:49     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 14/16] media: imx-pxp: Introduce pxp_read() and pxp_write() wrappers Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:50   ` Philipp Zabel
2023-01-13 11:50     ` Philipp Zabel
2023-01-13  9:54 ` [PATCH v2 15/16] media: imx-pxp: Use non-threaded IRQ Michael Tretter
2023-01-13  9:54   ` Michael Tretter
2023-01-13 11:52   ` Philipp Zabel
2023-01-13 11:52     ` Philipp Zabel
2023-01-13  9:54 ` Michael Tretter [this message]
2023-01-13  9:54   ` [PATCH v2 16/16] media: imx-pxp: convert to regmap Michael Tretter
2023-01-13 11:56   ` Philipp Zabel
2023-01-13 11:56     ` Philipp Zabel
2023-01-14 21:29 ` [PATCH v2 00/16] media: imx-pxp: add support for i.MX7D Laurent Pinchart
2023-01-14 21:29   ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230112-imx-pxp-v2-16-e2281da1db55@pengutronix.de \
    --to=m.tretter@pengutronix.de \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.