devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900
@ 2013-12-13 20:54 Sebastian Reichel
       [not found] ` <1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastian Reichel @ 2013-12-13 20:54 UTC (permalink / raw)
  To: Sebastian Reichel, Eric Piel, Daniel Mack,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Sebastian Reichel

Hi,

The lis302 has already a DT binding described in [0],
which descibes misc. hardware properties. The current
binding does not support all values needed to convert
the Nokia N900's platform data to DT.

This patchset introduces support for describing inverted
axis, configuration of second wakeup unit and wakeup
threshold support.

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

-- Sebastian

Sebastian Reichel (4):
  of: introduce of_property_read_s32
  lis3lv02d: DT: use s32 to support negative values
  lis3lv02d: DT: add wakeup unit 2 and wakeup threshold
  Documentation: DT: lis302: update wakeup binding

 Documentation/devicetree/bindings/misc/lis302.txt |  9 +++-
 drivers/misc/lis3lv02d/lis3lv02d.c                | 56 +++++++++++++++--------
 include/linux/of.h                                |  7 +++
 3 files changed, 52 insertions(+), 20 deletions(-)

-- 
1.8.5.1

--
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] 8+ messages in thread

* [PATCH 1/4] of: introduce of_property_read_s32
       [not found] ` <1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
@ 2013-12-13 20:54   ` Sebastian Reichel
  2013-12-13 20:54   ` [PATCH 2/4] lis3lv02d: DT: use s32 to support negative values Sebastian Reichel
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2013-12-13 20:54 UTC (permalink / raw)
  To: Sebastian Reichel, Eric Piel, Daniel Mack,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Sebastian Reichel

Introduce signed 32bit integer of_property_read method.

Signed-off-by: Sebastian Reichel <sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
---
 include/linux/of.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/of.h b/include/linux/of.h
index 276c546..24cac04 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -601,6 +601,13 @@ static inline int of_property_read_u32(const struct device_node *np,
 	return of_property_read_u32_array(np, propname, out_value, 1);
 }
 
+static inline int of_property_read_s32(const struct device_node *np,
+				       const char *propname,
+				       s32 *out_value)
+{
+	return of_property_read_u32(np, propname, (u32*) out_value);
+}
+
 #define of_property_for_each_u32(np, propname, prop, p, u)	\
 	for (prop = of_find_property(np, propname, NULL),	\
 		p = of_prop_next_u32(prop, NULL, &u);		\
-- 
1.8.5.1

--
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 related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] lis3lv02d: DT: use s32 to support negative values
       [not found] ` <1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
  2013-12-13 20:54   ` [PATCH 1/4] of: introduce of_property_read_s32 Sebastian Reichel
@ 2013-12-13 20:54   ` Sebastian Reichel
  2013-12-13 20:54   ` [PATCH 3/4] lis3lv02d: DT: add wakeup unit 2 and wakeup threshold Sebastian Reichel
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2013-12-13 20:54 UTC (permalink / raw)
  To: Sebastian Reichel, Eric Piel, Daniel Mack,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Sebastian Reichel

st,axis-{x,y,z} can be negative to imply inverted
axis.

Apart from that the minimal and maximal threshold
may be negative.

Signed-off-by: Sebastian Reichel <sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
---
 drivers/misc/lis3lv02d/lis3lv02d.c | 39 +++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index 036effe..dc4f5c7 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -951,6 +951,7 @@ int lis3lv02d_init_dt(struct lis3lv02d *lis3)
 	struct lis3lv02d_platform_data *pdata;
 	struct device_node *np = lis3->of_node;
 	u32 val;
+	s32 sval;
 
 	if (!lis3->of_node)
 		return 0;
@@ -1055,29 +1056,29 @@ int lis3lv02d_init_dt(struct lis3lv02d *lis3)
 	if (of_get_property(np, "st,hipass2-disable", NULL))
 		pdata->hipass_ctrl |= LIS3_HIPASS2_DISABLE;
 
-	if (of_get_property(np, "st,axis-x", &val))
-		pdata->axis_x = val;
-	if (of_get_property(np, "st,axis-y", &val))
-		pdata->axis_y = val;
-	if (of_get_property(np, "st,axis-z", &val))
-		pdata->axis_z = val;
+	if (of_property_read_s32(np, "st,axis-x", &sval) == 0)
+		pdata->axis_x = sval;
+	if (of_property_read_s32(np, "st,axis-y", &sval) == 0)
+		pdata->axis_y = sval;
+	if (of_property_read_s32(np, "st,axis-z", &sval) == 0)
+		pdata->axis_z = sval;
 
 	if (of_get_property(np, "st,default-rate", NULL))
 		pdata->default_rate = val;
 
