X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-kexec/blobdiff_plain/47984ac761a6891af13f184790b927b3cf682b2b..981f7356eac92de156d2ef7995ab9390b6ea3ef1:/boot_usb.c diff --git a/boot_usb.c b/boot_usb.c new file mode 100644 index 0000000..dae9869 --- /dev/null +++ b/boot_usb.c @@ -0,0 +1,65 @@ +/* + * Set software booting from USB + * + * From: + * http://www.droid-developers.org/wiki/How_to_load_mbmloader_from_SD_card + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#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 ");