Re: [PATCH 1/3] power: supply: bq25890_charger: Add support of BQ25892 and BQ25896 chips

From: Sebastian Reichel
Date: Wed Jan 15 2020 - 15:51:00 EST


Hi,

Thanks, queued to power-supply's for-next branch.

On Thu, Jan 02, 2020 at 04:53:35PM +0300, Yauhen Kharuzhy wrote:
> On Thu, Jan 02, 2020 at 01:46:25AM +0300, Yauhen Kharuzhy wrote:
> > Support BQ25892 and BQ25896 chips by this driver. They shared one chip
> > ID 0, so distinquish them by device revisions (2 for 25896 and 1 for
> > 25892).
> >
> > Signed-off-by: Yauhen Kharuzhy <jekhor@xxxxxxxxx>
> > ---
> > drivers/power/supply/bq25890_charger.c | 97 ++++++++++++++++++++------
> > 1 file changed, 76 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
> > index 9d1ec8d677de..a3dcd4eb1287 100644
> > --- a/drivers/power/supply/bq25890_charger.c
> > +++ b/drivers/power/supply/bq25890_charger.c
> > @@ -25,12 +25,20 @@
> > #define BQ25895_ID 7
> > #define BQ25896_ID 0
> >
> > +enum bq25890_chip_version {
> > + BQ25890,
> > + BQ25892,
> > + BQ25895,
> > + BQ25896,
> > +};
> > +
> ...
> > +static int bq25890_get_chip_version(struct bq25890_device *bq)
> > +{
> > + int id, rev;
> > +
> > + id = bq25890_field_read(bq, F_PN);
> > + if (id < 0) {
> > + dev_err(bq->dev, "Cannot read chip ID.\n");
> > + return id;
> > + }
> > +
> > + rev = bq25890_field_read(bq, F_DEV_REV);
> > + if (rev < 0) {
> > + dev_err(bq->dev, "Cannot read chip revision.\n");
> > + return id;
> > + }
> > +
> > + switch (id) {
> > + case BQ25890_ID:
> > + bq->chip_version = BQ25890;
> > + break;
> > +
> > + /* BQ25892 and BQ25896 share same ID 0 */
> > + case BQ25896_ID:
> > + switch (rev) {
> > + case 0:
> Sorry, typo here: should be 2 for 25896, I will fix this in v2.

I fixed this while applying.

-- Sebastian

> > + bq->chip_version = BQ25896;
> > + break;
> > + case 1:
> > + bq->chip_version = BQ25892;
> > + break;
> > + default:
> > + dev_err(bq->dev,
> > + "Unknown device revision %d, assume BQ25892\n",
> > + rev);
> > + bq->chip_version = BQ25892;
> > + }
> > + break;
> > +
> > + case BQ25895_ID:
> > + bq->chip_version = BQ25895;
> > + break;
> > +
> > + default:
> > + dev_err(bq->dev, "Unknown chip ID %d\n", id);
> > + return -ENODEV;
> > + }
> > +
> > + return 0;
> > +}
> ...
>
> --
> Yauhen Kharuzhy

Attachment: signature.asc
Description: PGP signature