imx: ventana: add support for GW5901/GW5902
[pandora-u-boot.git] / board / gateworks / gw_ventana / eeprom.c
index 1382e5d..ee22732 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2014 Gateworks Corporation
  * Author: Tim Harvey <tharvey@gateworks.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
  */
 
 #include <common.h>
@@ -64,6 +63,7 @@ read_eeprom(int bus, struct ventana_board_info *info)
        if (strncasecmp((const char *)info->model, "GW5400-A", 8) == 0)
                baseboard = '0';
 
+       type = GW_UNKNOWN;
        switch (baseboard) {
        case '0': /* original GW5400-A prototype */
                type = GW54proto;
@@ -91,10 +91,30 @@ read_eeprom(int bus, struct ventana_board_info *info)
                        type = GW553x;
                        break;
                }
-               /* fall through */
-       default:
-               printf("EEPROM: Unknown model in EEPROM: %s\n", info->model);
-               type = GW_UNKNOWN;
+               break;
+       case '6':
+               if (info->model[4] == '0')
+                       type = GW560x;
+               break;
+       case '9':
+               if (info->model[4] == '0' && info->model[5] == '1')
+                       type = GW5901;
+               else if (info->model[4] == '0' && info->model[5] == '2')
+                       type = GW5902;
+               else if (info->model[4] == '0' && info->model[5] == '3')
+                       type = GW5903;
+               else if (info->model[4] == '0' && info->model[5] == '4')
+                       type = GW5904;
+               else if (info->model[4] == '0' && info->model[5] == '5')
+                       type = GW5905;
+               else if (info->model[4] == '0' && info->model[5] == '6')
+                       type = GW5906;
+               else if (info->model[4] == '0' && info->model[5] == '7')
+                       type = GW5907;
+               else if (info->model[4] == '0' && info->model[5] == '8')
+                       type = GW5908;
+               else if (info->model[4] == '0' && info->model[5] == '9')
+                       type = GW5909;
                break;
        }
        return type;
@@ -112,7 +132,7 @@ struct ventana_eeprom_config econfig[] = {
        { /* Sentinel */ }
 };
 
-#ifdef CONFIG_CMD_EECONFIG
+#if defined(CONFIG_CMD_EECONFIG) && !defined(CONFIG_SPL_BUILD)
 static struct ventana_eeprom_config *get_config(const char *name)
 {
        struct ventana_eeprom_config *cfg = econfig;
@@ -128,7 +148,7 @@ static struct ventana_eeprom_config *get_config(const char *name)
 static u8 econfig_bytes[sizeof(ventana_info.config)];
 static int econfig_init = -1;
 
-int do_econfig(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_econfig(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        struct ventana_eeprom_config *cfg;
        struct ventana_board_info *info = &ventana_info;