Re: regmap I3C support
From: Guenter Roeck
Date: Fri Nov 15 2024 - 01:58:17 EST
On Thu, Nov 14, 2024 at 05:26:19PM +0000, Mark Brown wrote:
> On Thu, Nov 14, 2024 at 06:45:52AM -0800, Guenter Roeck wrote:
>
> > We now use
>
> > config SENSORS_TMP108
> > tristate "Texas Instruments TMP108"
> > depends on I2C
> > depends on I3C || !I3C
> > select REGMAP_I2C
> > select REGMAP_I3C if I3C
>
> > and in the i3c_probe function
>
> > #ifdef CONFIG_REGMAP_I3C
> > regmap = devm_regmap_init_i3c(i3cdev, &tmp108_regmap_config);
> > #else
> > regmap = ERR_PTR(-ENODEV);
> > #endif
> > if (IS_ERR(regmap))
>
> > Clumsy, and not my preferred solution, but it works.
>
> Right, so the fact that I3C depends on I2C deals with a lot of the
> problems that plague the I2C/SPI combination. Ugh. I guess the helper
> should be OK and there's not much doing for I2C/SPI.
Is it really that difficult for I2C and SPI ? The patch below seems to work
for the LTC2947 driver. It doesn't even need dummies (the compiler drops
the unused code), though I am not sure if that can be relied on. I thought
that dummy functions are needed, but maybe I am wrong.
The Kconfig for the combined ltc2947 driver is
config SENSORS_LTC2947
tristate "Analog Devices LTC2947 High Precision Power and Energy Monitor"
depends on I2C || SPI
depends on I2C || I2C=n
select REGMAP_I2C if I2C
select REGMAP_SPI if SPI
help
...
Guenter
---