Beaglebone Black, Battery interface as UPS

Hi, would like to use the Beaglebone Black’s battery interface as a UPS power backup. This UPS system should enable Linux to power up and down the system. Has anyone done this?

The PMIC (tps65217) is capable of generation an interrupt when the PB_IN button is pressed as well as when power source changes (AC, USB, or BAT). I would the power source changes interrupt to call the same interrupt handler as the PB_IN button. This should power up and down the system when power is lost/restore.
Thank you for your help.

I’m not quite sure what your question is …

The PMIC incorporates a battery charger and can be configured via I2C. You shouldnt need to be concerned with PMIC interrupts, although this would depend on your specific needs. You can just monitor external power using a GPIO if that’s easier than getting it from the PMIC.

One thing to be aware of - the li-ion cell is at the 3V level, so when 5V power is lost, USB power is also lost.

1 Like

Thank you, Paul,

I understand that Battery is only 3.7 volts. I need a way to Power down Linux OS when power is lost.

The PMIC also take care of the power push button on the Beaglebone. As far as I can tell, when the PWR_PB is pressed the PMIC generates an interrupt. This interrupt handler will generate a System Power Down call and Linux will clean everything up power down.

I want to enable the AC interface functionality in the PMIC. When this interrupt occurs, I can call the PWR_PB interrupt handler (maybe need some mask bit changed) to power down the system. When the power is restored, the system will boot up and run.

Thank you

Have you concidered simply using the shutdown or halt command when you detect that input power has been lost? You can detect loss of power by polling the PMIC status, or by using a GPIO. I havnt looked into this at all, but I would imagine this would be simpler that trying to hook into the PMIC interrupts.

Yes, that is my plane B approach.

I wanted to see if I could use the PMIC first. I like this chip and planning on using it in other projects if it works out.

Could you point me to where I can find the interrupt handler?

Thank you

Thank you foxsquirrel,

I have the datasheet. I am looking for the Linux PMIC Interrupt handler’s code. I am not sure if it is part of u-boot or Linux Kernal.

I got my U-Boot and Linux Kernal code from here.
GitHub - u-boot/u-boot: "Das U-Boot" Source Tree and GitHub - RobertCNelson/linux-stable-rcn-ee

Thank you again.

What I seen is the the pins, are those pins on the lower right actually connected to the BBB. If they are not connected or cannot be mux’d???

Hi,

I do not know what pins you are referring to.

I was looking at the int pin, just glanced at that and have not read anything.

Hi,

I believe they are connected because small power push button on the Beaglebone Black works for powering up and down.

I have been reviewing the hardware design and I believe there is no way to read the Push Button through GPIO.

It is posable Linux is Polling the I2C bus to see if the button is pushed.

I wonder what is going on with its i2c bus and how active it is. It would be assumed its talking back and forth with the kernel, do they possibly have a node in proc.

This is my first “Linux” type project. I don’t know what you mean by “node in proc”

From a PMIC point of view there is no need. It is a pretty much a set it and forget type part.

If you were do aggress power management, you could be adjusting power supplies value but the AM3352 is not really that type of chip.

fred@bbbi1:~$ cd /
fred@bbbi1:/$ ls
bin   data  etc   ID.txt  lost+found  mnt  proc  run   srv  tmp  var
boot  dev   home  lib     media       opt  root  sbin  sys  usr
fred@bbbi1:/$ cd proc
fred@bbbi1:/proc$ ls
1     121   2     559  785     buddyinfo      irq           schedstat
10    129   20    560  789     bus            kallsyms      self
103   13    21    590  792     cgroups        keys          slabinfo
1032  133   2125  596  794     cmdline        key-users     softirqs
1033  1338  2133  600  795     config.gz      kmsg          stat
104   134   2150  612  796     consoles       kpagecgroup   swaps
1089  1382  2179  624  8       cpu            kpagecount    sys
11    139   2199  634  88      cpuinfo        kpageflags    sysrq-trigger
110   14    22    665  881     crypto         loadavg       sysvipc
111   140   2204  68   882     devices        locks         thread-self
1115  144   2206  69   89      device-tree    meminfo       timer_list
1130  145   23    70   9       diskstats      misc          tty
1131  146   24    71   91      driver         modules       uptime
1149  147   3     72   92      dynamic_debug  mounts        version
1150  148   4     727  94      execdomains    mtd           vmallocinfo
1154  1522  486   73   95      fb             net           vmstat
1159  16    487   74   96      filesystems    pagetypeinfo  zoneinfo
1165  17    526   76   98      fs             partitions
1193  18    542   77   99      interrupts     pressure
12    19    549   78   apm     iomem          pvr
120   1912  554   783  asound  ioports        sched_debug
fred@bbbi1:/proc$ 


That is the virtual filesystem with kernel information.

fred@bbbi1:/proc$ cat interrupts 
           CPU0       
 16:     332954      INTC  68 Level     clockevent
 17:          0      INTC   3 Level     arm-pmu
 19:          0      INTC  96 Level     44e07000.gpio
 20:         15      INTC  72 Level     44e09000.serial
 21:        285      INTC  70 Level     44e0b000.i2c
 22:          0      INTC  16 Level     TI-am335x-adc.0.auto
 23:          1      INTC  78 Level     wkup_m3_txev
 25:          0      INTC  75 Level     rtc0
 26:          0      INTC  76 Level     rtc0
 29:          0      INTC  71 Level     4802a000.i2c
 30:          0      INTC  65 Level     48030000.spi
 31:          0      INTC  80 Level     48038000.mcasp_tx
 32:          0      INTC  81 Level     48038000.mcasp_rx
 38:          0      INTC  98 Level     4804c000.gpio
 39:          0      INTC  64 Level     mmc0
 40:          0      INTC  77 Level     mbox-wkup-m3
 41:        102      INTC  30 Level     4819c000.i2c
 42:          0      INTC 125 Level     481a0000.spi
 45:          0      INTC  32 Level     481ac000.gpio
 46:          0      INTC  62 Level     481ae000.gpio
 48:      32105      INTC  28 Level     mmc1
 52:          0      INTC  36 Level     tilcdc
 53:          0      INTC 111 Level     48310000.rng
 55:      21775      INTC  41 Level     4a100000.ethernet
 56:      31292      INTC  42 Level     4a100000.ethernet
 57:       4146      INTC  43 Level     4a100000.ethernet
 58:       9494      INTC  12 Level     49000000.dma_ccint
 60:        139      INTC  14 Level     49000000.dma_ccerrint
 64:          0      INTC  18 Level     musb-hdrc.0
 65:          1      INTC  19 Level     musb-hdrc.1
 66:          0      INTC  17 Level     47400000.dma-controller
 67:          0      INTC 109 Level     53100000.sham
 69:          2      INTC   7 Level     tps65217-irq
 71:          2  tps65217   0 Edge      vbus
 72:          0  tps65217   2 Edge      tps65217_pwr_but
143:          0  4804c000.gpio  25 Level     tda998x
144:          0  44e07000.gpio   6 Edge      48060000.mmc cd
Err:          0

Thank you

It looks like I am on the correct trail.