Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1214346 > unrolled thread
| Started by | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| First post | 2015-08-27 08:50 +0200 |
| Last post | 2015-08-29 11:40 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v3 0/4] regmap: i2c block support Markus Pargmann <mpa@pengutronix.de> - 2015-08-27 08:50 +0200
[PATCH v3 4/4] regmap-i2c: Add smbus i2c block support Markus Pargmann <mpa@pengutronix.de> - 2015-08-27 08:50 +0200
Re: [PATCH v3 0/4] regmap: i2c block support Mark Brown <broonie@kernel.org> - 2015-08-28 19:40 +0200
Re: [PATCH v3 0/4] regmap: i2c block support Mark Brown <broonie@kernel.org> - 2015-08-29 11:40 +0200
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-27 08:50 +0200 |
| Subject | [PATCH v3 0/4] regmap: i2c block support |
| Message-ID | <q1Zay-524-7@gated-at.bofh.it> |
Hi, This series adds support for i2c block read/writes. To support the maximum 32 byte read/write operations, the regmap core is extended by max_raw_read and max_raw_write. bulk operations are splitted depending of the size of max_raw_read/write. The last patch needs testing before it can be applied. Best Regards, Markus Changes in v3: - Rebased onto latest version of "regmap: fixes" series Changes in v2: - max_raw_io splitted into max_raw_read/write - Use E2BIG as error value in the block read/write functions Markus Pargmann (4): regmap: Introduce max_raw_read/write for regmap_bulk_read/write regmap: regmap max_raw_read/write getter functions regmap: Add raw_write/read checks for max_raw_write/read sizes regmap-i2c: Add smbus i2c block support drivers/base/regmap/internal.h | 4 ++ drivers/base/regmap/regmap-i2c.c | 49 +++++++++++++++++ drivers/base/regmap/regmap.c | 113 +++++++++++++++++++++++++++++++++------ include/linux/regmap.h | 6 +++ 4 files changed, 157 insertions(+), 15 deletions(-) -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Markus Pargmann <mpa@pengutronix.de> |
|---|---|
| Date | 2015-08-27 08:50 +0200 |
| Subject | [PATCH v3 4/4] regmap-i2c: Add smbus i2c block support |
| Message-ID | <q1Zaz-524-31@gated-at.bofh.it> |
| In reply to | #1214346 |
This allows to read/write up to 32 bytes of data and is to be prefered
if supported before the register read/write smbus support.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
drivers/base/regmap/regmap-i2c.c | 49 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/drivers/base/regmap/regmap-i2c.c b/drivers/base/regmap/regmap-i2c.c
index 4b76e33110a2..ddb9b0efb724 100644
--- a/drivers/base/regmap/regmap-i2c.c
+++ b/drivers/base/regmap/regmap-i2c.c
@@ -209,11 +209,60 @@ static struct regmap_bus regmap_i2c = {
.val_format_endian_default = REGMAP_ENDIAN_BIG,
};
+static int regmap_i2c_smbus_i2c_write(void *context, const void *data,
+ size_t count)
+{
+ struct device *dev = context;
+ struct i2c_client *i2c = to_i2c_client(dev);
+
+ if (count < 1)
+ return -EINVAL;
+ if (count >= I2C_SMBUS_BLOCK_MAX)
+ return -E2BIG;
+
+ --count;
+ return i2c_smbus_write_i2c_block_data(i2c, ((u8 *)data)[0], count,
+ ((u8 *)data + 1));
+}
+
+static int regmap_i2c_smbus_i2c_read(void *context, const void *reg,
+ size_t reg_size, void *val,
+ size_t val_size)
+{
+ struct device *dev = context;
+ struct i2c_client *i2c = to_i2c_client(dev);
+ int ret;
+
+ if (reg_size != 1 || val_size < 1)
+ return -EINVAL;
+ if (val_size >= I2C_SMBUS_BLOCK_MAX)
+ return -E2BIG;
+
+ ret = i2c_smbus_read_i2c_block_data(i2c, ((u8 *)reg)[0], val_size, val);
+ if (ret == val_size)
+ return 0;
+ else if (ret < 0)
+ return ret;
+ else
+ return -EIO;
+}
+
+static struct regmap_bus regmap_i2c_smbus_i2c_block = {
+ .write = regmap_i2c_smbus_i2c_write,
+ .read = regmap_i2c_smbus_i2c_read,
+ .max_raw_read = I2C_SMBUS_BLOCK_MAX,
+ .max_raw_write = I2C_SMBUS_BLOCK_MAX,
+};
+
static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c,
const struct regmap_config *config)
{
if (i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C))
return ®map_i2c;
+ else if (config->reg_bits == 8 &&
+ i2c_check_functionality(i2c->adapter,
+ I2C_FUNC_SMBUS_I2C_BLOCK))
+ return ®map_i2c_smbus_i2c_block;
else if (config->val_bits == 16 && config->reg_bits == 8 &&
i2c_check_functionality(i2c->adapter,
I2C_FUNC_SMBUS_WORD_DATA))
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2015-08-28 19:40 +0200 |
| Message-ID | <q2vN8-1Ec-19@gated-at.bofh.it> |
| In reply to | #1214346 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Aug 27, 2015 at 08:44:28AM +0200, Markus Pargmann wrote: > Changes in v3: > - Rebased onto latest version of "regmap: fixes" series New code not intended as bug fixes needs to apply against the latest development code, not a fixes branch (and especially not some out of tree patch series which may have ended up in multiple branches or something). git says it doesn't know what you generated this against...
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2015-08-29 11:40 +0200 |
| Message-ID | <q2KM9-6gM-1@gated-at.bofh.it> |
| In reply to | #1214346 |
[Multipart message — attachments visible in raw view] — view raw
On Thu, Aug 27, 2015 at 08:44:28AM +0200, Markus Pargmann wrote: > Hi, > > This series adds support for i2c block read/writes. To support the maximum 32 > byte read/write operations, the regmap core is extended by max_raw_read and > max_raw_write. bulk operations are splitted depending of the size of > max_raw_read/write. ...and reverted because it broke the build, probably because it was not a patch against current development trees: http://kernelci.org/build/broonie-regmap/kernel/v4.2-rc8-34-gd535ae53edec/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web