From 981f7356eac92de156d2ef7995ab9390b6ea3ef1 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Fri, 20 Jan 2012 16:43:16 +0100 Subject: [PATCH] update offsets to new european GB kernel, set software booting from USB --- .gitignore | 9 ++++++ Makefile | 3 +- board-mapphone-emu_uart.c | 8 ++--- boot_usb.c | 65 +++++++++++++++++++++++++++++++++++++++ hs_cons.c | 37 ++++++++++++++++++---- omap2_serial.c | 2 +- 6 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 boot_usb.c diff --git a/.gitignore b/.gitignore index fb191ec..5598ab3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ .abort-ev7.o.cmd .board-mapphone-emu_uart.o.cmd +.boot.ko.cmd +.boot.mod.o.cmd +.boot.o.cmd +.boot_usb.o.cmd .cache-v7.o.cmd .copypage-v6.o.cmd .core.o.cmd @@ -28,6 +32,11 @@ Module.symvers abort-ev7.o board-mapphone-emu_uart.o +boot.ko +boot.mod.c +boot.mod.o +boot.o +boot_usb.o cache-v7.o copypage-v6.o core.o diff --git a/Makefile b/Makefile index af055c9..0b62e27 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,11 @@ KERNEL_RESTART_PREPARE := $(shell grep ' T kernel_restart_prepare$$' $(KDIR)/Sys EXTRA_CFLAGS += -DCONFIG_KEXEC -Wall -DSYS_CALL_TABLE=0x$(SYS_CALL_TABLE) -DKERNEL_RESTART_PREPARE=0x$(KERNEL_RESTART_PREPARE) -obj-m += kexec_load.o headphone_cons.o +obj-m += kexec_load.o headphone_cons.o boot.o kexec_load-objs := kexec.o machine_kexec.o mmu.o sys.o core.o relocate_kernel.o \ proc-v7.o tlb-v7.o cache-v7.o abort-ev7.o pabort-v7.o copypage-v6.o driver_sys.o headphone_cons-objs := hs_cons.o omap2_serial.o board-mapphone-emu_uart.o +boot-objs := boot_usb.o all: PATH=$(CROSS_PATH):$(PATH) CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(ARCH) make -C $(KDIR) M=$(PWD) modules diff --git a/board-mapphone-emu_uart.c b/board-mapphone-emu_uart.c index 75752ba..9308f15 100644 --- a/board-mapphone-emu_uart.c +++ b/board-mapphone-emu_uart.c @@ -550,16 +550,16 @@ static int find_ms2_dev(struct device *dev, void *data) } /* - * c01fcb98 T cpcap_regacc_read - * c01fcc04 T cpcap_regacc_write + * c021544c T cpcap_regacc_read + * c02154b8 T cpcap_regacc_write */ static int (*my_cpcap_regacc_read)(struct cpcap_device *, enum cpcap_reg, unsigned short *) = - (int (*)(struct cpcap_device *, enum cpcap_reg, unsigned short *))0xc01fcb98; + (int (*)(struct cpcap_device *, enum cpcap_reg, unsigned short *))0xc021544c; static int (*my_cpcap_regacc_write)(struct cpcap_device *, enum cpcap_reg, unsigned short, unsigned short) = - (int (*)(struct cpcap_device *, enum cpcap_reg, unsigned short, unsigned short))0xc01fcc04; + (int (*)(struct cpcap_device *, enum cpcap_reg, unsigned short, unsigned short))0xc02154b8; void activate_emu_uart(void) 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 "); diff --git a/hs_cons.c b/hs_cons.c index 2aecae9..c5c182f 100644 --- a/hs_cons.c +++ b/hs_cons.c @@ -22,14 +22,20 @@ #include "prm.h" #include "prm-regbits-34xx.h" +#define USB_CONSOLE 1 + +#ifndef USB_CONSOLE static int hs_switch = -1; +#endif +#if 0 /* * int add_preferred_console(char *name, int idx, char *options) - * c0069208 T add_preferred_console + * c006bec0 T add_preferred_console */ -static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc0069208; +static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc006bec0; +#endif void my_omap_serial_init(int wake_gpio_strobe, unsigned int wake_strobe_enable_mask); int my_omap_hs_init(void); @@ -46,21 +52,35 @@ static int find_ms2_dev(struct device *dev, void *data) return 0; } +#define OMAP_CTRL_REGADDR(reg) (OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE) + (reg)) + +u32 omap_ctrl_readl(u16 offset) +{ + return __raw_readl(OMAP_CTRL_REGADDR(offset)); +} + static int __init headphone_cons_init(void) { int bpwake_strobe_gpio; struct device *uart3 = NULL; + printk("CONTROL_STATUS: 0x%08x\n", omap_ctrl_readl(OMAP343X_CONTROL_STATUS)); + //<4>[81323.057830] CONTROL_STATUS: 0x00000205 + // 01000000101 + // DEVICETYPE[10:8]: 010 -> Reserved (High Security) + // SYSBOOT[5:0]: 000101 -> MMC2 USB + /* Remove old uart3 device which was disabled... */ printk(KERN_INFO "Searching for omap-uart.3...\n"); uart3 = device_find_child(&platform_bus, "omap-uart.3", find_ms2_dev); if (uart3 == NULL) - return-ENODEV; + return -ENODEV; printk(KERN_INFO "Deleting old device...\n"); device_del(uart3); +#ifndef USB_CONSOLE /* Get the headset switch gpio number from devtree */ hs_switch = get_gpio_by_name("headset_uart_switch"); if (hs_switch < 0) @@ -70,9 +90,7 @@ static int __init headphone_cons_init(void) if (!gpio_get_value(hs_switch)) return -ENODEV; - - printk(KERN_INFO "Activating emu_uart on mini-usb port\n"); - activate_emu_uart(); +#endif printk(KERN_INFO "Enabling UART3...\n"); bpwake_strobe_gpio = get_gpio_by_name("ipc_bpwake_strobe"); @@ -82,11 +100,18 @@ static int __init headphone_cons_init(void) my_omap_serial_init(bpwake_strobe_gpio, 0x01); my_omap_hs_init(); +#ifdef USB_CONSOLE + printk(KERN_INFO "Activating emu_uart on mini-usb port\n"); + activate_emu_uart(); +#else /* route kernel uart out headset jack */ gpio_set_value(hs_switch, 0); printk(KERN_INFO "headset_uart_switch: %d, value: %d\n", hs_switch, gpio_get_value(hs_switch)); +#endif +#if 0 add_preferred_console("ttyS", 2, "115200"); +#endif return 0; } diff --git a/omap2_serial.c b/omap2_serial.c index 9d20bcc..380e100 100644 --- a/omap2_serial.c +++ b/omap2_serial.c @@ -40,7 +40,7 @@ #define OMAP_CTRL_REGADDR(reg) (OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE) + (reg)) -static int (*my_pwrdm_clkdm_state_switch)(struct clockdomain *) = (int (*)(struct clockdomain *))0xc0041370; +static int (*my_pwrdm_clkdm_state_switch)(struct clockdomain *) = (int (*)(struct clockdomain *))0xc0042458; void omap_ctrl_writew(u16 val, u16 offset) -- 2.39.2