linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] regmap: Add support for 12/20 register formatting
@ 2020-09-17 11:47 Ricardo Ribalda
  2020-09-17 18:57 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Ricardo Ribalda @ 2020-09-17 11:47 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel
  Cc: Ricardo Ribalda

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: Ricardo Ribalda <ribalda@kernel.org>
---
 drivers/base/regmap/regmap.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index e93700af7e6e..14cdfee4c6ba 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -209,6 +209,18 @@ static bool regmap_volatile_range(struct regmap *map, unsigned int reg,
 	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,
 				     unsigned int reg, unsigned int val)
 {
@@ -867,6 +879,16 @@ struct regmap *__regmap_init(struct device *dev,
 		}
 		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:
 		map->format.format_reg = regmap_format_8;
 		break;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] regmap: Add support for 12/20 register formatting
  2020-09-17 11:47 [PATCH v2] regmap: Add support for 12/20 register formatting Ricardo Ribalda
@ 2020-09-17 18:57 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-09-17 18:57 UTC (permalink / raw)
  To: Ricardo Ribalda, Rafael J. Wysocki, Greg Kroah-Hartman, linux-kernel

On Thu, 17 Sep 2020 13:47:27 +0200, Ricardo Ribalda wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: Add support for 12/20 register formatting
      commit: 0c2191c3da345e0fe73118445ddb1f0df114aadf

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-17 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 11:47 [PATCH v2] regmap: Add support for 12/20 register formatting Ricardo Ribalda
2020-09-17 18:57 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).