* [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO
@ 2011-09-05 3:12 Ben Hutchings
2011-09-05 6:54 ` Arnaud Patard (Rtp)
2011-09-05 12:41 ` [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO Linus Walleij
0 siblings, 2 replies; 10+ messages in thread
From: Ben Hutchings @ 2011-09-05 3:12 UTC (permalink / raw)
To: linux-arm-kernel
The GPIO implementations for these two machines depend on gpiolib,
so they must not select GENERIC_GPIO directly.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
This hould fix the build failure seen here:
https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.1.0%7Erc4-1%7Eexperimental.1&stamp=1315007168
However, I have not yet tested it.
Ben.
arch/arm/Kconfig | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index f23712d..a1dbc4b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -477,7 +477,7 @@ config ARCH_IXP4XX
depends on MMU
select CLKSRC_MMIO
select CPU_XSCALE
- select GENERIC_GPIO
+ select ARCH_REQUIRE_GPIOLIB
select GENERIC_CLOCKEVENTS
select HAVE_SCHED_CLOCK
select MIGHT_HAVE_PCI
@@ -830,7 +830,7 @@ config ARCH_U300
select GENERIC_CLOCKEVENTS
select CLKDEV_LOOKUP
select HAVE_MACH_CLKDEV
- select GENERIC_GPIO
+ select ARCH_REQUIRE_GPIOLIB
help
Support for ST-Ericsson U300 series mobile platforms.
--
1.7.5.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 828 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110905/ab978c83/attachment.sig>
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO
2011-09-05 3:12 [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO Ben Hutchings
@ 2011-09-05 6:54 ` Arnaud Patard (Rtp)
2011-09-05 10:41 ` Russell King - ARM Linux
2011-09-05 12:41 ` [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO Linus Walleij
1 sibling, 1 reply; 10+ messages in thread
From: Arnaud Patard (Rtp) @ 2011-09-05 6:54 UTC (permalink / raw)
To: linux-arm-kernel
Ben Hutchings <ben@decadent.org.uk> writes:
Hi,
> The GPIO implementations for these two machines depend on gpiolib,
> so they must not select GENERIC_GPIO directly.
They're not calling gpiochip_add afaik so they should really only select
GENERIC_GPIO.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> This hould fix the build failure seen here:
> https://buildd.debian.org/status/fetch.php?pkg=linux-2.6&arch=armel&ver=3.1.0%7Erc4-1%7Eexperimental.1&stamp=1315007168
The problem here is that gpio_request_one has been added to the ads7846
driver but gpio_request_one is not defined in GENERIC_GPIO case (I
guess that other (arm and non-arm) platforms may hit similar troubles
with gpio_request_one. One quick fix would be to add a gpio_request_one
function say in asm-generic/gpio.h. One other fix would be to define
gpio_request_one and gpio_request_array in each
machine/platform/... specific header. Don't know what's the best
solution.
Arnaud
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO
2011-09-05 6:54 ` Arnaud Patard (Rtp)
@ 2011-09-05 10:41 ` Russell King - ARM Linux
2011-09-05 12:18 ` Arnaud Patard (Rtp)
2011-09-05 12:49 ` [RFC/PATCH] ARM: ixp4xx gpiolib support Imre Kaloz
0 siblings, 2 replies; 10+ messages in thread
From: Russell King - ARM Linux @ 2011-09-05 10:41 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Sep 05, 2011 at 08:54:30AM +0200, Arnaud Patard wrote:
> The problem here is that gpio_request_one has been added to the ads7846
> driver but gpio_request_one is not defined in GENERIC_GPIO case (I
> guess that other (arm and non-arm) platforms may hit similar troubles
> with gpio_request_one. One quick fix would be to add a gpio_request_one
> function say in asm-generic/gpio.h. One other fix would be to define
> gpio_request_one and gpio_request_array in each
> machine/platform/... specific header. Don't know what's the best
> solution.
It looks like gpio_request_one() and gpio_request_array() have been added
at the wrong level in the GPIO support code.
There's two levels to the GPIO support code:
1. GENERIC_GPIO - for platforms which use the gpio_* interfaces.
2. GPIOLIB - for platforms which want the gpio library for handling multiple
GPIO controllers.
There is nothing GPIOLIB specific to the gpio_request_*() interfaces, so
to put them in gpiolib.c and include/asm-generic/gpio.h seems rather silly.
On the other hand, for the single ARM kernel project, we do need everyone
to move to GPIOLIB so that the GPIO calls can be bound appropriately at
runtime - which means this problem goes away. So probably the right
solution is for IXP4xx etc to move over completely to gpiolib.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO
2011-09-05 10:41 ` Russell King - ARM Linux
@ 2011-09-05 12:18 ` Arnaud Patard (Rtp)
2011-09-05 12:49 ` [RFC/PATCH] ARM: ixp4xx gpiolib support Imre Kaloz
1 sibling, 0 replies; 10+ messages in thread
From: Arnaud Patard (Rtp) @ 2011-09-05 12:18 UTC (permalink / raw)
To: linux-arm-kernel
Russell King - ARM Linux <linux@arm.linux.org.uk> writes:
Hi,
> On Mon, Sep 05, 2011 at 08:54:30AM +0200, Arnaud Patard wrote:
>> The problem here is that gpio_request_one has been added to the ads7846
>> driver but gpio_request_one is not defined in GENERIC_GPIO case (I
>> guess that other (arm and non-arm) platforms may hit similar troubles
>> with gpio_request_one. One quick fix would be to add a gpio_request_one
>> function say in asm-generic/gpio.h. One other fix would be to define
>> gpio_request_one and gpio_request_array in each
>> machine/platform/... specific header. Don't know what's the best
>> solution.
>
> It looks like gpio_request_one() and gpio_request_array() have been added
> at the wrong level in the GPIO support code.
>
> There's two levels to the GPIO support code:
>
> 1. GENERIC_GPIO - for platforms which use the gpio_* interfaces.
> 2. GPIOLIB - for platforms which want the gpio library for handling multiple
> GPIO controllers.
>
> There is nothing GPIOLIB specific to the gpio_request_*() interfaces, so
> to put them in gpiolib.c and include/asm-generic/gpio.h seems rather silly.
>
> On the other hand, for the single ARM kernel project, we do need everyone
> to move to GPIOLIB so that the GPIO calls can be bound appropriately at
> runtime - which means this problem goes away. So probably the right
> solution is for IXP4xx etc to move over completely to gpiolib.
I thought about it but I considered it was too late to do that. I don't
think that moving to gpiolib u300/ixp4xx in -rc is a good idea. imho
doing it for next kernel is better but this won't solve the build
failure. Of course, you can tell me I'm plain wrong and I'll look at
converting them to gpiolib asap. Then we'll need some testers as I don't
have neither u300 nor ixp4xx systems.
Also, moving u300/ixp4xx to gpiolib will solve the issue for ARM but I
fear that other architectures may be affected by similar trouble.
Arnaud
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO
2011-09-05 3:12 [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO Ben Hutchings
2011-09-05 6:54 ` Arnaud Patard (Rtp)
@ 2011-09-05 12:41 ` Linus Walleij
2011-09-05 16:22 ` Ben Hutchings
1 sibling, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2011-09-05 12:41 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Sep 5, 2011 at 5:12 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
> @@ -830,7 +830,7 @@ config ARCH_U300
> ? ? ? ?select GENERIC_CLOCKEVENTS
> ? ? ? ?select CLKDEV_LOOKUP
> ? ? ? ?select HAVE_MACH_CLKDEV
> - ? ? ? select GENERIC_GPIO
> + ? ? ? select ARCH_REQUIRE_GPIOLIB
> ? ? ? ?help
> ? ? ? ? ?Support for ST-Ericsson U300 series mobile platforms.
Please don't do that, it really is no gpiolib implementation.
In the archives you can find patches I already submitted switching
the U300 GPIO over to use gpiolib.
However it fell to the ground due to the shortage of a mechanism
in gpiolib to configure pin bias. I could try to hack around it but
it would still be a hack :-(
I sent several patches trying to adress that issue, none have been
accepted.
So instead I venture into inventing the pin control subsystem which
is intended to handle complex controllers like these. It is at
version 7 right now.
Thanks,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC/PATCH] ARM: ixp4xx gpiolib support
2011-09-05 10:41 ` Russell King - ARM Linux
2011-09-05 12:18 ` Arnaud Patard (Rtp)
@ 2011-09-05 12:49 ` Imre Kaloz
2011-09-06 6:49 ` Arnaud Patard (Rtp)
2011-09-06 7:30 ` Uwe Kleine-König
1 sibling, 2 replies; 10+ messages in thread
From: Imre Kaloz @ 2011-09-05 12:49 UTC (permalink / raw)
To: linux-arm-kernel
This patch adds gpiolib support for the IXP4xx platform
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
---
arch/arm/Kconfig | 2 +-
arch/arm/mach-ixp4xx/common.c | 39 +++++++++++++++++++++++++
arch/arm/mach-ixp4xx/include/mach/gpio.h | 46 ++++++++++--------------------
3 files changed, 55 insertions(+), 32 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3269576..e793a75 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -481,7 +481,7 @@ config ARCH_IXP4XX
depends on MMU
select CLKSRC_MMIO
select CPU_XSCALE
- select GENERIC_GPIO
+ select ARCH_REQUIRE_GPIOLIB
select GENERIC_CLOCKEVENTS
select HAVE_SCHED_CLOCK
select MIGHT_HAVE_PCI
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 0777257..7603456 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -36,6 +36,7 @@
#include <asm/page.h>
#include <asm/irq.h>
#include <asm/sched_clock.h>
+#include <asm/gpio.h>
#include <asm/mach/map.h>
#include <asm/mach/irq.h>
@@ -375,12 +376,50 @@ static struct platform_device *ixp46x_devices[] __initdata = {
unsigned long ixp4xx_exp_bus_size;
EXPORT_SYMBOL(ixp4xx_exp_bus_size);
+static int ixp4xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
+{
+ gpio_line_config(gpio, IXP4XX_GPIO_IN);
+ return 0;
+}
+
+static int ixp4xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
+{
+ gpio_line_set(gpio, level);
+ gpio_line_config(gpio, IXP4XX_GPIO_OUT);
+ return 0;
+}
+
+static int ixp4xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
+{
+ int value;
+
+ gpio_line_get(gpio, &value);
+ return value;
+}
+
+static void ixp4xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
+{
+ gpio_line_set(gpio, value);
+}
+
+static struct gpio_chip ixp4xx_gpio_chip = {
+ .label = "IXP4XX_GPIO_CHIP",
+ .direction_input = ixp4xx_gpio_direction_input,
+ .direction_output = ixp4xx_gpio_direction_output,
+ .get = ixp4xx_gpio_get_value,
+ .set = ixp4xx_gpio_set_value,
+ .base = 0,
+ .ngpio = 16,
+};
+
void __init ixp4xx_sys_init(void)
{
ixp4xx_exp_bus_size = SZ_16M;
platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices));
+ gpiochip_add(&ixp4xx_gpio_chip);
+
if (cpu_is_ixp46x()) {
int region;
diff --git a/arch/arm/mach-ixp4xx/include/mach/gpio.h b/arch/arm/mach-ixp4xx/include/mach/gpio.h
index a5f87de..86f3596 100644
--- a/arch/arm/mach-ixp4xx/include/mach/gpio.h
+++ b/arch/arm/mach-ixp4xx/include/mach/gpio.h
@@ -27,47 +27,31 @@
#include <linux/kernel.h>
#include <mach/hardware.h>
+#include <asm-generic/gpio.h> /* cansleep wrappers */
-static inline int gpio_request(unsigned gpio, const char *label)
-{
- return 0;
-}
-
-static inline void gpio_free(unsigned gpio)
-{
- might_sleep();
-
- return;
-}
-
-static inline int gpio_direction_input(unsigned gpio)
-{
- gpio_line_config(gpio, IXP4XX_GPIO_IN);
- return 0;
-}
-
-static inline int gpio_direction_output(unsigned gpio, int level)
-{
- gpio_line_set(gpio, level);
- gpio_line_config(gpio, IXP4XX_GPIO_OUT);
- return 0;
-}
+#define NR_BUILTIN_GPIO 16
static inline int gpio_get_value(unsigned gpio)
{
- int value;
-
- gpio_line_get(gpio, &value);
-
- return value;
+ if (gpio < NR_BUILTIN_GPIO)
+ {
+ int value;
+ gpio_line_get(gpio, &value);
+ return value;
+ }
+ else
+ return __gpio_get_value(gpio);
}
static inline void gpio_set_value(unsigned gpio, int value)
{
- gpio_line_set(gpio, value);
+ if (gpio < NR_BUILTIN_GPIO)
+ gpio_line_set(gpio, value);
+ else
+ __gpio_set_value(gpio, value);
}
-#include <asm-generic/gpio.h> /* cansleep wrappers */
+#define gpio_cansleep __gpio_cansleep
extern int gpio_to_irq(int gpio);
extern int irq_to_gpio(unsigned int irq);
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO
2011-09-05 12:41 ` [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO Linus Walleij
@ 2011-09-05 16:22 ` Ben Hutchings
2011-09-06 7:26 ` Linus Walleij
0 siblings, 1 reply; 10+ messages in thread
From: Ben Hutchings @ 2011-09-05 16:22 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Sep 05, 2011 at 02:41:30PM +0200, Linus Walleij wrote:
> On Mon, Sep 5, 2011 at 5:12 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
>
> > @@ -830,7 +830,7 @@ config ARCH_U300
> > ? ? ? ?select GENERIC_CLOCKEVENTS
> > ? ? ? ?select CLKDEV_LOOKUP
> > ? ? ? ?select HAVE_MACH_CLKDEV
> > - ? ? ? select GENERIC_GPIO
> > + ? ? ? select ARCH_REQUIRE_GPIOLIB
> > ? ? ? ?help
> > ? ? ? ? ?Support for ST-Ericsson U300 series mobile platforms.
>
> Please don't do that, it really is no gpiolib implementation.
>
> In the archives you can find patches I already submitted switching
> the U300 GPIO over to use gpiolib.
[...]
OK. But it doesn't seem to work without gpiolib either:
CC [M] drivers/input/touchscreen/ads7846.o
drivers/input/touchscreen/ads7846.c: In function 'ads7846_setup_pendown':
drivers/input/touchscreen/ads7846.c:970:3: error: implicit declaration of function 'gpio_request_one'
Ben.
--
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
- Albert Camus
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC/PATCH] ARM: ixp4xx gpiolib support
2011-09-05 12:49 ` [RFC/PATCH] ARM: ixp4xx gpiolib support Imre Kaloz
@ 2011-09-06 6:49 ` Arnaud Patard (Rtp)
2011-09-06 7:30 ` Uwe Kleine-König
1 sibling, 0 replies; 10+ messages in thread
From: Arnaud Patard (Rtp) @ 2011-09-06 6:49 UTC (permalink / raw)
To: linux-arm-kernel
Imre Kaloz <kaloz@openwrt.org> writes:
Hi,
I can't test it but it looks good. Just small nitpicks. See below.
> This patch adds gpiolib support for the IXP4xx platform
>
> Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
> ---
> arch/arm/Kconfig | 2 +-
> arch/arm/mach-ixp4xx/common.c | 39 +++++++++++++++++++++++++
> arch/arm/mach-ixp4xx/include/mach/gpio.h | 46 ++++++++++--------------------
> 3 files changed, 55 insertions(+), 32 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 3269576..e793a75 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -481,7 +481,7 @@ config ARCH_IXP4XX
> depends on MMU
> select CLKSRC_MMIO
> select CPU_XSCALE
> - select GENERIC_GPIO
> + select ARCH_REQUIRE_GPIOLIB
> select GENERIC_CLOCKEVENTS
> select HAVE_SCHED_CLOCK
> select MIGHT_HAVE_PCI
> diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
> index 0777257..7603456 100644
> --- a/arch/arm/mach-ixp4xx/common.c
> +++ b/arch/arm/mach-ixp4xx/common.c
> @@ -36,6 +36,7 @@
> #include <asm/page.h>
> #include <asm/irq.h>
> #include <asm/sched_clock.h>
> +#include <asm/gpio.h>
>
> #include <asm/mach/map.h>
> #include <asm/mach/irq.h>
> @@ -375,12 +376,50 @@ static struct platform_device *ixp46x_devices[] __initdata = {
> unsigned long ixp4xx_exp_bus_size;
> EXPORT_SYMBOL(ixp4xx_exp_bus_size);
>
> +static int ixp4xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
> +{
> + gpio_line_config(gpio, IXP4XX_GPIO_IN);
> + return 0;
> +}
> +
> +static int ixp4xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
> +{
> + gpio_line_set(gpio, level);
> + gpio_line_config(gpio, IXP4XX_GPIO_OUT);
> + return 0;
> +}
> +
> +static int ixp4xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
> +{
> + int value;
> +
> + gpio_line_get(gpio, &value);
> + return value;
> +}
> +
> +static void ixp4xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
> +{
> + gpio_line_set(gpio, value);
> +}
> +
> +static struct gpio_chip ixp4xx_gpio_chip = {
> + .label = "IXP4XX_GPIO_CHIP",
> + .direction_input = ixp4xx_gpio_direction_input,
> + .direction_output = ixp4xx_gpio_direction_output,
> + .get = ixp4xx_gpio_get_value,
> + .set = ixp4xx_gpio_set_value,
> + .base = 0,
> + .ngpio = 16,
Use NR_BUILTIN_GPIO instead of 16 ?
> +};
> +
> void __init ixp4xx_sys_init(void)
> {
> ixp4xx_exp_bus_size = SZ_16M;
>
> platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices));
>
> + gpiochip_add(&ixp4xx_gpio_chip);
> +
> if (cpu_is_ixp46x()) {
> int region;
>
> diff --git a/arch/arm/mach-ixp4xx/include/mach/gpio.h b/arch/arm/mach-ixp4xx/include/mach/gpio.h
> index a5f87de..86f3596 100644
> --- a/arch/arm/mach-ixp4xx/include/mach/gpio.h
> +++ b/arch/arm/mach-ixp4xx/include/mach/gpio.h
> @@ -27,47 +27,31 @@
>
> #include <linux/kernel.h>
> #include <mach/hardware.h>
> +#include <asm-generic/gpio.h> /* cansleep wrappers */
>
> -static inline int gpio_request(unsigned gpio, const char *label)
> -{
> - return 0;
> -}
> -
> -static inline void gpio_free(unsigned gpio)
> -{
> - might_sleep();
> -
> - return;
> -}
> -
> -static inline int gpio_direction_input(unsigned gpio)
> -{
> - gpio_line_config(gpio, IXP4XX_GPIO_IN);
> - return 0;
> -}
> -
> -static inline int gpio_direction_output(unsigned gpio, int level)
> -{
> - gpio_line_set(gpio, level);
> - gpio_line_config(gpio, IXP4XX_GPIO_OUT);
> - return 0;
> -}
> +#define NR_BUILTIN_GPIO 16
>
> static inline int gpio_get_value(unsigned gpio)
> {
> - int value;
> -
> - gpio_line_get(gpio, &value);
> -
> - return value;
> + if (gpio < NR_BUILTIN_GPIO)
> + {
> + int value;
> + gpio_line_get(gpio, &value);
> + return value;
> + }
> + else
> + return __gpio_get_value(gpio);
Please use
if () {
} else
I would also put the 'int value' declaration outside the if ().
Thanks,
Arnaud
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO
2011-09-05 16:22 ` Ben Hutchings
@ 2011-09-06 7:26 ` Linus Walleij
0 siblings, 0 replies; 10+ messages in thread
From: Linus Walleij @ 2011-09-06 7:26 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Sep 5, 2011 at 6:22 PM, Ben Hutchings <ben@decadent.org.uk> wrote:
> On Mon, Sep 05, 2011 at 02:41:30PM +0200, Linus Walleij wrote:
>> On Mon, Sep 5, 2011 at 5:12 AM, Ben Hutchings <ben@decadent.org.uk> wrote:
>>
>> > @@ -830,7 +830,7 @@ config ARCH_U300
>> > ? ? ? ?select GENERIC_CLOCKEVENTS
>> > ? ? ? ?select CLKDEV_LOOKUP
>> > ? ? ? ?select HAVE_MACH_CLKDEV
>> > - ? ? ? select GENERIC_GPIO
>> > + ? ? ? select ARCH_REQUIRE_GPIOLIB
>> > ? ? ? ?help
>> > ? ? ? ? ?Support for ST-Ericsson U300 series mobile platforms.
>>
>> Please don't do that, it really is no gpiolib implementation.
>>
>> In the archives you can find patches I already submitted switching
>> the U300 GPIO over to use gpiolib.
> [...]
>
> OK. ?But it doesn't seem to work without gpiolib either:
>
> ?CC [M] ?drivers/input/touchscreen/ads7846.o
> drivers/input/touchscreen/ads7846.c: In function 'ads7846_setup_pendown':
> drivers/input/touchscreen/ads7846.c:970:3: error: implicit declaration of function 'gpio_request_one'
Yes.
I don't know a good way out of this really :-(
I'll start looking for the bad ways out, like hacking
the GPIO driver to do GPIOLIB in a not-so-elegant
way.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC/PATCH] ARM: ixp4xx gpiolib support
2011-09-05 12:49 ` [RFC/PATCH] ARM: ixp4xx gpiolib support Imre Kaloz
2011-09-06 6:49 ` Arnaud Patard (Rtp)
@ 2011-09-06 7:30 ` Uwe Kleine-König
1 sibling, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2011-09-06 7:30 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
On Mon, Sep 05, 2011 at 02:49:51PM +0200, Imre Kaloz wrote:
> This patch adds gpiolib support for the IXP4xx platform
>
> Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
> ---
> arch/arm/Kconfig | 2 +-
> arch/arm/mach-ixp4xx/common.c | 39 +++++++++++++++++++++++++
> arch/arm/mach-ixp4xx/include/mach/gpio.h | 46 ++++++++++--------------------
> 3 files changed, 55 insertions(+), 32 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 3269576..e793a75 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -481,7 +481,7 @@ config ARCH_IXP4XX
> depends on MMU
> select CLKSRC_MMIO
> select CPU_XSCALE
> - select GENERIC_GPIO
> + select ARCH_REQUIRE_GPIOLIB
> select GENERIC_CLOCKEVENTS
> select HAVE_SCHED_CLOCK
> select MIGHT_HAVE_PCI
> diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
> index 0777257..7603456 100644
> --- a/arch/arm/mach-ixp4xx/common.c
> +++ b/arch/arm/mach-ixp4xx/common.c
> @@ -36,6 +36,7 @@
> #include <asm/page.h>
> #include <asm/irq.h>
> #include <asm/sched_clock.h>
> +#include <asm/gpio.h>
>
> #include <asm/mach/map.h>
> #include <asm/mach/irq.h>
> @@ -375,12 +376,50 @@ static struct platform_device *ixp46x_devices[] __initdata = {
> unsigned long ixp4xx_exp_bus_size;
> EXPORT_SYMBOL(ixp4xx_exp_bus_size);
>
> +static int ixp4xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
> +{
> + gpio_line_config(gpio, IXP4XX_GPIO_IN);
> + return 0;
> +}
> +
> +static int ixp4xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
> +{
> + gpio_line_set(gpio, level);
> + gpio_line_config(gpio, IXP4XX_GPIO_OUT);
> + return 0;
> +}
> +
> +static int ixp4xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
> +{
> + int value;
> +
> + gpio_line_get(gpio, &value);
> + return value;
> +}
> +
> +static void ixp4xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
> +{
> + gpio_line_set(gpio, value);
> +}
> +
> +static struct gpio_chip ixp4xx_gpio_chip = {
> + .label = "IXP4XX_GPIO_CHIP",
> + .direction_input = ixp4xx_gpio_direction_input,
> + .direction_output = ixp4xx_gpio_direction_output,
> + .get = ixp4xx_gpio_get_value,
> + .set = ixp4xx_gpio_set_value,
> + .base = 0,
> + .ngpio = 16,
> +};
> +
> void __init ixp4xx_sys_init(void)
> {
> ixp4xx_exp_bus_size = SZ_16M;
>
> platform_add_devices(ixp4xx_devices, ARRAY_SIZE(ixp4xx_devices));
>
> + gpiochip_add(&ixp4xx_gpio_chip);
> +
> if (cpu_is_ixp46x()) {
> int region;
>
> diff --git a/arch/arm/mach-ixp4xx/include/mach/gpio.h b/arch/arm/mach-ixp4xx/include/mach/gpio.h
> index a5f87de..86f3596 100644
> --- a/arch/arm/mach-ixp4xx/include/mach/gpio.h
> +++ b/arch/arm/mach-ixp4xx/include/mach/gpio.h
> @@ -27,47 +27,31 @@
>
> #include <linux/kernel.h>
> #include <mach/hardware.h>
> +#include <asm-generic/gpio.h> /* cansleep wrappers */
>
> -static inline int gpio_request(unsigned gpio, const char *label)
> -{
> - return 0;
> -}
> -
> -static inline void gpio_free(unsigned gpio)
> -{
> - might_sleep();
> -
> - return;
> -}
> -
> -static inline int gpio_direction_input(unsigned gpio)
> -{
> - gpio_line_config(gpio, IXP4XX_GPIO_IN);
> - return 0;
> -}
> -
> -static inline int gpio_direction_output(unsigned gpio, int level)
> -{
> - gpio_line_set(gpio, level);
> - gpio_line_config(gpio, IXP4XX_GPIO_OUT);
> - return 0;
> -}
> +#define NR_BUILTIN_GPIO 16
>
> static inline int gpio_get_value(unsigned gpio)
> {
> - int value;
> -
> - gpio_line_get(gpio, &value);
> -
> - return value;
> + if (gpio < NR_BUILTIN_GPIO)
you might want to test the impact of using
if (__builtin_constant_p(gpio) && gpio < NR_BUILTIN_GPIO)
here. I don't know what to expect from it, but this is the idiom I saw
when I implemented gpio stuff some years ago.
> + {
> + int value;
> + gpio_line_get(gpio, &value);
> + return value;
I wonder about the return value of gpio_line_get. If it's void why not
change it to return the value instead of using an output parameter.
> + }
> + else
> + return __gpio_get_value(gpio);
> }
>
> static inline void gpio_set_value(unsigned gpio, int value)
> {
> - gpio_line_set(gpio, value);
> + if (gpio < NR_BUILTIN_GPIO)
> + gpio_line_set(gpio, value);
> + else
> + __gpio_set_value(gpio, value);
> }
>
> -#include <asm-generic/gpio.h> /* cansleep wrappers */
> +#define gpio_cansleep __gpio_cansleep
>
> extern int gpio_to_irq(int gpio);
> extern int irq_to_gpio(unsigned int irq);
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-09-06 7:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-05 3:12 [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO Ben Hutchings
2011-09-05 6:54 ` Arnaud Patard (Rtp)
2011-09-05 10:41 ` Russell King - ARM Linux
2011-09-05 12:18 ` Arnaud Patard (Rtp)
2011-09-05 12:49 ` [RFC/PATCH] ARM: ixp4xx gpiolib support Imre Kaloz
2011-09-06 6:49 ` Arnaud Patard (Rtp)
2011-09-06 7:30 ` Uwe Kleine-König
2011-09-05 12:41 ` [PATCH] arm: ixp4xx, u300: Select ARCH_REQUIRE_GPIOLIB, not GENERIC_GPIO Linus Walleij
2011-09-05 16:22 ` Ben Hutchings
2011-09-06 7:26 ` Linus Walleij
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).