]> git.baikalelectronics.ru Git - kernel.git/commit
power: supply: axp288-charger: Optimize register reading method
authorKate Hsuan <hpa@redhat.com>
Tue, 12 Oct 2021 05:45:45 +0000 (13:45 +0800)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 12 Oct 2021 13:21:15 +0000 (15:21 +0200)
commitd4ae56241ded875f6c8660102e3bb6cb13ee6f09
tree1a38d26ef82cbc5b41b264d30be49d374a64b3ca
parentfa6c232e13a1b3cb17b5d219da76455c9c7afccd
power: supply: axp288-charger: Optimize register reading method

The original implementation access the charger the same register value
several times to get the charger status, such as online, enabled, and
bus limits. It takes a long time and bandwidth for every "status get"
operation. 

To reduce the access of the register and save bandwidth, this commit
integrated every read operation into only one "register value get" 
operation and cache them in the variables. Once the "get properties"
is requested from the user space, the cached information can be returned
immediately.

I2C access between Linux kernel and P-Unit is improved by explicitly taking
semaphore once for the entire set of register accesses in the new
axp288_charger_usb_update_property() function. The I2C-Bus to the XPower
AXP288 is shared between the Linux kernel and SoCs P-Unit. The P-Unit
has a semaphore which the kernel must "lock" before it may use the bus.
If not explicitly taken by the I2C-Driver, then this semaphore is
automatically taken by the I2C-bus-driver for each I2C-transfer. In
other words, the semaphore will be locked and released several times for
entire set of register accesses.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/axp288_charger.c