albsod/pinetime-hypnos

[feature] Touch controller: power management

endian-albin opened this issue · 7 comments

The touch panel CST816S supports three power states:

Mode Power consumption
Dynamic < 2.5µA
Standby < 10uA
Sleep < 5uA

Exiting sleep requires a reset, i.e it corresponds to the DEVICE_PM_SUSPEND_STATE according to the Zephyr PM API.

Implement Zephyr's power management API like it was done for the ST7789V display.

I've copied over relevant code from the ST7789v driver and pushed a new branch (wip).

We have the value for sleep (0x03), and dynamic mode can be enabled through a reset. I haven't found the value for standby mode, however, although it's maybe the most useful mode. Could it be the case that the device enters standby by itself? This image[1] seems to suggest that. If so, we'd gain little by implementing sleep mode in the driver but it could be fun.

  1. https://medium.com/@ly.lee/building-a-rust-driver-for-pinetimes-touch-controller-cbc1a5d5d3e9

I've worked on this a bit more, and I can now successfully crash the system by running the reset sequence as (apparently) required for the sleep command :)

Maybe the problem is CONFIG_CST816S_TRIGGER_GLOBAL_THREAD... On the other hand, without this config set, I've not been able to make touch interrupts crash-free at all.

The out-of-tree driver is a mess. It needs a rewrite, but without any copying from non-Apache 2.0 licensed code which would ruin any future upstreaming effort. I had thought this power management issue wouldn't be too hard :)

There seems to be more doc about the CST816 registers

Thanks @sdorre, but please don't upload documents of unknown origin to this repo.

Ah okay sorry.
I will link the post from the pinetime forum instead:
https://forum.pine64.org/showthread.php?tid=8836&pid=57390#pid57390

Here seems to be the reference driver:
https://github.com/lupyuen/hynitron_i2c_cst0xxse

I don't see the reset sequence before. I understand that we need the reset to wake up the Chip and send something to it. I don#t see why we would need to reset it otherwise.

Sleep mode will gives us only 5uA less. That could be an optimization but, there are now other device that a taking much more current i think. =)

@Lukas-Berglund wrote a thesis about power consumption of the PineTime devkit. The display is a major current thief if sleep mode isn’t used but the touch controller not much it seems. Gestures are more important. For completeness I’d like to finish this at some point though.