devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* lis302 DT binding for Nokia N900
@ 2013-12-03 12:21 Sebastian Reichel
       [not found] ` <20131203122059.GB4653-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2013-12-03 12:21 UTC (permalink / raw)
  To: Daniel Mack, Eric Piel, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: Sebastian Reichel

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

Hi,

The lis302 has already a DT binding described in [0],
which descibes misc. hardware properties. The problem
is, that the Nokia N900 needs negative values for some
of the properties, which seem to be unsupported by DT.
The following values would be needed for the N900 (taken
from board code):

st,axis-x = <1>;  /* LIS3_DEV_X */
st,axis-y = <-2>; /* LIS3_INV_DEV_Y */
st,axis-z = <-3>; /* LIS3_INV_DEV_Z */

st,min-limit-x = <-32>;
st,min-limit-y = <3>;
st,min-limit-z = <3>;

st,max-limit-x = <-3>;
st,max-limit-y = <32>;
st,max-limit-z = <32>;

Can you please tell me how to setup the properties correctly?

[0] Documentation/devicetree/bindings/misc/lis302.txt

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: lis302 DT binding for Nokia N900
       [not found] ` <20131203122059.GB4653-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
@ 2013-12-08 13:27   ` Éric Piel
       [not found]     ` <52A473D8.7020706-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Éric Piel @ 2013-12-08 13:27 UTC (permalink / raw)
  To: Sebastian Reichel, Daniel Mack, Rob Herring, Pawel Moll,
	Mark Rutland, Stephen Warren, Ian Campbell,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On 03-12-13 13:21, Sebastian Reichel wrote:
> Hi,
>
> The lis302 has already a DT binding described in [0],
> which descibes misc. hardware properties. The problem
> is, that the Nokia N900 needs negative values for some
> of the properties, which seem to be unsupported by DT.
> The following values would be needed for the N900 (taken
> from board code):
>
> st,axis-x = <1>;  /* LIS3_DEV_X */
> st,axis-y = <-2>; /* LIS3_INV_DEV_Y */
> st,axis-z = <-3>; /* LIS3_INV_DEV_Z */
>
> st,min-limit-x = <-32>;
> st,min-limit-y = <3>;
> st,min-limit-z = <3>;
>
> st,max-limit-x = <-3>;
> st,max-limit-y = <32>;
> st,max-limit-z = <32>;
>
> Can you please tell me how to setup the properties correctly?

Hi Sebastian,
The code to support inversion of the axis is there... but apparently 
only in the I2C code. It seems the SPI code doesn't (yet) use any of 
these values. Is the accelerometer on the N900 connected via SPI, by 
chance?

It should be pretty simple to extend the SPI driver to support axis 
conversion too. It'd basically be a copy-paste of lis3lv02d_i2c_probe()

