linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: kgene.kim@samsung.com (Kukjin Kim)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/6] ARM: Samsung: Add common samsung_gpiolib_to_irq function
Date: Fri, 01 Oct 2010 13:49:21 +0900	[thread overview]
Message-ID: <00fb01cb6124$068a8790$139f96b0$%kim@samsung.com> (raw)
In-Reply-To: <1283764347-460-6-git-send-email-m.szyprowski@samsung.com>

Marek Szyprowski wrote:
> 
> From: Joonyoung Shim <jy0922.shim@samsung.com>
> 
> This patch adds a common callback for gpio_to_irq() for external and
> gpio interrupts for Samsung SoCs.
> 
> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  arch/arm/mach-s3c64xx/gpiolib.c                |    8 +----
>  arch/arm/mach-s5pc100/gpiolib.c                |   31
++++++-----------------
>  arch/arm/mach-s5pv210/gpiolib.c                |    8 ++++++
>  arch/arm/plat-s3c24xx/gpiolib.c                |    8 +----
>  arch/arm/plat-s5p/irq-gpioint.c                |    1 +
>  arch/arm/plat-samsung/gpiolib.c                |    8 ++++++
>  arch/arm/plat-samsung/include/plat/gpio-core.h |   11 ++++++++
>  7 files changed, 40 insertions(+), 35 deletions(-)
> 
> diff --git a/arch/arm/mach-s3c64xx/gpiolib.c
b/arch/arm/mach-s3c64xx/gpiolib.c
> index 300dee4..fd99a82 100644
> --- a/arch/arm/mach-s3c64xx/gpiolib.c
> +++ b/arch/arm/mach-s3c64xx/gpiolib.c
> @@ -195,11 +195,6 @@ static struct s3c_gpio_cfg gpio_2bit_cfg_eint11 = {
>  	.get_pull	= s3c_gpio_getpull_updown,
>  };
> 
> -int s3c64xx_gpio2int_gpn(struct gpio_chip *chip, unsigned pin)
> -{
> -	return IRQ_EINT(0) + pin;
> -}
> -
>  static struct s3c_gpio_chip gpio_2bit[] = {
>  	{
>  		.base	= S3C64XX_GPF_BASE,
> @@ -227,12 +222,13 @@ static struct s3c_gpio_chip gpio_2bit[] = {
>  		},
>  	}, {
>  		.base	= S3C64XX_GPN_BASE,
> +		.irq_base = IRQ_EINT(0),
>  		.config	= &gpio_2bit_cfg_eint10,
>  		.chip	= {
>  			.base	= S3C64XX_GPN(0),
>  			.ngpio	= S3C64XX_GPIO_N_NR,
>  			.label	= "GPN",
> -			.to_irq = s3c64xx_gpio2int_gpn,
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= S3C64XX_GPO_BASE,
> diff --git a/arch/arm/mach-s5pc100/gpiolib.c
b/arch/arm/mach-s5pc100/gpiolib.c
> index 5811578..def4ff8 100644
> --- a/arch/arm/mach-s5pc100/gpiolib.c
> +++ b/arch/arm/mach-s5pc100/gpiolib.c
> @@ -61,25 +61,6 @@
>   * L3	8	4Bit	None
>   */
> 
> -static int s5pc100_gpiolib_to_eint(struct gpio_chip *chip, unsigned int
offset)
> -{
> -	int base;
> -
> -	base = chip->base - S5PC100_GPH0(0);
> -	if (base == 0)
> -		return IRQ_EINT(offset);
> -	base = chip->base - S5PC100_GPH1(0);
> -	if (base == 0)
> -		return IRQ_EINT(8 + offset);
> -	base = chip->base - S5PC100_GPH2(0);
> -	if (base == 0)
> -		return IRQ_EINT(16 + offset);
> -	base = chip->base - S5PC100_GPH3(0);
> -	if (base == 0)
> -		return IRQ_EINT(24 + offset);
> -	return -EINVAL;
> -}
> -
>  static struct s3c_gpio_cfg gpio_cfg = {
>  	.set_config	= s3c_gpio_setcfg_s3c64xx_4bit,
>  	.set_pull	= s3c_gpio_setpull_updown,
> @@ -223,38 +204,42 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
>  	}, {
>  		.base	= S5PC100_GPH0_BASE,
>  		.config	= &gpio_cfg_eint,
> +		.irq_base = IRQ_EINT(0),
>  		.chip	= {
>  			.base	= S5PC100_GPH0(0),
>  			.ngpio	= S5PC100_GPIO_H0_NR,
>  			.label	= "GPH0",
> -			.to_irq = s5pc100_gpiolib_to_eint,
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= S5PC100_GPH1_BASE,
>  		.config	= &gpio_cfg_eint,
> +		.irq_base = IRQ_EINT(8),
>  		.chip	= {
>  			.base	= S5PC100_GPH1(0),
>  			.ngpio	= S5PC100_GPIO_H1_NR,
>  			.label	= "GPH1",
> -			.to_irq = s5pc100_gpiolib_to_eint,
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= S5PC100_GPH2_BASE,
>  		.config	= &gpio_cfg_eint,
> +		.irq_base = IRQ_EINT(16),
>  		.chip	= {
>  			.base	= S5PC100_GPH2(0),
>  			.ngpio	= S5PC100_GPIO_H2_NR,
>  			.label	= "GPH2",
> -			.to_irq = s5pc100_gpiolib_to_eint,
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= S5PC100_GPH3_BASE,
>  		.config	= &gpio_cfg_eint,
> +		.irq_base = IRQ_EINT(24),
>  		.chip	= {
>  			.base	= S5PC100_GPH3(0),
>  			.ngpio	= S5PC100_GPIO_H3_NR,
>  			.label	= "GPH3",
> -			.to_irq = s5pc100_gpiolib_to_eint,
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= S5PC100_GPI_BASE,
> diff --git a/arch/arm/mach-s5pv210/gpiolib.c
b/arch/arm/mach-s5pv210/gpiolib.c
> index 29dfb89..ab673ef 100644
> --- a/arch/arm/mach-s5pv210/gpiolib.c
> +++ b/arch/arm/mach-s5pv210/gpiolib.c
> @@ -224,34 +224,42 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
>  	}, {
>  		.base	= (S5P_VA_GPIO + 0xC00),
>  		.config	= &gpio_cfg_noint,
> +		.irq_base = IRQ_EINT(0),
>  		.chip	= {
>  			.base	= S5PV210_GPH0(0),
>  			.ngpio	= S5PV210_GPIO_H0_NR,
>  			.label	= "GPH0",
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= (S5P_VA_GPIO + 0xC20),
>  		.config	= &gpio_cfg_noint,
> +		.irq_base = IRQ_EINT(8),
>  		.chip	= {
>  			.base	= S5PV210_GPH1(0),
>  			.ngpio	= S5PV210_GPIO_H1_NR,
>  			.label	= "GPH1",
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= (S5P_VA_GPIO + 0xC40),
>  		.config	= &gpio_cfg_noint,
> +		.irq_base = IRQ_EINT(16),
>  		.chip	= {
>  			.base	= S5PV210_GPH2(0),
>  			.ngpio	= S5PV210_GPIO_H2_NR,
>  			.label	= "GPH2",
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= (S5P_VA_GPIO + 0xC60),
>  		.config	= &gpio_cfg_noint,
> +		.irq_base = IRQ_EINT(24),
>  		.chip	= {
>  			.base	= S5PV210_GPH3(0),
>  			.ngpio	= S5PV210_GPIO_H3_NR,
>  			.label	= "GPH3",
> +			.to_irq = samsung_gpiolib_to_irq,
>  		},
>  	},
>  };
> diff --git a/arch/arm/plat-s3c24xx/gpiolib.c
b/arch/arm/plat-s3c24xx/gpiolib.c
> index 4c0896f..243b641 100644
> --- a/arch/arm/plat-s3c24xx/gpiolib.c
> +++ b/arch/arm/plat-s3c24xx/gpiolib.c
> @@ -74,11 +74,6 @@ static int s3c24xx_gpiolib_bankf_toirq(struct gpio_chip
> *chip, unsigned offset)
>  	return -EINVAL;
>  }
> 
> -static int s3c24xx_gpiolib_bankg_toirq(struct gpio_chip *chip, unsigned
offset)
> -{
> -	return IRQ_EINT8 + offset;
> -}
> -
>  static struct s3c_gpio_cfg s3c24xx_gpiocfg_banka = {
>  	.set_config	= s3c_gpio_setcfg_s3c24xx_a,
>  	.get_config	= s3c_gpio_getcfg_s3c24xx_a,
> @@ -157,12 +152,13 @@ struct s3c_gpio_chip s3c24xx_gpios[] = {
>  	[6] = {
>  		.base	= S3C2410_GPGCON,
>  		.pm	= __gpio_pm(&s3c_gpio_pm_2bit),
> +		.irq_base = IRQ_EINT8,
>  		.chip	= {
>  			.base			= S3C2410_GPG(0),
>  			.owner			= THIS_MODULE,
>  			.label			= "GPIOG",
>  			.ngpio			= 16,
> -			.to_irq			=
> s3c24xx_gpiolib_bankg_toirq,
> +			.to_irq			= samsung_gpiolib_to_irq,
>  		},
>  	}, {
>  		.base	= S3C2410_GPHCON,
> diff --git a/arch/arm/plat-s5p/irq-gpioint.c
b/arch/arm/plat-s5p/irq-gpioint.c
> index 7409ae0..5b735b1 100644
> --- a/arch/arm/plat-s5p/irq-gpioint.c
> +++ b/arch/arm/plat-s5p/irq-gpioint.c
> @@ -235,6 +235,7 @@ int __init s5p_register_gpio_interrupt(int pin)
>  	/* register gpio group */
>  	ret = s5p_gpioint_add(my_chip);
>  	if (ret == 0) {
> +		my_chip->chip.to_irq = samsung_gpiolib_to_irq;
>  		printk(KERN_INFO "Registered interrupt support for gpio
> group %d.\n",
>  		       group);
>  		return my_chip->irq_base + offset;
> diff --git a/arch/arm/plat-samsung/gpiolib.c
b/arch/arm/plat-samsung/gpiolib.c
> index c354089..f2dc389 100644
> --- a/arch/arm/plat-samsung/gpiolib.c
> +++ b/arch/arm/plat-samsung/gpiolib.c
> @@ -197,3 +197,11 @@ void __init samsung_gpiolib_add_4bit2_chips(struct
> s3c_gpio_chip *chip,
>  		s3c_gpiolib_add(chip);
>  	}
>  }
> +
> +int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset)
> +{
> +	struct s3c_gpio_chip *s3c_chip = container_of(chip,
> +			struct s3c_gpio_chip, chip);
> +
> +	return s3c_chip->irq_base + offset;
> +}

Hi,

Following is for your information...

Moved samsung_gpiolib_to_irq() into plat-samsung/gpio.c because happened
build error like following after applying this.

arch/arm/plat-s3c24xx/built-in.o:(.data+0x11c4): undefined reference to
`samsung_gpiolib_to_irq'

The reason is that plat-samsung/gpiolib.c is not required for
s3c24xx...applied anyway with modifying.

> diff --git a/arch/arm/plat-samsung/include/plat/gpio-core.h
b/arch/arm/plat-
> samsung/include/plat/gpio-core.h
> index c22c27c..13a22b8 100644
> --- a/arch/arm/plat-samsung/include/plat/gpio-core.h
> +++ b/arch/arm/plat-samsung/include/plat/gpio-core.h
> @@ -122,6 +122,17 @@ extern void samsung_gpiolib_add_4bit2_chips(struct
> s3c_gpio_chip *chip,
>  extern void samsung_gpiolib_add_4bit(struct s3c_gpio_chip *chip);
>  extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip);
> 
> +
> +/**
> + * samsung_gpiolib_to_irq - convert gpio pin to irq number
> + * @chip: The gpio chip that the pin belongs to.
> + * @offset: The offset of the pin in the chip.
> + *
> + * This helper returns the irq number calculated from the chip->irq_base
and
> + * the provided offset.
> + */
> +extern int samsung_gpiolib_to_irq(struct gpio_chip *chip, unsigned int
offset);
> +
>  /* exported for core SoC support to change */
>  extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default;
> 
> --


Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

  reply	other threads:[~2010-10-01  4:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06  9:12 [PATCH v3] ARM: S5P: Add support for gpio interrupts Marek Szyprowski
2010-09-06  9:12 ` [PATCH 1/6] ARM: Samsung: Add common s5p gpio interrupt support Marek Szyprowski
2010-09-28 14:03   ` Kukjin Kim
2010-09-28 14:24     ` Marek Szyprowski
2010-09-28 14:43       ` Kyungmin Park
2010-09-30  7:12       ` [PATCH v4] " Marek Szyprowski
2010-09-30 13:29         ` Kukjin Kim
2010-09-30 13:47           ` Kyungmin Park
2010-09-06  9:12 ` [PATCH 2/6] ARM: S5PC110: add support for gpio interrupts Marek Szyprowski
2010-09-06  9:12 ` [PATCH 3/6] ARM: S5PC100: Use generic S5P gpio interrupts interface Marek Szyprowski
2010-09-06  9:12 ` [PATCH 4/6] ARM: S5PC100: Move external interrupt defines Marek Szyprowski
2010-09-10 12:00   ` Kukjin Kim
2010-09-21  5:16     ` Marek Szyprowski
2010-09-06  9:12 ` [PATCH 5/6] ARM: Samsung: Add common samsung_gpiolib_to_irq function Marek Szyprowski
2010-10-01  4:49   ` Kukjin Kim [this message]
2010-10-01  5:19     ` Marek Szyprowski
2010-09-06  9:12 ` [PATCH 6/6] ARM: S5PC110: GONI: Add support for QT602240 TS driver Marek Szyprowski
2010-10-04  9:22   ` [PATCH RESEND] " Marek Szyprowski
2010-10-04  9:40     ` Kukjin Kim
2010-09-29  6:49 ` [PATCH v3] ARM: S5P: Add support for gpio interrupts Kukjin Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00fb01cb6124$068a8790$139f96b0$%kim@samsung.com' \
    --to=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).