Simon Glass | 8d30fcd | 2012-02-15 15:51:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This is the interface to the sandbox GPIO driver for test code which |
| 3 | * wants to change the GPIO values reported to U-Boot. |
| 4 | * |
| 5 | * Copyright (c) 2011 The Chromium OS Authors. |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #ifndef __ASM_SANDBOX_GPIO_H |
| 26 | #define __ASM_SANDBOX_GPIO_H |
| 27 | |
| 28 | /* |
| 29 | * We use the generic interface, and add a back-channel. |
| 30 | * |
| 31 | * The back-channel functions are declared in this file. They should not be used |
| 32 | * except in test code. |
| 33 | * |
| 34 | * Test code can, for example, call sandbox_gpio_set_value() to set the value of |
| 35 | * a simulated GPIO. From then on, normal code in U-Boot will see this new |
| 36 | * value when it calls gpio_get_value(). |
| 37 | * |
| 38 | * NOTE: DO NOT use the functions in this file except in test code! |
| 39 | */ |
| 40 | #include <asm-generic/gpio.h> |
| 41 | |
| 42 | /** |
| 43 | * Return the simulated value of a GPIO (used only in sandbox test code) |
| 44 | * |
| 45 | * @param gp GPIO number |
| 46 | * @return -1 on error, 0 if GPIO is low, >0 if high |
| 47 | */ |
| 48 | int sandbox_gpio_get_value(unsigned gp); |
| 49 | |
| 50 | /** |
| 51 | * Set the simulated value of a GPIO (used only in sandbox test code) |
| 52 | * |
| 53 | * @param gp GPIO number |
| 54 | * @param value value to set (0 for low, non-zero for high) |
| 55 | * @return -1 on error, 0 if ok |
| 56 | */ |
| 57 | int sandbox_gpio_set_value(unsigned gp, int value); |
| 58 | |
| 59 | /** |
| 60 | * Return the simulated direction of a GPIO (used only in sandbox test code) |
| 61 | * |
| 62 | * @param gp GPIO number |
| 63 | * @return -1 on error, 0 if GPIO is input, >0 if output |
| 64 | */ |
| 65 | int sandbox_gpio_get_direction(unsigned gp); |
| 66 | |
| 67 | /** |
| 68 | * Set the simulated direction of a GPIO (used only in sandbox test code) |
| 69 | * |
| 70 | * @param gp GPIO number |
| 71 | * @param output 0 to set as input, 1 to set as output |
| 72 | * @return -1 on error, 0 if ok |
| 73 | */ |
| 74 | int sandbox_gpio_set_direction(unsigned gp, int output); |
| 75 | |
| 76 | /* Display information about each GPIO */ |
| 77 | void gpio_info(void); |
| 78 | |
| 79 | #define gpio_status() gpio_info() |
| 80 | |
| 81 | #endif |