From d32d0b858a791adb1b1b15511eb97441d708f7be Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Thu, 26 May 2011 15:30:04 +0200 Subject: [PATCH 1/1] more stuff --- board-mapphone-emu_uart.c | 50 ++++++++++++++++++++++++++++++++++++--- hs_cons.c | 2 +- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/board-mapphone-emu_uart.c b/board-mapphone-emu_uart.c index ba209c0..82fbd9e 100644 --- a/board-mapphone-emu_uart.c +++ b/board-mapphone-emu_uart.c @@ -45,6 +45,9 @@ #include #include +#include +#include + /* * Register definitions for CPCAP related SPI register */ @@ -144,7 +147,9 @@ struct cpcap_dev { int access_flag; }; +#if 0 static char tx[4]; +#endif static bool emu_uart_is_active = FALSE; /* Although SPI driver is provided through linux system as implemented above, @@ -177,6 +182,7 @@ static bool emu_uart_is_active = FALSE; * we suggest they should use poweric interface. * */ +#if 0 static inline void raw_writel_reg(u32 value, u32 reg) { unsigned int absolute_reg = (u32)OMAP_MCSPI_BASE + reg; @@ -503,6 +509,7 @@ static int read_cpcap_register_raw(u16 addr, u16 *val) return result; } +#endif /* * Check if the writting is allowed. If MiniUSB port has already been @@ -533,12 +540,47 @@ static void write_omap_mux_register(u16 offset, u8 mode, u8 input_en) omap_writew(reg_val, reg); } +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; +} + +/* + * c01fcb98 T cpcap_regacc_read + * c01fcc04 T cpcap_regacc_write + */ + + +static int (*my_cpcap_regacc_read)(struct cpcap_device *, enum cpcap_reg, unsigned short *) = + (int (*)(struct cpcap_device *, enum cpcap_reg, unsigned short *))0xc01fcb98; + +static int (*my_cpcap_regacc_write)(struct cpcap_device *, enum cpcap_reg, unsigned short, unsigned short) = + (int (*)(struct cpcap_device *, enum cpcap_reg, unsigned short, unsigned short))0xc01fcc04; + + void activate_emu_uart(void) { int i; u16 tmp = 0; + struct device *cpcap = NULL; + struct cpcap_device *cpcap_dev; + + printk(KERN_INFO "Searching for cpcap_usb...\n"); + + cpcap = device_find_child(&platform_bus, "cpcap_usb", find_ms2_dev); + if (cpcap == NULL) + return; + + cpcap_dev = cpcap->platform_data; + if (cpcap_dev == NULL) + return; - read_cpcap_register_raw(18, &tmp); + //read_cpcap_register_raw(18, &tmp); + my_cpcap_regacc_read(cpcap_dev, CPCAP_REG_VERSC1, &tmp); printk(KERN_ALERT "Reading CPCAP vendor_version: 0x%04X\n", tmp); /* * Step 1: @@ -552,8 +594,10 @@ void activate_emu_uart(void) * Configure CPCAP to route UART3 to USB port; Switch VBUSIN to supply * UART/USB transeiver and set VBUS standby mode 3 */ - write_cpcap_register_raw(897, 0x0101); - write_cpcap_register_raw(411, 0x014C); + //write_cpcap_register_raw(897, 0x0101); + //write_cpcap_register_raw(411, 0x014C); + my_cpcap_regacc_write(cpcap_dev, CPCAP_REG_USBC2, 0x0101, 0xffff); + my_cpcap_regacc_write(cpcap_dev, CPCAP_REG_VUSBC, 0x014c, 0xffff); /* Step 3: * Configure OMAP SCM to set ULPI port as UART3 function diff --git a/hs_cons.c b/hs_cons.c index 9c1f47d..f64c340 100644 --- a/hs_cons.c +++ b/hs_cons.c @@ -61,7 +61,7 @@ static int __init headphone_cons_init(void) gpio_set_value(hs_switch, 0); printk(KERN_INFO "headset_uart_switch: %d, value: %d\n", hs_switch, gpio_get_value(hs_switch)); - //activate_emu_uart(); + activate_emu_uart(); //add_preferred_console("ttyS", 2, "115200"); return 0; -- 2.39.5