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, |
Charulatha V | d0d665a | 2011-08-31 00:02:21 +0530 | [diff] [blame] | 55 | .is_mpuio = true, |
Charulatha V | ec9af5d | 2011-05-25 12:44:28 +0530 | [diff] [blame^] | 56 | .bank_width = 16, |
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, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 97 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 98 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 99 | }; |
| 100 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 101 | static struct platform_device omap7xx_gpio1 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 102 | .name = "omap_gpio", |
| 103 | .id = 1, |
| 104 | .dev = { |
| 105 | .platform_data = &omap7xx_gpio1_config, |
| 106 | }, |
| 107 | .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources), |
| 108 | .resource = omap7xx_gpio1_resources, |
| 109 | }; |
| 110 | |
| 111 | /* gpio2 */ |
| 112 | static struct __initdata resource omap7xx_gpio2_resources[] = { |
| 113 | { |
| 114 | .start = OMAP7XX_GPIO2_BASE, |
| 115 | .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1, |
| 116 | .flags = IORESOURCE_MEM, |
| 117 | }, |
| 118 | { |
| 119 | .start = INT_7XX_GPIO_BANK2, |
| 120 | .flags = IORESOURCE_IRQ, |
| 121 | }, |
| 122 | }; |
| 123 | |
| 124 | static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { |
| 125 | .virtual_irq_start = IH_GPIO_BASE + 32, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 126 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 127 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 128 | }; |
| 129 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 130 | static struct platform_device omap7xx_gpio2 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 131 | .name = "omap_gpio", |
| 132 | .id = 2, |
| 133 | .dev = { |
| 134 | .platform_data = &omap7xx_gpio2_config, |
| 135 | }, |
| 136 | .num_resources = ARRAY_SIZE(omap7xx_gpio2_resources), |
| 137 | .resource = omap7xx_gpio2_resources, |
| 138 | }; |
| 139 | |
| 140 | /* gpio3 */ |
| 141 | static struct __initdata resource omap7xx_gpio3_resources[] = { |
| 142 | { |
| 143 | .start = OMAP7XX_GPIO3_BASE, |
| 144 | .end = OMAP7XX_GPIO3_BASE + SZ_2K - 1, |
| 145 | .flags = IORESOURCE_MEM, |
| 146 | }, |
| 147 | { |
| 148 | .start = INT_7XX_GPIO_BANK3, |
| 149 | .flags = IORESOURCE_IRQ, |
| 150 | }, |
| 151 | }; |
| 152 | |
| 153 | static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { |
| 154 | .virtual_irq_start = IH_GPIO_BASE + 64, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 155 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 156 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 157 | }; |
| 158 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 159 | static struct platform_device omap7xx_gpio3 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 160 | .name = "omap_gpio", |
| 161 | .id = 3, |
| 162 | .dev = { |
| 163 | .platform_data = &omap7xx_gpio3_config, |
| 164 | }, |
| 165 | .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources), |
| 166 | .resource = omap7xx_gpio3_resources, |
| 167 | }; |
| 168 | |
| 169 | /* gpio4 */ |
| 170 | static struct __initdata resource omap7xx_gpio4_resources[] = { |
| 171 | { |
| 172 | .start = OMAP7XX_GPIO4_BASE, |
| 173 | .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1, |
| 174 | .flags = IORESOURCE_MEM, |
| 175 | }, |
| 176 | { |
| 177 | .start = INT_7XX_GPIO_BANK4, |
| 178 | .flags = IORESOURCE_IRQ, |
| 179 | }, |
| 180 | }; |
| 181 | |
| 182 | static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { |
| 183 | .virtual_irq_start = IH_GPIO_BASE + 96, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 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 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 188 | static struct platform_device omap7xx_gpio4 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 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, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 213 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 214 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 215 | }; |
| 216 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 217 | static struct platform_device omap7xx_gpio5 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 218 | .name = "omap_gpio", |
| 219 | .id = 5, |
| 220 | .dev = { |
| 221 | .platform_data = &omap7xx_gpio5_config, |
| 222 | }, |
| 223 | .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources), |
| 224 | .resource = omap7xx_gpio5_resources, |
| 225 | }; |
| 226 | |
| 227 | /* gpio6 */ |
| 228 | static struct __initdata resource omap7xx_gpio6_resources[] = { |
| 229 | { |
| 230 | .start = OMAP7XX_GPIO6_BASE, |
| 231 | .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1, |
| 232 | .flags = IORESOURCE_MEM, |
| 233 | }, |
| 234 | { |
| 235 | .start = INT_7XX_GPIO_BANK6, |
| 236 | .flags = IORESOURCE_IRQ, |
| 237 | }, |
| 238 | }; |
| 239 | |
| 240 | static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { |
| 241 | .virtual_irq_start = IH_GPIO_BASE + 160, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 242 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 243 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 244 | }; |
| 245 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 246 | static struct platform_device omap7xx_gpio6 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 247 | .name = "omap_gpio", |
| 248 | .id = 6, |
| 249 | .dev = { |
| 250 | .platform_data = &omap7xx_gpio6_config, |
| 251 | }, |
| 252 | .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources), |
| 253 | .resource = omap7xx_gpio6_resources, |
| 254 | }; |
| 255 | |
| 256 | static struct __initdata platform_device * omap7xx_gpio_dev[] = { |
| 257 | &omap7xx_mpu_gpio, |
| 258 | &omap7xx_gpio1, |
| 259 | &omap7xx_gpio2, |
| 260 | &omap7xx_gpio3, |
| 261 | &omap7xx_gpio4, |
| 262 | &omap7xx_gpio5, |
| 263 | &omap7xx_gpio6, |
| 264 | }; |
| 265 | |
| 266 | /* |
| 267 | * omap7xx_gpio_init needs to be done before |
| 268 | * machine_init functions access gpio APIs. |
| 269 | * Hence omap7xx_gpio_init is a postcore_initcall. |
| 270 | */ |
| 271 | static int __init omap7xx_gpio_init(void) |
| 272 | { |
| 273 | int i; |
| 274 | |
| 275 | if (!cpu_is_omap7xx()) |
| 276 | return -EINVAL; |
| 277 | |
| 278 | for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++) |
| 279 | platform_device_register(omap7xx_gpio_dev[i]); |
| 280 | |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 281 | return 0; |
| 282 | } |
| 283 | postcore_initcall(omap7xx_gpio_init); |