From patchwork Sat Jan 27 13:32:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 10187465 X-Patchwork-Delegate: andy.shevchenko@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C3ABC60383 for ; Sat, 27 Jan 2018 13:32:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A756A286CD for ; Sat, 27 Jan 2018 13:32:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B7D728BF6; Sat, 27 Jan 2018 13:32:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2647B286CD for ; Sat, 27 Jan 2018 13:32:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752715AbeA0Nc4 (ORCPT ); Sat, 27 Jan 2018 08:32:56 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55641 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752556AbeA0Ncz (ORCPT ); Sat, 27 Jan 2018 08:32:55 -0500 Received: by mail-wm0-f65.google.com with SMTP id 143so6114659wma.5; Sat, 27 Jan 2018 05:32:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kTE1/Lys+bwXfPDAu8jN6DmvPi0x2FcGRJFM1hJsF8Y=; b=cWypObR6l+GGB21AHHjgdUlt/QNRVLG+EcvVD5mKZm7DFEwHexJQjaDesJET6lt88+ 1WAI+R4IHcvlOO7CjKQKe36fnidT/lLVQTKKOnEkPN/0q2LYN2tqX2yCC2POAtmYxjWJ F1+hqsZMKoHX3FddadmAlPf1xl78MS5DAFku0cFSSPaX6Ncdog3HYVFWB0/v43Bte256 jkK62oTZBQHVJPYdCfcHNmibKL/QzbSuMsUnMxrjKbsUaJS3xEKfQOfcwcW99fmK0FjI 1YWU3FwrWAUFL0ag81rOo1setmME0I2exLy57BtkL9OHU/i1D9g0Tg/1kYWVPhk7EiRd twvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kTE1/Lys+bwXfPDAu8jN6DmvPi0x2FcGRJFM1hJsF8Y=; b=fgZKhatqT6KYzMMlApDbSEKV9Xx9EndFfDbnNKohItA6/PdsnBlxTj1zQOfQ6THndP lH1PQsiRHmmpgAnnIJXKDgZ8dBxuRbHW0mPqH/UyDqfUTd0rF9i8bWR1lbZFwb4dLJJP 3/03C+1loUodhnD2gjuQjnaOUzAgpnj3wS8kOE9G+Jeu+8J1a9AC+QQRyiHMaEOWUCTF O6PstbuaeQ8ro6WMqXlcErjWDunP9w6g3OvlZgrmq3br4bas1bSpnv/suUIXp+mDjY8c GBUVCEcdVAGoKGh+sZN6gTyTfqycAU3eixC+Vb1TDtysa6nNSDsOBYBXUqPuKHd3KiLC 6QJA== X-Gm-Message-State: AKwxyteg5zn2SkajtfMfgcgiD8uHQp7EmRrob/cKJEP4Pwvle9hRajMk akUpk6ByHy+Fkh2zNS3uxeQ= X-Google-Smtp-Source: AH8x225vJtwEKYZWtiXkcAwCJo1G0bUv/ysSSgJb2qD52Iz3/LzVKbHuzU/GMxedHhwLuUsh9cDQSA== X-Received: by 10.28.71.198 with SMTP id m67mr14676580wmi.40.1517059973479; Sat, 27 Jan 2018 05:32:53 -0800 (PST) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id j132sm5974118wmd.38.2018.01.27.05.32.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jan 2018 05:32:52 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jean Delvare , Wolfram Sang , =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= , Steven Honeyman , Valdis.Kletnieks@vt.edu, Jochen Eisinger , Gabriele Mazzotta , Andy Lutomirski , Mario_Limonciello@dell.com, Alex Hung , Takashi Iwai Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v2] i2c: i801: Register optional lis3lv02d i2c device on Dell machines Date: Sat, 27 Jan 2018 14:32:09 +0100 Message-Id: <20180127133209.28995-1-pali.rohar@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Dell platform team told us that some (DMI whitelisted) Dell Latitude machines have ST microelectronics accelerometer at i2c address 0x29. Presence of that ST microelectronics accelerometer is verified by existence of SMO88xx ACPI device which represent that accelerometer. Unfortunately ACPI device does not specify i2c address. This patch registers lis3lv02d device for selected Dell Latitude machines at i2c address 0x29 after detection. And for Dell Vostro V131 machine at i2c address 0x1d which was manually detected. Finally commit a7ae81952cda ("i2c: i801: Allow ACPI SystemIO OpRegion to conflict with PCI BAR") allowed to use i2c-i801 driver on Dell machines so lis3lv02d correctly initialize accelerometer. Tested on Dell Latitude E6440. Signed-off-by: Pali Rohár Tested-by: Michał Kępień --- Changes since v1: * Added Dell Vostro V131 based on Michał Kępień testing * Changed DMI product structure to include also i2c address I re-tested this patch against Debian's 4.9 kernel on E6440. --- drivers/i2c/busses/i2c-i801.c | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 8eac00efadc1..502678e8b8c0 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1136,6 +1136,107 @@ static void dmi_check_onboard_devices(const struct dmi_header *dm, void *adap) } } +static acpi_status check_acpi_smo88xx_device(acpi_handle obj_handle, + u32 nesting_level, + void *context, + void **return_value) +{ + struct acpi_device_info *info; + acpi_status status; + char *hid; + + status = acpi_get_object_info(obj_handle, &info); + if (!ACPI_SUCCESS(status) || !(info->valid & ACPI_VALID_HID)) + return AE_OK; + + hid = info->hardware_id.string; + if (!hid) + return AE_OK; + + if (strlen(hid) < 7) + return AE_OK; + + if (memcmp(hid, "SMO88", 5) != 0) + return AE_OK; + + *((bool *)return_value) = true; + return AE_CTRL_TERMINATE; +} + +static bool is_dell_system_with_lis3lv02d(void) +{ + bool found; + acpi_status status; + const char *vendor; + + vendor = dmi_get_system_info(DMI_SYS_VENDOR); + if (strcmp(vendor, "Dell Inc.") != 0) + return false; + + /* + * Check that ACPI device SMO88xx exists and is enabled. That ACPI + * device represent our ST microelectronics lis3lv02d accelerometer but + * unfortunately without any other information (like i2c address). + */ + found = false; + status = acpi_get_devices(NULL, check_acpi_smo88xx_device, NULL, + (void **)&found); + if (!ACPI_SUCCESS(status) || !found) + return false; + + return true; +} + +/* + * Accelerometer's i2c address is not specified in DMI nor ACPI, + * so it is needed to define mapping table based on DMI product names. + */ +static struct { + const char *dmi_product_name; + unsigned short i2c_addr; +} dell_lis3lv02d_devices[] = { + /* + * Dell platform team told us that these Latitude devices have + * ST microelectronics accelerometer at i2c address 0x29. + */ + { "Latitude E5250", 0x29 }, + { "Latitude E5450", 0x29 }, + { "Latitude E5550", 0x29 }, + { "Latitude E6440", 0x29 }, + { "Latitude E6440 ATG", 0x29 }, + { "Latitude E6540", 0x29 }, + /* + * Additional individual entries were added after verification. + */ + { "Vostro V131", 0x1d }, +}; + +static void register_dell_lis3lv02d_i2c_device(struct i801_priv *priv) +{ + struct i2c_board_info info; + const char *dmi_product_name; + int i; + + dmi_product_name = dmi_get_system_info(DMI_PRODUCT_NAME); + for (i = 0; i < ARRAY_SIZE(dell_lis3lv02d_devices); ++i) { + if (strcmp(dmi_product_name, + dell_lis3lv02d_devices[i].dmi_product_name) == 0) + break; + } + + if (i == ARRAY_SIZE(dell_lis3lv02d_devices)) { + dev_warn(&priv->pci_dev->dev, + "Accelerometer lis3lv02d is present on i2c bus but its" + " i2c address is unknown, skipping registration...\n"); + return; + } + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = dell_lis3lv02d_devices[i].i2c_addr; + strlcpy(info.type, "lis3lv02d", I2C_NAME_SIZE); + i2c_new_device(&priv->adapter, &info); +} + /* Register optional slaves */ static void i801_probe_optional_slaves(struct i801_priv *priv) { @@ -1154,6 +1255,9 @@ static void i801_probe_optional_slaves(struct i801_priv *priv) if (dmi_name_in_vendors("FUJITSU")) dmi_walk(dmi_check_onboard_devices, &priv->adapter); + + if (is_dell_system_with_lis3lv02d()) + register_dell_lis3lv02d_i2c_device(priv); } #else static void __init input_apanel_init(void) {}