Skip to contentSkip to conversation

input: add driver for Bosch Sensortec's BMA150 accelerometer

PATCH Superseded Eric Andersson 3 participants 6 messages Jul 14, 2011 – Jul 15, 2011

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover input: add driver for Bosch Sensortec's BMA150 accelerometer

This is version 3 of the driver for Bosch Sensortec's accelerometers BMA150 and SMB380.

Since last time around, the following has happened:
* community review: Register the driver as a input_polled_device.
* community review: added runtime_pm support.
* community review: removed sysfs enable node
* community review: removed the value sysfs node
* community review: rephrased delay sysfs description
* Removed mode sysfs node
* Removed delay sysfs node
* Listed both bma150 & smb380 as supported i2c device id's.
* Added hw initialization function which will be called upon probing.
* Added soft reset function to be called from the probe.
* Minor consistency changes.

Signature · 19 lines
Best regards,
 Eric

 http://www.unixphere.com


Eric Andersson (1):
  input: add driver for Bosch Sensortec's BMA150 accelerometer

 Documentation/ABI/testing/sysfs-i2c-bma150 |   22 +
 drivers/input/misc/Kconfig                 |   11 +
 drivers/input/misc/Makefile                |    1 +
 drivers/input/misc/bma150.c                |  577 ++++++++++++++++++++++++++++
 4 files changed, 611 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-i2c-bma150
 create mode 100644 drivers/input/misc/bma150.c

-- 
1.7.3.4
#1 lore raw

PATCH v3 1/1 input: add driver for Bosch Sensortec's BMA150 accelerometer

---
 Documentation/ABI/testing/sysfs-i2c-bma150 |   22 +
 drivers/input/misc/Kconfig                 |   11 +
 drivers/input/misc/Makefile                |    1 +
 drivers/input/misc/bma150.c                |  577 ++++++++++++++++++++++++++++
 4 files changed, 611 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-i2c-bma150
 create mode 100644 drivers/input/misc/bma150.c
Documentation/ABI/testing/sysfs-i2c-bma150 new file +22 -0
new file mode 100644
index 0000000..842cb03
@@ -0,0 +1,22 @@
+What:		/sys/bus/i2c/devices/<busnum>-<devaddr>/range
+Date:		May 2011
+Contact:	Eric Andersson <[email protected]>
+Description:	This is used to select the full scale acceleration range. The
+		values represent the range given as +/- G.
+		Possible values are: 2, 4, 8.
+
+		Reading: returns the current acceleration range.
+
+		Writing: sets a new acceleration range.
+
+
+What:		/sys/bus/i2c/devices/<busnum>-<devaddr>/bandwidth
+Date:		May 2011
+Contact:	Eric Andersson <[email protected]>
+Description:	This is used to setup the digital filtering on ADC output data.
+		The values represent the bandwidth given in Hz.
+		Possible values are: 25, 50, 100, 190, 375, 750, 1500
+
+		Reading: returns the current bandwidth.
+
+		Writing: sets a new bandwidth.
drivers/input/misc/Kconfig +11 -0
index 45dc6aa..e6681d2 100644
@@ -478,4 +478,15 @@ config INPUT_XEN_KBDDEV_FRONTEND
 	  To compile this driver as a module, choose M here: the
 	  module will be called xen-kbdfront.
 
+config INPUT_BMA150
+	tristate "BMA150/SMB380 acceleration sensor support"
+	depends on I2C
+	select INPUT_POLLDEV
+	help
+	  Say Y here if you have Bosch Sensortec's BMA150 or SMB380
+	  acceleration sensor hooked to an I2C bus.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called bma150.
+
 endif
drivers/input/misc/Makefile +1 -0
index 38efb2c..9b13e0e 100644
@@ -45,4 +45,5 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS)	+= wistron_btns.o
 obj-$(CONFIG_INPUT_WM831X_ON)		+= wm831x-on.o
 obj-$(CONFIG_INPUT_XEN_KBDDEV_FRONTEND)	+= xen-kbdfront.o
 obj-$(CONFIG_INPUT_YEALINK)		+= yealink.o
