* Sharing resources between several drivers.
@ 2012-07-27 7:59 javier Martin
2012-07-27 9:03 ` Bedia, Vaibhav
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: javier Martin @ 2012-07-27 7:59 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
we are trying to support pinctrl for i.MX21, i.MX1 and i.MX27.
In these chips, gpio and pinctrl use the same HW memory area
registers. This means that we have to request the same memory area
from two different drivers (gpio and pinctrl) but we don't know how to
do that.
A similar example available is mxs, but it only works with device
tree, so this problem is avoided. However, some of these chips
(i.MX21, i.MX1...) don't support device tree yet, so we need to
provide backwards compatibility.
What is the right way to request the same memory region from two
different drivers? Moreover, how can we guarantee that there won't be
any conflicts when accessing these shared resources?
Regards.
--
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Sharing resources between several drivers.
2012-07-27 7:59 Sharing resources between several drivers javier Martin
@ 2012-07-27 9:03 ` Bedia, Vaibhav
2012-07-28 14:07 ` Shawn Guo
2012-07-27 9:19 ` Thomas Petazzoni
2012-07-29 14:19 ` Arnd Bergmann
2 siblings, 1 reply; 8+ messages in thread
From: Bedia, Vaibhav @ 2012-07-27 9:03 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Jul 27, 2012 at 13:29:21, javier Martin wrote:
> Hi,
> we are trying to support pinctrl for i.MX21, i.MX1 and i.MX27.
>
> In these chips, gpio and pinctrl use the same HW memory area
> registers. This means that we have to request the same memory area
> from two different drivers (gpio and pinctrl) but we don't know how to
> do that.
>
> A similar example available is mxs, but it only works with device
> tree, so this problem is avoided. However, some of these chips
I am curious as to how device tree solves the access issues for
a shared resource.
> (i.MX21, i.MX1...) don't support device tree yet, so we need to
> provide backwards compatibility.
>
> What is the right way to request the same memory region from two
> different drivers? Moreover, how can we guarantee that there won't be
> any conflicts when accessing these shared resources?
>
For a few registers this might be an overkill but MFD comes to mind.
Regards,
Vaibhav B.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Sharing resources between several drivers.
2012-07-27 7:59 Sharing resources between several drivers javier Martin
2012-07-27 9:03 ` Bedia, Vaibhav
@ 2012-07-27 9:19 ` Thomas Petazzoni
2012-07-27 9:33 ` javier Martin
2012-07-29 14:19 ` Arnd Bergmann
2 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2012-07-27 9:19 UTC (permalink / raw)
To: linux-arm-kernel
Le Fri, 27 Jul 2012 09:59:21 +0200,
javier Martin <javier.martin@vista-silicon.com> a ?crit :
> Hi,
> we are trying to support pinctrl for i.MX21, i.MX1 and i.MX27.
>
> In these chips, gpio and pinctrl use the same HW memory area
> registers. This means that we have to request the same memory area
> from two different drivers (gpio and pinctrl) but we don't know how to
> do that.
>
> A similar example available is mxs, but it only works with device
> tree, so this problem is avoided. However, some of these chips
> (i.MX21, i.MX1...) don't support device tree yet, so we need to
> provide backwards compatibility.
>
> What is the right way to request the same memory region from two
> different drivers? Moreover, how can we guarantee that there won't be
> any conflicts when accessing these shared resources?
I would say there is no right way. If the pinctrl/gpio registers are
really intermixed and belong to the same region, then there should be
only one driver that requests this region and that implements both the
pinctrl and gpio features.
See the drivers/pinctrl/pinctrl-coh901.c driver for example. It
implements both the pinctrl and the gpio logic.
Best regards,
Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Sharing resources between several drivers.
2012-07-27 9:19 ` Thomas Petazzoni
@ 2012-07-27 9:33 ` javier Martin
0 siblings, 0 replies; 8+ messages in thread
From: javier Martin @ 2012-07-27 9:33 UTC (permalink / raw)
To: linux-arm-kernel
On 27 July 2012 11:19, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Le Fri, 27 Jul 2012 09:59:21 +0200,
> javier Martin <javier.martin@vista-silicon.com> a ?crit :
>
>> Hi,
>> we are trying to support pinctrl for i.MX21, i.MX1 and i.MX27.
>>
>> In these chips, gpio and pinctrl use the same HW memory area
>> registers. This means that we have to request the same memory area
>> from two different drivers (gpio and pinctrl) but we don't know how to
>> do that.
>>
>> A similar example available is mxs, but it only works with device
>> tree, so this problem is avoided. However, some of these chips
>> (i.MX21, i.MX1...) don't support device tree yet, so we need to
>> provide backwards compatibility.
>>
>> What is the right way to request the same memory region from two
>> different drivers? Moreover, how can we guarantee that there won't be
>> any conflicts when accessing these shared resources?
>
> I would say there is no right way. If the pinctrl/gpio registers are
> really intermixed and belong to the same region, then there should be
> only one driver that requests this region and that implements both the
> pinctrl and gpio features.
>
> See the drivers/pinctrl/pinctrl-coh901.c driver for example. It
> implements both the pinctrl and the gpio logic.
Thank you, that was very useful.
Regards.
--
Javier Martin
Vista Silicon S.L.
CDTUC - FASE C - Oficina S-345
Avda de los Castros s/n
39005- Santander. Cantabria. Spain
+34 942 25 32 60
www.vista-silicon.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Sharing resources between several drivers.
2012-07-27 9:03 ` Bedia, Vaibhav
@ 2012-07-28 14:07 ` Shawn Guo
2012-07-30 12:00 ` Bedia, Vaibhav
0 siblings, 1 reply; 8+ messages in thread
From: Shawn Guo @ 2012-07-28 14:07 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Jul 27, 2012 at 09:03:33AM +0000, Bedia, Vaibhav wrote:
> On Fri, Jul 27, 2012 at 13:29:21, javier Martin wrote:
> > Hi,
> > we are trying to support pinctrl for i.MX21, i.MX1 and i.MX27.
> >
> > In these chips, gpio and pinctrl use the same HW memory area
> > registers. This means that we have to request the same memory area
> > from two different drivers (gpio and pinctrl) but we don't know how to
> > do that.
> >
> > A similar example available is mxs, but it only works with device
> > tree, so this problem is avoided. However, some of these chips
>
> I am curious as to how device tree solves the access issues for
> a shared resource.
>
Although pinctrl and gpio share the same IO region, they are accessing
different registers, so there should be no access issues.
--
Regards,
Shawn
^ permalink raw reply [flat|nested] 8+ messages in thread
* Sharing resources between several drivers.
2012-07-27 7:59 Sharing resources between several drivers javier Martin
2012-07-27 9:03 ` Bedia, Vaibhav
2012-07-27 9:19 ` Thomas Petazzoni
@ 2012-07-29 14:19 ` Arnd Bergmann
2012-08-04 23:46 ` Linus Walleij
2 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2012-07-29 14:19 UTC (permalink / raw)
To: linux-arm-kernel
On Friday 27 July 2012, javier Martin wrote:
> we are trying to support pinctrl for i.MX21, i.MX1 and i.MX27.
>
> In these chips, gpio and pinctrl use the same HW memory area
> registers. This means that we have to request the same memory area
> from two different drivers (gpio and pinctrl) but we don't know how to
> do that.
>
> A similar example available is mxs, but it only works with device
> tree, so this problem is avoided. However, some of these chips
> (i.MX21, i.MX1...) don't support device tree yet, so we need to
> provide backwards compatibility.
>
> What is the right way to request the same memory region from two
> different drivers? Moreover, how can we guarantee that there won't be
> any conflicts when accessing these shared resources?
I think the method that Linus Walleij usually recomments for dealing with
this is to create a combined gpio+pinctrl driver that lives in
drivers/pinctrl but registers to gpiolib as well.
Have a look at drivers/pinctrl/pinctrl-nomadik.c for an example of this.
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* Sharing resources between several drivers.
2012-07-28 14:07 ` Shawn Guo
@ 2012-07-30 12:00 ` Bedia, Vaibhav
0 siblings, 0 replies; 8+ messages in thread
From: Bedia, Vaibhav @ 2012-07-30 12:00 UTC (permalink / raw)
To: linux-arm-kernel
On Sat, Jul 28, 2012 at 19:37:54, Shawn Guo wrote:
> On Fri, Jul 27, 2012 at 09:03:33AM +0000, Bedia, Vaibhav wrote:
> > On Fri, Jul 27, 2012 at 13:29:21, javier Martin wrote:
> > > Hi,
> > > we are trying to support pinctrl for i.MX21, i.MX1 and i.MX27.
> > >
> > > In these chips, gpio and pinctrl use the same HW memory area
> > > registers. This means that we have to request the same memory area
> > > from two different drivers (gpio and pinctrl) but we don't know how to
> > > do that.
> > >
> > > A similar example available is mxs, but it only works with device
> > > tree, so this problem is avoided. However, some of these chips
> >
> > I am curious as to how device tree solves the access issues for
> > a shared resource.
> >
> Although pinctrl and gpio share the same IO region, they are accessing
> different registers, so there should be no access issues.
>
Ok that makes sense. Thanks for clarifying.
Regards,
Vaibhav B.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Sharing resources between several drivers.
2012-07-29 14:19 ` Arnd Bergmann
@ 2012-08-04 23:46 ` Linus Walleij
0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2012-08-04 23:46 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, Jul 29, 2012 at 4:19 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Friday 27 July 2012, javier Martin wrote:
>>
>> What is the right way to request the same memory region from two
>> different drivers? Moreover, how can we guarantee that there won't be
>> any conflicts when accessing these shared resources?
>
> I think the method that Linus Walleij usually recomments for dealing with
> this is to create a combined gpio+pinctrl driver that lives in
> drivers/pinctrl but registers to gpiolib as well.
Yepps.
> Have a look at drivers/pinctrl/pinctrl-nomadik.c for an example of this.
What this and many other drivers run into is the problem of mappings
between GPIOs and pin controller ranges (GPIO ranges).
Currently these are registered by the pin controller and may need
access to the struct gpio_chip which creates an "interesting"
probe order problem. But it can be solved (in not-so-elegant ways).
Long term we want to turn this upside down and have the GPIO
driver portion register it's ranges to the pin controller instead,
using local range GPIO numbers.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-08-04 23:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-27 7:59 Sharing resources between several drivers javier Martin
2012-07-27 9:03 ` Bedia, Vaibhav
2012-07-28 14:07 ` Shawn Guo
2012-07-30 12:00 ` Bedia, Vaibhav
2012-07-27 9:19 ` Thomas Petazzoni
2012-07-27 9:33 ` javier Martin
2012-07-29 14:19 ` Arnd Bergmann
2012-08-04 23:46 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox