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. |
Patrice Chotard | 7bbea7c | 2022-08-30 16:56:28 +0200 | [diff] [blame] | 48 | gpio status command output fields are:: |
| 49 | |
| 50 | <name>: <function>: <value> [x] <label> |
| 51 | |
| 52 | *function* can take the following values: |
| 53 | |
| 54 | output |
| 55 | pin configured in gpio output, *value* indicates the pin's level |
| 56 | |
| 57 | input |
| 58 | pin configured in gpio input, *value* indicates the pin's level |
| 59 | |
| 60 | func |
| 61 | pin configured in alternate function, followed by *label* |
| 62 | which shows pinmuxing label. |
| 63 | |
| 64 | unused |
| 65 | pin not configured |
| 66 | |
| 67 | *[x]* or *[ ]* indicate respectively if the gpio is used or not. |
| 68 | |
| 69 | *label* shows the gpio label. |
| 70 | |
| 71 | Parameters |
| 72 | ---------- |
Heinrich Schuchardt | 914d4f8 | 2022-08-02 14:20:32 +0200 | [diff] [blame] | 73 | |
| 74 | -a |
| 75 | Display GPIOs irrespective of being claimed. |
| 76 | |
| 77 | bank |
| 78 | Name of a bank of GPIOs to be displayed. |
| 79 | |
| 80 | pin |
| 81 | Name of a single GPIO to be displayed or manipulated. |
| 82 | |
| 83 | Examples |
| 84 | -------- |
| 85 | |
| 86 | Switch the status of a GPIO:: |
| 87 | |
| 88 | => gpio set a5 |
| 89 | gpio: pin a5 (gpio 133) value is 1 |
| 90 | => gpio clear a5 |
| 91 | gpio: pin a5 (gpio 133) value is 0 |
| 92 | => gpio toggle a5 |
| 93 | gpio: pin a5 (gpio 133) value is 1 |
| 94 | => gpio read myvar a5 |
| 95 | gpio: pin a5 (gpio 133) value is 1 |
| 96 | => echo $myvar |
| 97 | 1 |
| 98 | => gpio toggle a5 |
| 99 | gpio: pin a5 (gpio 133) value is 0 |
| 100 | => gpio read myvar a5 |
| 101 | gpio: pin a5 (gpio 133) value is 0 |
| 102 | => echo $myvar |
| 103 | 0 |
| 104 | |
Patrice Chotard | 7bbea7c | 2022-08-30 16:56:28 +0200 | [diff] [blame] | 105 | Show the GPIO status:: |
| 106 | |
| 107 | => gpio status |
| 108 | Bank GPIOA: |
| 109 | GPIOA1: func rgmii-0 |
| 110 | GPIOA2: func rgmii-0 |
| 111 | GPIOA7: func rgmii-0 |
| 112 | GPIOA10: output: 0 [x] hdmi-transmitter@39.reset-gpios |
| 113 | GPIOA13: output: 1 [x] red.gpios |
| 114 | |
| 115 | Bank GPIOB: |
| 116 | GPIOB0: func rgmii-0 |
| 117 | GPIOB1: func rgmii-0 |
| 118 | GPIOB2: func uart4-0 |
| 119 | GPIOB7: input: 0 [x] mmc@58005000.cd-gpios |
| 120 | GPIOB11: func rgmii-0 |
| 121 | |
Heinrich Schuchardt | 914d4f8 | 2022-08-02 14:20:32 +0200 | [diff] [blame] | 122 | Configuration |
| 123 | ------------- |
| 124 | |
| 125 | The *gpio* command is only available if CONFIG_CMD_GPIO=y. |
| 126 | The *gpio read* command is only available if CONFIG_CMD_GPIO_READ=y. |
| 127 | |
| 128 | Return value |
| 129 | ------------ |
| 130 | |
| 131 | If the command succeds the return value $? is set to 0. If an error occurs, the |
| 132 | return value $? is set to 1. |