mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] regmap: core: allow a virtual range to cover its own data window
@ 2013-07-23 10:16 Philipp Zabel
  2013-08-06 17:32 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Philipp Zabel @ 2013-07-23 10:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Philipp Zabel

I see no reason why a virtual range shouldn't be allowed to cover its
own data window if the page selection register is in the same place
on every page.
For chips which use paged access for all of their registers, but only
when connected via I2C, and which can access the whole register space
directly when connected via SPI, this allows to avoid acrobatics with
the register ranges by simply mapping the I2C ranges over the data
window beginning at 0x0, and then using linear access for the SPI
variant.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

---
I am looking at DA9063, which could use the following range
configuration for the I2C variant:

	struct regmap_range_cfg da9063_i2c_regmap_ranges[] = {
		{
			.range_min = 0x00,
			.range_max = 0x1ff,
			.selector_reg = 0x00,
			.selector_mask = 0x03,
			.selector_shift = 1,
			.window_start = 0x00,
			.window_len = 0x100,
		},
	};

	/* no da9063_spi_regmap_ranges needed */
---
 drivers/base/regmap/regmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 9592058..1205d8c 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -687,6 +687,10 @@ skip_format_initialization:
 			unsigned win_max = win_min +
 					   config->ranges[j].window_len - 1;
 
+			/* Allow data window inside its own virtual range */
+			if (j == i)
+				continue;
+
 			if (range_cfg->range_min <= sel_reg &&
 			    sel_reg <= range_cfg->range_max) {
 				dev_err(map->dev,
-- 
1.8.3.2


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

* Re: [RFC] regmap: core: allow a virtual range to cover its own data window
  2013-07-23 10:16 [RFC] regmap: core: allow a virtual range to cover its own data window Philipp Zabel
@ 2013-08-06 17:32 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-08-06 17:32 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

On Tue, Jul 23, 2013 at 12:16:02PM +0200, Philipp Zabel wrote:
> I see no reason why a virtual range shouldn't be allowed to cover its
> own data window if the page selection register is in the same place
> on every page.

So, this feature is clearly sensible and in fact the thing that was
concerning me was what happened when we try to do the selection but
looking at the code I see that there's already handling of that so I'm
not sure why the validation stuff wasn't permitting it.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-08-06 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 10:16 [RFC] regmap: core: allow a virtual range to cover its own data window Philipp Zabel
2013-08-06 17:32 ` Mark Brown

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®