From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Linus Walleij <linus.walleij@linaro.org>, linux-gpio@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: [PATCH v1] gpio: merrifield: Add support of ACPI enabled platforms
Date: Wed, 3 Jan 2018 19:32:40 +0200 [thread overview]
Message-ID: <20180103173240.45755-1-andriy.shevchenko@linux.intel.com> (raw)
The driver needs the pin control device name for ACPI.
We are looking through ACPI namespace and return first found device
based on ACPI HID for Intel Merrifield FLIS.
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-merrifield.c | 43 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c
index dd67a31ac337..61e75d10669d 100644
--- a/drivers/gpio/gpio-merrifield.c
+++ b/drivers/gpio/gpio-merrifield.c
@@ -9,6 +9,7 @@
* published by the Free Software Foundation.
*/
+#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/gpio/driver.h>
#include <linux/init.h>
@@ -380,9 +381,48 @@ static void mrfld_irq_init_hw(struct mrfld_gpio *priv)
}
}
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id mrfld_pinctrl_acpi_ids[] = {
+ {"INTC1002"},
+ {}
+};
+
+static acpi_status
+mrfld_acpi_find_pinctrl(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+ const char **name = context;
+ struct acpi_device *adev;
+
+ if (acpi_bus_get_device(handle, &adev))
+ return AE_OK;
+
+ if (acpi_match_device_ids(adev, mrfld_pinctrl_acpi_ids))
+ return AE_OK;
+
+ *name = dev_name(&adev->dev);
+ return AE_CTRL_TERMINATE;
+}
+
+static const char *mrfld_acpi_get_pinctrl_dev_name(const char *fallback)
+{
+ const char *pinctrl_dev_name = fallback;
+
+ acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, mrfld_acpi_find_pinctrl, NULL,
+ &pinctrl_dev_name, NULL);
+ return pinctrl_dev_name;
+}
+#else
+static inline const char *mrfld_acpi_get_pinctrl_dev_name(const char *fallback)
+{
+ return fallback;
+}
+#endif
+
static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
const struct mrfld_gpio_pinrange *range;
+ const char *pinctrl_dev_name;
struct mrfld_gpio *priv;
u32 gpio_base, irq_base;
void __iomem *base;
@@ -439,10 +479,11 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id
return retval;
}
+ pinctrl_dev_name = mrfld_acpi_get_pinctrl_dev_name("pinctrl-merrifield");
for (i = 0; i < ARRAY_SIZE(mrfld_gpio_ranges); i++) {
range = &mrfld_gpio_ranges[i];
retval = gpiochip_add_pin_range(&priv->chip,
- "pinctrl-merrifield",
+ pinctrl_dev_name,
range->gpio_base,
range->pin_base,
range->npins);
--
2.15.1
next reply other threads:[~2018-01-03 17:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 17:32 Andy Shevchenko [this message]
2018-01-04 9:36 ` [PATCH v1] gpio: merrifield: Add support of ACPI enabled platforms Mika Westerberg
2018-01-04 12:38 ` Andy Shevchenko
2018-01-04 16:32 ` 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=20180103173240.45755-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.