This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/BQ28Z610: How to configure bq28z610 to linux driver (bq27xxx_battery.c)

Part Number: BQ28Z610
Other Parts Discussed in Thread: BQ27010, BQ27000

Tool/software: Linux

Hi Sir,

My project use bq28z610 gauge in android device(linux kernel 4.4). I know bq28z610 gauge driver is bq27xxx_battery.c, but bq28z610 can not met some battery configuration.

So there are some question as below:

1.  In bq27xxx_battery.c, I need to modify configuration flags bit of battery status for definition marco, but I can't match some marco flags bit of battery status with bq28z610 datasheet ( EX : BQ27XXX_FLAG_SOCF , BQ27XXX_FLAG_SOC1, BQ27XXX_FLAG_OTD, BQ27XXX_FLAG_OTC, BQ27XXX_FLAG_UT)

Could you tell me what flags configuration is correction for bq28z610 datasheet.

 

/* BQ27XXX Flags */

#define BQ27XXX_FLAG_DSC       BIT(0)

#define BQ27XXX_FLAG_SOCF      BIT(1) /* State-of-Charge threshold final */

#define BQ27XXX_FLAG_SOC1      BIT(2) /* State-of-Charge threshold 1 */

#define BQ27XXX_FLAG_FC                BIT(9)

#define BQ27XXX_FLAG_OTD       BIT(14)

#define BQ27XXX_FLAG_OTC       BIT(15)

#define BQ27XXX_FLAG_UT                BIT(14)

#define BQ27XXX_FLAG_OT                BIT(15)

 

[bq28z610 datasheet ]


2. I need to add bq28z610 i2c register of battery information, but I could not find out NAC(Nominal Available Capacity) register for i2c communication.  it use in getting battery information of nominal available capacity by received POWER_SUPPLY_PROP_CHARGE_NOW.

Could you tell me what is NAC i2c register on bq28z610 datasheet.

 

/*

* bq27xxx_reg_index - Register names

*

* These are indexes into a device's register mapping array.

*/

enum bq27xxx_reg_index {

        BQ27XXX_REG_CTRL = 0,   /* Control */

        BQ27XXX_REG_TEMP,   /* Temperature */

        BQ27XXX_REG_INT_TEMP,   /* Internal Temperature */

        BQ27XXX_REG_VOLT,   /* Voltage */

        BQ27XXX_REG_AI,     /* Average Current */

        BQ27XXX_REG_FLAGS,  /* Flags */

        BQ27XXX_REG_TTE,    /* Time-to-Empty */

        BQ27XXX_REG_TTF,    /* Time-to-Full */

        BQ27XXX_REG_TTES,   /* Time-to-Empty Standby */

        BQ27XXX_REG_TTECP,  /* Time-to-Empty at Constant Power */

        BQ27XXX_REG_NAC,    /* Nominal Available Capacity */

        BQ27XXX_REG_FCC,    /* Full Charge Capacity */

        BQ27XXX_REG_CYCT,   /* Cycle Count */

        BQ27XXX_REG_AE,     /* Available Energy */

        BQ27XXX_REG_SOC,    /* State-of-Charge */

        BQ27XXX_REG_DCAP,   /* Design Capacity */

        BQ27XXX_REG_AP,     /* Average Power */

        };

 

[The below is added for referece bq28z610 datasheet]

/* [Pegatron][Terry_Tzeng@pegatroncorp.com][2018/02/07] Add BQ28Z610 gauge register - Begin */

static u8 bq28z610_regs[] = {

        0x00,   /* CONTROL  */

        0x06,   /* TEMP     */

        0x28,   /* INT TEMP */

        0x08,   /* VOLT     */

        0x14,   /* AVG CURR     */

        0x0A,   /* FLAGS    */

        0x16,   /* TTE      */

        0x18,   /* TTF      */

        0x1C,   /* TTES     */

        INVALID_REG_ADDR,   /* TTECP - Time-to-Empty at Constant Power  */

        ??,   /* NAC - Nominal Available Capacity */

        0x12,   /* FCC      */

        0x2A,   /* CYCT     */

        INVALID_REG_ADDR,   /* AE - Available Energy    */

        0x2C,   /* SOC      */

        0x3C,   /* DCAP     */

        0x22,   /* AP       */

        };

/* [Pegatron][Terry_Tzeng@pegatroncorp.com][2018/02/07] Add BQ28Z610 gauge register - End */

 

static inline int bq27xxx_battery_read_nac(struct bq27xxx_device_info *di)

{

   int flags;

 

    if (di->chip == BQ27000 || di->chip == BQ27010) {

        flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, true);

        if (flags >= 0 && (flags & BQ27000_FLAG_CI))

            return -ENODATA;

    }

 

    return bq27xxx_battery_read_charge(di, BQ27XXX_REG_NAC);

}

BR, Terry