+/*
+ * Set software booting from USB
+ *
+ * From:
+ * http://www.droid-developers.org/wiki/How_to_load_mbmloader_from_SD_card
+ */
+
+#include <linux/module.h>
+#include <linux/gpio_mapping.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/serial_reg.h>
+#include <linux/clk.h>
+
+#include <plat/board.h>
+#include <plat/control.h>
+#include <asm/mach/serial_omap.h>
+
+#include "prm.h"
+#include "prm-regbits-34xx.h"
+
+#define SCRATCH_MEM 0x48002910
+#define GLOBAL_REG_PRM 0x48307200
+
+static int __init boot_usb_init(void)
+{
+ void *scratch_mem, *global_reg_prm;
+
+ scratch_mem = ioremap(SCRATCH_MEM, 240);
+ global_reg_prm = ioremap(GLOBAL_REG_PRM, 256);
+
+ // Disable IRQ
+ local_irq_disable();
+ local_fiq_disable();
+
+ // Store address of booting configuration structure
+ __raw_writel(SCRATCH_MEM+0xA0, scratch_mem + 0);
+
+ // Header of booting config
+ __raw_writel(0xCF00AA01, scratch_mem + 0xA0);
+ // Size of booting config
+ __raw_writel(0xC, scratch_mem + 0xA4);
+ // First booting device is 0x11 (USB), Flags 0x00
+ __raw_writel(0x00110000, scratch_mem + 0xA8);
+ // Second is 0x11, third is 0x11
+ __raw_writel(0x00110011, scratch_mem + 0xAC);
+ // Fourth is 0x11
+ __raw_writel(0x00000011, scratch_mem + 0xB0);
+
+ // software reset
+ __raw_writel(0x04, global_reg_prm + 0x50);
+ return 0;
+}
+
+static void __exit boot_usb_exit(void)
+{
+ return;
+}
+
+
+module_init(boot_usb_init);
+module_exit(boot_usb_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");