From: alexandre.belloni@free-electrons.com (Alexandre Belloni)
To: linux-arm-kernel@lists.infradead.org
Subject: regmap-mmio and paged registers
Date: Wed, 9 Dec 2015 22:41:50 +0100 [thread overview]
Message-ID: <20151209214150.GH3515@piout.net> (raw)
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
next reply other threads:[~2015-12-09 21:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-09 21:41 Alexandre Belloni [this message]
2015-12-09 22:10 ` regmap-mmio and paged registers Mark Brown
2015-12-09 22:26 ` Alexandre Belloni
2015-12-16 11:38 ` Mark Brown
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=20151209214150.GH3515@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).