linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* regmap-mmio and paged registers
@ 2015-12-09 21:41 Alexandre Belloni
  2015-12-09 22:10 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2015-12-09 21:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mark,

On AT91, we have a paged register inside a register range.

This register looks like that:

AT91_PMC_PCR:
   31   30   29   28   27   26   25   24
 +----+----+----+----+----+----+----+----+
 | -- | -- | -- | EN | -- | -- | -- | -- |
 +----+----+----+----+----+----+----+----+

   23   22   21   20   19   18   17   16
 +----+----+----+----+----+----+----+----+
 | -- | -- | -- | -- | -- | -- |   DIV   |
 +----+----+----+----+----+----+----+----+

   15   14   13   12   11   10   09   08
 +----+----+----+----+----+----+----+----+
 | -- | -- | -- |CMD | -- | -- | -- | -- |
 +----+----+----+----+----+----+----+----+

   07   06   05   04   03   02   01   00
 +----+----+----+----+----+----+----+----+
 | -- | -- |             PID             |
 +----+----+----+----+----+----+----+----+

PID is our selector, the other bits are the data.

We described the regmap by creating a virtual range:

#define AT91_PMC_VIRT_PCR(id)	(0x200 + id)

static const struct regmap_range_cfg pmc_regmap_ranges[] = {
	{
		.range_min = AT91_PMC_VIRT_PCR(0),
		.range_max = AT91_PMC_VIRT_PCR(AT91_PMC_PCR_PID_MASK),
		.window_start = AT91_PMC_PCR,
		.window_len = 1,
		.selector_reg = AT91_PMC_PCR,
		.selector_mask = 0xffffffff,
	},
};

static struct regmap_config at91sam9x5_pmc_regmap_config = {
	.reg_bits = 32,
	.val_bits = 32,
	.reg_stride = 4,
	.ranges = pmc_regmap_ranges,
	.num_ranges = ARRAY_SIZE(pmc_regmap_ranges),
	.max_register = AT91_PMC_VIRT_PCR(AT91_PMC_PCR_PID_MASK),
};

The issue we have with that setup is that _regmap_select_page() does
that check before writing the page number:

	/* It is possible to have selector register inside data window.
	   In that case, selector register is located on every page and
	   it needs no page switching, when accessed alone. */
	if (val_num > 1 ||
	    range->window_start + win_offset != range->selector_reg) {

So it ends up never writing the page number in the register.

One possible solution would be to implement our own .read and .write to
handle that paging but maybe you can think of something else.


The full datasheet is here, 27.16.26 PMC Peripheral Control Register,
page 270
http://www.atmel.com/Images/Atmel-11121-32-bit-Cortex-A5-Microcontroller-SAMA5D3_Datasheet.pdf

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

end of thread, other threads:[~2015-12-16 11:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-09 21:41 regmap-mmio and paged registers Alexandre Belloni
2015-12-09 22:10 ` Mark Brown
2015-12-09 22:26   ` Alexandre Belloni
2015-12-16 11:38     ` Mark Brown

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).