Heinrich Schuchardt | 914d4f8 | 2022-08-02 14:20:32 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
| 3 | gpio command |
| 4 | ============ |
| 5 | |
| 6 | Synopsis |
| 7 | -------- |
| 8 | |
| 9 | :: |
| 10 | |
| 11 | gpio <input|set|clear|toggle> <pin> |
| 12 | gpio read <name> <pin> |
| 13 | gpio status [-a] [<bank>|<pin>] |
| 14 | |
| 15 | The gpio command is used to access General Purpose Inputs/Outputs. |
| 16 | |
| 17 | gpio input |
| 18 | ---------- |
| 19 | |
| 20 | Switch the GPIO *pin* to input mode. |
| 21 | |
| 22 | gpio set |
| 23 | -------- |
| 24 | |
| 25 | Switch the GPIO *pin* to output mode and set the signal to 1. |
| 26 | |
| 27 | gpio clear |
| 28 | ---------- |
| 29 | |
| 30 | Switch the GPIO *pin* to output mode and set the signal to 0. |
| 31 | |
| 32 | gpio toggle |
| 33 | ----------- |
| 34 | |
| 35 | Switch the GPIO *pin* to output mode and reverse the signal state. |
| 36 | |
| 37 | gpio read |
| 38 | --------- |
| 39 | |
| 40 | Read the signal state of the GPIO *pin* and save it in environment variable |
| 41 | *name*. |
| 42 | |
| 43 | gpio status |
| 44 | ----------- |
| 45 | |
| 46 | Display the status of one or multiple GPIOs. By default only claimed GPIOs |
| 47 | are displayed. |
| 48 | |
| 49 | -a |
| 50 | Display GPIOs irrespective of being claimed. |
| 51 | |
| 52 | bank |
| 53 | Name of a bank of GPIOs to be displayed. |
| 54 | |
| 55 | pin |
| 56 | Name of a single GPIO to be displayed or manipulated. |
| 57 | |
| 58 | Examples |
| 59 | -------- |
| 60 | |
| 61 | Switch the status of a GPIO:: |
| 62 | |
| 63 | => gpio set a5 |
| 64 | gpio: pin a5 (gpio 133) value is 1 |
| 65 | => gpio clear a5 |
| 66 | gpio: pin a5 (gpio 133) value is 0 |
| 67 | => gpio toggle a5 |
| 68 | gpio: pin a5 (gpio 133) value is 1 |
| 69 | => gpio read myvar a5 |
| 70 | gpio: pin a5 (gpio 133) value is 1 |
| 71 | => echo $myvar |
| 72 | 1 |
| 73 | => gpio toggle a5 |
| 74 | gpio: pin a5 (gpio 133) value is 0 |
| 75 | => gpio read myvar a5 |
| 76 | gpio: pin a5 (gpio 133) value is 0 |
| 77 | => echo $myvar |
| 78 | 0 |
| 79 | |
| 80 | Configuration |
| 81 | ------------- |
| 82 | |
| 83 | The *gpio* command is only available if CONFIG_CMD_GPIO=y. |
| 84 | The *gpio read* command is only available if CONFIG_CMD_GPIO_READ=y. |
| 85 | |
| 86 | Return value |
| 87 | ------------ |
| 88 | |
| 89 | If the command succeds the return value $? is set to 0. If an error occurs, the |
| 90 | return value $? is set to 1. |