-	if (of_get_property(np, "st,min-limit-x", &val))
-		pdata->st_min_limits[0] = val;
-	if (of_get_property(np, "st,min-limit-y", &val))
-		pdata->st_min_limits[1] = val;
-	if (of_get_property(np, "st,min-limit-z", &val))
-		pdata->st_min_limits[2] = val;
-
-	if (of_get_property(np, "st,max-limit-x", &val))
-		pdata->st_max_limits[0] = val;
-	if (of_get_property(np, "st,max-limit-y", &val))
-		pdata->st_max_limits[1] = val;
-	if (of_get_property(np, "st,max-limit-z", &val))
-		pdata->st_max_limits[2] = val;
+	if (of_property_read_s32(np, "st,min-limit-x", &sval) == 0)
+		pdata->st_min_limits[0] = sval;
+	if (of_property_read_s32(np, "st,min-limit-y", &sval) == 0)
+		pdata->st_min_limits[1] = sval;
+	if (of_property_read_s32(np, "st,min-limit-z", &sval) == 0)
+		pdata->st_min_limits[2] = sval;
+
+	if (of_property_read_s32(np, "st,max-limit-x", &sval) == 0)
+		pdata->st_max_limits[0] = sval;
+	if (of_property_read_s32(np, "st,max-limit-y", &sval) == 0)
+		pdata->st_max_limits[1] = sval;
+	if (of_property_read_s32(np, "st,max-limit-z", &sval) == 0)
+		pdata->st_max_limits[2] = sval;
 
 
 	lis3->pdata = pdata;
-- 
1.8.5.1

