From mboxrd@z Thu Jan 1 00:00:00 1970 From: Doug Anderson Subject: Re: [PATCH v3 1/2] regulator: dt-bindings: add QCOM RPMh regulator bindings Date: Tue, 29 May 2018 22:30:33 -0700 Message-ID: References: <20180523082908.GB4828@sirena.org.uk> <20180523154057.GL4828@sirena.org.uk> <20180523155617.GN4828@sirena.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: <20180523155617.GN4828@sirena.org.uk> Sender: linux-kernel-owner@vger.kernel.org To: Mark Brown Cc: David Collins , Liam Girdwood , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, Linux ARM , devicetree@vger.kernel.org, LKML , Rajendra Nayak , Stephen Boyd List-Id: linux-arm-msm@vger.kernel.org Hi, On Wed, May 23, 2018 at 8:56 AM, Mark Brown wrote: > On Wed, May 23, 2018 at 08:50:22AM -0700, Doug Anderson wrote: >> On Wed, May 23, 2018 at 8:40 AM, Mark Brown wrote: > >> > It's got to be valid to think about the voltage of a disabled regulator >> > since drivers want to be able make sure that the regulator gets enabled >> > with a sensible config. With most hardware this is really easy since >> > you can just look at the status reported by the hardware but the RPM >> > makes this hard since there's so much write only stuff in there. > >> I should be more clear. Certainly it should be valid to set the >> voltage before enabling it so, as you said, the regulator turns on at >> the right voltage. I'm saying that it's weird (to me) to expect that >> setting the voltage for a regulator that a client thinks is disabled >> will affect any real voltages in the system until the regulator is >> enabled. In RPMh apparently setting a voltage of a regulator you >> think is disabled can affect the regulator output if another client >> (unbeknownst to you) happens to have it enabled. > > Yes, that's definitely not what's expected but it's unfortunately what > the firmware chose to implement so we may well be stuck with it > unfortunately. We're not really stuck with it if we do what I was suggesting. I was suggesting that every time we disable the regulator in Linux we have Linux vote for the lowest voltage it's comfortable with. Linux keeps track of the true voltage that the driver wants and will always change its vote back to that before enabling. Thus (assuming Linux is OK with 1.2 V - 1.4 V for a rail): Modem: want 1.3 V and enabled. => Modem votes for 1.3 V => Modem votes for enabled. => At least one vote for enabled? Yes => Highest voltage vote: 1.3V => True output: 1.3V Linux: want 1.4 V and enabled. => Linux votes for 1.4 V => Linux votes for enabled => At least one vote for enabled? Yes => Highest voltage vote: 1.4V => True output: 1.4V Linux: want disabled => Linux votes for disabled => Linux votes for 1.2 V (keeps 1.4 V in local var) => At least one vote for enabled? Yes => Highest voltage vote: 1.3V => True output: 1.3V Linux: want enabled => Linux votes for 1.4 V (from local var) => Linux votes for enabled => At least one vote for enabled? Yes => Highest voltage vote: 1.4V => True output: 1.4V ...but I'll leave it to you if you think this is a big deal. If you're happy with how David's driver works without my suggestion then I won't push it. -Doug