Bob Liu | 7d861d9 | 2013-02-05 19:05:41 +0800 | [diff] [blame] | 1 | /* |
| 2 | * cmd_softswitch.c - set the softswitch for bf60x |
| 3 | * |
| 4 | * Copyright (c) 2012 Analog Devices Inc. |
| 5 | * |
| 6 | * Licensed under the GPL-2 or later. |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <command.h> |
| 11 | #include <asm/blackfin.h> |
| 12 | #include <asm/soft_switch.h> |
| 13 | |
| 14 | int do_softswitch(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 15 | { |
| 16 | int switchaddr, value, pin, port; |
| 17 | |
| 18 | if (argc != 5) |
| 19 | return CMD_RET_USAGE; |
| 20 | |
| 21 | if (strcmp(argv[2], "GPA") == 0) |
| 22 | port = IO_PORT_A; |
| 23 | else if (strcmp(argv[2], "GPB") == 0) |
| 24 | port = IO_PORT_B; |
| 25 | else |
| 26 | return CMD_RET_USAGE; |
| 27 | |
| 28 | switchaddr = simple_strtoul(argv[1], NULL, 16); |
| 29 | pin = simple_strtoul(argv[3], NULL, 16); |
| 30 | value = simple_strtoul(argv[4], NULL, 16); |
| 31 | |
| 32 | config_switch_bit(switchaddr, port, (1 << pin), IO_PORT_OUTPUT, value); |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | U_BOOT_CMD( |
| 38 | softswitch_output, 5, 1, do_softswitch, |
| 39 | "switchaddr GPA/GPB pin_offset value", |
| 40 | "" |
| 41 | ); |