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