Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f4b7f751 authored by Jacek Anaszewski's avatar Jacek Anaszewski Committed by Jonathan Cameron
Browse files

iio:ak8975 Add support for gpios DT property



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

Signed-off-by: default avatarJacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent e64e7d5c
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
* AsahiKASEI AK8975 magnetometer sensor

Required properties:

  - compatible : should be "asahi-kasei,ak8975"
  - reg : the I2C address of the magnetometer

Optional properties:

  - gpios : should be device tree identifier of the magnetometer DRDY pin

Example:

ak8975@0c {
        compatible = "asahi-kasei,ak8975";
        reg = <0x0c>;
        gpios = <&gpj0 7 0>;
};
+9 −3
Original line number Diff line number Diff line
@@ -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,10 +385,15 @@ static int ak8975_probe(struct i2c_client *client,
	int err;

	/* Grab and set up the supplied GPIO. */
	if (client->dev.platform_data == NULL)
		eoc_gpio = -1;
	else
	if (client->dev.platform_data)
		eoc_gpio = *(int *)(client->dev.platform_data);
	else if (client->dev.of_node)
		eoc_gpio = of_get_gpio(client->dev.of_node, 0);
	else
		eoc_gpio = -1;

	if (eoc_gpio == -EPROBE_DEFER)
		return -EPROBE_DEFER;

	/* We may not have a GPIO based IRQ to scan, that is fine, we will
	   poll if so */