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.

How to integrate Bq24725 and MAX172011G ICs into Kernel/Android 9?

Other Parts Discussed in Thread: BQ24725, BQ24257

Hi everyone,

We are using Bq24725 and MAX172011G to design charging and power management circuits for our NXP IMX8M processor board running Android 9. Anyone can guide me to integrate components of the operating system Android 9 (Kernel) to interact with these two ICs: device tree, sample code ... 

How can I show the percentage of battery from the outputs of these two ICs on Android / Linux operating system?

Pin connection between these IC and IMX8M processor is as follows:

Bq24725

SoC IMX8M

I2c_sda         

I2c_sda4

I2c_scl

I2c_scl4

ACOK

GPIO1_15

IOUT

GPIO1_13

MAX172011G

SoC IMX8M

I2c_sda         

I2c_sda4

I2c_scl

I2c_scl4

ALRT1

SAI5_MCLK (GPIO3_25)

Best Regards,

Thanks!

  • Luc,

    We do have a driver for BQ24725 that was developed for kernel 4.4 (this should play nicely with Android 9). The charger and driver are not capable of reporting battery percentage as the IC is not capable of determining battery percentage. I have provided the link to the commit and patch below:

    https://git.ti.com/gitweb?p=bms-linux/bms-kernel-4-4.git;a=commit;h=0b49522b0e11fc9f67d091998d5fc62af3ab5ec8

    The Maxim fuel gauge you have mentioned should be able to report battery percentages, but we do not offer support for Maxim products. We do offer support and drivers for many of our TI fuel gauges. Please create a new thread with the TI battery gauge team if you would like to know more about TI's battery gauge ICs.

    I hope this resolves your issue,

    Ricardo

  • Hi Ricardo,

    I am viewing the document file in the linux kernel elixir.bootlin.com/.../bq24257.txt
    I am wondering, to communicate with the IC through this driver, do I have to declare anything in the kernel device tree? An example paragraph in this tutorial is as follows:
    bq24257 {
    compatible = "ti, bq24257";
    reg = <0x6a>;
    interrupt-parent = <& gpio1>;
    interrupts = <16 IRQ_TYPE_EDGE_BOTH>;

    pg-gpios = <& gpio1 28 GPIO_ACTIVE_HIGH>;

    ti, battery-regulation-voltage = <4200000>;
    ti, charge-current = <1000000>;
    ti, termination-current = <50000>;
    };

    Thank you very much for your help!

    Best regards

  • Luc,

    You are correct. Looking at the code below you can see that the driver looks for ti,ac-detect-gpios, ti,charge-current, ti,charge-voltage, ti,input-current, and ti,enable-wdt in the devicetree. You can follow the example you have posted, but remove pg-gpios (replace with ti,ac-detect-gpios), remove ti,battery-regulation-voltage (replace with ti,charge-voltage), and remove ti,termination-current.

    449 static struct bq24725_platform *bq24725_parse_dt_data(struct i2c_client *client)
    451         struct bq24725_platform *pdata;
    452         struct device_node *np = client->dev.of_node;
    453         u32 val;
    454         int ret;
    455         enum of_gpio_flags flags;
    457         pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
    458         if (!pdata) {
    459                 dev_err(&client->dev,
    460                         "Memory alloc for bq24725 pdata failed\n");
    461                 return NULL;
    462         }
    464         pdata->status_gpio = of_get_named_gpio_flags(np, "ti,ac-detect-gpios",
    465                                                      0, &flags);
    467         if (flags & OF_GPIO_ACTIVE_LOW)
    468                 pdata->status_gpio_active_low = 1;
    470         ret = of_property_read_u32(np, "ti,charge-current", &val);
    471         if (!ret)
    472                 pdata->charge_current = val;
    474         ret = of_property_read_u32(np, "ti,charge-voltage", &val);
    475         if (!ret)
    476                 pdata->charge_voltage = val;
    478         ret = of_property_read_u32(np, "ti,input-current", &val);
    479         if (!ret)
    480                 pdata->input_current = val;
    482         pdata->enable_wdt = of_property_read_bool(np, "ti,enable-wdt");
    484         return pdata;
    I hope this resolves your issue,
    Ricardo