gpiolib: append SFI helpers for GPIO API
PATCH 1/1 gpiolib: append SFI helpers for GPIO API
To support some (legacy) firmwares and platforms let's make life easier for their customers.
This patch extracts SFI GPIO API from arch/x86/platform/mrst/mrst.c.
---
Since v1.1:
- use container_of
- switch to kmemdup
drivers/gpio/Kconfig | 4 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpiolib-sfi.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/sfi/sfi_core.c | 7 +++++ include/linux/sfi_gpio.h | 27 ++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 drivers/gpio/gpiolib-sfi.c create mode 100644 include/linux/sfi_gpio.h
drivers/gpio/Kconfig +4 -0
@@ -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
drivers/gpio/Makefile +1 -0
@@ -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
drivers/gpio/gpiolib-sfi.c new file +77 -0
77 lines not on this page · raw message
drivers/sfi/sfi_core.c +7 -0
@@ -67,6 +67,7 @@#include <linux/acpi.h> #include <linux/init.h> #include <linux/sfi.h> +#include <linux/sfi_gpio.h> #include <linux/slab.h> #include "sfi_core.h"
@@ -512,6 +513,12 @@ void __init sfi_init_late(void) syst_va =sfi_map_memory (syst_pa, length);sfi_acpi_init (); + +/* +* Parsing GPIO table first, since the DEVS table will need this table +* to map the pin name to the actual pin. +*/ +sfi_gpio_init (); }/*
include/linux/sfi_gpio.h new file +27 -0
@@ -0,0 +1,27 @@ +#ifndef _LINUX_SFI_GPIO_H_ +#define _LINUX_SFI_GPIO_H_ + +#include <linux/errno.h> +#include <linux/gpio.h> +#include <linux/sfi.h> + +#ifdef CONFIG_GPIO_SFI + +int sfi_get_gpio_by_name (const char *name); +int sfi_gpio_init (void ); + +#else /* CONFIG_GPIO_SFI */ + +static inline int sfi_get_gpio_by_name (const char *name); +{ +return -ENODEV ; +} + +static inline int sfi_gpio_init (void ) +{ +return -ENODEV ; +} + +#endif /* CONFIG_GPIO_SFI */ + +#endif /* _LINUX_SFI_GPIO_H_ */
Signature · 1 line
1.8.2.rc0.22.gb3600c3
Quoted 5 lines · Andy Shevchenko
To support some (legacy) firmwares and platforms let's make life easier for their customers.
This patch extracts SFI GPIO API from
arch/x86/platform/mrst/mrst.c.
Quoted 8 lines
Signed-off-by Andy Shevchenko <[email protected]>Acked-by Len Brown <[email protected]>Cc Grant Likely <[email protected]>Cc Linus Walleij <[email protected]>---
Since v1.1:
- usecontainer_of
- switch to kmemdup
Yours,
Linus Walleij
Quoted 17 lines · Linus Walleij
Quoted 5 lines · Andy Shevchenko
To support some (legacy) firmwares and platforms let's make life easier for their customers.
This patch extracts SFI GPIO API from
arch/x86/platform/mrst/mrst.c.Quoted 8 lines
Signed-off-by Andy Shevchenko <[email protected]>Acked-by Len Brown <[email protected]>Cc Grant Likely <[email protected]>Cc Linus Walleij <[email protected]>---
Since v1.1:
- usecontainer_of
- switch to kmemdup
Quoted 1 line
Acked-by Linus Walleij <[email protected]>
Consider this recalled.
Yours,
Linus Walleij
Quoted 6 lines · Andy Shevchenko
To support some (legacy) firmwares and platforms let's make life easier for their customers.
This patch extracts SFI GPIO API from
arch/x86/platform/mrst/mrst.c.Signed-off-by Andy Shevchenko <[email protected]>
So since this patch was ACKed the world has changed a bit and now I want new changes (or maybe I was tired and not paying enough attention at the time).
(...)
Quoted 6 lines
drivers/gpio/gpiolib-sfi.c new file +6
-0+int sfi_get_gpio_by_name (const char *name) +{ +struct sfi_gpio_table_entry *pentry = sfi_gpio_table; +int i; + +if (!pentry)
drivers/gpio/gpiolib-sfi.c line 43
Quoted 10 lines
drivers/gpio/gpiolib-sfi.c new file +10
-0+return -EINVAL ; + +for (i =0 ; i < sfi_gpio_num_entry; i++, pentry++) { +if (!strncmp (name, pentry->pin_name,SFI_NAME_LEN )) +return pentry->pin_no; + } + +return -ENODEV ; +} +EXPORT_SYMBOL_GPL (sfi_get_gpio_by_name);
Last merge window we merged the GPIO descriptor API and this is now the recommended way to handle GPIOs and it is also deployed into the ACPI and DT implementations.
So I'd like the signature of this function changed to return a GPIO descriptor rather than an int so we don't stockpile more stuff to refactor.
i.e.:
struct gpio_desc *sfi_get_gpio_by_name(const char *name);
--- /dev/null
Quoted 1 line
+++
b/include/linux/sfi_gpio.h
Maybe that header could move to <linux/gpio/sfi.h> instead. Alexandre what do you think?
Yours,
Linus Walleij
Quoted 40 lines · Linus Walleij
Quoted 6 lines · Andy Shevchenko
To support some (legacy) firmwares and platforms let's make life easier for their customers.
This patch extracts SFI GPIO API from
arch/x86/platform/mrst/mrst.c.Signed-off-by Andy Shevchenko <[email protected]>So since this patch was ACKed the world has changed a bit and now I want new changes (or maybe I was tired and not paying enough attention at the time).
(...)
Quoted 6 lines
drivers/gpio/gpiolib-sfi.c new file +6
-0+int sfi_get_gpio_by_name (const char *name) +{ +struct sfi_gpio_table_entry *pentry = sfi_gpio_table; +int i; + +if (!pentry)drivers/gpio/gpiolib-sfi.c line 43
Quoted 10 lines
drivers/gpio/gpiolib-sfi.c new file +10
-0+return -EINVAL ; + +for (i =0 ; i < sfi_gpio_num_entry; i++, pentry++) { +if (!strncmp (name, pentry->pin_name,SFI_NAME_LEN )) +return pentry->pin_no; + } + +return -ENODEV ; +} +EXPORT_SYMBOL_GPL (sfi_get_gpio_by_name);Last merge window we merged the GPIO descriptor API and this is now the recommended way to handle GPIOs and it is also deployed into the ACPI and DT implementations.
So I'd like the signature of this function changed to return a GPIO descriptor rather than an int so we don't stockpile more stuff to refactor.
Quoted 8 lines
i.e.:
structgpio_desc*sfi_get_gpio_by_name(const char *name);---
/dev/nullQuoted 1 line
+++
b/include/linux/sfi_gpio.hMaybe that header could move to <
linux/gpio/sfi.h> instead. Alexandre what do you think?
Agreed - all the GPIO drivers into drivers/gpio, all the headers into include/linux/gpio. Logical. :)
Alex.
Quoted 8 lines · Alex Courbot
Quoted 7 lines · Linus Walleij
Quoted 4 lines · Andy Shevchenko
To support some (legacy) firmwares and platforms let's make life easier for
their customers.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
This patch extracts SFI GPIO API from
arch/x86/platform/mrst/mrst.c.Signed-off-by Andy Shevchenko <[email protected]>So since this patch was ACKed the world has changed a bit and now I want new changes (or maybe I was tired and not paying enough attention at the time).
Agreed. Even my e-mail was outdated :)
Updating from [email protected] to [email protected] to avoid M$ servers.
Quoted 30 lines
Quoted 30 lines
(...)
Quoted 6 lines
drivers/gpio/gpiolib-sfi.c new file +6
-0+int sfi_get_gpio_by_name (const char *name) +{ +struct sfi_gpio_table_entry *pentry = sfi_gpio_table; +int i; + +if (!pentry)drivers/gpio/gpiolib-sfi.c line 43
Quoted 10 lines
drivers/gpio/gpiolib-sfi.c new file +10
-0+return -EINVAL ; + +for (i =0 ; i < sfi_gpio_num_entry; i++, pentry++) { +if (!strncmp (name, pentry->pin_name,SFI_NAME_LEN )) +return pentry->pin_no; + } + +return -ENODEV ; +} +EXPORT_SYMBOL_GPL (sfi_get_gpio_by_name);Last merge window we merged the GPIO descriptor API and this is now the recommended way to handle GPIOs and it is also deployed into the ACPI and DT implementations.
So I'd like the signature of this function changed to return a GPIO descriptor rather than an int so we don't stockpile more stuff to refactor.
i.e.:
structgpio_desc*sfi_get_gpio_by_name(const char *name);
Quoted 8 lines
Quoted 5 lines
---
/dev/nullQuoted 1 line
+++
b/include/linux/sfi_gpio.hMaybe that header could move to <
linux/gpio/sfi.h> instead. Alexandre what do you think?Agreed - all the GPIO drivers into
drivers/gpio, all the headers intoinclude/linux/gpio. Logical. :)
Sounds nice.
Andy, would you like to update the patch or should I go ahead and resend it myself?
Br, David Cohen
On Tue, 2013-11-19 at 09:32 -0800, David Cohen wrote:
[]
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Maybe that header could move to <
linux/gpio/sfi.h> instead. Alexandre what do you think?Agreed - all the GPIO drivers into
drivers/gpio, all the headers intoinclude/linux/gpio. Logical. :)Sounds nice.
Andy, would you like to update the patch or should I go ahead and resend it myself?
I already had done this, but I can't check since linux-next is broken for me. Once I tried it I send it here.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 13 lines · David Cohen
Quoted 12 lines · Alex Courbot
Quoted 11 lines · Linus Walleij
Quoted 7 lines · Andy Shevchenko
To support some (legacy) firmwares and platforms let's make life easier for
their customers.This patch extracts SFI GPIO API from
arch/x86/platform/mrst/mrst.c.Signed-off-by Andy Shevchenko <[email protected]>
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
So since this patch was ACKed the world has changed a bit and now I want new changes (or maybe I was tired and not paying enough attention at the time).
Agreed. Even my e-mail was outdated :)
Updating from [email protected] to [email protected] to avoid M$ servers.
Just sent a version, though, sorry, I forgot to update your email there.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy