Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 2 | /* |
| 3 | * GPIO driver for TI DaVinci DA8xx SOCs. |
| 4 | * |
| 5 | * (C) Copyright 2011 Guralp Systems Ltd. |
| 6 | * Laurence Withers <lwithers@guralp.com> |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <asm/io.h> |
| 11 | #include <asm/gpio.h> |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 12 | #include <asm/arch/hardware.h> |
| 13 | #include <asm/arch/davinci_misc.h> |
| 14 | |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 15 | static struct gpio_registry { |
| 16 | int is_registered; |
| 17 | char name[GPIO_NAME_SIZE]; |
| 18 | } gpio_registry[MAX_NUM_GPIOS]; |
| 19 | |
Holger Hans Peter Freyther | 03414ac | 2013-02-07 23:41:01 +0000 | [diff] [blame] | 20 | #if defined(CONFIG_SOC_DA8XX) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 21 | #define pinmux(x) (&davinci_syscfg_regs->pinmux[x]) |
| 22 | |
Tomas Novotny | b9f5669 | 2013-02-01 06:46:00 +0000 | [diff] [blame] | 23 | #if defined(CONFIG_SOC_DA8XX) && !defined(CONFIG_SOC_DA850) |
| 24 | static const struct pinmux_config gpio_pinmux[] = { |
| 25 | { pinmux(13), 8, 6 }, /* GP0[0] */ |
| 26 | { pinmux(13), 8, 7 }, |
| 27 | { pinmux(14), 8, 0 }, |
| 28 | { pinmux(14), 8, 1 }, |
| 29 | { pinmux(14), 8, 2 }, |
| 30 | { pinmux(14), 8, 3 }, |
| 31 | { pinmux(14), 8, 4 }, |
| 32 | { pinmux(14), 8, 5 }, |
| 33 | { pinmux(14), 8, 6 }, |
| 34 | { pinmux(14), 8, 7 }, |
| 35 | { pinmux(15), 8, 0 }, |
| 36 | { pinmux(15), 8, 1 }, |
| 37 | { pinmux(15), 8, 2 }, |
| 38 | { pinmux(15), 8, 3 }, |
| 39 | { pinmux(15), 8, 4 }, |
| 40 | { pinmux(15), 8, 5 }, |
| 41 | { pinmux(15), 8, 6 }, /* GP1[0] */ |
| 42 | { pinmux(15), 8, 7 }, |
| 43 | { pinmux(16), 8, 0 }, |
| 44 | { pinmux(16), 8, 1 }, |
| 45 | { pinmux(16), 8, 2 }, |
| 46 | { pinmux(16), 8, 3 }, |
| 47 | { pinmux(16), 8, 4 }, |
| 48 | { pinmux(16), 8, 5 }, |
| 49 | { pinmux(16), 8, 6 }, |
| 50 | { pinmux(16), 8, 7 }, |
| 51 | { pinmux(17), 8, 0 }, |
| 52 | { pinmux(17), 8, 1 }, |
| 53 | { pinmux(17), 8, 2 }, |
| 54 | { pinmux(17), 8, 3 }, |
| 55 | { pinmux(17), 8, 4 }, |
| 56 | { pinmux(17), 8, 5 }, |
| 57 | { pinmux(17), 8, 6 }, /* GP2[0] */ |
| 58 | { pinmux(17), 8, 7 }, |
| 59 | { pinmux(18), 8, 0 }, |
| 60 | { pinmux(18), 8, 1 }, |
| 61 | { pinmux(18), 8, 2 }, |
| 62 | { pinmux(18), 8, 3 }, |
| 63 | { pinmux(18), 8, 4 }, |
| 64 | { pinmux(18), 8, 5 }, |
| 65 | { pinmux(18), 8, 6 }, |
| 66 | { pinmux(18), 8, 7 }, |
| 67 | { pinmux(19), 8, 0 }, |
| 68 | { pinmux(9), 8, 2 }, |
| 69 | { pinmux(9), 8, 3 }, |
| 70 | { pinmux(9), 8, 4 }, |
| 71 | { pinmux(9), 8, 5 }, |
| 72 | { pinmux(9), 8, 6 }, |
| 73 | { pinmux(10), 8, 1 }, /* GP3[0] */ |
| 74 | { pinmux(10), 8, 2 }, |
| 75 | { pinmux(10), 8, 3 }, |
| 76 | { pinmux(10), 8, 4 }, |
| 77 | { pinmux(10), 8, 5 }, |
| 78 | { pinmux(10), 8, 6 }, |
| 79 | { pinmux(10), 8, 7 }, |
| 80 | { pinmux(11), 8, 0 }, |
| 81 | { pinmux(11), 8, 1 }, |
| 82 | { pinmux(11), 8, 2 }, |
| 83 | { pinmux(11), 8, 3 }, |
| 84 | { pinmux(11), 8, 4 }, |
| 85 | { pinmux(9), 8, 7 }, |
| 86 | { pinmux(2), 8, 6 }, |
| 87 | { pinmux(11), 8, 5 }, |
| 88 | { pinmux(11), 8, 6 }, |
| 89 | { pinmux(12), 8, 4 }, /* GP4[0] */ |
| 90 | { pinmux(12), 8, 5 }, |
| 91 | { pinmux(12), 8, 6 }, |
| 92 | { pinmux(12), 8, 7 }, |
| 93 | { pinmux(13), 8, 0 }, |
| 94 | { pinmux(13), 8, 1 }, |
| 95 | { pinmux(13), 8, 2 }, |
| 96 | { pinmux(13), 8, 3 }, |
| 97 | { pinmux(13), 8, 4 }, |
| 98 | { pinmux(13), 8, 5 }, |
| 99 | { pinmux(11), 8, 7 }, |
| 100 | { pinmux(12), 8, 0 }, |
| 101 | { pinmux(12), 8, 1 }, |
| 102 | { pinmux(12), 8, 2 }, |
| 103 | { pinmux(12), 8, 3 }, |
| 104 | { pinmux(9), 8, 1 }, |
| 105 | { pinmux(7), 8, 3 }, /* GP5[0] */ |
| 106 | { pinmux(7), 8, 4 }, |
| 107 | { pinmux(7), 8, 5 }, |
| 108 | { pinmux(7), 8, 6 }, |
| 109 | { pinmux(7), 8, 7 }, |
| 110 | { pinmux(8), 8, 0 }, |
| 111 | { pinmux(8), 8, 1 }, |
| 112 | { pinmux(8), 8, 2 }, |
| 113 | { pinmux(8), 8, 3 }, |
| 114 | { pinmux(8), 8, 4 }, |
| 115 | { pinmux(8), 8, 5 }, |
| 116 | { pinmux(8), 8, 6 }, |
| 117 | { pinmux(8), 8, 7 }, |
| 118 | { pinmux(9), 8, 0 }, |
| 119 | { pinmux(7), 8, 1 }, |
| 120 | { pinmux(7), 8, 2 }, |
| 121 | { pinmux(5), 8, 1 }, /* GP6[0] */ |
| 122 | { pinmux(5), 8, 2 }, |
| 123 | { pinmux(5), 8, 3 }, |
| 124 | { pinmux(5), 8, 4 }, |
| 125 | { pinmux(5), 8, 5 }, |
| 126 | { pinmux(5), 8, 6 }, |
| 127 | { pinmux(5), 8, 7 }, |
| 128 | { pinmux(6), 8, 0 }, |
| 129 | { pinmux(6), 8, 1 }, |
| 130 | { pinmux(6), 8, 2 }, |
| 131 | { pinmux(6), 8, 3 }, |
| 132 | { pinmux(6), 8, 4 }, |
| 133 | { pinmux(6), 8, 5 }, |
| 134 | { pinmux(6), 8, 6 }, |
| 135 | { pinmux(6), 8, 7 }, |
| 136 | { pinmux(7), 8, 0 }, |
| 137 | { pinmux(1), 8, 0 }, /* GP7[0] */ |
| 138 | { pinmux(1), 8, 1 }, |
| 139 | { pinmux(1), 8, 2 }, |
| 140 | { pinmux(1), 8, 3 }, |
| 141 | { pinmux(1), 8, 4 }, |
| 142 | { pinmux(1), 8, 5 }, |
| 143 | { pinmux(1), 8, 6 }, |
| 144 | { pinmux(1), 8, 7 }, |
| 145 | { pinmux(2), 8, 0 }, |
| 146 | { pinmux(2), 8, 1 }, |
| 147 | { pinmux(2), 8, 2 }, |
| 148 | { pinmux(2), 8, 3 }, |
| 149 | { pinmux(2), 8, 4 }, |
| 150 | { pinmux(2), 8, 5 }, |
| 151 | { pinmux(0), 1, 0 }, |
| 152 | { pinmux(0), 1, 1 }, |
| 153 | }; |
Tom Rini | 76b40ab | 2013-03-11 12:02:40 -0400 | [diff] [blame] | 154 | #else /* CONFIG_SOC_DA8XX && CONFIG_SOC_DA850 */ |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 155 | static const struct pinmux_config gpio_pinmux[] = { |
| 156 | { pinmux(1), 8, 7 }, /* GP0[0] */ |
| 157 | { pinmux(1), 8, 6 }, |
| 158 | { pinmux(1), 8, 5 }, |
| 159 | { pinmux(1), 8, 4 }, |
| 160 | { pinmux(1), 8, 3 }, |
| 161 | { pinmux(1), 8, 2 }, |
| 162 | { pinmux(1), 8, 1 }, |
| 163 | { pinmux(1), 8, 0 }, |
| 164 | { pinmux(0), 8, 7 }, |
| 165 | { pinmux(0), 8, 6 }, |
| 166 | { pinmux(0), 8, 5 }, |
| 167 | { pinmux(0), 8, 4 }, |
| 168 | { pinmux(0), 8, 3 }, |
| 169 | { pinmux(0), 8, 2 }, |
| 170 | { pinmux(0), 8, 1 }, |
| 171 | { pinmux(0), 8, 0 }, |
| 172 | { pinmux(4), 8, 7 }, /* GP1[0] */ |
| 173 | { pinmux(4), 8, 6 }, |
| 174 | { pinmux(4), 8, 5 }, |
| 175 | { pinmux(4), 8, 4 }, |
| 176 | { pinmux(4), 8, 3 }, |
| 177 | { pinmux(4), 8, 2 }, |
| 178 | { pinmux(4), 4, 1 }, |
| 179 | { pinmux(4), 4, 0 }, |
| 180 | { pinmux(3), 4, 0 }, |
| 181 | { pinmux(2), 4, 6 }, |
| 182 | { pinmux(2), 4, 5 }, |
| 183 | { pinmux(2), 4, 4 }, |
| 184 | { pinmux(2), 4, 3 }, |
| 185 | { pinmux(2), 4, 2 }, |
| 186 | { pinmux(2), 4, 1 }, |
| 187 | { pinmux(2), 8, 0 }, |
| 188 | { pinmux(6), 8, 7 }, /* GP2[0] */ |
| 189 | { pinmux(6), 8, 6 }, |
| 190 | { pinmux(6), 8, 5 }, |
| 191 | { pinmux(6), 8, 4 }, |
| 192 | { pinmux(6), 8, 3 }, |
| 193 | { pinmux(6), 8, 2 }, |
| 194 | { pinmux(6), 8, 1 }, |
| 195 | { pinmux(6), 8, 0 }, |
| 196 | { pinmux(5), 8, 7 }, |
| 197 | { pinmux(5), 8, 6 }, |
| 198 | { pinmux(5), 8, 5 }, |
| 199 | { pinmux(5), 8, 4 }, |
| 200 | { pinmux(5), 8, 3 }, |
| 201 | { pinmux(5), 8, 2 }, |
| 202 | { pinmux(5), 8, 1 }, |
| 203 | { pinmux(5), 8, 0 }, |
| 204 | { pinmux(8), 8, 7 }, /* GP3[0] */ |
| 205 | { pinmux(8), 8, 6 }, |
| 206 | { pinmux(8), 8, 5 }, |
| 207 | { pinmux(8), 8, 4 }, |
| 208 | { pinmux(8), 8, 3 }, |
| 209 | { pinmux(8), 8, 2 }, |
| 210 | { pinmux(8), 8, 1 }, |
| 211 | { pinmux(8), 8, 0 }, |
| 212 | { pinmux(7), 8, 7 }, |
| 213 | { pinmux(7), 8, 6 }, |
| 214 | { pinmux(7), 8, 5 }, |
| 215 | { pinmux(7), 8, 4 }, |
| 216 | { pinmux(7), 8, 3 }, |
| 217 | { pinmux(7), 8, 2 }, |
| 218 | { pinmux(7), 8, 1 }, |
| 219 | { pinmux(7), 8, 0 }, |
| 220 | { pinmux(10), 8, 7 }, /* GP4[0] */ |
| 221 | { pinmux(10), 8, 6 }, |
| 222 | { pinmux(10), 8, 5 }, |
| 223 | { pinmux(10), 8, 4 }, |
| 224 | { pinmux(10), 8, 3 }, |
| 225 | { pinmux(10), 8, 2 }, |
| 226 | { pinmux(10), 8, 1 }, |
| 227 | { pinmux(10), 8, 0 }, |
| 228 | { pinmux(9), 8, 7 }, |
| 229 | { pinmux(9), 8, 6 }, |
| 230 | { pinmux(9), 8, 5 }, |
| 231 | { pinmux(9), 8, 4 }, |
| 232 | { pinmux(9), 8, 3 }, |
| 233 | { pinmux(9), 8, 2 }, |
| 234 | { pinmux(9), 8, 1 }, |
| 235 | { pinmux(9), 8, 0 }, |
| 236 | { pinmux(12), 8, 7 }, /* GP5[0] */ |
| 237 | { pinmux(12), 8, 6 }, |
| 238 | { pinmux(12), 8, 5 }, |
| 239 | { pinmux(12), 8, 4 }, |
| 240 | { pinmux(12), 8, 3 }, |
| 241 | { pinmux(12), 8, 2 }, |
| 242 | { pinmux(12), 8, 1 }, |
| 243 | { pinmux(12), 8, 0 }, |
| 244 | { pinmux(11), 8, 7 }, |
| 245 | { pinmux(11), 8, 6 }, |
| 246 | { pinmux(11), 8, 5 }, |
| 247 | { pinmux(11), 8, 4 }, |
| 248 | { pinmux(11), 8, 3 }, |
| 249 | { pinmux(11), 8, 2 }, |
| 250 | { pinmux(11), 8, 1 }, |
| 251 | { pinmux(11), 8, 0 }, |
| 252 | { pinmux(19), 8, 6 }, /* GP6[0] */ |
| 253 | { pinmux(19), 8, 5 }, |
| 254 | { pinmux(19), 8, 4 }, |
| 255 | { pinmux(19), 8, 3 }, |
| 256 | { pinmux(19), 8, 2 }, |
| 257 | { pinmux(16), 8, 1 }, |
| 258 | { pinmux(14), 8, 1 }, |
| 259 | { pinmux(14), 8, 0 }, |
| 260 | { pinmux(13), 8, 7 }, |
| 261 | { pinmux(13), 8, 6 }, |
| 262 | { pinmux(13), 8, 5 }, |
| 263 | { pinmux(13), 8, 4 }, |
| 264 | { pinmux(13), 8, 3 }, |
| 265 | { pinmux(13), 8, 2 }, |
| 266 | { pinmux(13), 8, 1 }, |
| 267 | { pinmux(13), 8, 0 }, |
| 268 | { pinmux(18), 8, 1 }, /* GP7[0] */ |
| 269 | { pinmux(18), 8, 0 }, |
| 270 | { pinmux(17), 8, 7 }, |
| 271 | { pinmux(17), 8, 6 }, |
| 272 | { pinmux(17), 8, 5 }, |
| 273 | { pinmux(17), 8, 4 }, |
| 274 | { pinmux(17), 8, 3 }, |
| 275 | { pinmux(17), 8, 2 }, |
| 276 | { pinmux(17), 8, 1 }, |
| 277 | { pinmux(17), 8, 0 }, |
| 278 | { pinmux(16), 8, 7 }, |
| 279 | { pinmux(16), 8, 6 }, |
| 280 | { pinmux(16), 8, 5 }, |
| 281 | { pinmux(16), 8, 4 }, |
| 282 | { pinmux(16), 8, 3 }, |
| 283 | { pinmux(16), 8, 2 }, |
| 284 | { pinmux(19), 8, 0 }, /* GP8[0] */ |
| 285 | { pinmux(3), 4, 7 }, |
| 286 | { pinmux(3), 4, 6 }, |
| 287 | { pinmux(3), 4, 5 }, |
| 288 | { pinmux(3), 4, 4 }, |
| 289 | { pinmux(3), 4, 3 }, |
| 290 | { pinmux(3), 4, 2 }, |
| 291 | { pinmux(2), 4, 7 }, |
| 292 | { pinmux(19), 8, 1 }, |
| 293 | { pinmux(19), 8, 0 }, |
| 294 | { pinmux(18), 8, 7 }, |
| 295 | { pinmux(18), 8, 6 }, |
| 296 | { pinmux(18), 8, 5 }, |
| 297 | { pinmux(18), 8, 4 }, |
| 298 | { pinmux(18), 8, 3 }, |
| 299 | { pinmux(18), 8, 2 }, |
| 300 | }; |
Tom Rini | 76b40ab | 2013-03-11 12:02:40 -0400 | [diff] [blame] | 301 | #endif /* CONFIG_SOC_DA8XX && !CONFIG_SOC_DA850 */ |
| 302 | #else /* !CONFIG_SOC_DA8XX */ |
Holger Hans Peter Freyther | 03414ac | 2013-02-07 23:41:01 +0000 | [diff] [blame] | 303 | #define davinci_configure_pin_mux(a, b) |
Tom Rini | 76b40ab | 2013-03-11 12:02:40 -0400 | [diff] [blame] | 304 | #endif /* CONFIG_SOC_DA8XX */ |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 305 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 306 | int gpio_request(unsigned gpio, const char *label) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 307 | { |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 308 | if (gpio >= MAX_NUM_GPIOS) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 309 | return -1; |
| 310 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 311 | if (gpio_registry[gpio].is_registered) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 312 | return -1; |
| 313 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 314 | gpio_registry[gpio].is_registered = 1; |
| 315 | strncpy(gpio_registry[gpio].name, label, GPIO_NAME_SIZE); |
| 316 | gpio_registry[gpio].name[GPIO_NAME_SIZE - 1] = 0; |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 317 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 318 | davinci_configure_pin_mux(&gpio_pinmux[gpio], 1); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 319 | |
| 320 | return 0; |
| 321 | } |
| 322 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 323 | int gpio_free(unsigned gpio) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 324 | { |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 325 | if (gpio >= MAX_NUM_GPIOS) |
| 326 | return -1; |
| 327 | |
| 328 | if (!gpio_registry[gpio].is_registered) |
| 329 | return -1; |
| 330 | |
| 331 | gpio_registry[gpio].is_registered = 0; |
| 332 | gpio_registry[gpio].name[0] = '\0'; |
| 333 | /* Do not configure as input or change pin mux here */ |
| 334 | return 0; |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 335 | } |
| 336 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 337 | int gpio_direction_input(unsigned gpio) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 338 | { |
| 339 | struct davinci_gpio *bank; |
| 340 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 341 | bank = GPIO_BANK(gpio); |
| 342 | setbits_le32(&bank->dir, 1U << GPIO_BIT(gpio)); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 343 | return 0; |
| 344 | } |
| 345 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 346 | int gpio_direction_output(unsigned gpio, int value) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 347 | { |
| 348 | struct davinci_gpio *bank; |
| 349 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 350 | bank = GPIO_BANK(gpio); |
| 351 | clrbits_le32(&bank->dir, 1U << GPIO_BIT(gpio)); |
| 352 | gpio_set_value(gpio, value); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 353 | return 0; |
| 354 | } |
| 355 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 356 | int gpio_get_value(unsigned gpio) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 357 | { |
| 358 | struct davinci_gpio *bank; |
| 359 | unsigned int ip; |
| 360 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 361 | bank = GPIO_BANK(gpio); |
| 362 | ip = in_le32(&bank->in_data) & (1U << GPIO_BIT(gpio)); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 363 | return ip ? 1 : 0; |
| 364 | } |
| 365 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 366 | int gpio_set_value(unsigned gpio, int value) |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 367 | { |
| 368 | struct davinci_gpio *bank; |
| 369 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 370 | bank = GPIO_BANK(gpio); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 371 | |
| 372 | if (value) |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 373 | bank->set_data = 1U << GPIO_BIT(gpio); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 374 | else |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 375 | bank->clr_data = 1U << GPIO_BIT(gpio); |
| 376 | |
| 377 | return 0; |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 378 | } |
| 379 | |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 380 | void gpio_info(void) |
| 381 | { |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 382 | unsigned gpio, dir, val; |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 383 | struct davinci_gpio *bank; |
| 384 | |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 385 | for (gpio = 0; gpio < MAX_NUM_GPIOS; ++gpio) { |
| 386 | bank = GPIO_BANK(gpio); |
| 387 | dir = in_le32(&bank->dir) & (1U << GPIO_BIT(gpio)); |
| 388 | val = gpio_get_value(gpio); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 389 | |
| 390 | printf("% 4d: %s: %d [%c] %s\n", |
Joe Hershberger | 365d607 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 391 | gpio, dir ? " in" : "out", val, |
| 392 | gpio_registry[gpio].is_registered ? 'x' : ' ', |
| 393 | gpio_registry[gpio].name); |
Laurence Withers | f517afd | 2011-07-18 09:26:01 -0400 | [diff] [blame] | 394 | } |
| 395 | } |