From: Mario Limonciello <mario.limonciello@amd.com>
To: <Basavaraj.Natikar@amd.com>, <Shyam-sundar.S-k@amd.com>,
<linus.walleij@linaro.org>
Cc: <npliashechnikov@gmail.com>, <nmschulte@gmail.com>,
<friedrich.vock@gmx.de>, <dridri85@gmail.com>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH 3/4] pinctrl: amd: Unify debounce handling into amd_pinconf_set()
Date: Fri, 30 Jun 2023 14:47:15 -0500 [thread overview]
Message-ID: <20230630194716.6497-4-mario.limonciello@amd.com> (raw)
In-Reply-To: <20230630194716.6497-1-mario.limonciello@amd.com>
Debounce handling is done in two different entry points in the driver.
Unify this to make sure that it's always handled the same.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pinctrl/pinctrl-amd.c | 38 +++++++++++++++--------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index cd46a5200f9b4..a22e02e2f5d35 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -115,16 +115,12 @@ static void amd_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value)
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
}
-static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset,
- unsigned debounce)
+static int amd_gpio_set_debounce(struct amd_gpio *gpio_dev, unsigned offset,
+ unsigned debounce)
{
u32 time;
u32 pin_reg;
int ret = 0;
- unsigned long flags;
- struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
-
- raw_spin_lock_irqsave(&gpio_dev->lock, flags);
/* Use special handling for Pin0 debounce */
if (offset == 0) {
@@ -183,23 +179,10 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset,
pin_reg &= ~(DB_CNTRl_MASK << DB_CNTRL_OFF);
}
writel(pin_reg, gpio_dev->base + offset * 4);
- raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
return ret;
}
-static int amd_gpio_set_config(struct gpio_chip *gc, unsigned offset,
- unsigned long config)
-{
- u32 debounce;
-
- if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
- return -ENOTSUPP;
-
- debounce = pinconf_to_config_argument(config);
- return amd_gpio_set_debounce(gc, offset, debounce);
-}
-
#ifdef CONFIG_DEBUG_FS
static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)
{
@@ -794,9 +777,8 @@ static int amd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
switch (param) {
case PIN_CONFIG_INPUT_DEBOUNCE:
- pin_reg &= ~DB_TMR_OUT_MASK;
- pin_reg |= arg & DB_TMR_OUT_MASK;
- break;
+ ret = amd_gpio_set_debounce(gpio_dev, pin, arg);
+ goto out;
case PIN_CONFIG_BIAS_PULL_DOWN:
pin_reg &= ~BIT(PULL_DOWN_ENABLE_OFF);
@@ -823,6 +805,7 @@ static int amd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
writel(pin_reg, gpio_dev->base + pin*4);
}
+out:
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
return ret;
@@ -864,6 +847,17 @@ static int amd_pinconf_group_set(struct pinctrl_dev *pctldev,
return 0;
}
+static int amd_gpio_set_config(struct gpio_chip *gc, unsigned pin,
+ unsigned long config)
+{
+ struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
+
+ if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE)
+ return -ENOTSUPP;
+
+ return amd_pinconf_set(gpio_dev->pctrl, pin, &config, 1);
+}
+
static const struct pinconf_ops amd_pinconf_ops = {
.pin_config_get = amd_pinconf_get,
.pin_config_set = amd_pinconf_set,
--
2.34.1
next prev parent reply other threads:[~2023-06-30 19:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 19:47 [PATCH 0/4] Fix for interrupt storm on ASUS TUF A16 Mario Limonciello
2023-06-30 19:47 ` [PATCH 1/4] pinctrl: amd: Only use special debounce behavior for GPIO 0 Mario Limonciello
2023-06-30 19:47 ` [PATCH 2/4] pinctrl: amd: Drop pull up select configuration Mario Limonciello
2023-07-03 21:32 ` andy.shevchenko
2023-07-04 2:13 ` Mario Limonciello
2023-06-30 19:47 ` Mario Limonciello [this message]
2023-07-03 21:33 ` [PATCH 3/4] pinctrl: amd: Unify debounce handling into amd_pinconf_set() andy.shevchenko
2023-07-04 2:16 ` Mario Limonciello
2023-06-30 19:47 ` [PATCH 4/4] pinctrl: amd: Use amd_pinconf_set() for all config options Mario Limonciello
2023-07-03 21:35 ` andy.shevchenko
2023-07-04 2:15 ` Mario Limonciello
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=20230630194716.6497-4-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=Basavaraj.Natikar@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=dridri85@gmail.com \
--cc=friedrich.vock@gmx.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nmschulte@gmail.com \
--cc=npliashechnikov@gmail.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
all inboxes | Powered by JetHome®