]> git.zerfleddert.de Git - ms2-kexec/commitdiff
add module to switch kernel serial console to headphone jack
authorMichael Gernoth <michael@gernoth.net>
Wed, 25 May 2011 09:05:07 +0000 (11:05 +0200)
committerMichael Gernoth <michael@gernoth.net>
Wed, 25 May 2011 09:05:07 +0000 (11:05 +0200)
this should provide the kernel messages from the running motorola
kernel on the headset_switch pin of the headphone jack.
Currently untested, as I have no such cable yet. It's also
probably not connected to the currently hardcoded ttyS1.

.gitignore
Makefile
headphone_cons.c [new file with mode: 0644]

index c6a9045901bcce4950df7d2c0a3eda77154e88e7..0f4c01a35e809f8c7b54de1548ecd2e5281683ca 100644 (file)
@@ -4,6 +4,9 @@
 .core.o.cmd
 .driver_sys.o.cmd
 .entry-common.o.cmd
+.headphone_cons.ko.cmd
+.headphone_cons.mod.o.cmd
+.headphone_cons.o.cmd
 .idmap.o.cmd
 .kexec.o.cmd
 .kexec_load.ko.cmd
@@ -24,6 +27,10 @@ copypage-v6.o
 core.o
 driver_sys.o
 entry-common.o
+headphone_cons.ko
+headphone_cons.mod.c
+headphone_cons.mod.o
+headphone_cons.o
 idmap.o
 kexec.o
 kexec_load.ko
index 544acfffa0f9c5cd4da11ad431d6eae1a85893f7..f0d2079e1404e5610eb7bc10e2c5a0257aaa2cdb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ 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
+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
 
diff --git a/headphone_cons.c b/headphone_cons.c
new file mode 100644 (file)
index 0000000..edf8d16
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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>");
Impressum, Datenschutz