Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 1 | /* |
| 2 | * OMAP7xx 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 OMAP7XX_GPIO1_BASE 0xfffbc000 |
| 22 | #define OMAP7XX_GPIO2_BASE 0xfffbc800 |
| 23 | #define OMAP7XX_GPIO3_BASE 0xfffbd000 |
| 24 | #define OMAP7XX_GPIO4_BASE 0xfffbd800 |
| 25 | #define OMAP7XX_GPIO5_BASE 0xfffbe000 |
| 26 | #define OMAP7XX_GPIO6_BASE 0xfffbe800 |
| 27 | #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE |
| 28 | |
| 29 | /* mpu gpio */ |
| 30 | static struct __initdata resource omap7xx_mpu_gpio_resources[] = { |
| 31 | { |
| 32 | .start = OMAP1_MPUIO_VBASE, |
| 33 | .end = OMAP1_MPUIO_VBASE + SZ_2K - 1, |
| 34 | .flags = IORESOURCE_MEM, |
| 35 | }, |
| 36 | { |
| 37 | .start = INT_7XX_MPUIO, |
| 38 | .flags = IORESOURCE_IRQ, |
| 39 | }, |
| 40 | }; |
| 41 | |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 42 | static struct omap_gpio_reg_offs omap7xx_mpuio_regs = { |
Kevin Hilman | e5ff444 | 2011-04-22 14:37:16 -0700 | [diff] [blame] | 43 | .revision = USHRT_MAX, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 44 | .direction = OMAP_MPUIO_IO_CNTL / 2, |
| 45 | .datain = OMAP_MPUIO_INPUT_LATCH / 2, |
| 46 | .dataout = OMAP_MPUIO_OUTPUT / 2, |
Kevin Hilman | eef4bec | 2011-04-21 09:17:35 -0700 | [diff] [blame] | 47 | .irqstatus = OMAP_MPUIO_GPIO_INT / 2, |
Kevin Hilman | 28f3b5a | 2011-04-21 09:53:06 -0700 | [diff] [blame] | 48 | .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2, |
| 49 | .irqenable_inv = true, |
Tarun Kanti DebBarma | 5e571f3 | 2011-09-13 15:02:14 +0530 | [diff] [blame^] | 50 | .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 53 | static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { |
| 54 | .virtual_irq_start = IH_MPUIO_BASE, |
| 55 | .bank_type = METHOD_MPUIO, |
| 56 | .bank_width = 32, |
Tony Lindgren | 5de62b8 | 2010-12-07 16:26:58 -0800 | [diff] [blame] | 57 | .bank_stride = 2, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 58 | .regs = &omap7xx_mpuio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 59 | }; |
| 60 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 61 | static struct platform_device omap7xx_mpu_gpio = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 62 | .name = "omap_gpio", |
| 63 | .id = 0, |
| 64 | .dev = { |
| 65 | .platform_data = &omap7xx_mpu_gpio_config, |
| 66 | }, |
| 67 | .num_resources = ARRAY_SIZE(omap7xx_mpu_gpio_resources), |
| 68 | .resource = omap7xx_mpu_gpio_resources, |
| 69 | }; |
| 70 | |
| 71 | /* gpio1 */ |
| 72 | static struct __initdata resource omap7xx_gpio1_resources[] = { |
| 73 | { |
| 74 | .start = OMAP7XX_GPIO1_BASE, |
| 75 | .end = OMAP7XX_GPIO1_BASE + SZ_2K - 1, |
| 76 | .flags = IORESOURCE_MEM, |
| 77 | }, |
| 78 | { |
| 79 | .start = INT_7XX_GPIO_BANK1, |
| 80 | .flags = IORESOURCE_IRQ, |
| 81 | }, |
| 82 | }; |
| 83 | |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 84 | static struct omap_gpio_reg_offs omap7xx_gpio_regs = { |
Kevin Hilman | e5ff444 | 2011-04-22 14:37:16 -0700 | [diff] [blame] | 85 | .revision = USHRT_MAX, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 86 | .direction = OMAP7XX_GPIO_DIR_CONTROL, |
| 87 | .datain = OMAP7XX_GPIO_DATA_INPUT, |
| 88 | .dataout = OMAP7XX_GPIO_DATA_OUTPUT, |
Kevin Hilman | eef4bec | 2011-04-21 09:17:35 -0700 | [diff] [blame] | 89 | .irqstatus = OMAP7XX_GPIO_INT_STATUS, |
Kevin Hilman | 28f3b5a | 2011-04-21 09:53:06 -0700 | [diff] [blame] | 90 | .irqenable = OMAP7XX_GPIO_INT_MASK, |
| 91 | .irqenable_inv = true, |
Tarun Kanti DebBarma | 5e571f3 | 2011-09-13 15:02:14 +0530 | [diff] [blame^] | 92 | .irqctrl = OMAP7XX_GPIO_INT_CONTROL, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 95 | static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { |
| 96 | .virtual_irq_start = IH_GPIO_BASE, |
| 97 | .bank_type = METHOD_GPIO_7XX, |
| 98 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 99 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 100 | }; |
| 101 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 102 | static struct platform_device omap7xx_gpio1 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 103 | .name = "omap_gpio", |
| 104 | .id = 1, |
| 105 | .dev = { |
| 106 | .platform_data = &omap7xx_gpio1_config, |
| 107 | }, |
| 108 | .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources), |
| 109 | .resource = omap7xx_gpio1_resources, |
| 110 | }; |
| 111 | |
| 112 | /* gpio2 */ |
| 113 | static struct __initdata resource omap7xx_gpio2_resources[] = { |
| 114 | { |
| 115 | .start = OMAP7XX_GPIO2_BASE, |
| 116 | .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1, |
| 117 | .flags = IORESOURCE_MEM, |
| 118 | }, |
| 119 | { |
| 120 | .start = INT_7XX_GPIO_BANK2, |
| 121 | .flags = IORESOURCE_IRQ, |
| 122 | }, |
| 123 | }; |
| 124 | |
| 125 | static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { |
| 126 | .virtual_irq_start = IH_GPIO_BASE + 32, |
| 127 | .bank_type = METHOD_GPIO_7XX, |
| 128 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 129 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 130 | }; |
| 131 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 132 | static struct platform_device omap7xx_gpio2 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 133 | .name = "omap_gpio", |
| 134 | .id = 2, |
| 135 | .dev = { |
| 136 | .platform_data = &omap7xx_gpio2_config, |
| 137 | }, |
| 138 | .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources), |
| 139 | .resource = omap7xx_gpio2_resources, |
| 140 | }; |
| 141 | |
| 142 | /* gpio3 */ |
| 143 | static struct __initdata resource omap7xx_gpio3_resources[] = { |
| 144 | { |
| 145 | .start = OMAP7XX_GPIO3_BASE, |
| 146 | .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1, |
| 147 | .flags = IORESOURCE_MEM, |
| 148 | }, |
| 149 | { |
| 150 | .start = INT_7XX_GPIO_BANK3, |
| 151 | .flags = IORESOURCE_IRQ, |
| 152 | }, |
| 153 | }; |
| 154 | |
| 155 | static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { |
| 156 | .virtual_irq_start = IH_GPIO_BASE + 64, |
| 157 | .bank_type = METHOD_GPIO_7XX, |
| 158 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 159 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 160 | }; |
| 161 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 162 | static struct platform_device omap7xx_gpio3 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 163 | .name = "omap_gpio", |
| 164 | .id = 3, |
| 165 | .dev = { |
| 166 | .platform_data = &omap7xx_gpio3_config, |
| 167 | }, |
| 168 | .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources), |
| 169 | .resource = omap7xx_gpio3_resources, |
| 170 | }; |
| 171 | |
| 172 | /* gpio4 */ |
| 173 | static struct __initdata resource omap7xx_gpio4_resources[] = { |
| 174 | { |
| 175 | .start = OMAP7XX_GPIO4_BASE, |
| 176 | .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1, |
| 177 | .flags = IORESOURCE_MEM, |
| 178 | }, |
| 179 | { |
| 180 | .start = INT_7XX_GPIO_BANK4, |
| 181 | .flags = IORESOURCE_IRQ, |
| 182 | }, |
| 183 | }; |
| 184 | |
| 185 | static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { |
| 186 | .virtual_irq_start = IH_GPIO_BASE + 96, |
| 187 | .bank_type = METHOD_GPIO_7XX, |
| 188 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 189 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 190 | }; |
| 191 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 192 | static struct platform_device omap7xx_gpio4 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 193 | .name = "omap_gpio", |
| 194 | .id = 4, |
| 195 | .dev = { |
| 196 | .platform_data = &omap7xx_gpio4_config, |
| 197 | }, |
| 198 | .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources), |
| 199 | .resource = omap7xx_gpio4_resources, |
| 200 | }; |
| 201 | |
| 202 | /* gpio5 */ |
| 203 | static struct __initdata resource omap7xx_gpio5_resources[] = { |
| 204 | { |
| 205 | .start = OMAP7XX_GPIO5_BASE, |
| 206 | .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1, |
| 207 | .flags = IORESOURCE_MEM, |
| 208 | }, |
| 209 | { |
| 210 | .start = INT_7XX_GPIO_BANK5, |
| 211 | .flags = IORESOURCE_IRQ, |
| 212 | }, |
| 213 | }; |
| 214 | |
| 215 | static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { |
| 216 | .virtual_irq_start = IH_GPIO_BASE + 128, |
| 217 | .bank_type = METHOD_GPIO_7XX, |
| 218 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 219 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 220 | }; |
| 221 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 222 | static struct platform_device omap7xx_gpio5 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 223 | .name = "omap_gpio", |
| 224 | .id = 5, |
| 225 | .dev = { |
| 226 | .platform_data = &omap7xx_gpio5_config, |
| 227 | }, |
| 228 | .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources), |
| 229 | .resource = omap7xx_gpio5_resources, |
| 230 | }; |
| 231 | |
| 232 | /* gpio6 */ |
| 233 | static struct __initdata resource omap7xx_gpio6_resources[] = { |
| 234 | { |
| 235 | .start = OMAP7XX_GPIO6_BASE, |
| 236 | .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1, |
| 237 | .flags = IORESOURCE_MEM, |
| 238 | }, |
| 239 | { |
| 240 | .start = INT_7XX_GPIO_BANK6, |
| 241 | .flags = IORESOURCE_IRQ, |
| 242 | }, |
| 243 | }; |
| 244 | |
| 245 | static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { |
| 246 | .virtual_irq_start = IH_GPIO_BASE + 160, |
| 247 | .bank_type = METHOD_GPIO_7XX, |
| 248 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 249 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 250 | }; |
| 251 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 252 | static struct platform_device omap7xx_gpio6 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 253 | .name = "omap_gpio", |
| 254 | .id = 6, |
| 255 | .dev = { |
| 256 | .platform_data = &omap7xx_gpio6_config, |
| 257 | }, |
| 258 | .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources), |
| 259 | .resource = omap7xx_gpio6_resources, |
| 260 | }; |
| 261 | |
| 262 | static struct __initdata platform_device * omap7xx_gpio_dev[] = { |
| 263 | &omap7xx_mpu_gpio, |
| 264 | &omap7xx_gpio1, |
| 265 | &omap7xx_gpio2, |
| 266 | &omap7xx_gpio3, |
| 267 | &omap7xx_gpio4, |
| 268 | &omap7xx_gpio5, |
| 269 | &omap7xx_gpio6, |
| 270 | }; |
| 271 | |
| 272 | /* |
| 273 | * omap7xx_gpio_init needs to be done before |
| 274 | * machine_init functions access gpio APIs. |
| 275 | * Hence omap7xx_gpio_init is a postcore_initcall. |
| 276 | */ |
| 277 | static int __init omap7xx_gpio_init(void) |
| 278 | { |
| 279 | int i; |
| 280 | |
| 281 | if (!cpu_is_omap7xx()) |
| 282 | return -EINVAL; |
| 283 | |
| 284 | for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++) |
| 285 | platform_device_register(omap7xx_gpio_dev[i]); |
| 286 | |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 287 | return 0; |
| 288 | } |
| 289 | postcore_initcall(omap7xx_gpio_init); |