From: Hans de Goede <hdegoede@redhat.com>
To: Mark Gross <markgross@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
Daniel Scally <djrscally@gmail.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.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>,
Mark Pearson <markpearson@lenovo.com>,
linux-media@vger.kernel.org
Subject: [PATCH 2/6] platform/x86: int3472/discrete: Refactor GPIO to sensor mapping
Date: Wed, 30 Nov 2022 00:11:45 +0100 [thread overview]
Message-ID: <20221129231149.697154-3-hdegoede@redhat.com> (raw)
In-Reply-To: <20221129231149.697154-1-hdegoede@redhat.com>
Add a helper function to map the type returned by the _DSM
method to a function name + the default polarity for that function.
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>
---
Changes in v2:
- Make the helper function doing the type -> function mapping,
also return a default polarity for the function.
---
drivers/platform/x86/intel/int3472/discrete.c | 44 +++++++++++++++----
1 file changed, 35 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c
index 974a132db651..1eb053d13353 100644
--- a/drivers/platform/x86/intel/int3472/discrete.c
+++ b/drivers/platform/x86/intel/int3472/discrete.c
@@ -184,6 +184,35 @@ static int skl_int3472_map_gpio_to_clk(struct int3472_discrete_device *int3472,
return 0;
}
+static void int3472_get_func_and_polarity(u8 type, const char **func, u32 *polarity)
+{
+ switch (type) {
+ case INT3472_GPIO_TYPE_RESET:
+ *func = "reset";
+ *polarity = GPIO_ACTIVE_LOW;
+ break;
+ case INT3472_GPIO_TYPE_POWERDOWN:
+ *func = "powerdown";
+ *polarity = GPIO_ACTIVE_LOW;
+ break;
+ case INT3472_GPIO_TYPE_CLK_ENABLE:
+ *func = "clk-enable";
+ *polarity = GPIO_ACTIVE_HIGH;
+ break;
+ case INT3472_GPIO_TYPE_PRIVACY_LED:
+ *func = "privacy-led";
+ *polarity = GPIO_ACTIVE_HIGH;
+ break;
+ case INT3472_GPIO_TYPE_POWER_ENABLE:
+ *func = "power-enable";
+ *polarity = GPIO_ACTIVE_HIGH;
+ break;
+ default:
+ *func = "unknown";
+ *polarity = GPIO_ACTIVE_HIGH;
+ }
+}
+
/**
* skl_int3472_handle_gpio_resources: Map PMIC resources to consuming sensor
* @ares: A pointer to a &struct acpi_resource
@@ -223,6 +252,8 @@ 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;
+ u32 polarity;
int ret;
u8 type;
@@ -246,19 +277,14 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,
type = obj->integer.value & 0xff;
+ int3472_get_func_and_polarity(type, &func, &polarity);
+
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",
- GPIO_ACTIVE_LOW);
+ ret = skl_int3472_map_gpio_to_sensor(int3472, agpio, func, polarity);
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-29 23:13 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-29 23:11 [PATCH 0/6] ov5693/int3472: Privacy LED handling changes + IPU6 compatibility Hans de Goede
2022-11-29 23:11 ` [PATCH 1/6] media: ov5693: Add support for a privacy-led GPIO Hans de Goede
2022-11-30 13:41 ` Sakari Ailus
2022-11-30 13:56 ` Hans de Goede
2022-11-30 14:52 ` Sakari Ailus
2022-11-30 15:20 ` Laurent Pinchart
2022-11-30 16:07 ` Andy Shevchenko
2022-11-30 16:23 ` Laurent Pinchart
2022-11-30 16:29 ` Hans de Goede
2022-11-30 16:34 ` Hans de Goede
2022-12-02 10:54 ` Laurent Pinchart
2022-12-02 11:21 ` Hans de Goede
2022-12-02 11:49 ` Laurent Pinchart
2022-12-02 11:53 ` Andy Shevchenko
2022-12-02 12:14 ` Laurent Pinchart
2022-12-02 12:23 ` Andy Shevchenko
2022-12-02 13:46 ` Sakari Ailus
2022-12-02 15:55 ` Hans de Goede
2022-12-02 13:49 ` Sakari Ailus
2022-11-29 23:11 ` Hans de Goede [this message]
2022-11-30 9:49 ` [PATCH 2/6] platform/x86: int3472/discrete: Refactor GPIO to sensor mapping Andy Shevchenko
2022-11-30 10:37 ` Hans de Goede
2022-11-29 23:11 ` [PATCH 3/6] platform/x86: int3472/discrete: Treat privacy LED as regular GPIO Hans de Goede
2022-11-30 9:54 ` Andy Shevchenko
2022-11-30 10:34 ` Hans de Goede
2022-11-30 11:04 ` Andy Shevchenko
2022-11-29 23:11 ` [PATCH 4/6] platform/x86: int3472/discrete: Move GPIO request to skl_int3472_register_clock() Hans de Goede
2022-11-29 23:11 ` [PATCH 5/6] platform/x86: int3472/discrete: Ensure the clk/power enable pins are in output mode Hans de Goede
2022-11-30 9:59 ` Andy Shevchenko
2022-11-30 10:37 ` Hans de Goede
2022-11-29 23:11 ` [PATCH 6/6] platform/x86: int3472/discrete: Get the polarity from the _DSM entry Hans de Goede
2022-11-30 10:01 ` Andy Shevchenko
2022-11-30 10:39 ` Hans de Goede
2022-11-30 11:06 ` Andy Shevchenko
2022-11-30 11:10 ` Andy Shevchenko
2022-12-02 23:51 ` Hans de Goede
2022-11-30 10:03 ` [PATCH 0/6] ov5693/int3472: Privacy LED handling changes + IPU6 compatibility Andy Shevchenko
2022-11-30 10:40 ` Hans de Goede
2022-11-30 11:07 ` Andy Shevchenko
2022-12-02 13:50 ` Sakari Ailus
2022-12-07 17:34 ` Hans de Goede
2022-12-07 17:36 ` Andy Shevchenko
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=20221129231149.697154-3-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=andy@kernel.org \
--cc=djrscally@gmail.com \
--cc=hpa@redhat.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=markpearson@lenovo.com \
--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