Browse Source

board:starfive:visionfive2: add get_chip_type

Read the chip model from the eerpom and setenv "chip_vision"

Signed-off-by: Samin Guo <samin.guo@linux.starfivetech.com>
Samin Guo 1 year ago
parent
commit
48c7e4f1d0
1 changed files with 38 additions and 0 deletions
  1. 38 0
      board/starfive/visionfive2/starfive_visionfive2.c

+ 38 - 0
board/starfive/visionfive2/starfive_visionfive2.c

@@ -25,6 +25,7 @@
 #define PCB_REVISION_SHIFT	4
 #define PCB_REVISION_A		0x0A
 #define PCB_REVISION_B		0x0B
+#define CHIP_REVISION_SHIFT	80
 
 enum {
 	BOOT_FLASH =	0,
@@ -33,6 +34,12 @@ enum {
 	BOOT_UART,
 };
 
+enum chip_type_t {
+	CHIP_A = 0,
+	CHIP_B,
+	CHIP_MAX,
+};
+
 enum board_type_t {
 	BOARD_1000M_1000M = 0,
 	BOARD_1000M_100M,
@@ -132,6 +139,36 @@ static void jh7110_gmac_sel_tx_to_rgmii(int id)
 		break;
 	}
 }
+static int get_chip_type(void)
+{
+	int type;
+	int len = -1;
+	u8 data;
+
+	len = get_data_from_eeprom(CHIP_REVISION_SHIFT, 1, &data);
+	if (len <= 0) {
+		env_set("chip_vision", "UNKOWN");
+		return -EINVAL;
+	}
+
+	switch (data) {
+	case 'a':
+	case 'A':
+		type = CHIP_A;
+		env_set("chip_vision", "A");
+		break;
+	case 'b':
+	case 'B':
+		type = CHIP_B;
+		env_set("chip_vision", "B");
+		break;
+	default:
+		type = CHIP_MAX;
+		env_set("chip_vision", "UNKOWN");
+		break;
+	}
+	return type;
+}
 static int get_board_type(void)
 {
 	u8 pv;
@@ -410,6 +447,7 @@ err:
 	eth_env_set_enetaddr("eth0addr", mac0);
 	eth_env_set_enetaddr("eth1addr", mac1);
 
+	get_chip_type();
 	return 0;
 }
 #endif