From: Michael Gernoth Date: Wed, 25 May 2011 09:05:07 +0000 (+0200) Subject: add module to switch kernel serial console to headphone jack X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-kexec/commitdiff_plain/c4dc8ddb1a63cf2e5274d7d03ec6559e2eb28b75?ds=inline add module to switch kernel serial console to headphone jack 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. --- diff --git a/.gitignore b/.gitignore index c6a9045..0f4c01a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Makefile b/Makefile index 544acff..f0d2079 100644 --- 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 index 0000000..edf8d16 --- /dev/null +++ b/headphone_cons.c @@ -0,0 +1,39 @@ +/* + * Provide kernel console on headphone jack + */ + +#include +#include +#include + +/* + * 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 ");