From: Marc Reilly <marc@cpdesign.com.au>
To: sameo@linux.intel.com
Cc: linux-arm-kernel@lists.infradead.org,
spi-devel-general@lists.sourceforge.net,
linux-i2c@vger.kernel.org, u.kleine-koenig@pengutronix.de,
oskar@scara.com, linux-kernel@vger.kernel.org,
broonie@opensource.wolfsonmicro.com,
Marc Reilly <marc@cpdesign.com.au>
Subject: [PATCH v3 2/6] regmap: Add support for device with 24 data bits.
Date: Thu, 15 Mar 2012 07:43:06 +1100 [thread overview]
Message-ID: <1331757790-10583-3-git-send-email-marc@cpdesign.com.au> (raw)
In-Reply-To: <1331757790-10583-1-git-send-email-marc@cpdesign.com.au>
Add support for devices with 24 data bits.
Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
---
drivers/base/regmap/regmap.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 62ef0df..880e3a0 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -122,6 +122,15 @@ static void regmap_format_16(void *buf, unsigned int val)
b[0] = cpu_to_be16(val);
}
+static void regmap_format_24(void *buf, unsigned int val)
+{
+ u8 *b = buf;
+
+ b[0] = val >> 16;
+ b[1] = val >> 8;
+ b[2] = val;
+}
+
static unsigned int regmap_parse_8(void *buf)
{
u8 *b = buf;
@@ -138,6 +147,16 @@ static unsigned int regmap_parse_16(void *buf)
return b[0];
}
+static unsigned int regmap_parse_24(void *buf)
+{
+ u8 *b = buf;
+ unsigned int ret = b[2];
+ ret |= ((unsigned int)b[1]) << 8;
+ ret |= ((unsigned int)b[0]) << 16;
+
+ return ret;
+}
+
/**
* regmap_init(): Initialise register map
*
@@ -240,6 +259,10 @@ struct regmap *regmap_init(struct device *dev,
map->format.format_val = regmap_format_16;
map->format.parse_val = regmap_parse_16;
break;
+ case 24:
+ map->format.format_val = regmap_format_24;
+ map->format.parse_val = regmap_parse_24;
+ break;
}
if (!map->format.format_write &&
--
1.7.3.4
next prev parent reply other threads:[~2012-03-14 21:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-14 20:43 mc13xxx: add I2C support (now with regmap), V3 Marc Reilly
2012-03-14 20:43 ` [PATCH v3 1/6] regmap: add support for 7_25 format Marc Reilly
2012-03-15 10:44 ` Mark Brown
2012-03-14 20:43 ` Marc Reilly [this message]
2012-03-15 10:46 ` [PATCH v3 2/6] regmap: Add support for device with 24 data bits Mark Brown
2012-03-14 20:43 ` [PATCH v3 3/6] mfd: mc13xxx-core: Prepare for separate spi and i2c backends Marc Reilly
2012-03-14 20:43 ` [PATCH v3 4/6] mfd: mc13xxx-core: use regmap for register access Marc Reilly
2012-03-15 17:43 ` Mark Brown
2012-03-14 20:43 ` [PATCH v3 5/6] mfd: mc13xxx-core: Move spi specific code into separate module Marc Reilly
2012-03-14 20:43 ` [PATCH v3 6/6] mfd: mc13xxx: Add i2c driver Marc Reilly
2012-03-14 22:15 ` Fabio Estevam
2012-03-15 13:40 ` Shubhrajyoti Datta
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=1331757790-10583-3-git-send-email-marc@cpdesign.com.au \
--to=marc@cpdesign.com.au \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oskar@scara.com \
--cc=sameo@linux.intel.com \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=u.kleine-koenig@pengutronix.de \
/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
all inboxes | Powered by JetHome®