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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux