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