[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d2ba6ed1-3a6a-4481-9f43-265eee78c0c1@roeck-us.net>
Date: Sun, 16 Jun 2024 13:26:29 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Armin Wolf <W_Armin@....de>, linux-hwmon@...r.kernel.org
Cc: linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
René Rebe <rene@...ctcode.de>,
Thomas Weißschuh <linux@...ssschuh.net>,
Stephen Horvath <s.horvath@...look.com.au>,
Paul Menzel <pmenzel@...gen.mpg.de>, Sasha Kozachuk <skozachuk@...gle.com>,
John Hamrick <johnham@...gle.com>
Subject: Re: [RFT PATCH] hwmon: (spd5118) Add support for Renesas/ITD SPD5118
hub controllers
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
Powered by blists - more mailing lists