Am 16.06.24 um 22:26 schrieb Guenter Roeck:
Hi Armin,
On 6/16/24 11:09, Armin Wolf wrote:
Am 14.06.24 um 20:59 schrieb Guenter Roeck:
The SPD5118 specification says, in its documentation of the page bits
in the MR11 register:
"
This register only applies to non-volatile memory (1024) Bytes)
access of
SPD5 Hub device.
For volatile memory access, this register must be programmed to '000'.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"
Renesas/ITD SPD5118 hub controllers take this literally and disable
access
to volatile memory if the page selected in MR11 is != 0. Since the
BIOS or
ROMMON will access the non-volatile memory and likely select a page
!= 0,
this means that the driver will not instantiate since it can not
identify
the chip. Even if the driver instantiates, access to volatile registers
is blocked after a nvram read operation which selects a page other
than 0.
To solve the problem, add initialization code to select page 0 during
probe. Before doing that, use basic validation to ensure that this is
really a SPD5118 device and not some random EEPROM. Explicitly select
page 0 when accessing the volatile register space, and protect volatile
register access against nvmem access using the device mutex.
Hi,
maybe we can use struct regmap_range_cfg so the paged register
accesses are being
done by the regmap code itself?
In theory that might work, but regmap does not permit a selector
register to
be part of another range. The first range would be the non-volatile
registers,
and the selector register is part of that for all ranges.
I tried the following ranges configuration.
static const struct regmap_range_cfg spd5118_regmap_range_cfg[] = {
{
.selector_reg = SPD5118_REG_I2C_LEGACY_MODE,
.selector_mask = SPD5118_LEGACY_PAGE_MASK,
.selector_shift = 0,
.window_start = 0,
.window_len = SPD5118_PAGE_SIZE,
.range_min = 0,
.range_max = SPD5118_PAGE_SIZE - 1,
},
{
.selector_reg = SPD5118_REG_I2C_LEGACY_MODE,
.selector_mask = SPD5118_LEGACY_PAGE_MASK,
.selector_shift = 0,
.window_start = SPD5118_PAGE_SIZE,
.window_len = SPD5118_PAGE_SIZE,
.range_min = SPD5118_PAGE_SIZE,
.range_max = 9 * SPD5118_PAGE_SIZE - 1,
},
};
This results in
spd5118 0-0050: Range 0: selector for 1 in window
spd5118 0-0050: error -EINVAL: regmap init failed
If you have an idea how to configure the ranges differently,
please let me know.
Thanks,
Guenter
Oh, i did not think of this. In this case we indeed cannot use regmap here. I will test the patch tomorrow.
Thanks,
Armin Wolf