Is it possible to increase RTC supercapacitor charging current?

I found Jetson Nano Datasheet: https://www.realtimes.cn/Uploads/download/JetsonNano_DataSheet.pdf and it indeed mentions that “charger that can be configured between 2.5V and 3.5V CV output and 50uA to 800uA CC”. Unfortunattely, it does not mention how.

I found the following devices:

% cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current | xxd -p
00000064

0x64 = 100, this means currently it is limited to 100µA instead of 800uA (which equals to 0x320).

cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-voltage | xxd -p  
002dc6c0

0x2dc6c0 = 3000000µV = 3V but I would like to set it to 3.5V. Unfortunatelly, I cannot do this directly:

echo "0000 0320" | xxd -r -p - > /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current
zsh: permission denied: /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current

I found that /boot/tegra210-p3448-0000-p3449-0000-b00.dtb mentions backup-battery but it is a binary file. I searched the source code and found Linux_for_Tegra/source/public/hardware/nvidia/platform/t210/porg/kernel-dts/tegra210-porg-pmic-p3448-0000-a00.dtsi, and within it there is the backup-battery subsection I was looking for:

            backup-battery {
                maxim,backup-battery-charging-current = <100>;
                maxim,backup-battery-charging-voltage = <3000000>;
                maxim,backup-battery-output-resistor = <100>;
            };

I replaced it with the values I need to max out voltage and current:

            backup-battery {
                maxim,backup-battery-charging-current = <800>;
                maxim,backup-battery-charging-voltage = <3500000>;
                maxim,backup-battery-output-resistor = <100>;
            };

The last step is to compile the kernel and install it (if you do not how, here is a good guide: Overclocking the Jetson Nano - Q-engineering, you may skip overclocking part if you just want to build the kernel). This is how I do it (if using custom .config instead of Linux_for_Tegra/source/public/kernel/kernel-4.9/arch/arm64/configs/tegra_defconfig, comment out a section in nvbuild.sh which mentions "${config_file}" or nvbuild.sh will overwrite it):

cd ~/Linux_for_Tegra/source/public && \
sudo ./nvbuild.sh && cd kernel/kernel-4.9 && sudo make modules && \
sudo make modules_install && sudo make && sudo make install && \
sudo cp -av ./arch/arm64/boot/Image /boot/Image && \
sudo cp -av ./arch/arm64/boot/dts/*.dtb* /boot/

Obviously this assumes you already have kernel sources unpacked in the home directory. Refer to the guide mentioned above if you do not know where to get the kernel source code. The above command works directly in Jetson Nano and took less than 1.5h, no need to crosscompile with desktop PC.

Then find out the name of DTS the board is using:

% dmesg | grep -i '\.dts' | head -n1 | perl -pe 's|.*/||'
tegra210-p3448-0000-p3449-0000-b00.dts

Add to extlinux.conf FDT with the path to new DTB (named exactly like DTS):

% sudo nano /boot/extlinux/extlinux.conf

This how edited /boot/extlinux/extlinux.conf looks in my case (I added FDT line at the end):

TIMEOUT 3
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
      FDT /boot/tegra210-p3448-0000-p3449-0000-b00.dtb

I rebooted. Let’s check the result:

% cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-voltage | xxd -p
003567e0
% cat /sys/firmware/devicetree/base/i2c@7000d000/max77620@3c/backup-battery/maxim,backup-battery-charging-current | xxd -p 
00000320

0x3567e0 = 3500000µV = 3.5V and 0x320 = 800µA. This is a success!

Information how to do this was hard to figure out and it took hours. The documentation needs to be clearer how to do this, since charging a supercapacitor 8 times faster and to a higher voltage (important to compensate for self-discharge) is a big difference.