Received: by 10.223.176.5 with SMTP id f5csp563991wra; Sat, 27 Jan 2018 05:33:40 -0800 (PST) X-Google-Smtp-Source: AH8x227VXWO4dlRHFl8zMXWGPxgVH72RqsJ3AcWhBmMK8mVgD8suflLNX6EaOJ+J7dT42mdn2WtB X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr16635110plp.254.1517060020566; Sat, 27 Jan 2018 05:33:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517060020; cv=none; d=google.com; s=arc-20160816; b=LRKzcDu6aw7O1enO8W7iha3Iq2ZXSANXvhKaitHIInQjMtiHtMUovDAyUjxbUPVXHS pNPj8xqyB+Ofzlyw49JBIA+NhXLWfq+nhvvYW8v5Tc0cDHbTW6361QiKekUOOSnUKJ3l ACYYsF2p8ZiS8+tIggvZpRElXQqfKi7mX2y3Pjtk9Rmx9bKMFlf/LihqAAVhiIDAm/ni CP17yhj5cI6JAOq1fzwlRrdpjPHG/mrnHkWZsFE2fH60lgiHjXeifkjqOxxEoGLsbA4i uTqflT8nX5xqUowAam8u+8837kIEqZ+ZEoxejG8QWBOywael+wLjT3dBBf7P+KjseUkc kaVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=kTE1/Lys+bwXfPDAu8jN6DmvPi0x2FcGRJFM1hJsF8Y=; b=RNzADFL2qwWANOLrnZlNqWt4D0Bt0Mz+rbz2Hj/SlLAoQ8XWVq8YiIRgMLeM/+7NJD SCQqU/EW8RZm2tKD1Es7pocmcJphhHWsOyeVI3XsWsdsj44rTH5gTilGHIOsxYZ3vpbQ MVBYl5kq09GiM+jpNRWfhk67zC/VNs3F8+1z6wFcHoWjE6x1+s19PekqZHHeN5jITgIN 6Rq1VW3xTNwAXAfnGWxHt+4z0VqDuzbhw1Kd66sTMJyFIbkKTJqC12LzBbwGsyW8q3Zg Vrm7JyHOGbirEsBrm+vFfG6jluAKiYjJexuCoH4Gi9yhnKVNXqt34lz9oD5hdQGq0ltC l4dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cWypObR6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63si4421121pgg.392.2018.01.27.05.33.24; Sat, 27 Jan 2018 05:33:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cWypObR6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbeA0Nc5 (ORCPT + 99 others); Sat, 27 Jan 2018 08:32:57 -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-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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) {} -- 2.11.0