]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
iio: cros_ec: Move cros_ec_sensors_core.h in /include
authorGwendal Grignou <gwendal@chromium.org>
Tue, 13 Mar 2018 21:23:28 +0000 (14:23 -0700)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 17 Mar 2018 19:59:20 +0000 (19:59 +0000)
Similar to other common iio frameworks, move cros_ec_sensors_core.h from
drivers/iio/common/cros_ec_sensors/ to include/linux/iio/common.

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h [deleted file]
drivers/iio/light/cros_ec_light_prox.c
drivers/iio/pressure/cros_ec_baro.c
include/linux/iio/common/cros_ec_sensors_core.h [new file with mode: 0644]

index 705cb3e72663969f24a38bc5e42404500ea6872a..89cb0066a6e0839f49fd68fb2395e8425b174c90 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/iio/trigger_consumer.h>
@@ -31,8 +32,6 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 
-#include "cros_ec_sensors_core.h"
-
 #define CROS_EC_SENSORS_MAX_CHANNELS 4
 
 /* State data for ec_sensors iio driver. */
index a620eb5ce2022457df0fadd9a0f6500eafa64291..07863a6226e486899c60c18413bb84fa1004e122 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/iio/trigger_consumer.h>
@@ -27,8 +28,6 @@
 #include <linux/sysfs.h>
 #include <linux/platform_device.h>
 
