All of lore.kernel.org
 help / color / mirror / Atom feed
* Handling device shared SFR on dt platform
@ 2012-03-21 22:38 ` Sylwester Nawrocki
  0 siblings, 0 replies; 12+ messages in thread
From: Sylwester Nawrocki @ 2012-03-21 22:38 UTC (permalink / raw)
  To: devicetree-discuss, linux-arm-kernel


Hello,

I'm working on adding the device tree support for two devices that
share some IO registers. Exactly, there is one shared SFR that 
contains a common bit to enable two PHY devices, and another two
bits, each to separately reset each PHY.

Currently this shared register is statically memory mapped and it is
handled by a platform specific callback, that both drivers use to
control their corresponding (sub)devices in synchronised manner.

The two devices are a MIPI-CSI2 receiver and a MIPI-DSI transmitter, 
and the common register is there to control the camera and the display 
port PHY. The hardware design is a bit unfortunate, but there is not
much I could do about it.

The callback can be looked at at:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/arm/plat-s5p/setup-mipiphy.c

I have been trying to find method to handle this on a dt platform. 
Has anyone faced similar issue before ? I would appreciate any ideas
or suggestions.

One of ideas was to create some sort of PHY framework, similar to
clock API, and perhaps handle such platform quirks outside DT.

--

Thanks,
Sylwester

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

* Handling device shared SFR on dt platform
@ 2012-03-21 22:38 ` Sylwester Nawrocki
  0 siblings, 0 replies; 12+ messages in thread
From: Sylwester Nawrocki @ 2012-03-21 22:38 UTC (permalink / raw)
  To: linux-arm-kernel


Hello,

I'm working on adding the device tree support for two devices that
share some IO registers. Exactly, there is one shared SFR that 
contains a common bit to enable two PHY devices, and another two
bits, each to separately reset each PHY.

Currently this shared register is statically memory mapped and it is
handled by a platform specific callback, that both drivers use to
control their corresponding (sub)devices in synchronised manner.

The two devices are a MIPI-CSI2 receiver and a MIPI-DSI transmitter, 
and the common register is there to control the camera and the display 
port PHY. The hardware design is a bit unfortunate, but there is not
much I could do about it.

The callback can be looked at at:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=arch/arm/plat-s5p/setup-mipiphy.c

I have been trying to find method to handle this on a dt platform. 
Has anyone faced similar issue before ? I would appreciate any ideas
or suggestions.

One of ideas was to create some sort of PHY framework, similar to
clock API, and perhaps handle such platform quirks outside DT.

--

Thanks,
Sylwester

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

* Re: Handling device shared SFR on dt platform
  2012-03-21 22:38 ` Sylwester Nawrocki
@ 2012-03-24 19:32   ` Grant Likely
  -1 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2012-03-24 19:32 UTC (permalink / raw)
  To: Sylwester Nawrocki, devicetree-discuss, linux-arm-kernel

On Wed, 21 Mar 2012 23:38:11 +0100, Sylwester Nawrocki <snjw23@gmail.com> wrote:
> 
> Hello,
> 
> I'm working on adding the device tree support for two devices that
> share some IO registers. Exactly, there is one shared SFR that 
> contains a common bit to enable two PHY devices, and another two
> bits, each to separately reset each PHY.
> 
> Currently this shared register is statically memory mapped and it is
> handled by a platform specific callback, that both drivers use to
> control their corresponding (sub)devices in synchronised manner.
> 
> The two devices are a MIPI-CSI2 receiver and a MIPI-DSI transmitter, 
> and the common register is there to control the camera and the display 
> port PHY. The hardware design is a bit unfortunate, but there is not
> much I could do about it.

Generally, this is handled by having a third node for the shared
register block and both device nodes holding a phandle to it.

No, there isn't any common infrastructure for implementing this, but
it isn't very much code.

g.

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

