All of lore.kernel.org
 help / color / mirror / Atom feed
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	[thread overview]
Message-ID: <20210127162600.35927-3-mail@richard-neumann.de> (raw)
In-Reply-To: <20210127162600.35927-1-mail@richard-neumann.de>

From: Richard Neumann <mail@richard-neumann.de>

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 <mail@richard-neumann.de>
---
 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 <mail@richard-neumann.de>
+ */
+
+#include <linux/dmi.h>
+#include <linux/pci.h>
+
+#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;
+}
-- 
2.30.0


  parent reply	other threads:[~2021-01-27 16:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 16:25 [PATCH v2 0/3] Add quirks to AMD Sensor Fusion Hub driver mail
2021-01-27 16:25 ` [PATCH v2 1/3] Outsourced sensor masks to PCI driver header mail
2021-01-27 16:25 ` mail [this message]
2021-01-27 16:26 ` [PATCH v2 3/3] Updated MAINTAINERS mail
2021-02-09  9:39 ` [PATCH v2 0/3] Add quirks to AMD Sensor Fusion Hub driver Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210127162600.35927-3-mail@richard-neumann.de \
    --to=mail@richard-neumann.de \
    --cc=arnd@arndb.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nehal-bakulchandra.shah@amd.com \
    --cc=sandeep.singh@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.