blob: ee902138f166da6065f847751cb7b7d09f4b328a [file] [log] [blame]
Heinrich Schuchardt914d4f82022-08-02 14:20:32 +02001.. SPDX-License-Identifier: GPL-2.0+:
2
3gpio command
4============
5
6Synopsis
7--------
8
9::
10
11 gpio <input|set|clear|toggle> <pin>
12 gpio read <name> <pin>
13 gpio status [-a] [<bank>|<pin>]
14
15The gpio command is used to access General Purpose Inputs/Outputs.
16
17gpio input
18----------
19
20Switch the GPIO *pin* to input mode.
21
22gpio set
23--------
24
25Switch the GPIO *pin* to output mode and set the signal to 1.
26
27gpio clear
28----------
29
30Switch the GPIO *pin* to output mode and set the signal to 0.
31
32gpio toggle
33-----------
34
35Switch the GPIO *pin* to output mode and reverse the signal state.
36
37gpio read
38---------
39
40Read the signal state of the GPIO *pin* and save it in environment variable
41*name*.
42
43gpio status
44-----------
45
46Display the status of one or multiple GPIOs. By default only claimed GPIOs
47are displayed.
Patrice Chotard7bbea7c2022-08-30 16:56:28 +020048gpio status command output fields are::
49
50 <name>: <function>: <value> [x] <label>
51
52*function* can take the following values:
53
54output
55 pin configured in gpio output, *value* indicates the pin's level
56
57input
58 pin configured in gpio input, *value* indicates the pin's level
59
60func
61 pin configured in alternate function, followed by *label*
62 which shows pinmuxing label.
63
64unused
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
71Parameters
72----------
Heinrich Schuchardt914d4f82022-08-02 14:20:32 +020073
74-a
75 Display GPIOs irrespective of being claimed.
76
77bank
78 Name of a bank of GPIOs to be displayed.
79
80pin
81 Name of a single GPIO to be displayed or manipulated.
82
83Examples
84--------
85
86Switch 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 Chotard7bbea7c2022-08-30 16:56:28 +0200105Show 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 Schuchardt914d4f82022-08-02 14:20:32 +0200122Configuration
123-------------
124
125The *gpio* command is only available if CONFIG_CMD_GPIO=y.
126The *gpio read* command is only available if CONFIG_CMD_GPIO_READ=y.
127
128Return value
129------------
130
131If the command succeds the return value $? is set to 0. If an error occurs, the
132return value $? is set to 1.