Skip to contentSkip to conversation

AS3935 lightning sensor support

PATCH Superseded Matt Ranostay 2 participants 5 messages Feb 10, 2014 – Feb 11, 2014

Subsystems (2)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover AS3935 lightning sensor support

This series adds support for the AMS AS3935 lightning sensor that allows reporting back estimated storm distance and strike events.

Changes from v5

* SPI write cache-aligned issues fixed
* Fixed mutex_unlock's being missed
* Reports distance in meters instead of kilometers (1km steps)
* tune_cap is now in picofarads and not a register value

Matt Ranostay (2):
iio:as3935: Add DT binding docs for AS3935 driver
iio: Add AS3935 lightning sensor support

 .../ABI/testing/sysfs-bus-iio-proximity-as3935     |  18 +
 .../devicetree/bindings/iio/proximity/as3935.txt   |  27 ++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/iio/Kconfig                                |   1 +
 drivers/iio/Makefile                               |   1 +
 drivers/iio/proximity/Kconfig                      |  19 +
 drivers/iio/proximity/Makefile                     |   6 +
 drivers/iio/proximity/as3935.c                     | 443 +++++++++++++++++++++
 8 files changed, 516 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/as3935.txt
 create mode 100644 drivers/iio/proximity/Kconfig
 create mode 100644 drivers/iio/proximity/Makefile
 create mode 100644 drivers/iio/proximity/as3935.c
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v6 1/2 iio:as3935: Add DT binding docs for AS3935 driver

Document compatible string, required and optional DT properties for AS3935 chipset driver.

---
 .../devicetree/bindings/iio/proximity/as3935.txt   | 27 ++++++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +
 2 files changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/as3935.txt
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +27 -0
new file mode 100644
index 0000000..0453254
@@ -0,0 +1,27 @@
+Austrian Microsystems AS3935 Franklin lightning sensor device driver
+
+Required properties:
+	- compatible: must be "ams,as3935"
+	- reg: SPI chip select number for the device
+	- spi-cpha: SPI Mode 1. Refer to spi/spi-bus.txt for generic SPI
+	slave node bindings.
+	- interrupt-parent : should be the phandle for the interrupt controller
+	- interrupts : interrupt mapping
+
+	Refer to interrupt-controller/interrupts.txt for generic
+	interrupt client node bindings.
+
+Optional properties:
+	- ams,tune-cap: Calibration tuning capacitor stepping value 0 - 120pF.
+	  This will require using the calibration data from the manufacturer.
+
+Example:
+
+as3935@0 {
+	compatible = "ams,as3935";
+	reg = <0>;
+	spi-cpha;
+	interrupt-parent = <&gpio1>;
+	interrupts = <16 1>;
+	ams,tune-cap = <80>;
+};
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index e9d19e2..03e50ff 100644
@@ -11,6 +11,7 @@ ak	Asahi Kasei Corp.
 allwinner	Allwinner Technology Co., Ltd.
 altr	Altera Corp.
 amcc	Applied Micro Circuits Corporation (APM, formally AMCC)
+ams	AMS AG
 amstaos	AMS-Taos Inc.
 apm	Applied Micro Circuits Corporation (APM)
 arm	ARM Ltd.
Signature · 1 line
1.8.3.2
#2 lore raw

Re: [PATCH v6 1/2] iio:as3935: Add DT binding docs for AS3935 driver

Quoted 16 lines · Matt Ranostay

Document compatible string, required and optional DT properties for AS3935 chipset driver.

---
 .../devicetree/bindings/iio/proximity/as3935.txt   | 27 ++++++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +
 2 files changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/as3935.txt
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +0 -0
new file mode 100644
index 0000000..0453254

Documentation/devicetree/bindings/iio/proximity/as3935.txt line 9

Quoted 9 lines
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +9 -0
@@ -0,0 +1,27 @@
+Austrian Microsystems AS3935 Franklin lightning sensor device driver
+
+Required properties:
+	- compatible: must be "ams,as3935"
+	- reg: SPI chip select number for the device
+	- spi-cpha: SPI Mode 1. Refer to spi/spi-bus.txt for generic SPI
+	slave node bindings.
+	- interrupt-parent : should be the phandle for the interrupt controller
+	- interrupts : interrupt mapping

