未验证 提交 0c2191c3 编写于 作者: R Ricardo Ribalda 提交者: Mark Brown

regmap: Add support for 12/20 register formatting

Devices such as the AD5628 require 32 bits of data divided in 12 bits
for dummy, command and address, and 20 for data and dummy. Eg:

XXXXCCCCAAAADDDDDDDDDDDDDDDDXXXX

Where X is dont care, C is command, A is address and D is data bits.

Which would requierd the following regmap_config:

static const struct regmap_config config_dac = {
	.reg_bits = 12,
	.val_bits = 20,
	.max_register = 0xff,
};
Signed-off-by: NRicardo Ribalda <ribalda@kernel.org>
Link: https://lore.kernel.org/r/20200917114727.1120373-1-ribalda@kernel.orgSigned-off-by: NMark Brown <broonie@kernel.org>
上级 21f8e482
...@@ -209,6 +209,18 @@ static bool regmap_volatile_range(struct regmap *map, unsigned int reg, ...@@ -209,6 +209,18 @@ static bool regmap_volatile_range(struct regmap *map, unsigned int reg,
return true; return true;
} }
static void regmap_format_12_20_write(struct regmap *map,
unsigned int reg, unsigned int val)
{
u8 *out = map->work_buf;
out[0] = reg >> 4;
out[1] = (reg << 4) | (val >> 16);
out[2] = val >> 8;
out[3] = val;
}
static void regmap_format_2_6_write(struct regmap *map, static void regmap_format_2_6_write(struct regmap *map,
unsigned int reg, unsigned int val) unsigned int reg, unsigned int val)
{ {
...@@ -870,6 +882,16 @@ struct regmap *__regmap_init(struct device *dev, ...@@ -870,6 +882,16 @@ struct regmap *__regmap_init(struct device *dev,
} }
break; break;
case 12:
switch (config->val_bits) {
case 20:
map->format.format_write = regmap_format_12_20_write;
break;
default:
goto err_hwlock;
}
break;
case 8: case 8:
map->format.format_reg = regmap_format_8; map->format.format_reg = regmap_format_8;
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册