[U-Boot] [PATCH] regmap: Separate memory-based operations

Alexey Brodkin Alexey.Brodkin at synopsys.com
Fri May 25 09:45:08 UTC 2018


Hi Simon,

On Thu, 2018-05-24 at 20:42 -0600, Simon Glass wrote:
> Hi Alexey,
> 
> On 24 May 2018 at 06:36, Alexey Brodkin <Alexey.Brodkin at synopsys.com> wrote:
> > One of important features of regmap [at least in Linux kernel]
> > is an ability to seamlessly communicate to devices connected
> > via different buses like: MMIO, SPI, I2C and many others.
> > 
> > Current implementation in U-Boot only supports memory-mapped registers
> > which is a vere valid case but we'll need more in the future.
> > 
> > This change paves the way for support of other buses. Still all existing
> > users of regmap in U-Boot shouldn't be affected because for now we don't
> > change API which might be required once we start adding support of more
> > complicated cases like 8/16/32/64-bit accessors, big- and little-endian
> > flavours etc.
> > 
> > It was inspired by discussion [1] of addition of even more accessors to
> > a standard 16550 UART.
> > 
> > [1] https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.denx.de_pipermail_u-2Dboot_2018-2DMarch_322322.html&d=DwIBaQ&c=DPL6_X_6JkXFx7AXWqB0
> > tg&r=lqdeeSSEes0GFDDl656eViXO7breS55ytWkhpk5R81I&m=JMITUQeA5TvqyeIBTH0jtI2TOsSfOS-0qPz4kntF5Hc&s=yadG7Ir9EqQaMUpUychW3TY3B7acDOog8IQYDKvOI-8&e=
> > 
> > Signed-off-by: Alexey Brodkin <abrodkin at synopsys.com>
> > Cc: Simon Glass <sjg at chromium.org>
> > ---
> >  drivers/core/Makefile                   |  2 +-
> >  drivers/core/{regmap.c => regmap-mem.c} | 79 ++++++-----------------
> >  drivers/core/regmap.c                   | 85 +------------------------
> >  include/regmap.h                        |  9 +++
> >  4 files changed, 31 insertions(+), 144 deletions(-)
> >  copy drivers/core/{regmap.c => regmap-mem.c} (60%)
> > 
> 
> Are there any changes needed to the regmap test with this?

Given this change doesn't touch API I'm not sure what can we
test more than it's currently done. Any thoughts?

> [..]
> 
> > diff --git a/include/regmap.h b/include/regmap.h
> > index 493a5d8eff84..f01c5733afac 100644
> > --- a/include/regmap.h
> > +++ b/include/regmap.h
> > @@ -31,6 +31,8 @@ struct regmap {
> >         phys_addr_t base;
> >         int range_count;
> >         struct regmap_range *range, base_range;
> > +       int (*reg_read)(struct regmap *map, uint reg, uint *val);
> > +       int (*reg_write)(struct regmap *map, uint reg, uint val);
> 
> Can we use driver model for these somehow? E.g. we could create a
> UCLASS_SIMPLE_REG driver for each of memory, i2c, SPI, etc.

Probably we can do it here in U-Boot.
But at least in Linux kernel I see users of regmap (i.e. particular drivers)
initialize required regmap instance "manually", see for example:
https://elixir.bootlin.com/linux/latest/source/drivers/media/dvb-frontends/af9033.c#L1105

> When we want to use a particular I2C bus via regmap, we could bind the
> I2C -> regmap driver as a child of the I2C bus driver.

I guess that will require us to do corresponding changes in Device Tree
descriptions, right? And that will deviate those .dts-es from their kernel
counterparts [if they exist for a particular board].

-Alexey


More information about the U-Boot mailing list