-#include "cros_ec_sensors_core.h"
-
 static char *cros_ec_loc[] = {
        [MOTIONSENSE_LOC_BASE] = "base",
        [MOTIONSENSE_LOC_LID] = "lid",
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h
deleted file mode 100644 (file)
index 2edf68d..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * ChromeOS EC sensor hub
- *
- * Copyright (C) 2016 Google, Inc
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- */
-
-#ifndef __CROS_EC_SENSORS_CORE_H
-#define __CROS_EC_SENSORS_CORE_H
-
-#include <linux/irqreturn.h>
-
-enum {
-       CROS_EC_SENSOR_X,
-       CROS_EC_SENSOR_Y,
-       CROS_EC_SENSOR_Z,
-       CROS_EC_SENSOR_MAX_AXIS,
-};
-
-/* EC returns sensor values using signed 16 bit registers */
-#define CROS_EC_SENSOR_BITS 16
-
-/*
- * 4 16 bit channels are allowed.
- * Good enough for current sensors, they use up to 3 16 bit vectors.
- */
-#define CROS_EC_SAMPLE_SIZE  (sizeof(s64) * 2)
-
-/* Minimum sampling period to use when device is suspending */
-#define CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY 1000  /* 1 second */
-
-/**
- * struct cros_ec_sensors_core_state - state data for EC sensors IIO driver
- * @ec:                                cros EC device structure
- * @cmd_lock:                  lock used to prevent simultaneous access to the
- *                             commands.
- * @msg:                       cros EC command structure
- * @param:                     motion sensor parameters structure
- * @resp:                      motion sensor response structure
- * @type:                      type of motion sensor
- * @loc:                       location where the motion sensor is placed
- * @calib:                     calibration parameters. Note that trigger
- *                             captured data will always provide the calibrated
- *                             data
- * @samples:                   static array to hold data from a single capture.
- *                             For each channel we need 2 bytes, except for
- *                             the timestamp. The timestamp is always last and
- *                             is always 8-byte aligned.
- * @read_ec_sensors_data:      function used for accessing sensors values
- * @cuur_sampl_freq:           current sampling period
- */
-struct cros_ec_sensors_core_state {
-       struct cros_ec_device *ec;
-       struct mutex cmd_lock;
-
-       struct cros_ec_command *msg;
-       struct ec_params_motion_sense param;
-       struct ec_response_motion_sense *resp;
-
-       enum motionsensor_type type;
-       enum motionsensor_location loc;
-
-       s16 calib[CROS_EC_SENSOR_MAX_AXIS];
-
-       u8 samples[CROS_EC_SAMPLE_SIZE];
-
-       int (*read_ec_sensors_data)(struct iio_dev *indio_dev,
-                                   unsigned long scan_mask, s16 *data);
-
-       int curr_sampl_freq;
-};
-
-/**
- * cros_ec_sensors_read_lpc() - retrieve data from EC shared memory
- * @indio_dev: pointer to IIO device
- * @scan_mask: bitmap of the sensor indices to scan
- * @data:      location to store data
- *
- * This is the safe function for reading the EC data. It guarantees that the
- * data sampled was not modified by the EC while being read.
- *
- * Return: 0 on success, -errno on failure.
- */
-int cros_ec_sensors_read_lpc(struct iio_dev *indio_dev, unsigned long scan_mask,
-                            s16 *data);
-
-/**
- * cros_ec_sensors_read_cmd() - retrieve data using the EC command protocol
- * @indio_dev: pointer to IIO device
- * @scan_mask: bitmap of the sensor indices to scan
- * @data:      location to store data
- *
- * Return: 0 on success, -errno on failure.
- */
-int cros_ec_sensors_read_cmd(struct iio_dev *indio_dev, unsigned long scan_mask,
-                            s16 *data);
-
-/**
- * cros_ec_sensors_core_init() - basic initialization of the core structure
- * @pdev:              platform device created for the sensors
- * @indio_dev:         iio device structure of the device
- * @physical_device:   true if the device refers to a physical device
- *
- * Return: 0 on success, -errno on failure.
- */
-int cros_ec_sensors_core_init(struct platform_device *pdev,
-                             struct iio_dev *indio_dev, bool physical_device);
-
-/**
- * cros_ec_sensors_capture() - the trigger handler function
- * @irq:       the interrupt number.
- * @p:         a pointer to the poll function.
- *
- * On a trigger event occurring, if the pollfunc is attached then this
- * handler is called as a threaded interrupt (and hence may sleep). It
- * is responsible for grabbing data from the device and pushing it into
- * the associated buffer.
- *
- * Return: IRQ_HANDLED
- */
-irqreturn_t cros_ec_sensors_capture(int irq, void *p);
-
-/**
- * cros_ec_motion_send_host_cmd() - send motion sense host command
- * @st:                pointer to state information for device
- * @opt_length:        optional length to reduce the response size, useful on the data
- *             path. Otherwise, the maximal allowed response size is used
- *
- * When called, the sub-command is assumed to be set in param->cmd.
- *
- * Return: 0 on success, -errno on failure.
- */
-int cros_ec_motion_send_host_cmd(struct cros_ec_sensors_core_state *st,
-                                u16 opt_length);
-
-/**
- * cros_ec_sensors_core_read() - function to request a value from the sensor
- * @st:                pointer to state information for device
- * @chan:      channel specification structure table
- * @val:       will contain one element making up the returned value
- * @val2:      will contain another element making up the returned value
- * @mask:      specifies which values to be requested
- *
- * Return:     the type of value returned by the device
- */
-int cros_ec_sensors_core_read(struct cros_ec_sensors_core_state *st,
-                             struct iio_chan_spec const *chan,
-                             int *val, int *val2, long mask);
-
-/**
- * cros_ec_sensors_core_write() - function to write a value to the sensor
- * @st:                pointer to state information for device
- * @chan:      channel specification structure table
- * @val:       first part of value to write
- * @val2:      second part of value to write
- * @mask:      specifies which values to write
- *
- * Return:     the type of value returned by the device
- */
-int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
-                              struct iio_chan_spec const *chan,
-                              int val, int val2, long mask);
-
-extern const struct dev_pm_ops cros_ec_sensors_pm_ops;
-
-/* List of extended channel specification for all sensors */
-extern const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[];
-
-#endif  /* __CROS_EC_SENSORS_CORE_H */
index 8e8a0e7f78d1fa639a0d2b9d921f2081cdf857c4..fd1609e975ab3ba0c792c23e7113c97a2307331d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/iio/trigger.h>
@@ -29,8 +30,6 @@
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 
-#include "../common/cros_ec_sensors/cros_ec_sensors_core.h"
-
 /*
  * We only represent one entry for light or proximity. EC is merging different
  * light sensors to return the what the eye would see. For proximity, we
index 4599fde4dd25af224e31578483aebae4a789f171..87c07af9181f95c7f3dd93fe59423b1987fa0bd7 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/common/cros_ec_sensors_core.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/iio/trigger.h>
@@ -28,8 +29,6 @@
 #include <linux/slab.h>
 #include <linux/platform_device.h>
 
-#include "../common/cros_ec_sensors/cros_ec_sensors_core.h"
-
 /*
  * One channel for pressure, the other for timestamp.
  */
diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
new file mode 100644 (file)
index 0000000..ce16445
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * ChromeOS EC sensor hub
+ *
+ * Copyright (C) 2016 Google, Inc
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#ifndef __CROS_EC_SENSORS_CORE_H
+#define __CROS_EC_SENSORS_CORE_H
+
+#include <linux/iio/iio.h>
+#include <linux/irqreturn.h>
+#include <linux/mfd/cros_ec.h>
+
+enum {
+       CROS_EC_SENSOR_X,
+       CROS_EC_SENSOR_Y,
+       CROS_EC_SENSOR_Z,
+       CROS_EC_SENSOR_MAX_AXIS,
+};
+
+/* EC returns sensor values using signed 16 bit registers */
+#define CROS_EC_SENSOR_BITS 16
+
+/*
+ * 4 16 bit channels are allowed.
+ * Good enough for current sensors, they use up to 3 16 bit vectors.
+ */
+#define CROS_EC_SAMPLE_SIZE  (sizeof(s64) * 2)
+
+/* Minimum sampling period to use when device is suspending */
+#define CROS_EC_MIN_SUSPEND_SAMPLING_FREQUENCY 1000  /* 1 second */
+
+/**
+ * struct cros_ec_sensors_core_state - state data for EC sensors IIO driver
+ * @ec:                                cros EC device structure
+ * @cmd_lock:                  lock used to prevent simultaneous access to the
+ *                             commands.
+ * @msg:                       cros EC command structure
+ * @param:                     motion sensor parameters structure
+ * @resp:                      motion sensor response structure
+ * @type:                      type of motion sensor
+ * @loc:                       location where the motion sensor is placed
+ * @calib:                     calibration parameters. Note that trigger
+ *                             captured data will always provide the calibrated
+ *                             data
+ * @samples:                   static array to hold data from a single capture.
+ *                             For each channel we need 2 bytes, except for
+ *                             the timestamp. The timestamp is always last and
+ *                             is always 8-byte aligned.
+ * @read_ec_sensors_data:      function used for accessing sensors values
+ * @cuur_sampl_freq:           current sampling period
+ */
+struct cros_ec_sensors_core_state {
+       struct cros_ec_device *ec;
+       struct mutex cmd_lock;
+
+       struct cros_ec_command *msg;
+       struct ec_params_motion_sense param;
+       struct ec_response_motion_sense *resp;
+
+       enum motionsensor_type type;
+       enum motionsensor_location loc;
+
+       s16 calib[CROS_EC_SENSOR_MAX_AXIS];
+
+       u8 samples[CROS_EC_SAMPLE_SIZE];
+
+       int (*read_ec_sensors_data)(struct iio_dev *indio_dev,
+                                   unsigned long scan_mask, s16 *data);
+
+       int curr_sampl_freq;
+};
+
+/**
+ * cros_ec_sensors_read_lpc() - retrieve data from EC shared memory
+ * @indio_dev: pointer to IIO device
+ * @scan_mask: bitmap of the sensor indices to scan
+ * @data:      location to store data
+ *
+ * This is the safe function for reading the EC data. It guarantees that the
+ * data sampled was not modified by the EC while being read.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+int cros_ec_sensors_read_lpc(struct iio_dev *indio_dev, unsigned long scan_mask,
+                            s16 *data);
+
+/**
+ * cros_ec_sensors_read_cmd() - retrieve data using the EC command protocol
+ * @indio_dev: pointer to IIO device
+ * @scan_mask: bitmap of the sensor indices to scan
+ * @data:      location to store data
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+int cros_ec_sensors_read_cmd(struct iio_dev *indio_dev, unsigned long scan_mask,
+                            s16 *data);
+
+struct platform_device;
+/**
+ * cros_ec_sensors_core_init() - basic initialization of the core structure
+ * @pdev:              platform device created for the sensors
+ * @indio_dev:         iio device structure of the device
+ * @physical_device:   true if the device refers to a physical device
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+int cros_ec_sensors_core_init(struct platform_device *pdev,
+                             struct iio_dev *indio_dev, bool physical_device);
+
+/**
+ * cros_ec_sensors_capture() - the trigger handler function
+ * @irq:       the interrupt number.
+ * @p:         a pointer to the poll function.
+ *
+ * On a trigger event occurring, if the pollfunc is attached then this
+ * handler is called as a threaded interrupt (and hence may sleep). It
+ * is responsible for grabbing data from the device and pushing it into
+ * the associated buffer.
+ *
+ * Return: IRQ_HANDLED
+ */
+irqreturn_t cros_ec_sensors_capture(int irq, void *p);
+
+/**
+ * cros_ec_motion_send_host_cmd() - send motion sense host command
+ * @st:                pointer to state information for device
+ * @opt_length:        optional length to reduce the response size, useful on the data
+ *             path. Otherwise, the maximal allowed response size is used
+ *
+ * When called, the sub-command is assumed to be set in param->cmd.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+int cros_ec_motion_send_host_cmd(struct cros_ec_sensors_core_state *st,
+                                u16 opt_length);
+
+/**
+ * cros_ec_sensors_core_read() - function to request a value from the sensor
+ * @st:                pointer to state information for device
+ * @chan:      channel specification structure table
+ * @val:       will contain one element making up the returned value
+ * @val2:      will contain another element making up the returned value
+ * @mask:      specifies which values to be requested
+ *
+ * Return:     the type of value returned by the device
+ */
+int cros_ec_sensors_core_read(struct cros_ec_sensors_core_state *st,
+                             struct iio_chan_spec const *chan,
+                             int *val, int *val2, long mask);
+
+/**
+ * cros_ec_sensors_core_write() - function to write a value to the sensor
+ * @st:                pointer to state information for device
+ * @chan:      channel specification structure table
+ * @val:       first part of value to write
+ * @val2:      second part of value to write
+ * @mask:      specifies which values to write
+ *
+ * Return:     the type of value returned by the device
+ */
+int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
+                              struct iio_chan_spec const *chan,
+                              int val, int val2, long mask);
+
+extern const struct dev_pm_ops cros_ec_sensors_pm_ops;
+
+/* List of extended channel specification for all sensors */
+extern const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[];
+
+#endif  /* __CROS_EC_SENSORS_CORE_H */