All pastes #2472734 Raw Edit

spl_usb

public unlisted text v1 · immutable
#2472734 ·published 2013-10-30 15:57 UTC
rendered paste body
diff --git a/arch/arm/include/asm/arch-omap3/spl.h b/arch/arm/include/asm/arch-omap3/spl.h
index 84e6d7b..72581aa 100644
--- a/arch/arm/include/asm/arch-omap3/spl.h
+++ b/arch/arm/include/asm/arch-omap3/spl.h
@@ -30,6 +30,7 @@
 #define BOOT_DEVICE_MMC2	5 /*emmc*/
 #define BOOT_DEVICE_MMC1	6
 #define BOOT_DEVICE_XIPWAIT	7
+#define BOOT_DEVICE_USB		11
 #define BOOT_DEVICE_MMC2_2      0xFF
 
 #define MMC_BOOT_DEVICES_START	BOOT_DEVICE_MMC2
diff --git a/common/spl/Makefile b/common/spl/Makefile
index a74563c..c756ee5 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -21,6 +21,7 @@ COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
 COBJS-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
 COBJS-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
 COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
+COBJS-$(CONFIG_SPL_DFU_SUPPORT) += spl_dfu.o
 endif
 
 COBJS	:= $(sort $(COBJS-y))
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 7ce2d5f..a3c3fa8 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -224,6 +224,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 		spl_net_load_image("usb_ether");
 		break;
 #endif
+#ifdef CONFIG_SPL_USBDFU_SUPPORT
+	case BOOT_DEVICE_USB:
+		spl_dfu_load_image();
+		break;
+#endif
 	default:
 		debug("SPL: Un-supported Boot Device\n");
 		hang();
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
new file mode 100644
index 0000000..ed284da
--- /dev/null
+++ b/common/spl/spl_dfu.c
@@ -0,0 +1,53 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2012
+ * Ilya Yanok <ilya.yanok@gmail.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.
+ */
+#include <common.h>
+#include <asm/errno.h>
+#include <spl.h>
+#include <dfu.h>
+#include <g_dnl.h>
+#include <net.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void spl_dfu_load_image()
+{
+	int ret;
+
+	ret = dfu_config_entities(DFU_BOARD_FLASHINFO, DFU_BOARD_INTERFACE,
+				  DFU_BOARD_NUMBER);
+	board_usb_init();
+	g_dnl_register("dfu");
+	while(1) {
+		if (ctrlc())
+			goto exit;
+		ret = usb_gadget_handle_interrupts();
+		if (ret)
+			goto exit;
+	}
+
+exit:
+	g_dnl_unregister();
+	dfu_free_entities();
+}
diff --git a/include/configs/atbnxxx.h b/include/configs/atbnxxx.h
index 74992c8..584fa73 100644
--- a/include/configs/atbnxxx.h
+++ b/include/configs/atbnxxx.h
@@ -307,8 +307,14 @@
 
 #define CONFIG_SYS_CACHELINE_SIZE	64
 
+#define DFU_BOARD_FLASHINFO "SPL part 0 1;u-boot part 0 2;kernel part 0 4;rootfs part 0 5;"
+#define DFU_BOARD_INTERFACE "nand"
+#define DFU_BOARD_NUMBER 0
+
 /* Defines for SPL */
 #define CONFIG_SPL
+#define CONFIG_SPL_DFU_SUPPORT
+#define CONFIG_SPL_USB_SUPPORT
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_NAND_SIMPLE
 #define CONFIG_SPL_NAND_BASE
diff --git a/spl/Makefile b/spl/Makefile
index b5a8de7..dc50864 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -82,7 +82,7 @@ LIBS-$(CONFIG_SPL_NET_SUPPORT) += net/libnet.o
 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/libnet.o
 LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
 LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/libusb_musb-new.o
-LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/libusb_gadget.o
+LIBS-$(CONFIG_SPL_USB_SUPPORT) += drivers/usb/gadget/libusb_gadget.o
 
 ifneq ($(CONFIG_AM33XX)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TI814X),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o