]> git.zerfleddert.de Git - ms2-kexec/blob - hs_cons.c
enable this serial port, this does not work yet...
[ms2-kexec] / hs_cons.c
1 /*
2 * Provide kernel console on headphone jack
3 *
4 * Copyright (C) 2011 Michael Gernoth <michael@gernoth.net>
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11 #include <linux/module.h>
12 #include <linux/gpio_mapping.h>
13 #include <linux/gpio.h>
14 #include <linux/platform_device.h>
15 #include <linux/serial_reg.h>
16 #include <linux/clk.h>
17
18 #include <plat/board.h>
19 #include <plat/control.h>
20 #include <asm/mach/serial_omap.h>
21
22 #include "prm.h"
23 #include "prm-regbits-34xx.h"
24
25 static int hs_switch = -1;
26
27 /*
28 * int add_preferred_console(char *name, int idx, char *options)
29 * c0069208 T add_preferred_console
30 */
31
32 static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc0069208;
33
34 void my_omap_serial_init(int wake_gpio_strobe, unsigned int wake_strobe_enable_mask);
35 int my_omap_hs_init(void);
36
37 #define MAPPHONE_BPWAKE_STROBE_GPIO 157
38
39 static int __init headphone_cons_init(void)
40 {
41 /* Get the headset switch gpio number from devtree */
42 hs_switch = get_gpio_by_name("headset_uart_switch");
43 if (hs_switch < 0)
44 return -EINVAL;
45
46 printk(KERN_INFO "headset_uart_switch: %d\n", hs_switch);
47
48 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
49 if (!gpio_get_value(hs_switch))
50 return -ENODEV;
51
52 printk(KERN_INFO "Enabling UART3...\n");
53 my_omap_serial_init(MAPPHONE_BPWAKE_STROBE_GPIO, 0x01);
54 my_omap_hs_init();
55
56 /* route kernel uart out headset jack */
57 gpio_direction_output(hs_switch, 0);
58 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
59
60 //add_preferred_console("ttyS", 2, "115200");
61 return 0;
62 }
63
64 #if 0
65 static void __exit headphone_cons_exit(void)
66 {
67 if (hs_switch < 0)
68 return;
69
70 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
71 gpio_direction_output(hs_switch, 1);
72 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
73 }
74 #endif
75
76
77 module_init(headphone_cons_init);
78 #if 0
79 module_exit(headphone_cons_exit);
80 #endif
81
82 MODULE_LICENSE("GPL");
83 MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");
Impressum, Datenschutz