Skip to contentSkip to conversation

OMAP: GPIO: cleanup: first pass at ifdef removal

PATCH In review Kevin Hilman 2 participants 5 messages Apr 21, 2011

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

cover OMAP: GPIO: cleanup: first pass at ifdef removal

This series is a first pass at the #ifdef removal cleanup.

To demonstrate the type of changes needed for the cleanup, the direction and data input/output functions are handled first. Register offset fields are added to platform_data so #ifdefs can be removed.

Similar needs to be done for the remaining #ifdefs.

Currently boot tested on 3430/n900 only.

Series applies to v2.6.39-rc4.

Kevin Hilman (2):
OMAP: GPIO: move register offset defines into gpio.h
OMAP: GPIO: consolidate direction, input, output, remove #ifdefs

 arch/arm/mach-omap1/gpio15xx.c         |    7 +
 arch/arm/mach-omap1/gpio16xx.c         |   15 ++
 arch/arm/mach-omap1/gpio7xx.c          |   15 ++
 arch/arm/mach-omap2/gpio.c             |   10 +
 arch/arm/plat-omap/gpio.c              |  328 +++----------------------------
 arch/arm/plat-omap/include/plat/gpio.h |  111 +++++++++++
 6 files changed, 190 insertions(+), 296 deletions(-)
Signature · 1 line
1.7.4
#1 lore raw

PATCH 1/2 OMAP: GPIO: move register offset defines into gpio.h

Register offset defines are moved to <plat/gpio.h> so they can be used by SoC-specific device init code to fill out platform_data register offsets.

---
 arch/arm/plat-omap/gpio.c              |  103 --------------------------------
 arch/arm/plat-omap/include/plat/gpio.h |  103 ++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+), 103 deletions(-)
arch/arm/plat-omap/gpio.c +0 -103
index d2adcdd..ff70538 100644
@@ -30,109 +30,6 @@
 #include <mach/gpio.h>
 #include <asm/mach/irq.h>
 
-/*
- * OMAP1510 GPIO registers
- */
-#define OMAP1510_GPIO_DATA_INPUT	0x00
-#define OMAP1510_GPIO_DATA_OUTPUT	0x04
-#define OMAP1510_GPIO_DIR_CONTROL	0x08
-#define OMAP1510_GPIO_INT_CONTROL	0x0c
-#define OMAP1510_GPIO_INT_MASK		0x10
-#define OMAP1510_GPIO_INT_STATUS	0x14
-#define OMAP1510_GPIO_PIN_CONTROL	0x18
-
-#define OMAP1510_IH_GPIO_BASE		64
-
-/*
- * OMAP1610 specific GPIO registers
- */
-#define OMAP1610_GPIO_REVISION		0x0000
-#define OMAP1610_GPIO_SYSCONFIG		0x0010
-#define OMAP1610_GPIO_SYSSTATUS		0x0014
-#define OMAP1610_GPIO_IRQSTATUS1	0x0018
-#define OMAP1610_GPIO_IRQENABLE1	0x001c
-#define OMAP1610_GPIO_WAKEUPENABLE	0x0028
-#define OMAP1610_GPIO_DATAIN		0x002c
-#define OMAP1610_GPIO_DATAOUT		0x0030
-#define OMAP1610_GPIO_DIRECTION		0x0034
-#define OMAP1610_GPIO_EDGE_CTRL1	0x0038
-#define OMAP1610_GPIO_EDGE_CTRL2	0x003c
-#define OMAP1610_GPIO_CLEAR_IRQENABLE1	0x009c
-#define OMAP1610_GPIO_CLEAR_WAKEUPENA	0x00a8
-#define OMAP1610_GPIO_CLEAR_DATAOUT	0x00b0
-#define OMAP1610_GPIO_SET_IRQENABLE1	0x00dc
-#define OMAP1610_GPIO_SET_WAKEUPENA	0x00e8
-#define OMAP1610_GPIO_SET_DATAOUT	0x00f0
-
-/*
- * OMAP7XX specific GPIO registers
- */
-#define OMAP7XX_GPIO_DATA_INPUT		0x00
-#define OMAP7XX_GPIO_DATA_OUTPUT	0x04
-#define OMAP7XX_GPIO_DIR_CONTROL	0x08
-#define OMAP7XX_GPIO_INT_CONTROL	0x0c
-#define OMAP7XX_GPIO_INT_MASK		0x10
-#define OMAP7XX_GPIO_INT_STATUS		0x14
-
-/*
- * omap2+ specific GPIO registers
- */
-#define OMAP24XX_GPIO_REVISION		0x0000
-#define OMAP24XX_GPIO_IRQSTATUS1	0x0018
-#define OMAP24XX_GPIO_IRQSTATUS2	0x0028
-#define OMAP24XX_GPIO_IRQENABLE2	0x002c
-#define OMAP24XX_GPIO_IRQENABLE1	0x001c
-#define OMAP24XX_GPIO_WAKE_EN		0x0020
-#define OMAP24XX_GPIO_CTRL		0x0030
-#define OMAP24XX_GPIO_OE		0x0034
-#define OMAP24XX_GPIO_DATAIN		0x0038
-#define OMAP24XX_GPIO_DATAOUT		0x003c
-#define OMAP24XX_GPIO_LEVELDETECT0	0x0040
-#define OMAP24XX_GPIO_LEVELDETECT1	0x0044
-#define OMAP24XX_GPIO_RISINGDETECT	0x0048
-#define OMAP24XX_GPIO_FALLINGDETECT	0x004c
-#define OMAP24XX_GPIO_DEBOUNCE_EN	0x0050
-#define OMAP24XX_GPIO_DEBOUNCE_VAL	0x0054
-#define OMAP24XX_GPIO_CLEARIRQENABLE1	0x0060
-#define OMAP24XX_GPIO_SETIRQENABLE1	0x0064
-#define OMAP24XX_GPIO_CLEARWKUENA	0x0080
-#define OMAP24XX_GPIO_SETWKUENA		0x0084
-#define OMAP24XX_GPIO_CLEARDATAOUT	0x0090
-#define OMAP24XX_GPIO_SETDATAOUT	0x0094
-
-#define OMAP4_GPIO_REVISION		0x0000
-#define OMAP4_GPIO_EOI			0x0020
-#define OMAP4_GPIO_IRQSTATUSRAW0	0x0024
-#define OMAP4_GPIO_IRQSTATUSRAW1	0x0028
-#define OMAP4_GPIO_IRQSTATUS0		0x002c
-#define OMAP4_GPIO_IRQSTATUS1		0x0030
-#define OMAP4_GPIO_IRQSTATUSSET0	0x0034
-#define OMAP4_GPIO_IRQSTATUSSET1	0x0038
-#define OMAP4_GPIO_IRQSTATUSCLR0	0x003c
-#define OMAP4_GPIO_IRQSTATUSCLR1	0x0040
-#define OMAP4_GPIO_IRQWAKEN0		0x0044
-#define OMAP4_GPIO_IRQWAKEN1		0x0048
-#define OMAP4_GPIO_IRQENABLE1		0x011c
-#define OMAP4_GPIO_WAKE_EN		0x0120
-#define OMAP4_GPIO_IRQSTATUS2		0x0128
-#define OMAP4_GPIO_IRQENABLE2		0x012c
-#define OMAP4_GPIO_CTRL			0x0130
-#define OMAP4_GPIO_OE			0x0134
-#define OMAP4_GPIO_DATAIN		0x0138
-#define OMAP4_GPIO_DATAOUT		0x013c
-#define OMAP4_GPIO_LEVELDETECT0		0x0140
-#define OMAP4_GPIO_LEVELDETECT1		0x0144
-#define OMAP4_GPIO_RISINGDETECT		0x0148
-#define OMAP4_GPIO_FALLINGDETECT	0x014c
-#define OMAP4_GPIO_DEBOUNCENABLE	0x0150
-#define OMAP4_GPIO_DEBOUNCINGTIME	0x0154
-#define OMAP4_GPIO_CLEARIRQENABLE1	0x0160
-#define OMAP4_GPIO_SETIRQENABLE1	0x0164
-#define OMAP4_GPIO_CLEARWKUENA		0x0180
-#define OMAP4_GPIO_SETWKUENA		0x0184
-#define OMAP4_GPIO_CLEARDATAOUT		0x0190
-#define OMAP4_GPIO_SETDATAOUT		0x0194
-
 struct gpio_bank {
 	unsigned long pbase;
 	void __iomem *base;
arch/arm/plat-omap/include/plat/gpio.h +103 -0

109 lines not on this page · raw message

Signature · 1 line
1.7.4
#2 lore raw

PATCH 2/2 OMAP: GPIO: consolidate direction, input, output, remove #ifdefs

In reply to Kevin Hilman

Add register offset fields to GPIO platform_data for registers that control direction, input and output data. Using these register offsets in the common driver allows removal of #ifdefs and greatly improves readability.

---
 arch/arm/mach-omap1/gpio15xx.c         |    7 +
 arch/arm/mach-omap1/gpio16xx.c         |   15 ++
 arch/arm/mach-omap1/gpio7xx.c          |   15 ++
 arch/arm/mach-omap2/gpio.c             |   10 ++
 arch/arm/plat-omap/gpio.c              |  225 +++++---------------------------
 arch/arm/plat-omap/include/plat/gpio.h |    8 +
 6 files changed, 87 insertions(+), 193 deletions(-)
arch/arm/mach-omap1/gpio15xx.c +7 -0
index 04c4b04..706015b 100644
@@ -39,6 +39,10 @@ static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
 	.bank_type		= METHOD_MPUIO,
 	.bank_width		= 16,
 	.bank_stride		= 1,
+	.direction_reg		= OMAP_MPUIO_IO_CNTL,
+	.set_dataout_reg	= OMAP_MPUIO_OUTPUT,
+	.datain_reg		= OMAP_MPUIO_INPUT_LATCH,
+	.dataout_reg		= OMAP_MPUIO_OUTPUT,
 };
 
 static struct __initdata platform_device omap15xx_mpu_gpio = {
@@ -68,6 +72,9 @@ static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
 	.virtual_irq_start	= IH_GPIO_BASE,
 	.bank_type		= METHOD_GPIO_1510,
 	.bank_width		= 16,
+	.direction_reg		= OMAP1510_GPIO_DIR_CONTROL,
+	.datain_reg		= OMAP1510_GPIO_DATA_INPUT,
+	.dataout_reg		= OMAP1510_GPIO_DATA_OUTPUT,
 };
 
 static struct __initdata platform_device omap15xx_gpio = {
arch/arm/mach-omap1/gpio16xx.c +15 -0
index 5dd0d4c..9573b5e 100644
@@ -42,6 +42,10 @@ static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
 	.bank_type		= METHOD_MPUIO,
 	.bank_width		= 16,
 	.bank_stride		= 1,
+	.direction_reg		= OMAP_MPUIO_IO_CNTL,
+	.set_dataout_reg	= OMAP_MPUIO_OUTPUT,
+	.datain_reg		= OMAP_MPUIO_INPUT_LATCH,
+	.dataout_reg		= OMAP_MPUIO_OUTPUT,
 };
 
 static struct __initdata platform_device omap16xx_mpu_gpio = {
@@ -67,10 +71,18 @@ static struct __initdata resource omap16xx_gpio1_resources[] = {
 	},
 };
 
