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