]> git.zerfleddert.de Git - ms2-kexec/blame_incremental - headphone_cons.c
unload support
[ms2-kexec] / headphone_cons.c
... / ...
CommitLineData
1/*
2 * Provide kernel console on headphone jack
3 */
4
5#include <linux/module.h>
6#include <linux/gpio_mapping.h>
7#include <linux/gpio.h>
8
9static int hs_switch = -1;
10
11/*
12 * int add_preferred_console(char *name, int idx, char *options)
13 * c0069208 T add_preferred_console
14 */
15
16static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc0069208;
17
18static int __init headphone_cons_init(void)
19{
20 /* Get the headset switch gpio number from devtree */
21 hs_switch = get_gpio_by_name("headset_uart_switch");
22 if (hs_switch < 0)
23 return -EINVAL;
24
25 printk(KERN_INFO "headset_uart_switch: %d\n", hs_switch);
26
27 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
28
29#if 0
30 /* configure headset switch gpio as output and
31 direction based on devtree setting */
32 if (gpio_request(hs_switch, "mapphone audio headset uart switch") < 0)
33 return -ENODEV;
34#endif
35
36 /* route kernel uart out headset jack */
37 gpio_direction_output(hs_switch, 0);
38 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
39
40 add_preferred_console("ttyS", 0, "115200");
41 return 0;
42}
43
44static void __exit headphone_cons_exit(void)
45{
46 if (hs_switch < 0)
47 return;
48
49 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
50 gpio_direction_output(hs_switch, 1);
51 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
52}
53
54
55module_init(headphone_cons_init);
56module_exit(headphone_cons_exit);
57
58MODULE_LICENSE("GPL");
59MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");
Impressum, Datenschutz