Kaynağa Gözat

board:starfive:evb: add get_chip_type

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

1: jh7110B
0: JH7110A
defalut: JH7110A

Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
Samin Guo 1 yıl önce
ebeveyn
işleme
0dbe3fb0be

+ 2 - 0
arch/riscv/include/asm/arch-jh7110/jh7110-regs.h

@@ -15,6 +15,7 @@
 #define AON_SYSCON_BASE	0x17010000
 #define SYS_CRG_BASE		0x13020000
 #define AON_CRG_BASE		0x17000000
+#define AON_IOMUX_BASE		0x17020000
 #define STG_CRG_BASE		0x10230000
 #define CLK_ENABLE_MASK		0x80000000U
 #define SYS_CRG_RESET_ASSERT3_SHIFT	0X304U
@@ -75,6 +76,7 @@
 #define PCIE_USB3_RX_STANDBY_MASK	0x80U
 #define PCIE_USB3_PHY_ENABLE_SHIFT	0x4U
 #define PCIE_USB3_PHY_ENABLE_MASK	0x10U
+#define AON_GPIO_DIN_REG		0x2c
 
 /*timer cfg*/
 #define TIMER_CLK_APB_SHIFT		0x1F0U

+ 27 - 1
board/starfive/evb/starfive_evb.c

@@ -17,6 +17,12 @@
 #include <linux/bitops.h>
 #include <asm/arch/gpio.h>
 
+enum chip_type_t {
+	CHIP_A = 0,
+	CHIP_B,
+	CHIP_MAX,
+};
+
 #define SYS_CLOCK_ENABLE(clk) \
 	setbits_le32(SYS_CRG_BASE + clk, CLK_ENABLE_MASK)
 
@@ -157,6 +163,26 @@ static void jh7110_usb_init(bool usb2_enable)
 
 }
 
+static u32 get_chip_type(void)
+{
+	u32 value;
+
+	value = in_le32(AON_IOMUX_BASE + AON_GPIO_DIN_REG);
+	value = (value & BIT(3)) >> 3;
+	switch (value) {
+	case CHIP_B:
+		env_set("chip_vision", "B");
+		jh7110_gmac_sel_tx_to_rgmii(0);
+		jh7110_gmac_sel_tx_to_rgmii(1);
+		break;
+	case CHIP_A:
+	default:
+		env_set("chip_vision", "A");
+		break;
+	}
+	return value;
+}
+
 static void jh7110_mmc_init(int id)
 {
 	if (id == 0) {
@@ -238,7 +264,7 @@ err:
 #endif
 	eth_env_set_enetaddr("eth0addr", mac0);
 	eth_env_set_enetaddr("eth1addr", mac1);
-
+	get_chip_type();
 	return 0;
 }
 #endif