From patchwork Tue Dec 27 12:52:16 2016 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: 9489215 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 839FD60238 for ; Tue, 27 Dec 2016 12:52:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 734032015F for ; Tue, 27 Dec 2016 12:52:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64532209CD; Tue, 27 Dec 2016 12:52:44 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 B70202015F for ; Tue, 27 Dec 2016 12:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754805AbcL0Mwm (ORCPT ); Tue, 27 Dec 2016 07:52:42 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:36449 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752381AbcL0Mwk (ORCPT ); Tue, 27 Dec 2016 07:52:40 -0500 Received: by mail-wj0-f194.google.com with SMTP id j10so51456909wjb.3; Tue, 27 Dec 2016 04:52:39 -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=rhlS8gqxRpUu0NGp+J+udAAAUuYxKBn27DNO7llJXkw=; b=PMkWP3qlFNPtNXL5quItsIy7sX91Lp7uYmUbjwxWwarfEo3pu8aTr/e+tHIlWtD1xB ZCO9MFUwd+S8IxwOUXeiseAeMBR/ohml/EyHKdaDXy8xKsIMyflsMFPKRxKrAyOar+Gx M222AxVAEG7B3Cl+fSPEEwd4AsJ0hUg87tZOtKD9y3E6wBfD75EQY65/eoXKmz1yXeIk ogFn1tNbniJviarTr8xxgjwHypSVOccJkPzasn+bD2wlqFcg2XipACTIQJxGYY3vvVEB EBZlVW2UHdL0H/Q432DhnTkYT2qVsJmcEJr1pjN/BbtX5SeSIKcre0GvyBFXdApZ+xKj bahA== 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=rhlS8gqxRpUu0NGp+J+udAAAUuYxKBn27DNO7llJXkw=; b=f/IXlsgtvEpT4puXq8uHihU1Iy19wJaXvQRXHuCs89476x2qD5hGihtS/gQjAkkBVZ 8bjuKQAR4+WxWJMMCK8CHhh0lmw+x7fQS5Tx7p0gx+0lYAPUWG1p2bCYL85jUwD+yO7h 3bFD3kSiIgGk9FfFINjMRk63OrySX/MrzsGY+ReDt+Yg05MLZuwNnCgvVcgiUAE8jqbd tti8sES2YIywjkCI4y57SxAzGaPOMjmxMYhfbFiuaUdk2OhRG1hx2vDH1IZsm1ts3v8w YFcn4CcA4qXNW7GGoDKICc+IhvBuntLTHSds4aR3CKnvCoVpg6JBACMNEOFmztTyIle9 2NGQ== X-Gm-Message-State: AIkVDXKy3b+x8yWOW7E6x3V+qRAcLcXacVl3GDWOZLbLyd4CT6uBTZSx2XNXtVu83ipcQQ== X-Received: by 10.194.221.4 with SMTP id qa4mr33448401wjc.179.1482843158654; Tue, 27 Dec 2016 04:52:38 -0800 (PST) Received: from localhost.localdomain (ip-88-212-34-237.antik.sk. [88.212.34.237]) by smtp.gmail.com with ESMTPSA id kq7sm59312352wjb.30.2016.12.27.04.52.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 04:52:37 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jean Delvare , Wolfram Sang , Steven Honeyman , Valdis.Kletnieks@vt.edu, Jochen Eisinger , Gabriele Mazzotta , Andy Lutomirski , Mario_Limonciello@dell.com, Alex Hung , =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= , 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] i2c: i801: Register optional lis3lv02d i2c device on Dell machines Date: Tue, 27 Dec 2016 13:52:16 +0100 Message-Id: <1482843136-12838-1-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 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. That i2c address is not specified in DMI or ACPI, so runtime detection without whitelist which is below is not possible. Presence of that ST microelectronics accelerometer is verified by existence of SMO88xx ACPI device which represent that accelerometer. Unfortunately without i2c address. This patch registers lis3lv02d device at i2c address 0x29 if is 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 --- drivers/i2c/busses/i2c-i801.c | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index eb3627f..188cfd4 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -1118,6 +1118,101 @@ 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 if ACPI device SMO88xx exists and if is enabled. That ACPI + * device represent our ST microelectronics lis3lv02d accelerometer but + * unfortunately without any other additional information. + */ + found = false; + status = acpi_get_devices(NULL, check_acpi_smo88xx_device, NULL, + (void **)&found); + if (!ACPI_SUCCESS(status) || !found) + return false; + + return true; +} + +/* + * Dell platform team told us that these Latitude devices have + * ST microelectronics accelerometer at i2c address 0x29. + * That i2c address is not specified in DMI or ACPI, so runtime + * detection without whitelist which is below is not possible. + */ +static const char * const dmi_dell_product_names[] = { + "Latitude E5250", + "Latitude E5450", + "Latitude E5550", + "Latitude E6440", + "Latitude E6440 ATG", + "Latitude E6540", +}; + +static void register_dell_lis3lv02d_i2c_device(struct i801_priv *priv) +{ + struct i2c_board_info info; + const char *product_name; + bool known_i2c_address; + int i; + + known_i2c_address = false; + product_name = dmi_get_system_info(DMI_PRODUCT_NAME); + for (i = 0; i < ARRAY_SIZE(dmi_dell_product_names); ++i) { + if (strcmp(product_name, dmi_dell_product_names[i]) == 0) { + known_i2c_address = true; + break; + } + } + + if (!known_i2c_address) { + dev_warn(&priv->pci_dev->dev, + "Accelerometer lis3lv02d i2c device is present " + "but its i2c address is unknown, skipping ...\n"); + return; + } + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = 0x29; + 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) { @@ -1136,6 +1231,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) {}