From patchwork Wed Jan 27 16:25:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Neumann X-Patchwork-Id: 12050549 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2297C433E0 for ; Wed, 27 Jan 2021 16:28:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D201207A0 for ; Wed, 27 Jan 2021 16:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343970AbhA0Q2y (ORCPT ); Wed, 27 Jan 2021 11:28:54 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:38999 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343771AbhA0Q2x (ORCPT ); Wed, 27 Jan 2021 11:28:53 -0500 Received: from envy.fritz.box ([82.207.222.125]) by mrelayeu.kundenserver.de (mreue010 [213.165.67.97]) with ESMTPSA (Nemesis) id 1Ml6Vg-1lpzxw0zBE-00lUNz; Wed, 27 Jan 2021 17:26:04 +0100 From: mail@richard-neumann.de To: nehal-bakulchandra.shah@amd.com, sandeep.singh@amd.com, mail@richard-neumann.de, jikos@kernel.org, benjamin.tissoires@redhat.com, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v2 1/3] Outsourced sensor masks to PCI driver header. Date: Wed, 27 Jan 2021 17:25:58 +0100 Message-Id: <20210127162600.35927-2-mail@richard-neumann.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127162600.35927-1-mail@richard-neumann.de> References: <20210127162600.35927-1-mail@richard-neumann.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:mFABr6ZjPwfKAm12WSrIGFP1FF7lE2KsykK9TtzaZdc6lsrfm9h PfwThXyLy5crws55dfhXAkgk/0ECkykqHG4ZaAKvq1k37I34DxQAx//v6CJMZjlp+kiqke9 MxosF1jOk5qbhoxY+4AjHbI30F1N+MbEVGckErquWCAQmOBqBFxmrsgsFjUdTcW/B0PTR0W EKb5c+FN1SXSbJXAsqvKw== X-UI-Out-Filterresults: notjunk:1;V03:K0:sh8ePC+axWs=:U/YfR4WCjWSbIelt4WeMRc ngqxx4aDOC3JP+HRLrxN6xE4nfVJZ/Uu3P8GfrS8wPodAjKJhrE2RZJHRSoSBfjhPisazzgCI TDs5fEBYug16jFXE60UXYX7jx2zrTsXgIheP3zELlnajyOzKKehvfXJP4ON13Qs8xbZE9L374 cQCqynh4CsZ1dtH55K8ux1FE43ejiMSZ2AfQqcxT6z6S7uGBUUZ5LS6HhNyI1CYo7Jn8GtXsn xOoSg/oEq4Q8Z5vj2zfXqlJarFhXLIDYg72V96YVP3xLwBW517tXrUBlTIRZEqswgjgvuqHeo 9msiwzbfPXaQ3+MBR4l+YAzO2ebDfLM16B6U97DK/ul9Ea7ja8qytJiTxPxe3Dxtczl9/fkVU EiJ25vdr+7mUrsD0LpOvRuD23W94r7iOoYvSgfM8k6QloOnmVOr+4KEa7GZINqVGYJlQ+56bh dUE15o63AA== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Richard Neumann Outsourced the mask definitions of the four sensors into the PCI device driver header file for later use with the quirks. Also renamed the values from *_EN to *_MASK to emphasize that they are actually sensor bitmasks for matching against activestatus. Signed-off-by: Richard Neumann --- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 13 ++++--------- drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index dbac16641662..4b0ceb2ee86a 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -20,11 +20,6 @@ #define DRIVER_NAME "pcie_mp2_amd" #define DRIVER_DESC "AMD(R) PCIe MP2 Communication Driver" -#define ACEL_EN BIT(0) -#define GYRO_EN BIT(1) -#define MAGNO_EN BIT(2) -#define ALS_EN BIT(19) - void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info) { union sfh_cmd_param cmd_param; @@ -79,16 +74,16 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id) privdata->activecontrolstatus = readl(privdata->mmio + AMD_P2C_MSG3); activestatus = privdata->activecontrolstatus >> 4; - if (ACEL_EN & activestatus) + if (ACCEL_MASK & activestatus) sensor_id[num_of_sensors++] = accel_idx; - if (GYRO_EN & activestatus) + if (GYRO_MASK & activestatus) sensor_id[num_of_sensors++] = gyro_idx; - if (MAGNO_EN & activestatus) + if (MAGNO_MASK & activestatus) sensor_id[num_of_sensors++] = mag_idx; - if (ALS_EN & activestatus) + if (ALS_MASK & activestatus) sensor_id[num_of_sensors++] = als_idx; return num_of_sensors; diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 8f8d19b2cfe5..a39f02352c3b 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -57,6 +57,20 @@ enum sensor_idx { als_idx = 19 }; +/** + * Bit masks for sensors matching. + * @ACCEL_MASK: Bit mask of the accelerometer + * @GYRO_MASK: Bit mask of the gyroscope + * @MAGNO_MASK: Bit mask of the magnetometer + * @ALS_MASK: Bit mask of the ambient light sensor + */ +enum sensor_mask { + ACCEL_MASK = BIT(accel_idx), + GYRO_MASK = BIT(gyro_idx), + MAGNO_MASK = BIT(mag_idx), + ALS_MASK = BIT(als_idx), +}; + struct amd_mp2_dev { struct pci_dev *pdev; struct amdtp_cl_data *cl_data; From patchwork Wed Jan 27 16:25:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Neumann X-Patchwork-Id: 12050551 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10A48C433E6 for ; Wed, 27 Jan 2021 16:29:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF513207A0 for ; Wed, 27 Jan 2021 16:29:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343985AbhA0Q3Z (ORCPT ); Wed, 27 Jan 2021 11:29:25 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:51887 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343951AbhA0Q2z (ORCPT ); Wed, 27 Jan 2021 11:28:55 -0500 Received: from envy.fritz.box ([82.207.222.125]) by mrelayeu.kundenserver.de (mreue010 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MhUQ7-1lZioA1xVj-00eZZg; Wed, 27 Jan 2021 17:26:05 +0100 From: mail@richard-neumann.de To: nehal-bakulchandra.shah@amd.com, sandeep.singh@amd.com, mail@richard-neumann.de, jikos@kernel.org, benjamin.tissoires@redhat.com, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v2 2/3] Added quirks to detect sensor masks. Date: Wed, 27 Jan 2021 17:25:59 +0100 Message-Id: <20210127162600.35927-3-mail@richard-neumann.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127162600.35927-1-mail@richard-neumann.de> References: <20210127162600.35927-1-mail@richard-neumann.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:i77Dblb1rJWZkYKPVIzK+zz5/InieoczpEDSLs+R4P1CAQFoInz DopZHX6m1dJv0m2JgkHwjG4ZKf1Z2CH3Et2pMrqwJKppLkBPFlVYgO84z3dhlKDF5QguYbj Yzfq4DQV+k+evsB6EfQ14fBtV10f4bAWKxJ0hkfqCsBQuRDX0+7G5l6a/1uQsPwUYYyQtbf W824MKryJ7RDMwz18wd8w== X-UI-Out-Filterresults: notjunk:1;V03:K0:vM3F1ZddobU=:CATCLo0WTokbnHfiwwVYGQ W9Pjd7R3niQtEVJnjX5emi9iYGKNC5tA6GtyzG96RGlukYrLHspZNsam0cqTR9zxLvk4Qyc8N H1E6PQCErzAgVv2WnW5aAHHzYavxUu+wltwfEo+EVfRdzGVNn+uve/9FK7xK6vUr9pE1rA8Ic DK5uUI9RVnyyNfN+Vf6pARuPW0dTkK1WFnDA5hS17hHJ0zYZGCX5cuzh2xEypHeyfFivpLZI9 bTFLmj17Qi+WbHJMADaLDKTuB6QFFJicIfs6mOnjxRdM1zVLVfOFXUG+PiaMJ3GpCNNeY+Qgz ZB4/aotBqYwvacBt5Tju7ZLtMGWyIjCDtJ+7L6X5VMSAEY+kVJodd8RWY3QghptWEFnP+IzpG +OnC9l6eD7ejDdrnSI7CfAP9oAHeZSA+RB8Na14OqKMhcxU7KMtTNwRoKiXgQSRkW5dfRsXg5 I5ju1JRokA== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Richard Neumann Added quirks file to determine the sensor masks for systems that do not have it stored in the corresponding P2C register. Values are based upon user reports from: https://bugzilla.kernel.org/show_bug.cgi?id=199715 Signed-off-by: Richard Neumann --- drivers/hid/amd-sfh-hid/Makefile | 1 + drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 3 ++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 + drivers/hid/amd-sfh-hid/amd_sfh_quirks.c | 55 ++++++++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_quirks.c diff --git a/drivers/hid/amd-sfh-hid/Makefile b/drivers/hid/amd-sfh-hid/Makefile index 35e704da5612..c94cf51c0af5 100644 --- a/drivers/hid/amd-sfh-hid/Makefile +++ b/drivers/hid/amd-sfh-hid/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_AMD_SFH_HID) += amd_sfh.o amd_sfh-objs := amd_sfh_hid.o amd_sfh-objs += amd_sfh_client.o amd_sfh-objs += amd_sfh_pcie.o +amd_sfh-objs += amd_sfh_quirks.o amd_sfh-objs += hid_descriptor/amd_sfh_hid_desc.o ccflags-y += -I $(srctree)/$(src)/ diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 4b0ceb2ee86a..8f10d6d6b369 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -74,6 +74,9 @@ int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id) privdata->activecontrolstatus = readl(privdata->mmio + AMD_P2C_MSG3); activestatus = privdata->activecontrolstatus >> 4; + if (!activestatus) + activestatus = amd_sfh_quirks_get_sensor_mask(privdata->pdev); + if (ACCEL_MASK & activestatus) sensor_id[num_of_sensors++] = accel_idx; diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index a39f02352c3b..64884e515895 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -90,4 +90,5 @@ void amd_stop_all_sensors(struct amd_mp2_dev *privdata); int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id); int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata); int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata); +int amd_sfh_quirks_get_sensor_mask(struct pci_dev *pci_dev); #endif diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_quirks.c b/drivers/hid/amd-sfh-hid/amd_sfh_quirks.c new file mode 100644 index 000000000000..a4f0366e7982 --- /dev/null +++ b/drivers/hid/amd-sfh-hid/amd_sfh_quirks.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* + * AMD Sensor Fusion Hub quirks + * + * Authors: Richard Neumann + */ + +#include +#include + +#include "amd_sfh_pcie.h" + +/** + * DMI match for HP ENVY x360 convertibles, which do not + * have information about the sensor mask in the P2C registers. + */ +static const struct dmi_system_id hp_envy_x360[] = { + { + .ident = "HP ENVY x360 Convertible 13-ag0xxx", + .matches = { + DMI_MATCH(DMI_PRODUCT_NAME, "HP"), + DMI_MATCH(DMI_BOARD_NAME, "8496"), + DMI_MATCH(DMI_BOARD_VERSION, "92.48"), + }, + }, + { + .ident = "HP ENVY x360 Convertible 15-cp0xxx", + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "HP"), + DMI_MATCH(DMI_BOARD_NAME, "8497"), + DMI_MATCH(DMI_BOARD_VERSION, "92.48"), + }, + }, + { } +}; + +/** + * Returns the sensor mask for hardware, on which the + * sensor mask is not written into the P2C registers. + * + * Returns an appropriate sensor mask or zero per default. + */ +int amd_sfh_quirks_get_sensor_mask(struct pci_dev *pci_dev) +{ + const struct dmi_system_id *system; + + system = dmi_first_match(hp_envy_x360); + if (system) { + pci_info(pci_dev, "Detected %s.\n", system->ident); + return ACCEL_MASK + MAGNO_MASK; + } + + pci_warn(pci_dev, "No quirks available for this hardware.\n"); + return 0; +} From patchwork Wed Jan 27 16:26:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Neumann X-Patchwork-Id: 12050553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16F06C433E9 for ; Wed, 27 Jan 2021 16:29:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8B07207A0 for ; Wed, 27 Jan 2021 16:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343686AbhA0Q3g (ORCPT ); Wed, 27 Jan 2021 11:29:36 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:52911 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343953AbhA0Q2z (ORCPT ); Wed, 27 Jan 2021 11:28:55 -0500 Received: from envy.fritz.box ([82.207.222.125]) by mrelayeu.kundenserver.de (mreue010 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MLzWL-1lMC4N2uMT-00HyRm; Wed, 27 Jan 2021 17:26:06 +0100 From: mail@richard-neumann.de To: nehal-bakulchandra.shah@amd.com, sandeep.singh@amd.com, mail@richard-neumann.de, jikos@kernel.org, benjamin.tissoires@redhat.com, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH v2 3/3] Updated MAINTAINERS Date: Wed, 27 Jan 2021 17:26:00 +0100 Message-Id: <20210127162600.35927-4-mail@richard-neumann.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127162600.35927-1-mail@richard-neumann.de> References: <20210127162600.35927-1-mail@richard-neumann.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:xJ1Sf5XKgUYAdsgkLIj4+KmeVkDv6QJ7cYbj41W7dEMUjJh6VYx TkQ4oPHh4vWLAhgpWHwFnTVXw67mAP3yXPygIWr76NBF5bqVBOFR66an1QmiOITIC5bwU12 9H4wbDHcNOMJ9ZmcJpqVAzM+Ui4phkN4BIxq58z5q4g2SDjVpfau0R1Oto866KQ0007GWQ1 yz9KrsLUJqu37k/eraE4Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:xIcAJy1itWc=:yq5/TTGMaYjr1ZLTOHaqES SZy2LdtLvkof84KecRMCzEzKSRJ4JM5MOIcRzGrS//uU7x8Z8xW9oK9OORVPnMl2G7fOzn/h2 jqi27hln7v0BthDXj+flfDIjhHffamvrQa2YEZ3V8zCuEsKjS1KyPYeBuTKWZ51FP6LUJdzEQ w4jLblONB0BZfaeu2rfwVUTtlVG67KL5tQsZciaEFQfn7s6EzB+ld2Ey+IBdVKYdROpxwIdCo WnS42dTOPZXbvHIdgVZGWG4q24V6oj5bGArjZnPyllEcFZAidRMXskpkE1roK5F5pNCjYTSif ToVFja0TYS34csEs5ln72/fzfUeC2RpMhPJF1+9rM8IPM6h2Dvb4FtuNuscWmjhHmnt84h2n3 cYQjLHYZrnYOxBxIb6MNb7iJ4XS9MdoRGAYeXqE8+7bLa20cWO5EYbX27QWhkuqapMHGiA+P3 AzPDo9R72w== Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Richard Neumann Added Richard Neumann (me) to the list of maintainers for the AMD Sensor Fusion Hub driver. Signed-off-by: Richard Neumann --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 992fe3b0900a..de28236a08fe 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -958,6 +958,7 @@ F: drivers/net/ethernet/amd/xgbe/ AMD SENSOR FUSION HUB DRIVER M: Nehal Shah M: Sandeep Singh +M: Richard Neumann L: linux-input@vger.kernel.org S: Maintained F: Documentation/hid/amd-sfh*