EXTRA_CFLAGS += -DCONFIG_KEXEC -Wall -DSYS_CALL_TABLE=0x$(SYS_CALL_TABLE) -DKERNEL_RESTART_PREPARE=0x$(KERNEL_RESTART_PREPARE)
-obj-m += kexec_load.o
+obj-m += kexec_load.o headphone_cons.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
--- /dev/null
+/*
+ * Provide kernel console on headphone jack
+ */
+
+#include <linux/module.h>
+#include <linux/gpio_mapping.h>
+#include <linux/gpio.h>
+
+/*
+ * int add_preferred_console(char *name, int idx, char *options)
+ * c0069208 T add_preferred_console
+ */
+
+static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc0069208;
+
+static int __init headphone_cons_init(void)
+{
+ int hs_switch;
+
+ /* Get the headset switch gpio number from devtree */
+ hs_switch = get_gpio_by_name("headset_uart_switch");
+ if (hs_switch < 0)
+ return -EINVAL;
+
+ /* configure headset switch gpio as output and
+ direction based on devtree setting */
+ gpio_request(hs_switch, "mapphone audio headset uart switch");
+
+ /* route kernel uart out headset jack */
+ gpio_direction_output(hs_switch, 0);
+
+ add_preferred_console("ttyS", 1, "115200");
+ return 0;
+}
+
+module_init(headphone_cons_init);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");