Skip to contentSkip to conversation

Support accelerometers for veyron_minnie

PATCH Superseded Gwendal Grignou 2 participants 5 messages Jun 20, 2019 – Jun 21, 2019

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover Support accelerometers for veyron_minnie

veyron_minnie - ASUS Chromebook Flip C100PA - embedded controller controls two accelerometers, one in the lid, one in the base. However, the EC firmware does not follow the new interface that cros_ec_accel driver use.
Extend the legacy driver used on glimmer - Lenovo ThinkPad 11e Chromebook - to veyron_minnie.
veyron_minnie being ARM based, issue command over the I2C bus to the EC instead of relying on the shared registers over LPC.

Gwendal Grignou (2):
iio: cros_ec: Add sign vector in core for backward compatibility
iio: cros_ec : Extend legacy support to ARM device

 drivers/iio/accel/Kconfig                     |   4 +-
 drivers/iio/accel/cros_ec_accel_legacy.c      | 353 ++++--------------
 .../cros_ec_sensors/cros_ec_sensors_core.c    |   5 +-
 .../linux/iio/common/cros_ec_sensors_core.h   |   1 +
 4 files changed, 84 insertions(+), 279 deletions(-)
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
#1 lore raw

PATCH 1/2 iio: cros_ec: Add sign vector in core for backward compatibility

To allow cros_ec iio core library to be used with legacy device, add a vector to rotate sensor data if necessary: legacy devices are not reporting data in HTML5/Android sensor referential.

TEST=On veyron minnie, check chrome detect tablet mode and rotate screen in tablet mode.

---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 5 ++++-
 include/linux/iio/common/cros_ec_sensors_core.h           | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +4 -1
index 719a0df5aeeb..1b2e7a8242ad 100644
@@ -66,8 +66,10 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
 		}
 		state->type = state->resp->info.type;
 		state->loc = state->resp->info.location;
-	}
 
+		/* Set sign vector, only used for backward compatibility. */
+		memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
+	}
 	return 0;
 }
 EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init);
@@ -254,6 +256,7 @@ static int cros_ec_sensors_read_data_unsafe(struct iio_dev *indio_dev,
 		if (ret < 0)
 			return ret;
 
+		*data *= st->sign[i];
 		data++;
 	}
 
include/linux/iio/common/cros_ec_sensors_core.h +1 -0
index ce16445411ac..a1c85ad4df91 100644
@@ -71,6 +71,7 @@ struct cros_ec_sensors_core_state {
 	enum motionsensor_location loc;
 
 	s16 calib[CROS_EC_SENSOR_MAX_AXIS];
+	s8 sign[CROS_EC_SENSOR_MAX_AXIS];
 
 	u8 samples[CROS_EC_SAMPLE_SIZE];
 
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog
#2 lore raw

Re: [PATCH 1/2] iio: cros_ec: Add sign vector in core for backward compatibility

Hi,

Quoted 7 lines · Gwendal Grignou

To allow cros_ec iio core library to be used with legacy device, add a vector to rotate sensor data if necessary: legacy devices are not reporting data in HTML5/Android sensor referential.

TEST=On veyron minnie, check chrome detect tablet mode and rotate screen in tablet mode.

TEST= doesn't belong in an upstream patch.

Quoted 11 lines
---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 5 ++++-
 include/linux/iio/common/cros_ec_sensors_core.h           | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +0 -0
index 719a0df5aeeb..1b2e7a8242ad 100644

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c int cros_ec_sensors_core_init(struct platform_device *pdev, · line 73

Quoted 9 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +3 -1
@@ -66,8 +66,10 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
                }
                state->type = state->resp->info.type;
                state->loc = state->resp->info.location;
-       }
 
+               /* Set sign vector, only used for backward compatibility. */
+               memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
+       }
        return 0;

Normally there's a blank line before the "return". There was before your patch. Why did you remove it? It'll make your diff cleaner if you keep it.

