[PATCH 1/2] iio: ak8975: Add support for gpios DT property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add support for parsing 'gpios' property when initializing
from oftree.
This patch adds also the binding documentation file.

Signed-off-by: Jacek Anaszewski <j.anaszewski@xxxxxxxxxxx>
Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
Cc: Andrew Chew <achew@xxxxxxxxxx>
---
 .../bindings/staging/iio/magnetometer/ak8975.txt   |   19 +++++++++++++++++++
 drivers/iio/magnetometer/ak8975.c                  |    5 ++++-
 2 files changed, 23 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/staging/iio/magnetometer/ak8975.txt

diff --git a/Documentation/devicetree/bindings/staging/iio/magnetometer/ak8975.txt b/Documentation/devicetree/bindings/staging/iio/magnetometer/ak8975.txt
new file mode 100644
index 0000000..d085d90
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/iio/magnetometer/ak8975.txt
@@ -0,0 +1,19 @@
+* AsahiKASEI AK8975 device driver
+
+Required properties:
+
+  - compatible : should be "asahi-kasei,ak8975"
+  - reg : the I2C address of the magnetometer
+
+Optional properties:
+
+  - gpios : should be device tree identifier of magnetometer DRDY pin
+
+Example:
+
+ak8975@0C {
+        compatible = "asahi-kasei,ak8975";
+        reg = <0x0C>;
+        gpios = <&gpj0 7 0>;
+};
+
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index af6c320..eb17eca 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -29,6 +29,7 @@
 #include <linux/delay.h>
 
 #include <linux/gpio.h>
+#include <linux/of_gpio.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -384,7 +385,9 @@ static int ak8975_probe(struct i2c_client *client,
 	int err;
 
 	/* Grab and set up the supplied GPIO. */
-	if (client->dev.platform_data == NULL)
+	if (client->dev.of_node)
+		eoc_gpio = of_get_gpio(client->dev.of_node, 0);
+	else if (client->dev.platform_data == NULL)
 		eoc_gpio = -1;
 	else
 		eoc_gpio = *(int *)(client->dev.platform_data);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux