Jean-Christophe PLAGNIOL-VILLARD | b9c0e4c | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Jean-Christophe PLAGNIOL-VILLARD | b9c0e4c | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | |
| 11 | static int mmc_nspi (const char *); |
| 12 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 13 | int do_dataflash_mmc_mux (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Jean-Christophe PLAGNIOL-VILLARD | b9c0e4c | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 14 | { |
| 15 | switch (argc) { |
| 16 | case 2: /* on / off */ |
| 17 | switch (mmc_nspi (argv[1])) { |
| 18 | case 0: AT91F_SelectSPI (); |
| 19 | break; |
| 20 | case 1: AT91F_SelectMMC (); |
| 21 | break; |
| 22 | } |
| 23 | case 1: /* get status */ |
| 24 | printf ("Mux is configured to be %s\n", |
| 25 | AT91F_GetMuxStatus () ? "MMC" : "SPI"); |
| 26 | return 0; |
| 27 | default: |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 28 | return CMD_RET_USAGE; |
Jean-Christophe PLAGNIOL-VILLARD | b9c0e4c | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 29 | } |
| 30 | return 0; |
| 31 | } |
| 32 | |
| 33 | static int mmc_nspi (const char *s) |
| 34 | { |
| 35 | if (strcmp (s, "mmc") == 0) { |
| 36 | return 1; |
| 37 | } else if (strcmp (s, "spi") == 0) { |
| 38 | return 0; |
| 39 | } |
| 40 | return -1; |
| 41 | } |
| 42 | |
| 43 | U_BOOT_CMD( |
| 44 | dataflash_mmc_mux, 2, 1, do_dataflash_mmc_mux, |
Frans Meulenbroeks | cc9f607 | 2010-07-31 15:01:52 +0200 | [diff] [blame] | 45 | "enable or disable MMC or SPI\n", |
Jean-Christophe PLAGNIOL-VILLARD | b9c0e4c | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 46 | "[mmc, spi]\n" |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 47 | " - enable or disable MMC or SPI" |
Jean-Christophe PLAGNIOL-VILLARD | b9c0e4c | 2009-03-27 23:26:42 +0100 | [diff] [blame] | 48 | ); |