]> git.zerfleddert.de Git - ms2-kexec/blame - headphone_cons.c
unload support
[ms2-kexec] / headphone_cons.c
CommitLineData
c4dc8ddb
MG
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
81799b4e
MG
9static int hs_switch = -1;
10
c4dc8ddb
MG
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{
c4dc8ddb
MG
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
81799b4e
MG
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
c4dc8ddb
MG
30 /* configure headset switch gpio as output and
31 direction based on devtree setting */
81799b4e
MG
32 if (gpio_request(hs_switch, "mapphone audio headset uart switch") < 0)
33 return -ENODEV;
34#endif
c4dc8ddb
MG
35
36 /* route kernel uart out headset jack */
37 gpio_direction_output(hs_switch, 0);
81799b4e 38 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
c4dc8ddb 39
81799b4e 40 add_preferred_console("ttyS", 0, "115200");
c4dc8ddb
MG
41 return 0;
42}
43
81799b4e
MG
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
c4dc8ddb 55module_init(headphone_cons_init);
81799b4e 56module_exit(headphone_cons_exit);
c4dc8ddb
MG
57
58MODULE_LICENSE("GPL");
59MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");
Impressum, Datenschutz