Re: [PATCH 02/10] mach-u300: rewrite gpio driver, move to drivers/gpio

From: Barry Song
Date: Thu May 19 2011 - 07:12:23 EST


2011/4/27 Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>:
> From: Linus Walleij <linus.walleij@xxxxxxxxxx>
>
> This rewrites the U300 GPIO driver using gpiolib and the irq_chip
> abstractions, makes it runtime-configured rather than compile-time,
> and moves it to the drivers/gpio subsystem where it belongs,
> depopulating the ARM tree of one more driver.
>
> Cc: Jonas Aaberg <jonas.aberg@xxxxxxxxxxxxxx>
> Acked-by: Arnd Bergmann <arnd@xxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---
> Âarch/arm/Kconfig            |  Â2 +-
> Âarch/arm/mach-u300/Kconfig       |  Â1 +
> Âarch/arm/mach-u300/Makefile      Â|  Â6 +-
> Âarch/arm/mach-u300/core.c       Â|  31 ++-
> Âarch/arm/mach-u300/gpio.c       Â| Â700 --------------------------
> Âarch/arm/mach-u300/include/mach/gpio.h | Â163 +------
> Âarch/arm/mach-u300/include/mach/irqs.h | Â 25 +-
> Âdrivers/gpio/Kconfig          |  Â9 +
> Âdrivers/gpio/Makefile         Â|  Â1 +
> Âdrivers/gpio/u300-gpio.c        | Â836 ++++++++++++++++++++++++++++++++
> Âinclude/linux/gpio/u300.h       Â|  32 ++
> Â11 files changed, 932 insertions(+), 874 deletions(-)
> Âdelete mode 100644 arch/arm/mach-u300/gpio.c
> Âcreate mode 100644 drivers/gpio/u300-gpio.c
> Âcreate mode 100644 include/linux/gpio/u300.h
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index 377a7a5..5fb980d 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -820,7 +820,7 @@ config ARCH_U300
> Â Â Â Âselect ARM_VIC
> Â Â Â Âselect GENERIC_CLOCKEVENTS
> Â Â Â Âselect CLKDEV_LOOKUP
> - Â Â Â select GENERIC_GPIO
> + Â Â Â select ARCH_REQUIRE_GPIOLIB
> Â Â Â Âhelp
> Â Â Â Â ÂSupport for ST-Ericsson U300 series mobile platforms.
>
> diff --git a/arch/arm/mach-u300/Kconfig b/arch/arm/mach-u300/Kconfig
> index 32a7b0f..7b5c229 100644
> --- a/arch/arm/mach-u300/Kconfig
> +++ b/arch/arm/mach-u300/Kconfig
> @@ -6,6 +6,7 @@ comment "ST-Ericsson Mobile Platform Products"
>
> Âconfig MACH_U300
> Â Â Â Âbool "U300"
> + Â Â Â select GPIO_U300
>
> Âcomment "ST-Ericsson U300/U330/U335/U365 Feature Selections"
>
> diff --git a/arch/arm/mach-u300/Makefile b/arch/arm/mach-u300/Makefile
> index fab46fe..73da230 100644
> --- a/arch/arm/mach-u300/Makefile
> +++ b/arch/arm/mach-u300/Makefile
> @@ -2,11 +2,7 @@
> Â# Makefile for the linux kernel, U300 machine.
> Â#
>
> -obj-y     Â:= core.o clock.o timer.o gpio.o padmux.o
> -obj-m     Â:=
> -obj-n     Â:=
> -obj- Â Â Â Â Â :=
> -
> +obj-y             Â:= core.o clock.o timer.o padmux.o
> Âobj-$(CONFIG_ARCH_U300) Â Â Â Â Â Â Â Â Â+= u300.o
> Âobj-$(CONFIG_MMC) Â Â Â Â Â Â Â Â += mmc.o
> Âobj-$(CONFIG_SPI_PL022) Â Â Â Â Â += spi.o
> diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
> index 513d6ab..ddb604c 100644
> --- a/arch/arm/mach-u300/core.c
> +++ b/arch/arm/mach-u300/core.c
> @@ -25,6 +25,7 @@
> Â#include <linux/err.h>
> Â#include <linux/mtd/nand.h>
> Â#include <linux/mtd/fsmc.h>
> +#include <linux/gpio/u300.h>
>
> Â#include <asm/types.h>
> Â#include <asm/setup.h>
> @@ -239,7 +240,7 @@ static struct resource gpio_resources[] = {
>        Â.end  = IRQ_U300_GPIO_PORT2,
> Â Â Â Â Â Â Â Â.flags = IORESOURCE_IRQ,
> Â Â Â Â},
> -#ifdef U300_COH901571_3
> +#if defined(CONFIG_MACH_U300_BS365) || defined(CONFIG_MACH_U300_BS335)
> Â Â Â Â{
> Â Â Â Â Â Â Â Â.name Â= "gpio3",
> Â Â Â Â Â Â Â Â.start = IRQ_U300_GPIO_PORT3,
> @@ -252,6 +253,7 @@ static struct resource gpio_resources[] = {
>        Â.end  = IRQ_U300_GPIO_PORT4,
> Â Â Â Â Â Â Â Â.flags = IORESOURCE_IRQ,
> Â Â Â Â},
> +#endif
> Â#ifdef CONFIG_MACH_U300_BS335
> Â Â Â Â{
> Â Â Â Â Â Â Â Â.name Â= "gpio5",
> @@ -266,7 +268,6 @@ static struct resource gpio_resources[] = {
> Â Â Â Â Â Â Â Â.flags = IORESOURCE_IRQ,
> Â Â Â Â},
> Â#endif /* CONFIG_MACH_U300_BS335 */
> -#endif /* U300_COH901571_3 */
> Â};
>
> Âstatic struct resource keypad_resources[] = {
> @@ -1556,11 +1557,35 @@ static struct platform_device i2c1_device = {
> Â Â Â Â.resource = i2c1_resources,
> Â};
>
> +/*
> + * The different variants have a few different versions of the
> + * GPIO block, with different number of ports.
> + */
> +static struct u300_gpio_platform u300_gpio_plat = {
> +#if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330)
> + Â Â Â .variant = U300_GPIO_COH901335,
> + Â Â Â .ports = 3,
> +#endif
> +#ifdef CONFIG_MACH_U300_BS335
> + Â Â Â .variant = U300_GPIO_COH901571_3_BS335,
> + Â Â Â .ports = 7,
> +#endif
> +#ifdef CONFIG_MACH_U300_BS365
> + Â Â Â .variant = U300_GPIO_COH901571_3_BS365,
> + Â Â Â .ports = 5,
> +#endif
> + Â Â Â .gpio_base = 0,
> + Â Â Â .gpio_irq_base = IRQ_U300_GPIO_BASE,
> +};
> +
> Âstatic struct platform_device gpio_device = {
> Â Â Â Â.name = "u300-gpio",
> Â Â Â Â.id = -1,
> Â Â Â Â.num_resources = ARRAY_SIZE(gpio_resources),
> Â Â Â Â.resource = gpio_resources,
> + Â Â Â .dev = {
> + Â Â Â Â Â Â Â .platform_data = &u300_gpio_plat,
> + Â Â Â },
> Â};
>
> Âstatic struct platform_device keypad_device = {
> @@ -1666,7 +1691,7 @@ void __init u300_init_irq(void)
> Â Â Â ÂBUG_ON(IS_ERR(clk));
> Â Â Â Âclk_enable(clk);
>
> - Â Â Â for (i = 0; i < NR_IRQS; i++)
> + Â Â Â for (i = 0; i < U300_VIC_IRQS_END; i++)
> Â Â Â Â Â Â Â Âset_bit(i, (unsigned long *) &mask[0]);
> Â Â Â Âvic_init((void __iomem *) U300_INTCON0_VBASE, 0, mask[0], mask[0]);
> Â Â Â Âvic_init((void __iomem *) U300_INTCON1_VBASE, 32, mask[1], mask[1]);
> diff --git a/arch/arm/mach-u300/gpio.c b/arch/arm/mach-u300/gpio.c
> deleted file mode 100644
> index d927901..0000000
> --- a/arch/arm/mach-u300/gpio.c
> +++ /dev/null
> @@ -1,700 +0,0 @@
> -/*
> - *
> - * arch/arm/mach-u300/gpio.c
> - *
> - *
> - * Copyright (C) 2007-2009 ST-Ericsson AB
> - * License terms: GNU General Public License (GPL) version 2
> - * U300 GPIO module.
> - * This can driver either of the two basic GPIO cores
> - * available in the U300 platforms:
> - * COH 901 335 Â - Used in DB3150 (U300 1.0) and DB3200 (U330 1.0)
> - * COH 901 571/3 - Used in DB3210 (U365 2.0) and DB3350 (U335 1.0)
> - * Notice that you also have inline macros in <asm-arch/gpio.h>
> - * Author: Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>
> - * Author: Jonas Aaberg <jonas.aberg@xxxxxxxxxxxxxx>
> - *
> - */
> -#include <linux/module.h>
> -#include <linux/interrupt.h>
> -#include <linux/delay.h>
> -#include <linux/errno.h>
> -#include <linux/io.h>
> -#include <linux/clk.h>
> -#include <linux/err.h>
> -#include <linux/platform_device.h>
> -#include <linux/gpio.h>
> -
> -/* Reference to GPIO block clock */
> -static struct clk *clk;
> -
> -/* Memory resource */
> -static struct resource *memres;
> -static void __iomem *virtbase;
> -static struct device *gpiodev;
> -
> -struct u300_gpio_port {
> - Â Â Â const char *name;
> - Â Â Â int irq;
> - Â Â Â int number;
> -};
> -
> -
> -static struct u300_gpio_port gpio_ports[] = {
> - Â Â Â {
> - Â Â Â Â Â Â Â .name = "gpio0",
> - Â Â Â Â Â Â Â .number = 0,
> - Â Â Â },
> - Â Â Â {
> - Â Â Â Â Â Â Â .name = "gpio1",
> - Â Â Â Â Â Â Â .number = 1,
> - Â Â Â },
> - Â Â Â {
> - Â Â Â Â Â Â Â .name = "gpio2",
> - Â Â Â Â Â Â Â .number = 2,
> - Â Â Â },
> -#ifdef U300_COH901571_3
> - Â Â Â {
> - Â Â Â Â Â Â Â .name = "gpio3",
> - Â Â Â Â Â Â Â .number = 3,
> - Â Â Â },
> - Â Â Â {
> - Â Â Â Â Â Â Â .name = "gpio4",
> - Â Â Â Â Â Â Â .number = 4,
> - Â Â Â },
> -#ifdef CONFIG_MACH_U300_BS335
> - Â Â Â {
> - Â Â Â Â Â Â Â .name = "gpio5",
> - Â Â Â Â Â Â Â .number = 5,
> - Â Â Â },
> - Â Â Â {
> - Â Â Â Â Â Â Â .name = "gpio6",
> - Â Â Â Â Â Â Â .number = 6,
> - Â Â Â },
> -#endif
> -#endif
> -
> -};
> -
> -
> -#ifdef U300_COH901571_3
> -
> -/* Default input value */
> -#define DEFAULT_OUTPUT_LOW Â 0
> -#define DEFAULT_OUTPUT_HIGH Â1
> -
> -/* GPIO Pull-Up status */
> -#define DISABLE_PULL_UP Â0
> -#define ENABLE_PULL_UP Â1
> -
> -#define GPIO_NOT_USED 0
> -#define GPIO_IN Â Â Â 1
> -#define GPIO_OUT Â Â Â2
> -
> -struct u300_gpio_configuration_data {
> - Â Â Â unsigned char pin_usage;
> - Â Â Â unsigned char default_output_value;
> - Â Â Â unsigned char pull_up;
> -};
> -
> -/* Initial configuration */
> -const struct u300_gpio_configuration_data
> -u300_gpio_config[U300_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = {
> -#ifdef CONFIG_MACH_U300_BS335
> - Â Â Â /* Port 0, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_HIGH, ÂDISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 1, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_HIGH, ÂDISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 2, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 3, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 4, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 5, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 6, pind 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â }
> -#endif
> -
> -#ifdef CONFIG_MACH_U300_BS365
> - Â Â Â /* Port 0, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 1, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_HIGH, ÂDISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 2, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â DISABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 3, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP}
> - Â Â Â },
> - Â Â Â /* Port 4, pins 0-7 */
> - Â Â Â {
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_IN, ÂDEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â /* These 4 pins doesn't exist on DB3210 */
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP},
> - Â Â Â Â Â Â Â {GPIO_OUT, DEFAULT_OUTPUT_LOW, Â ÂENABLE_PULL_UP}
> - Â Â Â }
> -#endif
> -};
> -#endif
> -
> -
> -/* No users == we can power down GPIO */
> -static int gpio_users;
> -
> -struct gpio_struct {
> - Â Â Â int (*callback)(void *);
> - Â Â Â void *data;
> - Â Â Â int users;
> -};
> -
> -static struct gpio_struct gpio_pin[U300_GPIO_MAX];
> -
> -/*
> - * Let drivers register callback in order to get notified when there is
> - * an interrupt on the gpio pin
> - */
> -int gpio_register_callback(unsigned gpio, int (*func)(void *arg), void *data)
> -{
> - Â Â Â if (gpio_pin[gpio].callback)
> - Â Â Â Â Â Â Â dev_warn(gpiodev, "%s: WARNING: callback already "
> - Â Â Â Â Â Â Â Â Â Â Â Â"registered for gpio pin#%d\n", __func__, gpio);
> - Â Â Â gpio_pin[gpio].callback = func;
> - Â Â Â gpio_pin[gpio].data = data;
> -
> - Â Â Â return 0;
> -}
> -EXPORT_SYMBOL(gpio_register_callback);
> -
> -int gpio_unregister_callback(unsigned gpio)
> -{
> - Â Â Â if (!gpio_pin[gpio].callback)
> - Â Â Â Â Â Â Â dev_warn(gpiodev, "%s: WARNING: callback already "
> - Â Â Â Â Â Â Â Â Â Â Â Â"unregistered for gpio pin#%d\n", __func__, gpio);
> - Â Â Â gpio_pin[gpio].callback = NULL;
> - Â Â Â gpio_pin[gpio].data = NULL;
> -
> - Â Â Â return 0;
> -}
> -EXPORT_SYMBOL(gpio_unregister_callback);
> -
> -/* Non-zero means valid */
> -int gpio_is_valid(int number)
> -{
> - Â Â Â if (number >= 0 &&
> - Â Â Â Â Â number < (U300_GPIO_NUM_PORTS * U300_GPIO_PINS_PER_PORT))
> - Â Â Â Â Â Â Â return 1;
> - Â Â Â return 0;
> -}
> -EXPORT_SYMBOL(gpio_is_valid);
> -
> -int gpio_request(unsigned gpio, const char *label)
> -{
> - Â Â Â if (gpio_pin[gpio].users)
> - Â Â Â Â Â Â Â return -EINVAL;
> - Â Â Â else
> - Â Â Â Â Â Â Â gpio_pin[gpio].users++;
> -
> - Â Â Â gpio_users++;
> -
> - Â Â Â return 0;
> -}
> -EXPORT_SYMBOL(gpio_request);
> -
> -void gpio_free(unsigned gpio)
> -{
> - Â Â Â gpio_users--;
> - Â Â Â gpio_pin[gpio].users--;
> - Â Â Â if (unlikely(gpio_pin[gpio].users < 0)) {
> - Â Â Â Â Â Â Â dev_warn(gpiodev, "warning: gpio#%d release mismatch\n",
> - Â Â Â Â Â Â Â Â Â Â Â Âgpio);
> - Â Â Â Â Â Â Â gpio_pin[gpio].users = 0;
> - Â Â Â }
> -
> - Â Â Â return;
> -}
> -EXPORT_SYMBOL(gpio_free);
> -
> -/* This returns zero or nonzero */
> -int gpio_get_value(unsigned gpio)
> -{
> - Â Â Â return readl(virtbase + U300_GPIO_PXPDIR +
> - Â Â Â Â PIN_TO_PORT(gpio) * U300_GPIO_PORTX_SPACING) & (1 << (gpio & 0x07));
> -}
> -EXPORT_SYMBOL(gpio_get_value);
> -
> -/*
> - * We hope that the compiler will optimize away the unused branch
> - * in case "value" is a constant
> - */
> -void gpio_set_value(unsigned gpio, int value)
> -{
> - Â Â Â u32 val;
> - Â Â Â unsigned long flags;
> -
> - Â Â Â local_irq_save(flags);
> - Â Â Â if (value) {
> - Â Â Â Â Â Â Â /* set */
> - Â Â Â Â Â Â Â val = readl(virtbase + U300_GPIO_PXPDOR +
> - Â Â Â Â Â Â Â Â PIN_TO_PORT(gpio) * U300_GPIO_PORTX_SPACING)
> - Â Â Â Â Â Â Â Â & (1 << (gpio & 0x07));
> - Â Â Â Â Â Â Â writel(val | (1 << (gpio & 0x07)), virtbase +
> - Â Â Â Â Â Â Â Â U300_GPIO_PXPDOR +
> - Â Â Â Â Â Â Â Â PIN_TO_PORT(gpio) * U300_GPIO_PORTX_SPACING);
> - Â Â Â } else {
> - Â Â Â Â Â Â Â /* clear */
> - Â Â Â Â Â Â Â val = readl(virtbase + U300_GPIO_PXPDOR +
> - Â Â Â Â Â Â Â Â PIN_TO_PORT(gpio) * U300_GPIO_PORTX_SPACING)
> - Â Â Â Â Â Â Â Â & (1 << (gpio & 0x07));
> - Â Â Â Â Â Â Â writel(val & ~(1 << (gpio & 0x07)), virtbase +
> - Â Â Â Â Â Â Â Â U300_GPIO_PXPDOR +
> - Â Â Â Â Â Â Â Â PIN_TO_PORT(gpio) * U300_GPIO_PORTX_SPACING);
> - Â Â Â }
> - Â Â Â local_irq_restore(flags);
> -}
> -EXPORT_SYMBOL(gpio_set_value);
> -
> -int gpio_direction_input(unsigned gpio)
> -{
> - Â Â Â unsigned long flags;
> - Â Â Â u32 val;
> -
> - Â Â Â if (gpio > U300_GPIO_MAX)
> - Â Â Â Â Â Â Â return -EINVAL;
> -
> - Â Â Â local_irq_save(flags);
> - Â Â Â val = readl(virtbase + U300_GPIO_PXPCR + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â /* Mask out this pin*/
> - Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK << ((gpio & 0x07) << 1));
> - Â Â Â /* This is not needed since it sets the bits to zero.*/
> - Â Â Â /* val |= (U300_GPIO_PXPCR_PIN_MODE_INPUT << (gpio*2)); */
> - Â Â Â writel(val, virtbase + U300_GPIO_PXPCR + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â local_irq_restore(flags);
> - Â Â Â return 0;
> -}
> -EXPORT_SYMBOL(gpio_direction_input);
> -
> -int gpio_direction_output(unsigned gpio, int value)
> -{
> - Â Â Â unsigned long flags;
> - Â Â Â u32 val;
> -
> - Â Â Â if (gpio > U300_GPIO_MAX)
> - Â Â Â Â Â Â Â return -EINVAL;
> -
> - Â Â Â local_irq_save(flags);
> - Â Â Â val = readl(virtbase + U300_GPIO_PXPCR + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â /* Mask out this pin */
> - Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK << ((gpio & 0x07) << 1));
> - Â Â Â /*
> - Â Â Â Â* FIXME: configure for push/pull, open drain or open source per pin
> - Â Â Â Â* in setup. The current driver will only support push/pull.
> - Â Â Â Â*/
> - Â Â Â val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL
> - Â Â Â Â Â Â Â Â Â Â Â << ((gpio & 0x07) << 1));
> - Â Â Â writel(val, virtbase + U300_GPIO_PXPCR + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â gpio_set_value(gpio, value);
> - Â Â Â local_irq_restore(flags);
> - Â Â Â return 0;
> -}
> -EXPORT_SYMBOL(gpio_direction_output);
> -
> -/*
> - * Enable an IRQ, edge is rising edge (!= 0) or falling edge (==0).
> - */
> -void enable_irq_on_gpio_pin(unsigned gpio, int edge)
> -{
> - Â Â Â u32 val;
> - Â Â Â unsigned long flags;
> - Â Â Â local_irq_save(flags);
> -
> - Â Â Â val = readl(virtbase + U300_GPIO_PXIEN + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â val |= (1 << (gpio & 0x07));
> - Â Â Â writel(val, virtbase + U300_GPIO_PXIEN + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â val = readl(virtbase + U300_GPIO_PXICR + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â if (edge)
> - Â Â Â Â Â Â Â val |= (1 << (gpio & 0x07));
> - Â Â Â else
> - Â Â Â Â Â Â Â val &= ~(1 << (gpio & 0x07));
> - Â Â Â writel(val, virtbase + U300_GPIO_PXICR + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â local_irq_restore(flags);
> -}
> -EXPORT_SYMBOL(enable_irq_on_gpio_pin);
> -
> -void disable_irq_on_gpio_pin(unsigned gpio)
> -{
> - Â Â Â u32 val;
> - Â Â Â unsigned long flags;
> -
> - Â Â Â local_irq_save(flags);
> - Â Â Â val = readl(virtbase + U300_GPIO_PXIEN + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â val &= ~(1 << (gpio & 0x07));
> - Â Â Â writel(val, virtbase + U300_GPIO_PXIEN + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â local_irq_restore(flags);
> -}
> -EXPORT_SYMBOL(disable_irq_on_gpio_pin);
> -
> -/* Enable (value == 0) or disable (value == 1) internal pullup */
> -void gpio_pullup(unsigned gpio, int value)
> -{
> - Â Â Â u32 val;
> - Â Â Â unsigned long flags;
> -
> - Â Â Â local_irq_save(flags);
> - Â Â Â if (value) {
> - Â Â Â Â Â Â Â val = readl(virtbase + U300_GPIO_PXPER + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â Â Â Â Â writel(val | (1 << (gpio & 0x07)), virtbase + U300_GPIO_PXPER +
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â PIN_TO_PORT(gpio) * U300_GPIO_PORTX_SPACING);
> - Â Â Â } else {
> - Â Â Â Â Â Â Â val = readl(virtbase + U300_GPIO_PXPER + PIN_TO_PORT(gpio) *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â Â Â Â Â writel(val & ~(1 << (gpio & 0x07)), virtbase + U300_GPIO_PXPER +
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â PIN_TO_PORT(gpio) * U300_GPIO_PORTX_SPACING);
> - Â Â Â }
> - Â Â Â local_irq_restore(flags);
> -}
> -EXPORT_SYMBOL(gpio_pullup);
> -
> -static irqreturn_t gpio_irq_handler(int irq, void *dev_id)
> -{
> - Â Â Â struct u300_gpio_port *port = dev_id;
> - Â Â Â u32 val;
> - Â Â Â int pin;
> -
> - Â Â Â /* Read event register */
> - Â Â Â val = readl(virtbase + U300_GPIO_PXIEV + port->number *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â /* Mask with enable register */
> - Â Â Â val &= readl(virtbase + U300_GPIO_PXIEV + port->number *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â /* Mask relevant bits */
> - Â Â Â val &= U300_GPIO_PXIEV_ALL_IRQ_EVENT_MASK;
> - Â Â Â /* ACK IRQ (clear event) */
> - Â Â Â writel(val, virtbase + U300_GPIO_PXIEV + port->number *
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â U300_GPIO_PORTX_SPACING);
> - Â Â Â /* Print message */
> - Â Â Â while (val != 0) {
> - Â Â Â Â Â Â Â unsigned gpio;
> -
> - Â Â Â Â Â Â Â pin = __ffs(val);
> - Â Â Â Â Â Â Â /* mask off this pin */
> - Â Â Â Â Â Â Â val &= ~(1 << pin);
> - Â Â Â Â Â Â Â gpio = (port->number << 3) + pin;
> -
> - Â Â Â Â Â Â Â if (gpio_pin[gpio].callback)
> - Â Â Â Â Â Â Â Â Â Â Â (void)gpio_pin[gpio].callback(gpio_pin[gpio].data);
> - Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â dev_dbg(gpiodev, "stray GPIO IRQ on line %d\n",
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âgpio);
> - Â Â Â }
> - Â Â Â return IRQ_HANDLED;
> -}
> -
> -static void gpio_set_initial_values(void)
> -{
> -#ifdef U300_COH901571_3
> - Â Â Â int i, j;
> - Â Â Â unsigned long flags;
> - Â Â Â u32 val;
> -
> - Â Â Â /* Write default values to all pins */
> - Â Â Â for (i = 0; i < U300_GPIO_NUM_PORTS; i++) {
> - Â Â Â Â Â Â Â val = 0;
> - Â Â Â Â Â Â Â for (j = 0; j < 8; j++)
> - Â Â Â Â Â Â Â Â Â Â Â val |= (u32) (u300_gpio_config[i][j].default_output_value != DEFAULT_OUTPUT_LOW) << j;
> - Â Â Â Â Â Â Â local_irq_save(flags);
> - Â Â Â Â Â Â Â writel(val, virtbase + U300_GPIO_PXPDOR + i * U300_GPIO_PORTX_SPACING);
> - Â Â Â Â Â Â Â local_irq_restore(flags);
> - Â Â Â }
> -
> - Â Â Â /*
> - Â Â Â Â* Put all pins that are set to either 'GPIO_OUT' or 'GPIO_NOT_USED'
> - Â Â Â Â* to output and 'GPIO_IN' to input for each port. And initialize
> - Â Â Â Â* default value on outputs.
> - Â Â Â Â*/
> - Â Â Â for (i = 0; i < U300_GPIO_NUM_PORTS; i++) {
> - Â Â Â Â Â Â Â for (j = 0; j < U300_GPIO_PINS_PER_PORT; j++) {
> - Â Â Â Â Â Â Â Â Â Â Â local_irq_save(flags);
> - Â Â Â Â Â Â Â Â Â Â Â val = readl(virtbase + U300_GPIO_PXPCR +
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âi * U300_GPIO_PORTX_SPACING);
> - Â Â Â Â Â Â Â Â Â Â Â /* Mask out this pin */
> - Â Â Â Â Â Â Â Â Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK << (j << 1));
> -
> - Â Â Â Â Â Â Â Â Â Â Â if (u300_gpio_config[i][j].pin_usage != GPIO_IN)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL << (j << 1));
> - Â Â Â Â Â Â Â Â Â Â Â writel(val, virtbase + U300_GPIO_PXPCR +
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âi * U300_GPIO_PORTX_SPACING);
> - Â Â Â Â Â Â Â Â Â Â Â local_irq_restore(flags);
> - Â Â Â Â Â Â Â }
> - Â Â Â }
> -
> - Â Â Â /* Enable or disable the internal pull-ups in the GPIO ASIC block */
> - Â Â Â for (i = 0; i < U300_GPIO_MAX; i++) {
> - Â Â Â Â Â Â Â val = 0;
> - Â Â Â Â Â Â Â for (j = 0; j < 8; j++)
> - Â Â Â Â Â Â Â Â Â Â Â val |= (u32)((u300_gpio_config[i][j].pull_up == DISABLE_PULL_UP) << j);
> - Â Â Â Â Â Â Â local_irq_save(flags);
> - Â Â Â Â Â Â Â writel(val, virtbase + U300_GPIO_PXPER + i * U300_GPIO_PORTX_SPACING);
> - Â Â Â Â Â Â Â local_irq_restore(flags);
> - Â Â Â }
> -#endif
> -}
> -
> -static int __init gpio_probe(struct platform_device *pdev)
> -{
> - Â Â Â u32 val;
> - Â Â Â int err = 0;
> - Â Â Â int i;
> - Â Â Â int num_irqs;
> -
> - Â Â Â gpiodev = &pdev->dev;
> - Â Â Â memset(gpio_pin, 0, sizeof(gpio_pin));
> -
> - Â Â Â /* Get GPIO clock */
> - Â Â Â clk = clk_get(&pdev->dev, NULL);
> - Â Â Â if (IS_ERR(clk)) {
> - Â Â Â Â Â Â Â err = PTR_ERR(clk);
> - Â Â Â Â Â Â Â dev_err(gpiodev, "could not get GPIO clock\n");
> - Â Â Â Â Â Â Â goto err_no_clk;
> - Â Â Â }
> - Â Â Â err = clk_enable(clk);
> - Â Â Â if (err) {
> - Â Â Â Â Â Â Â dev_err(gpiodev, "could not enable GPIO clock\n");
> - Â Â Â Â Â Â Â goto err_no_clk_enable;
> - Â Â Â }
> -
> - Â Â Â memres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - Â Â Â if (!memres)
> - Â Â Â Â Â Â Â goto err_no_resource;
> -
> - Â Â Â if (request_mem_region(memres->start, memres->end - memres->start, "GPIO Controller")
> - Â Â Â Â Â == NULL) {
> - Â Â Â Â Â Â Â err = -ENODEV;
> - Â Â Â Â Â Â Â goto err_no_ioregion;
> - Â Â Â }
> -
> - Â Â Â virtbase = ioremap(memres->start, resource_size(memres));
> - Â Â Â if (!virtbase) {
> - Â Â Â Â Â Â Â err = -ENOMEM;
> - Â Â Â Â Â Â Â goto err_no_ioremap;
> - Â Â Â }
> - Â Â Â dev_info(gpiodev, "remapped 0x%08x to %p\n",
> - Â Â Â Â Â Â Â Âmemres->start, virtbase);
> -
> -#ifdef U300_COH901335
> - Â Â Â dev_info(gpiodev, "initializing GPIO Controller COH 901 335\n");
> - Â Â Â /* Turn on the GPIO block */
> - Â Â Â writel(U300_GPIO_CR_BLOCK_CLOCK_ENABLE, virtbase + U300_GPIO_CR);
> -#endif
> -
> -#ifdef U300_COH901571_3
> - Â Â Â dev_info(gpiodev, "initializing GPIO Controller COH 901 571/3\n");
> - Â Â Â val = readl(virtbase + U300_GPIO_CR);
> - Â Â Â dev_info(gpiodev, "COH901571/3 block version: %d, " \
> - Â Â Â Â Â Â Â"number of cores: %d\n",
> - Â Â Â Â Â Â Â((val & 0x0000FE00) >> 9),
> - Â Â Â Â Â Â Â((val & 0x000001FC) >> 2));
> - Â Â Â writel(U300_GPIO_CR_BLOCK_CLKRQ_ENABLE, virtbase + U300_GPIO_CR);
> -#endif
> -
> - Â Â Â gpio_set_initial_values();
> -
> - Â Â Â for (num_irqs = 0 ; num_irqs < U300_GPIO_NUM_PORTS; num_irqs++) {
> -
> - Â Â Â Â Â Â Â gpio_ports[num_irqs].irq =
> - Â Â Â Â Â Â Â Â Â Â Â platform_get_irq_byname(pdev,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gpio_ports[num_irqs].name);
> -
> - Â Â Â Â Â Â Â err = request_irq(gpio_ports[num_irqs].irq,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gpio_irq_handler, IRQF_DISABLED,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gpio_ports[num_irqs].name,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &gpio_ports[num_irqs]);
> - Â Â Â Â Â Â Â if (err) {
> - Â Â Â Â Â Â Â Â Â Â Â dev_err(gpiodev, "cannot allocate IRQ for %s!\n",
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â gpio_ports[num_irqs].name);
> - Â Â Â Â Â Â Â Â Â Â Â goto err_no_irq;
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â /* Turns off PortX_irq_force */
> - Â Â Â Â Â Â Â writel(0x0, virtbase + U300_GPIO_PXIFR +
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Ânum_irqs * U300_GPIO_PORTX_SPACING);
> - Â Â Â }
> -
> - Â Â Â return 0;
> -
> - err_no_irq:
> - Â Â Â for (i = 0; i < num_irqs; i++)
> - Â Â Â Â Â Â Â free_irq(gpio_ports[i].irq, &gpio_ports[i]);
> - Â Â Â iounmap(virtbase);
> - err_no_ioremap:
> - Â Â Â release_mem_region(memres->start, memres->end - memres->start);
> - err_no_ioregion:
> - err_no_resource:
> - Â Â Â clk_disable(clk);
> - err_no_clk_enable:
> - Â Â Â clk_put(clk);
> - err_no_clk:
> - Â Â Â dev_info(gpiodev, "module ERROR:%d\n", err);
> - Â Â Â return err;
> -}
> -
> -static int __exit gpio_remove(struct platform_device *pdev)
> -{
> - Â Â Â int i;
> -
> - Â Â Â /* Turn off the GPIO block */
> - Â Â Â writel(0x00000000U, virtbase + U300_GPIO_CR);
> - Â Â Â for (i = 0 ; i < U300_GPIO_NUM_PORTS; i++)
> - Â Â Â Â Â Â Â free_irq(gpio_ports[i].irq, &gpio_ports[i]);
> - Â Â Â iounmap(virtbase);
> - Â Â Â release_mem_region(memres->start, memres->end - memres->start);
> - Â Â Â clk_disable(clk);
> - Â Â Â clk_put(clk);
> - Â Â Â return 0;
> -}
> -
> -static struct platform_driver gpio_driver = {
> -    .driver     = {
> -        .name  = "u300-gpio",
> - Â Â Â },
> -    .remove     = __exit_p(gpio_remove),
> -};
> -
> -
> -static int __init u300_gpio_init(void)
> -{
> - Â Â Â return platform_driver_probe(&gpio_driver, gpio_probe);
> -}
> -
> -static void __exit u300_gpio_exit(void)
> -{
> - Â Â Â platform_driver_unregister(&gpio_driver);
> -}
> -
> -arch_initcall(u300_gpio_init);
> -module_exit(u300_gpio_exit);

looks like the driver can't be a real module, is the module_exit suitable?

> -
> -MODULE_AUTHOR("Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>");
> -
> -#ifdef U300_COH901571_3
> -MODULE_DESCRIPTION("ST-Ericsson AB COH 901 571/3 GPIO driver");
> -#endif
> -
> -#ifdef U300_COH901335
> -MODULE_DESCRIPTION("ST-Ericsson AB COH 901 335 GPIO driver");
> -#endif
> -
> -MODULE_LICENSE("GPL");
> diff --git a/arch/arm/mach-u300/include/mach/gpio.h b/arch/arm/mach-u300/include/mach/gpio.h
> index d5a71ab..6fc3205 100644
> --- a/arch/arm/mach-u300/include/mach/gpio.h
> +++ b/arch/arm/mach-u300/include/mach/gpio.h
> @@ -17,127 +17,13 @@
> Â#include <linux/io.h>
> Â#include <mach/hardware.h>
> Â#include <asm/irq.h>
> +#include <asm-generic/gpio.h>
>
> -/* Switch type depending on platform/chip variant */
> -#if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330)
> -#define U300_COH901335
> -#endif
> -#if defined(CONFIG_MACH_U300_BS365) || defined(CONFIG_MACH_U300_BS335)
> -#define U300_COH901571_3
> -#endif
> -
> -/* Get base address for regs here */
> -#include "u300-regs.h"
> -/* IRQ numbers */
> -#include "irqs.h"
> -
> -/*
> - * This is the GPIO block definitions. GPIO (General Purpose I/O) can be
> - * used for anything, and often is. The event/enable etc figures are for
> - * the lowermost pin (pin 0 on each port), shift this left to match your
> - * pin if you're gonna use these values.
> - */
> -#ifdef U300_COH901335
> -#define U300_GPIO_PORTX_SPACING Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x1C)
> -/* Port X Pin Data Register 32bit, this is both input and output (R/W) */
> -#define U300_GPIO_PXPDIR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x00)
> -#define U300_GPIO_PXPDOR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x00)
> -/* Port X Pin Config Register 32bit (R/W) */
> -#define U300_GPIO_PXPCR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x04)
> -#define U300_GPIO_PXPCR_ALL_PINS_MODE_MASK Â Â Â Â Â Â (0x0000FFFFUL)
> -#define U300_GPIO_PXPCR_PIN_MODE_MASK Â Â Â Â Â Â Â Â Â(0x00000003UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_SHIFT Â Â Â Â Â Â Â Â (0x00000002UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_INPUT Â Â Â Â Â Â Â Â (0x00000000UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL Â Â Â(0x00000001UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_DRAIN Â Â (0x00000002UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_SOURCE Â Â(0x00000003UL)
> -/* Port X Interrupt Event Register 32bit (R/W) */
> -#define U300_GPIO_PXIEV Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x08)
> -#define U300_GPIO_PXIEV_ALL_IRQ_EVENT_MASK Â Â Â Â Â Â (0x000000FFUL)
> -#define U300_GPIO_PXIEV_IRQ_EVENT Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -/* Port X Interrupt Enable Register 32bit (R/W) */
> -#define U300_GPIO_PXIEN Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x0C)
> -#define U300_GPIO_PXIEN_ALL_IRQ_ENABLE_MASK Â Â Â Â Â Â(0x000000FFUL)
> -#define U300_GPIO_PXIEN_IRQ_ENABLE Â Â Â Â Â Â Â Â Â Â (0x00000001UL)
> -/* Port X Interrupt Force Register 32bit (R/W) */
> -#define U300_GPIO_PXIFR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x10)
> -#define U300_GPIO_PXIFR_ALL_IRQ_FORCE_MASK Â Â Â Â Â Â (0x000000FFUL)
> -#define U300_GPIO_PXIFR_IRQ_FORCE Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -/* Port X Interrupt Config Register 32bit (R/W) */
> -#define U300_GPIO_PXICR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x14)
> -#define U300_GPIO_PXICR_ALL_IRQ_CONFIG_MASK Â Â Â Â Â Â(0x000000FFUL)
> -#define U300_GPIO_PXICR_IRQ_CONFIG_MASK Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -#define U300_GPIO_PXICR_IRQ_CONFIG_FALLING_EDGE Â Â Â Â Â Â Â Â(0x00000000UL)
> -#define U300_GPIO_PXICR_IRQ_CONFIG_RISING_EDGE Â Â Â Â (0x00000001UL)
> -/* Port X Pull-up Enable Register 32bit (R/W) */
> -#define U300_GPIO_PXPER Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x18)
> -#define U300_GPIO_PXPER_ALL_PULL_UP_DISABLE_MASK Â Â Â (0x000000FFUL)
> -#define U300_GPIO_PXPER_PULL_UP_DISABLE Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -/* Control Register 32bit (R/W) */
> -#define U300_GPIO_CR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x54)
> -#define U300_GPIO_CR_BLOCK_CLOCK_ENABLE Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -/* three ports of 8 bits each = GPIO pins 0..23 */
> -#define U300_GPIO_NUM_PORTS 3
> -#define U300_GPIO_PINS_PER_PORT 8
> -#define U300_GPIO_MAX Â(U300_GPIO_PINS_PER_PORT * U300_GPIO_NUM_PORTS - 1)
> -#endif
> -
> -#ifdef U300_COH901571_3
> -/*
> - * Control Register 32bit (R/W)
> - * bit 15-9 (mask 0x0000FE00) contains the number of cores. 8*cores
> - * gives the number of GPIO pins.
> - * bit 8-2 Â(mask 0x000001FC) contains the core version ID.
> - */
> -#define U300_GPIO_CR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x00)
> -#define U300_GPIO_CR_SYNC_SEL_ENABLE Â Â Â Â Â Â Â Â Â (0x00000002UL)
> -#define U300_GPIO_CR_BLOCK_CLKRQ_ENABLE Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -#define U300_GPIO_PORTX_SPACING Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x30)
> -/* Port X Pin Data INPUT Register 32bit (R/W) */
> -#define U300_GPIO_PXPDIR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x04)
> -/* Port X Pin Data OUTPUT Register 32bit (R/W) */
> -#define U300_GPIO_PXPDOR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x08)
> -/* Port X Pin Config Register 32bit (R/W) */
> -#define U300_GPIO_PXPCR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x0C)
> -#define U300_GPIO_PXPCR_ALL_PINS_MODE_MASK Â Â Â Â Â Â (0x0000FFFFUL)
> -#define U300_GPIO_PXPCR_PIN_MODE_MASK Â Â Â Â Â Â Â Â Â(0x00000003UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_SHIFT Â Â Â Â Â Â Â Â (0x00000002UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_INPUT Â Â Â Â Â Â Â Â (0x00000000UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL Â Â Â(0x00000001UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_DRAIN Â Â (0x00000002UL)
> -#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_SOURCE Â Â(0x00000003UL)
> -/* Port X Pull-up Enable Register 32bit (R/W) */
> -#define U300_GPIO_PXPER Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x10)
> -#define U300_GPIO_PXPER_ALL_PULL_UP_DISABLE_MASK Â Â Â (0x000000FFUL)
> -#define U300_GPIO_PXPER_PULL_UP_DISABLE Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -/* Port X Interrupt Event Register 32bit (R/W) */
> -#define U300_GPIO_PXIEV Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x14)
> -#define U300_GPIO_PXIEV_ALL_IRQ_EVENT_MASK Â Â Â Â Â Â (0x000000FFUL)
> -#define U300_GPIO_PXIEV_IRQ_EVENT Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -/* Port X Interrupt Enable Register 32bit (R/W) */
> -#define U300_GPIO_PXIEN Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x18)
> -#define U300_GPIO_PXIEN_ALL_IRQ_ENABLE_MASK Â Â Â Â Â Â(0x000000FFUL)
> -#define U300_GPIO_PXIEN_IRQ_ENABLE Â Â Â Â Â Â Â Â Â Â (0x00000001UL)
> -/* Port X Interrupt Force Register 32bit (R/W) */
> -#define U300_GPIO_PXIFR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x1C)
> -#define U300_GPIO_PXIFR_ALL_IRQ_FORCE_MASK Â Â Â Â Â Â (0x000000FFUL)
> -#define U300_GPIO_PXIFR_IRQ_FORCE Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -/* Port X Interrupt Config Register 32bit (R/W) */
> -#define U300_GPIO_PXICR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x20)
> -#define U300_GPIO_PXICR_ALL_IRQ_CONFIG_MASK Â Â Â Â Â Â(0x000000FFUL)
> -#define U300_GPIO_PXICR_IRQ_CONFIG_MASK Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> -#define U300_GPIO_PXICR_IRQ_CONFIG_FALLING_EDGE Â Â Â Â Â Â Â Â(0x00000000UL)
> -#define U300_GPIO_PXICR_IRQ_CONFIG_RISING_EDGE Â Â Â Â (0x00000001UL)
> -#ifdef CONFIG_MACH_U300_BS335
> -/* seven ports of 8 bits each = GPIO pins 0..55 */
> -#define U300_GPIO_NUM_PORTS 7
> -#else
> -/* five ports of 8 bits each = GPIO pins 0..39 */
> -#define U300_GPIO_NUM_PORTS 5
> -#endif
> -#define U300_GPIO_PINS_PER_PORT 8
> -#define U300_GPIO_MAX (U300_GPIO_PINS_PER_PORT * U300_GPIO_NUM_PORTS - 1)
> -#endif
> +/* Map these overrides to gpiolib functions, simply */
> +#define gpio_get_value Â__gpio_get_value
> +#define gpio_set_value Â__gpio_set_value
> +#define gpio_cansleep  __gpio_cansleep
> +#define gpio_to_irq   __gpio_to_irq
>
> Â/*
> Â* Individual pin assignments for the B26/S26. Notice that the
> @@ -254,41 +140,4 @@
>
> Â#endif
>
> -/* translates a pin number to a port number */
> -#define PIN_TO_PORT(val) (val >> 3)
> -
> -/* These can be found in arch/arm/mach-u300/gpio.c */
> -extern int gpio_is_valid(int number);
> -extern int gpio_request(unsigned gpio, const char *label);
> -extern void gpio_free(unsigned gpio);
> -extern int gpio_direction_input(unsigned gpio);
> -extern int gpio_direction_output(unsigned gpio, int value);
> -extern int gpio_register_callback(unsigned gpio,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int (*func)(void *arg),
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â void *);
> -extern int gpio_unregister_callback(unsigned gpio);
> -extern void enable_irq_on_gpio_pin(unsigned gpio, int edge);
> -extern void disable_irq_on_gpio_pin(unsigned gpio);
> -extern void gpio_pullup(unsigned gpio, int value);
> -extern int gpio_get_value(unsigned gpio);
> -extern void gpio_set_value(unsigned gpio, int value);
> -
> -#define gpio_get_value_cansleep gpio_get_value
> -#define gpio_set_value_cansleep gpio_set_value
> -
> -/* wrappers to sleep-enable the previous two functions */
> -static inline unsigned gpio_to_irq(unsigned gpio)
> -{
> - Â Â Â return PIN_TO_PORT(gpio) + IRQ_U300_GPIO_PORT0;
> -}
> -
> -static inline unsigned irq_to_gpio(unsigned irq)
> -{
> - Â Â Â /*
> - Â Â Â Â* FIXME: This is no 1-1 mapping at all, it points to the
> - Â Â Â Â* whole block of 8 pins.
> - Â Â Â Â*/
> - Â Â Â return (irq - IRQ_U300_GPIO_PORT0) << 3;
> -}
> -
> Â#endif
> diff --git a/arch/arm/mach-u300/include/mach/irqs.h b/arch/arm/mach-u300/include/mach/irqs.h
> index 09b1b28..d270fea 100644
> --- a/arch/arm/mach-u300/include/mach/irqs.h
> +++ b/arch/arm/mach-u300/include/mach/irqs.h
> @@ -72,7 +72,7 @@
>
> Â/* DB3150 and DB3200 have only 45 IRQs */
> Â#if defined(CONFIG_MACH_U300_BS2X) || defined(CONFIG_MACH_U300_BS330)
> -#define U300_NR_IRQS Â Â Â Â Â Â Â Â Â 45
> +#define U300_VIC_IRQS_END Â Â Â Â Â Â Â45
> Â#endif
>
> Â/* The DB3350-specific interrupt lines */
> @@ -88,7 +88,7 @@
> Â#define IRQ_U300_GPIO_PORT4 Â Â Â Â Â Â53
> Â#define IRQ_U300_GPIO_PORT5 Â Â Â Â Â Â54
> Â#define IRQ_U300_GPIO_PORT6 Â Â Â Â Â Â55
> -#define U300_NR_IRQS Â Â Â Â Â Â Â Â Â 56
> +#define U300_VIC_IRQS_END Â Â Â Â Â Â Â56
> Â#endif
>
> Â/* The DB3210-specific interrupt lines */
> @@ -106,16 +106,25 @@
> Â#define IRQ_U300_NFIF Â Â Â Â Â Â Â Â Â45
> Â#define IRQ_U300_NFIF2 Â Â Â Â Â Â Â Â 46
> Â#define IRQ_U300_SYSCON_PLL_LOCK Â Â Â 47
> -#define U300_NR_IRQS Â Â Â Â Â Â Â Â Â 48
> +#define U300_VIC_IRQS_END Â Â Â Â Â Â Â48
> Â#endif
>
> -#ifdef CONFIG_AB3550_CORE
> -#define IRQ_AB3550_BASE Â Â Â Â Â Â Â Â Â Â Â Â(U300_NR_IRQS)
> -#define IRQ_AB3550_END Â Â Â Â Â Â Â Â (IRQ_AB3550_BASE + 37)
> +/* Maximum 8*7 GPIO lines */
> +#ifdef CONFIG_GPIO_U300
> +#define IRQ_U300_GPIO_BASE Â Â Â Â Â Â (U300_VIC_IRQS_END)
> +#define IRQ_U300_GPIO_END Â Â Â Â Â Â Â(IRQ_U300_GPIO_BASE + 56)
> +#else
> +#define IRQ_U300_GPIO_END Â Â Â Â Â Â Â(U300_VIC_IRQS_END)
> +#endif
>
> -#define NR_IRQS Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(IRQ_AB3550_END + 1)
> +/* Optional AB3550 mixsig chip */
> +#ifdef CONFIG_AB3550_CORE
> +#define IRQ_AB3550_BASE Â Â Â Â Â Â Â Â Â Â Â Â(IRQ_U300_GPIO_END)
> +#define IRQ_AB3550_END Â Â Â Â Â Â Â Â (IRQ_AB3550_BASE + 38)
> Â#else
> -#define NR_IRQS U300_NR_IRQS
> +#define IRQ_AB3550_END Â Â Â Â Â Â Â Â (IRQ_U300_GPIO_END)
> Â#endif
>
> +#define NR_IRQS Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(IRQ_AB3550_END)
> +
> Â#endif
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index d3b2953..cc89dfa 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -119,6 +119,15 @@ config GPIO_SCH
> Â Â Â Â ÂThis driver can also be built as a module. If so, the module
> Â Â Â Â Âwill be called sch-gpio.
>
> +config GPIO_U300
> + Â Â Â bool "ST-Ericsson U300 COH 901 335/571 GPIO"
> + Â Â Â depends on GPIOLIB && ARCH_U300
> + Â Â Â help
> + Â Â Â Â Say yes here to support GPIO interface on ST-Ericsson U300.
> + Â Â Â Â The names of the two IP block variants supported are
> + Â Â Â Â COH 901 335 and COH 901 571/3. They contain 3, 5 or 7
> + Â Â Â Â ports of 8 GPIO pins each.
> +
> Âconfig GPIO_VX855
> Â Â Â Âtristate "VIA VX855/VX875 GPIO"
> Â Â Â Âdepends on GPIOLIB && MFD_SUPPORT && PCI
> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index becef59..26032b1 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -37,6 +37,7 @@ obj-$(CONFIG_GPIO_WM831X) Â Â += wm831x-gpio.o
> Âobj-$(CONFIG_GPIO_WM8350) Â Â Â+= wm8350-gpiolib.o
> Âobj-$(CONFIG_GPIO_WM8994) Â Â Â+= wm8994-gpio.o
> Âobj-$(CONFIG_GPIO_SCH) Â Â Â Â += sch_gpio.o
> +obj-$(CONFIG_GPIO_U300) Â Â Â Â Â Â Â Â+= u300-gpio.o
> Âobj-$(CONFIG_GPIO_RDC321X) Â Â += rdc321x-gpio.o
> Âobj-$(CONFIG_GPIO_JANZ_TTL) Â Â+= janz-ttl.o
> Âobj-$(CONFIG_GPIO_SX150X) Â Â Â+= sx150x.o
> diff --git a/drivers/gpio/u300-gpio.c b/drivers/gpio/u300-gpio.c
> new file mode 100644
> index 0000000..d85a116
> --- /dev/null
> +++ b/drivers/gpio/u300-gpio.c
> @@ -0,0 +1,836 @@
> +/*
> + * Copyright (C) 2007-2011 ST-Ericsson AB
> + * License terms: GNU General Public License (GPL) version 2
> + * U300 GPIO module.
> + * This can driver either of the two basic GPIO cores
> + * available in the U300 platforms:
> + * COH 901 335 Â - Used in DB3150 (U300 1.0) and DB3200 (U330 1.0)
> + * COH 901 571/3 - Used in DB3210 (U365 2.0) and DB3350 (U335 1.0)
> + * Author: Linus Walleij <linus.walleij@xxxxxxxxxx>
> + * Author: Jonas Aaberg <jonas.aberg@xxxxxxxxxxxxxx>
> + */
> +#include <linux/module.h>
> +#include <linux/irq.h>
> +#include <linux/interrupt.h>
> +#include <linux/delay.h>
> +#include <linux/errno.h>
> +#include <linux/io.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <linux/platform_device.h>
> +#include <linux/gpio.h>
> +#include <linux/list.h>
> +#include <linux/slab.h>
> +#include <linux/gpio/u300.h>
> +
> +/*
> + * Register definitions for COH 901 335 variant
> + */
> +#define U300_335_PORT_STRIDE Â Â Â Â Â Â Â Â Â Â Â Â Â (0x1C)
> +/* Port X Pin Data Register 32bit, this is both input and output (R/W) */
> +#define U300_335_PXPDIR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x00)
> +#define U300_335_PXPDOR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x00)
> +/* Port X Pin Config Register 32bit (R/W) */
> +#define U300_335_PXPCR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x04)
> +/* This register layout is the same in both blocks */
> +#define U300_GPIO_PXPCR_ALL_PINS_MODE_MASK Â Â Â Â Â Â (0x0000FFFFUL)
> +#define U300_GPIO_PXPCR_PIN_MODE_MASK Â Â Â Â Â Â Â Â Â(0x00000003UL)
> +#define U300_GPIO_PXPCR_PIN_MODE_SHIFT Â Â Â Â Â Â Â Â (0x00000002UL)
> +#define U300_GPIO_PXPCR_PIN_MODE_INPUT Â Â Â Â Â Â Â Â (0x00000000UL)
> +#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL Â Â Â(0x00000001UL)
> +#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_DRAIN Â Â (0x00000002UL)
> +#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_SOURCE Â Â(0x00000003UL)
> +/* Port X Interrupt Event Register 32bit (R/W) */
> +#define U300_335_PXIEV Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x08)
> +/* Port X Interrupt Enable Register 32bit (R/W) */
> +#define U300_335_PXIEN Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x0C)
> +/* Port X Interrupt Force Register 32bit (R/W) */
> +#define U300_335_PXIFR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x10)
> +/* Port X Interrupt Config Register 32bit (R/W) */
> +#define U300_335_PXICR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x14)
> +/* This register layout is the same in both blocks */
> +#define U300_GPIO_PXICR_ALL_IRQ_CONFIG_MASK Â Â Â Â Â Â(0x000000FFUL)
> +#define U300_GPIO_PXICR_IRQ_CONFIG_MASK Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> +#define U300_GPIO_PXICR_IRQ_CONFIG_FALLING_EDGE Â Â Â Â Â Â Â Â(0x00000000UL)
> +#define U300_GPIO_PXICR_IRQ_CONFIG_RISING_EDGE Â Â Â Â (0x00000001UL)
> +/* Port X Pull-up Enable Register 32bit (R/W) */
> +#define U300_335_PXPER Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x18)
> +/* This register layout is the same in both blocks */
> +#define U300_GPIO_PXPER_ALL_PULL_UP_DISABLE_MASK Â Â Â (0x000000FFUL)
> +#define U300_GPIO_PXPER_PULL_UP_DISABLE Â Â Â Â Â Â Â Â Â Â Â Â(0x00000001UL)
> +/* Control Register 32bit (R/W) */
> +#define U300_335_CR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x54)
> +#define U300_335_CR_BLOCK_CLOCK_ENABLE Â Â Â Â Â Â Â Â (0x00000001UL)
> +
> +/*
> + * Register definitions for COH 901 571 / 3 variant
> + */
> +#define U300_571_PORT_STRIDE Â Â Â Â Â Â Â Â Â Â Â Â Â (0x30)
> +/*
> + * Control Register 32bit (R/W)
> + * bit 15-9 (mask 0x0000FE00) contains the number of cores. 8*cores
> + * gives the number of GPIO pins.
> + * bit 8-2 Â(mask 0x000001FC) contains the core version ID.
> + */
> +#define U300_571_CR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x00)
> +#define U300_571_CR_SYNC_SEL_ENABLE Â Â Â Â Â Â Â Â Â Â(0x00000002UL)
> +#define U300_571_CR_BLOCK_CLKRQ_ENABLE Â Â Â Â Â Â Â Â (0x00000001UL)
> +/*
> + * These registers have the same layout and function as the corresponding
> + * COH 901 335 registers, just at different offset.
> + */
> +#define U300_571_PXPDIR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x04)
> +#define U300_571_PXPDOR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(0x08)
> +#define U300_571_PXPCR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x0C)
> +#define U300_571_PXPER Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x10)
> +#define U300_571_PXIEV Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x14)
> +#define U300_571_PXIEN Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x18)
> +#define U300_571_PXIFR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x1C)
> +#define U300_571_PXICR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (0x20)
> +
> +/* 8 bits per port, no version has more than 7 ports */
> +#define U300_GPIO_PINS_PER_PORT 8
> +#define U300_GPIO_MAX (U300_GPIO_PINS_PER_PORT * 7)
> +
> +struct u300_gpio {
> + Â Â Â struct gpio_chip chip;
> + Â Â Â struct list_head port_list;
> + Â Â Â struct clk *clk;
> + Â Â Â struct resource *memres;
> + Â Â Â void __iomem *base;
> + Â Â Â struct device *dev;
> + Â Â Â int irq_base;
> + Â Â Â int users;
> + Â Â Â u32 stride;
> + Â Â Â /* Register offsets */
> + Â Â Â u32 pcr;
> + Â Â Â u32 dor;
> + Â Â Â u32 dir;
> + Â Â Â u32 per;
> + Â Â Â u32 icr;
> + Â Â Â u32 ien;
> + Â Â Â u32 iev;
> +};
> +
> +struct u300_gpio_port {
> + Â Â Â struct list_head node;
> + Â Â Â struct u300_gpio *gpio;
> + Â Â Â char name[8];
> + Â Â Â int irq;
> + Â Â Â int number;
> +};
> +
> +/*
> + * Macro to expand to read a specific register found in the "gpio"
> + * struct. It requires the struct u300_gpio *gpio variable to exist in
> + * its context. It calculates the port offset from the given pin
> + * offset, muliplies by the port stride and adds the register offset
> + * so it provides a pointer to the desired register.
> + */
> +#define U300_PIN_REG(pin, reg) \
> + Â Â Â (gpio->base + (pin >> 3) * gpio->stride + gpio->reg)
> +
> +/*
> + * Provides a bitmask for a specific gpio pin inside an 8-bit GPIO
> + * register.
> + */
> +#define U300_PIN_BIT(pin) \
> + Â Â Â (1 << (pin & 0x07))
> +
> +struct u300_gpio_confdata {
> + Â Â Â u16 bias_mode;
> + Â Â Â bool output;
> + Â Â Â int outval;
> +};
> +
> +/* BS335 has seven ports of 8 bits each = GPIO pins 0..55 */
> +#define BS335_GPIO_NUM_PORTS 7
> +/* BS365 has five ports of 8 bits each = GPIO pins 0..39 */
> +#define BS365_GPIO_NUM_PORTS 5
> +
> +#define U300_FLOATING_INPUT { \
> + Â Â Â .bias_mode = GPIO_CONFIG_BIAS_FLOAT, \
> + Â Â Â .output = false, \
> +}
> +
> +#define U300_PULL_UP_INPUT { \
> + Â Â Â .bias_mode = GPIO_CONFIG_BIAS_PULL_UP, \
> + Â Â Â .output = false, \
> +}
> +
> +#define U300_OUTPUT_LOW { \
> + Â Â Â .output = true, \
> + Â Â Â .outval = 0, \
> +}
> +
> +#define U300_OUTPUT_HIGH { \
> + Â Â Â .output = true, \
> + Â Â Â .outval = 1, \
> +}
> +
> +
> +/* Initial configuration */
> +static struct __initdata u300_gpio_confdata
> +bs335_gpio_config[BS335_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = {
> + Â Â Â /* Port 0, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_HIGH,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â },
> + Â Â Â /* Port 1, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_HIGH,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â },
> + Â Â Â /* Port 2, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â },
> + Â Â Â /* Port 3, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â },
> + Â Â Â /* Port 4, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â },
> + Â Â Â /* Port 5, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â },
> + Â Â Â /* Port 6, pind 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â }
> +};
> +
> +static struct __initdata u300_gpio_confdata
> +bs365_gpio_config[BS365_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = {
> + Â Â Â /* Port 0, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â },
> + Â Â Â /* Port 1, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_HIGH,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â },
> + Â Â Â /* Port 2, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_FLOATING_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â },
> + Â Â Â /* Port 3, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â },
> + Â Â Â /* Port 4, pins 0-7 */
> + Â Â Â {
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â U300_PULL_UP_INPUT,
> + Â Â Â Â Â Â Â /* These 4 pins doesn't exist on DB3210 */
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â Â Â Â Â U300_OUTPUT_LOW,
> + Â Â Â }
> +};
> +
> +/**
> + * to_u300_gpio() - get the pointer to u300_gpio
> + * @chip: the gpio chip member of the structure u300_gpio
> + */
> +static inline struct u300_gpio *to_u300_gpio(struct gpio_chip *chip)
> +{
> + Â Â Â return container_of(chip, struct u300_gpio, chip);
> +}
> +
> +static int u300_gpio_get(struct gpio_chip *chip, unsigned offset)
> +{
> + Â Â Â struct u300_gpio *gpio = to_u300_gpio(chip);
> +
> + Â Â Â return readl(U300_PIN_REG(offset, dir)) & U300_PIN_BIT(offset);
> +}
> +
> +static void u300_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
> +{
> + Â Â Â struct u300_gpio *gpio = to_u300_gpio(chip);
> + Â Â Â unsigned long flags;
> + Â Â Â u32 val;
> +
> + Â Â Â local_irq_save(flags);
> +
> + Â Â Â val = readl(U300_PIN_REG(offset, dor));
> + Â Â Â if (value)
> + Â Â Â Â Â Â Â writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, dor));
> + Â Â Â else
> + Â Â Â Â Â Â Â writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, dor));
> +
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +static int u300_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
> +{
> + Â Â Â struct u300_gpio *gpio = to_u300_gpio(chip);
> + Â Â Â unsigned long flags;
> + Â Â Â u32 val;
> +
> + Â Â Â local_irq_save(flags);
> + Â Â Â val = readl(U300_PIN_REG(offset, pcr));
> + Â Â Â /* Mask out this pin, note 2 bits per setting */
> + Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK << ((offset & 0x07) << 1));
> + Â Â Â writel(val, U300_PIN_REG(offset, pcr));
> + Â Â Â local_irq_restore(flags);
> + Â Â Â return 0;
> +}
> +
> +static int u300_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int value)
> +{
> + Â Â Â struct u300_gpio *gpio = to_u300_gpio(chip);
> + Â Â Â unsigned long flags;
> + Â Â Â u32 oldmode;
> + Â Â Â u32 val;
> +
> + Â Â Â local_irq_save(flags);
> + Â Â Â val = readl(U300_PIN_REG(offset, pcr));
> + Â Â Â /*
> + Â Â Â Â* Drive mode must be set by the special mode set function, set
> + Â Â Â Â* push/pull mode by default if no mode has been selected.
> + Â Â Â Â*/
> + Â Â Â oldmode = val & (U300_GPIO_PXPCR_PIN_MODE_MASK <<
> + Â Â Â Â Â Â Â Â Â Â Â Â((offset & 0x07) << 1));
> + Â Â Â /* mode = 0 means input, else some mode is already set */
> + Â Â Â if (oldmode == 0) {
> + Â Â Â Â Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK <<
> + Â Â Â Â Â Â Â Â Â Â Â Â((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL
> + Â Â Â Â Â Â Â Â Â Â Â << ((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â writel(val, U300_PIN_REG(offset, pcr));
> + Â Â Â }
> + Â Â Â u300_gpio_set(chip, offset, value);
> + Â Â Â local_irq_restore(flags);
> + Â Â Â return 0;
> +}
> +
> +static int u300_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
> +{
> + Â Â Â struct u300_gpio *gpio = to_u300_gpio(chip);
> + Â Â Â int retirq = gpio->irq_base + offset;
> +
> + Â Â Â dev_dbg(gpio->dev, "request IRQ for GPIO %d, return %d\n", offset,
> + Â Â Â Â Â Â Â retirq);
> + Â Â Â return retirq;
> +}
> +
> +static int u300_gpio_config(struct gpio_chip *chip, unsigned offset,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Âu16 param, unsigned long *data)
> +{
> + Â Â Â struct u300_gpio *gpio = to_u300_gpio(chip);
> + Â Â Â unsigned long flags;
> + Â Â Â u32 val;
> +
> + Â Â Â local_irq_save(flags);
> + Â Â Â switch (param) {
> + Â Â Â case GPIO_CONFIG_BIAS_UNKNOWN:
> + Â Â Â case GPIO_CONFIG_BIAS_FLOAT:
> + Â Â Â Â Â Â Â val = readl(U300_PIN_REG(offset, per));
> + Â Â Â Â Â Â Â writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, per));
> + Â Â Â Â Â Â Â break;
> + Â Â Â case GPIO_CONFIG_BIAS_PULL_UP:
> + Â Â Â Â Â Â Â val = readl(U300_PIN_REG(offset, per));
> + Â Â Â Â Â Â Â writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, per));
> + Â Â Â Â Â Â Â break;
> + Â Â Â case GPIO_CONFIG_DRIVE_PUSH_PULL:
> + Â Â Â Â Â Â Â val = readl(U300_PIN_REG(offset, pcr));
> + Â Â Â Â Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK
> + Â Â Â Â Â Â Â Â Â Â Â Â<< ((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL
> + Â Â Â Â Â Â Â Â Â Â Â << ((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â writel(val, U300_PIN_REG(offset, pcr));
> + Â Â Â Â Â Â Â break;
> + Â Â Â case GPIO_CONFIG_DRIVE_OPEN_DRAIN:
> + Â Â Â Â Â Â Â val = readl(U300_PIN_REG(offset, pcr));
> + Â Â Â Â Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK
> + Â Â Â Â Â Â Â Â Â Â Â Â<< ((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_DRAIN
> + Â Â Â Â Â Â Â Â Â Â Â << ((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â writel(val, U300_PIN_REG(offset, pcr));
> + Â Â Â Â Â Â Â break;
> + Â Â Â case GPIO_CONFIG_DRIVE_OPEN_SOURCE:
> + Â Â Â Â Â Â Â val = readl(U300_PIN_REG(offset, pcr));
> + Â Â Â Â Â Â Â val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK
> + Â Â Â Â Â Â Â Â Â Â Â Â<< ((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_SOURCE
> + Â Â Â Â Â Â Â Â Â Â Â << ((offset & 0x07) << 1));
> + Â Â Â Â Â Â Â writel(val, U300_PIN_REG(offset, pcr));
> + Â Â Â Â Â Â Â break;
> + Â Â Â default:
> + Â Â Â Â Â Â Â local_irq_restore(flags);
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "illegal configuration requested\n");
> + Â Â Â Â Â Â Â return -EINVAL;
> + Â Â Â }
> + Â Â Â local_irq_restore(flags);
> + Â Â Â return 0;
> +}
> +
> +static struct gpio_chip u300_gpio_chip = {
> +    .label         Â= "u300-gpio-chip",
> +    .owner         Â= THIS_MODULE,
> +    .get          Â= u300_gpio_get,
> +    .set          Â= u300_gpio_set,
> +    .config         = u300_gpio_config,
> +    .direction_input    Â= u300_gpio_direction_input,
> +    .direction_output    = u300_gpio_direction_output,
> +    .to_irq         = u300_gpio_to_irq,
> +};
> +
> +static int u300_gpio_irq_type(struct irq_data *d, unsigned trigger)
> +{
> + Â Â Â struct u300_gpio *gpio = irq_data_get_irq_chip_data(d);
> + Â Â Â int offset = d->irq - gpio->irq_base;
> + Â Â Â u32 val;
> +
> + Â Â Â val = readl(U300_PIN_REG(offset, icr));
> + Â Â Â if (trigger & IRQF_TRIGGER_RISING)
> + Â Â Â Â Â Â Â writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, icr));
> + Â Â Â else
> + Â Â Â Â Â Â Â writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, icr));
> +
> + Â Â Â return 0;
> +}
> +
> +static void u300_gpio_irq_enable(struct irq_data *d)
> +{
> + Â Â Â struct u300_gpio *gpio = irq_data_get_irq_chip_data(d);
> + Â Â Â int offset = d->irq - gpio->irq_base;
> + Â Â Â u32 val;
> + Â Â Â unsigned long flags;
> +
> + Â Â Â local_irq_save(flags);
> + Â Â Â val = readl(U300_PIN_REG(offset, ien));
> + Â Â Â writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, ien));
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +static void u300_gpio_irq_disable(struct irq_data *d)
> +{
> + Â Â Â struct u300_gpio *gpio = irq_data_get_irq_chip_data(d);
> + Â Â Â int offset = d->irq - gpio->irq_base;
> + Â Â Â u32 val;
> + Â Â Â unsigned long flags;
> +
> + Â Â Â local_irq_save(flags);
> + Â Â Â val = readl(U300_PIN_REG(offset, ien));
> + Â Â Â writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, ien));
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +static struct irq_chip u300_gpio_irqchip = {
> +    .name          = "u300-gpio-irqchip",
> +    .irq_enable       = u300_gpio_irq_enable,
> +    .irq_disable      Â= u300_gpio_irq_disable,
> +    .irq_set_type      = u300_gpio_irq_type,
> +
> +};
> +
> +static void u300_gpio_irq_handler(unsigned irq, struct irq_desc *desc)
> +{
> + Â Â Â struct u300_gpio_port *port = irq_get_handler_data(irq);
> + Â Â Â struct u300_gpio *gpio = port->gpio;
> + Â Â Â int pinoffset = port->number << 3; /* get the right stride */
> + Â Â Â unsigned long val;
> +
> + Â Â Â desc->irq_data.chip->irq_ack(&desc->irq_data);
> + Â Â Â /* Read event register */
> + Â Â Â val = readl(U300_PIN_REG(pinoffset, iev));
> + Â Â Â /* Mask relevant bits */
> + Â Â Â val &= 0xFFU; /* 8 bits per port */
> + Â Â Â /* ACK IRQ (clear event) */
> + Â Â Â writel(val, U300_PIN_REG(pinoffset, iev));
> +
> + Â Â Â /* Call IRQ handler */
> + Â Â Â if (val != 0) {
> + Â Â Â Â Â Â Â int irqoffset;
> +
> + Â Â Â Â Â Â Â for_each_set_bit(irqoffset, &val, U300_GPIO_PINS_PER_PORT) {
> + Â Â Â Â Â Â Â Â Â Â Â int pin_irq = gpio->irq_base + (port->number << 3)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â + irqoffset;
> +
> + Â Â Â Â Â Â Â Â Â Â Â dev_dbg(gpio->dev, "GPIO IRQ on pin %d\n", pin_irq);
> + Â Â Â Â Â Â Â Â Â Â Â generic_handle_irq(pin_irq);
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> + Â Â Â desc->irq_data.chip->irq_unmask(&desc->irq_data);
> +}
> +
> +static void __init u300_gpio_init_pin(struct u300_gpio *gpio,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int offset,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct u300_gpio_confdata *conf)
> +{
> + Â Â Â /* Set mode: input or output */
> + Â Â Â if (conf->output) {
> + Â Â Â Â Â Â Â u300_gpio_direction_output(&gpio->chip, offset, conf->outval);
> +
> + Â Â Â Â Â Â Â /* Deactivate bias mode for output */
> + Â Â Â Â Â Â Â u300_gpio_config(&gpio->chip, offset, GPIO_CONFIG_BIAS_FLOAT,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂNULL);
> +
> + Â Â Â Â Â Â Â /* Set drive mode for output */
> + Â Â Â Â Â Â Â u300_gpio_config(&gpio->chip, offset,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂGPIO_CONFIG_DRIVE_PUSH_PULL, NULL);
> +
> + Â Â Â Â Â Â Â dev_dbg(gpio->dev, "set up pin %d as output, value: %d\n",
> + Â Â Â Â Â Â Â Â Â Â Â offset, conf->outval);
> + Â Â Â } else {
> + Â Â Â Â Â Â Â u300_gpio_direction_input(&gpio->chip, offset);
> +
> + Â Â Â Â Â Â Â /* Always set output low on input pins */
> + Â Â Â Â Â Â Â u300_gpio_set(&gpio->chip, offset, 0);
> +
> + Â Â Â Â Â Â Â /* Set bias mode for input */
> + Â Â Â Â Â Â Â u300_gpio_config(&gpio->chip, offset, conf->bias_mode, NULL);
> +
> + Â Â Â Â Â Â Â dev_dbg(gpio->dev, "set up pin %d as input, bias: %d\n",
> + Â Â Â Â Â Â Â Â Â Â Â offset, conf->bias_mode);
> + Â Â Â }
> +}
> +
> +static void __init u300_gpio_init_coh901571(struct u300_gpio *gpio,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct u300_gpio_platform *plat)
> +{
> + Â Â Â int i, j;
> +
> + Â Â Â /* Write default config and values to all pins */
> + Â Â Â for (i = 0; i < plat->ports; i++) {
> + Â Â Â Â Â Â Â for (j = 0; j < 8; j++) {
> + Â Â Â Â Â Â Â Â Â Â Â struct u300_gpio_confdata *conf;
> + Â Â Â Â Â Â Â Â Â Â Â int offset = (i*8) + j;
> +
> + Â Â Â Â Â Â Â Â Â Â Â if (plat->variant == U300_GPIO_COH901571_3_BS335)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â conf = &bs335_gpio_config[i][j];
> + Â Â Â Â Â Â Â Â Â Â Â else if (plat->variant == U300_GPIO_COH901571_3_BS365)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â conf = &bs365_gpio_config[i][j];
> + Â Â Â Â Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
> +
> + Â Â Â Â Â Â Â Â Â Â Â u300_gpio_init_pin(gpio, offset, conf);
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> +}
> +
> +static inline void u300_gpio_free_ports(struct u300_gpio *gpio)
> +{
> + Â Â Â struct u300_gpio_port *port;
> + Â Â Â struct list_head *p, *n;
> +
> + Â Â Â list_for_each_safe(p, n, &gpio->port_list) {
> + Â Â Â Â Â Â Â port = list_entry(p, struct u300_gpio_port, node);
> + Â Â Â Â Â Â Â list_del(&port->node);
> + Â Â Â Â Â Â Â free_irq(port->irq, port);
> + Â Â Â Â Â Â Â kfree(port);
> + Â Â Â }
> +}
> +
> +static int __init u300_gpio_probe(struct platform_device *pdev)
> +{
> + Â Â Â struct u300_gpio_platform *plat = dev_get_platdata(&pdev->dev);
> + Â Â Â struct u300_gpio *gpio;
> + Â Â Â int err = 0;
> + Â Â Â int portno;
> + Â Â Â u32 val;
> + Â Â Â u32 ifr;
> + Â Â Â int i;
> +
> + Â Â Â gpio = kzalloc(sizeof(struct u300_gpio), GFP_KERNEL);
> + Â Â Â if (gpio == NULL) {
> + Â Â Â Â Â Â Â dev_err(&pdev->dev, "failed to allocate memory\n");
> + Â Â Â Â Â Â Â return -ENOMEM;
> + Â Â Â }
> +
> + Â Â Â gpio->chip = u300_gpio_chip;
> + Â Â Â gpio->chip.ngpio = plat->ports * U300_GPIO_PINS_PER_PORT;
> + Â Â Â gpio->irq_base = plat->gpio_irq_base;
> + Â Â Â gpio->chip.dev = &pdev->dev;
> + Â Â Â gpio->chip.base = plat->gpio_base;
> + Â Â Â gpio->dev = &pdev->dev;
> +
> + Â Â Â /* Get GPIO clock */
> + Â Â Â gpio->clk = clk_get(gpio->dev, NULL);
> + Â Â Â if (IS_ERR(gpio->clk)) {
> + Â Â Â Â Â Â Â err = PTR_ERR(gpio->clk);
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "could not get GPIO clock\n");
> + Â Â Â Â Â Â Â goto err_no_clk;
> + Â Â Â }
> + Â Â Â err = clk_enable(gpio->clk);
> + Â Â Â if (err) {
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "could not enable GPIO clock\n");
> + Â Â Â Â Â Â Â goto err_no_clk_enable;
> + Â Â Â }
> +
> + Â Â Â gpio->memres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + Â Â Â if (!gpio->memres) {
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "could not get GPIO memory resource\n");
> + Â Â Â Â Â Â Â err = -ENODEV;
> + Â Â Â Â Â Â Â goto err_no_resource;
> + Â Â Â }
> +
> + Â Â Â if (request_mem_region(gpio->memres->start,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âgpio->memres->end - gpio->memres->start,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â"GPIO Controller")
> + Â Â Â Â Â == NULL) {
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "could not reserve GPIO memory region\n");
> + Â Â Â Â Â Â Â err = -ENODEV;
> + Â Â Â Â Â Â Â goto err_no_ioregion;
> + Â Â Â }
> +
> + Â Â Â gpio->base = ioremap(gpio->memres->start, resource_size(gpio->memres));
> + Â Â Â if (!gpio->base) {
> + Â Â Â Â Â Â Â err = -ENOMEM;
> + Â Â Â Â Â Â Â goto err_no_ioremap;
> + Â Â Â }
> +
> + Â Â Â if (plat->variant == U300_GPIO_COH901335) {
> + Â Â Â Â Â Â Â dev_info(gpio->dev,
> + Â Â Â Â Â Â Â Â Â Â Â Â"initializing GPIO Controller COH 901 335\n");
> + Â Â Â Â Â Â Â gpio->stride = U300_335_PORT_STRIDE;
> + Â Â Â Â Â Â Â gpio->pcr = U300_335_PXPCR;
> + Â Â Â Â Â Â Â gpio->dor = U300_335_PXPDOR;
> + Â Â Â Â Â Â Â gpio->dir = U300_335_PXPDIR;
> + Â Â Â Â Â Â Â gpio->per = U300_335_PXPER;
> + Â Â Â Â Â Â Â gpio->icr = U300_335_PXICR;
> + Â Â Â Â Â Â Â gpio->ien = U300_335_PXIEN;
> + Â Â Â Â Â Â Â gpio->iev = U300_335_PXIEV;
> + Â Â Â Â Â Â Â ifr = U300_335_PXIFR;
> +
> + Â Â Â Â Â Â Â /* Turn on the GPIO block */
> + Â Â Â Â Â Â Â writel(U300_335_CR_BLOCK_CLOCK_ENABLE,
> + Â Â Â Â Â Â Â Â Â Â Âgpio->base + U300_335_CR);
> + Â Â Â } else if (plat->variant == U300_GPIO_COH901571_3_BS335 ||
> + Â Â Â Â Â Â Â Â Âplat->variant == U300_GPIO_COH901571_3_BS365) {
> + Â Â Â Â Â Â Â dev_info(gpio->dev,
> + Â Â Â Â Â Â Â Â Â Â Â Â"initializing GPIO Controller COH 901 571/3\n");
> + Â Â Â Â Â Â Â gpio->stride = U300_571_PORT_STRIDE;
> + Â Â Â Â Â Â Â gpio->pcr = U300_571_PXPCR;
> + Â Â Â Â Â Â Â gpio->dor = U300_571_PXPDOR;
> + Â Â Â Â Â Â Â gpio->dir = U300_571_PXPDIR;
> + Â Â Â Â Â Â Â gpio->per = U300_571_PXPER;
> + Â Â Â Â Â Â Â gpio->icr = U300_571_PXICR;
> + Â Â Â Â Â Â Â gpio->ien = U300_571_PXIEN;
> + Â Â Â Â Â Â Â gpio->iev = U300_571_PXIEV;
> + Â Â Â Â Â Â Â ifr = U300_571_PXIFR;
> +
> + Â Â Â Â Â Â Â val = readl(gpio->base + U300_571_CR);
> + Â Â Â Â Â Â Â dev_info(gpio->dev, "COH901571/3 block version: %d, " \
> + Â Â Â Â Â Â Â Â Â Â Â Â"number of cores: %d\n",
> + Â Â Â Â Â Â Â Â Â Â Â Â((val & 0x0000FE00) >> 9),
> + Â Â Â Â Â Â Â Â Â Â Â Â((val & 0x000001FC) >> 2));
> + Â Â Â Â Â Â Â writel(U300_571_CR_BLOCK_CLKRQ_ENABLE,
> + Â Â Â Â Â Â Â Â Â Â Âgpio->base + U300_571_CR);
> + Â Â Â Â Â Â Â u300_gpio_init_coh901571(gpio, plat);
> + Â Â Â } else {
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "unknown block variant\n");
> + Â Â Â Â Â Â Â err = -ENODEV;
> + Â Â Â Â Â Â Â goto err_unknown_variant;
> + Â Â Â }
> +
> + Â Â Â /* Add each port with its IRQ separately */
> + Â Â Â INIT_LIST_HEAD(&gpio->port_list);
> + Â Â Â for (portno = 0 ; portno < plat->ports; portno++) {
> + Â Â Â Â Â Â Â struct u300_gpio_port *port =
> + Â Â Â Â Â Â Â Â Â Â Â kmalloc(sizeof(struct u300_gpio_port), GFP_KERNEL);
> +
> + Â Â Â Â Â Â Â if (!port) {
> + Â Â Â Â Â Â Â Â Â Â Â dev_err(gpio->dev, "out of memory\n");
> + Â Â Â Â Â Â Â Â Â Â Â err = -ENOMEM;
> + Â Â Â Â Â Â Â Â Â Â Â goto err_no_port;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â snprintf(port->name, 8, "gpio%d", portno);
> + Â Â Â Â Â Â Â port->number = portno;
> + Â Â Â Â Â Â Â port->gpio = gpio;
> +
> + Â Â Â Â Â Â Â port->irq = platform_get_irq_byname(pdev,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â port->name);
> +
> + Â Â Â Â Â Â Â dev_dbg(gpio->dev, "register IRQ %d for %s\n", port->irq,
> + Â Â Â Â Â Â Â Â Â Â Â port->name);
> +
> + Â Â Â Â Â Â Â irq_set_chained_handler(port->irq, u300_gpio_irq_handler);
> + Â Â Â Â Â Â Â irq_set_handler_data(port->irq, port);
> +
> + Â Â Â Â Â Â Â /* Then for each GPIO pin set the unique IRQ handler */
> + Â Â Â Â Â Â Â for (i = 0; i < U300_GPIO_PINS_PER_PORT; i++) {
> + Â Â Â Â Â Â Â Â Â Â Â int irqno = gpio->irq_base + (portno << 3) + i;
> +
> + Â Â Â Â Â Â Â Â Â Â Â dev_dbg(gpio->dev, "handler for IRQ %d on %s\n",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â irqno, port->name);
> + Â Â Â Â Â Â Â Â Â Â Â irq_set_chip_and_handler(irqno, &u300_gpio_irqchip,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âhandle_simple_irq);
> + Â Â Â Â Â Â Â Â Â Â Â set_irq_flags(irqno, IRQF_VALID);
> + Â Â Â Â Â Â Â Â Â Â Â irq_set_chip_data(irqno, gpio);
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /* Turns off irq force (test register) for this port */
> + Â Â Â Â Â Â Â writel(0x0, gpio->base + portno * gpio->stride + ifr);
> +
> + Â Â Â Â Â Â Â list_add_tail(&port->node, &gpio->port_list);
> + Â Â Â }
> +
> + Â Â Â err = gpiochip_add(&gpio->chip);
> + Â Â Â if (err) {
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "unable to add gpiochip: %d\n", err);
> + Â Â Â Â Â Â Â goto err_no_chip;
> + Â Â Â }
> +
> + Â Â Â platform_set_drvdata(pdev, gpio);
> +
> + Â Â Â return 0;
> +
> +err_no_chip:
> +err_no_port:
> + Â Â Â u300_gpio_free_ports(gpio);
> +err_unknown_variant:
> + Â Â Â iounmap(gpio->base);
> +err_no_ioremap:
> + Â Â Â release_mem_region(gpio->memres->start,
> + Â Â Â Â Â Â Â Â Â Â Â Â Âgpio->memres->end - gpio->memres->start);
> +err_no_ioregion:
> +err_no_resource:
> + Â Â Â clk_disable(gpio->clk);
> +err_no_clk_enable:
> + Â Â Â clk_put(gpio->clk);
> +err_no_clk:
> + Â Â Â kfree(gpio);
> + Â Â Â dev_info(&pdev->dev, "module ERROR:%d\n", err);
> + Â Â Â return err;
> +}
> +
> +static int __exit u300_gpio_remove(struct platform_device *pdev)
> +{
> + Â Â Â struct u300_gpio_platform *plat = dev_get_platdata(&pdev->dev);
> + Â Â Â struct u300_gpio *gpio = platform_get_drvdata(pdev);
> + Â Â Â int err;
> +
> + Â Â Â /* Turn off the GPIO block */
> + Â Â Â if (plat->variant == U300_GPIO_COH901335)
> + Â Â Â Â Â Â Â writel(0x00000000U, gpio->base + U300_335_CR);
> + Â Â Â if (plat->variant == U300_GPIO_COH901571_3_BS335 ||
> + Â Â Â Â Â plat->variant == U300_GPIO_COH901571_3_BS365)
> + Â Â Â Â Â Â Â writel(0x00000000U, gpio->base + U300_571_CR);
> +
> + Â Â Â err = gpiochip_remove(&gpio->chip);
> + Â Â Â if (err < 0) {
> + Â Â Â Â Â Â Â dev_err(gpio->dev, "unable to remove gpiochip: %d\n", err);
> + Â Â Â Â Â Â Â return err;
> + Â Â Â }
> + Â Â Â u300_gpio_free_ports(gpio);
> + Â Â Â iounmap(gpio->base);
> + Â Â Â release_mem_region(gpio->memres->start,
> + Â Â Â Â Â Â Â Â Â Â Â Â Âgpio->memres->end - gpio->memres->start);
> + Â Â Â clk_disable(gpio->clk);
> + Â Â Â clk_put(gpio->clk);
> + Â Â Â platform_set_drvdata(pdev, NULL);
> + Â Â Â kfree(gpio);
> + Â Â Â return 0;
> +}
> +
> +static struct platform_driver u300_gpio_driver = {
> +    .driver     = {
> +        .name  = "u300-gpio",
> + Â Â Â },
> +    .remove     = __exit_p(u300_gpio_remove),
> +};
> +
> +
> +static int __init u300_gpio_init(void)
> +{
> + Â Â Â return platform_driver_probe(&u300_gpio_driver, u300_gpio_probe);
> +}
> +
> +static void __exit u300_gpio_exit(void)
> +{
> + Â Â Â platform_driver_unregister(&u300_gpio_driver);
> +}
> +
> +arch_initcall(u300_gpio_init);
> +module_exit(u300_gpio_exit);
> +
> +MODULE_AUTHOR("Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>");
> +MODULE_DESCRIPTION("ST-Ericsson AB COH 901 335/COH 901 571/3 GPIO driver");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/gpio/u300.h b/include/linux/gpio/u300.h
> new file mode 100644
> index 0000000..38cd064
> --- /dev/null
> +++ b/include/linux/gpio/u300.h
> @@ -0,0 +1,32 @@
> +/*
> + * U300 GPIO platform data header
> + * Copyright (C) 2011 ST-Ericsson SA
> + * Written on behalf of Linaro for ST-Ericsson
> + *
> + * Author: Linus Walleij <linus.walleij@xxxxxxxxxx>
> + *
> + * License terms: GNU General Public License (GPL) version 2
> + */
> +
> +/**
> + * enum u300_gpio_variant - the type of U300 GPIO employed
> + */
> +enum u300_gpio_variant {
> + Â Â Â U300_GPIO_COH901335,
> + Â Â Â U300_GPIO_COH901571_3_BS335,
> + Â Â Â U300_GPIO_COH901571_3_BS365,
> +};
> +
> +/**
> + * struct u300_gpio_platform - U300 GPIO platform data
> + * @variant: IP block variant
> + * @ports: number of GPIO block ports
> + * @gpio_base: first GPIO number for this block (use a free range)
> + * @gpio_irq_base: first GPIO IRQ number for this block (use a free range)
> + */
> +struct u300_gpio_platform {
> + Â Â Â enum u300_gpio_variant variant;
> + Â Â Â u8 ports;
> + Â Â Â int gpio_base;
> + Â Â Â int gpio_irq_base;
> +};
> --
> 1.7.3.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
¢éì®&Þ~º&¶¬–+-±éÝ¥Šw®žË±Êâmébžìdz¹Þ)í…æèw*jg¬±¨¶‰šŽŠÝj/êäz¹ÞŠà2ŠÞ¨è­Ú&¢)ß«a¶Úþø®G«éh®æj:+v‰¨Šwè†Ù>Wš±êÞiÛaxPjØm¶Ÿÿà -»+ƒùdš_