From: Hans de Goede <hdegoede@redhat.com>
To: Mark Gross <markgross@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
Daniel Scally <djrscally@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
platform-driver-x86@vger.kernel.org,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Kate Hsuan <hpa@redhat.com>,
linux-media@vger.kernel.org
Subject: [PATCH 1/3] platform/x86: int3472/discrete: Refactor GPIO to sensor mapping
Date: Thu, 24 Nov 2022 21:00:05 +0100 [thread overview]
Message-ID: <20221124200007.390901-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20221124200007.390901-1-hdegoede@redhat.com>
Make the GPIO to sensor mapping more generic and fold the
INT3472_GPIO_TYPE_RESET and INT3472_GPIO_TYPE_POWERDOWN cases into
a single generic case.
This is a preparation patch for further GPIO mapping changes.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/intel/int3472/discrete.c | 31 ++++++++++++++-----
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index 974a132db651..bc6c62f3f3bf 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -184,6 +184,24 @@ static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
return 0;
}
+static const char *int3472_dsm_type_to_func(u8 type)
+{
+ switch (type) {
+ case INT3472_GPIO_TYPE_RESET:
+ return "reset";
+ case INT3472_GPIO_TYPE_POWERDOWN:
+ return "powerdown";
+ case INT3472_GPIO_TYPE_CLK_ENABLE:
+ return "clken";
+ case INT3472_GPIO_TYPE_PRIVACY_LED:
+ return "pled";
+ case INT3472_GPIO_TYPE_POWER_ENABLE:
+ return "power-enable";
+ }
+
+ return "unknown";
+}
+
/**
* skl_int3472_handle_gpio_resources: Map PMIC resources to consuming sensor
* @ares: A pointer to a &struct acpi_resource
@@ -223,6 +241,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
struct acpi_resource_gpio *agpio;
union acpi_object *obj;
const char *err_msg;
+ const char *func;
int ret;
u8 type;
@@ -246,19 +265,15 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
type = obj->integer.value & 0xff;
+ func = int3472_dsm_type_to_func(type);
+
switch (type) {
case INT3472_GPIO_TYPE_RESET:
- ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "reset",
- GPIO_ACTIVE_LOW);
- if (ret)
- err_msg = "Failed to map reset pin to sensor\n";
-
- break;
case INT3472_GPIO_TYPE_POWERDOWN:
- ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, "powerdown",
+ ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, func,
GPIO_ACTIVE_LOW);
if (ret)
- err_msg = "Failed to map powerdown pin to sensor\n";
+ err_msg = "Failed to map GPIO pin to sensor\n";
break;
case INT3472_GPIO_TYPE_CLK_ENABLE:
--
2.38.1
next prev parent reply other threads:[~2022-11-24 20:01 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-24 20:00 [PATCH 0/3] platform/x86: int3472/discrete: Make it work with IPU6 Hans de Goede
2022-11-24 20:00 ` Hans de Goede [this message]
2022-11-24 20:09 ` [PATCH 1/3] platform/x86: int3472/discrete: Refactor GPIO to sensor mapping Andy Shevchenko
2022-11-24 20:20 ` Hans de Goede
2022-11-24 22:19 ` Andy Shevchenko
2022-11-25 16:00 ` Dan Scally
2022-11-28 10:56 ` Hans de Goede
2022-11-24 20:00 ` [PATCH 2/3] platform/x86: int3472/discrete: Get the polarity from the _DSM entry Hans de Goede
2022-11-24 20:13 ` Andy Shevchenko
2022-11-24 20:26 ` Hans de Goede
2022-11-25 10:42 ` Dan Scally
2022-11-25 16:01 ` Dan Scally
2022-11-29 21:56 ` Hans de Goede
2022-11-24 20:00 ` [PATCH 3/3] platform/x86: int3472/discrete: Add support for sensor-drivers which expect clken + pled GPIOs Hans de Goede
2022-11-25 14:36 ` Laurent Pinchart
2022-11-25 16:07 ` Dan Scally
2022-11-25 18:38 ` Hans de Goede
2022-11-28 7:39 ` Dan Scally
2022-11-28 10:04 ` Hans de Goede
2022-11-25 10:17 ` [PATCH 0/3] platform/x86: int3472/discrete: Make it work with IPU6 Dan Scally
2022-11-25 10:58 ` Laurent Pinchart
2022-11-25 11:03 ` Dan Scally
2022-11-25 11:06 ` Andy Shevchenko
2022-11-25 11:11 ` Dan Scally
2022-11-25 11:23 ` Hans de Goede
2022-11-25 11:42 ` Dan Scally
2022-11-25 12:00 ` Hans de Goede
2022-11-25 11:15 ` Hans de Goede
2022-11-25 14:46 ` Laurent Pinchart
2022-11-28 16:11 ` Hans de Goede
2022-11-28 18:22 ` Laurent Pinchart
2022-11-25 11:02 ` Hans de Goede
2022-11-25 14:40 ` Laurent Pinchart
2022-11-28 11:28 ` 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=20221124200007.390901-2-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@kernel.org \
--cc=djrscally@gmail.com \
--cc=hpa@redhat.com \
--cc=linux-media@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sakari.ailus@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox