Charger / Battery detection


Andy Pont <andy.pont@...>
 

Hello,

Is there standard functionality to build into an image for an i.MX8 that
will allow me to detect, at application level, whether the device is
running on charger, battery, and what the battery level is? Does it
depend on what is used as the PMIC and charging device?

-Andy.


Fabio Estevam
 

Hi Andy,

On Sun, Nov 20, 2022 at 10:36 AM Andy Pont <andy.pont@...> wrote:

Hello,

Is there standard functionality to build into an image for an i.MX8 that
will allow me to detect, at application level, whether the device is
running on charger, battery, and what the battery level is? Does it
depend on what is used as the PMIC and charging device?
Yes, you need a charger device driver. Take a look at
drivers/power/supply/ for some examples.

The charger devices can expose to userspace information as you describe above.

You can check details at:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/ABI/testing/sysfs-class-power?h=v6.0.9

BTW, this is off-topic on this list.