Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-09-02 Thread Mark Brown
On Tue, Sep 01, 2015 at 11:56:06AM -0700, Tony Lindgren wrote:
> * Mark Brown  [150901 11:40]:

> > That'd work.  The other thing I was thinking we could do is to get
> > syscon to treat any excessively large address that gets passed in that
> > looks like an absolute address appropriately.

> Hmm wouldn't that get messy for 64-bit :) How about something
> like:

Meh, it'd probably be fine - I was thinking falling back to trying to
substract the base address if the passed address was out of bounds.
It's not super elegant though, something that directly does the right
thing would be better.

> unsigned long syscon_regmap_get_offset(struct regmap *syscon,
>   void __iomem *base)

> Not sure if that's something that some drivers would start to
> misuse with read/writel though.. Presumably not if the driver
> already is using syscon.

It should be really easy to spot abuse I'd hope.


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-09-01 Thread Tony Lindgren
* Mark Brown  [150901 11:40]:
> On Tue, Sep 01, 2015 at 07:17:21AM -0700, Tony Lindgren wrote:
> 
> > Why don't you just make reg unused for pbias_regulator since
> > we already use regmap for this driver?
> 
> > Then in the pbias driver just define the register offset from
> > the syscon base? You may need to set it based on the compatible
> > value, but it's not like it's going to change for SoC.
> 
> > If we eventually add some API to calculate reg base offset
> > from the syscon base it's easy to update the driver to use
> > that.
> 
> That'd work.  The other thing I was thinking we could do is to get
> syscon to treat any excessively large address that gets passed in that
> looks like an absolute address appropriately.

Hmm wouldn't that get messy for 64-bit :) How about something
like:

unsigned long syscon_regmap_get_offset(struct regmap *syscon,
void __iomem *base)

Not sure if that's something that some drivers would start to
misuse with read/writel though.. Presumably not if the driver
already is using syscon.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-09-01 Thread Mark Brown
On Tue, Sep 01, 2015 at 07:17:21AM -0700, Tony Lindgren wrote:

> Why don't you just make reg unused for pbias_regulator since
> we already use regmap for this driver?

> Then in the pbias driver just define the register offset from
> the syscon base? You may need to set it based on the compatible
> value, but it's not like it's going to change for SoC.

> If we eventually add some API to calculate reg base offset
> from the syscon base it's easy to update the driver to use
> that.

That'd work.  The other thing I was thinking we could do is to get
syscon to treat any excessively large address that gets passed in that
looks like an absolute address appropriately.


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-09-01 Thread Tony Lindgren
Hi,

I think the fix is rather easy here.. See below.

* Kishon Vijay Abraham I  [150901 02:43]:
> 
> Before commit d919501feffa8715147582c3ffce96fad0c7016f ARM: dts: dra7:
> add minimal l4 bus layout with control module support, the dt was like
> 
> ocp {
>   dra7_ctrl_general: tisyscon@4a002e00 {
>   compatible = "syscon";
>   reg = <0x4a002e00 0x7c>;
>   };
> 
>   pbias_regulator: pbias_regulator {
>   compatible = "ti,pbias-omap";
>   reg = <0 0x4>;
>   syscon = <&dra7_ctrl_general>;
>   };
> };

Yes the reg = <0 0x4> above is wrong, it's not an offset from the
ocp but from the syscon base.
 
> But after commit d919501fef, the dt became like this (after a couple of
> fixes)
> 
> ocp {
>   l4_cfg: l4@4a00 {
>   compatible = "ti,dra7-l4-cfg", "simple-bus";
>   ranges = <0 0x4a00 0x22c000>;
> 
>   scm: scm@2000 {
>   compatible = "ti,dra7-scm-core", "simple-bus";
>   reg = <0x2000 0x2000>;
>   ranges = <0 0x2000 0x2000>;
> 
>   scm_conf: scm_conf@0 {
>   compatible = "syscon", "simple-bus";
>   reg = <0x0 0x1400>;
>   ranges = <0 0x0 0x1400>;
> 
>   pbias_regulator: pbias_regulator {
>   compatible = "ti,pbias-omap";
>   reg = <0xe00 0x4>;
>   syscon = <&scm_conf>;
> };
>   };
>   };
>   };
> };