Concerning {min,max}-limit-*, I only have vague understanding of this 
information (only used in self test), but it should already be working 
fine with both I2C and SPI (as it's bus independent). In addition, note 
that it's compared to raw data (i.e., before axis conversion), so you 
probably don't need to put negative values there.

Éric
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: lis302 DT binding for Nokia N900
       [not found]     ` <52A473D8.7020706-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
@ 2013-12-08 13:46       ` Sebastian Reichel
       [not found]         ` <20131208134651.GA25587-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Reichel @ 2013-12-08 13:46 UTC (permalink / raw)
  To: Éric Piel
  Cc: Daniel Mack, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, devicetree-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 2119 bytes --]

Hi Éric,

On Sun, Dec 08, 2013 at 02:27:52PM +0100, Éric Piel wrote:
> On 03-12-13 13:21, Sebastian Reichel wrote:
> >The lis302 has already a DT binding described in [0],
> >which descibes misc. hardware properties. The problem
> >is, that the Nokia N900 needs negative values for some
> >of the properties, which seem to be unsupported by DT.
> >The following values would be needed for the N900 (taken
> >from board code):
> >
> >st,axis-x = <1>;  /* LIS3_DEV_X */
> >st,axis-y = <-2>; /* LIS3_INV_DEV_Y */
> >st,axis-z = <-3>; /* LIS3_INV_DEV_Z */
> >
> >st,min-limit-x = <-32>;
> >st,min-limit-y = <3>;
> >st,min-limit-z = <3>;
> >
> >st,max-limit-x = <-3>;
> >st,max-limit-y = <32>;
> >st,max-limit-z = <32>;
> >
> >Can you please tell me how to setup the properties correctly?
> 
> The code to support inversion of the axis is there... but apparently
> only in the I2C code. It seems the SPI code doesn't (yet) use any of
> these values. Is the accelerometer on the N900 connected via SPI, by
> chance?

No, it's connected via I2C. Please note, that the N900's accelerometer
is already supported, but only when initialized via legacy boardcode.

The problem is, that I can't specify negative values in the device
tree file (the device tree compiler complains). I couldn't find any
example of negative numbers in any dts file, so I guess, that
negative numbers are not supported.

> It should be pretty simple to extend the SPI driver to support axis
> conversion too. It'd basically be a copy-paste of
> lis3lv02d_i2c_probe()
> 
> Concerning {min,max}-limit-*, I only have vague understanding of
> this information (only used in self test), but it should already be
> working fine with both I2C and SPI (as it's bus independent). In
> addition, note that it's compared to raw data (i.e., before axis
> conversion), so you probably don't need to put negative values
> there.

I just want to port the existing boardcode to device tree.
The existing platform data is defined as rx51_lis3lv02d_data in
arch/arm/mach-omap2/board-rx51-peripherals.c.

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: lis302 DT binding for Nokia N900
       [not found]         ` <20131208134651.GA25587-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
@ 2013-12-08 14:00           ` Éric Piel
       [not found]             ` <52A47B84.8050009-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Éric Piel @ 2013-12-08 14:00 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Daniel Mack, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, devicetree-u79uwXL29TY76Z2rM5mHXA

On 08-12-13 14:46, Sebastian Reichel wrote:
:
> No, it's connected via I2C. Please note, that the N900's accelerometer
> is already supported, but only when initialized via legacy boardcode.
>
> The problem is, that I can't specify negative values in the device
> tree file (the device tree compiler complains). I couldn't find any
> example of negative numbers in any dts file, so I guess, that
> negative numbers are not supported.
>
:
> I just want to port the existing boardcode to device tree.
> The existing platform data is defined as rx51_lis3lv02d_data in
> arch/arm/mach-omap2/board-rx51-peripherals.c.
Oh! Yes, then the values themselves should be fine.
Indeed, the problem is in the parsing of the DT values.
Currently, lis3lv02d_init_dt() reads values as unsigned int:

u32 val;
if (of_get_property(np, "st,axis-x", &val))
	pdata->axis_x = val;

So it's quite unlikely to get negative ;-) Is there a way to read signed 
ints in DT? If so, I can update the driver.

Éric
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: lis302 DT binding for Nokia N900
       [not found]             ` <52A47B84.8050009-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
@ 2013-12-08 14:48               ` Sebastian Reichel
  0 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2013-12-08 14:48 UTC (permalink / raw)
  To: Éric Piel
  Cc: Daniel Mack, Rob Herring, Pawel Moll, Mark Rutland,
	Stephen Warren, Ian Campbell, devicetree-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1835 bytes --]

On Sun, Dec 08, 2013 at 03:00:36PM +0100, Éric Piel wrote:
> On 08-12-13 14:46, Sebastian Reichel wrote:
> :
> >No, it's connected via I2C. Please note, that the N900's accelerometer
> >is already supported, but only when initialized via legacy boardcode.
> >
> >The problem is, that I can't specify negative values in the device
> >tree file (the device tree compiler complains). I couldn't find any
> >example of negative numbers in any dts file, so I guess, that
> >negative numbers are not supported.
> >
> :
> >I just want to port the existing boardcode to device tree.
> >The existing platform data is defined as rx51_lis3lv02d_data in
> >arch/arm/mach-omap2/board-rx51-peripherals.c.
> Oh! Yes, then the values themselves should be fine.
> Indeed, the problem is in the parsing of the DT values.
> Currently, lis3lv02d_init_dt() reads values as unsigned int:
> 
> u32 val;
> if (of_get_property(np, "st,axis-x", &val))
> 	pdata->axis_x = val;
> 
> So it's quite unlikely to get negative ;-) Is there a way to read
> signed ints in DT? If so, I can update the driver.

I just found a link, which describes how to put negative values into
the DTS, so that the device tree compiler understands them and
translates them into 2's-compliment [0].

The kernel code currently does not provide of_property_read_s32(),
but it seems that there was just no use case so far. At least one
of the DT binding maintainers seems to be finde with introducing it
[1].

I will prepare a patch, which adds of_property_read_s32 and another
one, which updates lis3lv02d to use the new function.

[0] http://www.mail-archive.com/linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg05121.html
[1] http://www.mail-archive.com/linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org/msg05125.html

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-12-08 14:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 12:21 lis302 DT binding for Nokia N900 Sebastian Reichel
     [not found] ` <20131203122059.GB4653-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
2013-12-08 13:27   ` Éric Piel
     [not found]     ` <52A473D8.7020706-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
2013-12-08 13:46       ` Sebastian Reichel
     [not found]         ` <20131208134651.GA25587-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
2013-12-08 14:00           ` Éric Piel
     [not found]             ` <52A47B84.8050009-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
2013-12-08 14:48               ` Sebastian Reichel

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).