* Handling device shared SFR on dt platform
@ 2012-03-24 19:32   ` Grant Likely
  0 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2012-03-24 19:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 21 Mar 2012 23:38:11 +0100, Sylwester Nawrocki <snjw23@gmail.com> wrote:
> 
> Hello,
> 
> I'm working on adding the device tree support for two devices that
> share some IO registers. Exactly, there is one shared SFR that 
> contains a common bit to enable two PHY devices, and another two
> bits, each to separately reset each PHY.
> 
> Currently this shared register is statically memory mapped and it is
> handled by a platform specific callback, that both drivers use to
> control their corresponding (sub)devices in synchronised manner.
> 
> The two devices are a MIPI-CSI2 receiver and a MIPI-DSI transmitter, 
> and the common register is there to control the camera and the display 
> port PHY. The hardware design is a bit unfortunate, but there is not
> much I could do about it.

Generally, this is handled by having a third node for the shared
register block and both device nodes holding a phandle to it.

No, there isn't any common infrastructure for implementing this, but
it isn't very much code.

g.

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

* Re: Handling device shared SFR on dt platform
  2012-03-24 19:32   ` Grant Likely
@ 2012-03-28 19:45     ` Sylwester Nawrocki
  -1 siblings, 0 replies; 12+ messages in thread
From: Sylwester Nawrocki @ 2012-03-28 19:45 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Hello Grant,

On 03/24/2012 08:32 PM, Grant Likely wrote:
>
> Generally, this is handled by having a third node for the shared
> register block and both device nodes holding a phandle to it.
> 
> No, there isn't any common infrastructure for implementing this, but
> it isn't very much code.

Thank you, that sounds good. I'm just wondering how to handle the shared
resource access synchronisation. There is an IORESOURCE_MUXED resource type 
flag which could be used to prevent drivers from stomping on each others 
feet when accessing the shared register, if I understand the software muxed
resource semantics correctly. That is, using something like 
request_muxed_(mem_)region()/release_mem_region() for the shared register
protection.

What concerns me, is an overhead from region request/ioremap(?)/release, just
to access a single 32-bit register. I'm going to see if those accesses could
be moved to only device driver's probe() and remove() callbacks and what might
be the resulting power consumption increase from that, if any.


--

Thanks,
Sylwester

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

* Handling device shared SFR on dt platform
@ 2012-03-28 19:45     ` Sylwester Nawrocki
  0 siblings, 0 replies; 12+ messages in thread
From: Sylwester Nawrocki @ 2012-03-28 19:45 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Grant,

On 03/24/2012 08:32 PM, Grant Likely wrote:
>
> Generally, this is handled by having a third node for the shared
> register block and both device nodes holding a phandle to it.
> 
> No, there isn't any common infrastructure for implementing this, but
> it isn't very much code.

Thank you, that sounds good. I'm just wondering how to handle the shared
resource access synchronisation. There is an IORESOURCE_MUXED resource type 
flag which could be used to prevent drivers from stomping on each others 
feet when accessing the shared register, if I understand the software muxed
resource semantics correctly. That is, using something like 
request_muxed_(mem_)region()/release_mem_region() for the shared register
protection.

What concerns me, is an overhead from region request/ioremap(?)/release, just
to access a single 32-bit register. I'm going to see if those accesses could
be moved to only device driver's probe() and remove() callbacks and what might
be the resulting power consumption increase from that, if any.


--

Thanks,
Sylwester

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

* Re: Handling device shared SFR on dt platform
  2012-03-28 19:45     ` Sylwester Nawrocki
@ 2012-04-03 16:04       ` Grant Likely
  -1 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2012-04-03 16:04 UTC (permalink / raw)
  To: Sylwester Nawrocki; +Cc: devicetree-discuss, linux-arm-kernel

On Wed, 28 Mar 2012 21:45:14 +0200, Sylwester Nawrocki <snjw23@gmail.com> wrote:
> Hello Grant,
> 
> On 03/24/2012 08:32 PM, Grant Likely wrote:
> >
> > Generally, this is handled by having a third node for the shared
> > register block and both device nodes holding a phandle to it.
> > 
> > No, there isn't any common infrastructure for implementing this, but
> > it isn't very much code.
> 
> Thank you, that sounds good. I'm just wondering how to handle the shared
> resource access synchronisation. There is an IORESOURCE_MUXED resource type 
> flag which could be used to prevent drivers from stomping on each others 
> feet when accessing the shared register, if I understand the software muxed
> resource semantics correctly. That is, using something like 
> request_muxed_(mem_)region()/release_mem_region() for the shared register
> protection.
> 
> What concerns me, is an overhead from region request/ioremap(?)/release, just
> to access a single 32-bit register. I'm going to see if those accesses could
> be moved to only device driver's probe() and remove() callbacks and what might
> be the resulting power consumption increase from that, if any.

