login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
October
»
24
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Grant Likely
Subject:
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
Date: Friday, October 24, 2008 - 4:32 pm
On Fri, Oct 24, 2008 at 5:08 PM, Trent Piepho <tpiepho@freescale.com> wrote:
quoted text
> The device binding spec for OF GPIOs defines a flags field, but there is > currently no way to get it. This patch adds a parameter to of_get_gpio() > where the flags will be returned if non-NULL. of_get_gpio() in turn passes > the parameter to the of_gpio_chip's xlate method, which can extract any > flags present from the gpio_spec. > > The default (and currently only) of_gpio_chip xlate method, > of_gpio_simple_xlate(), is modified to do this. > > Signed-off-by: Trent Piepho <tpiepho@freescale.com>
This looks sane to me Acked-by: Grant Likely <grant.likely@secretlab.ca>
quoted text
> --- > drivers/mtd/nand/fsl_upm.c | 2 +- > drivers/net/fs_enet/fs_enet-main.c | 2 +- > drivers/net/phy/mdio-ofgpio.c | 4 ++-- > drivers/of/gpio.c | 13 ++++++++++--- > drivers/serial/cpm_uart/cpm_uart_core.c | 2 +- > include/linux/of_gpio.h | 17 +++++++++++++---- > 6 files changed, 28 insertions(+), 12 deletions(-) > > diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c > index 024e3ff..a25d962 100644 > --- a/drivers/mtd/nand/fsl_upm.c > +++ b/drivers/mtd/nand/fsl_upm.c > @@ -218,7 +218,7 @@ static int __devinit fun_probe(struct of_device *ofdev, > } > fun->upm_cmd_offset = *prop; > > - fun->rnb_gpio = of_get_gpio(ofdev->node, 0); > + fun->rnb_gpio = of_get_gpio(ofdev->node, 0, NULL); > if (fun->rnb_gpio >= 0) { > ret = gpio_request(fun->rnb_gpio, ofdev->dev.bus_id); > if (ret) { > diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c > index cb51c1f..5a3c7ee 100644 > --- a/drivers/net/fs_enet/fs_enet-main.c > +++ b/drivers/net/fs_enet/fs_enet-main.c > @@ -994,7 +994,7 @@ static int __devinit find_phy(struct device_node *np, > goto out_put_phy; > } > > - bus_id = of_get_gpio(mdionode, 0); > + bus_id = of_get_gpio(mdionode, 0, NULL); > if (bus_id < 0) { > struct resource res; > ret = of_address_to_resource(mdionode, 0, &res); > diff --git a/drivers/net/phy/mdio-ofgpio.c b/drivers/net/phy/mdio-ofgpio.c > index 2ff9775..e3757c6 100644 > --- a/drivers/net/phy/mdio-ofgpio.c > +++ b/drivers/net/phy/mdio-ofgpio.c > @@ -78,8 +78,8 @@ static int __devinit mdio_ofgpio_bitbang_init(struct mii_bus *bus, > { > struct mdio_gpio_info *bitbang = bus->priv; > > - bitbang->mdc = of_get_gpio(np, 0); > - bitbang->mdio = of_get_gpio(np, 1); > + bitbang->mdc = of_get_gpio(np, 0, NULL); > + bitbang->mdio = of_get_gpio(np, 1, NULL); > > if (bitbang->mdc < 0 || bitbang->mdio < 0) > return -ENODEV; > diff --git a/drivers/of/gpio.c b/drivers/of/gpio.c > index 7cd7301..2123517 100644 > --- a/drivers/of/gpio.c > +++ b/drivers/of/gpio.c > @@ -22,11 +22,12 @@ > * of_get_gpio - Get a GPIO number from the device tree to use with GPIO API > * @np: device node to get GPIO from > * @index: index of the GPIO > + * @flags: GPIO's flags are returned here if non-NULL > * > * Returns GPIO number to use with Linux generic GPIO API, or one of the errno > * value on the error condition. > */ > -int of_get_gpio(struct device_node *np, int index) > +int of_get_gpio(struct device_node *np, int index, unsigned int *flags) > { > int ret; > struct device_node *gc; > @@ -59,7 +60,9 @@ int of_get_gpio(struct device_node *np, int index) > goto err1; > } > > - ret = of_gc->xlate(of_gc, np, gpio_spec); > + if (flags) > + *flags = 0; > + ret = of_gc->xlate(of_gc, np, gpio_spec, flags); > if (ret < 0) > goto err1; > > @@ -77,19 +80,23 @@ EXPORT_SYMBOL(of_get_gpio); > * @of_gc: pointer to the of_gpio_chip structure > * @np: device node of the GPIO chip > * @gpio_spec: gpio specifier as found in the device tree > + * @flags: if non-NUll flags are returned here > * > * This is simple translation function, suitable for the most 1:1 mapped > * gpio chips. This function performs only one sanity check: whether gpio > * is less than ngpios (that is specified in the gpio_chip). > */ > int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, > - const void *gpio_spec) > + const void *gpio_spec, unsigned int *flags) > { > const u32 *gpio = gpio_spec; > > if (*gpio > of_gc->gc.ngpio) > return -EINVAL; > > + if (flags && of_gc->gpio_cells > 1) > + *flags = gpio[1]; > + > return *gpio; > } > EXPORT_SYMBOL(of_gpio_simple_xlate); > diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c > index bde4b4b..7835cd4 100644 > --- a/drivers/serial/cpm_uart/cpm_uart_core.c > +++ b/drivers/serial/cpm_uart/cpm_uart_core.c > @@ -1094,7 +1094,7 @@ static int cpm_uart_init_port(struct device_node *np, > } > > for (i = 0; i < NUM_GPIOS; i++) > - pinfo->gpios[i] = of_get_gpio(np, i); > + pinfo->gpios[i] = of_get_gpio(np, i, NULL); > > return cpm_uart_request_port(&pinfo->port); > > diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h > index 67db101..0d332bf 100644 > --- a/include/linux/of_gpio.h > +++ b/include/linux/of_gpio.h > @@ -26,7 +26,7 @@ struct of_gpio_chip { > struct gpio_chip gc; > int gpio_cells; > int (*xlate)(struct of_gpio_chip *of_gc, struct device_node *np, > - const void *gpio_spec); > + const void *gpio_spec, unsigned int *flags); > }; > > static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc) > @@ -35,6 +35,14 @@ static inline struct of_gpio_chip *to_of_gpio_chip(struct gpio_chip *gc) > } > > /* > + * Flags as returned by OF GPIO chip's xlate function. > + * These do not need to be the same as the flags in the GPIO specifier in the > + * OF device tree, but it's convenient if they are. The mm chip OF GPIO > + * driver works this way. > + */ > +#define OF_GPIO_ACTIVE_LOW 1 > + > +/* > * OF GPIO chip for memory mapped banks > */ > struct of_mm_gpio_chip { > @@ -50,16 +58,17 @@ static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc) > return container_of(of_gc, struct of_mm_gpio_chip, of_gc); > } > > -extern int of_get_gpio(struct device_node *np, int index); > +extern int of_get_gpio(struct device_node *np, int index, unsigned int *flags); > extern int of_mm_gpiochip_add(struct device_node *np, > struct of_mm_gpio_chip *mm_gc); > extern int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, > struct device_node *np, > - const void *gpio_spec); > + const void *gpio_spec, unsigned int *flags); > #else > > /* Drivers may not strictly depend on the GPIO support, so let them link. */ > -static inline int of_get_gpio(struct device_node *np, int index) > +static inline int of_get_gpio(struct device_node *np, int index, > + unsigned int *flags) > { > return -ENOSYS; > } > -- > 1.5.4.3 > >
-- Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
OpenFirmware GPIO LED driver
, Trent Piepho
, (Fri Oct 24, 4:04 pm)
[PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Trent Piepho
, (Fri Oct 24, 4:08 pm)
[PATCH 2/4] leds: Support OpenFirmware led bindings
, Trent Piepho
, (Fri Oct 24, 4:08 pm)
[PATCH 3/4] leds: Add option to have GPIO LEDs start on
, Trent Piepho
, (Fri Oct 24, 4:09 pm)
[PATCH 4/4] leds: Let GPIO LEDs keep their current state
, Trent Piepho
, (Fri Oct 24, 4:09 pm)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Grant Likely
, (Fri Oct 24, 4:32 pm)
Re: [PATCH 2/4] leds: Support OpenFirmware led bindings
, Grant Likely
, (Fri Oct 24, 4:50 pm)
Re: [PATCH 3/4] leds: Add option to have GPIO LEDs start on
, Grant Likely
, (Fri Oct 24, 4:59 pm)
Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
, Grant Likely
, (Fri Oct 24, 5:04 pm)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Anton Vorontsov
, (Tue Oct 28, 7:39 am)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Grant Likely
, (Tue Oct 28, 7:53 am)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Anton Vorontsov
, (Tue Oct 28, 8:16 am)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Grant Likely
, (Tue Oct 28, 8:42 am)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Anton Vorontsov
, (Tue Oct 28, 9:56 am)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()
, Grant Likely
, (Tue Oct 28, 10:40 am)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()A
, Trent Piepho
, (Wed Oct 29, 7:21 pm)
Re: [PATCH 1/4] of_gpio: Return GPIO flags from of_get_gpio()A
, Anton Vorontsov
, (Thu Oct 30, 4:15 am)
[PATCH v2] of_gpio: Return GPIO flags from of_get_gpio()
, Trent Piepho
, (Thu Oct 30, 7:03 pm)
Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
, Richard Purdie
, (Mon Nov 17, 7:50 am)
Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
, Trent Piepho
, (Thu Nov 20, 6:05 pm)
Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
, Pavel Machek
, (Sun Nov 23, 5:31 am)
Re: [PATCH v2] of_gpio: Return GPIO flags from of_get_gpio()
, Anton Vorontsov
, (Wed Nov 26, 9:20 am)
Re: [PATCH v2] of_gpio: Return GPIO flags from of_get_gpio()
, Paul Mackerras
, (Wed Nov 26, 2:38 pm)
Re: [PATCH v2] of_gpio: Return GPIO flags from of_get_gpio()
, Anton Vorontsov
, (Wed Nov 26, 3:31 pm)
Re: [PATCH v2] of_gpio: Return GPIO flags from of_get_gpio()
, Trent Piepho
, (Wed Nov 26, 3:35 pm)
Re: [PATCH v2] of_gpio: Return GPIO flags from of_get_gpio()
, Anton Vorontsov
, (Wed Nov 26, 3:58 pm)
Re: [PATCH v2] of_gpio: Return GPIO flags from of_get_gpio()
, Paul Mackerras
, (Wed Nov 26, 4:32 pm)
Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
, Richard Purdie
, (Wed Dec 3, 3:04 am)
Re: [PATCH 4/4] leds: Let GPIO LEDs keep their current state
, Trent Piepho
, (Tue Dec 9, 9:33 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
swhiteho
[PATCH 42/51] [GFS2] Move inode deletion out of blocking_cb
FUJITA Tomonori
Re: [Scst-devel] Integration of SCST in the mainstream Linux kernel
Benjamin Herrenschmidt
[git pull] Please pull powerpc.git merge branch
Ingo Molnar
Re: [RFC/RFT PATCH] sched: automated per tty task groups
Vivek Goyal
Re: [PATCH v4] sched: automated per session task groups
git
:
Mike Miller
git message
Junio C Hamano
Re: [PATCH] Detached HEAD (experimental)
Stefan Richter
Re: [kernel.org users] [RFD] On deprecating "git-foo" for builtins
Jeff King
Re: [PATCH] t7004: test that "git-tag -u" implies "-s"
Christian MICHON
Re: VCS comparison table
git-commits-head
:
Linux Kernel Mailing List
libata: disable ATAPI AN by default
Linux Kernel Mailing List
i915: Don't whine when pci_enable_msi() fails.
Linux Kernel Mailing List
Documentation/timers/hpet_example.c: only build on X86
Linux Kernel Mailing List
NFSv4: Move error handling out of the delegation generic code
Linux Kernel Mailing List
Disallow gcc versions 4.1.{0,1}
linux-netdev
:
Arnaldo Carvalho de Melo
Re: [PATCH 06/37] dccp: Limit feature negotiation to connection setup phase
David Miller
Re: 2.6.27.18: bnx2/tg3: BUG: "scheduling while atomic" trying to ifenslave a seco...
Jeff Garzik
Re: [PATCH] drivers/net: remove network drivers' last few uses of IRQF_SAMPLE_RANDOM
David Miller
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugins for negotiation
Chuck Lever
Re: svc: failed to register lockdv1 RPC service (errno 97).
openbsd-misc
:
Stuart Henderson
Re: Kuro5hin: OpenBSD Founder Theo deRaadt Has Conflict of Interest With AMD
Christian Weisgerber
Re: CARP with a single public IP address
Marco Peereboom
Re: OpenBSD culture?
"RALOVICH, Kristóf"
Re: thinkpad windows refund
Kevin
Re: uvm_mapent_alloc: out of static map entries on 4.3 i386
Colocation donated by:
Syndicate