summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/staging/iio/light/cm3217-als.txt28
-rw-r--r--drivers/staging/iio/light/Kconfig5
-rw-r--r--drivers/staging/iio/light/cm3217.c14
3 files changed, 46 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/staging/iio/light/cm3217-als.txt b/Documentation/devicetree/bindings/staging/iio/light/cm3217-als.txt
new file mode 100644
index 000000000000..2694b20bc1db
--- /dev/null
+++ b/Documentation/devicetree/bindings/staging/iio/light/cm3217-als.txt
@@ -0,0 +1,28 @@
+* Capella CM3217 ambient light sensor
+
+Required properties:
+- compatible: must be "capella,cm3217"
+- reg: i2c address of the device. It should be 0x10.
+- vdd-supply: regulator supply for the chip
+
+Optional propertied:
+- illuminance,integration-time: minimum sampling period in nano seconds.
+ default: ""480000""
+- illuminance,max-range: maximum range of this sensor's value in SI units.
+ default: "78643.2"
+- illuminance,resolution: conversion factor from sensor raw units to lux.
+ default: "307"
+- illuminance,power-consumed: rough estimate of this sensor's power consumption in mA.
+ default: "1670"
+
+Example:
+ cm3217@10 {
+ compatible = "capella,cm3217";
+ reg = <0x10>;
+ vdd-supply = <&palmas_smps9>;
+ illuminance,integration-time = "480000";
+ illuminance,max-range = "78643.2";
+ illuminance,resolution = "7675";
+ illuminance,power-consumed = "1670"; /* milli Watt */
+ };
+
diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig
index 49d0b146450e..3630c68dee51 100644
--- a/drivers/staging/iio/light/Kconfig
+++ b/drivers/staging/iio/light/Kconfig
@@ -98,9 +98,14 @@ config SENSORS_TCS3772
config SENSORS_CM3217
tristate "CM3217 Ambient light sensor"
depends on I2C
+ select LS_OF
+ select LS_SYSFS
default n
help
Say Y here to enable the CM3217 Ambient Light Sensor.
+ This driver will provide the measurements of ambient light intensity
+ in its own units.
+ Data from sensor is accessible via sysfs.
config LS_OF
tristate "Device Tree parsing for Light sensor specification details"
diff --git a/drivers/staging/iio/light/cm3217.c b/drivers/staging/iio/light/cm3217.c
index e5cc8e7f7223..a955bb255d7e 100644
--- a/drivers/staging/iio/light/cm3217.c
+++ b/drivers/staging/iio/light/cm3217.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
+/* Copyright (c) 2013-2014, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -19,6 +19,8 @@
#include <linux/regulator/consumer.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
+#include <linux/iio/light/ls_sysfs.h>
+#include <linux/iio/light/ls_dt.h>
/* IT = Integration Time. The amount of time the photons hit the sensor.
* STEP = the value from HW which is the photon count during IT.
@@ -445,6 +447,7 @@ static int cm3217_probe(struct i2c_client *client,
{
struct cm3217_inf *inf;
struct iio_dev *indio_dev;
+ struct lightsensor_spec *ls_spec;
int err;
indio_dev = iio_device_alloc(sizeof(*inf));
@@ -455,6 +458,15 @@ static int cm3217_probe(struct i2c_client *client,
inf = iio_priv(indio_dev);
+ ls_spec = of_get_ls_spec(&client->dev);
+ if (!ls_spec) {
+ dev_warn(&client->dev,
+ "devname:%s func:%s line:%d invalid meta data, use default\n",
+ id->name, __func__, __LINE__);
+ } else {
+ fill_ls_attrs(ls_spec, cm3217_attrs);
+ }
+
inf->wq = create_singlethread_workqueue(CM3217_NAME);
if (!inf->wq) {
dev_err(&client->dev, "%s workqueue err\n", __func__);