Hi Laurent,
[snip]
+static inline void xlnx_dsi_writel(void __iomem *base, int offset, u32 val) +{
- writel(val, base + offset);
+}
+static inline u32 xlnx_dsi_readl(void __iomem *base, int offset) +{
- return readl(base + offset);
+}
When I see implementations like this I wonder if a regmap would be beneficial?
regmap often seems overkill to me when the driver only needs plain 32-bit mmio read/write, given the overhead it adds at runtime. Is it just me ?
There are several points that speaks for using regmap: - The interface is well known - It has nice helpers - like update_bits - No need for own wrappers, that sometimes are made in creative ways (not the case here) - There is a possibility to add some run-time checks so one can catch attempt to write outside the register window, write to read-only registers etc.
On top of this - it is simple to configure:
static const struct regmap_config regmap_config = { .reg_bits = 32, .val_bits = 32, .reg_stride = 4, };
From the probe function:
priv->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(priv->regs)) return dev_err_probe(dev, PTR_ERR(priv->regs), "Failed to get memory resource\n");
regmap_cfg = regmap_config; regmap_cfg.max_register = res->end - res->start; priv->regmap = devm_regmap_init_mmio(dev, priv->regs, ®map_cfg); if (IS_ERR(priv->regmap)) return dev_err_probe(dev, PTR_ERR(priv->regmap), "Failed to init regmap\n");
The one point that brought me over was the well known interface. But using wrappers works too.
Sam