2 * Copyright (c) 2011 The Chromium OS Authors.
3 * See file CREDITS for list of people who contributed to this
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * Generic GPIO API for U-Boot
25 * GPIOs are numbered from 0 to GPIO_COUNT-1 which value is defined
26 * by the SOC/architecture.
28 * Each GPIO can be an input or output. If an input then its value can
29 * be read as 0 or 1. If an output then its value can be set to 0 or 1.
30 * If you try to write an input then the value is undefined. If you try
31 * to read an output, barring something very unusual, you will get
32 * back the value of the output that you previously set.
34 * In some cases the operation may fail, for example if the GPIO number
35 * is out of range, or the GPIO is not available because its pin is
36 * being used by another function. In that case, functions may return
37 * an error value of -1.
41 * Make a GPIO an input.
43 * @param gp GPIO number
44 * @return 0 if ok, -1 on error
46 int gpio_direction_input(int gp);
49 * Make a GPIO an output, and set its value.
51 * @param gp GPIO number
52 * @param value GPIO value (0 for low or 1 for high)
53 * @return 0 if ok, -1 on error
55 int gpio_direction_output(int gp, int value);
58 * Get a GPIO's value. This will work whether the GPIO is an input
61 * @param gp GPIO number
62 * @return 0 if low, 1 if high, -1 on error
64 int gpio_get_value(int gp);
67 * Set an output GPIO's value. The GPIO must already be an output of
68 * this function may have no effect.
70 * @param gp GPIO number
71 * @param value GPIO value (0 for low or 1 for high)
72 * @return 0 if ok, -1 on error
74 int gpio_set_value(int gp, int value);