From patchwork Wed Jan 27 15:35:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Neumann X-Patchwork-Id: 371913 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 28C70C433E0 for ; Wed, 27 Jan 2021 15:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5D2C207C4 for ; Wed, 27 Jan 2021 15:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236198AbhA0PnA (ORCPT ); Wed, 27 Jan 2021 10:43:00 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:51341 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236389AbhA0Pid (ORCPT ); Wed, 27 Jan 2021 10:38:33 -0500 Received: from envy.fritz.box ([82.207.222.125]) by mrelayeu.kundenserver.de (mreue012 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MNfgZ-1lKXcg2plz-00P1ta; Wed, 27 Jan 2021 16:35:37 +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 v1 1/3] Outsourced sensor masks to PCI driver header. Date: Wed, 27 Jan 2021 16:35:31 +0100 Message-Id: <20210127153533.21560-2-mail@richard-neumann.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127153533.21560-1-mail@richard-neumann.de> References: <20210127153533.21560-1-mail@richard-neumann.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:S0VWvSaZeX/9QNXkqFPXc+YHIO27cHQ4V+xApgEi7fuq1fvTnV8 cIr9OrG5oEu229hdQZ/NqAIMI2T3ceWj1VHYPyqRF+MVV3PRsMLwdfI377dmedZwZJsungY gXaXj09XapKra/9t57FXntqiyvGh9/1rVnldZvIjTfoQzsqq6wuUjapvpJxBTpn+2BSaWr/ wERakmTBPC9eP2q2F+tTQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:t9RraiFcYrk=:0KkyimE1B5yi4UtgIMfJv9 /Zf/bFlbXMj5It5rev+HxK+a7SiaX+SR2ljpUVr2jA3B7/aD95R1EK8G4ibXcGZYKV7f5iNmC pqqy64IN391+xyIU+bgCEMStpBemr3RO7UiXB/cupVhJxUo5Akz07GHpVCMGXs9PM035ICCWp y5XTUM6oVyTt+u+2IMS+Lw/NnuAQkBFPb8cWqi/B3qCQnGe/r/HLGqpoctiJo0OqmxaO81m+O 193JQy081xE9Bn5ElddlEqmX7NT4O/00wqPosTW0JDmiew+jbAvJvu4EBOVU0Wzikf6ztLtWt qWZ24dEY2HPyotnyp9dlJvy59Wu17cTbL1MItlcfcQImmTkkgmmY1MdlRPBnH8bUYKZ6FCO4l FbNiHOpiC+bS1ujRnipmvA5A5qz9s79Gi+QBVLedMTSzXCuB//Ycm6CAre4u1nyp3De+lqmB6 AqkoAAdP7A== 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 15:35:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Neumann X-Patchwork-Id: 371912 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 AAC04C433DB for ; Wed, 27 Jan 2021 15:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BAB6207B7 for ; Wed, 27 Jan 2021 15:44:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235799AbhA0Pn2 (ORCPT ); Wed, 27 Jan 2021 10:43:28 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:48113 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234675AbhA0Pic (ORCPT ); Wed, 27 Jan 2021 10:38:32 -0500 Received: from envy.fritz.box ([82.207.222.125]) by mrelayeu.kundenserver.de (mreue012 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MjPYI-1lpQPo076Q-00l0mR; Wed, 27 Jan 2021 16:35:38 +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 v1 2/3] Added quirks to detect sensor masks. Date: Wed, 27 Jan 2021 16:35:32 +0100 Message-Id: <20210127153533.21560-3-mail@richard-neumann.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127153533.21560-1-mail@richard-neumann.de> References: <20210127153533.21560-1-mail@richard-neumann.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:kDvi8cjYfFSonZL1f0E7lkaDzh+WkzhFHV+zDiQbU356ECP22bq ZyjuSDaOgZlyf5r2UqLeSHzhVR04vUSAaDM2FJzxiA1gW8pRnL/krscnmxuig+VyXskm08/ L4RKF44Rj2kRSdHMAiuEaWq6casijq2tdoISB6PwSjj2i64k0vMrvPnB5oRbjGSRzjA1Y+b Zcw6ZR968AJaqVyxOx5hA== X-UI-Out-Filterresults: notjunk:1; V03:K0:D4tCNtou888=:CtRCdiSo15DT2HO/hl207b qxh8pcRc0BMcVwHx91cTPuzKisdsKwHREikzTmdxaBUaMMJwJyL7R/jMwFcbiMuRmf+TQET90 FPMGgTvA2cwMV6uh0kDPZZ/ylThBkTpuiE4XGjof1V5z5dLDqv9YnM/cSa0/x7w9InAuK1JoK sZXnDMHztzg8bXR7BTIFCVveNde0NbV2zyLxDvk+Hj7tgdXJIX4e6SDiId/FbXQLIvw4qXHZp AMrsKBKWJ/E6yK5lkP6xNwse+dMmj+yf/d2Yynp9kWOX9VnUdCht/5qOKQ5/Haq94zWdouIc2 M/aLAovkBS19HLsd4PZnJt6iUhVfAjSJo6CuiIqJD/E/uIc3eZvSPf2y/yyVgnp2y4kn8iI1+ dnPhbI3IwzAhjXNy8FxObTI37H5VQZBOBiCt9/oM7pG3ZkkVgXWOs2Adx3C6SA+ZBPQra7n1w wsBmr+lCJQ== 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/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 ++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_quirks.c 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..3f6c81d8f555 --- /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) +{ + 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 15:35:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Neumann X-Patchwork-Id: 372903 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=unavailable 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 7B2F2C433E9 for ; Wed, 27 Jan 2021 15:43:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E736207E2 for ; Wed, 27 Jan 2021 15:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236032AbhA0Pm7 (ORCPT ); Wed, 27 Jan 2021 10:42:59 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:49311 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236084AbhA0Pid (ORCPT ); Wed, 27 Jan 2021 10:38:33 -0500 Received: from envy.fritz.box ([82.207.222.125]) by mrelayeu.kundenserver.de (mreue012 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MJFpj-1lOvKr1GXL-00KeAs; Wed, 27 Jan 2021 16:35:38 +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 v1 3/3] Updated MAINTAINERS Date: Wed, 27 Jan 2021 16:35:33 +0100 Message-Id: <20210127153533.21560-4-mail@richard-neumann.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210127153533.21560-1-mail@richard-neumann.de> References: <20210127153533.21560-1-mail@richard-neumann.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:v7SOAhV0Vpk6JIWS/laQe2eWzMwhukhUpjk8MOQk7/B4ZqY5k9U HkOfX+rFzVeb58+XVWNydcnRpe0psFGNWzUxmN58d6r0Gjc6AGhmjzfSgtEac/+fMnnemTe bEEByXbMyJnEUJkepGYN9s88t8EpefzESPAZZ5h+tOx3mF6Z8hS0KORfNDtS8VWryexJ1Ea ZmzsT2ZUKynaLW7xG4DAw== X-UI-Out-Filterresults: notjunk:1; V03:K0:YJNFv3CjWMs=:Z3AY8H/yCRzA+IvVZGe/PU 3tGmC2qp9INaGDF1658mig3iTFLP+qC/hg2QKQUsevrAQ5f0ylw7FgPI2QZQICMZ6WAJ36Tx8 3h2Lh+FAiTmIIkjBf5BUhdeZ+lKgP8WMjpnorMHMKXjyp2K96jJZ4q0grgvXpuVWsHFycuT+W NYw8g5rRFG6DY0oUWinenrm7RB3+/vNrTS/s9eMpJHM2FsSSLucm8CKjhR2Oc1pRI+GPjdiPZ JhZG3aiEvzP5ofwTvZxWTT+tkYpvnZhLAAr9XsCv5yMSwQjuE+TW7ed9uajKxgvmKyVQRA3yc 4XkL47o1FqEkB1Vx79tMNNaJ5EhRm3ZJp2lqXQpwYt29Ugz5cthzCUGSHg9+9mLyzjvPtD3m+ KbmhTa4krVg4jvrytoQjg0WbDEgwmngQOx7DnqZvNwc1vkip/hwVnbx4FMwsPtln9pVaLrQPd q5y/ynfZiA== 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*