Skip to contentSkip to conversation

ARM: S5PC100: Move external interrupt defines

PATCH New Joonyoung Shim 2 participants 9 messages Jun 3, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 ARM: S5PC100: Move external interrupt defines

This patch moves external interrupt defines from gpio.h to regs-gpio.h for consistency with s5pv210.

---
 arch/arm/mach-s5pc100/include/mach/gpio.h      |    7 -------
 arch/arm/mach-s5pc100/include/mach/regs-gpio.h |    7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-s5pc100/include/mach/gpio.h +0 -7
index 71ae1f5..29a8a12 100644
@@ -146,13 +146,6 @@ enum s5p_gpio_number {
 /* define the number of gpios we need to the one after the MP04() range */
 #define ARCH_NR_GPIOS		(S5PC100_GPIO_END + 1)
 
-#define EINT_MODE		S3C_GPIO_SFN(0x2)
-
-#define EINT_GPIO_0(x)		S5PC100_GPH0(x)
-#define EINT_GPIO_1(x)		S5PC100_GPH1(x)
-#define EINT_GPIO_2(x)		S5PC100_GPH2(x)
-#define EINT_GPIO_3(x)		S5PC100_GPH3(x)
-
 #include <asm-generic/gpio.h>
 
 #endif /* __ASM_ARCH_GPIO_H */
arch/arm/mach-s5pc100/include/mach/regs-gpio.h +7 -0
index dd6295e..6abe481 100644
@@ -71,5 +71,12 @@
 #define S5P_EXTINT_RISEEDGE		(0x03)
 #define S5P_EXTINT_BOTHEDGE		(0x04)
 
+#define EINT_MODE		S3C_GPIO_SFN(0x2)
+
+#define EINT_GPIO_0(x)		S5PC100_GPH0(x)
+#define EINT_GPIO_1(x)		S5PC100_GPH1(x)
+#define EINT_GPIO_2(x)		S5PC100_GPH2(x)
+#define EINT_GPIO_3(x)		S5PC100_GPH3(x)
+
 #endif /* __ASM_MACH_S5PC100_REGS_GPIO_H */
 
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 2/7 ARM: S5P: Add GPIOlib gpio_to_irq for external interrupts

This patch is to support gpio_to_irq() of GPIOlib for external interrupts. The gpio_to_irq() calls s5p_gpiolib_eint_to_irq function.

---
 arch/arm/plat-s5p/Makefile                     |    1 +
 arch/arm/plat-s5p/gpiolib.c                    |   35 ++++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/gpio-core.h |    2 +
 3 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-s5p/gpiolib.c
arch/arm/plat-s5p/Makefile +1 -0
index 39c242b..f6e1a13 100644
@@ -15,6 +15,7 @@ obj-				:=
 obj-y				+= dev-uart.o
 obj-y				+= cpu.o
 obj-y				+= clock.o
+obj-y				+= gpiolib.o
 obj-y				+= irq.o
 obj-$(CONFIG_S5P_EXT_INT)	+= irq-eint.o
 
arch/arm/plat-s5p/gpiolib.c new file +35 -0
new file mode 100644
index 0000000..0c27a9d
@@ -0,0 +1,35 @@
+/*
+ * linux/arch/arm/plat-s5p/gpiolib.c
+ *
+ * Copyright (C) 2010 Samsung Electronics Co.Ltd
+ * Author: Joonyoung Shim <[email protected]>
+ *
+ * S5P - GPIOlib support
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include <linux/gpio.h>
+#include <mach/irqs.h>
+#include <mach/regs-gpio.h>
+
+/* be called from gpio_to_irq() for external interrupts */
+int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset)
+{
+	switch (chip->base) {
+	case EINT_GPIO_0(0):
+		return IRQ_EINT(offset);
+	case EINT_GPIO_1(0):
+		return IRQ_EINT(8 + offset);
+	case EINT_GPIO_2(0):
+		return IRQ_EINT(16 + offset);
+	case EINT_GPIO_3(0):
+		return IRQ_EINT(24 + offset);
+	default:
+		return -EINVAL;
+	}
+}
arch/arm/plat-samsung/include/plat/gpio-core.h +2 -0
index e358c7d..f6c5151 100644
@@ -121,6 +121,8 @@ extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip);
 /* exported for core SoC support to change */
 extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default;
 
+extern int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset);
+
 #ifdef CONFIG_S3C_GPIO_TRACK
 extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END];
 
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 2/7 ARM: S5P: Add GPIOlib gpio_to_irq for external interrupts

