blob: 4ff6ff36ab73f6378f2d3129ffc355208cd0415c [file] [log] [blame]
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -08001/*
2 * OMAP16xx specific gpio init
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Author:
7 * Charulatha V <charu@ti.com>
8 *
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.
12 *
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.
17 */
18
19#include <linux/gpio.h>
20
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
26
27/* mpu gpio */
28static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
29 {
30 .start = OMAP1_MPUIO_VBASE,
31 .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
32 .flags = IORESOURCE_MEM,
33 },
34 {
35 .start = INT_MPUIO,
36 .flags = IORESOURCE_IRQ,
37 },
38};
39
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070040static 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};
45
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -080046static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
47 .virtual_irq_start = IH_MPUIO_BASE,
48 .bank_type = METHOD_MPUIO,
49 .bank_width = 16,
Tony Lindgren5de62b82010-12-07 16:26:58 -080050 .bank_stride = 1,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070051 .regs = &omap16xx_mpuio_regs,
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -080052};
53
54static struct __initdata platform_device omap16xx_mpu_gpio = {
55 .name = "omap_gpio",
56 .id = 0,
57 .dev = {
58 .platform_data = &omap16xx_mpu_gpio_config,
59 },
60 .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
61 .resource = omap16xx_mpu_gpio_resources,
62};
63
64/* gpio1 */
65static struct __initdata resource omap16xx_gpio1_resources[] = {
66 {
67 .start = OMAP1610_GPIO1_BASE,
68 .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
69 .flags = IORESOURCE_MEM,
70 },
71 {
72 .start = INT_GPIO_BANK1,
73 .flags = IORESOURCE_IRQ,
74 },
75};
76
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070077static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
78 .direction = OMAP1610_GPIO_DIRECTION,
79 .set_dataout = OMAP1610_GPIO_SET_DATAOUT,
80 .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT,
81 .datain = OMAP1610_GPIO_DATAIN,
82 .dataout = OMAP1610_GPIO_DATAOUT,
83};
84
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -080085static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
86 .virtual_irq_start = IH_GPIO_BASE,
87 .bank_type = METHOD_GPIO_1610,
88 .bank_width = 16,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -070089 .regs = &omap16xx_gpio_regs,
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -080090};
91
92static struct __initdata platform_device omap16xx_gpio1 = {
93 .name = "omap_gpio",
94 .id = 1,
95 .dev = {
96 .platform_data = &omap16xx_gpio1_config,
97 },
98 .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
99 .resource = omap16xx_gpio1_resources,
100};
101
102/* gpio2 */
103static struct __initdata resource omap16xx_gpio2_resources[] = {
104 {
105 .start = OMAP1610_GPIO2_BASE,
106 .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
107 .flags = IORESOURCE_MEM,
108 },
109 {
110 .start = INT_1610_GPIO_BANK2,
111 .flags = IORESOURCE_IRQ,
112 },
113};
114
115static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
116 .virtual_irq_start = IH_GPIO_BASE + 16,
117 .bank_type = METHOD_GPIO_1610,
118 .bank_width = 16,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700119 .regs = &omap16xx_gpio_regs,
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -0800120};
121
122static struct __initdata platform_device omap16xx_gpio2 = {
123 .name = "omap_gpio",
124 .id = 2,
125 .dev = {
126 .platform_data = &omap16xx_gpio2_config,
127 },
128 .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
129 .resource = omap16xx_gpio2_resources,
130};
131
132/* gpio3 */
133static struct __initdata resource omap16xx_gpio3_resources[] = {
134 {
135 .start = OMAP1610_GPIO3_BASE,
136 .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
137 .flags = IORESOURCE_MEM,
138 },
139 {
140 .start = INT_1610_GPIO_BANK3,
141 .flags = IORESOURCE_IRQ,
142 },
143};
144
145static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
146 .virtual_irq_start = IH_GPIO_BASE + 32,
147 .bank_type = METHOD_GPIO_1610,
148 .bank_width = 16,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700149 .regs = &omap16xx_gpio_regs,
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -0800150};
151
152static struct __initdata platform_device omap16xx_gpio3 = {
153 .name = "omap_gpio",
154 .id = 3,
155 .dev = {
156 .platform_data = &omap16xx_gpio3_config,
157 },
158 .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
159 .resource = omap16xx_gpio3_resources,
160};
161
162/* gpio4 */
163static struct __initdata resource omap16xx_gpio4_resources[] = {
164 {
165 .start = OMAP1610_GPIO4_BASE,
166 .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
167 .flags = IORESOURCE_MEM,
168 },
169 {
170 .start = INT_1610_GPIO_BANK4,
171 .flags = IORESOURCE_IRQ,
172 },
173};
174
175static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
176 .virtual_irq_start = IH_GPIO_BASE + 48,
177 .bank_type = METHOD_GPIO_1610,
178 .bank_width = 16,
Kevin Hilmanfa87931a2011-04-20 16:31:23 -0700179 .regs = &omap16xx_gpio_regs,
Varadarajan, Charulatha87fe6222010-12-07 16:26:56 -0800180};
181
182static struct __initdata platform_device omap16xx_gpio4 = {
183 .name = "omap_gpio",
184 .id = 4,
185 .dev = {
186 .platform_data = &omap16xx_gpio4_config,
187 },
188 .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
189 .resource = omap16xx_gpio4_resources,
190};
191
192static struct __initdata platform_device * omap16xx_gpio_dev[] = {
193 &omap16xx_mpu_gpio,
194 &omap16xx_gpio1,
195 &omap16xx_gpio2,
196 &omap16xx_gpio3,
197 &omap16xx_gpio4,
198};
199
200/*
201 * omap16xx_gpio_init needs to be done before
202 * machine_init functions access gpio APIs.
203 * Hence omap16xx_gpio_init is a postcore_initcall.
204 */
205static int __init omap16xx_gpio_init(void)
206{
207 int i;
208
209 if (!cpu_is_omap16xx())
210 return -EINVAL;
211
212 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
213 platform_device_register(omap16xx_gpio_dev[i]);
214
215 gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev);
216
217 return 0;
218}
219postcore_initcall(omap16xx_gpio_init);