ARM: cpu topology: Add debugfs interface for cpu_power
[cmplus.git] / arch / arm / mach-omap1 / gpio16xx.c
blobc6a4554b6594464c87a4fee1fbd84cb9d6617ae7
1 /*
2 * OMAP16xx specific gpio init
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
6 * Author:
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
27 /* mpu gpio */
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,
35 .start = INT_MPUIO,
36 .flags = IORESOURCE_IRQ,
40 static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
41 .revision = USHRT_MAX,
42 .direction = OMAP_MPUIO_IO_CNTL,
43 .datain = OMAP_MPUIO_INPUT_LATCH,
44 .dataout = OMAP_MPUIO_OUTPUT,
45 .irqstatus = OMAP_MPUIO_GPIO_INT,
46 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
47 .irqenable_inv = true,
48 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
51 static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
52 .virtual_irq_start = IH_MPUIO_BASE,
53 .is_mpuio = true,
54 .bank_width = 16,
55 .bank_stride = 1,
56 .suspend_support = true,
57 .regs = &omap16xx_mpuio_regs,
60 static struct platform_device omap16xx_mpu_gpio = {
61 .name = "omap_gpio",
62 .id = 0,
63 .dev = {
64 .platform_data = &omap16xx_mpu_gpio_config,
66 .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
67 .resource = omap16xx_mpu_gpio_resources,
70 /* gpio1 */
71 static struct __initdata resource omap16xx_gpio1_resources[] = {
73 .start = OMAP1610_GPIO1_BASE,
74 .end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
75 .flags = IORESOURCE_MEM,
78 .start = INT_GPIO_BANK1,
79 .flags = IORESOURCE_IRQ,
83 static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
84 .revision = OMAP1610_GPIO_REVISION,
85 .direction = OMAP1610_GPIO_DIRECTION,
86 .set_dataout = OMAP1610_GPIO_SET_DATAOUT,
87 .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT,
88 .datain = OMAP1610_GPIO_DATAIN,
89 .dataout = OMAP1610_GPIO_DATAOUT,
90 .irqstatus = OMAP1610_GPIO_IRQSTATUS1,
91 .irqenable = OMAP1610_GPIO_IRQENABLE1,
92 .set_irqenable = OMAP1610_GPIO_SET_IRQENABLE1,
93 .clr_irqenable = OMAP1610_GPIO_CLEAR_IRQENABLE1,
94 .wkup_status = OMAP1610_GPIO_WAKEUPENABLE,
95 .wkup_clear = OMAP1610_GPIO_CLEAR_WAKEUPENA,
96 .wkup_set = OMAP1610_GPIO_SET_WAKEUPENA,
97 .edgectrl1 = OMAP1610_GPIO_EDGE_CTRL1,
98 .edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2,
99 .sysconfig = OMAP1610_GPIO_SYSCONFIG,
102 static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
103 .virtual_irq_start = IH_GPIO_BASE,
104 .bank_width = 16,
105 .suspend_support = true,
106 .regs = &omap16xx_gpio_regs,
109 static struct platform_device omap16xx_gpio1 = {
110 .name = "omap_gpio",
111 .id = 1,
112 .dev = {
113 .platform_data = &omap16xx_gpio1_config,
115 .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
116 .resource = omap16xx_gpio1_resources,
119 /* gpio2 */
120 static struct __initdata resource omap16xx_gpio2_resources[] = {
122 .start = OMAP1610_GPIO2_BASE,
123 .end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
124 .flags = IORESOURCE_MEM,
127 .start = INT_1610_GPIO_BANK2,
128 .flags = IORESOURCE_IRQ,
132 static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
133 .virtual_irq_start = IH_GPIO_BASE + 16,
134 .bank_width = 16,
135 .suspend_support = true,
136 .regs = &omap16xx_gpio_regs,
139 static struct platform_device omap16xx_gpio2 = {
140 .name = "omap_gpio",
141 .id = 2,
142 .dev = {
143 .platform_data = &omap16xx_gpio2_config,
145 .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
146 .resource = omap16xx_gpio2_resources,
149 /* gpio3 */
150 static struct __initdata resource omap16xx_gpio3_resources[] = {
152 .start = OMAP1610_GPIO3_BASE,
153 .end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
154 .flags = IORESOURCE_MEM,
157 .start = INT_1610_GPIO_BANK3,
158 .flags = IORESOURCE_IRQ,
162 static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
163 .virtual_irq_start = IH_GPIO_BASE + 32,
164 .bank_width = 16,
165 .suspend_support = true,
166 .regs = &omap16xx_gpio_regs,
169 static struct platform_device omap16xx_gpio3 = {
170 .name = "omap_gpio",
171 .id = 3,
172 .dev = {
173 .platform_data = &omap16xx_gpio3_config,
175 .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
176 .resource = omap16xx_gpio3_resources,
179 /* gpio4 */
180 static struct __initdata resource omap16xx_gpio4_resources[] = {
182 .start = OMAP1610_GPIO4_BASE,
183 .end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
184 .flags = IORESOURCE_MEM,
187 .start = INT_1610_GPIO_BANK4,
188 .flags = IORESOURCE_IRQ,
192 static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
193 .virtual_irq_start = IH_GPIO_BASE + 48,
194 .bank_width = 16,
195 .suspend_support = true,
196 .regs = &omap16xx_gpio_regs,
199 static struct platform_device omap16xx_gpio4 = {
200 .name = "omap_gpio",
201 .id = 4,
202 .dev = {
203 .platform_data = &omap16xx_gpio4_config,
205 .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
206 .resource = omap16xx_gpio4_resources,
209 static struct __initdata platform_device * omap16xx_gpio_dev[] = {
210 &omap16xx_mpu_gpio,
211 &omap16xx_gpio1,
212 &omap16xx_gpio2,
213 &omap16xx_gpio3,
214 &omap16xx_gpio4,
218 * omap16xx_gpio_init needs to be done before
219 * machine_init functions access gpio APIs.
220 * Hence omap16xx_gpio_init is a postcore_initcall.
222 static int __init omap16xx_gpio_init(void)
224 int i;
226 if (!cpu_is_omap16xx())
227 return -EINVAL;
229 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++)
230 platform_device_register(omap16xx_gpio_dev[i]);
232 return 0;
234 postcore_initcall(omap16xx_gpio_init);