Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 1 | /* |
| 2 | * OMAP16xx 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 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 |
| 26 | |
| 27 | /* mpu gpio */ |
| 28 | static struct __initdata resource omap16xx_mpu_gpio_resources[] = { |
| 29 | { |
| 30 | .start = OMAP1_MPUIO_VBASE, |
| 31 | .end = OMAP1_MPUIO_VBASE + SZ_2K - 1, |
| 32 | .flags = IORESOURCE_MEM, |
| 33 | }, |
| 34 | { |
| 35 | .start = INT_MPUIO, |
| 36 | .flags = IORESOURCE_IRQ, |
| 37 | }, |
| 38 | }; |
| 39 | |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 40 | static struct omap_gpio_reg_offs omap16xx_mpuio_regs = { |
| 41 | .direction = OMAP_MPUIO_IO_CNTL, |
| 42 | .datain = OMAP_MPUIO_INPUT_LATCH, |
| 43 | .dataout = OMAP_MPUIO_OUTPUT, |
Kevin Hilman | eef4bec | 2011-04-21 09:17:35 -0700 | [diff] [blame^] | 44 | .irqstatus = OMAP_MPUIO_GPIO_INT, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 47 | static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { |
| 48 | .virtual_irq_start = IH_MPUIO_BASE, |
| 49 | .bank_type = METHOD_MPUIO, |
| 50 | .bank_width = 16, |
Tony Lindgren | 5de62b8 | 2010-12-07 16:26:58 -0800 | [diff] [blame] | 51 | .bank_stride = 1, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 52 | .regs = &omap16xx_mpuio_regs, |
Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | static struct __initdata platform_device omap16xx_mpu_gpio = { |
| 56 | .name = "omap_gpio", |
| 57 | .id = 0, |
| 58 | .dev = { |
| 59 | .platform_data = &omap16xx_mpu_gpio_config, |
| 60 | }, |
| 61 | .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources), |
| 62 | .resource = omap16xx_mpu_gpio_resources, |
| 63 | }; |
| 64 | |
| 65 | /* gpio1 */ |
| 66 | static struct __initdata resource omap16xx_gpio1_resources[] = { |
| 67 | { |
| 68 | .start = OMAP1610_GPIO1_BASE, |
| 69 | .end = OMAP1610_GPIO1_BASE + SZ_2K - 1, |
| 70 | .flags = IORESOURCE_MEM, |
| 71 | }, |
| 72 | { |
| 73 | .start = INT_GPIO_BANK1, |
| 74 | .flags = IORESOURCE_IRQ, |
| 75 | }, |
| 76 | }; |
| 77 | |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 78 | static struct omap_gpio_reg_offs omap16xx_gpio_regs = { |
| 79 | .direction = OMAP1610_GPIO_DIRECTION, |
| 80 | .set_dataout = OMAP1610_GPIO_SET_DATAOUT, |
| 81 | .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT, |
| 82 | .datain = OMAP1610_GPIO_DATAIN, |
| 83 | .dataout = OMAP1610_GPIO_DATAOUT, |
Kevin Hilman | eef4bec | 2011-04-21 09:17:35 -0700 | [diff] [blame^] | 84 | .irqstatus = OMAP1610_GPIO_IRQSTATUS1, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 85 | }; |
| 86 | |
Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 87 | static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { |
| 88 | .virtual_irq_start = IH_GPIO_BASE, |
| 89 | .bank_type = METHOD_GPIO_1610, |
| 90 | .bank_width = 16, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 91 | .regs = &omap16xx_gpio_regs, |
Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | static struct __initdata platform_device omap16xx_gpio1 = { |
| 95 | .name = "omap_gpio", |
| 96 | .id = 1, |
| 97 | .dev = { |
| 98 | .platform_data = &omap16xx_gpio1_config, |
| 99 | }, |
| 100 | .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources), |
| 101 | .resource = omap16xx_gpio1_resources, |
| 102 | }; |
| 103 | |
| 104 | /* gpio2 */ |
| 105 | static struct __initdata resource omap16xx_gpio2_resources[] = { |
| 106 | { |
| 107 | .start = OMAP1610_GPIO2_BASE, |
| 108 | .end = OMAP1610_GPIO2_BASE + SZ_2K - 1, |
| 109 | .flags = IORESOURCE_MEM, |
| 110 | }, |
| 111 | { |
| 112 | .start = INT_1610_GPIO_BANK2, |
| 113 | .flags = IORESOURCE_IRQ, |
| 114 | }, |
| 115 | }; |
| 116 | |
| 117 | static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { |
| 118 | .virtual_irq_start = IH_GPIO_BASE + 16, |
| 119 | .bank_type = METHOD_GPIO_1610, |
| 120 | .bank_width = 16, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 121 | .regs = &omap16xx_gpio_regs, |
Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | static struct __initdata platform_device omap16xx_gpio2 = { |
| 125 | .name = "omap_gpio", |
| 126 | .id = 2, |
| 127 | .dev = { |
| 128 | .platform_data = &omap16xx_gpio2_config, |
| 129 | }, |
| 130 | .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources), |
| 131 | .resource = omap16xx_gpio2_resources, |
| 132 | }; |
| 133 | |
| 134 | /* gpio3 */ |
| 135 | static struct __initdata resource omap16xx_gpio3_resources[] = { |
| 136 | { |
| 137 | .start = OMAP1610_GPIO3_BASE, |
| 138 | .end = OMAP1610_GPIO3_BASE + SZ_2K - 1, |
| 139 | .flags = IORESOURCE_MEM, |
| 140 | }, |
| 141 | { |
| 142 | .start = INT_1610_GPIO_BANK3, |
| 143 | .flags = IORESOURCE_IRQ, |
| 144 | }, |
| 145 | }; |
| 146 | |
| 147 | static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { |
| 148 | .virtual_irq_start = IH_GPIO_BASE + 32, |
| 149 | .bank_type = METHOD_GPIO_1610, |
| 150 | .bank_width = 16, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 151 | .regs = &omap16xx_gpio_regs, |
Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | static struct __initdata platform_device omap16xx_gpio3 = { |
| 155 | .name = "omap_gpio", |
| 156 | .id = 3, |
| 157 | .dev = { |
| 158 | .platform_data = &omap16xx_gpio3_config, |
| 159 | }, |
| 160 | .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources), |
| 161 | .resource = omap16xx_gpio3_resources, |
| 162 | }; |
| 163 | |
| 164 | /* gpio4 */ |
| 165 | static struct __initdata resource omap16xx_gpio4_resources[] = { |
| 166 | { |
| 167 | .start = OMAP1610_GPIO4_BASE, |
| 168 | .end = OMAP1610_GPIO4_BASE + SZ_2K - 1, |
| 169 | .flags = IORESOURCE_MEM, |
| 170 | }, |
| 171 | { |
| 172 | .start = INT_1610_GPIO_BANK4, |
| 173 | .flags = IORESOURCE_IRQ, |
| 174 | }, |
| 175 | }; |
| 176 | |
| 177 | static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { |
| 178 | .virtual_irq_start = IH_GPIO_BASE + 48, |
| 179 | .bank_type = METHOD_GPIO_1610, |
| 180 | .bank_width = 16, |
Kevin Hilman | fa87931a | 2011-04-20 16:31:23 -0700 | [diff] [blame] | 181 | .regs = &omap16xx_gpio_regs, |
Varadarajan, Charulatha | 87fe622 | 2010-12-07 16:26:56 -0800 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | static struct __initdata platform_device omap16xx_gpio4 = { |
| 185 | .name = "omap_gpio", |
| 186 | .id = 4, |
| 187 | .dev = { |
| 188 | .platform_data = &omap16xx_gpio4_config, |
| 189 | }, |
| 190 | .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources), |
| 191 | .resource = omap16xx_gpio4_resources, |
| 192 | }; |
| 193 | |
| 194 | static struct __initdata platform_device * omap16xx_gpio_dev[] = { |
| 195 | &omap16xx_mpu_gpio, |
| 196 | &omap16xx_gpio1, |
| 197 | &omap16xx_gpio2, |
| 198 | &omap16xx_gpio3, |
| 199 | &omap16xx_gpio4, |
| 200 | }; |
| 201 | |
| 202 | /* |
| 203 | * omap16xx_gpio_init needs to be done before |
| 204 | * machine_init functions access gpio APIs. |
| 205 | * Hence omap16xx_gpio_init is a postcore_initcall. |
| 206 | */ |
| 207 | static int __init omap16xx_gpio_init(void) |
| 208 | { |
| 209 | int i; |
| 210 | |
| 211 | if (!cpu_is_omap16xx()) |
| 212 | return -EINVAL; |
| 213 | |
| 214 | for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++) |
| 215 | platform_device_register(omap16xx_gpio_dev[i]); |
| 216 | |
| 217 | gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev); |
| 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | postcore_initcall(omap16xx_gpio_init); |