1 // SPDX-License-Identifier: GPL-2.0
3 * cros_ec_sensors_core - Common function for Chrome OS EC sensor driver.
5 * Copyright (C) 2016 Google, Inc
8 #include <linux/delay.h>
9 #include <linux/device.h>
10 #include <linux/iio/buffer.h>
11 #include <linux/iio/common/cros_ec_sensors_core.h>
12 #include <linux/iio/iio.h>
13 #include <linux/iio/kfifo_buf.h>
14 #include <linux/iio/sysfs.h>
15 #include <linux/iio/trigger.h>
16 #include <linux/iio/trigger_consumer.h>
17 #include <linux/iio/triggered_buffer.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/slab.h>
21 #include <linux/platform_data/cros_ec_commands.h>
22 #include <linux/platform_data/cros_ec_proto.h>
23 #include <linux/platform_data/cros_ec_sensorhub.h>
24 #include <linux/platform_device.h>
27 * Hard coded to the first device to support sensor fifo. The EC has a 2048
28 * byte fifo and will trigger an interrupt when fifo is 2/3 full.
30 #define CROS_EC_FIFO_SIZE (2048 * 2 / 3)
32 static char *cros_ec_loc[] = {
33 [MOTIONSENSE_LOC_BASE] = "base",
34 [MOTIONSENSE_LOC_LID] = "lid",
35 [MOTIONSENSE_LOC_MAX] = "unknown",
38 static int cros_ec_get_host_cmd_version_mask(struct cros_ec_device *ec_dev,
39 u16 cmd_offset, u16 cmd, u32 *mask)
43 struct cros_ec_command msg;
45 struct ec_params_get_cmd_versions params;
46 struct ec_response_get_cmd_versions resp;
50 .command = EC_CMD_GET_CMD_VERSIONS + cmd_offset,
51 .insize = sizeof(struct ec_response_get_cmd_versions),
52 .outsize = sizeof(struct ec_params_get_cmd_versions)
54 .params = {.cmd = cmd}
57 ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg);
59 *mask = buf.resp.version_mask;
63 static void get_default_min_max_freq(enum motionsensor_type type,
69 * We don't know fifo size, set to size previously used by older
72 *max_fifo_events = CROS_EC_FIFO_SIZE;
75 case MOTIONSENSE_TYPE_ACCEL:
79 case MOTIONSENSE_TYPE_GYRO:
83 case MOTIONSENSE_TYPE_MAG:
87 case MOTIONSENSE_TYPE_PROX:
88 case MOTIONSENSE_TYPE_LIGHT:
92 case MOTIONSENSE_TYPE_BARO:
96 case MOTIONSENSE_TYPE_ACTIVITY:
104 static int cros_ec_sensor_set_ec_rate(struct cros_ec_sensors_core_state *st,
112 mutex_lock(&st->cmd_lock);
113 st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
114 st->param.ec_rate.data = rate;
115 ret = cros_ec_motion_send_host_cmd(st, 0);
116 mutex_unlock(&st->cmd_lock);
120 static ssize_t cros_ec_sensor_set_report_latency(struct device *dev,
121 struct device_attribute *attr,
122 const char *buf, size_t len)
124 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
125 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
126 int integer, fract, ret;
129 ret = iio_str_to_fixpoint(buf, 100000, &integer, &fract);
133 /* EC rate is in ms. */
134 latency = integer * 1000 + fract / 1000;
135 ret = cros_ec_sensor_set_ec_rate(st, latency);
142 static ssize_t cros_ec_sensor_get_report_latency(struct device *dev,
143 struct device_attribute *attr,
146 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
147 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
150 mutex_lock(&st->cmd_lock);
151 st->param.cmd = MOTIONSENSE_CMD_EC_RATE;
152 st->param.ec_rate.data = EC_MOTION_SENSE_NO_VALUE;
154 ret = cros_ec_motion_send_host_cmd(st, 0);
155 latency = st->resp->ec_rate.ret;
156 mutex_unlock(&st->cmd_lock);
160 return sprintf(buf, "%d.%06u\n",
162 (latency % 1000) * 1000);
165 static IIO_DEVICE_ATTR(hwfifo_timeout, 0644,
166 cros_ec_sensor_get_report_latency,
167 cros_ec_sensor_set_report_latency, 0);
169 static ssize_t hwfifo_watermark_max_show(struct device *dev,
170 struct device_attribute *attr,
173 struct iio_dev *indio_dev = dev_to_iio_dev(dev);
174 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
176 return sprintf(buf, "%d\n", st->fifo_max_event_count);
179 static IIO_DEVICE_ATTR_RO(hwfifo_watermark_max, 0);
181 static const struct attribute *cros_ec_sensor_fifo_attributes[] = {
182 &iio_dev_attr_hwfifo_timeout.dev_attr.attr,
183 &iio_dev_attr_hwfifo_watermark_max.dev_attr.attr,
187 int cros_ec_sensors_push_data(struct iio_dev *indio_dev,
191 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
197 * Ignore samples if the buffer is not set: it is needed if the ODR is
198 * set but the buffer is not enabled yet.
200 if (!iio_buffer_enabled(indio_dev))
203 out = (s16 *)st->samples;
205 indio_dev->active_scan_mask,
206 indio_dev->masklength) {
211 if (iio_device_get_clock(indio_dev) != CLOCK_BOOTTIME)
212 delta = iio_get_time_ns(indio_dev) - cros_ec_get_time_ns();
216 iio_push_to_buffers_with_timestamp(indio_dev, st->samples,
221 EXPORT_SYMBOL_GPL(cros_ec_sensors_push_data);
223 static void cros_ec_sensors_core_clean(void *arg)
225 struct platform_device *pdev = (struct platform_device *)arg;
226 struct cros_ec_sensorhub *sensor_hub =
227 dev_get_drvdata(pdev->dev.parent);
228 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
229 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
230 u8 sensor_num = st->param.info.sensor_num;
232 cros_ec_sensorhub_unregister_push_data(sensor_hub, sensor_num);
236 * cros_ec_sensors_core_init() - basic initialization of the core structure
237 * @pdev: platform device created for the sensors
238 * @indio_dev: iio device structure of the device
239 * @physical_device: true if the device refers to a physical device
240 * @trigger_capture: function pointer to call buffer is triggered,
241 * for backward compatibility.
242 * @push_data: function to call when cros_ec_sensorhub receives
243 * a sample for that sensor.
245 * Return: 0 on success, -errno on failure.
247 int cros_ec_sensors_core_init(struct platform_device *pdev,
248 struct iio_dev *indio_dev,
249 bool physical_device,
250 cros_ec_sensors_capture_t trigger_capture,
251 cros_ec_sensorhub_push_data_cb_t push_data)
253 struct device *dev = &pdev->dev;
254 struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
255 struct cros_ec_sensorhub *sensor_hub = dev_get_drvdata(dev->parent);
256 struct cros_ec_dev *ec = sensor_hub->ec;
257 struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev);
259 int frequencies[ARRAY_SIZE(state->frequencies) / 2] = { 0 };
262 platform_set_drvdata(pdev, indio_dev);
264 state->ec = ec->ec_dev;
265 state->msg = devm_kzalloc(&pdev->dev,
266 max((u16)sizeof(struct ec_params_motion_sense),
267 state->ec->max_response), GFP_KERNEL);
271 state->resp = (struct ec_response_motion_sense *)state->msg->data;
273 mutex_init(&state->cmd_lock);
275 ret = cros_ec_get_host_cmd_version_mask(state->ec,
277 EC_CMD_MOTION_SENSE_CMD,
282 /* Set up the host command structure. */
283 state->msg->version = fls(ver_mask) - 1;
284 state->msg->command = EC_CMD_MOTION_SENSE_CMD + ec->cmd_offset;
285 state->msg->outsize = sizeof(struct ec_params_motion_sense);
287 indio_dev->name = pdev->name;
289 if (physical_device) {
290 state->param.cmd = MOTIONSENSE_CMD_INFO;
291 state->param.info.sensor_num = sensor_platform->sensor_num;
292 ret = cros_ec_motion_send_host_cmd(state, 0);
294 dev_warn(dev, "Can not access sensor info\n");
297 state->type = state->resp->info.type;
298 state->loc = state->resp->info.location;
300 /* Set sign vector, only used for backward compatibility. */
301 memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
303 for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
304 state->calib[i].scale = MOTION_SENSE_DEFAULT_SCALE;
306 /* 0 is a correct value used to stop the device */
307 if (state->msg->version < 3) {
308 get_default_min_max_freq(state->resp->info.type,
311 &state->fifo_max_event_count);
313 if (state->resp->info_3.max_frequency == 0) {
314 get_default_min_max_freq(state->resp->info.type,
319 frequencies[1] = state->resp->info_3.min_frequency;
320 frequencies[2] = state->resp->info_3.max_frequency;
322 state->fifo_max_event_count = state->resp->info_3.fifo_max_event_count;
324 for (i = 0; i < ARRAY_SIZE(frequencies); i++) {
325 state->frequencies[2 * i] = frequencies[i] / 1000;
326 state->frequencies[2 * i + 1] =
327 (frequencies[i] % 1000) * 1000;
330 if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) {
332 * Create a software buffer, feed by the EC FIFO.
333 * We can not use trigger here, as events are generated
334 * as soon as sample_frequency is set.
336 ret = devm_iio_kfifo_buffer_setup_ext(dev, indio_dev,
337 INDIO_BUFFER_SOFTWARE, NULL,
338 cros_ec_sensor_fifo_attributes);
342 ret = cros_ec_sensorhub_register_push_data(
343 sensor_hub, sensor_platform->sensor_num,
344 indio_dev, push_data);
348 ret = devm_add_action_or_reset(
349 dev, cros_ec_sensors_core_clean, pdev);
353 /* Timestamp coming from FIFO are in ns since boot. */
354 ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME);
360 * The only way to get samples in buffer is to set a
361 * software trigger (systrig, hrtimer).
363 ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
364 NULL, trigger_capture, NULL);
372 EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init);
375 * cros_ec_motion_send_host_cmd() - send motion sense host command
376 * @state: pointer to state information for device
377 * @opt_length: optional length to reduce the response size, useful on the data
378 * path. Otherwise, the maximal allowed response size is used
380 * When called, the sub-command is assumed to be set in param->cmd.
382 * Return: 0 on success, -errno on failure.
384 int cros_ec_motion_send_host_cmd(struct cros_ec_sensors_core_state *state,
390 state->msg->insize = min(opt_length, state->ec->max_response);
392 state->msg->insize = state->ec->max_response;
394 memcpy(state->msg->data, &state->param, sizeof(state->param));
396 ret = cros_ec_cmd_xfer_status(state->ec, state->msg);
401 state->resp != (struct ec_response_motion_sense *)state->msg->data)
402 memcpy(state->resp, state->msg->data, ret);
406 EXPORT_SYMBOL_GPL(cros_ec_motion_send_host_cmd);
408 static ssize_t cros_ec_sensors_calibrate(struct iio_dev *indio_dev,
409 uintptr_t private, const struct iio_chan_spec *chan,
410 const char *buf, size_t len)
412 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
416 ret = strtobool(buf, &calibrate);
422 mutex_lock(&st->cmd_lock);
423 st->param.cmd = MOTIONSENSE_CMD_PERFORM_CALIB;
424 ret = cros_ec_motion_send_host_cmd(st, 0);
426 dev_warn(&indio_dev->dev, "Unable to calibrate sensor\n");
429 for (i = CROS_EC_SENSOR_X; i < CROS_EC_SENSOR_MAX_AXIS; i++)
430 st->calib[i].offset = st->resp->perform_calib.offset[i];
432 mutex_unlock(&st->cmd_lock);
434 return ret ? ret : len;
437 static ssize_t cros_ec_sensors_id(struct iio_dev *indio_dev,
439 const struct iio_chan_spec *chan, char *buf)
441 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
443 return snprintf(buf, PAGE_SIZE, "%d\n", st->param.info.sensor_num);
446 static ssize_t cros_ec_sensors_loc(struct iio_dev *indio_dev,
447 uintptr_t private, const struct iio_chan_spec *chan,
450 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
452 return snprintf(buf, PAGE_SIZE, "%s\n", cros_ec_loc[st->loc]);
455 const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[] = {
458 .shared = IIO_SHARED_BY_ALL,
459 .write = cros_ec_sensors_calibrate
463 .shared = IIO_SHARED_BY_ALL,
464 .read = cros_ec_sensors_id
468 .shared = IIO_SHARED_BY_ALL,
469 .read = cros_ec_sensors_loc
473 EXPORT_SYMBOL_GPL(cros_ec_sensors_ext_info);
476 * cros_ec_sensors_idx_to_reg - convert index into offset in shared memory
477 * @st: pointer to state information for device
478 * @idx: sensor index (should be element of enum sensor_index)
480 * Return: address to read at
482 static unsigned int cros_ec_sensors_idx_to_reg(
483 struct cros_ec_sensors_core_state *st,
487 * When using LPC interface, only space for 2 Accel and one Gyro.
488 * First halfword of MOTIONSENSE_TYPE_ACCEL is used by angle.
490 if (st->type == MOTIONSENSE_TYPE_ACCEL)
491 return EC_MEMMAP_ACC_DATA + sizeof(u16) *
492 (1 + idx + st->param.info.sensor_num *
493 CROS_EC_SENSOR_MAX_AXIS);
495 return EC_MEMMAP_GYRO_DATA + sizeof(u16) * idx;
498 static int cros_ec_sensors_cmd_read_u8(struct cros_ec_device *ec,
499 unsigned int offset, u8 *dest)
501 return ec->cmd_readmem(ec, offset, 1, dest);
504 static int cros_ec_sensors_cmd_read_u16(struct cros_ec_device *ec,
505 unsigned int offset, u16 *dest)
508 int ret = ec->cmd_readmem(ec, offset, 2, &tmp);
511 *dest = le16_to_cpu(tmp);
517 * cros_ec_sensors_read_until_not_busy() - read until is not busy
519 * @st: pointer to state information for device
521 * Read from EC status byte until it reads not busy.
522 * Return: 8-bit status if ok, -errno on failure.
524 static int cros_ec_sensors_read_until_not_busy(
525 struct cros_ec_sensors_core_state *st)
527 struct cros_ec_device *ec = st->ec;
529 int ret, attempts = 0;
531 ret = cros_ec_sensors_cmd_read_u8(ec, EC_MEMMAP_ACC_STATUS, &status);
535 while (status & EC_MEMMAP_ACC_STATUS_BUSY_BIT) {
536 /* Give up after enough attempts, return error. */
537 if (attempts++ >= 50)
540 /* Small delay every so often. */
541 if (attempts % 5 == 0)
544 ret = cros_ec_sensors_cmd_read_u8(ec, EC_MEMMAP_ACC_STATUS,
554 * cros_ec_sensors_read_data_unsafe() - read acceleration data from EC shared memory
555 * @indio_dev: pointer to IIO device
556 * @scan_mask: bitmap of the sensor indices to scan
557 * @data: location to store data
559 * This is the unsafe function for reading the EC data. It does not guarantee
560 * that the EC will not modify the data as it is being read in.
562 * Return: 0 on success, -errno on failure.
564 static int cros_ec_sensors_read_data_unsafe(struct iio_dev *indio_dev,
565 unsigned long scan_mask, s16 *data)
567 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
568 struct cros_ec_device *ec = st->ec;
572 /* Read all sensors enabled in scan_mask. Each value is 2 bytes. */
573 for_each_set_bit(i, &scan_mask, indio_dev->masklength) {
574 ret = cros_ec_sensors_cmd_read_u16(ec,
575 cros_ec_sensors_idx_to_reg(st, i),
580 *data *= st->sign[i];
588 * cros_ec_sensors_read_lpc() - read acceleration data from EC shared memory.
589 * @indio_dev: pointer to IIO device.
590 * @scan_mask: bitmap of the sensor indices to scan.
591 * @data: location to store data.
593 * Note: this is the safe function for reading the EC data. It guarantees
594 * that the data sampled was not modified by the EC while being read.
596 * Return: 0 on success, -errno on failure.
598 int cros_ec_sensors_read_lpc(struct iio_dev *indio_dev,
599 unsigned long scan_mask, s16 *data)
601 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
602 struct cros_ec_device *ec = st->ec;
603 u8 samp_id = 0xff, status = 0;
604 int ret, attempts = 0;
607 * Continually read all data from EC until the status byte after
608 * all reads reflects that the EC is not busy and the sample id
609 * matches the sample id from before all reads. This guarantees
610 * that data read in was not modified by the EC while reading.
612 while ((status & (EC_MEMMAP_ACC_STATUS_BUSY_BIT |
613 EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK)) != samp_id) {
614 /* If we have tried to read too many times, return error. */
618 /* Read status byte until EC is not busy. */
619 ret = cros_ec_sensors_read_until_not_busy(st);
624 * Store the current sample id so that we can compare to the
625 * sample id after reading the data.
627 samp_id = ret & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK;
629 /* Read all EC data, format it, and store it into data. */
630 ret = cros_ec_sensors_read_data_unsafe(indio_dev, scan_mask,
635 /* Read status byte. */
636 ret = cros_ec_sensors_cmd_read_u8(ec, EC_MEMMAP_ACC_STATUS,
644 EXPORT_SYMBOL_GPL(cros_ec_sensors_read_lpc);
647 * cros_ec_sensors_read_cmd() - retrieve data using the EC command protocol
648 * @indio_dev: pointer to IIO device
649 * @scan_mask: bitmap of the sensor indices to scan
650 * @data: location to store data
652 * Return: 0 on success, -errno on failure.
654 int cros_ec_sensors_read_cmd(struct iio_dev *indio_dev,
655 unsigned long scan_mask, s16 *data)
657 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
661 /* Read all sensor data through a command. */
662 st->param.cmd = MOTIONSENSE_CMD_DATA;
663 ret = cros_ec_motion_send_host_cmd(st, sizeof(st->resp->data));
665 dev_warn(&indio_dev->dev, "Unable to read sensor data\n");
669 for_each_set_bit(i, &scan_mask, indio_dev->masklength) {
670 *data = st->resp->data.data[i];
676 EXPORT_SYMBOL_GPL(cros_ec_sensors_read_cmd);
679 * cros_ec_sensors_capture() - the trigger handler function
680 * @irq: the interrupt number.
681 * @p: a pointer to the poll function.
683 * On a trigger event occurring, if the pollfunc is attached then this
684 * handler is called as a threaded interrupt (and hence may sleep). It
685 * is responsible for grabbing data from the device and pushing it into
686 * the associated buffer.
688 * Return: IRQ_HANDLED
690 irqreturn_t cros_ec_sensors_capture(int irq, void *p)
692 struct iio_poll_func *pf = p;
693 struct iio_dev *indio_dev = pf->indio_dev;
694 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
697 mutex_lock(&st->cmd_lock);
699 /* Clear capture data. */
700 memset(st->samples, 0, indio_dev->scan_bytes);
702 /* Read data based on which channels are enabled in scan mask. */
703 ret = st->read_ec_sensors_data(indio_dev,
704 *(indio_dev->active_scan_mask),
709 iio_push_to_buffers_with_timestamp(indio_dev, st->samples,
710 iio_get_time_ns(indio_dev));
714 * Tell the core we are done with this trigger and ready for the
717 iio_trigger_notify_done(indio_dev->trig);
719 mutex_unlock(&st->cmd_lock);
723 EXPORT_SYMBOL_GPL(cros_ec_sensors_capture);
726 * cros_ec_sensors_core_read() - function to request a value from the sensor
727 * @st: pointer to state information for device
728 * @chan: channel specification structure table
729 * @val: will contain one element making up the returned value
730 * @val2: will contain another element making up the returned value
731 * @mask: specifies which values to be requested
733 * Return: the type of value returned by the device
735 int cros_ec_sensors_core_read(struct cros_ec_sensors_core_state *st,
736 struct iio_chan_spec const *chan,
737 int *val, int *val2, long mask)
742 case IIO_CHAN_INFO_SAMP_FREQ:
743 st->param.cmd = MOTIONSENSE_CMD_SENSOR_ODR;
744 st->param.sensor_odr.data =
745 EC_MOTION_SENSE_NO_VALUE;
747 ret = cros_ec_motion_send_host_cmd(st, 0);
751 frequency = st->resp->sensor_odr.ret;
752 *val = frequency / 1000;
753 *val2 = (frequency % 1000) * 1000;
754 ret = IIO_VAL_INT_PLUS_MICRO;
763 EXPORT_SYMBOL_GPL(cros_ec_sensors_core_read);
766 * cros_ec_sensors_core_read_avail() - get available values
767 * @indio_dev: pointer to state information for device
768 * @chan: channel specification structure table
769 * @vals: list of available values
770 * @type: type of data returned
771 * @length: number of data returned in the array
772 * @mask: specifies which values to be requested
774 * Return: an error code, IIO_AVAIL_RANGE or IIO_AVAIL_LIST
776 int cros_ec_sensors_core_read_avail(struct iio_dev *indio_dev,
777 struct iio_chan_spec const *chan,
783 struct cros_ec_sensors_core_state *state = iio_priv(indio_dev);
786 case IIO_CHAN_INFO_SAMP_FREQ:
787 *length = ARRAY_SIZE(state->frequencies);
788 *vals = (const int *)&state->frequencies;
789 *type = IIO_VAL_INT_PLUS_MICRO;
790 return IIO_AVAIL_LIST;
795 EXPORT_SYMBOL_GPL(cros_ec_sensors_core_read_avail);
798 * cros_ec_sensors_core_write() - function to write a value to the sensor
799 * @st: pointer to state information for device
800 * @chan: channel specification structure table
801 * @val: first part of value to write
802 * @val2: second part of value to write
803 * @mask: specifies which values to write
805 * Return: the type of value returned by the device
807 int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
808 struct iio_chan_spec const *chan,
809 int val, int val2, long mask)
814 case IIO_CHAN_INFO_SAMP_FREQ:
815 frequency = val * 1000 + val2 / 1000;
816 st->param.cmd = MOTIONSENSE_CMD_SENSOR_ODR;
817 st->param.sensor_odr.data = frequency;
819 /* Always roundup, so caller gets at least what it asks for. */
820 st->param.sensor_odr.roundup = 1;
822 ret = cros_ec_motion_send_host_cmd(st, 0);
830 EXPORT_SYMBOL_GPL(cros_ec_sensors_core_write);
832 static int __maybe_unused cros_ec_sensors_resume(struct device *dev)
834 struct iio_dev *indio_dev = dev_get_drvdata(dev);
835 struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
838 if (st->range_updated) {
839 mutex_lock(&st->cmd_lock);
840 st->param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE;
841 st->param.sensor_range.data = st->curr_range;
842 st->param.sensor_range.roundup = 1;
843 ret = cros_ec_motion_send_host_cmd(st, 0);
844 mutex_unlock(&st->cmd_lock);
849 SIMPLE_DEV_PM_OPS(cros_ec_sensors_pm_ops, NULL, cros_ec_sensors_resume);
850 EXPORT_SYMBOL_GPL(cros_ec_sensors_pm_ops);
852 MODULE_DESCRIPTION("ChromeOS EC sensor hub core functions");
853 MODULE_LICENSE("GPL v2");