blob: 9f271b6f611cbd7b18de5fc1e58d077a99fd91b8 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jean-Christophe PLAGNIOL-VILLARDebe54bf2009-03-27 23:26:42 +01002/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Jean-Christophe PLAGNIOL-VILLARDebe54bf2009-03-27 23:26:42 +01005 */
6
7#include <common.h>
8#include <command.h>
9
10static int mmc_nspi (const char *);
11
Wolfgang Denk6262d0212010-06-28 22:00:46 +020012int do_dataflash_mmc_mux (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Jean-Christophe PLAGNIOL-VILLARDebe54bf2009-03-27 23:26:42 +010013{
14 switch (argc) {
15 case 2: /* on / off */
16 switch (mmc_nspi (argv[1])) {
17 case 0: AT91F_SelectSPI ();
18 break;
19 case 1: AT91F_SelectMMC ();
20 break;
21 }
22 case 1: /* get status */
23 printf ("Mux is configured to be %s\n",
24 AT91F_GetMuxStatus () ? "MMC" : "SPI");
25 return 0;
26 default:
Simon Glassa06dfc72011-12-10 08:44:01 +000027 return CMD_RET_USAGE;
Jean-Christophe PLAGNIOL-VILLARDebe54bf2009-03-27 23:26:42 +010028 }
29 return 0;
30}
31
32static int mmc_nspi (const char *s)
33{
34 if (strcmp (s, "mmc") == 0) {
35 return 1;
36 } else if (strcmp (s, "spi") == 0) {
37 return 0;
38 }
39 return -1;
40}
41
42U_BOOT_CMD(
43 dataflash_mmc_mux, 2, 1, do_dataflash_mmc_mux,
Frans Meulenbroeks0dddc002010-07-31 15:01:52 +020044 "enable or disable MMC or SPI\n",
Jean-Christophe PLAGNIOL-VILLARDebe54bf2009-03-27 23:26:42 +010045 "[mmc, spi]\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +020046 " - enable or disable MMC or SPI"
Jean-Christophe PLAGNIOL-VILLARDebe54bf2009-03-27 23:26:42 +010047);