Nit: Please don't use the term "interrupt mapping", as it's undefined and clashes with the "interrupt-map" property on an interrupt nexus. There are a lot of bindings using it, and it would be nice to get them fixed up too.

As interrupts can be described in a couple of ways it probably doesn't make sense to state the exact format here, but could this be something like the following instead:

- interrupts: the sole interrupt generated by the device.

Documentation/devicetree/bindings/iio/proximity/as3935.txt line 16

Quoted 7 lines
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +7 -0
+
+	Refer to interrupt-controller/interrupts.txt for generic
+	interrupt client node bindings.
+
+Optional properties:
+	- ams,tune-cap: Calibration tuning capacitor stepping value 0 - 120pF.
+	  This will require using the calibration data from the manufacturer.

I think "tune-cap" is a little terse. Also "cap" is used as an abbreviation for "capability" elsewhere, and it would be nice to make it clear that in this case it means "capacitor".

Could this be "ams,tuning-capacitor-pf" instead? That would make it clear at a glance what the value is and the units (though people would still ahve to refer to documentation to figure out precisely what this means).

Quoted 16 lines
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +11 -0
+
+Example:
+
+as3935@0 {
+	compatible = "ams,as3935";
+	reg = <0>;
+	spi-cpha;
+	interrupt-parent = <&gpio1>;
+	interrupts = <16 1>;
+	ams,tune-cap = <80>;
+};
Documentation/devicetree/bindings/vendor-prefixes.txt +0 -0
index e9d19e2..03e50ff 100644

Documentation/devicetree/bindings/vendor-prefixes.txt ak Asahi Kasei Corp. · line 14

Quoted 4 lines
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -11,6 +11,7 @@ ak	Asahi Kasei Corp.
 allwinner	Allwinner Technology Co., Ltd.
 altr	Altera Corp.
 amcc	Applied Micro Circuits Corporation (APM, formally AMCC)
+ams	AMS AG

The vendor-prefix addition looks fine to me.

Thanks,
Mark.

#3 lore raw

Re: [PATCH v6 1/2] iio:as3935: Add DT binding docs for AS3935 driver

Quoted 32 lines · Mark Rutland
Quoted 16 lines · Matt Ranostay

Document compatible string, required and optional DT properties for AS3935 chipset driver.

---
 .../devicetree/bindings/iio/proximity/as3935.txt   | 27 ++++++++++++++++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +
 2 files changed, 28 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/as3935.txt
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +0 -0
new file mode 100644
index 0000000..0453254

Documentation/devicetree/bindings/iio/proximity/as3935.txt line 9

Quoted 9 lines
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +9 -0
@@ -0,0 +1,27 @@
+Austrian Microsystems AS3935 Franklin lightning sensor device driver
+
+Required properties:
+     - compatible: must be "ams,as3935"
+     - reg: SPI chip select number for the device
+     - spi-cpha: SPI Mode 1. Refer to spi/spi-bus.txt for generic SPI
+     slave node bindings.
+     - interrupt-parent : should be the phandle for the interrupt controller
+     - interrupts : interrupt mapping

Nit: Please don't use the term "interrupt mapping", as it's undefined and clashes with the "interrupt-map" property on an interrupt nexus. There are a lot of bindings using it, and it would be nice to get them fixed up too.

Quoted 6 lines

As interrupts can be described in a couple of ways it probably doesn't make sense to state the exact format here, but could this be something like the following instead:

- interrupts: the sole interrupt generated by the device.

Noted.

Quoted 12 lines

Documentation/devicetree/bindings/iio/proximity/as3935.txt line 16

Quoted 7 lines
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +7 -0
+
+     Refer to interrupt-controller/interrupts.txt for generic
+     interrupt client node bindings.
+
+Optional properties:
+     - ams,tune-cap: Calibration tuning capacitor stepping value 0 - 120pF.
+       This will require using the calibration data from the manufacturer.

I think "tune-cap" is a little terse. Also "cap" is used as an abbreviation for "capability" elsewhere, and it would be nice to make it clear that in this case it means "capacitor".

Quoted 5 lines

Could this be "ams,tuning-capacitor-pf" instead? That would make it clear at a glance what the value is and the units (though people would still ahve to refer to documentation to figure out precisely what this means).

Yeah that would be a lot more clear. Noted for next version.

