#include "prm.h"
#include "prm-regbits-34xx.h"
+#define USB_CONSOLE 1
+
+#ifndef USB_CONSOLE
static int hs_switch = -1;
+#endif
+#if 0
/*
* int add_preferred_console(char *name, int idx, char *options)
- * c0069208 T add_preferred_console
+ * c006bec0 T add_preferred_console
*/
-static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc0069208;
+static int (*add_preferred_console)(char *, int, char*) = (int (*)(char*, int, char*))0xc006bec0;
+#endif
void my_omap_serial_init(int wake_gpio_strobe, unsigned int wake_strobe_enable_mask);
int my_omap_hs_init(void);
-int my_serial_omap_init(void);
void activate_emu_uart(void);
#define MAPPHONE_BPWAKE_STROBE_GPIO 157
+static int find_ms2_dev(struct device *dev, void *data)
+{
+ if (!strncmp((char*)data, dev_name(dev), strlen((char*)data))) {
+ printk(KERN_INFO "Found it\n");
+ return 1;
+ }
+ return 0;
+}
+
+#define OMAP_CTRL_REGADDR(reg) (OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE) + (reg))
+
+u32 omap_ctrl_readl(u16 offset)
+{
+ return __raw_readl(OMAP_CTRL_REGADDR(offset));
+}
+
static int __init headphone_cons_init(void)
{
+ int bpwake_strobe_gpio;
+ struct device *uart3 = NULL;
+
+ printk("CONTROL_STATUS: 0x%08x\n", omap_ctrl_readl(OMAP343X_CONTROL_STATUS));
+ //<4>[81323.057830] CONTROL_STATUS: 0x00000205
+ // 01000000101
+ // DEVICETYPE[10:8]: 010 -> Reserved (High Security)
+ // SYSBOOT[5:0]: 000101 -> MMC2 USB
+
+ /* Remove old uart3 device which was disabled... */
+ printk(KERN_INFO "Searching for omap-uart.3...\n");
+
+ uart3 = device_find_child(&platform_bus, "omap-uart.3", find_ms2_dev);
+ if (uart3 == NULL)
+ return -ENODEV;
+
+ printk(KERN_INFO "Deleting old device...\n");
+ device_del(uart3);
+
+#ifndef USB_CONSOLE
/* Get the headset switch gpio number from devtree */
hs_switch = get_gpio_by_name("headset_uart_switch");
if (hs_switch < 0)
if (!gpio_get_value(hs_switch))
return -ENODEV;
-
- printk(KERN_INFO "Loading slightly modified omap serial driver...\n");
- my_serial_omap_init();
+#endif
printk(KERN_INFO "Enabling UART3...\n");
- my_omap_serial_init(MAPPHONE_BPWAKE_STROBE_GPIO, 0x01);
+ bpwake_strobe_gpio = get_gpio_by_name("ipc_bpwake_strobe");
+ if (bpwake_strobe_gpio < 0)
+ bpwake_strobe_gpio = MAPPHONE_BPWAKE_STROBE_GPIO;
+ printk("Serial init with strobe pin %d\n", bpwake_strobe_gpio);
+ my_omap_serial_init(bpwake_strobe_gpio, 0x01);
my_omap_hs_init();
+#ifdef USB_CONSOLE
+ printk(KERN_INFO "Activating emu_uart on mini-usb port\n");
+ activate_emu_uart();
+#else
/* route kernel uart out headset jack */
gpio_set_value(hs_switch, 0);
printk(KERN_INFO "headset_uart_switch: %d, value: %d\n", hs_switch, gpio_get_value(hs_switch));
+#endif
- activate_emu_uart();
-
- //add_preferred_console("ttyS", 2, "115200");
+#if 0
+ add_preferred_console("ttyS", 2, "115200");
+#endif
return 0;
}