Skip to content

Commit

Permalink
Merge remote-tracking branches 'regmap/topic/noinc' and 'regmap/topic…
Browse files Browse the repository at this point in the history
…/single-rw' into regmap-next
  • Loading branch information
broonie committed Oct 21, 2018
3 parents 9ef6884 + cdf6b11 + 1c96a2f commit ae2399c
Show file tree
Hide file tree
Showing 35 changed files with 193 additions and 53 deletions.
5 changes: 4 additions & 1 deletion drivers/base/regmap/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ struct regmap {
bool (*readable_reg)(struct device *dev, unsigned int reg);
bool (*volatile_reg)(struct device *dev, unsigned int reg);
bool (*precious_reg)(struct device *dev, unsigned int reg);
bool (*writeable_noinc_reg)(struct device *dev, unsigned int reg);
bool (*readable_noinc_reg)(struct device *dev, unsigned int reg);
const struct regmap_access_table *wr_table;
const struct regmap_access_table *rd_table;
const struct regmap_access_table *volatile_table;
const struct regmap_access_table *precious_table;
const struct regmap_access_table *wr_noinc_table;
const struct regmap_access_table *rd_noinc_table;

int (*reg_read)(void *context, unsigned int reg, unsigned int *val);
Expand Down Expand Up @@ -149,7 +151,7 @@ struct regmap {

/* if set, converts bulk read to single read */
bool use_single_read;
/* if set, converts bulk read to single read */
/* if set, converts bulk write to single write */
bool use_single_write;
/* if set, the device supports multi write mode */
bool can_multi_write;
Expand Down Expand Up @@ -183,6 +185,7 @@ bool regmap_writeable(struct regmap *map, unsigned int reg);
bool regmap_readable(struct regmap *map, unsigned int reg);
bool regmap_volatile(struct regmap *map, unsigned int reg);
bool regmap_precious(struct regmap *map, unsigned int reg);
bool regmap_writeable_noinc(struct regmap *map, unsigned int reg);
bool regmap_readable_noinc(struct regmap *map, unsigned int reg);

int _regmap_write(struct regmap *map, unsigned int reg,
Expand Down
81 changes: 79 additions & 2 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,17 @@ bool regmap_precious(struct regmap *map, unsigned int reg)
return false;
}

bool regmap_writeable_noinc(struct regmap *map, unsigned int reg)
{
if (map->writeable_noinc_reg)
return map->writeable_noinc_reg(map->dev, reg);

if (map->wr_noinc_table)
return regmap_check_range_table(map, reg, map->wr_noinc_table);

return true;
}

bool regmap_readable_noinc(struct regmap *map, unsigned int reg)
{
if (map->readable_noinc_reg)
Expand Down Expand Up @@ -772,8 +783,8 @@ struct regmap *__regmap_init(struct device *dev,
map->reg_stride_order = ilog2(map->reg_stride);
else
map->reg_stride_order = -1;
map->use_single_read = config->use_single_rw || !bus || !bus->read;
map->use_single_write = config->use_single_rw || !bus || !bus->write;
map->use_single_read = config->use_single_read || !bus || !bus->read;
map->use_single_write = config->use_single_write || !bus || !bus->write;
map->can_multi_write = config->can_multi_write && bus && bus->write;
if (bus) {
map->max_raw_read = bus->max_raw_read;
Expand All @@ -787,11 +798,13 @@ struct regmap *__regmap_init(struct device *dev,
map->rd_table = config->rd_table;
map->volatile_table = config->volatile_table;
map->precious_table = config->precious_table;
map->wr_noinc_table = config->wr_noinc_table;
map->rd_noinc_table = config->rd_noinc_table;
map->writeable_reg = config->writeable_reg;
map->readable_reg = config->readable_reg;
map->volatile_reg = config->volatile_reg;
map->precious_reg = config->precious_reg;
map->writeable_noinc_reg = config->writeable_noinc_reg;
map->readable_noinc_reg = config->readable_noinc_reg;
map->cache_type = config->cache_type;

Expand Down Expand Up @@ -1308,6 +1321,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
map->readable_reg = config->readable_reg;
map->volatile_reg = config->volatile_reg;
map->precious_reg = config->precious_reg;
map->writeable_noinc_reg = config->writeable_noinc_reg;
map->readable_noinc_reg = config->readable_noinc_reg;
map->cache_type = config->cache_type;

Expand Down Expand Up @@ -1905,6 +1919,69 @@ int regmap_raw_write(struct regmap *map, unsigned int reg,
}
EXPORT_SYMBOL_GPL(regmap_raw_write);

/**
* regmap_noinc_write(): Write data from a register without incrementing the
* register number
*
* @map: Register map to write to
* @reg: Register to write to
* @val: Pointer to data buffer
* @val_len: Length of output buffer in bytes.
*
* The regmap API usually assumes that bulk bus write operations will write a
* range of registers. Some devices have certain registers for which a write
* operation can write to an internal FIFO.
*
* The target register must be volatile but registers after it can be
* completely unrelated cacheable registers.
*
* This will attempt multiple writes as required to write val_len bytes.
*
* A value of zero will be returned on success, a negative errno will be
* returned in error cases.
*/
int regmap_noinc_write(struct regmap *map, unsigned int reg,
const void *val, size_t val_len)
{
size_t write_len;
int ret;

if (!map->bus)
return -EINVAL;
if (!map->bus->write)
return -ENOTSUPP;
if (val_len % map->format.val_bytes)
return -EINVAL;
if (!IS_ALIGNED(reg, map->reg_stride))
return -EINVAL;
if (val_len == 0)
return -EINVAL;

map->lock(map->lock_arg);

if (!regmap_volatile(map, reg) || !regmap_writeable_noinc(map, reg)) {
ret = -EINVAL;
goto out_unlock;
}

while (val_len) {
if (map->max_raw_write && map->max_raw_write < val_len)
write_len = map->max_raw_write;
else
write_len = val_len;
ret = _regmap_raw_write(map, reg, val, write_len);
if (ret)
goto out_unlock;
val = ((u8 *)val) + write_len;
val_len -= write_len;
}

out_unlock:
map->unlock(map->lock_arg);
return ret;
}
EXPORT_SYMBOL_GPL(regmap_noinc_write);

/**
* regmap_field_update_bits_base() - Perform a read/modify/write cycle a
* register field.
Expand Down
3 changes: 2 additions & 1 deletion drivers/edac/altera_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ static const struct regmap_config s10_sdram_regmap_cfg = {
.volatile_reg = s10_sdram_volatile_reg,
.reg_read = s10_protected_reg_read,
.reg_write = s10_protected_reg_write,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static int altr_s10_sdram_probe(struct platform_device *pdev)
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/lm75.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ static const struct regmap_config lm75_regmap_config = {
.volatile_reg = lm75_is_volatile_reg,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static void lm75_remove(void *data)
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/lm95245.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ static const struct regmap_config lm95245_regmap_config = {
.writeable_reg = lm95245_is_writeable_reg,
.volatile_reg = lm95245_is_volatile_reg,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static const u32 lm95245_chip_config[] = {
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/tmp102.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ static const struct regmap_config tmp102_regmap_config = {
.volatile_reg = tmp102_is_volatile_reg,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static int tmp102_probe(struct i2c_client *client,
Expand Down
3 changes: 2 additions & 1 deletion drivers/hwmon/tmp108.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ static const struct regmap_config tmp108_regmap_config = {
.volatile_reg = tmp108_is_volatile_reg,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static int tmp108_probe(struct i2c_client *client,
Expand Down
3 changes: 2 additions & 1 deletion drivers/iio/light/apds9960.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ static const struct regmap_config apds9960_regmap_config = {
.name = APDS9960_REGMAP_NAME,
.reg_bits = 8,
.val_bits = 8,
.use_single_rw = 1,
.use_single_read = true,
.use_single_write = true,

.volatile_table = &apds9960_volatile_table,
.precious_table = &apds9960_precious_table,
Expand Down
23 changes: 12 additions & 11 deletions drivers/iio/light/max44000.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,17 +473,18 @@ static bool max44000_precious_reg(struct device *dev, unsigned int reg)
}

static const struct regmap_config max44000_regmap_config = {
.reg_bits = 8,
.val_bits = 8,

.max_register = MAX44000_REG_PRX_DATA,
.readable_reg = max44000_readable_reg,
.writeable_reg = max44000_writeable_reg,
.volatile_reg = max44000_volatile_reg,
.precious_reg = max44000_precious_reg,

.use_single_rw = 1,
.cache_type = REGCACHE_RBTREE,
.reg_bits = 8,
.val_bits = 8,

.max_register = MAX44000_REG_PRX_DATA,
.readable_reg = max44000_readable_reg,
.writeable_reg = max44000_writeable_reg,
.volatile_reg = max44000_volatile_reg,
.precious_reg = max44000_precious_reg,

.use_single_read = true,
.use_single_write = true,
.cache_type = REGCACHE_RBTREE,
};

static irqreturn_t max44000_trigger_handler(int irq, void *p)
Expand Down
3 changes: 2 additions & 1 deletion drivers/iio/temperature/mlx90632.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ static const struct regmap_config mlx90632_regmap = {
.rd_table = &mlx90632_readable_regs_tbl,
.wr_table = &mlx90632_writeable_regs_tbl,

.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.reg_format_endian = REGMAP_ENDIAN_BIG,
.val_format_endian = REGMAP_ENDIAN_BIG,
.cache_type = REGCACHE_RBTREE,
Expand Down
3 changes: 2 additions & 1 deletion drivers/input/touchscreen/tsc200x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const struct regmap_config tsc200x_regmap_config = {
.read_flag_mask = TSC200X_REG_READ,
.write_flag_mask = TSC200X_REG_PND0,
.wr_table = &tsc200x_writable_table,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};
EXPORT_SYMBOL_GPL(tsc200x_regmap_config);

Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/altera-a10sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ static const struct regmap_config altr_a10sr_regmap_config = {

.cache_type = REGCACHE_NONE,

.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.read_flag_mask = 1,
.write_flag_mask = 0,

Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/da9052-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ static int da9052_spi_probe(struct spi_device *spi)
config.reg_bits = 7;
config.pad_bits = 1;
config.val_bits = 8;
config.use_single_rw = 1;
config.use_single_read = true;
config.use_single_write = true;

da9052->regmap = devm_regmap_init_spi(spi, &config);
if (IS_ERR(da9052->regmap)) {
Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/mc13xxx-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static const struct regmap_config mc13xxx_regmap_spi_config = {
.max_register = MC13XXX_NUMREGS,

.cache_type = REGCACHE_NONE,
.use_single_rw = 1,
.use_single_read = true,
.use_single_write = true,
};

static int mc13xxx_spi_read(void *context, const void *reg, size_t reg_size,
Expand Down
3 changes: 2 additions & 1 deletion drivers/mfd/twl6040.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,8 @@ static const struct regmap_config twl6040_regmap_config = {
.writeable_reg = twl6040_writeable_reg,

.cache_type = REGCACHE_RBTREE,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
};

static const struct regmap_irq twl6040_irqs[] = {
Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/ltc3589.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,8 @@ static const struct regmap_config ltc3589_regmap_config = {
.max_register = LTC3589_L2DTV2,
.reg_defaults = ltc3589_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(ltc3589_reg_defaults),
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.cache_type = REGCACHE_RBTREE,
};

Expand Down
3 changes: 2 additions & 1 deletion drivers/regulator/ltc3676.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ static const struct regmap_config ltc3676_regmap_config = {
.readable_reg = ltc3676_readable_reg,
.volatile_reg = ltc3676_volatile_reg,
.max_register = LTC3676_CLIRQ,
.use_single_rw = true,
.use_single_read = true,
.use_single_write = true,
.cache_type = REGCACHE_RBTREE,
};

Expand Down
Loading

0 comments on commit ae2399c

Please sign in to comment.