2017-06-29 07:19:01

by Waldemar Rymarkiewicz

[permalink] [raw]
Subject: Where to update regulator register with initial voltage set by HW

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


2017-06-30 10:41:49

by Mark Brown

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

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.


Attachments:
(No filename) (635.00 B)
signature.asc (488.00 B)
Download all attachments

2017-06-30 11:38:31

by Waldemar Rymarkiewicz

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

On 30 June 2017 at 12:41, Mark Brown <[email protected]> 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

2017-06-30 12:15:02

by Mark Brown

[permalink] [raw]
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.


Attachments:
(No filename) (468.00 B)
signature.asc (488.00 B)
Download all attachments

2017-06-30 12:28:58

by Bartholomae, Thomas

[permalink] [raw]
Subject: RE: Where to update regulator register with initial voltage set by HW

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:[email protected]]
Sent: Friday, June 30, 2017 14:15
To: Waldemar Rymarkiewicz <[email protected]>
Cc: [email protected]; Liam Girdwood <[email protected]>; Bartholomae, Thomas <[email protected]>
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.

2017-06-30 15:26:21

by Waldemar Rymarkiewicz

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

On 30 June 2017 at 14:14, Mark Brown <[email protected]> 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

2017-07-03 15:11:54

by Mark Brown

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

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.


Attachments:
(No filename) (1.19 kB)
signature.asc (488.00 B)
Download all attachments

2017-07-03 15:33:49

by Waldemar Rymarkiewicz

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

On 3 July 2017 at 17:11, Mark Brown <[email protected]> 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

2017-07-03 15:36:46

by Mark Brown

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

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.


Attachments:
(No filename) (482.00 B)
signature.asc (488.00 B)
Download all attachments

2017-07-04 10:58:47

by Waldemar Rymarkiewicz

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

Hi Mark,

On 3 July 2017 at 17:36, Mark Brown <[email protected]> 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

2017-07-04 11:19:51

by Mark Brown

[permalink] [raw]
Subject: Re: Where to update regulator register with initial voltage set by HW

On Tue, Jul 04, 2017 at 12:58:04PM +0200, Waldemar Rymarkiewicz wrote:
> On 3 July 2017 at 17:36, Mark Brown <[email protected]> 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.


Attachments:
(No filename) (1.44 kB)
signature.asc (488.00 B)
Download all attachments