summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/nxp
diff options
context:
space:
mode:
authorMichael Tretter <m.tretter@pengutronix.de>2023-01-13 10:54:22 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-02-08 09:21:30 +0100
commit4e5bd3fdbeb3100d1f120999130afb2a7d41d82a (patch)
tree70ee9386994bb592cc947cfa49f800ea3d421536 /drivers/media/platform/nxp
parent4d25e97747d3f94c0e8ae9c0da2db801256908d0 (diff)
downloadlinux-stable-4e5bd3fdbeb3100d1f120999130afb2a7d41d82a.tar.gz
linux-stable-4e5bd3fdbeb3100d1f120999130afb2a7d41d82a.tar.bz2
linux-stable-4e5bd3fdbeb3100d1f120999130afb2a7d41d82a.zip
media: imx-pxp: convert to regmap
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> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/nxp')
-rw-r--r--drivers/media/platform/nxp/imx-pxp.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c
index f44cf16be942..fde3c36e5e1d 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)
u32 hw_version;
int irq;
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)