diff options
-rw-r--r-- | Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt | 18 | ||||
-rw-r--r-- | drivers/iio/magnetometer/ak8975.c | 12 |
2 files changed, 27 insertions, 3 deletions
diff --git a/Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt b/Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt new file mode 100644 index 000000000000..011679f1a425 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/ak8975.txt | |||
@@ -0,0 +1,18 @@ | |||
1 | * AsahiKASEI AK8975 magnetometer sensor | ||
2 | |||
3 | Required properties: | ||
4 | |||
5 | - compatible : should be "asahi-kasei,ak8975" | ||
6 | - reg : the I2C address of the magnetometer | ||
7 | |||
8 | Optional properties: | ||
9 | |||
10 | - gpios : should be device tree identifier of the magnetometer DRDY pin | ||
11 | |||
12 | Example: | ||
13 | |||
14 | ak8975@0c { | ||
15 | compatible = "asahi-kasei,ak8975"; | ||
16 | reg = <0x0c>; | ||
17 | gpios = <&gpj0 7 0>; | ||
18 | }; | ||
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index af6c320a534e..d75cc23e8ae7 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | 30 | ||
31 | #include <linux/gpio.h> | 31 | #include <linux/gpio.h> |
32 | #include <linux/of_gpio.h> | ||
32 | 33 | ||
33 | #include <linux/iio/iio.h> | 34 | #include <linux/iio/iio.h> |
34 | #include <linux/iio/sysfs.h> | 35 | #include <linux/iio/sysfs.h> |
@@ -384,10 +385,15 @@ static int ak8975_probe(struct i2c_client *client, | |||
384 | int err; | 385 | int err; |
385 | 386 | ||
386 | /* Grab and set up the supplied GPIO. */ | 387 | /* Grab and set up the supplied GPIO. */ |
387 | if (client->dev.platform_data == NULL) | 388 | if (client->dev.platform_data) |
388 | eoc_gpio = -1; | ||
389 | else | ||
390 | eoc_gpio = *(int *)(client->dev.platform_data); | 389 | eoc_gpio = *(int *)(client->dev.platform_data); |
390 | else if (client->dev.of_node) | ||
391 | eoc_gpio = of_get_gpio(client->dev.of_node, 0); | ||
392 | else | ||
393 | eoc_gpio = -1; | ||
394 | |||
395 | if (eoc_gpio == -EPROBE_DEFER) | ||
396 | return -EPROBE_DEFER; | ||
391 | 397 | ||
392 | /* We may not have a GPIO based IRQ to scan, that is fine, we will | 398 | /* We may not have a GPIO based IRQ to scan, that is fine, we will |
393 | poll if so */ | 399 | poll if so */ |