Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa87931a authored by Kevin Hilman's avatar Kevin Hilman
Browse files

gpio/omap: consolidate direction, input, output, remove #ifdefs



Add register offset fields to GPIO platform_data for registers.

This patch adds registers that control direction, input and output
data.  Using these register offsets in the common driver allows
removal of #ifdefs and greatly improves readability.

Also create dedicated data out functions: one for banks with dedicated
set/clear registers, and another for banks with a single mask
register.

Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent a8be8daf
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -34,11 +34,18 @@ static struct __initdata resource omap15xx_mpu_gpio_resources[] = {
	},
};

static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
	.direction	= OMAP_MPUIO_IO_CNTL,
	.datain		= OMAP_MPUIO_INPUT_LATCH,
	.dataout	= OMAP_MPUIO_OUTPUT,
};

static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
	.virtual_irq_start	= IH_MPUIO_BASE,
	.bank_type		= METHOD_MPUIO,
	.bank_width		= 16,
	.bank_stride		= 1,
	.regs			= &omap15xx_mpuio_regs,
};

static struct __initdata platform_device omap15xx_mpu_gpio = {
@@ -64,10 +71,17 @@ static struct __initdata resource omap15xx_gpio_resources[] = {
	},
};

static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
	.direction	= OMAP1510_GPIO_DIR_CONTROL,
	.datain		= OMAP1510_GPIO_DATA_INPUT,
	.dataout	= OMAP1510_GPIO_DATA_OUTPUT,
};

static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
	.virtual_irq_start	= IH_GPIO_BASE,
	.bank_type		= METHOD_GPIO_1510,
	.bank_width		= 16,
	.regs                   = &omap15xx_gpio_regs,
};

static struct __initdata platform_device omap15xx_gpio = {
+19 −0
Original line number Diff line number Diff line
@@ -37,11 +37,18 @@ static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
	},
};

static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
	.direction	= OMAP_MPUIO_IO_CNTL,
	.datain		= OMAP_MPUIO_INPUT_LATCH,
	.dataout	= OMAP_MPUIO_OUTPUT,
};

static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
	.virtual_irq_start	= IH_MPUIO_BASE,
	.bank_type		= METHOD_MPUIO,
	.bank_width		= 16,
	.bank_stride		= 1,
	.regs                   = &omap16xx_mpuio_regs,
};

static struct __initdata platform_device omap16xx_mpu_gpio = {
@@ -67,10 +74,19 @@ static struct __initdata resource omap16xx_gpio1_resources[] = {
	},
};

static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
	.direction	= OMAP1610_GPIO_DIRECTION,
	.set_dataout	= OMAP1610_GPIO_SET_DATAOUT,
	.clr_dataout	= OMAP1610_GPIO_CLEAR_DATAOUT,
	.datain		= OMAP1610_GPIO_DATAIN,
	.dataout	= 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,
	.regs                   = &omap16xx_gpio_regs,
};

static struct __initdata platform_device omap16xx_gpio1 = {
@@ -100,6 +116,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,
	.regs                   = &omap16xx_gpio_regs,
};

static struct __initdata platform_device omap16xx_gpio2 = {
@@ -129,6 +146,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,
	.regs                   = &omap16xx_gpio_regs,
};

static struct __initdata platform_device omap16xx_gpio3 = {
@@ -158,6 +176,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,
	.regs                   = &omap16xx_gpio_regs,
};

static struct __initdata platform_device omap16xx_gpio4 = {
+19 −0
Original line number Diff line number Diff line
@@ -39,11 +39,18 @@ static struct __initdata resource omap7xx_mpu_gpio_resources[] = {
	},
};

static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
	.direction	= OMAP_MPUIO_IO_CNTL / 2,
	.datain		= OMAP_MPUIO_INPUT_LATCH / 2,
	.dataout	= OMAP_MPUIO_OUTPUT / 2,
};

static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
	.virtual_irq_start	= IH_MPUIO_BASE,
	.bank_type		= METHOD_MPUIO,
	.bank_width		= 32,
	.bank_stride		= 2,
	.regs                   = &omap7xx_mpuio_regs,
};

static struct __initdata platform_device omap7xx_mpu_gpio = {
@@ -69,10 +76,17 @@ static struct __initdata resource omap7xx_gpio1_resources[] = {
	},
};

static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
	.direction	= OMAP7XX_GPIO_DIR_CONTROL,
	.datain		= OMAP7XX_GPIO_DATA_INPUT,
	.dataout	= 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,
	.regs			= &omap7xx_gpio_regs,
};

static struct __initdata platform_device omap7xx_gpio1 = {
@@ -102,6 +116,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,
	.regs			= &omap7xx_gpio_regs,
};

static struct __initdata platform_device omap7xx_gpio2 = {
@@ -131,6 +146,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,
	.regs			= &omap7xx_gpio_regs,
};

static struct __initdata platform_device omap7xx_gpio3 = {
@@ -160,6 +176,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,
	.regs			= &omap7xx_gpio_regs,
};

static struct __initdata platform_device omap7xx_gpio4 = {
@@ -189,6 +206,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,
	.regs			= &omap7xx_gpio_regs,
};

static struct __initdata platform_device omap7xx_gpio5 = {
@@ -218,6 +236,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,
	.regs			= &omap7xx_gpio_regs,
};

static struct __initdata platform_device omap7xx_gpio6 = {
+16 −0
Original line number Diff line number Diff line
@@ -61,13 +61,29 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
	pdata->dbck_flag = dev_attr->dbck_flag;
	pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1);

	pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
	if (!pdata) {
		pr_err("gpio%d: Memory allocation failed\n", id);
		return -ENOMEM;
	}

	switch (oh->class->rev) {
	case 0:
	case 1:
		pdata->bank_type = METHOD_GPIO_24XX;
		pdata->regs->direction = OMAP24XX_GPIO_OE;
		pdata->regs->datain = OMAP24XX_GPIO_DATAIN;
		pdata->regs->dataout = OMAP24XX_GPIO_DATAOUT;
		pdata->regs->set_dataout = OMAP24XX_GPIO_SETDATAOUT;
		pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT;
		break;
	case 2:
		pdata->bank_type = METHOD_GPIO_44XX;
		pdata->regs->direction = OMAP4_GPIO_OE;
		pdata->regs->datain = OMAP4_GPIO_DATAIN;
		pdata->regs->dataout = OMAP4_GPIO_DATAOUT;
		pdata->regs->set_dataout = OMAP4_GPIO_SETDATAOUT;
		pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT;
		break;
	default:
		WARN(1, "Invalid gpio bank_type\n");
+10 −0
Original line number Diff line number Diff line
@@ -174,12 +174,22 @@ struct omap_gpio_dev_attr {
	bool dbck_flag;		/* dbck required or not - True for OMAP3&4 */
};

struct omap_gpio_reg_offs {
	u16 direction;
	u16 datain;
	u16 dataout;
	u16 set_dataout;
	u16 clr_dataout;
};

struct omap_gpio_platform_data {
	u16 virtual_irq_start;
	int bank_type;
	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 */

	struct omap_gpio_reg_offs *regs;
};

/* TODO: Analyze removing gpio_bank_count usage from driver code */
Loading