Quoted 2 lines · Joonyoung Shim

This patch is to support gpio_to_irq() of GPIOlib for external interrupts. The gpio_to_irq() calls s5p_gpiolib_eint_to_irq function.

How about each s3c_gpio_chip have a irq base in it?

Quoted 78 lines
---
 arch/arm/plat-s5p/Makefile                     |    1 +
 arch/arm/plat-s5p/gpiolib.c                    |   35 ++++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/gpio-core.h |    2 +
 3 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-s5p/gpiolib.c
arch/arm/plat-s5p/Makefile +1 -0
index 39c242b..f6e1a13 100644
@@ -15,6 +15,7 @@ obj-				:=
 obj-y				+= dev-uart.o
 obj-y				+= cpu.o
 obj-y				+= clock.o
+obj-y				+= gpiolib.o
 obj-y				+= irq.o
 obj-$(CONFIG_S5P_EXT_INT)	+= irq-eint.o
 
arch/arm/plat-s5p/gpiolib.c new file +35 -0
new file mode 100644
index 0000000..0c27a9d
@@ -0,0 +1,35 @@
+/*
+ * linux/arch/arm/plat-s5p/gpiolib.c
+ *
+ * Copyright (C) 2010 Samsung Electronics Co.Ltd
+ * Author: Joonyoung Shim <[email protected]>
+ *
+ * S5P - GPIOlib support
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include <linux/gpio.h>
+#include <mach/irqs.h>
+#include <mach/regs-gpio.h>
+
+/* be called from gpio_to_irq() for external interrupts */
+int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset)
+{
+	switch (chip->base) {
+	case EINT_GPIO_0(0):
+		return IRQ_EINT(offset);
+	case EINT_GPIO_1(0):
+		return IRQ_EINT(8 + offset);
+	case EINT_GPIO_2(0):
+		return IRQ_EINT(16 + offset);
+	case EINT_GPIO_3(0):
+		return IRQ_EINT(24 + offset);
+	default:
+		return -EINVAL;
+	}
+}
arch/arm/plat-samsung/include/plat/gpio-core.h +2 -0
index e358c7d..f6c5151 100644
@@ -121,6 +121,8 @@ extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip);
 /* exported for core SoC support to change */
 extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default;
 
+extern int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset);
+
 #ifdef CONFIG_S3C_GPIO_TRACK
 extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END];
 
Signature · 1 line
1.7.0.4
Signature · 5 lines
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.
#3 lore raw

PATCH 2/7 ARM: S5P: Add GPIOlib gpio_to_irq for external interrupts

Quoted 6 lines · Ben Dooks
Quoted 2 lines · Joonyoung Shim

This patch is to support gpio_to_irq() of GPIOlib for external interrupts. The gpio_to_irq() calls s5p_gpiolib_eint_to_irq function.

How about each s3c_gpio_chip have a irq base in it?

Good, then it can be arch and irq type(gpio, external)independent codes.

Quoted 79 lines
Quoted 78 lines
---
 arch/arm/plat-s5p/Makefile                     |    1 +
 arch/arm/plat-s5p/gpiolib.c                    |   35 ++++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/gpio-core.h |    2 +
 3 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-s5p/gpiolib.c
arch/arm/plat-s5p/Makefile +1 -0
index 39c242b..f6e1a13 100644
@@ -15,6 +15,7 @@ obj-				:=
 obj-y				+= dev-uart.o
 obj-y				+= cpu.o
 obj-y				+= clock.o
+obj-y				+= gpiolib.o
 obj-y				+= irq.o
 obj-$(CONFIG_S5P_EXT_INT)	+= irq-eint.o
 
arch/arm/plat-s5p/gpiolib.c new file +35 -0
new file mode 100644
index 0000000..0c27a9d
@@ -0,0 +1,35 @@
+/*
+ * linux/arch/arm/plat-s5p/gpiolib.c
+ *
+ * Copyright (C) 2010 Samsung Electronics Co.Ltd
+ * Author: Joonyoung Shim <[email protected]>
+ *
+ * S5P - GPIOlib support
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ */
+
+#include <linux/gpio.h>
+#include <mach/irqs.h>
+#include <mach/regs-gpio.h>
+
+/* be called from gpio_to_irq() for external interrupts */
+int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset)
+{
+	switch (chip->base) {
+	case EINT_GPIO_0(0):
+		return IRQ_EINT(offset);
+	case EINT_GPIO_1(0):
+		return IRQ_EINT(8 + offset);
+	case EINT_GPIO_2(0):
+		return IRQ_EINT(16 + offset);
+	case EINT_GPIO_3(0):
+		return IRQ_EINT(24 + offset);
+	default:
+		return -EINVAL;
+	}
+}
arch/arm/plat-samsung/include/plat/gpio-core.h +2 -0
index e358c7d..f6c5151 100644
@@ -121,6 +121,8 @@ extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip);
 /* exported for core SoC support to change */
 extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default;
 