+obj-$(CONFIG_INPUT_BMA150)		+= bma150.o
 
drivers/input/misc/bma150.c new file +577 -0

577 lines not on this page · raw message

Signature · 1 line
1.7.3.4
#2 lore raw

Documentation/ABI/testing/sysfs-i2c-bma150 line 10

Quoted 6 lines
Documentation/ABI/testing/sysfs-i2c-bma150 new file +6 -0
+		values represent the range given as +/- G.
+		Possible values are: 2, 4, 8.
+
+		Reading: returns the current acceleration range.
+
+		Writing: sets a new acceleration range.

Same comment as last time - these values are not discoverable so it should set the nearest bigger range.

Documentation/ABI/testing/sysfs-i2c-bma150 line 22

Quoted 12 lines
Documentation/ABI/testing/sysfs-i2c-bma150 new file +12 -0
+
+
+What:		/sys/bus/i2c/devices/<busnum>-<devaddr>/bandwidth
+Date:		May 2011
+Contact:	Eric Andersson <[email protected]>
+Description:	This is used to setup the digital filtering on ADC output data.
+		The values represent the bandwidth given in Hz.
+		Possible values are: 25, 50, 100, 190, 375, 750, 1500
+
+		Reading: returns the current bandwidth.
+
+		Writing: sets a new bandwidth.

Ditto

drivers/input/misc/bma150.c line 337

Quoted 4 lines
drivers/input/misc/bma150.c new file +4 -0
+	for (i = 0, ret = 0; i < ARRAY_SIZE(bw_val); i++)
+		ret += sprintf(buf + ret,
+			(bw_val[i].reg == bw) ? "[%d] " : "%d ",
+			bw_val[i].value);

sysfs nodes should really be single values

drivers/input/misc/bma150.c line 543

