Enable AC Power IRQ from TPS65217 on BBB?

In my project I use the BBB as the main controller for the autonomous system with a battery supply. The startup of the system has only one option, it’s a key. It is a simple key with 2 positions on/off that switches the power relay. The supply remains on till key in “on” position. The same logic as the key in the car.
The BBB uses 5V AC connector wich comes from switch relay for supplying and BBB board has a nice feature with a battery as 2nd power supply. To be sure that BBB will be switched off correctly I want to use PMIC’s (TPS65217) feature to generate an ACM interrupt. In this interrupt, I want to stop execution, save logs and switch BBB off till the supercap/battery will discharge.

I use Debian ( 4.19.173-bone-rt-r60 ) on BBB. The image was build with OMAP builder.

After boot, I’ve checked the PMIC settings:

i2cget -f -y 0 0x24 0x2
0x20

Where AC interrupt mask bit 5:
0b = Interrupt is issued when power to the AC input is applied or removed.
1b = No interrupt is issued when power to the AC input is applied or removed.

That means, that the interrupt is masked and if I do any action with AC cable, the interrupt counter will not be increased

~$ cat /proc/interrupts | grep tps
 68:          0      INTC   7 Level     tps65217-irq
 70:          0  tps65217   0 Edge      vbus
 71:          0  tps65217   2 Edge      tps65217_pwr_but

Interrupt counter returns always 0:

~$ cat /proc/irq/68/spurious
count 0
unhandled 0
last_unhandled 0 ms

if I manually remove 5th bit, the counter works fine.

To debug this, I tried to follow that topic:
Disable Power Button IRQ from TPS65217 on BBBW? - Linux Discussions - Engineering and Component Solution Forum - TechForum │ Digi-Key

