From patchwork Wed Apr 12 22:36:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marius Hoch X-Patchwork-Id: 13209594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE8E0C77B6C for ; Wed, 12 Apr 2023 22:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229817AbjDLWhH (ORCPT ); Wed, 12 Apr 2023 18:37:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbjDLWhF (ORCPT ); Wed, 12 Apr 2023 18:37:05 -0400 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4223240D3; Wed, 12 Apr 2023 15:37:04 -0700 (PDT) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Pxcyj2rNyz9t4f; Thu, 13 Apr 2023 00:37:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mariushoch.de; s=MBO0001; t=1681339021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OflZ1RQRYS0/eVL+f/CPrQlcwSt09TX0tGm9J6rHhqk=; b=h7qusGoSLdrfx8DItFUEDDNlXRyLftV+S9hq0L+tIawAReu0zJGwhAuxTnK9qC8Ir1w22M poNzRhHXvzGM8BKVp1ivP60gMtW6lWSytoF46eTMqwcTcmNMQHW5k2LpXfvWBs/DeCtJM4 sS9TlJGs5sovibQZXCJcP8hKqoYqKGzm0zJXfBhADBWRoOAvo+djKOjl9YczosAHglSQ3f dXSP3sdDFg70jn3VGWYoSoSQdCRtETcOyznDDiCj4fr6BBGetk7/ssGYZLFSClmz1kEN11 KiUxy87NjPJSPJo2E0plFHdCBBg//6Tg64i/6n2j974KKvV3X2Y9+On5WECCwg== From: mail@mariushoch.de To: Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Hans de Goede , Marius Hoch Subject: [PATCH] iio: st_sensors: Add ACPI support for lsm303d to the LSM9DS0 IMU driver Date: Thu, 13 Apr 2023 00:36:25 +0200 Message-Id: <20230412223627.442963-5-mail@mariushoch.de> In-Reply-To: <20230412223627.442963-1-mail@mariushoch.de> References: <20230412223627.442963-1-mail@mariushoch.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4Pxcyj2rNyz9t4f Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Marius Hoch The lsm303d can be found as ACCL0001 on various Lenovo devices, including the Lenovo Yoga Tablet 2 1051-F, where I tested this patch. Signed-off-by: Marius Hoch --- drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 10 ++++++++++ drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c index 64fa77d302e2..79be8d28d965 100644 --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -37,6 +38,14 @@ static const struct i2c_device_id st_lsm9ds0_id_table[] = { }; MODULE_DEVICE_TABLE(i2c, st_lsm9ds0_id_table); +#ifdef CONFIG_ACPI +static const struct acpi_device_id st_lsm9ds0_acpi_match[] = { + {"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match); +#endif + static const struct regmap_config st_lsm9ds0_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -73,6 +82,7 @@ static struct i2c_driver st_lsm9ds0_driver = { .driver = { .name = "st-lsm9ds0-i2c", .of_match_table = st_lsm9ds0_of_match, + .acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match), }, .probe_new = st_lsm9ds0_i2c_probe, .id_table = st_lsm9ds0_id_table, diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c index 997b5ff792be..27c5d99ce0e3 100644 --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -37,6 +38,14 @@ static const struct spi_device_id st_lsm9ds0_id_table[] = { }; MODULE_DEVICE_TABLE(spi, st_lsm9ds0_id_table); +#ifdef CONFIG_ACPI +static const struct acpi_device_id st_lsm9ds0_acpi_match[] = { + {"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match); +#endif + static const struct regmap_config st_lsm9ds0_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -72,6 +81,7 @@ static struct spi_driver st_lsm9ds0_driver = { .driver = { .name = "st-lsm9ds0-spi", .of_match_table = st_lsm9ds0_of_match, + .acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match), }, .probe = st_lsm9ds0_spi_probe, .id_table = st_lsm9ds0_id_table,