]> Git Repo - J-u-boot.git/blobdiff - drivers/core/regmap.c
dm: core: Replace of_offset with accessor
[J-u-boot.git] / drivers / core / regmap.c
index 0299ff087937f406a939a15a585046b900584143..833cd78e8489038496da2ad7fe31a3f4600e9a07 100644 (file)
@@ -13,6 +13,8 @@
 #include <mapmem.h>
 #include <regmap.h>
 
+#include <asm/io.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 static struct regmap *regmap_alloc_count(int count)
@@ -69,12 +71,12 @@ int regmap_init_mem(struct udevice *dev, struct regmap **mapp)
        int parent;
        int len;
 
-       parent = dev->parent->of_offset;
+       parent = dev_of_offset(dev->parent);
        addr_len = fdt_address_cells(blob, parent);
        size_len = fdt_size_cells(blob, parent);
        both_len = addr_len + size_len;
 
-       cell = fdt_getprop(blob, dev->of_offset, "reg", &len);
+       cell = fdt_getprop(blob, dev_of_offset(dev), "reg", &len);
        len /= sizeof(*cell);
        count = len / both_len;
        if (!cell || !count)
@@ -117,3 +119,21 @@ int regmap_uninit(struct regmap *map)
 
        return 0;
 }
+
+int regmap_read(struct regmap *map, uint offset, uint *valp)
+{
+       uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE);
+
+       *valp = le32_to_cpu(readl(ptr));
+
+       return 0;
+}
+
+int regmap_write(struct regmap *map, uint offset, uint val)
+{
+       uint32_t *ptr = map_physmem(map->base + offset, 4, MAP_NOCACHE);
+
+       writel(cpu_to_le32(val), ptr);
+
+       return 0;
+}
This page took 0.025819 seconds and 4 git commands to generate.