On Sun, Nov 07, 2021 at 10:07:27PM +0300, Yauhen Kharuzhy wrote: > On Sat, Oct 30, 2021 at 08:28:11PM +0200, Hans de Goede wrote: > > The i2c-controller on the Cherry Trail - Whiskey Cove PMIC is special > > in that it is always connected to the I2C charger IC of the board on > > which the PMIC is used; and the charger IC is not described in ACPI, > > so the i2c-cht-wc code needs to instantiate an i2c-client for it itself. > > > > So far there has been a rudimentary check to make sure the ACPI tables > > are at least somewhat as expected by checking for the presence of an > > INT33FE device and sofar the code has assumed that if this INT33FE > > device is present that the used charger then is a bq24290i. > > > > But some boards with an INT33FE device in their ACPI tables use a > > different charger IC and some boards don't have an INT33FE device at all. > > > > Since the information about the used charger + fuel-gauge + other chips is > > necessary in other places too, the kernel now adds a "intel,cht-wc-setup" > > string property to the Whiskey Cove PMIC i2c-client based on DMI matching, > > which reliably describes the board's setup of the PMIC. > > > > Switch to using the "intel,cht-wc-setup" property and add support for > > instantiating an i2c-client for either a bq24292i or a bq25890 charger. > > > > This has been tested on a GPD pocket (which uses the old bq24292i setup) > > and on a Xiaomi Mi Pad 2 with a bq25890 charger. > > > > Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx> > > --- > > drivers/i2c/busses/i2c-cht-wc.c | 77 +++++++++++++++++++++++++-------- > > 1 file changed, 59 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c > > index 1cf68f85b2e1..e7d62af6c39d 100644 > > --- a/drivers/i2c/busses/i2c-cht-wc.c > > +++ b/drivers/i2c/busses/i2c-cht-wc.c > > @@ -18,6 +18,7 @@ > > #include <linux/module.h> > > #include <linux/platform_device.h> > > #include <linux/power/bq24190_charger.h> > > +#include <linux/power/bq25890_charger.h> > > #include <linux/slab.h> > > > > #define CHT_WC_I2C_CTRL 0x5e24 > > @@ -304,18 +305,55 @@ static struct bq24190_platform_data bq24190_pdata = { > > .regulator_init_data = &bq24190_vbus_init_data, > > }; > > > > +static struct i2c_board_info bq24190_board_info = { > > + .type = "bq24190", > > + .addr = 0x6b, > > + .dev_name = "bq24190", > > + .swnode = &bq24190_node, > > + .platform_data = &bq24190_pdata, > > +}; > > + > > +static struct regulator_consumer_supply bq25890_vbus_consumer = { > > + .supply = "vbus", > > + .dev_name = "cht_wcove_pwrsrc", > > +}; > > + > > +static const struct regulator_init_data bq25890_vbus_init_data = { > > + .constraints = { > > + .valid_ops_mask = REGULATOR_CHANGE_STATUS, > > + }, > > + .consumer_supplies = &bq25890_vbus_consumer, > > + .num_consumer_supplies = 1, > > +}; > > + > > +static struct bq25890_platform_data bq25890_pdata = { > > + .regulator_init_data = &bq25890_vbus_init_data, > > +}; > > + > > +static const struct property_entry bq25890_props[] = { > > + PROPERTY_ENTRY_BOOL("ti,skip-init"), > > + { } > > +}; > > The Lenovo Yoga Book firmware set the IINLIM field to 500 mA at > initialization, we need a way to pass maximum allowed current in the fast > charging mode to driver. I have added 'ti,input-max-current' in my port, for > example. ICHG (charging current limit) is too low also (2A versus 4A in Android sources for this device), so it should be set by properties. -- Yauhen Kharuzhy