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