Hi, On Tue, Aug 31, 2021 at 08:49:04AM +0200, Thomas Marangoni wrote: > > What kind of devices is it going to handle, specifically? > The AXP209 is a power management chip for e.g. Allwinner A20 (ARM > architecture), I want to focus on the axp20x-battery driver. > > > > The device has multiple > > > warnings like: temperature too high or low, > > You should be able to use the existing thermal framework for this. > > > > > over-voltage, under-voltage > > But there's no generic way to communicate those AFAICS. > > > > The question here is what user space is going to do about them, though. > > Events I like to communicate to the user-space: > > - Battery Temperature to high (as already mentioned, possible with thermal > framework) > - Battery Temperature to low (as already mentioned, possible with thermal > framework) > - AXP209Internal over-temperature (should also be possible with thermal > framework) > - Low Voltage Level 2 (shuts down the device) > > - Low Voltage Level 1 > - Over Voltage > - Under Voltage > - Chargingcurrent shortage > > In my case the application would prepare for a shutdown if the low voltage > warning level 1 event is received. For the other events the user would get a > warning with instruction how to handle them from the application. > > > > etc. What is the recommended way to communicate such warnings to the > > > user-space, besides dmesg, so programs can handle them? Or should I just > > > create my own attribute for each warning and set it to a specific value > > > from the kernel and let user-space applications reset them to > > > acknowledge them? And if there is a recommended way can you name me a > > > driver that is using it? > > > > > > Thanks for your help! power-supply drivers can expose the health property, which exposes status like overvoltage or overheat (just one at a time though. Drivers should report the most critical one). In general userspace gets a uevent notification with all properties incl. health when power_supply_changed() is called for the device. It definetly should be called when health status changes. You can find more information in Documentation/ABI/testing/sysfs-class-power (look for "/health") and by searching the kernel tree for POWER_SUPPLY_PROP_HEALTH. -- Sebastian