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> |
Tony Lindgren | 4b25408 | 2012-08-30 15:37:24 -0700 | [diff] [blame] | 20 | #include <linux/platform_data/gpio-omap.h> |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 21 | |
| 22 | #define OMAP7XX_GPIO1_BASE 0xfffbc000 |
| 23 | #define OMAP7XX_GPIO2_BASE 0xfffbc800 |
| 24 | #define OMAP7XX_GPIO3_BASE 0xfffbd000 |
| 25 | #define OMAP7XX_GPIO4_BASE 0xfffbd800 |
| 26 | #define OMAP7XX_GPIO5_BASE 0xfffbe000 |
| 27 | #define OMAP7XX_GPIO6_BASE 0xfffbe800 |
| 28 | #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE |
| 29 | |
| 30 | /* mpu gpio */ |
| 31 | static struct __initdata resource omap7xx_mpu_gpio_resources[] = { |
| 32 | { |
| 33 | .start = OMAP1_MPUIO_VBASE, |
| 34 | .end = OMAP1_MPUIO_VBASE + SZ_2K - 1, |
| 35 | .flags = IORESOURCE_MEM, |
| 36 | }, |
| 37 | { |
| 38 | .start = INT_7XX_MPUIO, |
| 39 | .flags = IORESOURCE_IRQ, |
| 40 | }, |
| 41 | }; |
| 42 | |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 43 | static struct omap_gpio_reg_offs omap7xx_mpuio_regs = { |
Kevin Hilman | e5ff444 | 2011-04-22 14:37:16 -0700 | [diff] [blame] | 44 | .revision = USHRT_MAX, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 45 | .direction = OMAP_MPUIO_IO_CNTL / 2, |
| 46 | .datain = OMAP_MPUIO_INPUT_LATCH / 2, |
| 47 | .dataout = OMAP_MPUIO_OUTPUT / 2, |
Kevin Hilman | eef4bec | 2011-04-21 09:17:35 -0700 | [diff] [blame] | 48 | .irqstatus = OMAP_MPUIO_GPIO_INT / 2, |
Kevin Hilman | 28f3b5a | 2011-04-21 09:53:06 -0700 | [diff] [blame] | 49 | .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2, |
| 50 | .irqenable_inv = true, |
Tarun Kanti DebBarma | 5e571f3 | 2011-09-13 15:02:14 +0530 | [diff] [blame] | 51 | .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 54 | static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { |
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 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 96 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 97 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 98 | }; |
| 99 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 100 | static struct platform_device omap7xx_gpio1 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 101 | .name = "omap_gpio", |
| 102 | .id = 1, |
| 103 | .dev = { |
| 104 | .platform_data = &omap7xx_gpio1_config, |
| 105 | }, |
| 106 | .num_resources = ARRAY_SIZE(omap7xx_gpio1_resources), |
| 107 | .resource = omap7xx_gpio1_resources, |
| 108 | }; |
| 109 | |
| 110 | /* gpio2 */ |
| 111 | static struct __initdata resource omap7xx_gpio2_resources[] = { |
| 112 | { |
| 113 | .start = OMAP7XX_GPIO2_BASE, |
| 114 | .end = OMAP7XX_GPIO2_BASE + SZ_2K - 1, |
| 115 | .flags = IORESOURCE_MEM, |
| 116 | }, |
| 117 | { |
| 118 | .start = INT_7XX_GPIO_BANK2, |
| 119 | .flags = IORESOURCE_IRQ, |
| 120 | }, |
| 121 | }; |
| 122 | |
| 123 | static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 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 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 128 | static struct platform_device omap7xx_gpio2 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 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 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 152 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 153 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 154 | }; |
| 155 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 156 | static struct platform_device omap7xx_gpio3 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 157 | .name = "omap_gpio", |
| 158 | .id = 3, |
| 159 | .dev = { |
| 160 | .platform_data = &omap7xx_gpio3_config, |
| 161 | }, |
| 162 | .num_resources = ARRAY_SIZE(omap7xx_gpio3_resources), |
| 163 | .resource = omap7xx_gpio3_resources, |
| 164 | }; |
| 165 | |
| 166 | /* gpio4 */ |
| 167 | static struct __initdata resource omap7xx_gpio4_resources[] = { |
| 168 | { |
| 169 | .start = OMAP7XX_GPIO4_BASE, |
| 170 | .end = OMAP7XX_GPIO4_BASE + SZ_2K - 1, |
| 171 | .flags = IORESOURCE_MEM, |
| 172 | }, |
| 173 | { |
| 174 | .start = INT_7XX_GPIO_BANK4, |
| 175 | .flags = IORESOURCE_IRQ, |
| 176 | }, |
| 177 | }; |
| 178 | |
| 179 | static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 180 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 181 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 182 | }; |
| 183 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 184 | static struct platform_device omap7xx_gpio4 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 185 | .name = "omap_gpio", |
| 186 | .id = 4, |
| 187 | .dev = { |
| 188 | .platform_data = &omap7xx_gpio4_config, |
| 189 | }, |
| 190 | .num_resources = ARRAY_SIZE(omap7xx_gpio4_resources), |
| 191 | .resource = omap7xx_gpio4_resources, |
| 192 | }; |
| 193 | |
| 194 | /* gpio5 */ |
| 195 | static struct __initdata resource omap7xx_gpio5_resources[] = { |
| 196 | { |
| 197 | .start = OMAP7XX_GPIO5_BASE, |
| 198 | .end = OMAP7XX_GPIO5_BASE + SZ_2K - 1, |
| 199 | .flags = IORESOURCE_MEM, |
| 200 | }, |
| 201 | { |
| 202 | .start = INT_7XX_GPIO_BANK5, |
| 203 | .flags = IORESOURCE_IRQ, |
| 204 | }, |
| 205 | }; |
| 206 | |
| 207 | static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 208 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 209 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 210 | }; |
| 211 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 212 | static struct platform_device omap7xx_gpio5 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 213 | .name = "omap_gpio", |
| 214 | .id = 5, |
| 215 | .dev = { |
| 216 | .platform_data = &omap7xx_gpio5_config, |
| 217 | }, |
| 218 | .num_resources = ARRAY_SIZE(omap7xx_gpio5_resources), |
| 219 | .resource = omap7xx_gpio5_resources, |
| 220 | }; |
| 221 | |
| 222 | /* gpio6 */ |
| 223 | static struct __initdata resource omap7xx_gpio6_resources[] = { |
| 224 | { |
| 225 | .start = OMAP7XX_GPIO6_BASE, |
| 226 | .end = OMAP7XX_GPIO6_BASE + SZ_2K - 1, |
| 227 | .flags = IORESOURCE_MEM, |
| 228 | }, |
| 229 | { |
| 230 | .start = INT_7XX_GPIO_BANK6, |
| 231 | .flags = IORESOURCE_IRQ, |
| 232 | }, |
| 233 | }; |
| 234 | |
| 235 | static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 236 | .bank_width = 32, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 237 | .regs = &omap7xx_gpio_regs, |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 238 | }; |
| 239 | |
Janusz Krzysztofik | 07ad6ab | 2011-07-04 03:56:15 -0700 | [diff] [blame] | 240 | static struct platform_device omap7xx_gpio6 = { |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 241 | .name = "omap_gpio", |
| 242 | .id = 6, |
| 243 | .dev = { |
| 244 | .platform_data = &omap7xx_gpio6_config, |
| 245 | }, |
| 246 | .num_resources = ARRAY_SIZE(omap7xx_gpio6_resources), |
| 247 | .resource = omap7xx_gpio6_resources, |
| 248 | }; |
| 249 | |
| 250 | static struct __initdata platform_device * omap7xx_gpio_dev[] = { |
| 251 | &omap7xx_mpu_gpio, |
| 252 | &omap7xx_gpio1, |
| 253 | &omap7xx_gpio2, |
| 254 | &omap7xx_gpio3, |
| 255 | &omap7xx_gpio4, |
| 256 | &omap7xx_gpio5, |
| 257 | &omap7xx_gpio6, |
| 258 | }; |
| 259 | |
| 260 | /* |
| 261 | * omap7xx_gpio_init needs to be done before |
| 262 | * machine_init functions access gpio APIs. |
| 263 | * Hence omap7xx_gpio_init is a postcore_initcall. |
| 264 | */ |
| 265 | static int __init omap7xx_gpio_init(void) |
| 266 | { |
| 267 | int i; |
| 268 | |
| 269 | if (!cpu_is_omap7xx()) |
| 270 | return -EINVAL; |
| 271 | |
| 272 | for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++) |
| 273 | platform_device_register(omap7xx_gpio_dev[i]); |
| 274 | |
Varadarajan, Charulatha | 9d52342 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 275 | return 0; |
| 276 | } |
| 277 | postcore_initcall(omap7xx_gpio_init); |