From: Christian Marangi Date: Sat, 1 Nov 2025 00:44:52 +0000 (+0300) Subject: reset: airoha: convert to regmap API X-Git-Tag: v2026.01-rc2~7^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea9b7975378a1ab216a28d2851335a3db5c2d445;p=thirdparty%2Fu-boot.git reset: airoha: convert to regmap API In preparation for support for Airoha AN7583, convert the driver to regmap API. This is needed as Airoha AN7583 will use syscon to access reset registers. Signed-off-by: Christian Marangi --- diff --git a/drivers/reset/reset-airoha.c b/drivers/reset/reset-airoha.c index e878af6167c..a618bf62b4d 100644 --- a/drivers/reset/reset-airoha.c +++ b/drivers/reset/reset-airoha.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -21,7 +22,7 @@ struct airoha_reset_priv { const u16 *bank_ofs; const u16 *idx_map; - void __iomem *base; + struct regmap *map; }; static const u16 en7581_rst_ofs[] = { @@ -90,17 +91,11 @@ static const u16 en7581_rst_map[] = { static int airoha_reset_update(struct airoha_reset_priv *priv, unsigned long id, bool assert) { - void __iomem *addr = priv->base + priv->bank_ofs[id / RST_NR_PER_BANK]; - u32 val; - - val = readl(addr); - if (assert) - val |= BIT(id % RST_NR_PER_BANK); - else - val &= ~BIT(id % RST_NR_PER_BANK); - writel(val, addr); + u16 offset = priv->bank_ofs[id / RST_NR_PER_BANK]; - return 0; + return regmap_update_bits(priv->map, offset, + BIT(id % RST_NR_PER_BANK), + assert ? BIT(id % RST_NR_PER_BANK) : 0); } static int airoha_reset_assert(struct reset_ctl *reset_ctl) @@ -123,11 +118,16 @@ static int airoha_reset_status(struct reset_ctl *reset_ctl) { struct airoha_reset_priv *priv = dev_get_priv(reset_ctl->dev); int id = reset_ctl->id; - void __iomem *addr; + u16 offset; + u32 val; + int ret; - addr = priv->base + priv->bank_ofs[id / RST_NR_PER_BANK]; + offset = priv->bank_ofs[id / RST_NR_PER_BANK]; + ret = regmap_read(priv->map, offset, &val); + if (ret) + return ret; - return !!(readl(addr) & BIT(id % RST_NR_PER_BANK)); + return !!(val & BIT(id % RST_NR_PER_BANK)); } static int airoha_reset_xlate(struct reset_ctl *reset_ctl, @@ -153,10 +153,11 @@ static struct reset_ops airoha_reset_ops = { static int airoha_reset_probe(struct udevice *dev) { struct airoha_reset_priv *priv = dev_get_priv(dev); + int ret; - priv->base = dev_remap_addr(dev); - if (!priv->base) - return -ENOMEM; + ret = regmap_init_mem(dev_ofnode(dev), &priv->map); + if (ret) + return ret; priv->bank_ofs = en7581_rst_ofs; priv->idx_map = en7581_rst_map;