Message ID | 20160727142651.10570-8-paul.burton@imgtec.com |
---|---|
State | Superseded |
Delegated to: | Daniel Schwierzeck |
Headers | show |
On 27 July 2016 at 08:26, Paul Burton <paul.burton@imgtec.com> wrote: > The regmap_read & regmap_write functions were previously declared in > regmap.h but not implemented anywhere. The regmap implementation & > commit message of 6f98b7504f70 ("dm: Add support for register maps > (regmap)") indicate that only memory mapped accesses are supported for > now, so providing simple implementations of regmap_read & regmap_write > is trivial. The access size is presumed to be 4 bytes & endianness is > presumed native, which are the defaults for the regmap code in Linux. > > Signed-off-by: Paul Burton <paul.burton@imgtec.com> > > --- > > Changes in v2: > - New patch > > drivers/core/regmap.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org> nits below > > diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c > index 0299ff0..030a40a 100644 > --- a/drivers/core/regmap.c > +++ b/drivers/core/regmap.c > @@ -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) > @@ -117,3 +119,17 @@ int regmap_uninit(struct regmap *map) > > return 0; > } > + > +int regmap_read(struct regmap *map, uint offset, uint *valp) > +{ > + uint32_t *ptr = ioremap(map->base + offset, 4); blank line here (after decls) > + *valp = __raw_readl(ptr); and here (before return) > + return 0; > +} > + > +int regmap_write(struct regmap *map, uint offset, uint val) > +{ > + uint32_t *ptr = ioremap(map->base + offset, 4); and here (after decls) > + __raw_writel(val, ptr); and here (before return) > + return 0; > +} > -- > 2.9.0 > - Simon
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 0299ff0..030a40a 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -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) @@ -117,3 +119,17 @@ int regmap_uninit(struct regmap *map) return 0; } + +int regmap_read(struct regmap *map, uint offset, uint *valp) +{ + uint32_t *ptr = ioremap(map->base + offset, 4); + *valp = __raw_readl(ptr); + return 0; +} + +int regmap_write(struct regmap *map, uint offset, uint val) +{ + uint32_t *ptr = ioremap(map->base + offset, 4); + __raw_writel(val, ptr); + return 0; +}
The regmap_read & regmap_write functions were previously declared in regmap.h but not implemented anywhere. The regmap implementation & commit message of 6f98b7504f70 ("dm: Add support for register maps (regmap)") indicate that only memory mapped accesses are supported for now, so providing simple implementations of regmap_read & regmap_write is trivial. The access size is presumed to be 4 bytes & endianness is presumed native, which are the defaults for the regmap code in Linux. Signed-off-by: Paul Burton <paul.burton@imgtec.com> --- Changes in v2: - New patch drivers/core/regmap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)