+extern int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset);
+
 #ifdef CONFIG_S3C_GPIO_TRACK
 extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END];
 
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH 3/7 ARM: S5PV210: Support GPIOlib gpio_to_irq for external interrupts

In reply to Joonyoung Shim

This patch is to support GPIOlib gpio_to_irq for external interrupts to s5pv210 machine.

---
 arch/arm/mach-s5pv210/gpiolib.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-s5pv210/gpiolib.c +4 -0
index 9ea8972..5b73c3e 100644
@@ -213,6 +213,7 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
 			.base	= S5PV210_GPH0(0),
 			.ngpio	= S5PV210_GPIO_H0_NR,
 			.label	= "GPH0",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	}, {
 		.base	= (S5P_VA_GPIO + 0xC20),
@@ -221,6 +222,7 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
 			.base	= S5PV210_GPH1(0),
 			.ngpio	= S5PV210_GPIO_H1_NR,
 			.label	= "GPH1",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	}, {
 		.base	= (S5P_VA_GPIO + 0xC40),
@@ -229,6 +231,7 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
 			.base	= S5PV210_GPH2(0),
 			.ngpio	= S5PV210_GPIO_H2_NR,
 			.label	= "GPH2",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	}, {
 		.base	= (S5P_VA_GPIO + 0xC60),
@@ -237,6 +240,7 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
 			.base	= S5PV210_GPH3(0),
 			.ngpio	= S5PV210_GPIO_H3_NR,
 			.label	= "GPH3",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	},
 };
Signature · 1 line
1.7.0.4
#5 lore raw

PATCH 4/7 ARM: S5PC100: Use S5P GPIOlib gpio_to_irq function for external interrupts

In reply to Joonyoung Shim

This changes from s5pc100 machine specific gpio_to_irq function to S5P GPIOlib gpio_to_irq function for external interrupts.

---
 arch/arm/mach-s5pc100/gpiolib.c |   25 ++++---------------------
 1 files changed, 4 insertions(+), 21 deletions(-)
arch/arm/mach-s5pc100/gpiolib.c +4 -21
index 0fab7f2..60704ef 100644
@@ -66,25 +66,6 @@ static int s5pc100_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset)
 	return S3C_IRQ_GPIO(chip->base + offset);
 }
 
-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,
@@ -232,6 +213,7 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
 			.base	= S5PC100_GPH0(0),
 			.ngpio	= S5PC100_GPIO_H0_NR,
 			.label	= "GPH0",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	}, {
 		.base	= S5PC100_GPH1_BASE,
@@ -240,6 +222,7 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
 			.base	= S5PC100_GPH1(0),
 			.ngpio	= S5PC100_GPIO_H1_NR,
 			.label	= "GPH1",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	}, {
 		.base	= S5PC100_GPH2_BASE,
@@ -248,6 +231,7 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
 			.base	= S5PC100_GPH2(0),
 			.ngpio	= S5PC100_GPIO_H2_NR,
 			.label	= "GPH2",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	}, {
 		.base	= S5PC100_GPH3_BASE,
@@ -256,6 +240,7 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
 			.base	= S5PC100_GPH3(0),
 			.ngpio	= S5PC100_GPIO_H3_NR,
 			.label	= "GPH3",
+			.to_irq = s5p_gpiolib_eint_to_irq,
 		},
 	}, {
 		.base	= S5PC100_GPI_BASE,
@@ -399,8 +384,6 @@ static __init void s5pc100_gpiolib_link(struct s3c_gpio_chip *chip)
 			set_irq_handler(irq, handle_level_irq);
 			set_irq_flags(irq, IRQF_VALID);
 		}
-	} else if (chip->config == &gpio_cfg_eint) {
-		chip->chip.to_irq = s5pc100_gpiolib_to_eint;
 	}
 }
 
Signature · 1 line
1.7.0.4
#6 lore raw

PATCH 5/7 ARM: S5PV210: Add gpio interrupt support

In reply to Joonyoung Shim

This patch is to support gpio interrupts on s5pv210.

---
 arch/arm/mach-s5pv210/gpiolib.c                |    8 +-
 arch/arm/mach-s5pv210/include/mach/irqs.h      |   16 ++-
 arch/arm/plat-s5p/Makefile                     |    2 +-
 arch/arm/plat-s5p/irq-gpioint.c                |  208 ++++++++++++++++++++++++
 arch/arm/plat-samsung/include/plat/gpio-core.h |    2 +
 5 files changed, 233 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/plat-s5p/irq-gpioint.c
arch/arm/mach-s5pv210/gpiolib.c +7 -1
index 5b73c3e..166725f 100644
@@ -150,6 +150,7 @@ static struct s3c_gpio_chip s5pv210_gpio_4bit[] = {
 			.label	= "GPG3",
 		},
 	}, {
+		.config	= &gpio_cfg_noint,
 		.chip	= {
 			.base	= S5PV210_GPI(0),
 			.ngpio	= S5PV210_GPIO_I_NR,
@@ -249,11 +250,16 @@ static __init int s5pv210_gpiolib_init(void)
 {
 	struct s3c_gpio_chip *chip = s5pv210_gpio_4bit;
 	int nr_chips = ARRAY_SIZE(s5pv210_gpio_4bit);
+	int gpioint_group = 0;
 	int i = 0;
 
 	for (i = 0; i < nr_chips; i++, chip++) {
-		if (chip->config == NULL)
+		if (chip->config == NULL) {
 			chip->config = &gpio_cfg;
+
+			/* gpio interrupts */
+			s5p_gpioint_add(chip, gpioint_group++);
+		}
 		if (chip->base == NULL)
 			chip->base = S5PV210_BANK_BASE(i);
 	}
arch/arm/mach-s5pv210/include/mach/irqs.h +15 -1
index 9689537..43baacc 100644
@@ -121,8 +121,22 @@
 #define S5P_EINT_BASE1		(S5P_IRQ_VIC0(0))
 #define S5P_EINT_BASE2		(IRQ_VIC_END + 1)
 
+/* GPIO interrupt */
+#define S5P_GPIOINT_GROUP_NR	22
+#define S5P_GPIOINT_BASE	(IRQ_EINT(31) + 1)
+#define S5P_IRQ_GPIOINT(x)	(S5P_GPIOINT_BASE + (x))
+
 /* Set the default NR_IRQS */
-#define NR_IRQS			(IRQ_EINT(31) + 1)
+
+/*
+ * GPIO groups is 27. Each GPIO group can have max 8 GPIO interrupts.
+ *
+ * We should include gpios of all gpio groups from GPIO_A0 until GPIO_J4 to
+ * NR_IRQS because 22 gpio groups having gpio interrupts aren't in order and
+ * are mixed with no interrupt gpio groups, then it can give simple irq
+ * computation of gpio interrupts.
+ */
+#define NR_IRQS			(S5P_IRQ_GPIOINT(27 * 8) + 1)
 
 /* Compatibility */
 #define IRQ_LCD_FIFO		IRQ_LCD0
arch/arm/plat-s5p/Makefile +1 -1
index f6e1a13..23c153c 100644
@@ -16,6 +16,6 @@ obj-y				+= dev-uart.o
 obj-y				+= cpu.o
 obj-y				+= clock.o
 obj-y				+= gpiolib.o
-obj-y				+= irq.o
+obj-y				+= irq.o irq-gpioint.o
 obj-$(CONFIG_S5P_EXT_INT)	+= irq-eint.o
 
arch/arm/plat-s5p/irq-gpioint.c new file +208 -0

208 lines not on this page · raw message

arch/arm/plat-samsung/include/plat/gpio-core.h +2 -0
index f6c5151..a6b844c 100644
@@ -123,6 +123,8 @@ extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default;
 
 extern int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset);
 
+extern void s5p_gpioint_add(struct s3c_gpio_chip *chip, int group);
+
 #ifdef CONFIG_S3C_GPIO_TRACK
 extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END];
 
Signature · 1 line
1.7.0.4
#7 lore raw

PATCH 6/7 ARM: S5PC100: Use S5P gpio interrupts interface

In reply to Joonyoung Shim

The s5pc100 can use s5p gpio interrupts codes instead of s5pc100 specific gpio interrupts codes.

---
 arch/arm/mach-s5pc100/Makefile            |    2 +-
 arch/arm/mach-s5pc100/gpiolib.c           |   37 +---
 arch/arm/mach-s5pc100/include/mach/irqs.h |   18 ++-
 arch/arm/mach-s5pc100/irq-gpio.c          |  266 -----------------------------
 4 files changed, 24 insertions(+), 299 deletions(-)
 delete mode 100644 arch/arm/mach-s5pc100/irq-gpio.c
arch/arm/mach-s5pc100/Makefile +1 -1
index 543f3de..e9723f8 100644
@@ -11,7 +11,7 @@ obj-				:=
 
 # Core support for S5PC100 system
 
-obj-$(CONFIG_CPU_S5PC100)	+= cpu.o init.o clock.o gpiolib.o irq-gpio.o
+obj-$(CONFIG_CPU_S5PC100)	+= cpu.o init.o clock.o gpiolib.o
 obj-$(CONFIG_CPU_S5PC100)	+= setup-i2c0.o
 obj-$(CONFIG_CPU_S5PC100)	+= dma.o
 
arch/arm/mach-s5pc100/gpiolib.c +9 -28
index 60704ef..a34a700 100644
@@ -63,7 +63,7 @@
 
 static int s5pc100_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset)
 {
-	return S3C_IRQ_GPIO(chip->base + offset);
+	return S5P_IRQ_GPIOINT(chip->base + offset);
 }
 
 static struct s3c_gpio_cfg gpio_cfg = {
@@ -365,45 +365,26 @@ static struct s3c_gpio_chip s5pc100_gpio_chips[] = {
 	},
 };
 
