]> git.zerfleddert.de Git - ms2-kexec/blobdiff - hs_cons.c
enable this serial port, this does not work yet...
[ms2-kexec] / hs_cons.c
diff --git a/hs_cons.c b/hs_cons.c
new file mode 100644 (file)
index 0000000..858fbf1
--- /dev/null
+++ b/hs_cons.c
@@ -0,0 +1,83 @@
+/*
+ * Provide kernel console on headphone jack
+ *
+ * Copyright (C) 2011 Michael Gernoth <michael@gernoth.net>
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/gpio_mapping.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/serial_reg.h>
+#include <linux/clk.h>
+
+#include <plat/board.h>
+#include <plat/control.h>
+#include <asm/mach/serial_omap.h>
+
+#include "prm.h"
+#include "prm-regbits-34xx.h"
+
+static int hs_switch = -1;
+
+/*
+ * 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;
+
+void my_omap_serial_init(int wake_gpio_strobe, unsigned int wake_strobe_enable_mask);
+int my_omap_hs_init(void);
+
+#define MAPPHONE_BPWAKE_STROBE_GPIO    157
+
+static int __init headphone_cons_init(void)
+{
+       /* Get the headset switch gpio number from devtree */
+       hs_switch = get_gpio_by_name("headset_uart_switch");
+       if (hs_switch < 0)
+               return -EINVAL;
+
+       printk(KERN_INFO "headset_uart_switch: %d\n", hs_switch);
+
+       printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
+       if (!gpio_get_value(hs_switch))
+               return -ENODEV;
+
+       printk(KERN_INFO "Enabling UART3...\n");
+       my_omap_serial_init(MAPPHONE_BPWAKE_STROBE_GPIO, 0x01);
+       my_omap_hs_init();
+
+       /* route kernel uart out headset jack */
+       gpio_direction_output(hs_switch, 0);
+       printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
+
+       //add_preferred_console("ttyS", 2, "115200");
+       return 0;
+}
+
+#if 0
+static void __exit headphone_cons_exit(void)
+{
+       if (hs_switch < 0)
+               return;
+
+       printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
+       gpio_direction_output(hs_switch, 1);
+       printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
+}
+#endif
+
+
+module_init(headphone_cons_init);
+#if 0
+module_exit(headphone_cons_exit);
+#endif
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");
Impressum, Datenschutz