blob: 436f26ac04d8ccb5748badefe9512718022f5623 [file] [log] [blame]
Vadim Bendebury9c9c3362014-07-23 09:40:02 -07001/*
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. */
24typedef 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 *
Daisuke Nojiri573e2112014-08-08 15:38:52 -070034 * gpio[]: pin positions to read. little-endian (less significant value first).
35 * num_gpio: number of pins to read.
36 * tertiary: 1: pins are interpreted as a quad coded tertiary.
37 * 0: pins are interpreted as a set of two bit fields.
Vadim Bendebury9c9c3362014-07-23 09:40:02 -070038 */
Vadim Bendebury37602722014-08-07 12:02:26 -070039int gpio_get_in_tristate_values(gpio_t gpio[], int num_gpio, int tertiary);
Vadim Bendebury9c9c3362014-07-23 09:40:02 -070040
41/*
42 * The following functions are not provided by the common library, but must be
43 * implemented by the appropriate SOC/board instead.
44 */
45int gpio_get_in_value(gpio_t gpio);
46void gpio_set_out_value(gpio_t gpio, int value);
47void gpio_input_pulldown(gpio_t gpio);
48void gpio_input_pullup(gpio_t gpio);
49void gpio_input(gpio_t gpio);
50
51#endif