Quoted 3 lines
drivers/input/misc/bma150.c new file +3 -0
+static const struct i2c_device_id bma150_id[] = {
+	{ "bma150", 0 },
+	{ "smb380", 0 },

bma023 ?

It also doesn't expose the thresholds or support interrupts which the one I posted did.

So while its better it still seems incomplete - its certainly nowhere near where it can replace the one I posted months ago and doesn't seem to be making any headway.

Dmitry shall I repost the intel one - at this point I think it would be a better starting point as it supports more features, interrupts and the like although it's not perfect either.

Alan

#3 lore raw
Quoted 9 lines

Documentation/ABI/testing/sysfs-i2c-bma150 line 10

Quoted 6 lines
Documentation/ABI/testing/sysfs-i2c-bma150 new file +6 -0
+		values represent the range given as +/- G.
+		Possible values are: 2, 4, 8.
+
+		Reading: returns the current acceleration range.
+
+		Writing: sets a new acceleration range.

Same comment as last time - these values are not discoverable so it should set the nearest bigger range.

And same answer as last time - The values can be retreived by doing a:
cat range. This whole idea comes from a review comment that Jonathan Cameron gave on your bma023 driver [1].
If we could agree on how these values should be represented I will be glad to fix it! Dmitry, any preferences?

[1] http://www.spinics.net/lists/linux-input/msg14271.html

Quoted 6 lines

drivers/input/misc/bma150.c line 337

Quoted 4 lines
drivers/input/misc/bma150.c new file +4 -0
+	for (i = 0, ret = 0; i < ARRAY_SIZE(bw_val); i++)
+		ret += sprintf(buf + ret,
+			(bw_val[i].reg == bw) ? "[%d] " : "%d ",
+			bw_val[i].value);

sysfs nodes should really be single values

Once again it's a previous comment from Jonathan [1]. Please specify how you want this and I'll fix it.

Quoted 5 lines

drivers/input/misc/bma150.c line 543

Quoted 3 lines
drivers/input/misc/bma150.c new file +3 -0
+static const struct i2c_device_id bma150_id[] = {
+	{ "bma150", 0 },
+	{ "smb380", 0 },

bma023 ?

As mentioned earlier bma023 is not an official product name from Bosch Sensortec. Hence, there will be no datasheet available or references from Bosch Sensortec. IMHO it would be confusing to add it.

Quoted 2 lines

It also doesn't expose the thresholds or support interrupts which the one I posted did.

We were told by Bosch S that the interrupt is triggered every 333 us (data ready) which would pretty much flood the irq handler.
However, if this is stopping the patch we can add it. Would it be acceptable to have a driver that supports both a polling and irq driven setup, e.g. by checking if the .irq is non zero?

Quoted 9 lines

So while its better it still seems incomplete - its certainly nowhere near where it can replace the one I posted months ago and doesn't seem to
be making any headway.

Dmitry shall I repost the intel one - at this point I think it would be a
better starting point as it supports more features, interrupts and the like although it's not perfect either.

My hope is that we can sort out the differences before I post v4. Dmitry, if you have time could you please give an objective review of the patch?

Best regards,
Eric

http://www.unixphere.com

#4 lore raw
Quoted 10 lines · Eric Andersson
Quoted 9 lines

Documentation/ABI/testing/sysfs-i2c-bma150 line 10

Quoted 6 lines
Documentation/ABI/testing/sysfs-i2c-bma150 new file +6 -0
+		values represent the range given as +/- G.
+		Possible values are: 2, 4, 8.
+
+		Reading: returns the current acceleration range.
+
+		Writing: sets a new acceleration range.

Same comment as last time - these values are not discoverable so it should set the nearest bigger range.

Quoted 3 lines

And same answer as last time - The values can be retreived by doing a:
cat range. This whole idea comes from a review comment that Jonathan Cameron gave on your bma023 driver [1].

Needs documenting. Right now there is no mention of that here.

Quoted 13 lines

If we could agree on how these values should be represented I will be glad to fix it! Dmitry, any preferences?

[1] http://www.spinics.net/lists/linux-input/msg14271.html

Quoted 6 lines

drivers/input/misc/bma150.c line 337

Quoted 4 lines
drivers/input/misc/bma150.c new file +4 -0
+	for (i = 0, ret = 0; i < ARRAY_SIZE(bw_val); i++)
+		ret += sprintf(buf + ret,
+			(bw_val[i].reg == bw) ? "[%d] " : "%d ",
+			bw_val[i].value);

sysfs nodes should really be single values

Quoted 2 lines

Once again it's a previous comment from Jonathan [1]. Please specify how you want this and I'll fix it.

Yes in general to the single value, but this is a pretty common syntax for choosing one of a set. Got to indicate it somehow and it's either this or
a list of available ones in a separate attribute. There was an LWN article on this a while back that lays out the options very clearly http://lwn.net/Articles/378884/

Quoted 10 lines
Quoted 6 lines

drivers/input/misc/bma150.c line 543

Quoted 4 lines
drivers/input/misc/bma150.c new file +3 -0
+static const struct i2c_device_id bma150_id[] = {
+	{ "bma150", 0 },
+	{ "smb380", 0 },

bma023 ?

As mentioned earlier bma023 is not an official product name from Bosch Sensortec. Hence, there will be no datasheet available or references from Bosch Sensortec. IMHO it would be confusing to add it.

Just ignore the marketing and add it anyway :)

Quoted 6 lines
Quoted 3 lines

It also doesn't expose the thresholds or support interrupts which the one I posted did.

We were told by Bosch S that the interrupt is triggered every 333 us (data ready) which would pretty much flood the irq handler.

Somewhat quick, but maybe still worth having... Just use a one shot threaded interrupt and it will at least run safely even if it isn't keeping up with all of them. Alan, do you have a device that has frequency control on chip? (very unusual not to see this on an accelerometer).

Quoted 2 lines

However, if this is stopping the patch we can add it. Would it be acceptable to have a driver that supports both a polling and irq driven setup, e.g. by checking if the .irq is non zero?

Yes: common situation. See the recent kionix driver for an example. You definitely want the theshold stuff from Alan's driver though.

Quoted 23 lines
Quoted 10 lines

So while its better it still seems incomplete - its certainly nowhere near where it can replace the one I posted months ago and doesn't seem to
be making any headway.

Dmitry shall I repost the intel one - at this point I think it would be a
better starting point as it supports more features, interrupts and the like although it's not perfect either.

My hope is that we can sort out the differences before I post v4. Dmitry, if you have time could you please give an objective review of the patch?

Best regards,
Eric

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

#5 lore raw

Thanks for your input Jonathan!

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines

Documentation/ABI/testing/sysfs-i2c-bma150 line 10

Quoted 6 lines
Documentation/ABI/testing/sysfs-i2c-bma150 new file +6 -0
+		values represent the range given as +/- G.
+		Possible values are: 2, 4, 8.
+
+		Reading: returns the current acceleration range.
+
+		Writing: sets a new acceleration range.

Same comment as last time - these values are not discoverable so it should set the nearest bigger range.

Quoted 6 lines
Quoted 5 lines

And same answer as last time - The values can be retreived by doing a:
cat range. This whole idea comes from a review comment that Jonathan Cameron
gave on your bma023 driver [1].

Needs documenting. Right now there is no mention of that here.

True. I'll add a comment on how to get the valid values in v4.

Quoted 17 lines
Quoted 14 lines

If we could agree on how these values should be represented I will be glad
to fix it! Dmitry, any preferences?

[1] http://www.spinics.net/lists/linux-input/msg14271.html

Quoted 6 lines

drivers/input/misc/bma150.c line 337

Quoted 4 lines
drivers/input/misc/bma150.c new file +4 -0
+	for (i = 0, ret = 0; i < ARRAY_SIZE(bw_val); i++)
+		ret += sprintf(buf + ret,
+			(bw_val[i].reg == bw) ? "[%d] " : "%d ",
+			bw_val[i].value);

sysfs nodes should really be single values

Quoted 3 lines

Once again it's a previous comment from Jonathan [1]. Please specify how
you want this and I'll fix it.

Quoted 8 lines

Yes in general to the single value, but this is a pretty common syntax for
choosing one of a set. Got to indicate it somehow and it's either this or
a list of available ones in a separate attribute. There was an LWN article
on this a while back that lays out the options very clearly
http://lwn.net/Articles/378884/

An extra attribute does sound a bit over-kill to me. Would it be acceptable to keep it the way it is?

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

drivers/input/misc/bma150.c line 543

Quoted 3 lines
drivers/input/misc/bma150.c new file +3 -0
+static const struct i2c_device_id bma150_id[] = {
+	{ "bma150", 0 },
+	{ "smb380", 0 },

bma023 ?

Quoted 6 lines
Quoted 5 lines

As mentioned earlier bma023 is not an official product name from Bosch Sensortec. Hence,
there will be no datasheet available or references from Bosch Sensortec. IMHO it would be
confusing to add it.

Just ignore the marketing and add it anyway :)

You are probably right. I'll add it.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

It also doesn't expose the thresholds or support interrupts which the
one I posted did.

We were told by Bosch S that the interrupt is triggered every 333 us (data ready) which would
pretty much flood the irq handler.

Quoted 6 lines

Somewhat quick, but maybe still worth having... Just use a one shot threaded interrupt and it
will at least run safely even if it isn't keeping up with all of them. Alan, do you have a device
that has frequency control on chip? (very unusual not to see this on an accelerometer).

Ok, I will add irq handling for v4. It will be threshold triggered, meaning I will also add the threshold parameters from bma023. If no .irq is given it will use polldev. Does that work for you Alan?

Regarding the sysfs paramters - how about removing them and use platform data only?

Best regards,
Eric

http://www.unixphere.com