• Michael Bohan's avatar
    msm: saw-regulator: Support enable and disable · ee3ce19c
    Michael Bohan authored
    
    
    Enable and disable callbacks are added as an optimization so that
    we don't update voltages when the regulator is disabled. The use
    case for this is a call sequence during CPU Hotplug like so:
    
    Down:
    
    regulator_disable()
    regulator_set_voltage(0)
    
    Up:
    
    regulator_set_voltage(original_voltage)
    regulator_enable()
    
    Since the SPM actually enables and disables the regulator when
    executing a WFI, we want these calls to actually amount to NOPs.
    The calls must exist for consistency with other regulator
    implementations that do mandate this sequence.
    
    In order to support this sequence, regulator_disable() will simply
    set the device to 'offline'. When a regulator is offline, then
    calls to regulator_set_voltage() do not actually adjust the
    voltage through the SPM; they simply cache the value that was
    specified. Then, during regulator_enable, iff the voltage value
    corresponding to the last regulator_set_voltage differs from the
    value actually programmed in hardware do we reprogram the
    hardware.
    
    These rules support the call sequence above since the last value
    written to hardware will occur with the regulator enabled by
    acpuclock. When executing Hotplug Down, the
    set_voltage(0) call does not take effect since the regulator has
    been explicitly disabled. In the Hotplug Up case, the set_voltage
    case is also cached since the regulator remains disabled. The
    value set by the client here should be equal to the value
    previously set in hardware (eg. restore). Lastly, the
    regulaor_enable() callback sees that the value are the same, and
    therefore does not update hardware.
    
    Change-Id: I071a25e6d0c30e378c5dcddcdd9ae26fe02da04a
    Signed-off-by: default avatarMichael Bohan <mbohan@codeaurora.org>
    ee3ce19c
board-8930-regulator-pm8038.c 21.9 KB