From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Alexandre Courbot <acourbot@nvidia.com>,
linux-gpio@vger.kernel.org,
Linus Walleij <linus.walleij@linaro.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
David Cohen <david.a.cohen@intel.com>,
Sathyanarayanan Kuppuswamy <sathyanarayanan.kuppuswamy@intel.com>,
Len Brown <lenb@kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v5 2/2] gpiolib: append SFI helpers for GPIO API
Date: Mon, 9 Dec 2013 16:47:01 +0200 [thread overview]
Message-ID: <1386600421-16463-3-git-send-email-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <1386600421-16463-1-git-send-email-andriy.shevchenko@linux.intel.com>
To support some (legacy) firmwares and platforms let's make life easier for
their customers.
This patch provides a function which converts sfi_gpio_table_entry to
gpio_desc. The use of it is integrated into GPIO library to enable generic
access to the SFI GPIO resources.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/Kconfig | 4 ++++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpiolib-sfi.c | 27 +++++++++++++++++++++++++++
drivers/gpio/gpiolib.c | 3 +++
drivers/gpio/gpiolib.h | 13 +++++++++++++
5 files changed, 48 insertions(+)
create mode 100644 drivers/gpio/gpiolib-sfi.c
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index ae3682d..a12752a 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -51,6 +51,10 @@ config OF_GPIO
def_bool y
depends on OF
+config GPIO_SFI
+ def_bool y
+ depends on SFI
+
config GPIO_ACPI
def_bool y
depends on ACPI
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index ee95154..5373e3a 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -5,6 +5,7 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
obj-$(CONFIG_GPIO_DEVRES) += devres.o
obj-$(CONFIG_GPIOLIB) += gpiolib.o
obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
+obj-$(CONFIG_GPIO_SFI) += gpiolib-sfi.o
obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o
# Device drivers. Generally keep list sorted alphabetically
diff --git a/drivers/gpio/gpiolib-sfi.c b/drivers/gpio/gpiolib-sfi.c
new file mode 100644
index 0000000..7531624
--- /dev/null
+++ b/drivers/gpio/gpiolib-sfi.c
@@ -0,0 +1,27 @@
+/*
+ * Simple Firmware Interface (SFI) helpers for GPIO API
+ *
+ * Copyright (C) 2013, Intel Corporation
+ * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/gpio/consumer.h>
+#include <linux/sfi.h>
+#include <linux/err.h>
+
+#include "gpiolib.h"
+
+struct gpio_desc *sfi_get_gpiod_by_name(const char *name)
+{
+ struct sfi_gpio_table_entry *pentry;
+
+ pentry = sfi_gpio_get_entry_by_name(name);
+ if (IS_ERR(pentry))
+ return ERR_CAST(pentry);
+
+ return gpio_to_desc(pentry->pin_no);
+}
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index d2ffdfe..7575c51 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2452,6 +2452,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
} else if (IS_ENABLED(CONFIG_ACPI) && dev && ACPI_HANDLE(dev)) {
dev_dbg(dev, "using ACPI for GPIO lookup\n");
desc = acpi_find_gpio(dev, con_id, idx, &flags);
+ } else if (IS_ENABLED(CONFIG_SFI)) {
+ dev_dbg(dev, "using SFI for GPIO lookup\n");
+ desc = sfi_get_gpiod_by_name(con_id);
}
/*
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index 82be586..ca0615a 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -43,4 +43,17 @@ acpi_get_gpiod_by_index(struct device *dev, int index,
}
#endif
+#ifdef CONFIG_GPIO_SFI
+
+struct gpio_desc *sfi_get_gpiod_by_name(const char *name);
+
+#else /* !CONFIG_GPIO_SFI */
+
+static inline struct gpio_desc *sfi_get_gpiod_by_name(const char *name)
+{
+ return ERR_PTR(-ENODEV);
+}
+
+#endif /* !CONFIG_GPIO_SFI */
+
#endif /* GPIOLIB_H */
--
1.8.4.4
next prev parent reply other threads:[~2013-12-09 14:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-09 14:46 [PATCH v5 0/2] gpiolib, sfi: introduce SFI GPIO helpers Andy Shevchenko
2013-12-09 14:47 ` [PATCH v5 1/2] SFI: store GPIO table and export lookup function Andy Shevchenko
2013-12-10 3:08 ` Alex Courbot
2013-12-09 14:47 ` Andy Shevchenko [this message]
2013-12-09 15:01 ` [PATCH v5 0/2] gpiolib, sfi: introduce SFI GPIO helpers Mika Westerberg
2013-12-10 3:05 ` Alex Courbot
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=1386600421-16463-3-git-send-email-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=acourbot@nvidia.com \
--cc=david.a.cohen@intel.com \
--cc=lenb@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=sathyanarayanan.kuppuswamy@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).