linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antoniu Miclaus <antoniu.miclaus@analog.com>
To: <linux-kernel@vger.kernel.org>
Cc: <broonie@kernel.org>, <gregkh@linuxfoundation.org>,
	<rafael@kernel.org>, Antoniu Miclaus <antoniu.miclaus@analog.com>,
	Andrei Drimbarean <andrei.drimbarean@analog.com>
Subject: [PATCH] regmap: add support for 7/17 register formating
Date: Wed, 26 May 2021 11:52:24 +0300	[thread overview]
Message-ID: <20210526085223.14896-1-antoniu.miclaus@analog.com> (raw)

This patch adds support for 7 bits register, 17 bits value type register
formating. This is used, for example, by the Analog Devices
ADMV1013/ADMV1014.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Andrei Drimbarean <andrei.drimbarean@analog.com>
---
 drivers/base/regmap/regmap.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 19f57ccfbe1d..bc1c36b93c15 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -230,6 +230,16 @@ static void regmap_format_7_9_write(struct regmap *map,
 	*out = cpu_to_be16((reg << 9) | val);
 }
 
+static void regmap_format_7_17_write(struct regmap *map,
+				    unsigned int reg, unsigned int val)
+{
+	u8 *out = map->work_buf;
+
+	out[2] = val;
+	out[1] = val >> 8;
+	out[0] = (val >> 16) | (reg << 1);
+}
+
 static void regmap_format_10_14_write(struct regmap *map,
 				    unsigned int reg, unsigned int val)
 {
@@ -864,6 +874,9 @@ struct regmap *__regmap_init(struct device *dev,
 		case 9:
 			map->format.format_write = regmap_format_7_9_write;
 			break;
+		case 17:
+			map->format.format_write = regmap_format_7_17_write;
+			break;
 		default:
 			goto err_hwlock;
 		}
-- 
2.25.1


             reply	other threads:[~2021-05-26  8:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26  8:52 Antoniu Miclaus [this message]
2021-05-26 20:21 ` [PATCH] regmap: add support for 7/17 register formating Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210526085223.14896-1-antoniu.miclaus@analog.com \
    --to=antoniu.miclaus@analog.com \
    --cc=andrei.drimbarean@analog.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).