Message ID | 1409053061-22568-1-git-send-email-javier.martinez@collabora.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Javier, On Tue, Aug 26, 2014 at 4:37 AM, Javier Martinez Canillas <javier.martinez@collabora.co.uk> wrote: > The max77802 driver reads the default operating mode (opmode) > set for regulators when enabled from the hardware registers. > > But if a regulator is disabled and the system warm restarted, > the hardware reports OFF as the opmode so the regulator is > not enabled. Default to operating mode NORMAL if OFF is read > from the hardware register. > > Reported-by: Yuvaraj Cd <yuvaraj.lkml@gmail.com> > Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> > --- > > This patch fixes the issue reported in https://lkml.org/lkml/2014/8/25/69 > > drivers/regulator/max77802.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c > index ad1caa9..967e109 100644 > --- a/drivers/regulator/max77802.c > +++ b/drivers/regulator/max77802.c > @@ -540,7 +540,17 @@ static int max77802_pmic_probe(struct platform_device *pdev) > config.of_node = pdata->regulators[i].of_node; > > ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); > - max77802->opmode[id] = val >> shift & MAX77802_OPMODE_MASK; > + val = val >> shift & MAX77802_OPMODE_MASK; > + > + /* > + * If the regulator is disabled and the system warm rebooted, > + * the hardware reports OFF as the regulator operating mode. > + * Default to operating mode NORMAL in that case. > + */ > + if (val == MAX77802_OPMODE_OFF) > + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; > + else > + max77802->opmode[id] = val; Reviewed-by: Doug Anderson <dianders@chromium.org> -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Tested-by: Yuvaraj Kumar CD <yuvaraj.cd@samsung.com> On Tue, Aug 26, 2014 at 5:07 PM, Javier Martinez Canillas <javier.martinez@collabora.co.uk> wrote: > The max77802 driver reads the default operating mode (opmode) > set for regulators when enabled from the hardware registers. > > But if a regulator is disabled and the system warm restarted, > the hardware reports OFF as the opmode so the regulator is > not enabled. Default to operating mode NORMAL if OFF is read > from the hardware register. > > Reported-by: Yuvaraj Cd <yuvaraj.lkml@gmail.com> > Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> > --- > > This patch fixes the issue reported in https://lkml.org/lkml/2014/8/25/69 > > drivers/regulator/max77802.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c > index ad1caa9..967e109 100644 > --- a/drivers/regulator/max77802.c > +++ b/drivers/regulator/max77802.c > @@ -540,7 +540,17 @@ static int max77802_pmic_probe(struct platform_device *pdev) > config.of_node = pdata->regulators[i].of_node; > > ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); > - max77802->opmode[id] = val >> shift & MAX77802_OPMODE_MASK; > + val = val >> shift & MAX77802_OPMODE_MASK; > + > + /* > + * If the regulator is disabled and the system warm rebooted, > + * the hardware reports OFF as the regulator operating mode. > + * Default to operating mode NORMAL in that case. > + */ > + if (val == MAX77802_OPMODE_OFF) > + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; > + else > + max77802->opmode[id] = val; > > rdev = devm_regulator_register(&pdev->dev, > ®ulators[i], &config); > -- > 2.0.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, Aug 26, 2014 at 01:37:41PM +0200, Javier Martinez Canillas wrote: > The max77802 driver reads the default operating mode (opmode) > set for regulators when enabled from the hardware registers. Applied, thanks.
On 26.08.2014 13:37, Javier Martinez Canillas wrote: > + /* > + * If the regulator is disabled and the system warm rebooted, > + * the hardware reports OFF as the regulator operating mode. > + * Default to operating mode NORMAL in that case. > + */ > + if (val == MAX77802_OPMODE_OFF) > + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; > + else > + max77802->opmode[id] = val; I might be missing something, but I believe I see a flaw here. If after a cold boot opmode is something else than OFF or NORMAL, the kernel starts, turns the regulator off and does warm reboot, the setting is lost and the regulator is switched to NORMAL mode. Best regards, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Aug 27, 2014 at 08:32:38PM +0200, Tomasz Figa wrote: > On 26.08.2014 13:37, Javier Martinez Canillas wrote: > > + /* > > + * If the regulator is disabled and the system warm rebooted, > > + * the hardware reports OFF as the regulator operating mode. > > + * Default to operating mode NORMAL in that case. > > + */ > > + if (val == MAX77802_OPMODE_OFF) > > + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; > > + else > > + max77802->opmode[id] = val; > I might be missing something, but I believe I see a flaw here. If after > a cold boot opmode is something else than OFF or NORMAL, the kernel > starts, turns the regulator off and does warm reboot, the setting is > lost and the regulator is switched to NORMAL mode. That's essentially the situation the patch is trying to fix - if we boot and the regulator is off there's no way to figure out what the operating mode would have been so we have to pick something. If you've got an idea for something better to do...
On 27.08.2014 20:37, Mark Brown wrote: > On Wed, Aug 27, 2014 at 08:32:38PM +0200, Tomasz Figa wrote: >> On 26.08.2014 13:37, Javier Martinez Canillas wrote: > >>> + /* >>> + * If the regulator is disabled and the system warm rebooted, >>> + * the hardware reports OFF as the regulator operating mode. >>> + * Default to operating mode NORMAL in that case. >>> + */ >>> + if (val == MAX77802_OPMODE_OFF) >>> + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; >>> + else >>> + max77802->opmode[id] = val; > >> I might be missing something, but I believe I see a flaw here. If after >> a cold boot opmode is something else than OFF or NORMAL, the kernel >> starts, turns the regulator off and does warm reboot, the setting is >> lost and the regulator is switched to NORMAL mode. > > That's essentially the situation the patch is trying to fix - if we boot > and the regulator is off there's no way to figure out what the operating > mode would have been so we have to pick something. If you've got an > idea for something better to do... > Probably the only way to correctly handle this is to specify the right operating mode in DT (after defining a binding for it). -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Aug 27, 2014 at 08:39:39PM +0200, Tomasz Figa wrote: > On 27.08.2014 20:37, Mark Brown wrote: > > That's essentially the situation the patch is trying to fix - if we boot > > and the regulator is off there's no way to figure out what the operating > > mode would have been so we have to pick something. If you've got an > > idea for something better to do... > Probably the only way to correctly handle this is to specify the right > operating mode in DT (after defining a binding for it). I'm not convinced that's worth it - chances are that if anything changed the mode it was a previously running Linux which will most likely be doing the same things when it starts running anyway.
On 27.08.2014 20:47, Mark Brown wrote: > On Wed, Aug 27, 2014 at 08:39:39PM +0200, Tomasz Figa wrote: >> On 27.08.2014 20:37, Mark Brown wrote: > >>> That's essentially the situation the patch is trying to fix - if we boot >>> and the regulator is off there's no way to figure out what the operating >>> mode would have been so we have to pick something. If you've got an >>> idea for something better to do... > >> Probably the only way to correctly handle this is to specify the right >> operating mode in DT (after defining a binding for it). > > I'm not convinced that's worth it - chances are that if anything changed > the mode it was a previously running Linux which will most likely be > doing the same things when it starts running anyway. > The previously running Linux would have changed the opmode accidentally, due to hardware design of PMIC chip, which doesn't allow powering off a regulator in other way than setting opmode to OFF. If you provide the "active" opmode to that Linux, after a warm reboot it will be able to power on such regulator to correct opmode, without defaulting it incorrectly to NORMAL. -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Aug 27, 2014 at 08:52:49PM +0200, Tomasz Figa wrote: > On 27.08.2014 20:47, Mark Brown wrote: > > I'm not convinced that's worth it - chances are that if anything changed > > the mode it was a previously running Linux which will most likely be > > doing the same things when it starts running anyway. > The previously running Linux would have changed the opmode accidentally, > due to hardware design of PMIC chip, which doesn't allow powering off a > regulator in other way than setting opmode to OFF. > If you provide the "active" opmode to that Linux, after a warm reboot it > will be able to power on such regulator to correct opmode, without > defaulting it incorrectly to NORMAL. This is in the scenario where the previously running Linux changed the mode to something other than normal and where the freshly booted Linux can't figure out how to do that when it needs to. I'm not sure how plausible that scenario is, or that real systems would handle it robustly.
On 27.08.2014 21:15, Mark Brown wrote: > On Wed, Aug 27, 2014 at 08:52:49PM +0200, Tomasz Figa wrote: >> On 27.08.2014 20:47, Mark Brown wrote: > >>> I'm not convinced that's worth it - chances are that if anything changed >>> the mode it was a previously running Linux which will most likely be >>> doing the same things when it starts running anyway. > >> The previously running Linux would have changed the opmode accidentally, >> due to hardware design of PMIC chip, which doesn't allow powering off a >> regulator in other way than setting opmode to OFF. > >> If you provide the "active" opmode to that Linux, after a warm reboot it >> will be able to power on such regulator to correct opmode, without >> defaulting it incorrectly to NORMAL. > > This is in the scenario where the previously running Linux changed the > mode to something other than normal and where the freshly booted Linux > can't figure out how to do that when it needs to. I'm not sure how > plausible that scenario is, or that real systems would handle it > robustly. > I'm not sure I'm getting your point. If the only thing Linux can do is read back the opmode from PMIC registers, it doesn't explicitly set it to something other, but rather reuses what was set by something before it (or, after this patch, defaults to NORMAL if it's OFF), i.e. the low level firmware or Linux. However the information about original setting is lost whenever Linux turns the regulator off and performs a warm reboot, which I believe would be a quite common scenario. Best regards, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Aug 27, 2014 at 09:21:02PM +0200, Tomasz Figa wrote: > On 27.08.2014 21:15, Mark Brown wrote: > > This is in the scenario where the previously running Linux changed the > > mode to something other than normal and where the freshly booted Linux > > can't figure out how to do that when it needs to. I'm not sure how > > plausible that scenario is, or that real systems would handle it > > robustly. > I'm not sure I'm getting your point. > If the only thing Linux can do is read back the opmode from PMIC > registers, it doesn't explicitly set it to something other, but rather > reuses what was set by something before it (or, after this patch, > defaults to NORMAL if it's OFF), i.e. the low level firmware or Linux. > However the information about original setting is lost whenever Linux > turns the regulator off and performs a warm reboot, which I believe > would be a quite common scenario. The point is that if anything was setting the mode to something other than normal it was almost certainly a previously running copy of Linux and one would expect that if the mode does need to be changed the new copy will be doing that anyway. It's rare enough to need to actively manage modes in the first place.
On 27.08.2014 21:44, Mark Brown wrote: > On Wed, Aug 27, 2014 at 09:21:02PM +0200, Tomasz Figa wrote: >> On 27.08.2014 21:15, Mark Brown wrote: > >>> This is in the scenario where the previously running Linux changed the >>> mode to something other than normal and where the freshly booted Linux >>> can't figure out how to do that when it needs to. I'm not sure how >>> plausible that scenario is, or that real systems would handle it >>> robustly. > >> I'm not sure I'm getting your point. > >> If the only thing Linux can do is read back the opmode from PMIC >> registers, it doesn't explicitly set it to something other, but rather >> reuses what was set by something before it (or, after this patch, >> defaults to NORMAL if it's OFF), i.e. the low level firmware or Linux. > >> However the information about original setting is lost whenever Linux >> turns the regulator off and performs a warm reboot, which I believe >> would be a quite common scenario. > > The point is that if anything was setting the mode to something other > than normal it was almost certainly a previously running copy of Linux > and one would expect that if the mode does need to be changed the new > copy will be doing that anyway. It's rare enough to need to actively > manage modes in the first place. > From what I know based on my experience with Samsung boards we used, the opmodes of regulators are preconfigured by board bootloader to certain values based on power design of the board (i.e. there is no need to keep a regulator in full power mode, if on given board only a little fraction of it is needed). Now Linux should not change this mode (excluding cases when the values in the bootloader are wrong - they happen unfortunately), so I'm not getting why you say that it is Linux which changes the mode to something other than normal. Linux should only toggle between the value resulting from power design and off. Best regards, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Aug 27, 2014 at 09:58:55PM +0200, Tomasz Figa wrote: > On 27.08.2014 21:44, Mark Brown wrote: > > The point is that if anything was setting the mode to something other > > than normal it was almost certainly a previously running copy of Linux > > and one would expect that if the mode does need to be changed the new > > copy will be doing that anyway. It's rare enough to need to actively > > manage modes in the first place. > From what I know based on my experience with Samsung boards we used, the > opmodes of regulators are preconfigured by board bootloader to certain > values based on power design of the board (i.e. there is no need to keep > a regulator in full power mode, if on given board only a little fraction > of it is needed). Well, presumably the bootloader is going to run again even for a warm reboot? > Now Linux should not change this mode (excluding cases when the values > in the bootloader are wrong - they happen unfortunately), so I'm not > getting why you say that it is Linux which changes the mode to something > other than normal. Linux should only toggle between the value resulting > from power design and off. It's not in general true that Linux should never change the mode (the main case for toggling modes is usually going between an idle/suspend state and active state) and for practical purposes bootloader and hardware defaults tend to be the same. You're talking about the case where the bootloader does set something but avoids doing so on warm reboots only here. Besides, even if we did have a way of specifying modes in DT (with all the problems that brings) we still have to pick a default if that's not used).
On 27.08.2014 22:25, Mark Brown wrote: > On Wed, Aug 27, 2014 at 09:58:55PM +0200, Tomasz Figa wrote: >> On 27.08.2014 21:44, Mark Brown wrote: > >>> The point is that if anything was setting the mode to something other >>> than normal it was almost certainly a previously running copy of Linux >>> and one would expect that if the mode does need to be changed the new >>> copy will be doing that anyway. It's rare enough to need to actively >>> manage modes in the first place. > >> From what I know based on my experience with Samsung boards we used, the >> opmodes of regulators are preconfigured by board bootloader to certain >> values based on power design of the board (i.e. there is no need to keep >> a regulator in full power mode, if on given board only a little fraction >> of it is needed). > > Well, presumably the bootloader is going to run again even for a warm > reboot? This is strange, but apparently it's not the case for the hardware which this patch is supposed to fix or at least this is how I understood it. > >> Now Linux should not change this mode (excluding cases when the values >> in the bootloader are wrong - they happen unfortunately), so I'm not >> getting why you say that it is Linux which changes the mode to something >> other than normal. Linux should only toggle between the value resulting >> from power design and off. > > It's not in general true that Linux should never change the mode (the > main case for toggling modes is usually going between an idle/suspend > state and active state) I believe this is yet another reason why we should have a way to specify opmodes in DT, now not only active but also suspend/idle opmodes. However on many PMICs this is a bit more complicated. There are opmodes such as 1) Regulator powered off. 2) Regulator powered off if certain pin is active, regulator powered on otherwise. 3) Regulator powered on. some of them might also have more interesting combinations, e.g. 4) Regulator powered off if certain pin is active, regulator powered on in low power mode otherwise. 5) Regulator powered on in lower power mode if certain pin is active, regulator powered on in full power mode otherwise. They all go to the same opmode field, as "off", "low power", "normal" mentioned earlier in this thread. > and for practical purposes bootloader and > hardware defaults tend to be the same. Not on the boards I worked with. At least when it's just about the difference between normal and low power modes. I believe the hardware will always default to normal just to be safe, so to optimize power on the board, the bootloader will switch those which don't need full power to low power mode. I believe we shouldn't even rely on the bootloader here, as we all know that often all you can expect from them is to load and jump to your kernel and even some of them can't do this properly... > You're talking about the case > where the bootloader does set something but avoids doing so on warm > reboots only here. From Javier's description I understood this is the case for the board for which he develops. > > Besides, even if we did have a way of specifying modes in DT (with all > the problems that brings) we still have to pick a default if that's not > used). Sure we do and we can define the binding to default to something (e.g. normal mode) if respective property is not present. Btw. the issue with opmode also affects other PMIC chips such as Samsung S5M ones. Best regards, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 27.08.2014 22:41, Tomasz Figa wrote: > On 27.08.2014 22:25, Mark Brown wrote: >> On Wed, Aug 27, 2014 at 09:58:55PM +0200, Tomasz Figa wrote: >>> On 27.08.2014 21:44, Mark Brown wrote: >> >>>> The point is that if anything was setting the mode to something other >>>> than normal it was almost certainly a previously running copy of Linux >>>> and one would expect that if the mode does need to be changed the new >>>> copy will be doing that anyway. It's rare enough to need to actively >>>> manage modes in the first place. >> >>> From what I know based on my experience with Samsung boards we used, the >>> opmodes of regulators are preconfigured by board bootloader to certain >>> values based on power design of the board (i.e. there is no need to keep >>> a regulator in full power mode, if on given board only a little fraction >>> of it is needed). >> >> Well, presumably the bootloader is going to run again even for a warm >> reboot? > > This is strange, but apparently it's not the case for the hardware which > this patch is supposed to fix or at least this is how I understood it. > OK, I just realized that Javier's problem might be caused by the fact that the bootloader he use doesn't change the regulators from defaults at all. In this case this patch is just fine. Best regards, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Aug 27, 2014 at 10:41:42PM +0200, Tomasz Figa wrote: > On 27.08.2014 22:25, Mark Brown wrote: > > Well, presumably the bootloader is going to run again even for a warm > > reboot? > This is strange, but apparently it's not the case for the hardware which > this patch is supposed to fix or at least this is how I understood it. Fun. It's like everyone was setting out to define the most fragile system they could, from the chip design up... so many moving pieces that have to line up. > > It's not in general true that Linux should never change the mode (the > > main case for toggling modes is usually going between an idle/suspend > > state and active state) > I believe this is yet another reason why we should have a way to specify > opmodes in DT, now not only active but also suspend/idle opmodes. > However on many PMICs this is a bit more complicated. There are opmodes > such as Well, quite. Plus the more basic question of what a mode actually is and how you talk about them generically. It's not that there's no use for this functionality, it's that it doesn't lend itself to defining ABIs. > > You're talking about the case > > where the bootloader does set something but avoids doing so on warm > > reboots only here. > From Javier's description I understood this is the case for the board > for which he develops. No, the issue is that the bootloader isn't touching the regulator then Linux turns it off, reboots and ends up thinking the default operating mode is off which doesn't work terribly well when it tries to enable the regulator. The reading back from hardware is trying to implement the standard Linux behaviour of not changing a setting without explicit permission, this change is providing a fallback for the case where that's giving us something obviously wrong. > > Besides, even if we did have a way of specifying modes in DT (with all > > the problems that brings) we still have to pick a default if that's not > > used). > Sure we do and we can define the binding to default to something (e.g. > normal mode) if respective property is not present. Btw. the issue with > opmode also affects other PMIC chips such as Samsung S5M ones. That's then going against our purposely conservative implementation, and would be especially bad if it overrode one of the hardware managed modes on an otherwise unused regulator.
Hello Tomasz and Mark, Sorry for not answering before but I'm on vacations until Sep, 5 and I have limited access to my email. On Wed, Aug 27, 2014 at 11:03 PM, Tomasz Figa <tomasz.figa@gmail.com> wrote: >>>> From what I know based on my experience with Samsung boards we used, the >>>> opmodes of regulators are preconfigured by board bootloader to certain >>>> values based on power design of the board (i.e. there is no need to keep >>>> a regulator in full power mode, if on given board only a little fraction >>>> of it is needed). >>> This is the case for Chromebooks as well but the solution implemented in the downstream Chrome OS 3.8 kernel is what Tomasz suggested before, the max77802/686 PMIC regulator driver has a DT binding that allows to define the initial opmode for each regulator: Required properties for each regulator: - regulator-op-mode : Regulator operating mode, the meaning is regulator- dependent. Valid values are 0-3. >>> Well, presumably the bootloader is going to run again even for a warm >>> reboot? >> >> This is strange, but apparently it's not the case for the hardware which >> this patch is supposed to fix or at least this is how I understood it. >> > > OK, I just realized that Javier's problem might be caused by the fact > that the bootloader he use doesn't change the regulators from defaults > at all. In this case this patch is just fine. > Yes, AFAIK the bootloader (none of them because Chromebooks use two chained U-boots) change the regulators default opmode so once is set to OFF on .disable, that value is preserved on warm reboot. This made sense with the Chrome OS kernel since the kernel always set the opmode defined in the "regulator-op-mode" DT property and did not relied on the bootloader to set the most efficient default opmode. As Tomasz said this issue also affects other PMICs, for example a similar DT binding was proposed [0] for the max77686 PMIC which is very similar to the max77802. Doug even suggested in that thread a more generic DT binding that could be part of the regulator core. At the end that DT binding was not merged and the max77686 driver just sets the default operating mode for all regulators to NORMAL and does not even read the value reported by the hardware registers. So in that regard the max77802 driver (even after this patch) does better since at least respects the default opmode read from the hardware register if is not OFF. Also, other drivers have customs operating mode DT properties, please take a look at Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt: The above regulator entries are defined in regulator bindings documentation except these properties: - op_mode: describes the different operating modes of the LDO's with power mode change in SOC. The different possible values are, 0 - always off mode 1 - on in normal mode 2 - low power mode 3 - suspend mode This is not a great binding IMHO since not only uses a quite generic "op_mode" for property that is driver specific ("s5m8767,op-mode" or something would had been better) but also this seems to be a general issue for many platforms so if we don't try to solve this with a generic approach, each driver author will try to solve it in its own way. > Best regards, > Tomasz > -- Best regards, Javier [0]: https://patchwork.kernel.org/patch/1855331/ -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Aug 28, 2014 at 12:44:18AM +0200, Javier Martinez Canillas wrote: > On Wed, Aug 27, 2014 at 11:03 PM, Tomasz Figa <tomasz.figa@gmail.com> wrote: > This is the case for Chromebooks as well but the solution implemented > in the downstream Chrome OS 3.8 kernel is what Tomasz suggested *sigh* This is not what you were describing, though most of what you then go on to say doesn't correspond to the issue Tomasz was describing. > Yes, AFAIK the bootloader (none of them because Chromebooks use two > chained U-boots) change the regulators default opmode so once is set > to OFF on .disable, that value is preserved on warm reboot. This made > sense with the Chrome OS kernel since the kernel always set the opmode > defined in the "regulator-op-mode" DT property and did not relied on > the bootloader to set the most efficient default opmode. I'm sorry but this is just really unclear. Does the bootloader change the mode or does it not change the mode? You start off saying that the bootloader does change the mode, then go on to say that it doesn't and that the system relies on Linux changing the mode (which is consistent with what you were originally saying and what you say for much of the rest of this mail but not with what Tomasz was talking about). > Also, other drivers have customs operating mode DT properties, please > take a look at Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt: Per driver things can potentially be fine, trying to define generic properties is much harder.
Hello Mark, > On 28/08/2014, at 10:28, Mark Brown <broonie@kernel.org> wrote: >> Yes, AFAIK the bootloader (none of them because Chromebooks use two >> chained U-boots) change the regulators default opmode so once is set >> to OFF on .disable, that value is preserved on warm reboot. This made >> sense with the Chrome OS kernel since the kernel always set the opmode >> defined in the "regulator-op-mode" DT property and did not relied on >> the bootloader to set the most efficient default opmode. > > I'm sorry but this is just really unclear. Does the bootloader change > the mode or does it not change the mode? I meant that the boot loader *does not* change the mode and is Linux who change it, sorry for the confusion. Best regards, Javier-- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Aug 28, 2014 at 11:59:16AM +0200, Javier Martinez Canillas wrote: > > On 28/08/2014, at 10:28, Mark Brown <broonie@kernel.org> wrote: > >> Yes, AFAIK the bootloader (none of them because Chromebooks use two > >> chained U-boots) change the regulators default opmode so once is set > >> to OFF on .disable, that value is preserved on warm reboot. This made > >> sense with the Chrome OS kernel since the kernel always set the opmode > >> defined in the "regulator-op-mode" DT property and did not relied on > >> the bootloader to set the most efficient default opmode. > > I'm sorry but this is just really unclear. Does the bootloader change > > the mode or does it not change the mode? > I meant that the boot loader *does not* change the mode and is Linux > who change it, sorry for the confusion. Ah, OK. Like I say that's a separate concern to the one Tomasz was raising - he is worried about the case where we change the mode in the bootloader but only on cold boot.
diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c index ad1caa9..967e109 100644 --- a/drivers/regulator/max77802.c +++ b/drivers/regulator/max77802.c @@ -540,7 +540,17 @@ static int max77802_pmic_probe(struct platform_device *pdev) config.of_node = pdata->regulators[i].of_node; ret = regmap_read(iodev->regmap, regulators[i].enable_reg, &val); - max77802->opmode[id] = val >> shift & MAX77802_OPMODE_MASK; + val = val >> shift & MAX77802_OPMODE_MASK; + + /* + * If the regulator is disabled and the system warm rebooted, + * the hardware reports OFF as the regulator operating mode. + * Default to operating mode NORMAL in that case. + */ + if (val == MAX77802_OPMODE_OFF) + max77802->opmode[id] = MAX77802_OPMODE_NORMAL; + else + max77802->opmode[id] = val; rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config);
The max77802 driver reads the default operating mode (opmode) set for regulators when enabled from the hardware registers. But if a regulator is disabled and the system warm restarted, the hardware reports OFF as the opmode so the regulator is not enabled. Default to operating mode NORMAL if OFF is read from the hardware register. Reported-by: Yuvaraj Cd <yuvaraj.lkml@gmail.com> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> --- This patch fixes the issue reported in https://lkml.org/lkml/2014/8/25/69 drivers/regulator/max77802.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)