• Kate Hsuan's avatar
    power: supply: axp288-charger: Optimize register reading method · ed229454
    Kate Hsuan authored
    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: default avatarKate Hsuan <hpa@redhat.com>
    Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
    Tested-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
    ed229454
axp288_charger.c 26.6 KB