regmap: slimbus: add support to multi read/write

SLIMbus supports upto 16 bytes in value management messages,
so add support to read/writes upto 16 bytes.

This also removes redundant single register reg_read/reg_write.

Also useful for paged register access on SLIMbus interfaced codecs.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Srinivas Kandagatla 2018-07-06 16:05:27 +01:00 committed by Mark Brown
parent ce397d215c
commit e76ad18b56
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -7,33 +7,24 @@
#include "internal.h" #include "internal.h"
static int regmap_slimbus_byte_reg_read(void *context, unsigned int reg, static int regmap_slimbus_write(void *context, const void *data, size_t count)
unsigned int *val)
{ {
struct slim_device *sdev = context; struct slim_device *sdev = context;
int v;
v = slim_readb(sdev, reg); return slim_write(sdev, *(u16 *)data, count - 2, (u8 *)data + 2);
if (v < 0)
return v;
*val = v;
return 0;
} }
static int regmap_slimbus_byte_reg_write(void *context, unsigned int reg, static int regmap_slimbus_read(void *context, const void *reg, size_t reg_size,
unsigned int val) void *val, size_t val_size)
{ {
struct slim_device *sdev = context; struct slim_device *sdev = context;
return slim_writeb(sdev, reg, val); return slim_read(sdev, *(u16 *)reg, val_size, val);
} }
static struct regmap_bus regmap_slimbus_bus = { static struct regmap_bus regmap_slimbus_bus = {
.reg_write = regmap_slimbus_byte_reg_write, .write = regmap_slimbus_write,
.reg_read = regmap_slimbus_byte_reg_read, .read = regmap_slimbus_read,
.reg_format_endian_default = REGMAP_ENDIAN_LITTLE, .reg_format_endian_default = REGMAP_ENDIAN_LITTLE,
.val_format_endian_default = REGMAP_ENDIAN_LITTLE, .val_format_endian_default = REGMAP_ENDIAN_LITTLE,
}; };