clockworkpi / uConsole

This code repository offers downloads for the latest images of various uConsole models, along with kernel patches, firmware for the keyboard and 4G expansion module, hardware schematics, assembly instructions, and essential technical documents.
276 stars 42 forks source link

Fix Battery Charge Current in PMU Devicetree Overlay #19

Closed mikemacwillie closed 2 months ago

mikemacwillie commented 3 months ago

This change fixes a small error in the devicetree overlay for the PMIC, which was causing battery charge current to be set to the default of 300mA rather than the desired 2.1A.

elkoniu commented 3 months ago

@mikemacwillie I did some testing and everything looks fine in my opinion, see the details bellow.

Vanilla image I used: http://dl.clockworkpi.com/uConsole_CM4_v0.1b_xfce_64bit.img.7z

Battery details:

cpi@raspberrypi:~ $ upower -i /org/freedesktop/UPower/devices/battery_axp20x_battery
  native-path:          axp20x-battery
  power supply:         yes
  updated:              Fri 29 Mar 2024 09:46:43 GMT (91 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              8 Wh
    energy-empty:        0 Wh
    energy-full:         8 Wh
    energy-full-design:  0 Wh
    energy-rate:         0.836 W
    voltage:             4.132 V
    percentage:          98%
    capacity:            100%
    icon-name:          'battery-full-charging-symbolic'
  History (charge):
    1711705588  98.000  discharging
  History (rate):
    1711705603  0.836   charging
    1711705588  0.438   discharging

After 1st boot dmesg content:

cpi@raspberrypi:~ $ dmesg | grep axp20x-battery
[    7.261459] axp20x-battery-power-supply axp20x-battery-power-supply: DMA mask not set
[    7.825296] axp20x-battery-power-supply axp20x-battery-power-supply: couldn't set constant charge current from DT: fallback to minimum value

System wide config. As expected reverting to default value around 300mA:

cpi@raspberrypi:~ $ cat /sys/class/power_supply/axp20x-battery/constant_charge_current
300000
cpi@raspberrypi:~ $ cat /sys/class/power_supply/axp20x-battery/constant_charge_current_max 
300000

System specific overlay files:

cpi@raspberrypi:/boot/overlays $ for file in `ls devterm-*`; do md5sum $file; done
fd0d30adcf7cba9b83d5f6681fd6bf98  devterm-bt.dtbo
70c5968cf212db1a48cbfbe30294075e  devterm-misc.dtbo
bc3ac6b0d5efb170efe33f3d6558cd4a  devterm-panel.dtbo
7dfaad007dd4ea0cf8d0015aec4f2157  devterm-panel-uc.dtbo
e96f41fd792c25be367f32a1a0e0cb88  devterm-pmu.dtbo
31e809f275b4e9a332c9f516cfadcea7  devterm-wifi.dtbo

Now I built the kernel, modules and overlays with your change on top. As only overlay changed I just replaced devterm-pmu.dtbo with the new file:

21bfa1e19a91e7fe11d2082ecae6240e  devterm-pmu.dtbo

After reboot, no more dmesg warning:

cpi@raspberrypi:~ $ dmesg | grep axp20x-battery
[    6.442965] axp20x-battery-power-supply axp20x-battery-power-supply: DMA mask not set

And as expected, new charging current values are in place:

cpi@raspberrypi:~ $ cat /sys/class/power_supply/axp20x-battery/constant_charge_current
2100000
cpi@raspberrypi:~ $ cat /sys/class/power_supply/axp20x-battery/constant_charge_current_max
2100000
elkoniu commented 3 months ago

@cuu I think this PR is a good merge candidate.