]> git.zerfleddert.de Git - ms2-kexec/blame - hs_cons.c
update offsets to new european GB kernel, set software booting from USB
[ms2-kexec] / hs_cons.c
CommitLineData
c4dc8ddb
MG
1/*
2 * Provide kernel console on headphone jack
8eb83dc7
MG
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.
c4dc8ddb
MG
9 */
10
11#include <linux/module.h>
12#include <linux/gpio_mapping.h>
13#include <linux/gpio.h>
8eb83dc7
MG
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"
c4dc8ddb 24
981f7356
MG
25#define USB_CONSOLE 1
26
27#ifndef USB_CONSOLE
81799b4e 28static int hs_switch = -1;
981f7356 29#endif
81799b4e 30
981f7356 31#if 0
c4dc8ddb
MG
32/*
33 * int add_preferred_console(char *name, int idx, char *options)
981f7356 34 * c006bec0 T add_preferred_console
c4dc8ddb
MG
35 */
36
981f7356
MG
37static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc006bec0;
38#endif
c4dc8ddb 39
8eb83dc7
MG
40void my_omap_serial_init(int wake_gpio_strobe, unsigned int wake_strobe_enable_mask);
41int my_omap_hs_init(void);
a18588b1 42void activate_emu_uart(void);
8eb83dc7
MG
43
44#define MAPPHONE_BPWAKE_STROBE_GPIO 157
45
47984ac7
MG
46static int find_ms2_dev(struct device *dev, void *data)
47{
48 if (!strncmp((char*)data, dev_name(dev), strlen((char*)data))) {
49 printk(KERN_INFO "Found it\n");
50 return 1;
51 }
52 return 0;
53}
54
981f7356
MG
55#define OMAP_CTRL_REGADDR(reg) (OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE) + (reg))
56
57u32 omap_ctrl_readl(u16 offset)
58{
59 return __raw_readl(OMAP_CTRL_REGADDR(offset));
60}
61
c4dc8ddb
MG
62static int __init headphone_cons_init(void)
63{
47984ac7
MG
64 int bpwake_strobe_gpio;
65 struct device *uart3 = NULL;
66
981f7356
MG
67 printk("CONTROL_STATUS: 0x%08x\n", omap_ctrl_readl(OMAP343X_CONTROL_STATUS));
68 //<4>[81323.057830] CONTROL_STATUS: 0x00000205
69 // 01000000101
70 // DEVICETYPE[10:8]: 010 -> Reserved (High Security)
71 // SYSBOOT[5:0]: 000101 -> MMC2 USB
72
47984ac7
MG
73 /* Remove old uart3 device which was disabled... */
74 printk(KERN_INFO "Searching for omap-uart.3...\n");
75
76 uart3 = device_find_child(&platform_bus, "omap-uart.3", find_ms2_dev);
77 if (uart3 == NULL)
981f7356 78 return -ENODEV;
47984ac7
MG
79
80 printk(KERN_INFO "Deleting old device...\n");
81 device_del(uart3);
82
981f7356 83#ifndef USB_CONSOLE
c4dc8ddb
MG
84 /* Get the headset switch gpio number from devtree */
85 hs_switch = get_gpio_by_name("headset_uart_switch");
86 if (hs_switch < 0)
87 return -EINVAL;
88
66526df8 89 printk(KERN_INFO "headset_uart_switch: %d, value: %d\n", hs_switch, gpio_get_value(hs_switch));
81799b4e 90
8eb83dc7 91 if (!gpio_get_value(hs_switch))
81799b4e 92 return -ENODEV;
981f7356 93#endif
e14c6eae 94
8eb83dc7 95 printk(KERN_INFO "Enabling UART3...\n");
47984ac7
MG
96 bpwake_strobe_gpio = get_gpio_by_name("ipc_bpwake_strobe");
97 if (bpwake_strobe_gpio < 0)
98 bpwake_strobe_gpio = MAPPHONE_BPWAKE_STROBE_GPIO;
99 printk("Serial init with strobe pin %d\n", bpwake_strobe_gpio);
100 my_omap_serial_init(bpwake_strobe_gpio, 0x01);
8eb83dc7 101 my_omap_hs_init();
c4dc8ddb 102
981f7356
MG
103#ifdef USB_CONSOLE
104 printk(KERN_INFO "Activating emu_uart on mini-usb port\n");
105 activate_emu_uart();
106#else
c4dc8ddb 107 /* route kernel uart out headset jack */
a18588b1 108 gpio_set_value(hs_switch, 0);
66526df8 109 printk(KERN_INFO "headset_uart_switch: %d, value: %d\n", hs_switch, gpio_get_value(hs_switch));
981f7356 110#endif
c4dc8ddb 111
981f7356 112#if 0
47984ac7 113 add_preferred_console("ttyS", 2, "115200");
981f7356 114#endif
c4dc8ddb
MG
115 return 0;
116}
117
8eb83dc7 118#if 0
81799b4e
MG
119static void __exit headphone_cons_exit(void)
120{
121 if (hs_switch < 0)
122 return;
123
124 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
125 gpio_direction_output(hs_switch, 1);
126 printk(KERN_INFO "value: %d\n", gpio_get_value(hs_switch));
127}
8eb83dc7 128#endif
81799b4e
MG
129
130
c4dc8ddb 131module_init(headphone_cons_init);
8eb83dc7 132#if 0
81799b4e 133module_exit(headphone_cons_exit);
8eb83dc7 134#endif
c4dc8ddb
MG
135
136MODULE_LICENSE("GPL");
137MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");
Impressum, Datenschutz