Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | .. SPDX-License-Identifier: GPL-2.0+: .. index:: single: gpio (command) gpio command ============ Synopsis -------- :: gpio <input|set|clear|toggle> <pin> gpio read <name> <pin> gpio status [-a] [<bank>|<pin>] The gpio command is used to access General Purpose Inputs/Outputs. gpio input ---------- Switch the GPIO *pin* to input mode. gpio set -------- Switch the GPIO *pin* to output mode and set the signal to 1. gpio clear ---------- Switch the GPIO *pin* to output mode and set the signal to 0. gpio toggle ----------- Switch the GPIO *pin* to output mode and reverse the signal state. gpio read --------- Read the signal state of the GPIO *pin* and save it in environment variable *name*. gpio status ----------- Display the status of one or multiple GPIOs. By default only claimed GPIOs are displayed. gpio status command output fields are:: <name>: <function>: <value> [x] <label> *function* can take the following values: output pin configured in gpio output, *value* indicates the pin's level input pin configured in gpio input, *value* indicates the pin's level func pin configured in alternate function, followed by *label* which shows pinmuxing label. unused pin not configured *[x]* or *[ ]* indicate respectively if the gpio is used or not. *label* shows the gpio label. Parameters ---------- -a Display GPIOs irrespective of being claimed. bank Name of a bank of GPIOs to be displayed. pin Name of a single GPIO to be displayed or manipulated. Examples -------- Switch the status of a GPIO:: => gpio set a5 gpio: pin a5 (gpio 133) value is 1 => gpio clear a5 gpio: pin a5 (gpio 133) value is 0 => gpio toggle a5 gpio: pin a5 (gpio 133) value is 1 => gpio read myvar a5 gpio: pin a5 (gpio 133) value is 1 => echo $myvar 1 => gpio toggle a5 gpio: pin a5 (gpio 133) value is 0 => gpio read myvar a5 gpio: pin a5 (gpio 133) value is 0 => echo $myvar 0 Show the GPIO status:: => gpio status Bank GPIOA: GPIOA1: func rgmii-0 GPIOA2: func rgmii-0 GPIOA7: func rgmii-0 GPIOA10: output: 0 [x] hdmi-transmitter@39.reset-gpios GPIOA13: output: 1 [x] red.gpios Bank GPIOB: GPIOB0: func rgmii-0 GPIOB1: func rgmii-0 GPIOB2: func uart4-0 GPIOB7: input: 0 [x] mmc@58005000.cd-gpios GPIOB11: func rgmii-0 Configuration ------------- The *gpio* command is only available if CONFIG_CMD_GPIO=y. The *gpio read* command is only available if CONFIG_CMD_GPIO_READ=y. Return value ------------ If the command succeds the return value $? is set to 0. If an error occurs, the return value $? is set to 1. |