From: Daniel Bertalan <dani@danielbertalan.dev>
To: Mark Gross <markgross@kernel.org>,
Hans de Goede <hdegoede@redhat.com>,
Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: ibm-acpi-devel@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org, liavalb@gmail.com,
Daniel Bertalan <dani@danielbertalan.dev>
Subject: [PATCH] platform/x86: thinkpad_acpi: Fix Embedded Controller access on X380 Yoga
Date: Fri, 14 Apr 2023 18:02:10 +0000 [thread overview]
Message-ID: <20230414180034.63914-1-dani@danielbertalan.dev> (raw)
On the X380 Yoga, the `ECRD` and `ECWR` ACPI objects cannot be used for
accessing the Embedded Controller: instead of a method that reads from
the EC's memory, `ECRD` is the name of a location in high memory. This
meant that trying to call them would fail with the following message:
ACPI: \_SB.PCI0.LPCB.EC.ECRD: 1 arguments were passed to a non-method
ACPI object (RegionField)
With this commit, it is now possible to access the EC and read
temperature and fan speed information. Note that while writes to the
HFSP register do go through (as indicated by subsequent reads showing
the new value), the fan does not actually change its speed.
Signed-off-by: Daniel Bertalan <dani@danielbertalan.dev>
---
drivers/platform/x86/thinkpad_acpi.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 7191ff2625b1..6fe82f805ea8 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -11699,6 +11699,7 @@ static int __init thinkpad_acpi_module_init(void)
{
const struct dmi_system_id *dmi_id;
int ret, i;
+ acpi_object_type obj_type;
tpacpi_lifecycle = TPACPI_LIFE_INIT;
@@ -11724,6 +11725,21 @@ static int __init thinkpad_acpi_module_init(void)
TPACPI_ACPIHANDLE_INIT(ecrd);
TPACPI_ACPIHANDLE_INIT(ecwr);
+ /*
+ * Quirk: in some models (e.g. X380 Yoga), an object named ECRD
+ * exists, but it is a register, not a method.
+ */
+ if (ecrd_handle) {
+ acpi_get_type(ecrd_handle, &obj_type);
+ if (obj_type != ACPI_TYPE_METHOD)
+ ecrd_handle = NULL;
+ }
+ if (ecwr_handle) {
+ acpi_get_type(ecwr_handle, &obj_type);
+ if (obj_type != ACPI_TYPE_METHOD)
+ ecwr_handle = NULL;
+ }
+
tpacpi_wq = create_singlethread_workqueue(TPACPI_WORKQUEUE_NAME);
if (!tpacpi_wq) {
thinkpad_acpi_module_exit();
--
2.40.0
next reply other threads:[~2023-04-14 18:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 18:02 Daniel Bertalan [this message]
2023-04-15 10:12 ` [PATCH] platform/x86: thinkpad_acpi: Fix Embedded Controller access on X380 Yoga Hans de Goede
[not found] ` <a1229347-b5f3-8a1d-40a8-20beb863592a@gmail.com>
2023-04-15 13:30 ` Hans de Goede
2023-04-15 14:22 ` Daniel Bertalan
2023-04-17 10:19 ` Hans de Goede
2023-04-17 13:17 ` Mark Pearson
[not found] ` <TYZPR03MB59945171347BC248412EBEE6BD9D9@TYZPR03MB5994.apcprd03.prod.outlook.com>
2023-04-18 13:16 ` [ibm-acpi-devel] " Mark Pearson
2023-04-18 13:23 ` Hans de Goede
2023-04-18 14:17 ` Daniel Bertalan
2023-04-17 10:23 ` Hans de Goede
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=20230414180034.63914-1-dani@danielbertalan.dev \
--to=dani@danielbertalan.dev \
--cc=hdegoede@redhat.com \
--cc=hmh@hmh.eng.br \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=liavalb@gmail.com \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox