summaryrefslogtreecommitdiff
path: root/drivers/platform
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-04-17 00:28:41 +0300
committerHans de Goede <hdegoede@redhat.com>2023-04-17 13:23:26 +0300
commite578c943e363ff47d08e7b4f5648f3da9db325d8 (patch)
tree1345bb68826f7e1dff3f42e1139d790a7984b465 /drivers/platform
parent1d3f7a31aa9671c43e03570edaebcd7e02751c15 (diff)
downloadlinux-e578c943e363ff47d08e7b4f5648f3da9db325d8.tar.xz
platform/x86: x86-android-tablets: Add accelerometer support for Yoga Tablet 2 1050/830 series
The Yoga Tablet 2 1050/830 series have a LSM303DA accelerometer + magnetometer (IMU), add this to the list of i2c_clients to instantiate on these models. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20230416212841.311152-4-hdegoede@redhat.com
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/x86-android-tablets/lenovo.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/platform/x86/x86-android-tablets/lenovo.c b/drivers/platform/x86/x86-android-tablets/lenovo.c
index cf1629970f98..65cfccaa2894 100644
--- a/drivers/platform/x86/x86-android-tablets/lenovo.c
+++ b/drivers/platform/x86/x86-android-tablets/lenovo.c
@@ -255,8 +255,19 @@ static struct x86_gpio_button lenovo_yoga_tab2_830_1050_lid = {
/* This gets filled by lenovo_yoga_tab2_830_1050_init() */
static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
-static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initconst = {
+static struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initdata = {
{
+ /*
+ * This must be the first entry because lenovo_yoga_tab2_830_1050_init()
+ * may update its swnode. LSM303DA accelerometer + magnetometer.
+ */
+ .board_info = {
+ .type = "lsm303d",
+ .addr = 0x1d,
+ .dev_name = "lsm303d",
+ },
+ .adapter_path = "\\_SB_.I2C5",
+ }, {
/* bq24292i battery charger */
.board_info = {
.type = "bq24190",
@@ -357,7 +368,24 @@ const struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initconst = {
* The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same
* mainboard, but the 830 uses a portrait LCD panel with a landscape touchscreen,
* requiring the touchscreen driver to adjust the touch-coords to match the LCD.
+ * And requiring the accelerometer to have a mount-matrix set to correct for
+ * the 90° rotation of the LCD vs the frame.
*/
+static const char * const lenovo_yoga_tab2_830_lms303d_mount_matrix[] = {
+ "0", "1", "0",
+ "-1", "0", "0",
+ "0", "0", "1"
+};
+
+static const struct property_entry lenovo_yoga_tab2_830_lms303d_props[] = {
+ PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", lenovo_yoga_tab2_830_lms303d_mount_matrix),
+ { }
+};
+
+static const struct software_node lenovo_yoga_tab2_830_lms303d_node = {
+ .properties = lenovo_yoga_tab2_830_lms303d_props,
+};
+
static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void)
{
struct gpio_desc *gpiod;
@@ -375,6 +403,8 @@ static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void)
pr_info("detected Lenovo Yoga Tablet 2 830F/L\n");
lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.swap_axes = true;
lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.flip_y = true;
+ lenovo_yoga_tab2_830_1050_i2c_clients[0].board_info.swnode =
+ &lenovo_yoga_tab2_830_lms303d_node;
}
return 0;