Also, should you be basing your patch atop +Fabien's series? I notice you got a conflict when you picked this into the Chrome OS tree, but maybe you wouldn't have if you had based atop
<https://lore.kernel.org/patchwork/patch/1090463/> AKA
<https://lkml.kernel.org/r/ac3cdc104e59565d178dfa86f2727045224dc4da.1560848479.git.fabien.lahoudere@collabora.com>

-Doug

#3 lore raw

Re: [PATCH 1/2] iio: cros_ec: Add sign vector in core for backward compatibility

Quoted 31 lines · Doug Anderson

Hi,

Quoted 7 lines · Gwendal Grignou

To allow cros_ec iio core library to be used with legacy device, add a vector to rotate sensor data if necessary: legacy devices are not reporting data in HTML5/Android sensor referential.

TEST=On veyron minnie, check chrome detect tablet mode and rotate screen in tablet mode.

TEST= doesn't belong in an upstream patch.

Quoted 16 lines
---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 5 ++++-
 include/linux/iio/common/cros_ec_sensors_core.h           | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +0 -1
index 719a0df5aeeb..1b2e7a8242ad 100644
@@ -66,8 +66,10 @@ int cros_ec_sensors_core_init(struct platform_device *pdev,
                }
                state->type = state->resp->info.type;
                state->loc = state->resp->info.location;
-       }
 
Quoted 8 lines

drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c int cros_ec_sensors_core_init(struct platform_device *pdev, · line 73

Quoted 4 lines
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +3 -0
+               /* Set sign vector, only used for backward compatibility. */
+               memset(state->sign, 1, CROS_EC_SENSOR_MAX_AXIS);
+       }
        return 0;

Normally there's a blank line before the "return". There was before your patch. Why did you remove it? It'll make your diff cleaner if you keep it.

Will fix these issues in next patch.

Quoted 6 lines

Also, should you be basing your patch atop +Fabien's series? I notice you got a conflict when you picked this into the Chrome OS tree, but maybe you wouldn't have if you had based atop
<https://lore.kernel.org/patchwork/patch/1090463/> AKA
<https://lkml.kernel.org/r/ac3cdc104e59565d178dfa86f2727045224dc4da.1560848479.git.fabien.lahoudere@collabora.com>

I did not based on top of Fabien's patches because this change is orthogonal to Fabien's. Moreover a new set of patches is needed as the attributes added (min_freq, max_freq) do not match the current sysfs ABI.

Gwendal.

Quoted 3 lines

-Doug

#4 lore raw

PATCH 2/2 iio: cros_ec : Extend legacy support to ARM device

In reply to Gwendal Grignou

Add support to ARM based device, that lack LPC access code. Allow cros-ec-accel-legacy to use cros-ec-sensors-core, add specific command to capture sensor data.

TEST=On veyron minnie, check chrome detect tablet mode and rotate screen in tablet mode.
Same tests on glimmer.
Check only a subset of the attributes are presented.

---
 drivers/iio/accel/Kconfig                |   4 +-
 drivers/iio/accel/cros_ec_accel_legacy.c | 350 +++++------------------
 2 files changed, 79 insertions(+), 275 deletions(-)
drivers/iio/accel/Kconfig +1 -3
index 62a970a20219..7d0848f9ea45 100644
@@ -201,9 +201,7 @@ config HID_SENSOR_ACCEL_3D
 
 config IIO_CROS_EC_ACCEL_LEGACY
 	tristate "ChromeOS EC Legacy Accelerometer Sensor"
-	select IIO_BUFFER
-	select IIO_TRIGGERED_BUFFER
-	select CROS_EC_LPC_REGISTER_DEVICE
+	depends on IIO_CROS_EC_SENSORS_CORE
 	help
 	  Say yes here to get support for accelerometers on Chromebook using
 	  legacy EC firmware.
drivers/iio/accel/cros_ec_accel_legacy.c +78 -272

442 lines not on this page · raw message

Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog