Merge "[msm_shared/uart]: Fix UART for msm7x30 targets."
diff --git a/platform/msm7x30/include/platform/iomap.h b/platform/msm7x30/include/platform/iomap.h
index 7a1d396..f012f5b 100644
--- a/platform/msm7x30/include/platform/iomap.h
+++ b/platform/msm7x30/include/platform/iomap.h
@@ -30,12 +30,12 @@
* SUCH DAMAGE.
*/
-#ifndef _PLATFORM_MSM7K_IOMAP_H_
-#define _PLATFORM_MSM7K_IOMAP_H_
+#ifndef _PLATFORM_MSM7X30_IOMAP_H_
+#define _PLATFORM_MSM7X30_IOMAP_H_
-#define MSM_UART1_BASE 0xA9A00000
-#define MSM_UART2_BASE 0xA9B00000
-#define MSM_UART3_BASE 0xA9C00000
+#define MSM_UART1_BASE 0xACA00000
+#define MSM_UART2_BASE 0xACB00000
+#define MSM_UART3_BASE 0xACC00000
#define MSM_VIC_BASE 0xC0080000
#define MSM_TMR_BASE 0xC0100000
diff --git a/platform/msm7x30/platform.c b/platform/msm7x30/platform.c
index 56852a4..5480e24 100644
--- a/platform/msm7x30/platform.c
+++ b/platform/msm7x30/platform.c
@@ -42,16 +42,32 @@
void platform_init_interrupts(void);
void platform_init_timer();
-void uart3_clock_init(void);
+void uart2_clock_init(void);
void uart_init(void);
struct fbcon_config *lcdc_init(void);
+#define ARRAY_SIZE(a) (sizeof(a)/(sizeof((a)[0])))
+
+static unsigned uart2_gpio_table[] = {
+ GPIO_CFG(49, 2, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA),
+ GPIO_CFG(50, 2, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),
+ GPIO_CFG(51, 2, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),
+ GPIO_CFG(52, 2, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA),
+};
+
+void uart2_mux_init(void)
+{
+ platform_gpios_enable(uart2_gpio_table, ARRAY_SIZE(uart2_gpio_table));
+}
+
void platform_early_init(void)
{
- //uart3_clock_init();
- //uart_init();
-
+#if WITH_DEBUG_UART
+ uart2_mux_init();
+ uart2_clock_init();
+ uart_init();
+#endif
platform_init_interrupts();
platform_init_timer();
}
diff --git a/platform/msm_shared/proc_comm.c b/platform/msm_shared/proc_comm.c
index 5056917..48d2040 100644
--- a/platform/msm_shared/proc_comm.c
+++ b/platform/msm_shared/proc_comm.c
@@ -252,6 +252,12 @@
clock_set_rate(UART3_CLK, 19200000 / 4);
}
+void uart2_clock_init(void)
+{
+ clock_enable(UART2_CLK);
+ clock_set_rate(UART2_CLK, 19200000);
+}
+
void mddi_clock_init(unsigned num, unsigned rate)
{
unsigned clock_id;
diff --git a/platform/msm_shared/uart.c b/platform/msm_shared/uart.c
index ae579d4..7f5c7e2 100644
--- a/platform/msm_shared/uart.c
+++ b/platform/msm_shared/uart.c
@@ -119,7 +119,11 @@
static unsigned uart_ready = 0;
+#if PLATFORM_MSM7X30
+static unsigned uart_base = MSM_UART2_BASE;
+#else
static unsigned uart_base = MSM_UART3_BASE;
+#endif
#define uwr(v,a) writel(v, uart_base + (a))
#define urd(a) readl(uart_base + (a))
@@ -132,7 +136,7 @@
uwr(0x10, UART_CR); /* reset receiver */
uwr(0x20, UART_CR); /* reset transmitter */
-#if PLATFORM_QSD8K
+#if PLATFORM_QSD8K || PLATFORM_MSM7X30
/* TCXO */
uwr(0x06, UART_MREG);
uwr(0xF1, UART_NREG);
@@ -172,7 +176,7 @@
uart_ready = 1;
}
-int uart_putc(int port, char c)
+static int _uart_putc(int port, char c)
{
if (!uart_ready)
return -1;
@@ -181,6 +185,15 @@
return 0;
}
+int uart_putc (int port, char c)
+{
+ if(c == '\n')
+ {
+ _uart_putc(0, '\r');
+ }
+ _uart_putc(0, c);
+}
+
int uart_getc(int port, bool wait)
{
if (!uart_ready)