Skip to contentSkip to conversation

lis3lv02d: update DT binding for use with Nokia N900

PATCH In review Sebastian Reichel 2 participants 8 messages Dec 13, 2013 – Jan 8, 2014 3 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover lis3lv02d: update DT binding for use with Nokia N900

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(-)
Signature · 6 lines
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1386968094-24554-1-git-send-email-sre-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org

#2 lore raw

PATCH 1/4 of: introduce of_property_read_s32

Introduce signed 32bit integer of_property_read method.

---
 include/linux/of.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/linux/of.h +7 -0
index 276c546..24cac04 100644
@@ -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);		\
Signature · 6 lines
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 2/4 lis3lv02d: DT: use s32 to support negative values

In reply to a message not in the archive

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

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

---
 drivers/misc/lis3lv02d/lis3lv02d.c | 39 +++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)
drivers/misc/lis3lv02d/lis3lv02d.c +20 -19
index 036effe..dc4f5c7 100644
@@ -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;
Signature · 6 lines
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH 3/4 lis3lv02d: DT: add wakeup unit 2 and wakeup threshold

In reply to a message not in the archive

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

---
 drivers/misc/lis3lv02d/lis3lv02d.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/misc/lis3lv02d/lis3lv02d.c +17 -0
index dc4f5c7..aa61627 100644
@@ -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) {
Signature · 6 lines
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH 4/4 Documentation: DT: lis302: update wakeup binding

In reply to a message not in the archive

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.

---
 Documentation/devicetree/bindings/misc/lis302.txt | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/misc/lis302.txt +8 -1
index 6def86f..2a19bff 100644
@@ -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)
 
Signature · 6 lines
1.8.5.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
In reply to a message not in the archive
Quoted 10 lines · 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.

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:

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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 12 lines · Éric Piel
Quoted 8 lines · Sebastian Reichel

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:

Quoted 7 lines

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.

Quoted 3 lines

* 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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Hi,

Quoted 5 lines · Sebastian Reichel
Quoted 3 lines

* 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