drivers/base/regmap: Implementation for regmap_multi_reg_write
Subsystems (2)
RFC v3 1/1 drivers/base/regmap: Implementation for regmap_multi_reg_write
This is the implementation of regmap_multi_reg_write()
There is a new capability 'can_multi_write' that device drivers must set in order to use this multi reg write mode.
This replaces the first definition, which just defined the API.
---
This patch is relative to linux-next repository tag next-20140304
This 3rd RFC attempt adds a 'can_multi_write' config capability, that is initialized by a device driver through regmap_init(). If a driver making a call to regmap_multi_reg_write() has not previously set the 'can_multi_write' config capability then the implementation will just change the transfer to a sequence of single register writes.
If there is a different or better way to advertise a device capability please respond to this RFC.
The API definition of regmap_multi_reg_write() has been in the kernel mainline since v3.13. This patch suggests an implementation that works for DA9052 family of PMIC chips from Dialog Semiconductor.
This implementation will work in the presense of register ranges because the algorithm will chop the set of (reg,val) changes each time the page changes. This part of the algorithm will be need for other Dialog PMIC that both need to use the Multi Register Write mode and use paged registers.
The big difference between this attempt and V1 is that the set of (reg,val) changes are now treated as 'const ...' and the simplest option of doing a pre pass to catch possible register changes to page relative is done so that in-situ changes can be made to an kalloc'ed copy.
A minor change is moving knowledge of the range structure from _regmap_range_multi_paged_reg_write() to a new static function _regmap_register_page(). Specifically the function _regmap_select_page() will send an I2C command if the register is in a new page, whereas the algorothm needs to know in advance when the page is going to change so that the fragment of multi register writes can be sent out to the I2C device.
Please feel free to comment on this implementation. This patch has only had limited testing with a DA9053 chip so the real attempt to submit into the MainLine will come later giving any reviewer ample time to make constructive comments.
drivers/base/regmap/internal.h | 2 + drivers/base/regmap/regmap.c | 188 ++++++++++++++++++++++++++++++++++++---- include/linux/regmap.h | 4 + 3 files changed, 178 insertions(+), 16 deletions(-)
drivers/base/regmap/internal.h +2 -0
@@ -134,6 +134,8 @@ struct regmap {/* if set, converts bulk rw to single rw */ bool use_single_rw; +/* if set, the device supports multi write mode */ +bool can_multi_write;struct rb_root range_tree;void *selector_work_buf;/* Scratch buffer used for selector */
drivers/base/regmap/regmap.c +172 -16
219 lines not on this page · raw message
include/linux/regmap.h +4 -0
@@ -164,6 +164,9 @@ typedef void (*regmap_unlock)(void *);* @use_single_rw: If set, converts the bulk read and write operations into * a series of single read and write operations. This is useful * for device that does not support bulk read and write. +* @can_multi_write: If set, the device supports the multi write mode of bulk +* write operations, if clear multi write requests will be +* split into individual write operations * * @cache_type: The actual cache type. * @reg_defaults_raw: Power on reset values for registers (for use with
@@ -215,6 +218,7 @@ struct regmap_config {u8 write_flag_mask;bool use_single_rw; +bool can_multi_write;enum regmap_endian reg_format_endian;enum regmap_endian val_format_endian;
Signature · 1 line
end-of-rfc 1/1 for drivers/base/regmap: Implementation for regmap_multi_reg_write V3
Quoted 4 lines · Opensource [Anthony Olech]
This is the implementation of
regmap_multi_reg_write()There is a new capability '
can_multi_write' that device drivers must set in order to use this multi reg write mode.
Applied, thanks. Please use subject lines consistent with the general style for the subsystem.