12-20-2018 04:39 AM
We would like to have a proper power button on our ZYNQ & Petalinux design, using the button + LTC2953 On/Off controller to gracefully shutdown linux. However, I can find very little information on how to achieve this. Apparently the OS needs set a GPIO high, connected to the 'not kill' of the On/Off controller.
Then, when the power button is pressed again, an IRQ signal is send to the OS and needs to shut-down gracefully. Once the OS is shutdown, it pulls the kill signal low (or tristates with a pull down resistor) and LTC2953 will disable the DC/DC converter.
However, I have no idea how to configure this for Petalinux. Any insights on how to achieve this? Thanks!
12-21-2018 11:57 PM
The Linux kernel includes a driver that *might* be adaptable to your needs. The driver is for the LTC2952 which is similar to the LTC2953 in that it uses an INT trigger signal to indicate to the CPU that a shutdown is required and a KILL signal for the CPU to indicate to the power controller that the shutdown is complete and the power can be removed. The LTC2953 doesn't have a WDE signal so the watchdog output generated by the LTC2952 driver would not be used with a LTC2953.
When the LTC2952 driver receives the INT trigger interrupt via a GPIO it starts a timer and once the timer expires it calls the kernel orderly_poweroff API to initiate a shutdown. Once the shutdown is complete the kernel calls pm_power_off which the driver handles and then sends the KILL signal to the power controller via a GPIO. Note that if any other driver in your kernel configuration claims pm_power_off this won't work - the LTC2952 driver will tell you this when it is loaded via a kernel message. In that case you will need to figure out what driver has already claimed pm_power_off and see if you really need that driver.
To use the LTC2952 driver you need to modify the Linux kernel configuration to include the driver. The configuration option required is CONFIG_POWER_RESET_LTC2952. You can select this option when configuring petalinux using the command:
petalinux-config -c kernel
The source for the driver can be found at https://github.com/Xilinx/linux-xlnx/blob/xilinx-v2018.3/drivers/power/reset/ltc2952-poweroff.c. The source code includes some limited documentation.
The driver requires configuration via the device tree to specify what GPIO ports are used for the INT and KILL connections to the power controller and their polarity. The device tree binding for the driver is documented at https://github.com/Xilinx/linux-xlnx/blob/xilinx-v2018.3/Documentation/devicetree/bindings/power/reset/ltc2952-poweroff.txt.
Hopefully the above gives you some ideas.
Note that the LTC2952 driver shouldn't be used with a ZynqMP as Xilinx already has code in their ZynqMP PMU firmware to handle a LTC295X style power controller.
12-22-2018 05:00 AM
Thanks for your reply. That is an excellent idea! I'll try that, or maybe I could even adapt the driver for the KTC2953. I'm on holiday now for a week or so, but I will try it once I get back! Thanks!
12-25-2018 09:26 AM - edited 12-25-2018 09:30 AM
Ultra96 board has power button with LTC2954
Petalinux2018.3 supports recipe for ultra96 power button