Version 3 of the EC protocol provides min and max frequencies and fifo
size for EC sensors.
Signed-off-by: Fabien Lahoudere <[email protected]>
---
.../cros_ec_sensors/cros_ec_sensors_core.c | 98 ++++++++++++++++++-
.../linux/iio/common/cros_ec_sensors_core.h | 7 ++
include/linux/mfd/cros_ec_commands.h | 21 ++++
3 files changed, 125 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index 719a0df5aeeb..d5c8b4714ad6 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -19,12 +19,84 @@
#include <linux/slab.h>
#include <linux/platform_device.h>
+/*
+ * Hard coded to the first device to support sensor fifo. The EC has a 2048
+ * byte fifo and will trigger an interrupt when fifo is 2/3 full.
+ */
+#define CROS_EC_FIFO_SIZE (2048 * 2 / 3)
+
static char *cros_ec_loc[] = {
[MOTIONSENSE_LOC_BASE] = "base",
[MOTIONSENSE_LOC_LID] = "lid",
[MOTIONSENSE_LOC_MAX] = "unknown",
};
+static void get_default_min_max_freq_and_fifo_size(enum motionsensor_type type,
+ u32 *min_freq,
+ u32 *max_freq,
+ u32 *max_fifo_events)
+{
+ /* we don't know fifo size, set to size previously used by sensor HAL */
+ *max_fifo_events = CROS_EC_FIFO_SIZE;
+
+ switch (type) {
+ case MOTIONSENSE_TYPE_ACCEL:
+ case MOTIONSENSE_TYPE_GYRO:
+ *min_freq = 12500;
+ *max_freq = 100000;
+ break;
+ case MOTIONSENSE_TYPE_MAG:
+ *min_freq = 5000;
+ *max_freq = 25000;
+ break;
+ case MOTIONSENSE_TYPE_PROX:
+ case MOTIONSENSE_TYPE_LIGHT:
+ *min_freq = 100;
+ *max_freq = 50000;
+ break;
+ case MOTIONSENSE_TYPE_BARO:
+ *min_freq = 250;
+ *max_freq = 20000;
+ break;
+ case MOTIONSENSE_TYPE_ACTIVITY:
+ default:
+ *max_fifo_events = 0;
+ *min_freq = 0;
+ *max_freq = 0;
+ break;
+ }
+}
+
+static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
+ u16 cmd_offset, u16 cmd, u32 *mask)
+{
+ struct {
+ struct cros_ec_command msg;
+ union {
+ struct ec_params_get_cmd_versions params;
+ struct ec_response_get_cmd_versions resp;
+ };
+ } __packed buf;
+ struct ec_params_get_cmd_versions *params = &buf.params;
+ struct ec_response_get_cmd_versions *resp = &buf.resp;
+ struct cros_ec_command *msg = &buf.msg;
+ int ret;
+
+ memset(&buf, 0, sizeof(buf));
+ msg->command = EC_CMD_GET_CMD_VERSIONS + cmd_offset;
+ msg->insize = sizeof(*resp);
+ msg->outsize = sizeof(*params);
+ params->cmd = cmd;
+ ret = cros_ec_cmd_xfer_status(ec_dev, msg);
+ if (ret >= 0) {
+ if (msg->result == EC_RES_SUCCESS)
+ *mask = resp->version_mask;
+ else
+ *mask = 0;
+ }
+ return ret;
+}
+
int cros_ec_sensors_core_init(struct platform_device *pdev,
struct iio_dev *indio_dev,
bool physical_device)
@@ -33,6 +105,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
+ u32 ver_mask;
+ int ret;
platform_set_drvdata(pdev, indio_dev);
@@ -47,8 +121,16 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
mutex_init(&state->cmd_lock);
+ /* determine what version of MOTIONSENSE CMD EC has */
+ ret = cros_ec_get_host_cmd_version_mask(state->ec,
+ ec->cmd_offset,
+ EC_CMD_MOTION_SENSE_CMD,
+ &ver_mask);
+ if (ret < 0 || ver_mask == 0)
+ return -ENODEV;
+
/* Set up the host command structure. */
- state->msg->version = 2;
+ state->msg->version = fls(ver_mask) - 1;
state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
state->msg->outsize = sizeof(struct ec_params_motion_sense);
@@ -66,6 +148,20 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
}
state->type = state->resp->info.type;
state->loc = state->resp->info.location;
+ if (state->msg->version < 3) {
+ get_default_min_max_freq_and_fifo_size(
+ state->resp->info.type,
+ &state->min_freq,
+ &state->max_freq,
+ &state->fifo_max_event_count);
+ } else {
+ state->min_freq =
+ state->resp->info_3.min_frequency;
+ state->max_freq =
+ state->resp->info_3.max_frequency;
+ state->fifo_max_event_count =
+ state->resp->info_3.fifo_max_event_count;
+ }
}
return 0;
diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
index ce16445411ac..4742a9637a85 100644
--- a/include/linux/iio/common/cros_ec_sensors_core.h
+++ b/include/linux/iio/common/cros_ec_sensors_core.h
@@ -78,6 +78,13 @@ struct cros_ec_sensors_core_state {
unsigned long scan_mask, s16 *data);
int curr_sampl_freq;
+
+ /* Min and Max Sampling Frequency in mHz */
+ u32 min_freq;
+ u32 max_freq;
+
+ /* event fifo size represented in number of events */
+ u32 fifo_max_event_count;
};
/**
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index dcec96f01879..27d71cbf22f1 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -1744,6 +1744,27 @@ struct ec_response_motion_sense {
uint8_t chip;
} info;
+ /* Used for MOTIONSENSE_CMD_INFO version 3 */
+ struct __ec_todo_unpacked {
+ /* Should be element of enum motionsensor_type. */
+ uint8_t type;
+
+ /* Should be element of enum motionsensor_location. */
+ uint8_t location;
+
+ /* Should be element of enum motionsensor_chip. */
+ uint8_t chip;
+
+ /* Minimum sensor sampling frequency */
+ uint32_t min_frequency;
+
+ /* Maximum sensor sampling frequency */
+ uint32_t max_frequency;
+
+ /* Max number of sensor events that could be in fifo */
+ uint32_t fifo_max_event_count;
+ } info_3;
+
/* Used for MOTIONSENSE_CMD_DATA */
struct ec_response_motion_sensor_data data;
--
2.20.1
In order to provide minimum and maximum frequencies for each sensors,
we use a standard API (sampling_frequency_available) to provide them
to userland.
As cros_ec_sensors_core_init do not manage default attrs, we change
the signature to let all kind of sensors to provide "struct iio_info"
with their callback. This change impact drivers using that function.
Then cros_ec_* sensors provides frequencies range in sysfs like this:
[min step max]
Signed-off-by: Fabien Lahoudere <[email protected]>
---
.../common/cros_ec_sensors/cros_ec_sensors.c | 6 +--
.../cros_ec_sensors/cros_ec_sensors_core.c | 38 +++++++++++++++++++
drivers/iio/light/cros_ec_light_prox.c | 6 +--
drivers/iio/pressure/cros_ec_baro.c | 6 +--
.../linux/iio/common/cros_ec_sensors_core.h | 4 +-
5 files changed, 50 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 17af4e0fd5f8..a0ecee15a6c8 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -172,7 +172,7 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev,
return ret;
}
-static const struct iio_info ec_sensors_info = {
+static struct iio_info ec_sensors_info = {
.read_raw = &cros_ec_sensors_read,
.write_raw = &cros_ec_sensors_write,
};
@@ -195,11 +195,11 @@ static int cros_ec_sensors_probe(struct platform_device *pdev)
if (!indio_dev)
return -ENOMEM;
- ret = cros_ec_sensors_core_init(pdev, indio_dev, true);
+ ret = cros_ec_sensors_core_init(pdev, indio_dev, &ec_sensors_info,
+ true);
if (ret)
return ret;
- indio_dev->info = &ec_sensors_info;
state = iio_priv(indio_dev);
for (channel = state->channels, i = CROS_EC_SENSOR_X;
i < CROS_EC_SENSOR_MAX_AXIS; i++, channel++) {
diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
index d5c8b4714ad6..2c2a608a10ec 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
@@ -10,6 +10,7 @@
#include <linux/iio/buffer.h>
#include <linux/iio/common/cros_ec_sensors_core.h>
#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
#include <linux/iio/kfifo_buf.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/kernel.h>
@@ -97,8 +98,42 @@ static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
return ret;
}
+/**
+ * cros_ec_sensors_read_freq() - sysfs function to get available frequencies
+ * @dev: Device structure for this device.
+ * @attr: Description of the attribute.
+ * @buf: Incoming string
+ *
+ * The later modes are only relevant to the ring buffer - and depend on current
+ * mode. Note that data sheet gives rather wide tolerances for these so integer
+ * division will give good enough answer and not all chips have them specified
+ * at all.
+ **/
+static ssize_t cros_ec_sensors_read_freq(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
+
+ return snprintf(buf, PAGE_SIZE, "[ %d 1 %d ]\n", state->min_freq,
+ state->max_freq);
+}
+
+static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(cros_ec_sensors_read_freq);
+
+static struct attribute *cros_ec_sensors_attributes[] = {
+ &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
+ NULL,
+};
+
+static const struct attribute_group cros_ec_sensors_attribute_group = {
+ .attrs = cros_ec_sensors_attributes,
+};
+
int cros_ec_sensors_core_init(struct platform_device *pdev,
struct iio_dev *indio_dev,
+ struct iio_info *info,
bool physical_device)
{
struct device *dev = &pdev->dev;
@@ -164,6 +199,9 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
}
}
+ info->attrs = &cros_ec_sensors_attribute_group;
+ indio_dev->info = info;
+
return 0;
}
EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init);
diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index 308ee6ff2e22..1772e339cf14 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -161,7 +161,7 @@ static int cros_ec_light_prox_write(struct iio_dev *indio_dev,
return ret;
}
-static const struct iio_info cros_ec_light_prox_info = {
+static struct iio_info cros_ec_light_prox_info = {
.read_raw = &cros_ec_light_prox_read,
.write_raw = &cros_ec_light_prox_write,
};
@@ -184,11 +184,11 @@ static int cros_ec_light_prox_probe(struct platform_device *pdev)
if (!indio_dev)
return -ENOMEM;
- ret = cros_ec_sensors_core_init(pdev, indio_dev, true);
+ ret = cros_ec_sensors_core_init(pdev, indio_dev,
+ &cros_ec_light_prox_info, true);
if (ret)
return ret;
- indio_dev->info = &cros_ec_light_prox_info;
state = iio_priv(indio_dev);
state->core.type = state->core.resp->info.type;
state->core.loc = state->core.resp->info.location;
diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index 034ce98d6e97..cd3be0f16226 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -107,7 +107,7 @@ static int cros_ec_baro_write(struct iio_dev *indio_dev,
return ret;
}
-static const struct iio_info cros_ec_baro_info = {
+static struct iio_info cros_ec_baro_info = {
.read_raw = &cros_ec_baro_read,
.write_raw = &cros_ec_baro_write,
};
@@ -130,11 +130,11 @@ static int cros_ec_baro_probe(struct platform_device *pdev)
if (!indio_dev)
return -ENOMEM;
- ret = cros_ec_sensors_core_init(pdev, indio_dev, true);
+ ret = cros_ec_sensors_core_init(pdev, indio_dev, &cros_ec_baro_info,
+ true);
if (ret)
return ret;
- indio_dev->info = &cros_ec_baro_info;
state = iio_priv(indio_dev);
state->core.type = state->core.resp->info.type;
state->core.loc = state->core.resp->info.location;
diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
index 4742a9637a85..7052cfb5884a 100644
--- a/include/linux/iio/common/cros_ec_sensors_core.h
+++ b/include/linux/iio/common/cros_ec_sensors_core.h
@@ -117,12 +117,14 @@ 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
+ * @info: iio info structure with read and write callback
* @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);
+ struct iio_dev *indio_dev, struct iio_info *info,
+ bool physical_device);
/**
* cros_ec_sensors_capture() - the trigger handler function
--
2.20.1
The documentation give some exemple on what format can be expected
from sampling_frequency_available sysfs attribute
Signed-off-by: Fabien Lahoudere <[email protected]>
---
Documentation/ABI/testing/sysfs-bus-iio | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 6aef7dbbde44..680451695422 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -61,8 +61,11 @@ What: /sys/bus/iio/devices/triggerX/sampling_frequency_available
KernelVersion: 2.6.35
Contact: [email protected]
Description:
- When the internal sampling clock can only take a small
- discrete set of values, this file lists those available.
+ When the internal sampling clock can only take a specific set of
+ frequencies, we can specify the available values with:
+ - a small discrete set of values like "0 2 4 6 8"
+ - a range with minimum, step and maximum frequencies like
+ "[min step max]"
What: /sys/bus/iio/devices/iio:deviceX/oversampling_ratio
KernelVersion: 2.6.38
--
2.20.1
Remove CROS_EC_FIFO_SIZE and "u32 fifo_max_event_count;" from the
driver/iio/ code. This code is for a driver - cros-ec-sensor-ring -
that is not upstreamable. [see
http://lkml.iu.edu/hypermail/linux/kernel/1607.2/01335.html]. The EC
interface is fine though, we are working on a new version of the
driver that can be merged.
Gwendal.
On Wed, May 22, 2019 at 7:10 AM Fabien Lahoudere
<[email protected]> wrote:
>
> Version 3 of the EC protocol provides min and max frequencies and fifo
> size for EC sensors.
>
> Signed-off-by: Fabien Lahoudere <[email protected]>
> ---
> .../cros_ec_sensors/cros_ec_sensors_core.c | 98 ++++++++++++++++++-
> .../linux/iio/common/cros_ec_sensors_core.h | 7 ++
> include/linux/mfd/cros_ec_commands.h | 21 ++++
> 3 files changed, 125 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> index 719a0df5aeeb..d5c8b4714ad6 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> @@ -19,12 +19,84 @@
> #include <linux/slab.h>
> #include <linux/platform_device.h>
>
> +/*
> + * Hard coded to the first device to support sensor fifo. The EC has a 2048
> + * byte fifo and will trigger an interrupt when fifo is 2/3 full.
> + */
> +#define CROS_EC_FIFO_SIZE (2048 * 2 / 3)
> +
> static char *cros_ec_loc[] = {
> [MOTIONSENSE_LOC_BASE] = "base",
> [MOTIONSENSE_LOC_LID] = "lid",
> [MOTIONSENSE_LOC_MAX] = "unknown",
> };
>
> +static void get_default_min_max_freq_and_fifo_size(enum motionsensor_type type,
> + u32 *min_freq,
> + u32 *max_freq,
> + u32 *max_fifo_events)
> +{
> + /* we don't know fifo size, set to size previously used by sensor HAL */
> + *max_fifo_events = CROS_EC_FIFO_SIZE;
> +
> + switch (type) {
> + case MOTIONSENSE_TYPE_ACCEL:
> + case MOTIONSENSE_TYPE_GYRO:
> + *min_freq = 12500;
> + *max_freq = 100000;
> + break;
> + case MOTIONSENSE_TYPE_MAG:
> + *min_freq = 5000;
> + *max_freq = 25000;
> + break;
> + case MOTIONSENSE_TYPE_PROX:
> + case MOTIONSENSE_TYPE_LIGHT:
> + *min_freq = 100;
> + *max_freq = 50000;
> + break;
> + case MOTIONSENSE_TYPE_BARO:
> + *min_freq = 250;
> + *max_freq = 20000;
> + break;
> + case MOTIONSENSE_TYPE_ACTIVITY:
> + default:
> + *max_fifo_events = 0;
> + *min_freq = 0;
> + *max_freq = 0;
> + break;
> + }
> +}
> +
> +static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
> + u16 cmd_offset, u16 cmd, u32 *mask)
> +{
> + struct {
> + struct cros_ec_command msg;
> + union {
> + struct ec_params_get_cmd_versions params;
> + struct ec_response_get_cmd_versions resp;
> + };
> + } __packed buf;
> + struct ec_params_get_cmd_versions *params = &buf.params;
> + struct ec_response_get_cmd_versions *resp = &buf.resp;
> + struct cros_ec_command *msg = &buf.msg;
> + int ret;
> +
> + memset(&buf, 0, sizeof(buf));
> + msg->command = EC_CMD_GET_CMD_VERSIONS + cmd_offset;
> + msg->insize = sizeof(*resp);
> + msg->outsize = sizeof(*params);
> + params->cmd = cmd;
> + ret = cros_ec_cmd_xfer_status(ec_dev, msg);
> + if (ret >= 0) {
> + if (msg->result == EC_RES_SUCCESS)
> + *mask = resp->version_mask;
> + else
> + *mask = 0;
> + }
> + return ret;
> +}
> +
> int cros_ec_sensors_core_init(struct platform_device *pdev,
> struct iio_dev *indio_dev,
> bool physical_device)
> @@ -33,6 +105,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
> struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
> struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
> struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
> + u32 ver_mask;
> + int ret;
>
> platform_set_drvdata(pdev, indio_dev);
>
> @@ -47,8 +121,16 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>
> mutex_init(&state->cmd_lock);
>
> + /* determine what version of MOTIONSENSE CMD EC has */
> + ret = cros_ec_get_host_cmd_version_mask(state->ec,
> + ec->cmd_offset,
> + EC_CMD_MOTION_SENSE_CMD,
> + &ver_mask);
> + if (ret < 0 || ver_mask == 0)
> + return -ENODEV;
> +
> /* Set up the host command structure. */
> - state->msg->version = 2;
> + state->msg->version = fls(ver_mask) - 1;
> state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
> state->msg->outsize = sizeof(struct ec_params_motion_sense);
>
> @@ -66,6 +148,20 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
> }
> state->type = state->resp->info.type;
> state->loc = state->resp->info.location;
> + if (state->msg->version < 3) {
> + get_default_min_max_freq_and_fifo_size(
> + state->resp->info.type,
> + &state->min_freq,
> + &state->max_freq,
> + &state->fifo_max_event_count);
> + } else {
> + state->min_freq =
> + state->resp->info_3.min_frequency;
> + state->max_freq =
> + state->resp->info_3.max_frequency;
> + state->fifo_max_event_count =
> + state->resp->info_3.fifo_max_event_count;
> + }
> }
>
> return 0;
> diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
> index ce16445411ac..4742a9637a85 100644
> --- a/include/linux/iio/common/cros_ec_sensors_core.h
> +++ b/include/linux/iio/common/cros_ec_sensors_core.h
> @@ -78,6 +78,13 @@ struct cros_ec_sensors_core_state {
> unsigned long scan_mask, s16 *data);
>
> int curr_sampl_freq;
> +
> + /* Min and Max Sampling Frequency in mHz */
> + u32 min_freq;
> + u32 max_freq;
> +
> + /* event fifo size represented in number of events */
> + u32 fifo_max_event_count;
> };
>
> /**
> diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
> index dcec96f01879..27d71cbf22f1 100644
> --- a/include/linux/mfd/cros_ec_commands.h
> +++ b/include/linux/mfd/cros_ec_commands.h
> @@ -1744,6 +1744,27 @@ struct ec_response_motion_sense {
> uint8_t chip;
> } info;
>
> + /* Used for MOTIONSENSE_CMD_INFO version 3 */
> + struct __ec_todo_unpacked {
> + /* Should be element of enum motionsensor_type. */
> + uint8_t type;
> +
> + /* Should be element of enum motionsensor_location. */
> + uint8_t location;
> +
> + /* Should be element of enum motionsensor_chip. */
> + uint8_t chip;
> +
> + /* Minimum sensor sampling frequency */
> + uint32_t min_frequency;
> +
> + /* Maximum sensor sampling frequency */
> + uint32_t max_frequency;
> +
> + /* Max number of sensor events that could be in fifo */
> + uint32_t fifo_max_event_count;
> + } info_3;
> +
> /* Used for MOTIONSENSE_CMD_DATA */
> struct ec_response_motion_sensor_data data;
>
> --
> 2.20.1
>
Hi Fabien,
On Wed, May 22, 2019 at 04:09:52PM +0200, Fabien Lahoudere wrote:
> Version 3 of the EC protocol provides min and max frequencies and fifo
> size for EC sensors.
>
> Signed-off-by: Fabien Lahoudere <[email protected]>
It looks like this is mainly based on patches from the chromium kernel:
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/490495
and a subsequent revert of a revert:
https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/529686
originally by Nick Vaccaro <[email protected]>.
Please put links to that original work here, and include Nick in the
Signed-off-by. Also, don't forget to CC him when posting to the list.
Thanks,
Benson
> ---
> .../cros_ec_sensors/cros_ec_sensors_core.c | 98 ++++++++++++++++++-
> .../linux/iio/common/cros_ec_sensors_core.h | 7 ++
> include/linux/mfd/cros_ec_commands.h | 21 ++++
> 3 files changed, 125 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> index 719a0df5aeeb..d5c8b4714ad6 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> @@ -19,12 +19,84 @@
> #include <linux/slab.h>
> #include <linux/platform_device.h>
>
> +/*
> + * Hard coded to the first device to support sensor fifo. The EC has a 2048
> + * byte fifo and will trigger an interrupt when fifo is 2/3 full.
> + */
> +#define CROS_EC_FIFO_SIZE (2048 * 2 / 3)
> +
> static char *cros_ec_loc[] = {
> [MOTIONSENSE_LOC_BASE] = "base",
> [MOTIONSENSE_LOC_LID] = "lid",
> [MOTIONSENSE_LOC_MAX] = "unknown",
> };
>
> +static void get_default_min_max_freq_and_fifo_size(enum motionsensor_type type,
> + u32 *min_freq,
> + u32 *max_freq,
> + u32 *max_fifo_events)
> +{
> + /* we don't know fifo size, set to size previously used by sensor HAL */
> + *max_fifo_events = CROS_EC_FIFO_SIZE;
> +
> + switch (type) {
> + case MOTIONSENSE_TYPE_ACCEL:
> + case MOTIONSENSE_TYPE_GYRO:
> + *min_freq = 12500;
> + *max_freq = 100000;
> + break;
> + case MOTIONSENSE_TYPE_MAG:
> + *min_freq = 5000;
> + *max_freq = 25000;
> + break;
> + case MOTIONSENSE_TYPE_PROX:
> + case MOTIONSENSE_TYPE_LIGHT:
> + *min_freq = 100;
> + *max_freq = 50000;
> + break;
> + case MOTIONSENSE_TYPE_BARO:
> + *min_freq = 250;
> + *max_freq = 20000;
> + break;
> + case MOTIONSENSE_TYPE_ACTIVITY:
> + default:
> + *max_fifo_events = 0;
> + *min_freq = 0;
> + *max_freq = 0;
> + break;
> + }
> +}
> +
> +static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
> + u16 cmd_offset, u16 cmd, u32 *mask)
> +{
> + struct {
> + struct cros_ec_command msg;
> + union {
> + struct ec_params_get_cmd_versions params;
> + struct ec_response_get_cmd_versions resp;
> + };
> + } __packed buf;
> + struct ec_params_get_cmd_versions *params = &buf.params;
> + struct ec_response_get_cmd_versions *resp = &buf.resp;
> + struct cros_ec_command *msg = &buf.msg;
> + int ret;
> +
> + memset(&buf, 0, sizeof(buf));
> + msg->command = EC_CMD_GET_CMD_VERSIONS + cmd_offset;
> + msg->insize = sizeof(*resp);
> + msg->outsize = sizeof(*params);
> + params->cmd = cmd;
> + ret = cros_ec_cmd_xfer_status(ec_dev, msg);
> + if (ret >= 0) {
> + if (msg->result == EC_RES_SUCCESS)
> + *mask = resp->version_mask;
> + else
> + *mask = 0;
> + }
> + return ret;
> +}
> +
> int cros_ec_sensors_core_init(struct platform_device *pdev,
> struct iio_dev *indio_dev,
> bool physical_device)
> @@ -33,6 +105,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
> struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
> struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
> struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
> + u32 ver_mask;
> + int ret;
>
> platform_set_drvdata(pdev, indio_dev);
>
> @@ -47,8 +121,16 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>
> mutex_init(&state->cmd_lock);
>
> + /* determine what version of MOTIONSENSE CMD EC has */
> + ret = cros_ec_get_host_cmd_version_mask(state->ec,
> + ec->cmd_offset,
> + EC_CMD_MOTION_SENSE_CMD,
> + &ver_mask);
> + if (ret < 0 || ver_mask == 0)
> + return -ENODEV;
> +
> /* Set up the host command structure. */
> - state->msg->version = 2;
> + state->msg->version = fls(ver_mask) - 1;
> state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
> state->msg->outsize = sizeof(struct ec_params_motion_sense);
>
> @@ -66,6 +148,20 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
> }
> state->type = state->resp->info.type;
> state->loc = state->resp->info.location;
> + if (state->msg->version < 3) {
> + get_default_min_max_freq_and_fifo_size(
> + state->resp->info.type,
> + &state->min_freq,
> + &state->max_freq,
> + &state->fifo_max_event_count);
> + } else {
> + state->min_freq =
> + state->resp->info_3.min_frequency;
> + state->max_freq =
> + state->resp->info_3.max_frequency;
> + state->fifo_max_event_count =
> + state->resp->info_3.fifo_max_event_count;
> + }
> }
>
> return 0;
> diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
> index ce16445411ac..4742a9637a85 100644
> --- a/include/linux/iio/common/cros_ec_sensors_core.h
> +++ b/include/linux/iio/common/cros_ec_sensors_core.h
> @@ -78,6 +78,13 @@ struct cros_ec_sensors_core_state {
> unsigned long scan_mask, s16 *data);
>
> int curr_sampl_freq;
> +
> + /* Min and Max Sampling Frequency in mHz */
> + u32 min_freq;
> + u32 max_freq;
> +
> + /* event fifo size represented in number of events */
> + u32 fifo_max_event_count;
> };
>
> /**
> diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
> index dcec96f01879..27d71cbf22f1 100644
> --- a/include/linux/mfd/cros_ec_commands.h
> +++ b/include/linux/mfd/cros_ec_commands.h
> @@ -1744,6 +1744,27 @@ struct ec_response_motion_sense {
> uint8_t chip;
> } info;
>
> + /* Used for MOTIONSENSE_CMD_INFO version 3 */
> + struct __ec_todo_unpacked {
> + /* Should be element of enum motionsensor_type. */
> + uint8_t type;
> +
> + /* Should be element of enum motionsensor_location. */
> + uint8_t location;
> +
> + /* Should be element of enum motionsensor_chip. */
> + uint8_t chip;
> +
> + /* Minimum sensor sampling frequency */
> + uint32_t min_frequency;
> +
> + /* Maximum sensor sampling frequency */
> + uint32_t max_frequency;
> +
> + /* Max number of sensor events that could be in fifo */
> + uint32_t fifo_max_event_count;
> + } info_3;
> +
> /* Used for MOTIONSENSE_CMD_DATA */
> struct ec_response_motion_sensor_data data;
>
> --
> 2.20.1
>
--
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
[email protected]
Chromium OS Project
[email protected]
On Wed, 22 May 2019, Fabien Lahoudere wrote:
> Version 3 of the EC protocol provides min and max frequencies and fifo
> size for EC sensors.
>
> Signed-off-by: Fabien Lahoudere <[email protected]>
> ---
> .../cros_ec_sensors/cros_ec_sensors_core.c | 98 ++++++++++++++++++-
> .../linux/iio/common/cros_ec_sensors_core.h | 7 ++
> include/linux/mfd/cros_ec_commands.h | 21 ++++
Please note that we are about to add a pretty bit update for this
file. Once it's complete you may wish to rebase in order to avoid
any possible merge conflicts.
> 3 files changed, 125 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> index 719a0df5aeeb..d5c8b4714ad6 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> @@ -19,12 +19,84 @@
> #include <linux/slab.h>
> #include <linux/platform_device.h>
>
> +/*
> + * Hard coded to the first device to support sensor fifo. The EC has a 2048
> + * byte fifo and will trigger an interrupt when fifo is 2/3 full.
> + */
> +#define CROS_EC_FIFO_SIZE (2048 * 2 / 3)
> +
> static char *cros_ec_loc[] = {
> [MOTIONSENSE_LOC_BASE] = "base",
> [MOTIONSENSE_LOC_LID] = "lid",
> [MOTIONSENSE_LOC_MAX] = "unknown",
> };
>
> +static void get_default_min_max_freq_and_fifo_size(enum motionsensor_type type,
> + u32 *min_freq,
> + u32 *max_freq,
> + u32 *max_fifo_events)
> +{
> + /* we don't know fifo size, set to size previously used by sensor HAL */
> + *max_fifo_events = CROS_EC_FIFO_SIZE;
> +
> + switch (type) {
> + case MOTIONSENSE_TYPE_ACCEL:
> + case MOTIONSENSE_TYPE_GYRO:
> + *min_freq = 12500;
> + *max_freq = 100000;
> + break;
> + case MOTIONSENSE_TYPE_MAG:
> + *min_freq = 5000;
> + *max_freq = 25000;
> + break;
> + case MOTIONSENSE_TYPE_PROX:
> + case MOTIONSENSE_TYPE_LIGHT:
> + *min_freq = 100;
> + *max_freq = 50000;
> + break;
> + case MOTIONSENSE_TYPE_BARO:
> + *min_freq = 250;
> + *max_freq = 20000;
> + break;
> + case MOTIONSENSE_TYPE_ACTIVITY:
> + default:
> + *max_fifo_events = 0;
> + *min_freq = 0;
> + *max_freq = 0;
> + break;
> + }
> +}
> +
> +static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
> + u16 cmd_offset, u16 cmd, u32 *mask)
> +{
> + struct {
> + struct cros_ec_command msg;
> + union {
> + struct ec_params_get_cmd_versions params;
> + struct ec_response_get_cmd_versions resp;
> + };
> + } __packed buf;
> + struct ec_params_get_cmd_versions *params = &buf.params;
> + struct ec_response_get_cmd_versions *resp = &buf.resp;
> + struct cros_ec_command *msg = &buf.msg;
> + int ret;
> +
> + memset(&buf, 0, sizeof(buf));
> + msg->command = EC_CMD_GET_CMD_VERSIONS + cmd_offset;
> + msg->insize = sizeof(*resp);
> + msg->outsize = sizeof(*params);
> + params->cmd = cmd;
> + ret = cros_ec_cmd_xfer_status(ec_dev, msg);
> + if (ret >= 0) {
> + if (msg->result == EC_RES_SUCCESS)
> + *mask = resp->version_mask;
> + else
> + *mask = 0;
> + }
> + return ret;
> +}
> +
> int cros_ec_sensors_core_init(struct platform_device *pdev,
> struct iio_dev *indio_dev,
> bool physical_device)
> @@ -33,6 +105,8 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
> struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
> struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
> struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
> + u32 ver_mask;
> + int ret;
>
> platform_set_drvdata(pdev, indio_dev);
>
> @@ -47,8 +121,16 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
>
> mutex_init(&state->cmd_lock);
>
> + /* determine what version of MOTIONSENSE CMD EC has */
> + ret = cros_ec_get_host_cmd_version_mask(state->ec,
> + ec->cmd_offset,
> + EC_CMD_MOTION_SENSE_CMD,
> + &ver_mask);
> + if (ret < 0 || ver_mask == 0)
> + return -ENODEV;
> +
> /* Set up the host command structure. */
> - state->msg->version = 2;
> + state->msg->version = fls(ver_mask) - 1;
> state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
> state->msg->outsize = sizeof(struct ec_params_motion_sense);
>
> @@ -66,6 +148,20 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
> }
> state->type = state->resp->info.type;
> state->loc = state->resp->info.location;
> + if (state->msg->version < 3) {
> + get_default_min_max_freq_and_fifo_size(
> + state->resp->info.type,
> + &state->min_freq,
> + &state->max_freq,
> + &state->fifo_max_event_count);
> + } else {
> + state->min_freq =
> + state->resp->info_3.min_frequency;
> + state->max_freq =
> + state->resp->info_3.max_frequency;
> + state->fifo_max_event_count =
> + state->resp->info_3.fifo_max_event_count;
> + }
> }
>
> return 0;
> diff --git a/include/linux/iio/common/cros_ec_sensors_core.h b/include/linux/iio/common/cros_ec_sensors_core.h
> index ce16445411ac..4742a9637a85 100644
> --- a/include/linux/iio/common/cros_ec_sensors_core.h
> +++ b/include/linux/iio/common/cros_ec_sensors_core.h
> @@ -78,6 +78,13 @@ struct cros_ec_sensors_core_state {
> unsigned long scan_mask, s16 *data);
>
> int curr_sampl_freq;
> +
> + /* Min and Max Sampling Frequency in mHz */
> + u32 min_freq;
> + u32 max_freq;
> +
> + /* event fifo size represented in number of events */
> + u32 fifo_max_event_count;
> };
>
> /**
> diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
> index dcec96f01879..27d71cbf22f1 100644
> --- a/include/linux/mfd/cros_ec_commands.h
> +++ b/include/linux/mfd/cros_ec_commands.h
> @@ -1744,6 +1744,27 @@ struct ec_response_motion_sense {
> uint8_t chip;
> } info;
>
> + /* Used for MOTIONSENSE_CMD_INFO version 3 */
> + struct __ec_todo_unpacked {
> + /* Should be element of enum motionsensor_type. */
> + uint8_t type;
> +
> + /* Should be element of enum motionsensor_location. */
> + uint8_t location;
> +
> + /* Should be element of enum motionsensor_chip. */
> + uint8_t chip;
> +
> + /* Minimum sensor sampling frequency */
> + uint32_t min_frequency;
> +
> + /* Maximum sensor sampling frequency */
> + uint32_t max_frequency;
> +
> + /* Max number of sensor events that could be in fifo */
> + uint32_t fifo_max_event_count;
> + } info_3;
> +
> /* Used for MOTIONSENSE_CMD_DATA */
> struct ec_response_motion_sensor_data data;
>
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Le lundi 03 juin 2019 à 13:55 +0100, Lee Jones a écrit :
> On Wed, 22 May 2019, Fabien Lahoudere wrote:
>
> > Version 3 of the EC protocol provides min and max frequencies and
> > fifo
> > size for EC sensors.
> >
> > Signed-off-by: Fabien Lahoudere <[email protected]>
> > ---
> > .../cros_ec_sensors/cros_ec_sensors_core.c | 98
> > ++++++++++++++++++-
> > .../linux/iio/common/cros_ec_sensors_core.h | 7 ++
> > include/linux/mfd/cros_ec_commands.h | 21 ++++
>
> Please note that we are about to add a pretty bit update for this
> file. Once it's complete you may wish to rebase in order to avoid
> any possible merge conflicts.
>
Thanks Lee. Indeed I see and reviewed this 30 patches series.
I am waiting they are applied to rebase ans submit v3.
> > 3 files changed, 125 insertions(+), 1 deletion(-)
> >
> > diff --git
> > a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > index 719a0df5aeeb..d5c8b4714ad6 100644
> > --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
> > @@ -19,12 +19,84 @@
> > #include <linux/slab.h>
> > #include <linux/platform_device.h>
> >
> > +/*
> > + * Hard coded to the first device to support sensor fifo. The EC
> > has a 2048
> > + * byte fifo and will trigger an interrupt when fifo is 2/3 full.
> > + */
> > +#define CROS_EC_FIFO_SIZE (2048 * 2 / 3)
> > +
> > static char *cros_ec_loc[] = {
> > [MOTIONSENSE_LOC_BASE] = "base",
> > [MOTIONSENSE_LOC_LID] = "lid",
> > [MOTIONSENSE_LOC_MAX] = "unknown",
> > };
> >
> > +static void get_default_min_max_freq_and_fifo_size(enum
> > motionsensor_type type,
> > + u32 *min_freq,
> > + u32 *max_freq,
> > + u32
> > *max_fifo_events)
> > +{
> > + /* we don't know fifo size, set to size previously used by
> > sensor HAL */
> > + *max_fifo_events = CROS_EC_FIFO_SIZE;
> > +
> > + switch (type) {
> > + case MOTIONSENSE_TYPE_ACCEL:
> > + case MOTIONSENSE_TYPE_GYRO:
> > + *min_freq = 12500;
> > + *max_freq = 100000;
> > + break;
> > + case MOTIONSENSE_TYPE_MAG:
> > + *min_freq = 5000;
> > + *max_freq = 25000;
> > + break;
> > + case MOTIONSENSE_TYPE_PROX:
> > + case MOTIONSENSE_TYPE_LIGHT:
> > + *min_freq = 100;
> > + *max_freq = 50000;
> > + break;
> > + case MOTIONSENSE_TYPE_BARO:
> > + *min_freq = 250;
> > + *max_freq = 20000;
> > + break;
> > + case MOTIONSENSE_TYPE_ACTIVITY:
> > + default:
> > + *max_fifo_events = 0;
> > + *min_freq = 0;
> > + *max_freq = 0;
> > + break;
> > + }
> > +}
> > +
> > +static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device
> > *ec_dev,
> > + u16 cmd_offset, u16 cmd,
> > u32 *mask)
> > +{
> > + struct {
> > + struct cros_ec_command msg;
> > + union {
> > + struct ec_params_get_cmd_versions params;
> > + struct ec_response_get_cmd_versions resp;
> > + };
> > + } __packed buf;
> > + struct ec_params_get_cmd_versions *params = &buf.params;
> > + struct ec_response_get_cmd_versions *resp = &buf.resp;
> > + struct cros_ec_command *msg = &buf.msg;
> > + int ret;
> > +
> > + memset(&buf, 0, sizeof(buf));
> > + msg->command = EC_CMD_GET_CMD_VERSIONS + cmd_offset;
> > + msg->insize = sizeof(*resp);
> > + msg->outsize = sizeof(*params);
> > + params->cmd = cmd;
> > + ret = cros_ec_cmd_xfer_status(ec_dev, msg);
> > + if (ret >= 0) {
> > + if (msg->result == EC_RES_SUCCESS)
> > + *mask = resp->version_mask;
> > + else
> > + *mask = 0;
> > + }
> > + return ret;
> > +}
> > +
> > int cros_ec_sensors_core_init(struct platform_device *pdev,
> > struct iio_dev *indio_dev,
> > bool physical_device)
> > @@ -33,6 +105,8 @@ int cros_ec_sensors_core_init(struct
> > platform_device *pdev,
> > struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
> > struct cros_ec_dev *ec = dev_get_drvdata(pdev->dev.parent);
> > struct cros_ec_sensor_platform *sensor_platform =
> > dev_get_platdata(dev);
> > + u32 ver_mask;
> > + int ret;
> >
> > platform_set_drvdata(pdev, indio_dev);
> >
> > @@ -47,8 +121,16 @@ int cros_ec_sensors_core_init(struct
> > platform_device *pdev,
> >
> > mutex_init(&state->cmd_lock);
> >
> > + /* determine what version of MOTIONSENSE CMD EC has */
> > + ret = cros_ec_get_host_cmd_version_mask(state->ec,
> > + ec->cmd_offset,
> > + EC_CMD_MOTION_SENSE_CMD
> > ,
> > + &ver_mask);
> > + if (ret < 0 || ver_mask == 0)
> > + return -ENODEV;
> > +
> > /* Set up the host command structure. */
> > - state->msg->version = 2;
> > + state->msg->version = fls(ver_mask) - 1;
> > state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
> > state->msg->outsize = sizeof(struct ec_params_motion_sense);
> >
> > @@ -66,6 +148,20 @@ int cros_ec_sensors_core_init(struct
> > platform_device *pdev,
> > }
> > state->type = state->resp->info.type;
> > state->loc = state->resp->info.location;
> > + if (state->msg->version < 3) {
> > + get_default_min_max_freq_and_fifo_size(
> > + state->resp->info.type,
> > + &state->min_freq,
> > + &state->max_freq,
> > + &state->fifo_max_event_count);
> > + } else {
> > + state->min_freq =
> > + state->resp->info_3.min_frequency;
> > + state->max_freq =
> > + state->resp->info_3.max_frequency;
> > + state->fifo_max_event_count =
> > + state->resp-
> > >info_3.fifo_max_event_count;
> > + }
> > }
> >
> > return 0;
> > diff --git a/include/linux/iio/common/cros_ec_sensors_core.h
> > b/include/linux/iio/common/cros_ec_sensors_core.h
> > index ce16445411ac..4742a9637a85 100644
> > --- a/include/linux/iio/common/cros_ec_sensors_core.h
> > +++ b/include/linux/iio/common/cros_ec_sensors_core.h
> > @@ -78,6 +78,13 @@ struct cros_ec_sensors_core_state {
> > unsigned long scan_mask, s16
> > *data);
> >
> > int curr_sampl_freq;
> > +
> > + /* Min and Max Sampling Frequency in mHz */
> > + u32 min_freq;
> > + u32 max_freq;
> > +
> > + /* event fifo size represented in number of events */
> > + u32 fifo_max_event_count;
> > };
> >
> > /**
> > diff --git a/include/linux/mfd/cros_ec_commands.h
> > b/include/linux/mfd/cros_ec_commands.h
> > index dcec96f01879..27d71cbf22f1 100644
> > --- a/include/linux/mfd/cros_ec_commands.h
> > +++ b/include/linux/mfd/cros_ec_commands.h
> > @@ -1744,6 +1744,27 @@ struct ec_response_motion_sense {
> > uint8_t chip;
> > } info;
> >
> > + /* Used for MOTIONSENSE_CMD_INFO version 3 */
> > + struct __ec_todo_unpacked {
> > + /* Should be element of enum motionsensor_type.
> > */
> > + uint8_t type;
> > +
> > + /* Should be element of enum
> > motionsensor_location. */
> > + uint8_t location;
> > +
> > + /* Should be element of enum motionsensor_chip.
> > */
> > + uint8_t chip;
> > +
> > + /* Minimum sensor sampling frequency */
> > + uint32_t min_frequency;
> > +
> > + /* Maximum sensor sampling frequency */
> > + uint32_t max_frequency;
> > +
> > + /* Max number of sensor events that could be in
> > fifo */
> > + uint32_t fifo_max_event_count;
> > + } info_3;
> > +
> > /* Used for MOTIONSENSE_CMD_DATA */
> > struct ec_response_motion_sensor_data data;
> >
On Tue, 04 Jun 2019, Fabien Lahoudere wrote:
> Le lundi 03 juin 2019 à 13:55 +0100, Lee Jones a écrit :
> > On Wed, 22 May 2019, Fabien Lahoudere wrote:
> >
> > > Version 3 of the EC protocol provides min and max frequencies and
> > > fifo
> > > size for EC sensors.
> > >
> > > Signed-off-by: Fabien Lahoudere <[email protected]>
> > > ---
> > > .../cros_ec_sensors/cros_ec_sensors_core.c | 98
> > > ++++++++++++++++++-
> > > .../linux/iio/common/cros_ec_sensors_core.h | 7 ++
> > > include/linux/mfd/cros_ec_commands.h | 21 ++++
> >
> > Please note that we are about to add a pretty bit update for this
> > file. Once it's complete you may wish to rebase in order to avoid
> > any possible merge conflicts.
> >
>
> Thanks Lee. Indeed I see and reviewed this 30 patches series.
> I am waiting they are applied to rebase ans submit v3.
They are applied.
--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog