Re: [PATCH] regulator: arizona-ldo1: Only enable status change if we have LDOENA

From: Richard Fitzgerald
Date: Fri Apr 22 2016 - 12:38:19 EST

On 22/04/16 16:04, Mark Brown wrote:
On Fri, Apr 22, 2016 at 02:43:28PM +0100, Richard Fitzgerald wrote:
The driver was hardcoding REGULATOR_CHANGE_STATUS on the regulator
which made the regulator core assume that it can be powered off.

The power state of the regulator is controlled by the LDOENA pin so
this patch changes to only setting the REGULATOR_CHANGE_STATUS flag
if we have a valid gpio for LDOENA.
What's the difference between this and the previous version of the patch
and what problem is this aiming to solve? If we want to disable the
regulator why would we not be happy to do that by removing the supply?
The background to all this is that runtime suspend and resume needs to know whether the DCVDD turned off. If it definitely turned off a regmap cache sync is safe - if not or I can't be sure then I need the overhead of a forced reset to restore register defaults before the sync.

What I'm trying to achieve here is to stop the regulator core sending false notifications that LDO1 has been turned off. The way that the regulator core code handles the disable notifier has no dependency on what happens to the parent supply. The REGULATOR_CHANGE_STATUS flag is used to indicate whether the status of _this_ regulator can be changed (it doesn't affect whether the parent is disabled).

So if LDO1 is disabled without an LDOENA and without this patch, it looks like the current core behaviour of the functions regulator_disable(), _regulator_disable() and _regulator_do_disable() is:

1) Are we the last user? - Yes
2) _regulator_can_change_status()? - Yes because REGULATOR_CHANGE_STATUS is set
3) Send PRE_DISABLE notification
4) call _regulator_do_disable(), no GPIO pin and no disable callback so return 0 (claims success even though there was no way to disable it)
6) Return to regulator_disable() and then disable the parent supply

The result will be that we got a disable notification though LDO1 wasn't disabled.

I think it's a bug that LDO1 claimed to be able to turn off when it couldn't, and fixing that prevents bogus disable notifications.