Personally, I'd just create a shared function used by both drivers to
access the register and protect it with a spinlock.  That way the
region only needs to be mapped once, and the overhead is as low as
possible.

g.

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

* Handling device shared SFR on dt platform
@ 2012-04-03 16:04       ` Grant Likely
  0 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2012-04-03 16:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 28 Mar 2012 21:45:14 +0200, Sylwester Nawrocki <snjw23@gmail.com> wrote:
> Hello Grant,
> 
> On 03/24/2012 08:32 PM, Grant Likely wrote:
> >
> > Generally, this is handled by having a third node for the shared
> > register block and both device nodes holding a phandle to it.
> > 
> > No, there isn't any common infrastructure for implementing this, but
> > it isn't very much code.
> 
> Thank you, that sounds good. I'm just wondering how to handle the shared
> resource access synchronisation. There is an IORESOURCE_MUXED resource type 
> flag which could be used to prevent drivers from stomping on each others 
> feet when accessing the shared register, if I understand the software muxed
> resource semantics correctly. That is, using something like 
> request_muxed_(mem_)region()/release_mem_region() for the shared register
> protection.
> 
> What concerns me, is an overhead from region request/ioremap(?)/release, just
> to access a single 32-bit register. I'm going to see if those accesses could
> be moved to only device driver's probe() and remove() callbacks and what might
> be the resulting power consumption increase from that, if any.

Personally, I'd just create a shared function used by both drivers to
access the register and protect it with a spinlock.  That way the
region only needs to be mapped once, and the overhead is as low as
possible.

g.

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

* Re: Handling device shared SFR on dt platform
  2012-04-03 16:04       ` Grant Likely
@ 2012-04-04 20:35         ` Sylwester Nawrocki
  -1 siblings, 0 replies; 12+ messages in thread
From: Sylwester Nawrocki @ 2012-04-04 20:35 UTC (permalink / raw)
  To: Grant Likely
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 04/03/2012 06:04 PM, Grant Likely wrote:
>> What concerns me, is an overhead from region request/ioremap(?)/release, 
>> just to access a single 32-bit register. I'm going to see if those accesses
>> could be moved to only device driver's probe() and remove() callbacks and 
>> what might be the resulting power consumption increase from that, if any.
> 
> Personally, I'd just create a shared function used by both drivers to
> access the register and protect it with a spinlock.  That way the
> region only needs to be mapped once, and the overhead is as low as
> possible.

Hmm, that's what I originally started with. I've just removed function 
callback from the platform data struct in favour of having the drivers 
using directly the function exported by plat-s5p. Then I started devising
something alternative, in hope to get rid of the drivers compilation 
dependency on PLAT_S5P. There seems little point in that though, since 
the chance to have those IP blocks available on other archs or ARM sub-archs,
than Samsung S5P/Exynos, are extremely low. 

I'll post finally some patches for review. Thank you.

---
Regards,
Sylwester

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

* Handling device shared SFR on dt platform
@ 2012-04-04 20:35         ` Sylwester Nawrocki
  0 siblings, 0 replies; 12+ messages in thread
From: Sylwester Nawrocki @ 2012-04-04 20:35 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/03/2012 06:04 PM, Grant Likely wrote:
>> What concerns me, is an overhead from region request/ioremap(?)/release, 
>> just to access a single 32-bit register. I'm going to see if those accesses
>> could be moved to only device driver's probe() and remove() callbacks and 
>> what might be the resulting power consumption increase from that, if any.
> 
> Personally, I'd just create a shared function used by both drivers to
> access the register and protect it with a spinlock.  That way the
> region only needs to be mapped once, and the overhead is as low as
> possible.

