]> git.ipfire.org Git - thirdparty/u-boot.git/blame - cmd/dataflash_mmc_mux.c
Merge tag 'video-for-2019.07-rc1' of git://git.denx.de/u-boot-video
[thirdparty/u-boot.git] / cmd / dataflash_mmc_mux.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
b9c0e4c2
JCPV
2/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
b9c0e4c2
JCPV
5 */
6
7#include <common.h>
8#include <command.h>
9
10static int mmc_nspi (const char *);
11
54841ab5 12int do_dataflash_mmc_mux (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
b9c0e4c2
JCPV
13{
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:
4c12eeb8 27 return CMD_RET_USAGE;
b9c0e4c2
JCPV
28 }
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,
cc9f607b 44 "enable or disable MMC or SPI\n",
b9c0e4c2 45 "[mmc, spi]\n"
a89c33db 46 " - enable or disable MMC or SPI"
b9c0e4c2 47);