I’ve disabled pwr button, just to be sure that dts was compiled correctly.
The button was disabled successful.
The next step was to remove USB from the charger part:

                        tps@24 {

                                reg = < 0x24 >;

                                compatible = "ti,tps65217";

                                interrupt-controller;

                                #interrupt-cells = < 0x01 >;

                                interrupts = < 0x07 >;

                                interrupt-parent = < 0x01 >;

                                ti,pmic-shutdown-controller;

                                phandle = < 0x38 >;



                                charger {

                                        compatible = "ti,tps65217-charger";

                                        interrupts = < 0x00 >;

                                        interrupt-names = "AC";

                                        status = "okay";

                                };



                                pwrbutton {

                                        compatible = "ti,tps65217-pwrbutton-disabled";

                                        interrupts = < 0x02 >;

                                        status = "disabled";

                                };

But after replacing the new compiled am335x-boneblack-uboot-univ.dtb

i2cget -f -y 0 0x24 0x2
0x60

The mask was not cleared and AC interrupt does not work as expected.

It would be nice to hear from the community how can I get it working or what I do wrong.
Thank you for your attention
Best regard

One thing to quickly double check with the “version.sh” script to make sure you booted with that actual device-tree file…

Regards,

Dear Robert,
Thank you for your answer. I hope that I’ve understood you correctly and have used the correct script. For me, it looks like the “am335x-boneblack-uboot.dts” was used, correct me if I’m wrong. The output of the script is below:

$ sudo /opt/scripts/tools/version.sh
sudo: unable to resolve host BBB-ya: No address associated with hostname
git:/opt/scripts/:[674bb55e34e94e3837f4f55790c7d1a52c9e149f]
eeprom:[A335BNLTAIA04917BBBI3472]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BBB custom Image 2022-05-17]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2019.04-g923f8b8 (Jan 02 2022 - 19:05:15 +0000)]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-g923f8b8]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-UIO-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0.bb.org-overlays]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0.bb.org-overlays]
kernel:[4.19.173-bone-rt-r60]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[uboot_overlay_pru=AM335X-PRU-UIO-00A0.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.14.20210821.0-0~buster+20210821]
pkg:[bb-customizations]:[1.20220513.0-0~buster+20220513]
pkg:[bb-usb-gadgets]:[1.20220316.1-0~buster+20220316]
pkg:[bb-wl18xx-firmware]:[1.20211222.2-0~buster+20211222]
pkg:[kmod]:[26-1]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
cmdline:[console=ttyS0,115200n8 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[    1.059779] remoteproc remoteproc0: wkup_m3 is available
[    1.188753] remoteproc remoteproc0: powering up wkup_m3
[    1.188772] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[    1.190876] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru
dmesg | grep pinctrl-single
[    0.746124] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[    0.747053] gpio-of-helper ocp:cape-universal: ready
END

Thank you for your support,
Best regard

it’s actually using am335x-boneblack-uboot.dts, so apply to both:

am335x-boneblack-uboot-univ.dtb
am335x-boneblack-uboot.dtb

to ensure…

Regards,

Hello Robert,

both files

am335x-boneblack-uboot-univ.dtb
am335x-boneblack-uboot.dtb

I’ve replaced them with newly compiled files but the same behaviour. To be sure that I use new files, I tried to decompile the dtb. In the content, I’ve found exactly the same content at I’ve modified.

Maybe it’s not relevant but what about CM3 FW of the power unit module, does this controller correctly handle the ACM interrupt definition in dtb?

Best regards,

The Cortex-M3 only does power management, think Sleep etc…

Regards,

The default value of the Interrupt Register (INT) of PMIC is (Address = 0x02) [reset = 0x80]. After power-on I see 0x60. That means that something has changed the register value.
Do you know who can be responsible for that change?
I think, Cortex-M3 can be responsible for that task because I would not expect that the main Sitara processor will do IRQ tasks from PMIC (USB IRQ is still working).

Unfortunately, I can’t find any info about that.

Best regards

Both U-Boot and the Kernel touch the TPS65217…

Regards,

Hello Robert,

I’ve found something in the build script. bb-kernel/bone-config-checker.sh at 8ea55b4996fc07e94c555f4234e75ec0e8249cb7 · RobertCNelson/bb-kernel · GitHub

In the .dts file the AC interrupt is located in the charger part. But in the configuration, the charger option is disabled with a comment “broken”. Do you remember why?

Thank you for your support

Hi Robert,

could you suggest how can I configure this line via omap-builder?

Thank you for your support,
Best regards

I can confirm, that the problem was in the line above. I’ve enabled this feature, recompiled the kernel and now I’m able to get AC interrupt.

Can anybody help me to understand how can I integrate it with omap-builder?
I have prepared custom config file and I want to use omap image builder script ( GitHub - RobertCNelson/omap-image-builder: omap image builder ) with this “charger enable” change.

Thanks for advice
Best regards

Hi @Siverian sorry, that’s been a bug for so long, i can’t find why it was disabled…

Let me do a little bit of testing, and just re-enable it again on later kernel’s…

Which branch are you using?

We’ve been setting up runner’s at https://git.beagleboard.org/ to help build these user ‘tweaked’ kernel builds, which would help give you a new “linux-image*.deb” in 10 minutes…

edit:

Are you seeing this error:

genirq: Flags mismatch irq 54. 00002000 (vbus) vs. 00000000 (tps65217-charger)

and does, shutdown completely power off the board?

sudo systemctl poweroff

Those were the two issues… (power off was the big one…)

Regards,

For debug reasons, I’ve used am33x-v4.19 branch. But in the end application I need bbb.io-kernel-4.19-ti.

No, I did not seen any error during compilation.
When the AC adapter switched off and battery is connected the device does not turn off but I see tps65217-charger interrupt counter increasing.

I’ve seen such a problem somewhere on the forum but as I understood, it was a driver problem which was patched and in 4.19 seems to be solved

UPD:

if I execute

sudo systemctl poweroff

Switching off was done without a problem

Regards,

On 6.1.x:

[   26.414467] tps65217-charger tps65217-charger: DMA mask not set
[   26.505710] genirq: Flags mismatch irq 53. 00002000 (tps65217-charger) vs. 00002000 (vbus)
[   26.576819] snd: no symbol version for __init_rwsem
[   26.631144] tps65217-charger tps65217-charger: Unable to register irq 53 err -16
[   26.724582] tps65217-charger: probe of tps65217-charger failed with error -16
sudo apt update
sudo apt install bbb.io-kernel-6.1-bone

WARNING

Disable overlays…

#enable_uboot_overlays=1

Otherwise it won’t boot, first pass of 6.1.x is kernel config sync with debian, so overlays are disabled while i do basic stability testing…

Regards,

Hello Robert,

I did not check with 6.1.x. ,in my case I would prefer to stay on 4.19 .
Could you suggest me how can I use your omap builder with a custom kernel?

As I’ve understood from this forum (Arch Linux ARM • View topic - [BBB] Reboot/halt problem) the vbus and tps652217-charger trying to use the same interrupt.
At the end of discussion, I’ve seen a possible solution: Re: [PATCH] usb: musb: Add support for optional VBUS irq to dsps glue layer — Linux USB

Thank you for your help and Merry Christmas
Best regards

So the default kernel’s are installed here:

We’d need to patch it something like this…

if [ ! "x${custom_kernel_version}" = "x" ] ; then
  wget --directory-prefix=/ <webhost>/linux-image-<pkg_version>
  sudo dpkg -i /linux-image-<pkg_version> || true
  depmod -a ${pkg_version}
  update-initramfs -u -k ${pkg_version}
fi

Regards,

Hello Robert,

Now I’m back with this kernel feature. Unfortunately, I don’t have a server where I may locate the kernel to use wget.

I there any option how to link to the kernel locally?
I tried to place the linux image in the image builder folder, but when I try to dpkg, it can’t find this file.

Thank you in advance

locahost?

sudo apt install apache2

Regards,

Yes, locallhost is a good idea.

Now I’m facing with another interesting error:

dpkg-deb: error: archive '/linux-image-4.19.173-bone-rt-r60_1xross_armhf.deb' uses unknown compression for member 'control.tar.zst', giving up

Do I understand correctly, that I have to repack the kernel?

Thank you in advance

Built on Ubuntu 22.04 or newer i’m guessing?

If so, just open “build_deb.sh” and edit this section:

From:

	build_opts="${build_opts} KDEB_SOURCENAME=linux-upstream"

to:

	build_opts="${build_opts} KDEB_SOURCENAME=linux-upstream"
	build_opts="${build_opts} KDEB_COMPRESS=xz"

Then it’ll compress properly in newer versions of ubuntu.

Regards,