aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sensorhub/atmel/light_cm36651.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sensorhub/atmel/light_cm36651.c')
-rwxr-xr-xdrivers/sensorhub/atmel/light_cm36651.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/drivers/sensorhub/atmel/light_cm36651.c b/drivers/sensorhub/atmel/light_cm36651.c
new file mode 100755
index 00000000000..68081e44deb
--- /dev/null
+++ b/drivers/sensorhub/atmel/light_cm36651.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012, Samsung Electronics Co. Ltd. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ */
+#include "ssp.h"
+
+#define VENDOR "CAPELLA"
+#define CHIP_ID "CM36651"
+
+/*************************************************************************/
+/* factory Sysfs */
+/*************************************************************************/
+
+static ssize_t light_vendor_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%s\n", VENDOR);
+}
+
+static ssize_t light_name_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%s\n", CHIP_ID);
+}
+
+static ssize_t light_lux_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ssp_data *data = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%u,%u,%u,%u\n",
+ data->buf[LIGHT_SENSOR].r, data->buf[LIGHT_SENSOR].g,
+ data->buf[LIGHT_SENSOR].b, data->buf[LIGHT_SENSOR].w);
+}
+
+static ssize_t light_data_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct ssp_data *data = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%u,%u,%u,%u\n",
+ data->buf[LIGHT_SENSOR].r, data->buf[LIGHT_SENSOR].g,
+ data->buf[LIGHT_SENSOR].b, data->buf[LIGHT_SENSOR].w);
+}
+
+static DEVICE_ATTR(vendor, S_IRUGO, light_vendor_show, NULL);
+static DEVICE_ATTR(name, S_IRUGO, light_name_show, NULL);
+static DEVICE_ATTR(lux, S_IRUGO, light_lux_show, NULL);
+static DEVICE_ATTR(raw_data, S_IRUGO, light_data_show, NULL);
+
+static struct device_attribute *light_attrs[] = {
+ &dev_attr_vendor,
+ &dev_attr_name,
+ &dev_attr_lux,
+ &dev_attr_raw_data,
+ NULL,
+};
+
+void initialize_light_factorytest(struct ssp_data *data)
+{
+ sensors_register(data->light_device, data, light_attrs, "light_sensor");
+}
+
+void remove_light_factorytest(struct ssp_data *data)
+{
+ sensors_unregister(data->light_device, light_attrs);
+}