+#define OMAP16XX_GPIO_REG_OFFSETS \
+	.direction_reg		= OMAP1610_GPIO_DIRECTION, \
+	.set_dataout_reg	= OMAP1610_GPIO_SET_DATAOUT, \
+	.clr_dataout_reg	= OMAP1610_GPIO_CLEAR_DATAOUT, \
+	.datain_reg		= OMAP1610_GPIO_DATAIN, \
+	.dataout_reg		= OMAP1610_GPIO_DATAOUT
+
 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
 	.virtual_irq_start	= IH_GPIO_BASE,
 	.bank_type		= METHOD_GPIO_1610,
 	.bank_width		= 16,
+	OMAP16XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap16xx_gpio1 = {
@@ -100,6 +112,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 16,
 	.bank_type		= METHOD_GPIO_1610,
 	.bank_width		= 16,
+	OMAP16XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap16xx_gpio2 = {
@@ -129,6 +142,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 32,
 	.bank_type		= METHOD_GPIO_1610,
 	.bank_width		= 16,
+	OMAP16XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap16xx_gpio3 = {
@@ -158,6 +172,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 48,
 	.bank_type		= METHOD_GPIO_1610,
 	.bank_width		= 16,
+	OMAP16XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap16xx_gpio4 = {
arch/arm/mach-omap1/gpio7xx.c +15 -0
index 1204c8b..79b0af8 100644
@@ -44,6 +44,10 @@ static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
 	.bank_type		= METHOD_MPUIO,
 	.bank_width		= 32,
 	.bank_stride		= 2,
+	.direction_reg		= OMAP_MPUIO_IO_CNTL / 2, \
+	.set_dataout_reg	= OMAP_MPUIO_OUTPUT / 2, \
+	.datain_reg		= OMAP_MPUIO_INPUT_LATCH / 2, \
+	.dataout_reg		= OMAP_MPUIO_OUTPUT / 2
 };
 
 static struct __initdata platform_device omap7xx_mpu_gpio = {
@@ -69,10 +73,16 @@ static struct __initdata resource omap7xx_gpio1_resources[] = {
 	},
 };
 
+#define OMAP7XX_GPIO_REG_OFFSETS \
+	.direction_reg		= OMAP7XX_GPIO_DIR_CONTROL, \
+	.datain_reg             = OMAP7XX_GPIO_DATA_INPUT, \
+	.dataout_reg            = OMAP7XX_GPIO_DATA_OUTPUT
+
 static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
 	.virtual_irq_start	= IH_GPIO_BASE,
 	.bank_type		= METHOD_GPIO_7XX,
 	.bank_width		= 32,
+	OMAP7XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap7xx_gpio1 = {
@@ -102,6 +112,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 32,
 	.bank_type		= METHOD_GPIO_7XX,
 	.bank_width		= 32,
+	OMAP7XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap7xx_gpio2 = {
@@ -131,6 +142,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 64,
 	.bank_type		= METHOD_GPIO_7XX,
 	.bank_width		= 32,
+	OMAP7XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap7xx_gpio3 = {
@@ -160,6 +172,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 96,
 	.bank_type		= METHOD_GPIO_7XX,
 	.bank_width		= 32,
+	OMAP7XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap7xx_gpio4 = {
@@ -189,6 +202,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 128,
 	.bank_type		= METHOD_GPIO_7XX,
 	.bank_width		= 32,
+	OMAP7XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap7xx_gpio5 = {
@@ -218,6 +232,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
 	.virtual_irq_start	= IH_GPIO_BASE + 160,
 	.bank_type		= METHOD_GPIO_7XX,
 	.bank_width		= 32,
+	OMAP7XX_GPIO_REG_OFFSETS,
 };
 
 static struct __initdata platform_device omap7xx_gpio6 = {
arch/arm/mach-omap2/gpio.c +10 -0
index 9529842..92855d7 100644
@@ -65,9 +65,19 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
 	case 0:
 	case 1:
 		pdata->bank_type = METHOD_GPIO_24XX;
+		pdata->direction_reg = OMAP24XX_GPIO_OE;
+		pdata->set_dataout_reg = OMAP24XX_GPIO_SETDATAOUT;
+		pdata->clr_dataout_reg = OMAP24XX_GPIO_CLEARDATAOUT;
+		pdata->datain_reg = OMAP24XX_GPIO_DATAIN;
+		pdata->dataout_reg = OMAP24XX_GPIO_DATAOUT;
 		break;
 	case 2:
 		pdata->bank_type = METHOD_GPIO_44XX;
+		pdata->direction_reg = OMAP4_GPIO_OE;
+		pdata->set_dataout_reg = OMAP4_GPIO_SETDATAOUT;
+		pdata->clr_dataout_reg = OMAP4_GPIO_CLEARDATAOUT;
+		pdata->datain_reg = OMAP4_GPIO_DATAIN;
+		pdata->dataout_reg = OMAP4_GPIO_DATAOUT;
 		break;
 	default:
 		WARN(1, "Invalid gpio bank_type\n");
arch/arm/plat-omap/gpio.c +32 -193

272 lines not on this page · raw message

arch/arm/plat-omap/include/plat/gpio.h +8 -0
index ec97e00..de80f7e 100644
@@ -180,6 +180,14 @@ struct omap_gpio_platform_data {
 	int bank_width;		/* GPIO bank width */
 	int bank_stride;	/* Only needed for omap1 MPUIO */
 	bool dbck_flag;		/* dbck required or not - True for OMAP3&4 */
+
+	/* SoC-specific register offsets (required) */
+	u16 direction_reg;
+	u16 datain_reg;
+	u16 dataout_reg;
+	/* SoC-specific register offsets (optional) */
+	u16 set_dataout_reg;
+	u16 clr_dataout_reg;
 };
 
 /* TODO: Analyze removing gpio_bank_count usage from driver code */
Signature · 1 line
1.7.4
#3 lore raw
In reply to Kevin Hilman

[...]

Quoted 10 lines

This series is a first pass at the #ifdef removal cleanup.

To demonstrate the type of changes needed for the cleanup, the direction and data input/output functions are handled first. Register offset fields are added to platform_data so #ifdefs can be removed.

Similar needs to be done for the remaining #ifdefs.

Currently boot tested on 3430/n900 only.

Tested following on OMAP2420, OMAP2430, OMAP4430:
-> request/free of gpio lines
-> configure input/output mode
-> interrupt configuration
-> read/write
--
Tarun

Quoted 23 lines

Series applies to v2.6.39-rc4.

Kevin Hilman (2):
OMAP: GPIO: move register offset defines into gpio.h
OMAP: GPIO: consolidate direction, input, output, remove #ifdefs

 arch/arm/mach-omap1/gpio15xx.c         |    7 +
 arch/arm/mach-omap1/gpio16xx.c         |   15 ++
 arch/arm/mach-omap1/gpio7xx.c          |   15 ++
 arch/arm/mach-omap2/gpio.c             |   10 +
 arch/arm/plat-omap/gpio.c              |  328 +++------------------------
----
 arch/arm/plat-omap/include/plat/gpio.h |  111 +++++++++++
 6 files changed, 190 insertions(+), 296 deletions(-)

--
1.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Hi Tarun,

Quoted 8 lines · Tarun Kanti

[...]

Quoted 7 lines

This series is a first pass at the #ifdef removal cleanup.

To demonstrate the type of changes needed for the cleanup, the direction and data input/output functions are handled first. Register offset fields are added to platform_data so #ifdefs can be removed.

Quoted 8 lines
Quoted 3 lines

Similar needs to be done for the remaining #ifdefs.

Currently boot tested on 3430/n900 only.

Tested following on OMAP2420, OMAP2430, OMAP4430:
-> request/free of gpio lines
-> configure input/output mode
-> interrupt configuration
-> read/write

Thanks for testing!

Kevin