regmap: change regmap_init_mem() to take ofnode instead udevice
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 19 Apr 2018 03:14:03 +0000 (12:14 +0900)
committerTom Rini <trini@konsulko.com>
Mon, 7 May 2018 19:49:51 +0000 (15:49 -0400)
Currently, regmap_init_mem() takes a udevice. This requires the node
has already been associated with a device. It prevents syscon/regmap
from behaving like those in Linux.

Change the first argumenet to take a device node.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
13 files changed:
arch/arm/mach-aspeed/ast2500/sdram_ast2500.c
drivers/core/regmap.c
drivers/core/syscon-uclass.c
drivers/phy/meson-gxl-usb2.c
drivers/phy/meson-gxl-usb3.c
drivers/ram/rockchip/dmc-rk3368.c
drivers/ram/rockchip/sdram_rk3188.c
drivers/ram/rockchip/sdram_rk322x.c
drivers/ram/rockchip/sdram_rk3288.c
drivers/ram/rockchip/sdram_rk3399.c
drivers/ram/stm32mp1/stm32mp1_ram.c
drivers/reset/reset-meson.c
include/regmap.h

index 63df5f2e864328b70cd218b795389fe6e6205878..9498cbc92d7d5b75d18bd52000864f61b83f84b9 100644 (file)
@@ -391,7 +391,7 @@ static int ast2500_sdrammc_ofdata_to_platdata(struct udevice *dev)
        struct regmap *map;
        int ret;
 
-       ret = regmap_init_mem(dev, &map);
+       ret = regmap_init_mem(dev_ofnode(dev), &map);
        if (ret)
                return ret;
 
index 0f787ab4e139b0c1a875a1ef6f525d6621e4dc7e..fabcc5f53a838fb7bf1bc2a86f7cadfb0763e6e9 100644 (file)
@@ -50,7 +50,7 @@ int regmap_init_mem_platdata(struct udevice *dev, fdt_val_t *reg, int count,
        return 0;
 }
 #else
-int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
+int regmap_init_mem(ofnode node, struct regmap **mapp)
 {
        struct regmap_range *range;
        struct regmap *map;
@@ -58,14 +58,13 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
        int addr_len, size_len, both_len;
        int len;
        int index;
-       ofnode node = dev_ofnode(dev);
        struct resource r;
 
-       addr_len = dev_read_simple_addr_cells(dev->parent);
-       size_len = dev_read_simple_size_cells(dev->parent);
+       addr_len = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
+       size_len = ofnode_read_simple_size_cells(ofnode_get_parent(node));
        both_len = addr_len + size_len;
 
-       len = dev_read_size(dev, "reg");
+       len = ofnode_read_size(node, "reg");
        if (len < 0)
                return len;
        len /= sizeof(fdt32_t);
@@ -86,7 +85,7 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
                        range->size = r.end - r.start + 1;
                } else {
                        range->start = fdtdec_get_addr_size_fixed(gd->fdt_blob,
-                                       dev_of_offset(dev), "reg", index,
+                                       ofnode_to_offset(node), "reg", index,
                                        addr_len, size_len, &sz, true);
                        range->size = sz;
                }
index 96408dea7e699434fc61de6fa564f2ec747573bc..62ba462158d1d4096d903ed13e9b457947818ed0 100644 (file)
@@ -40,7 +40,7 @@ static int syscon_pre_probe(struct udevice *dev)
        return regmap_init_mem_platdata(dev, plat->reg, ARRAY_SIZE(plat->reg),
                                        &priv->regmap);
 #else
-       return regmap_init_mem(dev, &priv->regmap);
+       return regmap_init_mem(dev_ofnode(dev), &priv->regmap);
 #endif
 }
 
index 7ea4fe797e0a59356e4780195b7264520a167019..86e69c73ba26ba5b487ea4ff7b189c7c88aeac73 100644 (file)
@@ -192,7 +192,7 @@ int meson_gxl_usb2_phy_probe(struct udevice *dev)
        struct phy_meson_gxl_usb2_priv *priv = dev_get_priv(dev);
        int ret;
 
-       ret = regmap_init_mem(dev, &priv->regmap);
+       ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap);
        if (ret)
                return ret;
 
index 22824de517007dfa95b25c6e51303bcc135673ae..5cbbd4d8f7ba49d03596cd112df15ebe6f921a9c 100644 (file)
@@ -163,7 +163,7 @@ int meson_gxl_usb3_phy_probe(struct udevice *dev)
        struct phy_meson_gxl_usb3_priv *priv = dev_get_priv(dev);
        int ret;
 
-       ret = regmap_init_mem(dev, &priv->regmap);
+       ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap);
        if (ret)
                return ret;
        
