2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation; either version 2 of
5 * the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 static int do_gpio_get_value(struct command
*cmdtp
, int argc
, char *argv
[])
28 return COMMAND_ERROR_USAGE
;
30 gpio
= simple_strtoul(argv
[1], NULL
, 0);
32 value
= gpio_get_value(gpio
);
39 static const __maybe_unused
char cmd_gpio_get_value_help
[] =
40 "Usage: gpio_set_value <gpio>\n";
42 BAREBOX_CMD_START(gpio_get_value
)
43 .cmd
= do_gpio_get_value
,
44 .usage
= "return a gpio's value",
45 BAREBOX_CMD_HELP(cmd_gpio_get_value_help
)
48 static int do_gpio_set_value(struct command
*cmdtp
, int argc
, char *argv
[])
53 return COMMAND_ERROR_USAGE
;
55 gpio
= simple_strtoul(argv
[1], NULL
, 0);
56 value
= simple_strtoul(argv
[2], NULL
, 0);
58 gpio_set_value(gpio
, value
);
63 static const __maybe_unused
char cmd_gpio_set_value_help
[] =
64 "Usage: gpio_set_value <gpio> <value>\n";
66 BAREBOX_CMD_START(gpio_set_value
)
67 .cmd
= do_gpio_set_value
,
68 .usage
= "set a gpio's output value",
69 BAREBOX_CMD_HELP(cmd_gpio_set_value_help
)
72 static int do_gpio_direction_input(struct command
*cmdtp
, int argc
, char *argv
[])
77 return COMMAND_ERROR_USAGE
;
79 gpio
= simple_strtoul(argv
[1], NULL
, 0);
81 ret
= gpio_direction_input(gpio
);
88 static const __maybe_unused
char cmd_do_gpio_direction_input_help
[] =
89 "Usage: gpio_direction_input <gpio>\n";
91 BAREBOX_CMD_START(gpio_direction_input
)
92 .cmd
= do_gpio_direction_input
,
93 .usage
= "set a gpio as output",
94 BAREBOX_CMD_HELP(cmd_do_gpio_direction_input_help
)
97 static int do_gpio_direction_output(struct command
*cmdtp
, int argc
, char *argv
[])
102 return COMMAND_ERROR_USAGE
;
104 gpio
= simple_strtoul(argv
[1], NULL
, 0);
105 value
= simple_strtoul(argv
[2], NULL
, 0);
107 ret
= gpio_direction_output(gpio
, value
);
114 static const __maybe_unused
char cmd_gpio_direction_output_help
[] =
115 "Usage: gpio_direction_output <gpio> <value>\n";
117 BAREBOX_CMD_START(gpio_direction_output
)
118 .cmd
= do_gpio_direction_output
,
119 .usage
= "set a gpio as output",
120 BAREBOX_CMD_HELP(cmd_gpio_direction_output_help
)