Message ID | 20250621180119.163423-1-macroalpha82@gmail.com |
---|---|
Headers | show |
Series | Add Texas Instruments BQ25703A Charger | expand |
On Sat, Jun 21, 2025 at 01:01:17PM -0500, Chris Morgan wrote: > From: Chris Morgan <macromorgan@hotmail.com> > > Add support for the charger function of the BQ257XX. The device is > capable of charging batteries with a layout of 1 to 4 cells in > series. > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com> > --- [...] > +static void bq257xx_external_power_changed(struct power_supply *psy) > +{ > + struct bq257xx_chg *pdata = power_supply_get_drvdata(psy); > + union power_supply_propval val; > + int ret; > + int imax = pdata->iindpm_max; > + > + pdata->chip->bq257xx_get_state(pdata); > + > + pdata->supplied = power_supply_am_i_supplied(pdata->charger); > + if (pdata->supplied < 0) > + return; > + > + if (pdata->supplied == 0) > + goto out; > + > + ret = power_supply_get_property_from_supplier(psy, > + POWER_SUPPLY_PROP_USB_TYPE, > + &val); > + if (ret) > + return; > + > + pdata->usb_type = val.intval; > + > + if ((pdata->usb_type == POWER_SUPPLY_USB_TYPE_PD) || > + (pdata->usb_type == POWER_SUPPLY_USB_TYPE_PD_DRP) || > + (pdata->usb_type == POWER_SUPPLY_USB_TYPE_PD)) { Duplicated check for POWER_SUPPLY_USB_TYPE_PD. > + ret = power_supply_get_property_from_supplier(psy, > + POWER_SUPPLY_PROP_CURRENT_MAX, > + &val); > + if (ret) > + return; > + > + if (val.intval) > + imax = val.intval; > + } > + > + if (pdata->supplied) { > + pdata->chip->bq257xx_set_ichg(pdata, imax); > + pdata->chip->bq257xx_set_iindpm(pdata, imax); Are you sure about this? ichg and iindpm are two completley separate things. One runs at USB bus voltage and one runs at battery charge voltage. Setting both to the same current limit is a hint that somebody did not understand what they are doing. Otherwise the driver LGTM (apart from the documentation issue reported by the bit of course). Greetings, -- Sebastian
From: Chris Morgan <macromorgan@hotmail.com> Add support for the Texas Instruments BQ25703A charger manager. The device integrates a boost converter with the charger manager. This series adds the device as an MFD with separate regulator and power supply drivers. This allows us to manage a circular dependency with a type-c port manager which depends on the regulator for usb-otg but supplies power to the BQ25703A charger. --- Changes since RFC - Corrected some minor issues with code and device-tree labels. - Replaced most of the manufacturer specific device-tree properties with monitored-battery properties. --- Chris Morgan (5): dt-bindings: mfd: ti,bq25703a: Add TI BQ25703A Charger mfd: bq257xx: Add support for BQ25703A core driver power: supply: bq257xx: Add support for BQ257XX charger manager regulator: bq257xx: Add bq257xx boost regulator driver arm64: dts: rockchip: Add USB and charger to Gameforce Ace .../devicetree/bindings/mfd/ti,bq25703a.yaml | 123 +++ .../dts/rockchip/rk3588s-gameforce-ace.dts | 122 +++ drivers/mfd/Kconfig | 11 + drivers/mfd/Makefile | 1 + drivers/mfd/bq257xx.c | 104 +++ drivers/power/supply/Kconfig | 7 + drivers/power/supply/Makefile | 1 + drivers/power/supply/bq257xx_charger.c | 754 ++++++++++++++++++ drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/bq257xx-regulator.c | 188 +++++ include/linux/mfd/bq257xx.h | 108 +++ 12 files changed, 1428 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/ti,bq25703a.yaml create mode 100644 drivers/mfd/bq257xx.c create mode 100644 drivers/power/supply/bq257xx_charger.c create mode 100644 drivers/regulator/bq257xx-regulator.c create mode 100644 include/linux/mfd/bq257xx.h