index 75e2e9969b3099ec5dde4d97e4a91d2e866acc0e..8d1b9faacc01c39677317a30d5faf2de783921a1 100644 (file)
@@ -877,7 +877,7 @@ static int rk3368_dmc_ofdata_to_platdata(struct udevice *dev)
 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
        struct rk3368_sdram_params *plat = dev_get_platdata(dev);
 
-       ret = regmap_init_mem(dev, &plat->map);
+       ret = regmap_init_mem(dev_ofnode(dev), &plat->map);
        if (ret)
                return ret;
 #endif
index 91edc5a661dd2627797658ebb37c02ef30326269..3774abfa98a1cb0a006b6f119fd9b7091929876e 100644 (file)
@@ -839,7 +839,7 @@ static int rk3188_dmc_ofdata_to_platdata(struct udevice *dev)
                printf("%s: Cannot read rockchip,sdram-params\n", __func__);
                return -EINVAL;
        }
-       ret = regmap_init_mem(dev, &params->map);
+       ret = regmap_init_mem(dev_ofnode(dev), &params->map);
        if (ret)
                return ret;
 #endif
index 16cf557af41e189296c97ad703ca629316a89bf9..8bafd17f8ff7f545f13b7d84552b49a7cb65ce78 100644 (file)
@@ -743,7 +743,7 @@ static int rk322x_dmc_ofdata_to_platdata(struct udevice *dev)
                printf("%s: Cannot read rockchip,sdram-params\n", __func__);
                return -EINVAL;
        }
-       ret = regmap_init_mem(dev, &params->map);
+       ret = regmap_init_mem(dev_ofnode(dev), &params->map);
        if (ret)
                return ret;
 #endif
index 14c30c90809fd121e14f2c0e95783f0ae7397db6..bb3cf48788c2d3f5d2b4ab2d118edb8257a66d30 100644 (file)
@@ -1000,7 +1000,7 @@ static int rk3288_dmc_ofdata_to_platdata(struct udevice *dev)
 
        priv->is_veyron = !fdt_node_check_compatible(blob, 0, "google,veyron");
 #endif
-       ret = regmap_init_mem(dev, &params->map);
+       ret = regmap_init_mem(dev_ofnode(dev), &params->map);
        if (ret)
                return ret;
 #endif
index d16ff0d427595133e93c22e9d0d6905f20a67148..49ebd8809f036f560168135707af2668f41f8192 100644 (file)
@@ -1098,7 +1098,7 @@ static int rk3399_dmc_ofdata_to_platdata(struct udevice *dev)
                       __func__, ret);
                return ret;
        }
-       ret = regmap_init_mem(dev, &plat->map);
+       ret = regmap_init_mem(dev_ofnode(dev), &plat->map);
        if (ret)
                printf("%s: regmap failed %d\n", __func__, ret);
 
index a40f992f1a7a28eb36a8e5001ee44db6ca960e16..bd497a3021d825a85ac493164107a2e1c9486c91 100644 (file)
@@ -146,7 +146,7 @@ static int stm32mp1_ddr_probe(struct udevice *dev)
        debug("STM32MP1 DDR probe\n");
        priv->dev = dev;
 
-       ret = regmap_init_mem(dev, &map);
+       ret = regmap_init_mem(dev_ofnode(dev), &map);
        if (ret)
                return ret;
 
index ef0d043afb78ec98f509d0cbd85b07ce6aa6f998..92f04695ecdac72cb3e23bbac7d2436db6e10cb9 100644 (file)
@@ -76,7 +76,7 @@ static int meson_reset_probe(struct udevice *dev)
 {
        struct meson_reset_priv *priv = dev_get_priv(dev);
        
-       return regmap_init_mem(dev, &priv->regmap);
+       return regmap_init_mem(dev_ofnode(dev), &priv->regmap);
 }
 
 U_BOOT_DRIVER(meson_reset) = {
index d827a0bd523b6a4938ca6c55f52bf6c1b292f978..e96c79dd26a219843d6343fb7d789aa63ae1cad5 100644 (file)
@@ -47,10 +47,10 @@ int regmap_read(struct regmap *map, uint offset, uint *valp);
  *
  * Use regmap_uninit() to free it.
  *
- * @dev:       Device that uses this map
+ * @node:      Device node that uses this map
  * @mapp:      Returns allocated map
  */
-int regmap_init_mem(struct udevice *dev, struct regmap **mapp);
+int regmap_init_mem(ofnode node, struct regmap **mapp);
 
 /**
  * regmap_init_mem_platdata() - Set up a new memory register map for of-platdata