* [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator [not found] <1437996250-2913-1-git-send-email-kishon@ti.com> @ 2015-07-27 11:24 ` Kishon Vijay Abraham I 2015-07-29 8:57 ` Grygorii Strashko ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Kishon Vijay Abraham I @ 2015-07-27 11:24 UTC (permalink / raw) To: tony, lgirdwood, broonie, linux-omap, linux-kernel Cc: grygorii.strashko, nsekhar, kishon, stable, Tero Kristo 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: <stable@vger.kernel.org> Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> --- drivers/regulator/pbias-regulator.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index bd2b75c..a24cb43 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c @@ -22,6 +22,7 @@ #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <linux/regulator/of_regulator.h> +#include <linux/of_address.h> #include <linux/regmap.h> #include <linux/slab.h> #include <linux/of.h> @@ -108,12 +109,14 @@ static int pbias_regulator_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct pbias_regulator_data *drvdata; - struct resource *res; struct regulator_config cfg = { }; struct regmap *syscon; const struct pbias_reg_info *info; int ret = 0; int count, idx, data_idx = 0; + const __be32 *addrp; + int ns; + unsigned int reg; count = of_regulator_match(&pdev->dev, np, pbias_matches, PBIAS_NUM_REGS); @@ -141,10 +144,13 @@ static int pbias_regulator_probe(struct platform_device *pdev) if (!info) return -ENODEV; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) + addrp = of_get_address(np, 0, NULL, NULL); + if (!addrp) return -EINVAL; + ns = of_n_size_cells(np); + reg = of_read_number(addrp, ns); + drvdata[data_idx].syscon = syscon; drvdata[data_idx].info = info; drvdata[data_idx].desc.name = info->name; @@ -154,9 +160,9 @@ static int pbias_regulator_probe(struct platform_device *pdev) drvdata[data_idx].desc.volt_table = pbias_volt_table; drvdata[data_idx].desc.n_voltages = 2; drvdata[data_idx].desc.enable_time = info->enable_time; - drvdata[data_idx].desc.vsel_reg = res->start; + drvdata[data_idx].desc.vsel_reg = reg; drvdata[data_idx].desc.vsel_mask = info->vmode; - drvdata[data_idx].desc.enable_reg = res->start; + drvdata[data_idx].desc.enable_reg = reg; drvdata[data_idx].desc.enable_mask = info->enable_mask; drvdata[data_idx].desc.enable_val = info->enable; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-07-27 11:24 ` [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator Kishon Vijay Abraham I @ 2015-07-29 8:57 ` Grygorii Strashko 2015-08-05 9:47 ` Tony Lindgren 2015-08-14 18:00 ` Mark Brown 2 siblings, 0 replies; 11+ messages in thread From: Grygorii Strashko @ 2015-07-29 8:57 UTC (permalink / raw) To: Kishon Vijay Abraham I, tony, lgirdwood, broonie, linux-omap, linux-kernel Cc: nsekhar, stable, Tero Kristo 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: <stable@vger.kernel.org> > Cc: Tero Kristo <t-kristo@ti.com> > Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> For dra7-evm: Tested-by: Grygorii Strashko <grygorii.strashko@ti.com> -- regards, -grygorii ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-07-27 11:24 ` [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator Kishon Vijay Abraham I 2015-07-29 8:57 ` Grygorii Strashko @ 2015-08-05 9:47 ` Tony Lindgren 2015-08-05 14:56 ` Kishon Vijay Abraham I 2015-08-14 18:00 ` Mark Brown 2 siblings, 1 reply; 11+ messages in thread From: Tony Lindgren @ 2015-08-05 9:47 UTC (permalink / raw) To: Kishon Vijay Abraham I Cc: lgirdwood, broonie, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo * Kishon Vijay Abraham I <kishon@ti.com> [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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-08-05 9:47 ` Tony Lindgren @ 2015-08-05 14:56 ` Kishon Vijay Abraham I 2015-08-06 6:26 ` Tony Lindgren 0 siblings, 1 reply; 11+ messages in thread From: Kishon Vijay Abraham I @ 2015-08-05 14:56 UTC (permalink / raw) To: Tony Lindgren Cc: lgirdwood, broonie, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo Hi Tony, On Wednesday 05 August 2015 03:17 PM, Tony Lindgren wrote: > * Kishon Vijay Abraham I <kishon@ti.com> [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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-08-05 14:56 ` Kishon Vijay Abraham I @ 2015-08-06 6:26 ` Tony Lindgren 2015-08-06 9:58 ` Grygorii Strashko 0 siblings, 1 reply; 11+ messages in thread From: Tony Lindgren @ 2015-08-06 6:26 UTC (permalink / raw) To: Kishon Vijay Abraham I Cc: lgirdwood, broonie, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo * Kishon Vijay Abraham I <kishon@ti.com> [150805 07:59]: > Hi Tony, > > On Wednesday 05 August 2015 03:17 PM, Tony Lindgren wrote: > > * Kishon Vijay Abraham I <kishon@ti.com> [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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-08-06 6:26 ` Tony Lindgren @ 2015-08-06 9:58 ` Grygorii Strashko 0 siblings, 0 replies; 11+ messages in thread From: Grygorii Strashko @ 2015-08-06 9:58 UTC (permalink / raw) To: Tony Lindgren, Kishon Vijay Abraham I Cc: lgirdwood, broonie, linux-omap, linux-kernel, nsekhar, stable, Tero Kristo On 08/06/2015 09:26 AM, Tony Lindgren wrote: > * Kishon Vijay Abraham I <kishon@ti.com> [150805 07:59]: >> Hi Tony, >> >> On Wednesday 05 August 2015 03:17 PM, Tony Lindgren wrote: >>> * Kishon Vijay Abraham I <kishon@ti.com> [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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-07-27 11:24 ` [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator Kishon Vijay Abraham I 2015-07-29 8:57 ` Grygorii Strashko 2015-08-05 9:47 ` Tony Lindgren @ 2015-08-14 18:00 ` Mark Brown 2015-08-18 5:53 ` Kishon Vijay Abraham I 2 siblings, 1 reply; 11+ messages in thread From: Mark Brown @ 2015-08-14 18:00 UTC (permalink / raw) To: Kishon Vijay Abraham I Cc: tony, lgirdwood, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo [-- Attachment #1: Type: text/plain, Size: 908 bytes --] 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? [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-08-14 18:00 ` Mark Brown @ 2015-08-18 5:53 ` Kishon Vijay Abraham I 2015-08-19 18:11 ` Mark Brown 0 siblings, 1 reply; 11+ messages in thread From: Kishon Vijay Abraham I @ 2015-08-18 5:53 UTC (permalink / raw) To: Mark Brown Cc: tony, lgirdwood, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-08-18 5:53 ` Kishon Vijay Abraham I @ 2015-08-19 18:11 ` Mark Brown 2015-08-20 5:51 ` Kishon Vijay Abraham I 0 siblings, 1 reply; 11+ messages in thread From: Mark Brown @ 2015-08-19 18:11 UTC (permalink / raw) To: Kishon Vijay Abraham I Cc: tony, lgirdwood, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo [-- Attachment #1: Type: text/plain, Size: 1131 bytes --] 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. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-08-19 18:11 ` Mark Brown @ 2015-08-20 5:51 ` Kishon Vijay Abraham I 2015-08-20 17:42 ` Mark Brown 0 siblings, 1 reply; 11+ messages in thread From: Kishon Vijay Abraham I @ 2015-08-20 5:51 UTC (permalink / raw) To: Mark Brown Cc: tony, lgirdwood, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator 2015-08-20 5:51 ` Kishon Vijay Abraham I @ 2015-08-20 17:42 ` Mark Brown 0 siblings, 0 replies; 11+ messages in thread From: Mark Brown @ 2015-08-20 17:42 UTC (permalink / raw) To: Kishon Vijay Abraham I Cc: tony, lgirdwood, linux-omap, linux-kernel, grygorii.strashko, nsekhar, stable, Tero Kristo [-- Attachment #1: Type: text/plain, Size: 2010 bytes --] 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. [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-08-20 17:43 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1437996250-2913-1-git-send-email-kishon@ti.com>
2015-07-27 11:24 ` [PATCH 1/2] regulator: pbias: use untranslated address to program pbias regulator Kishon Vijay Abraham I
2015-07-29 8:57 ` Grygorii Strashko
2015-08-05 9:47 ` Tony Lindgren
2015-08-05 14:56 ` Kishon Vijay Abraham I
2015-08-06 6:26 ` Tony Lindgren
2015-08-06 9:58 ` Grygorii Strashko
2015-08-14 18:00 ` Mark Brown
2015-08-18 5:53 ` Kishon Vijay Abraham I
2015-08-19 18:11 ` Mark Brown
2015-08-20 5:51 ` Kishon Vijay Abraham I
2015-08-20 17:42 ` Mark Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).