]>
Commit | Line | Data |
---|---|---|
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 | ||
9 | static 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 | ||
16 | static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc0069208; | |
17 | ||
18 | static 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 | ||
44 | static 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 | ||
55 | module_init(headphone_cons_init); | |
56 | module_exit(headphone_cons_exit); | |
57 | ||
58 | MODULE_LICENSE("GPL"); | |
59 | MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>"); |