2 * OMAP16xx specific gpio init
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
7 * Charulatha V <charu@ti.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation version 2.
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <linux/gpio.h>
21 #define OMAP1610_GPIO1_BASE 0xfffbe400
22 #define OMAP1610_GPIO2_BASE 0xfffbec00
23 #define OMAP1610_GPIO3_BASE 0xfffbb400
24 #define OMAP1610_GPIO4_BASE 0xfffbbc00
25 #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
28 static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
30 .start = OMAP1_MPUIO_VBASE,
31 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
32 .flags = IORESOURCE_MEM,
36 .flags = IORESOURCE_IRQ,
40 static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
41 .direction = OMAP_MPUIO_IO_CNTL,
42 .datain = OMAP_MPUIO_INPUT_LATCH,
43 .dataout = OMAP_MPUIO_OUTPUT,
44 .irqstatus = OMAP_MPUIO_GPIO_INT,
45 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
46 .irqenable_inv = true,
49 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
50 .virtual_irq_start = IH_MPUIO_BASE,
51 .bank_type = METHOD_MPUIO,
54 .regs = &omap16xx_mpuio_regs,
57 static struct __initdata platform_device omap16xx_mpu_gpio = {
61 .platform_data = &omap16xx_mpu_gpio_config,
63 .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
64 .resource = omap16xx_mpu_gpio_resources,
68 static struct __initdata resource omap16xx_gpio1_resources[] = {
70 .start = OMAP1610_GPIO1_BASE,
71 .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
72 .flags = IORESOURCE_MEM,
75 .start = INT_GPIO_BANK1,
76 .flags = IORESOURCE_IRQ,
80 static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
81 .direction = OMAP1610_GPIO_DIRECTION,
82 .set_dataout = OMAP1610_GPIO_SET_DATAOUT,
83 .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT,
84 .datain = OMAP1610_GPIO_DATAIN,
85 .dataout = OMAP1610_GPIO_DATAOUT,
86 .irqstatus = OMAP1610_GPIO_IRQSTATUS1,
87 .irqenable = OMAP1610_GPIO_IRQENABLE1,
88 .set_irqenable = OMAP1610_GPIO_SET_IRQENABLE1,
89 .clr_irqenable = OMAP1610_GPIO_CLEAR_IRQENABLE1,
92 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
93 .virtual_irq_start = IH_GPIO_BASE,
94 .bank_type = METHOD_GPIO_1610,
96 .regs = &omap16xx_gpio_regs,
99 static struct __initdata platform_device omap16xx_gpio1 = {
103 .platform_data = &omap16xx_gpio1_config,
105 .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
106 .resource = omap16xx_gpio1_resources,
110 static struct __initdata resource omap16xx_gpio2_resources[] = {
112 .start = OMAP1610_GPIO2_BASE,
113 .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
114 .flags = IORESOURCE_MEM,
117 .start = INT_1610_GPIO_BANK2,
118 .flags = IORESOURCE_IRQ,
122 static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
123 .virtual_irq_start = IH_GPIO_BASE + 16,
124 .bank_type = METHOD_GPIO_1610,
126 .regs = &omap16xx_gpio_regs,
129 static struct __initdata platform_device omap16xx_gpio2 = {
133 .platform_data = &omap16xx_gpio2_config,
135 .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
136 .resource = omap16xx_gpio2_resources,
140 static struct __initdata resource omap16xx_gpio3_resources[] = {
142 .start = OMAP1610_GPIO3_BASE,
143 .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
144 .flags = IORESOURCE_MEM,
147 .start = INT_1610_GPIO_BANK3,
148 .flags = IORESOURCE_IRQ,
152 static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
153 .virtual_irq_start = IH_GPIO_BASE + 32,
154 .bank_type = METHOD_GPIO_1610,
156 .regs = &omap16xx_gpio_regs,
159 static struct __initdata platform_device omap16xx_gpio3 = {
163 .platform_data = &omap16xx_gpio3_config,
165 .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
166 .resource = omap16xx_gpio3_resources,
170 static struct __initdata resource omap16xx_gpio4_resources[] = {
172 .start = OMAP1610_GPIO4_BASE,
173 .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
174 .flags = IORESOURCE_MEM,
177 .start = INT_1610_GPIO_BANK4,
178 .flags = IORESOURCE_IRQ,
182 static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
183 .virtual_irq_start = IH_GPIO_BASE + 48,
184 .bank_type = METHOD_GPIO_1610,
186 .regs = &omap16xx_gpio_regs,
189 static struct __initdata platform_device omap16xx_gpio4 = {
193 .platform_data = &omap16xx_gpio4_config,
195 .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
196 .resource = omap16xx_gpio4_resources,
199 static struct __initdata platform_device * omap16xx_gpio_dev[] = {
208 * omap16xx_gpio_init needs to be done before
209 * machine_init functions access gpio APIs.
210 * Hence omap16xx_gpio_init is a postcore_initcall.
212 static int __init omap16xx_gpio_init(void)
216 if (!cpu_is_omap16xx())
219 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
220 platform_device_register(omap16xx_gpio_dev[i]);
222 gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
226 postcore_initcall(omap16xx_gpio_init);