-/* FIXME move from irq-gpio.c */
-extern struct irq_chip s5pc100_gpioint;
-extern void s5pc100_irq_gpioint_handler(unsigned int irq, struct irq_desc *desc);
-
-static __init void s5pc100_gpiolib_link(struct s3c_gpio_chip *chip)
-{
-	/* Interrupt */
-	if (chip->config == &gpio_cfg) {
-		int i, irq;
-
-		chip->chip.to_irq = s5pc100_gpiolib_to_irq;
-
-		for (i = 0;  i < chip->chip.ngpio; i++) {
-			irq = S3C_IRQ_GPIO_BASE + chip->chip.base + i;
-			set_irq_chip(irq, &s5pc100_gpioint);
-			set_irq_data(irq, &chip->chip);
-			set_irq_handler(irq, handle_level_irq);
-			set_irq_flags(irq, IRQF_VALID);
-		}
-	}
-}
-
 static __init int s5pc100_gpiolib_init(void)
 {
 	struct s3c_gpio_chip *chip;
 	int nr_chips;
+	int gpioint_group = 0;
 
 	chip = s5pc100_gpio_chips;
 	nr_chips = ARRAY_SIZE(s5pc100_gpio_chips);
 
-	for (; nr_chips > 0; nr_chips--, chip++)
-		s5pc100_gpiolib_link(chip);
+	for (; nr_chips > 0; nr_chips--, chip++) {
+		if (chip->config == &gpio_cfg) {
+			/* gpio interrupts */
+			chip->chip.to_irq = s5pc100_gpiolib_to_irq;
+			s5p_gpioint_add(chip, gpioint_group++);
+		}
+	}
 
 	samsung_gpiolib_add_4bit_chips(s5pc100_gpio_chips,
 				       ARRAY_SIZE(s5pc100_gpio_chips));
 
-	/* Interrupt */
-	set_irq_chained_handler(IRQ_GPIOINT, s5pc100_irq_gpioint_handler);
-
 	return 0;
 }
 core_initcall(s5pc100_gpiolib_init);
arch/arm/mach-s5pc100/include/mach/irqs.h +14 -4
index 28aa551..8f725bd 100644
@@ -100,11 +100,21 @@
 #define S5P_EINT_BASE1		(S5P_IRQ_VIC0(0))
 #define S5P_EINT_BASE2		(IRQ_VIC_END + 1)
 
-#define S3C_IRQ_GPIO_BASE	(IRQ_EINT(31) + 1)
-#define S3C_IRQ_GPIO(x)		(S3C_IRQ_GPIO_BASE + (x))
+#define S5P_GPIOINT_GROUP_NR	21
+#define S5P_GPIOINT_BASE	(IRQ_EINT(31) + 1)
+#define S5P_IRQ_GPIOINT(x)	(S5P_GPIOINT_BASE + (x))
 
-/* Until MP04 Groups -> 40 (exactly 39) Groups * 8 ~= 320 GPIOs */
-#define NR_IRQS		(S3C_IRQ_GPIO(320) + 1)
+/* Set the default NR_IRQS */
+
+/*
+ * GPIO groups is 25. Each GPIO group can have max 8 GPIO interrupts.
+ *
+ * We should include gpios of all gpio groups from GPIO_A0 until GPIO_J4 to
+ * NR_IRQS because 21 gpio groups having gpio interrupts aren't in order and
+ * are mixed with no interrupt gpio groups, then it can give simple irq
+ * computation of gpio interrupts.
+ */
+#define NR_IRQS			(S5P_IRQ_GPIOINT(25 * 8) + 1)
 
 /* Compatibility */
 #define IRQ_LCD_FIFO		IRQ_LCD0
arch/arm/mach-s5pc100/irq-gpio.c deleted +0 -266

266 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#8 lore raw

PATCH 7/7 ARM: S5P: Add GPIOlib gpio_to_irq for gpio interrupts

In reply to Joonyoung Shim

This patch is to support gpio_to_irq() of GPIOlib for gpio interrupts on s5p cpus. The gpio_to_irq() calls s5p_gpiolib_gpioint_to_irq function.

---
 arch/arm/mach-s5pc100/gpiolib.c                |    7 +------
 arch/arm/mach-s5pv210/gpiolib.c                |    1 +
 arch/arm/plat-s5p/gpiolib.c                    |    7 +++++++
 arch/arm/plat-samsung/include/plat/gpio-core.h |    2 ++
 4 files changed, 11 insertions(+), 6 deletions(-)
arch/arm/mach-s5pc100/gpiolib.c +1 -6
index a34a700..2dcb501 100644
@@ -61,11 +61,6 @@
  * L3	8	4Bit	None
  */
 
-static int s5pc100_gpiolib_to_irq(struct gpio_chip *chip, unsigned int offset)
-{
-	return S5P_IRQ_GPIOINT(chip->base + offset);
-}
-
 static struct s3c_gpio_cfg gpio_cfg = {
 	.set_config	= s3c_gpio_setcfg_s3c64xx_4bit,
 	.set_pull	= s3c_gpio_setpull_updown,
@@ -377,7 +372,7 @@ static __init int s5pc100_gpiolib_init(void)
 	for (; nr_chips > 0; nr_chips--, chip++) {
 		if (chip->config == &gpio_cfg) {
 			/* gpio interrupts */
-			chip->chip.to_irq = s5pc100_gpiolib_to_irq;
+			chip->chip.to_irq = s5p_gpiolib_gpioint_to_irq;
 			s5p_gpioint_add(chip, gpioint_group++);
 		}
 	}
arch/arm/mach-s5pv210/gpiolib.c +1 -0
index 166725f..f4ac81f 100644
@@ -258,6 +258,7 @@ static __init int s5pv210_gpiolib_init(void)
 			chip->config = &gpio_cfg;
 
 			/* gpio interrupts */
+			chip->chip.to_irq = s5p_gpiolib_gpioint_to_irq;
 			s5p_gpioint_add(chip, gpioint_group++);
 		}
 		if (chip->base == NULL)
arch/arm/plat-s5p/gpiolib.c +7 -0
index 0c27a9d..dcd1ee4 100644
@@ -33,3 +33,10 @@ int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset)
 		return -EINVAL;
 	}
 }
+
+/* be called from gpio_to_irq() for gpio interrupts */
+int s5p_gpiolib_gpioint_to_irq(struct gpio_chip *chip, unsigned int offset)
+{
+	return S5P_IRQ_GPIOINT(chip->base + offset);
+}
+
arch/arm/plat-samsung/include/plat/gpio-core.h +2 -0
index a6b844c..d484aaf 100644
@@ -122,6 +122,8 @@ extern void samsung_gpiolib_add_4bit2(struct s3c_gpio_chip *chip);
 extern struct s3c_gpio_cfg s3c24xx_gpiocfg_default;
 
 extern int s5p_gpiolib_eint_to_irq(struct gpio_chip *chip, unsigned int offset);
+extern int s5p_gpiolib_gpioint_to_irq(struct gpio_chip *chip,
+		unsigned int offset);
 
 extern void s5p_gpioint_add(struct s3c_gpio_chip *chip, int group);
 
Signature · 1 line
1.7.0.4