Skip to content

Commit e578c94

Browse files
committed
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
1 parent 1d3f7a3 commit e578c94

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

  • drivers/platform/x86/x86-android-tablets

drivers/platform/x86/x86-android-tablets/lenovo.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,19 @@ static struct x86_gpio_button lenovo_yoga_tab2_830_1050_lid = {
255255
/* This gets filled by lenovo_yoga_tab2_830_1050_init() */
256256
static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
257257

258-
static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initconst = {
258+
static struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initdata = {
259259
{
260+
/*
261+
* This must be the first entry because lenovo_yoga_tab2_830_1050_init()
262+
* may update its swnode. LSM303DA accelerometer + magnetometer.
263+
*/
264+
.board_info = {
265+
.type = "lsm303d",
266+
.addr = 0x1d,
267+
.dev_name = "lsm303d",
268+
},
269+
.adapter_path = "\\_SB_.I2C5",
270+
}, {
260271
/* bq24292i battery charger */
261272
.board_info = {
262273
.type = "bq24190",
@@ -357,7 +368,24 @@ const struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initconst = {
357368
* The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same
358369
* mainboard, but the 830 uses a portrait LCD panel with a landscape touchscreen,
359370
* requiring the touchscreen driver to adjust the touch-coords to match the LCD.
371+
* And requiring the accelerometer to have a mount-matrix set to correct for
372+
* the 90° rotation of the LCD vs the frame.
360373
*/
374+
static const char * const lenovo_yoga_tab2_830_lms303d_mount_matrix[] = {
375+
"0", "1", "0",
376+
"-1", "0", "0",
377+
"0", "0", "1"
378+
};
379+
380+
static const struct property_entry lenovo_yoga_tab2_830_lms303d_props[] = {
381+
PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", lenovo_yoga_tab2_830_lms303d_mount_matrix),
382+
{ }
383+
};
384+
385+
static const struct software_node lenovo_yoga_tab2_830_lms303d_node = {
386+
.properties = lenovo_yoga_tab2_830_lms303d_props,
387+
};
388+
361389
static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void)
362390
{
363391
struct gpio_desc *gpiod;
@@ -375,6 +403,8 @@ static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void)
375403
pr_info("detected Lenovo Yoga Tablet 2 830F/L\n");
376404
lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.swap_axes = true;
377405
lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.flip_y = true;
406+
lenovo_yoga_tab2_830_1050_i2c_clients[0].board_info.swnode =
407+
&lenovo_yoga_tab2_830_lms303d_node;
378408
}
379409

380410
return 0;

0 commit comments

Comments
 (0)