public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Yauhen Kharuzhy <jekhor@gmail.com>
To: linux-pm@vger.kernel.org
Cc: Sebastian Reichel <sre@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] power: supply: bq25890_charger: Add support of BQ25892 and BQ25896 chips
Date: Thu, 2 Jan 2020 16:53:35 +0300	[thread overview]
Message-ID: <20200102135335.GA13218@jeknote.loshitsa1.net> (raw)
In-Reply-To: <20200101224627.12093-1-jekhor@gmail.com>

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@gmail.com>
> ---
>  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.

> +			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

  parent reply	other threads:[~2020-01-02 13:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-01 22:46 [PATCH 1/3] power: supply: bq25890_charger: Add support of BQ25892 and BQ25896 chips Yauhen Kharuzhy
2020-01-01 22:46 ` [PATCH 2/3] power: supply: bq25890_charger: Add DT and I2C ids for all supported chips Yauhen Kharuzhy
2020-01-01 22:46 ` [PATCH 3/3] dt-bindings: Add new chips to bq25890 binding documentation Yauhen Kharuzhy
2020-01-08 16:51   ` Rob Herring
2020-01-02 13:53 ` Yauhen Kharuzhy [this message]
2020-01-15 20:50   ` [PATCH 1/3] power: supply: bq25890_charger: Add support of BQ25892 and BQ25896 chips Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200102135335.GA13218@jeknote.loshitsa1.net \
    --to=jekhor@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox