summaryrefslogtreecommitdiffstats
path: root/target/u-boot/2009.01-rc1/u-boot-2009.01-rc1-011-spimux.patch
blob: 8ab469fd8d7d58c9011f417ac8274cdfb89ff881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
diff -urN u-boot-2009.01-0rig//common/cmd_mux.c u-boot-2009.01/common/cmd_mux.c
--- u-boot-2009.01-0rig//common/cmd_mux.c	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-2009.01/common/cmd_mux.c	2009-01-04 00:17:19.000000000 +0100
@@ -0,0 +1,78 @@
+/*
+ * (C) Copyright 2008
+ * Ulf Samuelsson <ulf.samuelsson@atmel.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#if (defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK) || defined(CONFIG_AT91RM9200DF))
+
+#include <asm/arch/AT91RM9200.h>
+#include <dataflash.h>
+#include <at45.h>
+
+
+static int mmc_nspi (const char *s)
+{
+	if (strcmp(s, "mmc") == 0) {
+		return (1);
+	} else if (strcmp(s, "spi") == 0) {
+		return (0);
+	}
+	return (-1);
+}
+
+int do_mux ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	switch (argc) {
+	case 2:			/* on / off	*/
+		switch (mmc_nspi(argv[1])) {
+#if 0	/* prevented by varargs handling; FALLTROUGH is harmless, too */
+		default: printf ("Usage:\n%s\n", cmdtp->usage);
+			return;
+#endif
+		case 0:	AT91F_SelectSPI ();
+			break;
+		case 1:	AT91F_SelectMMC ();
+			break;
+		}
+		/* FALL TROUGH */
+	case 1:			/* get status */
+		printf ("Mux is configured to be %s\n",
+			AT91F_GetMuxStatus() ? "MMC" : "SPI");
+		return 0;
+	default:
+		printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+	return 0;
+}
+
+
+U_BOOT_CMD(
+	mux,   2,   1,     do_mux,
+	"mux\t- enable or disable MMC or SPI\n",
+	"[mmc, spi]\n"
+	"    - enable or disable MMC or SPI\n"
+);
+
+#endif	/* CONFIG_CMD_MUX */
+
diff -urN u-boot-2009.01-0rig//common/Makefile u-boot-2009.01/common/Makefile
--- u-boot-2009.01-0rig//common/Makefile	2009-01-04 00:10:28.000000000 +0100
+++ u-boot-2009.01/common/Makefile	2009-01-04 00:20:39.000000000 +0100
@@ -112,6 +112,7 @@
 COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o
 COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
 COBJS-$(CONFIG_MP) += cmd_mp.o
+COBJS-$(CONFIG_CMD_AT91_SPIMUX) += cmd_mux.o
 COBJS-y += cmd_nand.o
 COBJS-$(CONFIG_CMD_NET) += cmd_net.o
 COBJS-$(CONFIG_CMD_ONENAND) += cmd_onenand.o