diff options
Diffstat (limited to 'plat/rockchip/common/params_setup.c')
-rw-r--r-- | plat/rockchip/common/params_setup.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/plat/rockchip/common/params_setup.c b/plat/rockchip/common/params_setup.c index baf25633..8a743bfe 100644 --- a/plat/rockchip/common/params_setup.c +++ b/plat/rockchip/common/params_setup.c @@ -28,6 +28,12 @@ static struct gpio_info *poweroff_gpio; static struct gpio_info suspend_gpio[10]; uint32_t suspend_gpio_cnt; static struct apio_info *suspend_apio; +static uint32_t rk_uart_base = PLAT_RK_UART_BASE; + +uint32_t rockchip_get_uart_base(void) +{ + return rk_uart_base; +} #if COREBOOT static int dt_process_fdt(void *blob) @@ -42,6 +48,63 @@ void *plat_get_fdt(void) return &fdt_buffer[0]; } +static void plat_rockchip_dt_process_fdt_uart(void *fdt) +{ + const char *path_name = "/chosen"; + const char *prop_name = "stdout-path"; + int node_offset; + int stdout_path_len; + const char *stdout_path; + char serial_char; + int serial_no; + uint32_t uart_base; + + node_offset = fdt_path_offset(fdt, path_name); + if (node_offset < 0) + return; + + stdout_path = fdt_getprop(fdt, node_offset, prop_name, + &stdout_path_len); + if (stdout_path == NULL) + return; + + /* + * We expect something like: + * "serial0:..."" + */ + if (strncmp("serial", stdout_path, 6) != 0) + return; + + serial_char = stdout_path[6]; + serial_no = serial_char - '0'; + + switch (serial_no) { + case 0: + uart_base = UART0_BASE; + break; + case 1: + uart_base = UART1_BASE; + break; + case 2: + uart_base = UART2_BASE; + break; +#ifdef UART3_BASE + case 3: + uart_base = UART3_BASE; + break; +#endif +#ifdef UART4_BASE + case 4: + uart_base = UART4_BASE; + break; +#endif + default: + return; + } + + rk_uart_base = uart_base; +} + static int dt_process_fdt(void *blob) { void *fdt = plat_get_fdt(); @@ -51,6 +114,8 @@ static int dt_process_fdt(void *blob) if (ret < 0) return ret; + plat_rockchip_dt_process_fdt_uart(fdt); + return 0; } #endif |