--
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 related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] lis3lv02d: DT: add wakeup unit 2 and wakeup threshold
       [not found] ` <1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
  2013-12-13 20:54   ` [PATCH 1/4] of: introduce of_property_read_s32 Sebastian Reichel
  2013-12-13 20:54   ` [PATCH 2/4] lis3lv02d: DT: use s32 to support negative values Sebastian Reichel
@ 2013-12-13 20:54   ` Sebastian Reichel
  2013-12-13 20:54   ` [PATCH 4/4] Documentation: DT: lis302: update wakeup binding Sebastian Reichel
  2013-12-13 22:31   ` [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900 Éric Piel
  4 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2013-12-13 20:54 UTC (permalink / raw)
  To: Sebastian Reichel, Eric Piel, Daniel Mack,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Sebastian Reichel

This adds support for the the wakeup threshold and
support for the second wakeup unit to the DT based
setup.

Signed-off-by: Sebastian Reichel <sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
---
 drivers/misc/lis3lv02d/lis3lv02d.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
index dc4f5c7..aa61627 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
@@ -1033,6 +1033,23 @@ int lis3lv02d_init_dt(struct lis3lv02d *lis3)
 		pdata->wakeup_flags |= LIS3_WAKEUP_Z_LO;
 	if (of_get_property(np, "st,wakeup-z-hi", NULL))
 		pdata->wakeup_flags |= LIS3_WAKEUP_Z_HI;
+	if (of_get_property(np, "st,wakeup-threshold", &val))
+		pdata->wakeup_thresh = val;
+
+	if (of_get_property(np, "st,wakeup2-x-lo", NULL))
+		pdata->wakeup_flags2 |= LIS3_WAKEUP_X_LO;
+	if (of_get_property(np, "st,wakeup2-x-hi", NULL))
+		pdata->wakeup_flags2 |= LIS3_WAKEUP_X_HI;
+	if (of_get_property(np, "st,wakeup2-y-lo", NULL))
+		pdata->wakeup_flags2 |= LIS3_WAKEUP_Y_LO;
+	if (of_get_property(np, "st,wakeup2-y-hi", NULL))
+		pdata->wakeup_flags2 |= LIS3_WAKEUP_Y_HI;
+	if (of_get_property(np, "st,wakeup2-z-lo", NULL))
+		pdata->wakeup_flags2 |= LIS3_WAKEUP_Z_LO;
+	if (of_get_property(np, "st,wakeup2-z-hi", NULL))
+		pdata->wakeup_flags2 |= LIS3_WAKEUP_Z_HI;
+	if (of_get_property(np, "st,wakeup2-threshold", &val))
+		pdata->wakeup_thresh2 = val;
 
 	if (!of_property_read_u32(np, "st,highpass-cutoff-hz", &val)) {
 		switch (val) {
-- 
1.8.5.1

--
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 related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] Documentation: DT: lis302: update wakeup binding
       [not found] ` <1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
                     ` (2 preceding siblings ...)
  2013-12-13 20:54   ` [PATCH 3/4] lis3lv02d: DT: add wakeup unit 2 and wakeup threshold Sebastian Reichel
@ 2013-12-13 20:54   ` Sebastian Reichel
  2013-12-13 22:31   ` [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900 Éric Piel
  4 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2013-12-13 20:54 UTC (permalink / raw)
  To: Sebastian Reichel, Eric Piel, Daniel Mack,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Sebastian Reichel

This updated the documentation of the DT binding to
describe the added wakeup threshold and second wakeup
engine.

It also adds a note, that the axis values may be
negative.

Signed-off-by: Sebastian Reichel <sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
---
 Documentation/devicetree/bindings/misc/lis302.txt | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/misc/lis302.txt b/Documentation/devicetree/bindings/misc/lis302.txt
index 6def86f..2a19bff 100644
--- a/Documentation/devicetree/bindings/misc/lis302.txt
+++ b/Documentation/devicetree/bindings/misc/lis302.txt
@@ -46,11 +46,18 @@ Optional properties for all bus drivers:
 				interrupt 2
  - st,wakeup-{x,y,z}-{lo,hi}:	set wakeup condition on x/y/z axis for
 				upper/lower limit
+ - st,wakeup-threshold:		set wakeup threshold
+ - st,wakeup2-{x,y,z}-{lo,hi}:	set wakeup condition on x/y/z axis for
+				upper/lower limit for second wakeup
+				engine.
+ - st,wakeup2-threshold:	set wakeup threshold for second wakeup
+				engine.
  - st,highpass-cutoff-hz=:	1, 2, 4 or 8 for 1Hz, 2Hz, 4Hz or 8Hz of
 				highpass cut-off frequency
  - st,hipass{1,2}-disable:	disable highpass 1/2.
  - st,default-rate=:		set the default rate
- - st,axis-{x,y,z}=:		set the axis to map to the three coordinates
+ - st,axis-{x,y,z}=:		set the axis to map to the three coordinates.
+				Negative values can be used for inverted axis.
  - st,{min,max}-limit-{x,y,z}	set the min/max limits for x/y/z axis
 				(used by self-test)
 
-- 
1.8.5.1

--
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 related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900
       [not found] ` <1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
                     ` (3 preceding siblings ...)
  2013-12-13 20:54   ` [PATCH 4/4] Documentation: DT: lis302: update wakeup binding Sebastian Reichel
@ 2013-12-13 22:31   ` Éric Piel
       [not found]     ` <52AB8ACB.6000101-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
  4 siblings, 1 reply; 8+ messages in thread
From: Éric Piel @ 2013-12-13 22:31 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Daniel Mack,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Stephen Warren
  Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	arnd-r2nGTMty4D4, Greg Kroah-Hartman

On 13-12-13 21:54, Sebastian Reichel wrote:
> Hi,
>
> The lis302 has already a DT binding described in [0],
> which descibes misc. hardware properties. The current
> binding does not support all values needed to convert
> the Nokia N900's platform data to DT.
>
> This patchset introduces support for describing inverted
> axis, configuration of second wakeup unit and wakeup
> threshold support.
Hi,

All the three patches related to the lis3lv02d driver look fine to me.
Here is my signed-off for patches 2, 3, and 4:
Signed-off-by: Éric Piel <eric.piel-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>

I've got 2 side questions:
  * How do you write a negative value in a DTS file? Is this just the 
very standard way (i.e., -), or do you need to use a specific technique 
(such as 2-completemnt on 32 bits)? If it's not the standard way, it 
should probably be documented somewhere.
  * Who wants to carry these patches? Can they all go via the devicetree 
branch? Or maybe Arnd or Greg would prefer to pick them via the misc 
driver branch? Both ways are fine for me...

Cheers,
É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] 8+ messages in thread

* Re: [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900
       [not found]     ` <52AB8ACB.6000101-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
@ 2013-12-13 22:59       ` Sebastian Reichel
       [not found]         ` <20131213225920.GA20534-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Sebastian Reichel @ 2013-12-13 22:59 UTC (permalink / raw)
  To: Éric Piel
  Cc: Daniel Mack, devicetree-u79uwXL29TY76Z2rM5mHXA, Stephen Warren,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	arnd-r2nGTMty4D4, Greg Kroah-Hartman

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

On Fri, Dec 13, 2013 at 11:31:39PM +0100, Éric Piel wrote:
> On 13-12-13 21:54, Sebastian Reichel wrote:
> >The lis302 has already a DT binding described in [0],
> >which descibes misc. hardware properties. The current
> >binding does not support all values needed to convert
> >the Nokia N900's platform data to DT.
> >
> >This patchset introduces support for describing inverted
> >axis, configuration of second wakeup unit and wakeup
> >threshold support.
> 
> All the three patches related to the lis3lv02d driver look fine to me.
> Here is my signed-off for patches 2, 3, and 4:
> Signed-off-by: Éric Piel <eric.piel-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
> 
> I've got 2 side questions:
>  * How do you write a negative value in a DTS file? Is this just the
> very standard way (i.e., -), or do you need to use a specific
> technique (such as 2-completemnt on 32 bits)? If it's not the
> standard way, it should probably be documented somewhere.

One can simply use -, but one has to put the value into (). This is
because DT supports simple mathematical operations for the values,
e.g. 5-10 and must have some way to distinguish between (5) (-10)
and (5-10).

Here is an example for N900 axis configuration from DT file:

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

I had some trouble to find this out myself, so probably its a good
idea to document this somewhere.

>  * Who wants to carry these patches? Can they all go via the
> devicetree branch? Or maybe Arnd or Greg would prefer to pick them
> via the misc driver branch? Both ways are fine for me...

I don't care, but it would be nice to see this in 3.14.

-- Sebastian

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

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

* Re: [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900
       [not found]         ` <20131213225920.GA20534-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
@ 2014-01-08 11:17           ` Sebastian Reichel
  0 siblings, 0 replies; 8+ messages in thread
From: Sebastian Reichel @ 2014-01-08 11:17 UTC (permalink / raw)
  To: Grant Likely
  Cc: Éric Piel, devicetree-u79uwXL29TY76Z2rM5mHXA, Rob Herring,
	arnd-r2nGTMty4D4, Greg Kroah-Hartman

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

Hi,

On Fri, Dec 13, 2013 at 11:59:20PM +0100, Sebastian Reichel wrote:
> >  * Who wants to carry these patches? Can they all go via the
> > devicetree branch? Or maybe Arnd or Greg would prefer to pick them
> > via the misc driver branch? Both ways are fine for me...
> 
> I don't care, but it would be nice to see this in 3.14.

mh looks like nobody feels responsible.

I think the first patch should normally go through Grant's tree,
whom I forgot to Cc in the patchset (sorry).

The patches 3-4 can go the same way as the other updates for the
driver, but should be merged after Grant's tree.

-- Sebastian

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

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

end of thread, other threads:[~2014-01-08 11:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-13 20:54 [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900 Sebastian Reichel
     [not found] ` <1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>
2013-12-13 20:54   ` [PATCH 1/4] of: introduce of_property_read_s32 Sebastian Reichel
2013-12-13 20:54   ` [PATCH 2/4] lis3lv02d: DT: use s32 to support negative values Sebastian Reichel
2013-12-13 20:54   ` [PATCH 3/4] lis3lv02d: DT: add wakeup unit 2 and wakeup threshold Sebastian Reichel
2013-12-13 20:54   ` [PATCH 4/4] Documentation: DT: lis302: update wakeup binding Sebastian Reichel
2013-12-13 22:31   ` [PATCH 0/4] lis3lv02d: update DT binding for use with Nokia N900 Éric Piel
     [not found]     ` <52AB8ACB.6000101-VkQ1JFuSMpfAbQlEx87xDw@public.gmane.org>
2013-12-13 22:59       ` Sebastian Reichel
     [not found]         ` <20131213225920.GA20534-SfvFxonMDyemK9LvCR3Hrw@public.gmane.org>
2014-01-08 11:17           ` 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).