blob: f6a5668388c548ce1f893ab05190172a092a31b4 [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.
48
49-a
50 Display GPIOs irrespective of being claimed.
51
52bank
53 Name of a bank of GPIOs to be displayed.
54
55pin
56 Name of a single GPIO to be displayed or manipulated.
57
58Examples
59--------
60
61Switch 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
80Configuration
81-------------
82
83The *gpio* command is only available if CONFIG_CMD_GPIO=y.
84The *gpio read* command is only available if CONFIG_CMD_GPIO_READ=y.
85
86Return value
87------------
88
89If the command succeds the return value $? is set to 0. If an error occurs, the
90return value $? is set to 1.