And here we properly describe the hardware interconnect layout and
of_ioremap and friends do the right thing. And reg = <0xxe00 0x4>
is correct offset from the scm_conf base.

Why don't you just make reg unused for pbias_regulator since
we already use regmap for this driver?

Then in the pbias driver just define the register offset from
the syscon base? You may need to set it based on the compatible
value, but it's not like it's going to change for SoC.

If we eventually add some API to calculate reg base offset
from the syscon base it's easy to update the driver to use
that.

Cheers,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-09-01 Thread Kishon Vijay Abraham I
Now fixed Lee Jones mail address!

On Tuesday 01 September 2015 03:10 PM, Kishon Vijay Abraham I wrote:
> Hi Mark,
> 
> On Monday 31 August 2015 08:22 PM, Mark Brown wrote:
>> On Mon, Aug 31, 2015 at 04:14:07PM +0530, Kishon Vijay Abraham I wrote:
>>> On Tuesday 25 August 2015 07:20 PM, Mark Brown wrote:
 On Tue, Aug 25, 2015 at 01:03:04PM +0300, Grygorii Strashko wrote:
> On 08/19/2015 09:11 PM, Mark Brown wrote:
>>
>> So substract this address from the start of the resource to get the
>> offset?  Or provide a wrapper function in the resource code which does
>> that.  

> I'd be very appreciated if you have and can share any thought on
> How can we get this absolute base address to substract?

 Ask the syscon device for its resource?  Or have it provide an absolute
