AXP209

From www.chip-community.org
Jump to: navigation, search

The AXP209 is a sophisticated power control device which is used on CHIP.

The data sheet for the AXP can be found here: https://linux-sunxi.org/images/8/89/AXP209_Datasheet_v1.0en.pdf (NTC's hardware repo has a copy of that same PDF.)

See Power for general information about powering CHIP.


Data Sheet Errors

The data sheet has some errors in it:

  • Page 4, column 1, 3rd bullet point: "Configurable Intelligent Power Delect ..." last word should be "Select".
  • Page 12, section 7 "Pin Definition", pin 3: "REG9EH[7]", should be "REG95H[7]".
  • Page 12, pin 5: "REG92H[2:0]", should be "REG93H[2:0]".
  • Page 13, pin 18: "REG93H[2:0]", should be "REG92H[2:0]".


Device Address

The AXP is on CHIP's I2C bus number 0.

According to the data sheet:

Host can access the AXP209 registers via the TWSI interface, ... In addition, multi read and write operation is supported, and the device addresses are 69H (READ) and 68H (WRITE).

Note that TWSI is just another name for I2C.

Also note that they are interpreting the read/write line as the least significant bit of an 8-bit device address. A more host-oriented way of interpreting it is as a 7-bit device address and a separate read/write bit. Thus, the 69H and 68H addresses should be shifted right one bit, producing the address 34H. This is the address that should be used with the i2c-oriented commands.


CHIP's LEDs

There are two LEDs on CHIP: PWR and STAT. The PWR LED is simply connected to VCC-3V3, and indicates that CHIP is powered on. If that LED is illuminated, the CPU has power. Note that one of the AXP209's jobs is to cut off power to CHIP if the power supply is out of spec. Thus, you might have a power supply plugged in and running, but the AXP might decide it doesn't like the voltage and will cut power. This is indicated by the PWR LED being off.

The other LED is STAT is connected to AXP209 GPIO2 line, and is therefore under software control. GPIO2 is controlled with the AXP209 register REG93H. It can be turned on from CHIP's shell with:

sudo i2cset -f -y 0 0x34 0x93 0x1

It can be turned off with:

sudo i2cset -f -y 0 0x34 0x93 0x0


CHIP's Reset Button

CHIP's reset button is connected to AXP209 PWRON line, which is also exposed on the header U13, pin 10. This means that you can add your own switch between PWRON and GND, which will be wired in parallel with CHIP's reset button.

The AXP209 differentiates between short presses of the button (less than 6 seconds) and long presses (6 seconds or more). For short presses, an internal status bit is turned on, which is readable by software from the SXP209 register REG4AH, bit 1. This register can be read from CHIP's shell with:

sudo i2cget -f -y 0 0x34 0x4a

This will print an 8-bit hexidecimal value of the form "0xNN" where N is 0-9,a-f. To accurately and reliably detect a short press of the reset button, you should mask that printed value with 0x02:

REG34H=`sudo i2cget -f -y 0 0x34 0x4a`  # Read AXP209 register 34H
BUTTON=$((REG34H & 0x02))  # mask off the short press bit 1

These bash shell lines leave BUTTON set to either 0 (short press not detected) or 2 (short press detected).