blob: 73876e9464a341c14bc70fd153f37dc8717f5209 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jean-Christophe PLAGNIOL-VILLARDb9c0e4c2009-03-27 23:26:42 +01002/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Jean-Christophe PLAGNIOL-VILLARDb9c0e4c2009-03-27 23:26:42 +01005 */
6
7#include <common.h>
8#include <command.h>
9
10static int mmc_nspi (const char *);
11
Simon Glass09140112020-05-10 11:40:03 -060012int do_dataflash_mmc_mux(struct cmd_tbl *cmdtp, int flag, int argc,
13 char *const argv[])
Jean-Christophe PLAGNIOL-VILLARDb9c0e4c2009-03-27 23:26:42 +010014{
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 Glass4c12eeb2011-12-10 08:44:01 +000028 return CMD_RET_USAGE;
Jean-Christophe PLAGNIOL-VILLARDb9c0e4c2009-03-27 23:26:42 +010029 }
30 return 0;
31}
32
33static 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
43U_BOOT_CMD(
44 dataflash_mmc_mux, 2, 1, do_dataflash_mmc_mux,
Frans Meulenbroekscc9f6072010-07-31 15:01:52 +020045 "enable or disable MMC or SPI\n",
Jean-Christophe PLAGNIOL-VILLARDb9c0e4c2009-03-27 23:26:42 +010046 "[mmc, spi]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020047 " - enable or disable MMC or SPI"
Jean-Christophe PLAGNIOL-VILLARDb9c0e4c2009-03-27 23:26:42 +010048);