Hmm, that's what I originally started with. I've just removed function 
callback from the platform data struct in favour of having the drivers 
using directly the function exported by plat-s5p. Then I started devising
something alternative, in hope to get rid of the drivers compilation 
dependency on PLAT_S5P. There seems little point in that though, since 
the chance to have those IP blocks available on other archs or ARM sub-archs,
than Samsung S5P/Exynos, are extremely low. 

I'll post finally some patches for review. Thank you.

---
Regards,
Sylwester

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

* Re: Handling device shared SFR on dt platform
  2012-04-04 20:35         ` Sylwester Nawrocki
@ 2012-04-07  1:41             ` Grant Likely
  -1 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2012-04-07  1:41 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Wed, 04 Apr 2012 22:35:50 +0200, Sylwester Nawrocki <snjw23-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On 04/03/2012 06:04 PM, Grant Likely wrote:
> >> What concerns me, is an overhead from region request/ioremap(?)/release, 
> >> just to access a single 32-bit register. I'm going to see if those accesses
> >> could be moved to only device driver's probe() and remove() callbacks and 
> >> what might be the resulting power consumption increase from that, if any.
> > 
> > Personally, I'd just create a shared function used by both drivers to
> > access the register and protect it with a spinlock.  That way the
> > region only needs to be mapped once, and the overhead is as low as
> > possible.
> 
> Hmm, that's what I originally started with. I've just removed function 
> callback from the platform data struct in favour of having the drivers 
> using directly the function exported by plat-s5p. Then I started devising
> something alternative, in hope to get rid of the drivers compilation 
> dependency on PLAT_S5P. There seems little point in that though, since 
> the chance to have those IP blocks available on other archs or ARM sub-archs,
> than Samsung S5P/Exynos, are extremely low. 

As long as everything remains multiplatform friendly, I'm fine with
this.  It will need to change though if ever there needs to be
multiple definitions of that helper function because that means only
one platform can be enabled at a time.

g.

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

* Handling device shared SFR on dt platform
@ 2012-04-07  1:41             ` Grant Likely
  0 siblings, 0 replies; 12+ messages in thread
From: Grant Likely @ 2012-04-07  1:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 04 Apr 2012 22:35:50 +0200, Sylwester Nawrocki <snjw23@gmail.com> wrote:
> On 04/03/2012 06:04 PM, Grant Likely wrote:
> >> What concerns me, is an overhead from region request/ioremap(?)/release, 
> >> just to access a single 32-bit register. I'm going to see if those accesses
> >> could be moved to only device driver's probe() and remove() callbacks and 
> >> what might be the resulting power consumption increase from that, if any.
> > 
> > Personally, I'd just create a shared function used by both drivers to
> > access the register and protect it with a spinlock.  That way the
> > region only needs to be mapped once, and the overhead is as low as
> > possible.
> 
> Hmm, that's what I originally started with. I've just removed function 
> callback from the platform data struct in favour of having the drivers 
> using directly the function exported by plat-s5p. Then I started devising
> something alternative, in hope to get rid of the drivers compilation 
> dependency on PLAT_S5P. There seems little point in that though, since 
> the chance to have those IP blocks available on other archs or ARM sub-archs,
> than Samsung S5P/Exynos, are extremely low. 

As long as everything remains multiplatform friendly, I'm fine with
this.  It will need to change though if ever there needs to be
multiple definitions of that helper function because that means only
one platform can be enabled at a time.

g.

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

end of thread, other threads:[~2012-04-07  1:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-21 22:38 Handling device shared SFR on dt platform Sylwester Nawrocki
2012-03-21 22:38 ` Sylwester Nawrocki
2012-03-24 19:32 ` Grant Likely
2012-03-24 19:32   ` Grant Likely
2012-03-28 19:45   ` Sylwester Nawrocki
2012-03-28 19:45     ` Sylwester Nawrocki
2012-04-03 16:04     ` Grant Likely
2012-04-03 16:04       ` Grant Likely
2012-04-04 20:35       ` Sylwester Nawrocki
2012-04-04 20:35         ` Sylwester Nawrocki
     [not found]         ` <4F7CB0A6.7010809-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-04-07  1:41           ` Grant Likely
2012-04-07  1:41             ` Grant Likely

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.