From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-gpio@vger.kernel.org,
Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 23/24] pinctrl: lynxpoint: Switch to pin control API
Date: Mon, 9 Dec 2019 15:09:25 +0200 [thread overview]
Message-ID: <20191209130926.86483-24-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20191209130926.86483-1-andriy.shevchenko@linux.intel.com>
When all preparations are done, we may switch to pin control API.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pinctrl/intel/Kconfig | 3 +
drivers/pinctrl/intel/pinctrl-lynxpoint.c | 67 ++++-------------------
2 files changed, 13 insertions(+), 57 deletions(-)
diff --git a/drivers/pinctrl/intel/Kconfig b/drivers/pinctrl/intel/Kconfig
index c2e6bc9e3e04..ee440ec4c94c 100644
--- a/drivers/pinctrl/intel/Kconfig
+++ b/drivers/pinctrl/intel/Kconfig
@@ -34,6 +34,9 @@ config PINCTRL_CHERRYVIEW
config PINCTRL_LYNXPOINT
tristate "Intel Lynxpoint pinctrl and GPIO driver"
depends on ACPI
+ select PINMUX
+ select PINCONF
+ select GENERIC_PINCONF
select GPIOLIB
select GPIOLIB_IRQCHIP
help
diff --git a/drivers/pinctrl/intel/pinctrl-lynxpoint.c b/drivers/pinctrl/intel/pinctrl-lynxpoint.c
index 795a9c7054ca..774b226f3a4d 100644
--- a/drivers/pinctrl/intel/pinctrl-lynxpoint.c
+++ b/drivers/pinctrl/intel/pinctrl-lynxpoint.c
@@ -577,43 +577,6 @@ static const struct pinctrl_desc lptlp_pinctrl_desc = {
.owner = THIS_MODULE,
};
-static int lp_gpio_request(struct gpio_chip *chip, unsigned int offset)
-{
- struct intel_pinctrl *lg = gpiochip_get_data(chip);
- void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
- void __iomem *conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2);
- u32 value;
-
- pm_runtime_get(lg->dev); /* should we put if failed */
-
- /*
- * Reconfigure pin to GPIO mode if needed and issue a warning,
- * since we expect firmware to configure it properly.
- */
- value = ioread32(reg);
- if ((value & USE_SEL_MASK) != USE_SEL_GPIO) {
- iowrite32((value & USE_SEL_MASK) | USE_SEL_GPIO, reg);
- dev_warn(lg->dev, FW_BUG "pin %u forcibly reconfigured as GPIO\n", offset);
- }
-
- /* enable input sensing */
- iowrite32(ioread32(conf2) & ~GPINDIS_BIT, conf2);
-
-
- return 0;
-}
-
-static void lp_gpio_free(struct gpio_chip *chip, unsigned int offset)
-{
- struct intel_pinctrl *lg = gpiochip_get_data(chip);
- void __iomem *conf2 = lp_gpio_reg(chip, offset, LP_CONFIG2);
-
- /* disable input sensing */
- iowrite32(ioread32(conf2) | GPINDIS_BIT, conf2);
-
- pm_runtime_put(lg->dev);
-}
-
static int lp_gpio_get(struct gpio_chip *chip, unsigned int offset)
{
void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
@@ -638,31 +601,15 @@ static void lp_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
static int lp_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
{
- struct intel_pinctrl *lg = gpiochip_get_data(chip);
- void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
- unsigned long flags;
-
- raw_spin_lock_irqsave(&lg->lock, flags);
- iowrite32(ioread32(reg) | DIR_BIT, reg);
- raw_spin_unlock_irqrestore(&lg->lock, flags);
-
- return 0;
+ return pinctrl_gpio_direction_input(chip->base + offset);
}
static int lp_gpio_direction_output(struct gpio_chip *chip, unsigned int offset,
int value)
{
- struct intel_pinctrl *lg = gpiochip_get_data(chip);
- void __iomem *reg = lp_gpio_reg(chip, offset, LP_CONFIG1);
- unsigned long flags;
-
lp_gpio_set(chip, offset, value);
- raw_spin_lock_irqsave(&lg->lock, flags);
- iowrite32(ioread32(reg) & ~DIR_BIT, reg);
- raw_spin_unlock_irqrestore(&lg->lock, flags);
-
- return 0;
+ return pinctrl_gpio_direction_output(chip->base + offset);
}
static int lp_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
@@ -874,6 +821,12 @@ static int lp_gpio_probe(struct platform_device *pdev)
lg->pctldesc.pins = lg->soc->pins;
lg->pctldesc.npins = lg->soc->npins;
+ lg->pctldev = devm_pinctrl_register(dev, &lg->pctldesc, lg);
+ if (IS_ERR(lg->pctldev)) {
+ dev_err(dev, "failed to register pinctrl driver\n");
+ return PTR_ERR(lg->pctldev);
+ }
+
platform_set_drvdata(pdev, lg);
io_rc = platform_get_resource(pdev, IORESOURCE_IO, 0);
@@ -902,8 +855,8 @@ static int lp_gpio_probe(struct platform_device *pdev)
gc = &lg->chip;
gc->label = dev_name(dev);
gc->owner = THIS_MODULE;
- gc->request = lp_gpio_request;
- gc->free = lp_gpio_free;
+ gc->request = gpiochip_generic_request;
+ gc->free = gpiochip_generic_free;
gc->direction_input = lp_gpio_direction_input;
gc->direction_output = lp_gpio_direction_output;
gc->get = lp_gpio_get;
--
2.24.0
next prev parent reply other threads:[~2019-12-09 13:09 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 13:09 [PATCH v2 00/24] pinctrl: intel: Move Lynxpoint to pin control umbrella Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 01/24] pinctrl: lynxpoint: Move GPIO driver to pin controller folder Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 02/24] pinctrl: lynxpoint: Use raw_spinlock for locking Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 03/24] pinctrl: lynxpoint: Correct amount of pins Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 04/24] pinctrl: lynxpoint: Drop useless assignment Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 05/24] pinctrl: lynxpoint: Use %pR to print IO resource Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 06/24] pinctrl: lynxpoint: Use standard pattern for memory allocation Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 07/24] pinctrl: lynxpoint: Assume 2 bits for mode selector Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 08/24] pinctrl: lynxpoint: Relax GPIO request rules Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 09/24] pinctrl: lynxpoint: Keep pointer to struct device instead of its container Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 10/24] pinctrl: lynxpoint: Switch to memory mapped IO accessors Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 11/24] pinctrl: lynxpoint: Convert unsigned to unsigned int Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 12/24] pinctrl: lynxpoint: Extract lp_gpio_acpi_use() for future use Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 13/24] pinctrl: lynxpoint: Move ->remove closer to ->probe() Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 14/24] pinctrl: lynxpoint: Move lp_irq_type() closer to IRQ related routines Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 15/24] pinctrl: lynxpoint: Move ownership check to IRQ chip Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 16/24] pinctrl: lynxpoint: Implement ->irq_ack() callback Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 17/24] pinctrl: lynxpoint: Implement intel_gpio_get_direction callback Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 18/24] pinctrl: lynxpoint: Add pin control data structures Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 19/24] pinctrl: lynxpoint: Reuse struct intel_pinctrl in the driver Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 20/24] pinctrl: lynxpoint: Add pin control operations Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 21/24] pinctrl: lynxpoint: Implement ->pin_dbg_show() Andy Shevchenko
2019-12-09 13:09 ` [PATCH v2 22/24] pinctrl: lynxpoint: Add GPIO <-> pin mapping ranges via callback Andy Shevchenko
2019-12-09 13:09 ` Andy Shevchenko [this message]
2019-12-09 13:09 ` [PATCH v2 24/24] pinctrl: lynxpoint: Update summary in the driver Andy Shevchenko
2019-12-11 13:19 ` [PATCH v2 00/24] pinctrl: intel: Move Lynxpoint to pin control umbrella Mika Westerberg
2019-12-13 13:36 ` Linus Walleij
2019-12-13 14:44 ` Andy Shevchenko
2019-12-16 10:19 ` Linus Walleij
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=20191209130926.86483-24-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mika.westerberg@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;
as well as URLs for NNTP newsgroup(s).