Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v6 00/11] Cros EC sensor hub FIFO support
@ 2020-03-24 20:27 Gwendal Grignou
  2020-03-24 20:27 ` [PATCH v6 01/11] platform: chrome: sensorhub: Add " Gwendal Grignou
                   ` (11 more replies)
  0 siblings, 12 replies; 15+ messages in thread
From: Gwendal Grignou @ 2020-03-24 20:27 UTC (permalink / raw)
  To: bleung, enric.balletbo, Jonathan.Cameron
  Cc: linux-iio, linux-kernel, Gwendal Grignou

This patchset adds a sensorhub driver for spreading sensor
events coming from the Embedded controller sensor FIFO:

       +---------------+ +--------------+ +----
       | cros_ec_accel | | cros_ec_gyro | | ...
       +---------------+ +--------------+ +----
           id:0       \        id:1 |       / id:..
                 +------------------------------+
                 |       cros-ec-sensorhub      |
                 +------------------------------+
                 |           cros_ec_dev        |
                 +------------------------------+
                 | cros_ec_i2c, cros_ec_lpc, .. |
                 +------------------------------+
                                 |
                                 EC

When new sensors events are present, the EC raises and interrupt,
sensorhub reads the FIFO and uses the 'id' field to spread the event to
the proper IIO sensors. This stack is similar to the HID sensor input
stack.

The patch set allows the host to receive MEMS sensor sample
asynchronously from ChromeOS Emebedded Controller (EC).

Given the EC and the host are not synchronized, the timestamp generated
by the EC drifts and the AP interrupt latency adds variable delay.

When events arrive, the driver stores the time of the interrupt and use
that information to convert the timestamp from the EC time domain to the
AP time domain. To prevent the errors from the interrupt time variation,
a median filter smooth the timestamp generation and prevents timestamps
to go in the past.

When a batch of sensor events arrives, the sensor hub ring code spreads
the timestamps.

The buffer interaface is presentid through the IIO ABI.
And extra parameter - flush - (presents on HID and ST sensor hub
implementation) force the EC to send accumulated events in its queue,
without waiting for buffer hwfifo_timeout to expire.

To access sensor data, we can use iio_readdev like:
 iio_readdev -T 10000 -s 4 -b 2 iio:device4

When FIFO is not supported by the EC, a trigger is present in the
directory. After registering a trigger, setting sampling_frequency,
the latest data collected by the sensor will be retrieved by the host
when the trigger expires.

When cros_ec_accel_legacy driver is used, no FIFO is supported and the
sampling frequency for the accelerometers is hard coded at 10Hz.

Gwendal Grignou (11):
  platform: chrome: sensorhub: Add FIFO support
  platform: chrome: sensorhub: Add code to spread timestmap
  platform: chrome: sensorhub: Add median filter
  iio: cros_ec: Move function description to .c file
  iio: expose iio_device_set_clock
  iio: cros_ec: Register to cros_ec_sensorhub when EC supports FIFO
  iio: cros_ec: Remove pm function
  iio: cros_ec: Expose hwfifo_timeout
  iio: cros_ec: Report hwfifo_watermark_max
  iio: cros_ec: Use Hertz as unit for sampling frequency
  iio: cros_ec: flush as hwfifo attribute

 drivers/iio/accel/cros_ec_accel_legacy.c      |    8 +-
 .../cros_ec_sensors/cros_ec_lid_angle.c       |    3 +-
 .../common/cros_ec_sensors/cros_ec_sensors.c  |   13 +-
 .../cros_ec_sensors/cros_ec_sensors_core.c    |  404 +++++--
 drivers/iio/industrialio-core.c               |    8 +-
 drivers/iio/light/cros_ec_light_prox.c        |   15 +-
 drivers/iio/pressure/cros_ec_baro.c           |   14 +-
 drivers/platform/chrome/Makefile              |    4 +-
 drivers/platform/chrome/cros_ec_sensorhub.c   |  107 +-
 .../platform/chrome/cros_ec_sensorhub_ring.c  | 1002 +++++++++++++++++
 .../linux/iio/common/cros_ec_sensors_core.h   |  104 +-
 include/linux/iio/iio.h                       |    2 +
 .../linux/platform_data/cros_ec_sensorhub.h   |  166 +++
 13 files changed, 1612 insertions(+), 238 deletions(-)
 create mode 100644 drivers/platform/chrome/cros_ec_sensorhub_ring.c

-- 
2.25.1.696.g5e7596f4ac-goog


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, back to index

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 20:27 [PATCH v6 00/11] Cros EC sensor hub FIFO support Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 01/11] platform: chrome: sensorhub: Add " Gwendal Grignou
2020-03-25 16:28   ` Enric Balletbo i Serra
2020-03-26  8:56     ` Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 02/11] platform: chrome: sensorhub: Add code to spread timestmap Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 03/11] platform: chrome: sensorhub: Add median filter Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 04/11] iio: cros_ec: Move function description to .c file Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 05/11] iio: expose iio_device_set_clock Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 06/11] iio: cros_ec: Register to cros_ec_sensorhub when EC supports FIFO Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 07/11] iio: cros_ec: Remove pm function Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 08/11] iio: cros_ec: Expose hwfifo_timeout Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 09/11] iio: cros_ec: Report hwfifo_watermark_max Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 10/11] iio: cros_ec: Use Hertz as unit for sampling frequency Gwendal Grignou
2020-03-24 20:27 ` [PATCH v6 11/11] iio: cros_ec: flush as hwfifo attribute Gwendal Grignou
2020-03-25 15:59 ` [PATCH v6 00/11] Cros EC sensor hub FIFO support Andy Shevchenko

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git