From: Rithvik Rama <rithvik.rama@gmail.com>
To: rafael@kernel.org, lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Rithvik Rama <rithvik.rama@gmail.com>
Subject: [PATCH] ACPI/ADXL: Added function for ADXL DSM Function 3
Date: Sun, 31 Mar 2024 10:41:26 +0530 [thread overview]
Message-ID: <20240331051126.10024-1-rithvik.rama@gmail.com> (raw)
Current driver supports only Function Index 1 & 2 as mentioned in the
ACPI ADXL DSM Interface. Added a function for ACPI Function Index 3.
Signed-off-by: Rithvik Rama <rithvik.rama@gmail.com>
---
drivers/acpi/acpi_adxl.c | 54 +++++++++++++++++++++++++++++++++++++++-
include/linux/adxl.h | 1 +
2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/acpi_adxl.c b/drivers/acpi/acpi_adxl.c
index 13c8f7b50c46..5bf53662b737 100644
--- a/drivers/acpi/acpi_adxl.c
+++ b/drivers/acpi/acpi_adxl.c
@@ -14,6 +14,7 @@
#define ADXL_REVISION 0x1
#define ADXL_IDX_GET_ADDR_PARAMS 0x1
#define ADXL_IDX_FORWARD_TRANSLATE 0x2
+#define ADXL_IDX_REVERSE_TRANSLATE 0X3
#define ACPI_ADXL_PATH "\\_SB.ADXL"
/*
@@ -135,6 +136,56 @@ int adxl_decode(u64 addr, u64 component_values[])
}
EXPORT_SYMBOL_GPL(adxl_decode);
+/**
+ * adxl_reverse_decode - Ask BIOS to decode a memory address to system address
+ * @component_values: pointer to array of values for each component
+ * Returns 0 on success, negative error code otherwise
+ *
+ */
+
+int adxl_reverse_decode(u64 component_values[])
+{
+ union acpi_object *argv4, *results, *r;
+ int i, cnt;
+
+ argv4 = kzalloc((adxl_count+1)*sizeof(*argv4), GFP_KERNEL);
+ if (!argv4)
+ return -ENOMEM;
+
+ if (!adxl_component_names)
+ return -EOPNOTSUPP;
+
+ argv4[0].type = ACPI_TYPE_PACKAGE;
+ argv4[0].package.count = adxl_count;
+ argv4[0].package.elements = &argv4[1];
+
+ /*
+ * Loop through supported memory component values
+ */
+ for (i = 1; i <= adxl_count; i++) {
+ argv4[i].integer.type = ACPI_TYPE_INTEGER;
+ argv4[i].integer.value = component_values[i-1];
+ }
+
+ results = adxl_dsm(ADXL_IDX_REVERSE_TRANSLATE, argv4);
+ if (!results)
+ return -EINVAL;
+
+ r = results->package.elements + 1;
+ cnt = r->package.count;
+ if (cnt != adxl_count) {
+ ACPI_FREE(results);
+ return -EINVAL;
+ }
+ r = r->package.elements;
+ for (i = 0; i < cnt; i++)
+ component_values[i] = r[i].integer.value;
+
+ ACPI_FREE(results);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(adxl_reverse_decode);
+
static int __init adxl_init(void)
{
char *path = ACPI_ADXL_PATH;
@@ -155,7 +206,8 @@ static int __init adxl_init(void)
if (!acpi_check_dsm(handle, &adxl_guid, ADXL_REVISION,
ADXL_IDX_GET_ADDR_PARAMS |
- ADXL_IDX_FORWARD_TRANSLATE)) {
+ ADXL_IDX_FORWARD_TRANSLATE |
+ ADXL_IDX_REVERSE_TRANSLATE)) {
pr_info("DSM method does not support forward translate\n");
return -ENODEV;
}
diff --git a/include/linux/adxl.h b/include/linux/adxl.h
index 2a629acb4c3f..f3fea64a270c 100644
--- a/include/linux/adxl.h
+++ b/include/linux/adxl.h
@@ -9,5 +9,6 @@
const char * const *adxl_get_component_names(void);
int adxl_decode(u64 addr, u64 component_values[]);
+int adxl_reverse_decode(u64 component_values[]);
#endif /* _LINUX_ADXL_H */
--
2.34.1
next reply other threads:[~2024-03-31 5:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-31 5:11 Rithvik Rama [this message]
2024-04-26 17:25 ` [PATCH] ACPI/ADXL: Added function for ADXL DSM Function 3 Rafael J. Wysocki
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=20240331051126.10024-1-rithvik.rama@gmail.com \
--to=rithvik.rama@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).