All of lore.kernel.org
 help / color / mirror / Atom feed
* Where to update regulator register with initial voltage set by HW
@ 2017-06-29  7:18 Waldemar Rymarkiewicz
  2017-06-30 10:41 ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Waldemar Rymarkiewicz @ 2017-06-29  7:18 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood

Hi,

I do a power regulator driver and  I have faced an issue with an
initial voltage value set  (or rather not set) in regulator register.

Initially, on boot, the voltage is set by HW (sensing resistors). When
OS starts and the reg driver registers regulator with the specific
constraints uV_min and uV_max, regulator core will apply uV_min or
uV_max if current (in regulator register) setting is not in the range.
Normally, by default register holds min(voltage_table) which is
different than the value set by HW (sensing resistors).

So, it results in uV_min set by regulator core which is not expected
as I start my board with max cpu freq which needs relevant voltage
(the power reg supplies CPU)  in order CPU to be stable.

I believe this issue is not specific just to my HW, so wondering where
in the system the actual voltage set by HW is typically also put into
the register, so probing regulator we can read the real value?
bootloader seems to be a good candidate? platform code?

Will appreciate any hints.

Thanks
/Waldek

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-06-29  7:18 Where to update regulator register with initial voltage set by HW Waldemar Rymarkiewicz
@ 2017-06-30 10:41 ` Mark Brown
  2017-06-30 11:37   ` Waldemar Rymarkiewicz
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2017-06-30 10:41 UTC (permalink / raw)
  To: Waldemar Rymarkiewicz; +Cc: linux-kernel, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 635 bytes --]

On Thu, Jun 29, 2017 at 09:18:09AM +0200, Waldemar Rymarkiewicz wrote:

> Initially, on boot, the voltage is set by HW (sensing resistors). When
> OS starts and the reg driver registers regulator with the specific
> constraints uV_min and uV_max, regulator core will apply uV_min or
> uV_max if current (in regulator register) setting is not in the range.
> Normally, by default register holds min(voltage_table) which is
> different than the value set by HW (sensing resistors).

You shoudn't be specfiying a default value for the register, clearly
there is none as it is determined dynamically by the hardware when the
system boots.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-06-30 10:41 ` Mark Brown
@ 2017-06-30 11:37   ` Waldemar Rymarkiewicz
  2017-06-30 12:14     ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Waldemar Rymarkiewicz @ 2017-06-30 11:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Liam Girdwood, Bartholomae, Thomas

On 30 June 2017 at 12:41, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Jun 29, 2017 at 09:18:09AM +0200, Waldemar Rymarkiewicz wrote:
>
>> Initially, on boot, the voltage is set by HW (sensing resistors). When
>> OS starts and the reg driver registers regulator with the specific
>> constraints uV_min and uV_max, regulator core will apply uV_min or
>> uV_max if current (in regulator register) setting is not in the range.
>> Normally, by default register holds min(voltage_table) which is
>> different than the value set by HW (sensing resistors).
>
> You shoudn't be specfiying a default value for the register, clearly
> there is none as it is determined dynamically by the hardware when the
> system boots.

Thanks Mark for your feedback.

I am not sure if I understand. Do you mean, a regulator should
determine a voltage and update a register with a right selector when
system boots, so the regulator framework reading reg register knows
actual voltage?

BTW, I work with TPS65273 regulator.

/Waldek

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-06-30 11:37   ` Waldemar Rymarkiewicz
@ 2017-06-30 12:14     ` Mark Brown
  2017-06-30 12:26       ` Bartholomae, Thomas
  2017-06-30 15:25       ` Waldemar Rymarkiewicz
  0 siblings, 2 replies; 11+ messages in thread
From: Mark Brown @ 2017-06-30 12:14 UTC (permalink / raw)
  To: Waldemar Rymarkiewicz; +Cc: linux-kernel, Liam Girdwood, Bartholomae, Thomas

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

On Fri, Jun 30, 2017 at 01:37:32PM +0200, Waldemar Rymarkiewicz wrote:

> I am not sure if I understand. Do you mean, a regulator should
> determine a voltage and update a register with a right selector when
> system boots, so the regulator framework reading reg register knows
> actual voltage?

Just don't provide a default value for the cache, regmap will do a
physical read if there's nothing in the cache for that register and
everything will work transparently.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: Where to update regulator register with initial voltage set by HW
  2017-06-30 12:14     ` Mark Brown
@ 2017-06-30 12:26       ` Bartholomae, Thomas
  2017-07-03 15:11         ` Mark Brown
  2017-06-30 15:25       ` Waldemar Rymarkiewicz
  1 sibling, 1 reply; 11+ messages in thread
From: Bartholomae, Thomas @ 2017-06-30 12:26 UTC (permalink / raw)
  To: Mark Brown, Waldemar Rymarkiewicz; +Cc: linux-kernel, Liam Girdwood

Hi Mark,

The problem is that our used regulator TPS65273V from TI do not have the possibility to read the current voltage defined by the HW, means by the circuit of the regulator.
In this case the register holding the voltage to be set later by software has a reset value which is normally the min value the regulator can support. This value can be out of the range of the supported rail. Therefore before the regulator gets registered this register needs to be set with a 'good' value.
I assume the only practicable solution will be that we initialize this voltage register in the boot code where we also set the CPU frequency.
BR Thomas

-----Original Message-----
From: Mark Brown [mailto:broonie@kernel.org] 
Sent: Friday, June 30, 2017 14:15
To: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@gmail.com>
Cc: linux-kernel@vger.kernel.org; Liam Girdwood <lgirdwood@gmail.com>; Bartholomae, Thomas <t.bartholomae@intel.com>
Subject: Re: Where to update regulator register with initial voltage set by HW

On Fri, Jun 30, 2017 at 01:37:32PM +0200, Waldemar Rymarkiewicz wrote:

> I am not sure if I understand. Do you mean, a regulator should 
> determine a voltage and update a register with a right selector when 
> system boots, so the regulator framework reading reg register knows 
> actual voltage?

Just don't provide a default value for the cache, regmap will do a physical read if there's nothing in the cache for that register and everything will work transparently.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-06-30 12:14     ` Mark Brown
  2017-06-30 12:26       ` Bartholomae, Thomas
@ 2017-06-30 15:25       ` Waldemar Rymarkiewicz
  1 sibling, 0 replies; 11+ messages in thread
From: Waldemar Rymarkiewicz @ 2017-06-30 15:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Liam Girdwood, Bartholomae, Thomas

On 30 June 2017 at 14:14, Mark Brown <broonie@kernel.org> wrote:
> On Fri, Jun 30, 2017 at 01:37:32PM +0200, Waldemar Rymarkiewicz wrote:
>
>> I am not sure if I understand. Do you mean, a regulator should
>> determine a voltage and update a register with a right selector when
>> system boots, so the regulator framework reading reg register knows
>> actual voltage?
>
> Just don't provide a default value for the cache, regmap will do a
> physical read if there's nothing in the cache for that register and
> everything will work transparently.

Just want to understand well. "Physical read" means to read a register
value? or determine actual value another way? As Thomas mentioned in
previous email TPS65275 does not have a circuit to determine startup
voltage at least I cannot see this in the datasheet.

Data sheet: http://www.ti.com/lit/gpn/tps65273v

/Waldek

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-06-30 12:26       ` Bartholomae, Thomas
@ 2017-07-03 15:11         ` Mark Brown
  2017-07-03 15:33           ` Waldemar Rymarkiewicz
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2017-07-03 15:11 UTC (permalink / raw)
  To: Bartholomae, Thomas; +Cc: Waldemar Rymarkiewicz, linux-kernel, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]

On Fri, Jun 30, 2017 at 12:26:52PM +0000, Bartholomae, Thomas wrote:
> Hi Mark,

Please don't top post, reply in line with needed context.  This allows
readers to readily follow the flow of conversation and understand what
you are talking about and also helps ensure that everything in the
discussion is being addressed.

Please fix your mail client to word wrap within paragraphs at something
substantially less than 80 columns.  Doing this makes your messages much
easier to read and reply to.

> The problem is that our used regulator TPS65273V from TI do not have
> the possibility to read the current voltage defined by the HW, means
> by the circuit of the regulator.  In this case the register holding
> the voltage to be set later by software has a reset value which is
> normally the min value the regulator can support. This value can be
> out of the range of the supported rail. Therefore before the regulator
> gets registered this register needs to be set with a 'good' value.  I
> assume the only practicable solution will be that we initialize this
> voltage register in the boot code where we also set the CPU frequency.

You probably need platform data to tell the kernelw hat teh startup
value is.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-07-03 15:11         ` Mark Brown
@ 2017-07-03 15:33           ` Waldemar Rymarkiewicz
  2017-07-03 15:36             ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Waldemar Rymarkiewicz @ 2017-07-03 15:33 UTC (permalink / raw)
  To: Mark Brown; +Cc: Bartholomae, Thomas, linux-kernel, Liam Girdwood

On 3 July 2017 at 17:11, Mark Brown <broonie@kernel.org> wrote:
> On Fri, Jun 30, 2017 at 12:26:52PM +0000, Bartholomae, Thomas wrote:
>> Hi Mark,
>
>> The problem is that our used regulator TPS65273V from TI do not have
>> the possibility to read the current voltage defined by the HW, means
>> by the circuit of the regulator.  In this case the register holding
>> the voltage to be set later by software has a reset value which is
>> normally the min value the regulator can support. This value can be
>> out of the range of the supported rail. Therefore before the regulator
>> gets registered this register needs to be set with a 'good' value.  I
>> assume the only practicable solution will be that we initialize this
>> voltage register in the boot code where we also set the CPU frequency.
>
> You probably need platform data to tell the kernelw hat teh startup
> value is.

