diff --git a/board/nm/hw25/board.c b/board/nm/hw25/board.c index 67415a418e..389e3efc0c 100644 --- a/board/nm/hw25/board.c +++ b/board/nm/hw25/board.c @@ -118,6 +118,8 @@ static int hw_rev = -1; static int hw_patch = -1; static int hw_type = -1; static char hw_variant_name[64]; +static bool hw_has_tty = false; +static int hw_num_ios = -1; #else static int hw_type = -1; static uint32_t sys_start_event = 0x0; @@ -810,6 +812,43 @@ static void get_hw_version(void) #endif } +static void get_dio(void) +{ + /* + * Check digital I/O variant + * - 2xin, 1xout -> port0=in,port1=in,port2=out + * - 4xin, 2xout -> port0=in,port1=in,port2=in,port3=in,port4=out,port5=out + */ + char dio_conf[128]; + + dio_conf[0] = 0; + bd_get_pd_dio(dio_conf, sizeof(dio_conf)); + + if (strstr(dio_conf, "port2=in,port3=in,port4=out,port5=out") != 0) { + hw_num_ios = 6; + } + else if (strstr(dio_conf, "port0=in,port1=in,port2=out") != 0) { + hw_num_ios = 3; + } + else { + hw_num_ios = 0; + } +} + +static void get_serial(void) +{ + /* Check if the variant implements ttyS5 */ + char serial_conf[128]; + + serial_conf[0] = 0; + bd_get_pd_serial(serial_conf, sizeof(serial_conf)); + + // AddItemString('pd_serial', 'port0=ttyS0,port1=ttyS5') + if (strstr(serial_conf, "ttyS5") != 0) { + hw_has_tty = true; + } +} + static void get_pmic_version(void) { uint8_t val = 0x00; @@ -974,6 +1013,8 @@ int board_late_init(void) get_variant_name(); get_hw_version(); + get_dio(); + get_serial(); get_pmic_version(); set_root_partition(); @@ -1143,7 +1184,6 @@ int board_fit_config_name_match(const char *name) #if defined(CONFIG_OF_BOARD_SETUP) && !defined(CONFIG_SPL_BUILD) -#if 0 static void ft_enable_node(void* blob, const char* name) { int node_ofs = -1; @@ -1154,64 +1194,6 @@ static void ft_enable_node(void* blob, const char* name) } } -/* - * Modify the name of a gpio in a gpio-line-names string list. - */ -static void ft_set_gpio_name(void *blob, const char* gpio, int pin, const char* name) -{ - int node_ofs = fdt_path_offset(blob, gpio); - int gpios = -1; - const char* text; - int pos = 0; - int i; - char buffer[512]; - - if (node_ofs == -1) { - printf("Can't find node %s\n", gpio); - goto end; - } - - /* get number of IOs in node */ - gpios = fdt_getprop_u32_default_node(blob, node_ofs, 0, "ngpios", -1); - if (gpios == -1 || gpios > 64) { - printf("Illegal number of gpios %d\n", gpios); - goto end; - } - - /* get string array with names */ - const struct fdt_property* prop = fdt_get_property(blob, node_ofs, "gpio-line-names", NULL); - if (prop == NULL) { - goto end; - } - - /* modify given name */ - for (i=0; i