>>>
>>> Even if we get the absolute address of syscon, we have to do the
>>> subtraction only for the newer dtbs (previous dtbs already have only the
>>> offset). Do you recommend adding a new property to differentiate between
>>> older dtbs and newer dtbs? Any other suggestions here?
>>
>> Hang on.  This is the first I've heard of any DTs not just having
>> absolute addresses.  How does any of this work - has it ever worked, and
>> is the situation completely understood?  My original concern with this
> 
> Before commit d919501feffa8715147582c3ffce96fad0c7016f ARM: dts: dra7:
> add minimal l4 bus layout with control module support, the dt was like
> 
> ocp {
>   dra7_ctrl_general: tisyscon@4a002e00 {
>   compatible = "syscon";
>   reg = <0x4a002e00 0x7c>;
>   };
> 
>   pbias_regulator: pbias_regulator {
>   compatible = "ti,pbias-omap";
>   reg = <0 0x4>;
>   syscon = <&dra7_ctrl_general>;
>   };
> };
> 
> Here platform_get_resource in pbias driver returns '0' which is
> populated in vsel_reg and enable_reg. And regulator_enable_regmap uses
> the base address from tisyscon@4a002e00 which is '0x4a002e00' and offset
> from enable_reg which is '0' inorder to write to the pbias register.
> 
> But after commit d919501fef, the dt became like this (after a couple of
> fixes)
> 
> ocp {
>   l4_cfg: l4@4a00 {
>   compatible = "ti,dra7-l4-cfg", "simple-bus";
>   ranges = <0 0x4a00 0x22c000>;
> 
>   scm: scm@2000 {
>   compatible = "ti,dra7-scm-core", "simple-bus";
>   reg = <0x2000 0x2000>;
>   ranges = <0 0x2000 0x2000>;
> 
>   scm_conf: scm_conf@0 {
>   compatible = "syscon", "simple-bus";
>   reg = <0x0 0x1400>;
>   ranges = <0 0x0 0x1400>;
> 
>   pbias_regulator: pbias_regulator {
>   compatible = "ti,pbias-omap";
>   reg = <0xe00 0x4>;
>   syscon = <&scm_conf>;
> };
>   };
>   };
>   };
> };
> 
> Here platform_get_resource in pbias driver returns '4a002e00' which is
> populated in vsel_reg and enable_reg. And regulator_enable_regmap uses
> the base address from scm_conf@0 which is '0x4a002000' and offset from
> enable_reg which is '4a002e00' inorder to write to the pbias register
> and it results in a abort.
> 
>> was that I coudn't understand the commit log and your original response
>> seemed to indicate that we always have the absolute address :(  Perhaps
> 
> We started having the absolute address only after the dt change (commit
> d919501fef and a couple of more dt fixes).
> 
>> this is something to do with the brief mention of having moved the DT
>> node for some reason?
>>
>> We at least need some sort of coherent explanation of the problem and a
>> comprehensible fix to go with it.  Right now it seems like things are
>> just being moved about to hide problems without either of these things
>> which seems like it makes the code less clear and more fragile.
> 
> hmm.. IMO the actual problem was modelling the 'offset' as a resource
> (by populating the offset in 'reg' property) which was added when the
> initial pbias dt node was created. And now since the pbias dt node is
> being moved around, it's causing inadvertent address translation
> breaking the pbias driver. IMHO the value in 'reg' property of pbias dt
> node should be treated as 'offset' instead of address 'resource' and
> that's what my patch tried to do.
>>
 address based interface for that matter?
>>
>>> Syscon doesn't directly expose any API's to write to it's register.
>>> Rather it uses regmap APIs to read/write to it's register. I'm not sure
>>> if it's possible to add regmap APIs to write to a register with absolute
>>> address. Any hints?
>>
>> Yes, I'm aware that it is regmap based!  What I am suggesting is that if
>> people are making DTs like you

Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-09-01 Thread Kishon Vijay Abraham I
Hi Mark,

On Monday 31 August 2015 08:22 PM, Mark Brown wrote:
> On Mon, Aug 31, 2015 at 04:14:07PM +0530, Kishon Vijay Abraham I wrote:
>> On Tuesday 25 August 2015 07:20 PM, Mark Brown wrote:
>>> On Tue, Aug 25, 2015 at 01:03:04PM +0300, Grygorii Strashko wrote:
 On 08/19/2015 09:11 PM, Mark Brown wrote:
> 
> So substract this address from the start of the resource to get the
> offset?  Or provide a wrapper function in the resource code which does
> that.  
>>>
 I'd be very appreciated if you have and can share any thought on
 How can we get this absolute base address to substract?
>>>
>>> Ask the syscon device for its resource?  Or have it provide an absolute
>>
>> Even if we get the absolute address of syscon, we have to do the
>> subtraction only for the newer dtbs (previous dtbs already have only the
>> offset). Do you recommend adding a new property to differentiate between
>> older dtbs and newer dtbs? Any other suggestions here?
> 
> Hang on.  This is the first I've heard of any DTs not just having
> absolute addresses.  How does any of this work - has it ever worked, and
> is the situation completely understood?  My original concern with this

Before commit d919501feffa8715147582c3ffce96fad0c7016f ARM: dts: dra7:
add minimal l4 bus layout with control module support, the dt was like

ocp {
dra7_ctrl_general: tisyscon@4a002e00 {
compatible = "syscon";
reg = <0x4a002e00 0x7c>;
};

pbias_regulator: pbias_regulator {
compatible = "ti,pbias-omap";
reg = <0 0x4>;
syscon = <&dra7_ctrl_general>;
};
};

Here platform_get_resource in pbias driver returns '0' which is
populated in vsel_reg and enable_reg. And regulator_enable_regmap uses
the base address from tisyscon@4a002e00 which is '0x4a002e00' and offset
from enable_reg which is '0' inorder to write to the pbias register.

But after commit d919501fef, the dt became like this (after a couple of
fixes)

ocp {
l4_cfg: l4@4a00 {
compatible = "ti,dra7-l4-cfg", "simple-bus";
ranges = <0 0x4a00 0x22c000>;

scm: scm@2000 {
compatible = "ti,dra7-scm-core", "simple-bus";
reg = <0x2000 0x2000>;
ranges = <0 0x2000 0x2000>;

scm_conf: scm_conf@0 {
compatible = "syscon", "simple-bus";
reg = <0x0 0x1400>;
ranges = <0 0x0 0x1400>;

pbias_regulator: pbias_regulator {
compatible = "ti,pbias-omap";
reg = <0xe00 0x4>;
syscon = <&scm_conf>;
};
};
};
};
};

Here platform_get_resource in pbias driver returns '4a002e00' which is
populated in vsel_reg and enable_reg. And regulator_enable_regmap uses
the base address from scm_conf@0 which is '0x4a002000' and offset from
enable_reg which is '4a002e00' inorder to write to the pbias register
and it results in a abort.

> was that I coudn't understand the commit log and your original response
> seemed to indicate that we always have the absolute address :(  Perhaps

We started having the absolute address only after the dt change (commit
d919501fef and a couple of more dt fixes).

> this is something to do with the brief mention of having moved the DT
> node for some reason?
> 
> We at least need some sort of coherent explanation of the problem and a
> comprehensible fix to go with it.  Right now it seems like things are
> just being moved about to hide problems without either of these things
> which seems like it makes the code less clear and more fragile.

hmm.. IMO the actual problem was modelling the 'offset' as a resource
(by populating the offset in 'reg' property) which was added when the
initial pbias dt node was created. And now since the pbias dt node is
being moved around, it's causing inadvertent address translation
breaking the pbias driver. IMHO the value in 'reg' property of pbias dt
node should be treated as 'offset' instead of address 'resource' and
that's what my patch tried to do.
> 
>>> address based interface for that matter?
> 
>> Syscon doesn't directly expose any API's to write to it's register.
>> Rather it uses regmap APIs to read/write to it's register. I'm not sure
>> if it's possible to add regmap APIs to write to a register with absolute
>> address. Any hints?
> 
> Yes, I'm aware that it is regmap based!  What I am suggesting is that if
> people are making DTs like yours with devices that are children of the
> syscon then presumably it might be useful for it to allow client drivers
> to pass absolute addresses in so that it can translate for them.

Arnd, Lee?

Thanks
Kishon
--
To unsubscribe

Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-31 Thread Mark Brown
On Mon, Aug 31, 2015 at 04:14:07PM +0530, Kishon Vijay Abraham I wrote:
> On Tuesday 25 August 2015 07:20 PM, Mark Brown wrote:
> > On Tue, Aug 25, 2015 at 01:03:04PM +0300, Grygorii Strashko wrote:
> >> On 08/19/2015 09:11 PM, Mark Brown wrote:

> >>> So substract this address from the start of the resource to get the
> >>> offset?  Or provide a wrapper function in the resource code which does
> >>> that.  
> > 
> >> I'd be very appreciated if you have and can share any thought on
> >> How can we get this absolute base address to substract?
> > 
> > Ask the syscon device for its resource?  Or have it provide an absolute
> 
> Even if we get the absolute address of syscon, we have to do the
> subtraction only for the newer dtbs (previous dtbs already have only the
> offset). Do you recommend adding a new property to differentiate between
> older dtbs and newer dtbs? Any other suggestions here?

Hang on.  This is the first I've heard of any DTs not just having
absolute addresses.  How does any of this work - has it ever worked, and
is the situation completely understood?  My original concern with this
was that I coudn't understand the commit log and your original response
seemed to indicate that we always have the absolute address :(  Perhaps
this is something to do with the brief mention of having moved the DT
node for some reason?

We at least need some sort of coherent explanation of the problem and a
comprehensible fix to go with it.  Right now it seems like things are
just being moved about to hide problems without either of these things
which seems like it makes the code less clear and more fragile.

> > address based interface for that matter?

> Syscon doesn't directly expose any API's to write to it's register.
> Rather it uses regmap APIs to read/write to it's register. I'm not sure
> if it's possible to add regmap APIs to write to a register with absolute
> address. Any hints?

Yes, I'm aware that it is regmap based!  What I am suggesting is that if
people are making DTs like yours with devices that are children of the
syscon then presumably it might be useful for it to allow client drivers
to pass absolute addresses in so that it can translate for them.


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-31 Thread Kishon Vijay Abraham I
Hi Mark,

On Tuesday 25 August 2015 07:20 PM, Mark Brown wrote:
> On Tue, Aug 25, 2015 at 01:03:04PM +0300, Grygorii Strashko wrote:
>> On 08/19/2015 09:11 PM, Mark Brown wrote:
> 
>>> So substract this address from the start of the resource to get the
>>> offset?  Or provide a wrapper function in the resource code which does
>>> that.  
> 
>> I'd be very appreciated if you have and can share any thought on
>> How can we get this absolute base address to substract?
> 
> Ask the syscon device for its resource?  Or have it provide an absolute

Even if we get the absolute address of syscon, we have to do the
subtraction only for the newer dtbs (previous dtbs already have only the
offset). Do you recommend adding a new property to differentiate between
older dtbs and newer dtbs? Any other suggestions here?

> address based interface for that matter?

Syscon doesn't directly expose any API's to write to it's register.
Rather it uses regmap APIs to read/write to it's register. I'm not sure
if it's possible to add regmap APIs to write to a register with absolute
address. Any hints?

Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-25 Thread Mark Brown
On Tue, Aug 25, 2015 at 01:03:04PM +0300, Grygorii Strashko wrote:
> On 08/19/2015 09:11 PM, Mark Brown wrote:

> > So substract this address from the start of the resource to get the
> > offset?  Or provide a wrapper function in the resource code which does
> > that.  

> I'd be very appreciated if you have and can share any thought on
> How can we get this absolute base address to substract?

Ask the syscon device for its resource?  Or have it provide an absolute
address based interface for that matter?


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-25 Thread Grygorii Strashko
Hi Mark,

On 08/19/2015 09:11 PM, Mark Brown wrote:
> On Tue, Aug 18, 2015 at 11:23:54AM +0530, Kishon Vijay Abraham I wrote:
>> On Friday 14 August 2015 11:30 PM, Mark Brown wrote:
>>> On Mon, Jul 27, 2015 at 04:54:09PM +0530, Kishon Vijay Abraham I wrote:
>
 is moved as a child node of syscon, vsel_reg and enable_reg has the
 absolute address because of the address translation that happens while
 creating device from device tree node.
 So avoid using platform_get_resource and use of_get_address in order to
 get only the offset (untranslated address) and populate these in
 vsel_reg and enable_reg.
>
>>> This sounds like we're going in the wrong direction, we're moving from a
>>> more generic API to a firmware specific one.  Why is this a good fix?
>
>> platform_get_resource can be used if we need the absolute address but here we
>> need only the offset.
>
> So substract this address from the start of the resource to get the
> offset?  Or provide a wrapper function in the resource code which does
> that.  

I'd be very appreciated if you have and can share any thought on
How can we get this absolute base address to substract?

Below is what we have in DT:

l4_cfg: l4@4a00 {
compatible = "ti,dra7-l4-cfg", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x4a00 0x22c000>;

[GS] <=== 0x4a00 is our top level l4 base address

scm: scm@2000 {
compatible = "ti,dra7-scm-core", "simple-bus";
reg = <0x2000 0x2000>;
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 0x2000 0x2000>;

[GS] <=== 0x4a002000 is our scm-core base address
IORESOURCE_MEM: 0x4a002000 : 4A003FFF

scm_conf: scm_conf@0 {
compatible = "syscon", "simple-bus";
reg = <0x0 0x1400>;
#address-cells = <1>;
#size-cells = <1>;

[GS] <=== 0x4a002000 is our syscon base address
IORESOURCE_MEM: 0x4a002000 : 4A0033FF

pbias_regulator: pbias_regulator {
compatible = "ti,pbias-omap";
reg = <0xe00 0x4>;

[GS] <=== 0x4a002E00 is our pbias base address
IORESOURCE_MEM: 0x4a002E00 : 4A002E03
Here we should use reg_offset=0xE00 as input parameter for regmap APIs.

syscon = <&scm_conf>;
pbias_mmc_reg: pbias_mmc_omap5 {
regulator-name = 
"pbias_mmc_omap5";
regulator-min-microvolt 
= <180>;
regulator-max-microvolt 
= <300>;
};
};

scm_conf_clocks: clocks {
#address-cells = <1>;
#size-cells = <0>;
};
};

As I understood, all of_address APIs/code is designed to parse/translate
addresses in top-bottom direction, and it looks nontrivial to get any kind
of base addresses from driver's side (except of its own address), because
it will require reverse DT parsing in bottom-top direction.
Maybe I missed smth?

-- 
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-20 Thread Mark Brown
On Thu, Aug 20, 2015 at 11:21:06AM +0530, Kishon Vijay Abraham I wrote:
> On Wednesday 19 August 2015 11:41 PM, Mark Brown wrote:
> > On Tue, Aug 18, 2015 at 11:23:54AM +0530, Kishon Vijay Abraham I wrote:

Please fix your mail client to word wrap within paragraphs.

> >> platform_get_resource can be used if we need the absolute address but here 
> >> we
> >> need only the offset.

> > So substract this address from the start of the resource to get the

> That would mean from the offset (provided in dt) get the absolute address and
> then again from the absolute address get the offset.

Sure, that's how the Linux APIs work right now and why I'm suggesting
you might want a wrapper.

> > offset?  Or provide a wrapper function in the resource code which does

> Why not use 'of_get_address' which does the same thing? Moreover it's not a
> resource we are dealing with here. It's a resource only for the syscon driver.

This is how the OF description you've done is intended to be parsed and
hence is interpreted by the generic code, it's just a detail of the
syscon implementation that you need to translate it into an offset.

> > that.  What you're saying above is pretty much "this happens to work"
> > but my concern is that the solution that happens to work isn't really
> > what we want to do.

> Not just makes this work, this is also the most reasonable solution available 
> IMHO.

In general moving to a lower level inteface is not usually a step
forward.  As far as I can tell the driver already has all the
information it needs from the more generic APIs, it's just not
interpreting it in the way that the APIs it's trying to use wants.  It
just needs to fix the way it interprets the data it's passing through.

> The most ideal way would have been to use something like what Grygorii
> mentioned to use syscon = <&scm_conf 0xe00> and then use the phandle to get 
> the
> offset. But then with this we'll be breaking older dtbs.

There is no need to break older DTs, that would clearly be a bad idea.


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-19 Thread Kishon Vijay Abraham I
Hi Mark Brown,

On Wednesday 19 August 2015 11:41 PM, Mark Brown wrote:
> On Tue, Aug 18, 2015 at 11:23:54AM +0530, Kishon Vijay Abraham I wrote:
>> On Friday 14 August 2015 11:30 PM, Mark Brown wrote:
>>> On Mon, Jul 27, 2015 at 04:54:09PM +0530, Kishon Vijay Abraham I wrote:
> 
 is moved as a child node of syscon, vsel_reg and enable_reg has the
 absolute address because of the address translation that happens while
 creating device from device tree node.
 So avoid using platform_get_resource and use of_get_address in order to
 get only the offset (untranslated address) and populate these in
 vsel_reg and enable_reg.
> 
>>> This sounds like we're going in the wrong direction, we're moving from a
>>> more generic API to a firmware specific one.  Why is this a good fix?
> 
>> platform_get_resource can be used if we need the absolute address but here we
>> need only the offset.
> 
> So substract this address from the start of the resource to get the

That would mean from the offset (provided in dt) get the absolute address and
then again from the absolute address get the offset.
> offset?  Or provide a wrapper function in the resource code which does

Why not use 'of_get_address' which does the same thing? Moreover it's not a
resource we are dealing with here. It's a resource only for the syscon driver.
> that.  What you're saying above is pretty much "this happens to work"
> but my concern is that the solution that happens to work isn't really
> what we want to do.

Not just makes this work, this is also the most reasonable solution available 
IMHO.

The most ideal way would have been to use something like what Grygorii
mentioned to use syscon = <&scm_conf 0xe00> and then use the phandle to get the
offset. But then with this we'll be breaking older dtbs.

Thanks
Kishon


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-19 Thread Mark Brown
On Tue, Aug 18, 2015 at 11:23:54AM +0530, Kishon Vijay Abraham I wrote:
> On Friday 14 August 2015 11:30 PM, Mark Brown wrote:
> > On Mon, Jul 27, 2015 at 04:54:09PM +0530, Kishon Vijay Abraham I wrote:

> >> is moved as a child node of syscon, vsel_reg and enable_reg has the
> >> absolute address because of the address translation that happens while
> >> creating device from device tree node.
> >> So avoid using platform_get_resource and use of_get_address in order to
> >> get only the offset (untranslated address) and populate these in
> >> vsel_reg and enable_reg.

> > This sounds like we're going in the wrong direction, we're moving from a
> > more generic API to a firmware specific one.  Why is this a good fix?

> platform_get_resource can be used if we need the absolute address but here we
> need only the offset.

So substract this address from the start of the resource to get the
offset?  Or provide a wrapper function in the resource code which does
that.  What you're saying above is pretty much "this happens to work"
but my concern is that the solution that happens to work isn't really
what we want to do.


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-17 Thread Kishon Vijay Abraham I
Hi Mark Brown,

On Friday 14 August 2015 11:30 PM, Mark Brown wrote:
> On Mon, Jul 27, 2015 at 04:54:09PM +0530, Kishon Vijay Abraham I wrote:
> 
>> vsel_reg and enable_reg of the pbias regulator descriptor should actually
>> have the offset from syscon. However after the pbias device tree node
> 
> I'm having a hard time understanding this statement, sorry.  What makes
> you say that they "shouild actually have the offset from syscon"?  What
> is the problem that this is supposed to fix?

The register to program pbias regulator is 0x4A002E00. The syscon base address
is 0x4a002000. So the vsel_reg and enable_reg should have the offset from
syscon base address. regulator_enable_regmap gets the base address from
'regmap' and offset from 'enable_reg' in order to program the pbias regulator.

But without this patch vsel_reg and enable_reg have the absolute address
instead of just the offset.
> 
>> is moved as a child node of syscon, vsel_reg and enable_reg has the
>> absolute address because of the address translation that happens while
>> creating device from device tree node.
>> So avoid using platform_get_resource and use of_get_address in order to
>> get only the offset (untranslated address) and populate these in
>> vsel_reg and enable_reg.
> 
> This sounds like we're going in the wrong direction, we're moving from a
> more generic API to a firmware specific one.  Why is this a good fix?

platform_get_resource can be used if we need the absolute address but here we
need only the offset.

Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-14 Thread Mark Brown
On Mon, Jul 27, 2015 at 04:54:09PM +0530, Kishon Vijay Abraham I wrote:

> vsel_reg and enable_reg of the pbias regulator descriptor should actually
> have the offset from syscon. However after the pbias device tree node

I'm having a hard time understanding this statement, sorry.  What makes
you say that they "shouild actually have the offset from syscon"?  What
is the problem that this is supposed to fix?

> is moved as a child node of syscon, vsel_reg and enable_reg has the
> absolute address because of the address translation that happens while
> creating device from device tree node.
> So avoid using platform_get_resource and use of_get_address in order to
> get only the offset (untranslated address) and populate these in
> vsel_reg and enable_reg.

This sounds like we're going in the wrong direction, we're moving from a
more generic API to a firmware specific one.  Why is this a good fix?


signature.asc
Description: Digital signature


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-06 Thread Grygorii Strashko
On 08/06/2015 09:26 AM, Tony Lindgren wrote:
> * Kishon Vijay Abraham I  [150805 07:59]:
>> Hi Tony,
>>
>> On Wednesday 05 August 2015 03:17 PM, Tony Lindgren wrote:
>>> * Kishon Vijay Abraham I  [150727 04:27]:
 vsel_reg and enable_reg of the pbias regulator descriptor should actually
 have the offset from syscon. However after the pbias device tree node
 is moved as a child node of syscon, vsel_reg and enable_reg has the
 absolute address because of the address translation that happens while
 creating device from device tree node.
 So avoid using platform_get_resource and use of_get_address in order to
 get only the offset (untranslated address) and populate these in
 vsel_reg and enable_reg.
>>>
>>> I think this gets fixed automatically with your other series
>>> adding the "simple-bus" to the nodes. For the children of_ioremap
>>
>> Nope. The probe of pbias regulator fails as Grygorii has already pointed out
>> here [1].
> 
> Oh I see, you want the offset from syscon, not the virtual address of
> the register. Yeah then it makes sense to me. You could also get the
> offset by doing res->start & 0xff or something but I don't know if
> that's any better. I guess ideallly we'd have some syscon function
> to get the offest from the syscon base if it does not exist already.

Hypothetically, the "syscon" property can be used to get register offset
syscon = <&scm_conf 0xe00>;
and even "reg" property can be dropped if driver uses syscon/regmap only for io.

But, in this particular case, such change will lead to DT compatibility issues 
:(

-- 
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-05 Thread Tony Lindgren
* Kishon Vijay Abraham I  [150805 07:59]:
> Hi Tony,
> 
> On Wednesday 05 August 2015 03:17 PM, Tony Lindgren wrote:
> > * Kishon Vijay Abraham I  [150727 04:27]:
> >> vsel_reg and enable_reg of the pbias regulator descriptor should actually
> >> have the offset from syscon. However after the pbias device tree node
> >> is moved as a child node of syscon, vsel_reg and enable_reg has the
> >> absolute address because of the address translation that happens while
> >> creating device from device tree node.
> >> So avoid using platform_get_resource and use of_get_address in order to
> >> get only the offset (untranslated address) and populate these in
> >> vsel_reg and enable_reg.
> > 
> > I think this gets fixed automatically with your other series
> > adding the "simple-bus" to the nodes. For the children of_ioremap
> 
> Nope. The probe of pbias regulator fails as Grygorii has already pointed out
> here [1].

Oh I see, you want the offset from syscon, not the virtual address of
the register. Yeah then it makes sense to me. You could also get the
offset by doing res->start & 0xff or something but I don't know if
that's any better. I guess ideallly we'd have some syscon function
to get the offest from the syscon base if it does not exist already.

Regards,

Tony

 
> [1] -> http://www.spinics.net/lists/linux-omap/msg120462.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-05 Thread Kishon Vijay Abraham I
Hi Tony,

On Wednesday 05 August 2015 03:17 PM, Tony Lindgren wrote:
> * Kishon Vijay Abraham I  [150727 04:27]:
>> vsel_reg and enable_reg of the pbias regulator descriptor should actually
>> have the offset from syscon. However after the pbias device tree node
>> is moved as a child node of syscon, vsel_reg and enable_reg has the
>> absolute address because of the address translation that happens while
>> creating device from device tree node.
>> So avoid using platform_get_resource and use of_get_address in order to
>> get only the offset (untranslated address) and populate these in
>> vsel_reg and enable_reg.
> 
> I think this gets fixed automatically with your other series
> adding the "simple-bus" to the nodes. For the children of_ioremap

Nope. The probe of pbias regulator fails as Grygorii has already pointed out
here [1].

Thanks
Kishon

[1] -> http://www.spinics.net/lists/linux-omap/msg120462.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-08-05 Thread Tony Lindgren
* Kishon Vijay Abraham I  [150727 04:27]:
> vsel_reg and enable_reg of the pbias regulator descriptor should actually
> have the offset from syscon. However after the pbias device tree node
> is moved as a child node of syscon, vsel_reg and enable_reg has the
> absolute address because of the address translation that happens while
> creating device from device tree node.
> So avoid using platform_get_resource and use of_get_address in order to
> get only the offset (untranslated address) and populate these in
> vsel_reg and enable_reg.

I think this gets fixed automatically with your other series
adding the "simple-bus" to the nodes. For the children of_ioremap
and friends should do the right thing, but without help from the bus
things won't work right without "simple-bus".

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator

2015-07-29 Thread Grygorii Strashko

On 07/27/2015 02:24 PM, Kishon Vijay Abraham I wrote:

vsel_reg and enable_reg of the pbias regulator descriptor should actually
have the offset from syscon. However after the pbias device tree node
is moved as a child node of syscon, vsel_reg and enable_reg has the
absolute address because of the address translation that happens while
creating device from device tree node.
So avoid using platform_get_resource and use of_get_address in order to
get only the offset (untranslated address) and populate these in
vsel_reg and enable_reg.

Cc: 
Cc: Tero Kristo 
Signed-off-by: Kishon Vijay Abraham I 


For dra7-evm:
Tested-by: Grygorii Strashko 


--
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html