I've asked also on TI forum if this is typical to the regulator not to
determine the startup voltage but still waiting for feedback. Anyway,
if this is the case I guess a driver is a good place to update
register before we register to the regulator framework.

Thanks Mark for your feedback.

/Waldek

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-07-03 15:33           ` Waldemar Rymarkiewicz
@ 2017-07-03 15:36             ` Mark Brown
  2017-07-04 10:58               ` Waldemar Rymarkiewicz
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Brown @ 2017-07-03 15:36 UTC (permalink / raw)
  To: Waldemar Rymarkiewicz; +Cc: Bartholomae, Thomas, linux-kernel, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

On Mon, Jul 03, 2017 at 05:33:03PM +0200, Waldemar Rymarkiewicz wrote:

> I've asked also on TI forum if this is typical to the regulator not to
> determine the startup voltage but still waiting for feedback. Anyway,
> if this is the case I guess a driver is a good place to update
> register before we register to the regulator framework.

It's really unusual to have a device that has the voltage changable by
register write at runtime where the current state can't be read back.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-07-03 15:36             ` Mark Brown
@ 2017-07-04 10:58               ` Waldemar Rymarkiewicz
  2017-07-04 11:19                 ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Waldemar Rymarkiewicz @ 2017-07-04 10:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: Bartholomae, Thomas, linux-kernel, Liam Girdwood

Hi Mark,

On 3 July 2017 at 17:36, Mark Brown <broonie@kernel.org> wrote:
> On Mon, Jul 03, 2017 at 05:33:03PM +0200, Waldemar Rymarkiewicz wrote:
>
>> I've asked also on TI forum if this is typical to the regulator not to
>> determine the startup voltage but still waiting for feedback. Anyway,
>> if this is the case I guess a driver is a good place to update
>> register before we register to the regulator framework.
>
> It's really unusual to have a device that has the voltage changable by
> register write at runtime where the current state can't be read back.

or you did not realise that this is initialised by bootloader for example.

After investigating this issue a bit more I've found that this is
rather typical for power regulators not to update a register with
startup voltage set by a feedback resistor divider as it would cost
extra circuit.  So, I assume that most likely a bootloader normally
initializes power regulator in case it's needed eg. if it's supplying
CPU which is DVS-enabled.

Anyway, it's more clear now to me how this should be done.

/Waldek

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Where to update regulator register with initial voltage set by HW
  2017-07-04 10:58               ` Waldemar Rymarkiewicz
@ 2017-07-04 11:19                 ` Mark Brown
  0 siblings, 0 replies; 11+ messages in thread
From: Mark Brown @ 2017-07-04 11:19 UTC (permalink / raw)
  To: Waldemar Rymarkiewicz; +Cc: Bartholomae, Thomas, linux-kernel, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]

On Tue, Jul 04, 2017 at 12:58:04PM +0200, Waldemar Rymarkiewicz wrote:
> On 3 July 2017 at 17:36, Mark Brown <broonie@kernel.org> wrote:
> > On Mon, Jul 03, 2017 at 05:33:03PM +0200, Waldemar Rymarkiewicz wrote:

> >> I've asked also on TI forum if this is typical to the regulator not to
> >> determine the startup voltage but still waiting for feedback. Anyway,
> >> if this is the case I guess a driver is a good place to update
> >> register before we register to the regulator framework.

> > It's really unusual to have a device that has the voltage changable by
> > register write at runtime where the current state can't be read back.

> or you did not realise that this is initialised by bootloader for example.

No, it's just incredibly unusual to have hardware that does this.

> After investigating this issue a bit more I've found that this is
> rather typical for power regulators not to update a register with
> startup voltage set by a feedback resistor divider as it would cost
> extra circuit.  So, I assume that most likely a bootloader normally
> initializes power regulator in case it's needed eg. if it's supplying
> CPU which is DVS-enabled.

The majority of things that have configuration based on bias resistors
just wouldn't have any register based control at all, or wouldn't have
any physical readback (for really old devices that were concerned with
the I2C licensing issues).  I'm pretty surprised to see such a
combination in a current system.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-07-04 11:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29  7:18 Where to update regulator register with initial voltage set by HW Waldemar Rymarkiewicz
2017-06-30 10:41 ` Mark Brown
2017-06-30 11:37   ` Waldemar Rymarkiewicz
2017-06-30 12:14     ` Mark Brown
2017-06-30 12:26       ` Bartholomae, Thomas
2017-07-03 15:11         ` Mark Brown
2017-07-03 15:33           ` Waldemar Rymarkiewicz
2017-07-03 15:36             ` Mark Brown
2017-07-04 10:58               ` Waldemar Rymarkiewicz
2017-07-04 11:19                 ` Mark Brown
2017-06-30 15:25       ` Waldemar Rymarkiewicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.