tmd2672, tsl2772, tmd2772 devices.
Provides iio_events and direct access via sysfs.
+config SENSORS_LTR558
+ tristate "LTR558 Ambient light and proximity sensor"
+ depends on I2C
+ default n
+ help
+ If you say yes here you get support for ambient light sensing and
+ proximity ir sensing from Lite On Technology LTR558.
+
+config SENSORS_MAX44005
+ tristate "MAX44005 ALS, RGB, temperature, IR, proximity Sensor"
+ depends on I2C
+ default n
+ help
+ If you say yes here you get support for ambient light, RGB, IR,
+ Proximity and temperature sensing from MAX44005.
+
+config SENSORS_STM8T143
+ tristate "STM8T143 proximity sensor"
+ default n
+ help
+ If you say yes here you get support for ST Microelectronics
+ STM8T143 sensor driver.
+ The STM8T143 sensor driver provices suport for proximity sensing.
+ Data from sensor is accessible via sysfs.
+
+config SENSORS_TCS3772
+ tristate "TCS3772 Ambient light, RGB and proximity Sensor"
+ depends on I2C
+ select REGMAP_I2C
+ default n
+ help
+ If you say yes here you get support for ambient light, RGB and
+ Proximity sensing from TCS3772.
+
+config SENSORS_CM3217
+ tristate "CM3217 Ambient light sensor"
+ depends on I2C
+ default n
+ help
+ Say Y here to enable the CM3217 Ambient Light Sensor.
+
+config LS_OF
+ tristate "Device Tree parsing for Light sensor specification details"
+ depends on OF
+ default n
+ help
+ Say Y for helpers to retrieve the sensor specification details like
+ vendor, power consumed, max range, resolution and integration.
+ This information is common to most Ambient light sensors as well as
+ proximity sensors. Hence, have common callbacks to retrive this
+ information from the respective device tree nodes.
+
+config LS_SYSFS
+ tristate "IIO registration for sensor meta data"
+ depends on LS_OF
+ default n
+ help
+ Say Y for to share sensor specification details to user space.
+ The information is retrieved from device platform data. If you are
+ using helpers from this file, make sure device's platform data
+ contains all the required information.
+
endmenu
obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o
obj-$(CONFIG_TSL2583) += tsl2583.o
obj-$(CONFIG_SENSORS_CM3217) += cm3217.o
+obj-$(CONFIG_LS_SYSFS) += ls_sysfs.o
+obj-$(CONFIG_LS_OF) += ls_dt.o
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/iio/light/ls_sysfs.h>
+
+static const char *propname[NUM_PROP] = {
+ "vendor"
+};
+
+static const char *dt_chan_sysfs_lut[MAX_CHAN][MAX_CHAN_PROP] = {
+ {
+ "illuminance,max-range",
+ "illuminance,integration-time",
+ "illuminance,resolution",
+ "illuminance,power-consumed"
+ },
+ {
+ "proximity,max-range",
+ "proximity,integration-time",
+ "proximity,power-consumed"
+ }
+};
+
+/*
+ * 1. create instance of lightsensor_spec,
+ * 2. parse the DT node for the dev * and fill the lightsensor_spec
+ * 3. return the filled lightsensor_spec if success.
+ */
+struct lightsensor_spec *of_get_ls_spec(struct device *dev)
+{
+ const char *prop_value;
+ int i, j, ret;
+ struct lightsensor_spec *ls_spec;
+ bool is_empty = true;
+
+ if (!dev->of_node)
+ return NULL;
+
+ ls_spec = devm_kzalloc(dev,
+ sizeof(struct lightsensor_spec), GFP_KERNEL);
+ if (!ls_spec)
+ return NULL;
+
+ /* fill values of dt properties in propname -> ls_spec->propname */
+ for (i = 0; i < NUM_PROP; i++) {
+ ret = of_property_read_string(dev->of_node, propname[i],
+ &prop_value);
+ if (!ret) {
+ ls_spec->prop[i] = prop_value;
+ is_empty = false;
+ }
+ }
+
+ /*
+ * fill values of dt properties in dt_chan_sysfs_lut to
+ * ls_spec->chan_prop
+ */
+ for (i = 0; i < MAX_CHAN; i++)
+ for (j = 0; j < MAX_CHAN_PROP; j++)
+ if (dt_chan_sysfs_lut[i][j]) {
+ ret = of_property_read_string(dev->of_node,
+ dt_chan_sysfs_lut[i][j], &prop_value);
+ if (!ret) {
+ ls_spec->chan_prop[i][j] = prop_value;
+ is_empty = false;
+ }
+ }
+
+ if (is_empty) {
+ devm_kfree(dev, ls_spec);
+ ls_spec = NULL;
+ }
+
+ return ls_spec;
+}
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/module.h>
+#include <linux/iio/light/ls_sysfs.h>
+
+static const char *propname[NUM_PROP] = {
+ "vendor"
+};
+
+/* look up table for light sensor's per channel sysfs */
+static const char *sysfs_ls_lut[MAX_CHAN][MAX_CHAN_PROP] = {
+ {
+ "in_illuminance_max_range",
+ "in_illuminance_integration_time",
+ "in_illuminance_resolution",
+ "in_illuminance_power_consumed"
+ },
+ {
+ "in_proximity_max_range",
+ "in_proximity_integration_time",
+ "in_proximity_power_consumed"
+ }
+};
+
+static const char *get_ls_spec_val(struct lightsensor_spec *ls_spec,
+ const char *sysfs_name)
+{
+ int i, j;
+
+ if (sysfs_name == NULL)
+ return NULL;
+
+ if (!ls_spec)
+ return NULL;
+
+ for (i = 0; i < NUM_PROP; i++)
+ if (strstr(sysfs_name, propname[i]))
+ return ls_spec->prop[i];
+
+ for (i = 0; i < MAX_CHAN; i++)
+ for (j = 0; j < MAX_CHAN_PROP; j++)
+ if (sysfs_ls_lut[i][j] &&
+ strstr(sysfs_name, sysfs_ls_lut[i][j]))
+ return ls_spec->chan_prop[i][j];
+
+ return NULL;
+}
+
+void fill_ls_attrs(struct lightsensor_spec *ls_spec,
+ struct attribute **attrs)
+{
+ struct attribute *attr;
+ struct device_attribute *dev_attr;
+ struct iio_const_attr *iio_const_attr;
+ int i;
+ const char *val;
+
+ if (!ls_spec || !attrs)
+ return;
+
+ for (i = 0, attr = attrs[i]; attr; attr = attrs[i++]) {
+ dev_attr = container_of(attr, struct device_attribute, attr);
+ iio_const_attr = to_iio_const_attr(dev_attr);
+ val = get_ls_spec_val(ls_spec, attr->name);
+ if (val)
+ iio_const_attr->string = val;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __IIO_LS_DT_H__
+#define __IIO_LS_DT_H__
+
+#include <linux/iio/iio.h>
+
+struct lightsensor_spec;
+
+#ifdef CONFIG_LS_OF
+extern struct lightsensor_spec *of_get_ls_spec(struct device *);
+#else
+static inline struct lightsensor_spec *of_get_ls_spec(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 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,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#ifndef __IIO_LS_SYSFS_H__
+#define __IIO_LS_SYSFS_H__
+
+#define MAX_CHAN 2
+
+enum prop {
+ VENDOR,
+ NUM_PROP,
+};
+
+enum channel_prop {
+ MAX_RANGE,
+ INTEGRATION_TIME,
+ RESOLUTION,
+ POWER_CONSUMED,
+ MAX_CHAN_PROP,
+};
+
+struct lightsensor_spec {
+ const char *prop[NUM_PROP];
+ const char *chan_prop[MAX_CHAN][MAX_CHAN_PROP];
+};
+
+#ifdef CONFIG_LS_SYSFS
+extern void fill_ls_attrs(struct lightsensor_spec *, struct attribute **);
+#else
+void fill_ls_attrs(struct lightsensor_spec *meta, struct attribute **attrs)
+{
+}
+#endif
+
+#endif /* __IIO_LS_SYSFS_H__ */