Vadim Bendebury | 9c9c336 | 2014-07-23 09:40:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #ifndef __SRC_INCLUDE_GPIOLIB_H__ |
| 21 | #define __SRC_INCLUDE_GPIOLIB_H__ |
| 22 | |
| 23 | /* A generic type, use accessor macros to actually access the hardware. */ |
| 24 | typedef unsigned gpio_t; |
| 25 | |
| 26 | /* |
| 27 | * Read the value presented by the set of GPIOs, when each pin is interpreted |
| 28 | * as a number in 0..2 range depending on the external pullup situation. |
| 29 | * |
| 30 | * Depending on the third parameter, the return value is either a set of two |
| 31 | * bit fields, each representing one GPIO value, or a number where each GPIO is |
| 32 | * included multiplied by 3^gpio_num, resulting in a true tertiary value. |
| 33 | * |
| 34 | */ |
Vadim Bendebury | 3760272 | 2014-08-07 12:02:26 -0700 | [diff] [blame^] | 35 | int gpio_get_in_tristate_values(gpio_t gpio[], int num_gpio, int tertiary); |
Vadim Bendebury | 9c9c336 | 2014-07-23 09:40:02 -0700 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * The following functions are not provided by the common library, but must be |
| 39 | * implemented by the appropriate SOC/board instead. |
| 40 | */ |
| 41 | int gpio_get_in_value(gpio_t gpio); |
| 42 | void gpio_set_out_value(gpio_t gpio, int value); |
| 43 | void gpio_input_pulldown(gpio_t gpio); |
| 44 | void gpio_input_pullup(gpio_t gpio); |
| 45 | void gpio_input(gpio_t gpio); |
| 46 | |
| 47 | #endif |