Quoted 25 lines
Quoted 16 lines
Documentation/devicetree/bindings/iio/proximity/as3935.txt new file +11 -0
+
+Example:
+
+as3935@0 {
+     compatible = "ams,as3935";
+     reg = <0>;
+     spi-cpha;
+     interrupt-parent = <&gpio1>;
+     interrupts = <16 1>;
+     ams,tune-cap = <80>;
+};
Documentation/devicetree/bindings/vendor-prefixes.txt +0 -0
index e9d19e2..03e50ff 100644

Documentation/devicetree/bindings/vendor-prefixes.txt ak Asahi Kasei Corp. · line 14

Quoted 4 lines
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -11,6 +11,7 @@ ak  Asahi Kasei Corp.
 allwinner    Allwinner Technology Co., Ltd.
 altr Altera Corp.
 amcc Applied Micro Circuits Corporation (APM, formally AMCC)
+ams  AMS AG

The vendor-prefix addition looks fine to me.

Thanks,
Mark.

#4 lore raw

PATCH v6 2/2 iio: Add AS3935 lightning sensor support

In reply to Matt Ranostay

AS3935 chipset can detect lightning strikes and reports those back as events and the estimated distance to the storm.

---
 .../ABI/testing/sysfs-bus-iio-proximity-as3935     |  18 +
 drivers/iio/Kconfig                                |   1 +
 drivers/iio/Makefile                               |   1 +
 drivers/iio/proximity/Kconfig                      |  19 +
 drivers/iio/proximity/Makefile                     |   6 +
 drivers/iio/proximity/as3935.c                     | 443 +++++++++++++++++++++
 6 files changed, 488 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
 create mode 100644 drivers/iio/proximity/Kconfig
 create mode 100644 drivers/iio/proximity/Makefile
 create mode 100644 drivers/iio/proximity/as3935.c
Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 new file +18 -0
new file mode 100644
index 0000000..fc92bce
@@ -0,0 +1,18 @@
+What		/sys/bus/iio/devices/iio:deviceX/in_proximity_raw
+Date:		January 2014
+KernelVersion:	3.15
+Contact:	Matt Ranostay <[email protected]>
+Description:
+		Get the current distance in meters of storm (1km steps)
+		1000       = storm overhead
+		1000-40000 = distance in meters
+		63000      = out of range
+
+What		/sys/bus/iio/devices/iio:deviceX/gain_boost
+Date:		January 2014
+KernelVersion:	3.15
+Contact:	Matt Ranostay <[email protected]>
+Description:
+		Show or set the gain boost of the amp, from 0-31 range.
+		18 = indoors (default)
+		14 = outdoors
drivers/iio/Kconfig +1 -0
index 5dd0e12..743485e 100644
@@ -74,6 +74,7 @@ if IIO_TRIGGER
    source "drivers/iio/trigger/Kconfig"
 endif #IIO_TRIGGER
 source "drivers/iio/pressure/Kconfig"
+source "drivers/iio/proximity/Kconfig"
 source "drivers/iio/temperature/Kconfig"
 
 endif # IIO
drivers/iio/Makefile +1 -0
index 887d390..698afc2 100644
@@ -24,5 +24,6 @@ obj-y += light/
 obj-y += magnetometer/
 obj-y += orientation/
 obj-y += pressure/
+obj-y += proximity/
 obj-y += temperature/
 obj-y += trigger/
drivers/iio/proximity/Kconfig new file +19 -0
new file mode 100644
index 0000000..0c8cdf5
@@ -0,0 +1,19 @@
+#
+# Proximity sensors
+#
+
+menu "Lightning sensors"
+
+config AS3935
+	tristate "AS3935 Franklin lightning sensor"
+	select IIO_BUFFER
+	select IIO_TRIGGERED_BUFFER
+	depends on SPI
+	help
+	  Say Y here to build SPI interface support for the Austrian
+	  Microsystems AS3935 lightning detection sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called as3935
+
+endmenu
drivers/iio/proximity/Makefile new file +6 -0
new file mode 100644
index 0000000..743adee
@@ -0,0 +1,6 @@
+#
+# Makefile for IIO proximity sensors
+#
+
+# When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_AS3935)		+= as3935.o
drivers/iio/proximity/as3935.c new file +443 -0

443 lines not on this page · raw message

Signature · 1 line
1.8.3.2