Skip to contentSkip to conversation

ARM: stm32: Add additional ID register check for KSZ8851 presence

PATCH In review Marek Vasut 3 participants 4 messages May 3, 2021 – May 28, 2021 Arm STM32

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: stm32: Add additional ID register check for KSZ8851 presence

Currently the code sets eth1addr only if /ethernet1 alias exists in DT, the node pointed to by the alias has "micrel,ks8851-mll" compatible string, and the KSZ8851 CCR register read indicates programmed EEPROM is not connected.

This is not sufficient to detect cases where the DT still contains the KSZ8851 nodes, but the chip itself is not present. Extend the detection to handle these cases.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
 board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
board/dhelectronics/dh_stm32mp1/board.c +10 -1
index 49b12c4c042..ac1af718d4a 100644
@@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define KS_CCR_EEPROM	BIT(9)
 #define KS_BE0		BIT(12)
 #define KS_BE1		BIT(13)
+#define KS_CIDER	0xC0
+#define CIDER_ID	0x8870
 
 int setup_mac_address(void)
 {
@@ -123,11 +125,18 @@ int setup_mac_address(void)
 	 * is present. If EEPROM is present, it must contain valid
 	 * MAC address.
 	 */
-	u32 reg, ccr;
+	u32 reg, cider, ccr;
 	reg = fdt_get_base_address(gd->fdt_blob, off);
 	if (!reg)
 		goto out_set_ethaddr;
 
+	writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
+	cider = readw(reg);
+	if ((cider & 0xfff0) != CIDER_ID) {
+		skip_eth1 = true;
+		goto out_set_ethaddr;
+	}
+
 	writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
 	ccr = readw(reg);
 	if (ccr & KS_CCR_EEPROM) {
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/1 ARM: stm32: Add additional ID register check for KSZ8851 presence

Hi Marek

Quoted 40 lines · Marek Vasut

Currently the code sets eth1addr only if /ethernet1 alias exists in DT, the node pointed to by the alias has "micrel,ks8851-mll" compatible string, and the KSZ8851 CCR register read indicates programmed EEPROM is not connected.

This is not sufficient to detect cases where the DT still contains the KSZ8851 nodes, but the chip itself is not present. Extend the detection to handle these cases.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
 board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
board/dhelectronics/dh_stm32mp1/board.c +3 -1
index 49b12c4c042..ac1af718d4a 100644
@@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
 #define KS_CCR_EEPROM	BIT(9)
 #define KS_BE0		BIT(12)
 #define KS_BE1		BIT(13)
+#define KS_CIDER	0xC0
+#define CIDER_ID	0x8870
 
 int setup_mac_address(void)
 {
@@ -123,11 +125,18 @@ int setup_mac_address(void)
 	 * is present. If EEPROM is present, it must contain valid
 	 * MAC address.
 	 */
-	u32 reg, ccr;
+	u32 reg, cider, ccr;
 	reg = fdt_get_base_address(gd->fdt_blob, off);
 	if (!reg)
 		goto out_set_ethaddr;
 

board/dhelectronics/dh_stm32mp1/board.c int setup_mac_address(void) · line 142

Quoted 10 lines
board/dhelectronics/dh_stm32mp1/board.c +7 -0
+	writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
+	cider = readw(reg);
+	if ((cider & 0xfff0) != CIDER_ID) {
+		skip_eth1 = true;
+		goto out_set_ethaddr;
+	}
+
 	writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
 	ccr = readw(reg);
 	if (ccr & KS_CCR_EEPROM) {

Thanks
Patrice

#2 lore raw

PATCH 1/1 ARM: stm32: Add additional ID register check for KSZ8851 presence

In reply to Marek Vasut

Hi,

Quoted 39 lines · Marek Vasut

Currently the code sets eth1addr only if /ethernet1 alias exists in DT, the node pointed to by the alias has "micrel,ks8851-mll" compatible string, and the KSZ8851 CCR register read indicates programmed EEPROM is not connected.

This is not sufficient to detect cases where the DT still contains the KSZ8851 nodes, but the chip itself is not present. Extend the detection to handle these cases.

Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
  board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
board/dhelectronics/dh_stm32mp1/board.c +3 -1
index 49b12c4c042..ac1af718d4a 100644
@@ -86,6 +86,8 @@ DECLARE_GLOBAL_DATA_PTR;
  #define KS_CCR_EEPROM	BIT(9)
  #define KS_BE0		BIT(12)
  #define KS_BE1		BIT(13)
+#define KS_CIDER	0xC0
+#define CIDER_ID	0x8870
 
  int setup_mac_address(void)
  {
@@ -123,11 +125,18 @@ int setup_mac_address(void)
  	 * is present. If EEPROM is present, it must contain valid
  	 * MAC address.
  	 */
-	u32 reg, ccr;
+	u32 reg, cider, ccr;
  	reg = fdt_get_base_address(gd->fdt_blob, off);
  	if (!reg)
  		goto out_set_ethaddr;
 

board/dhelectronics/dh_stm32mp1/board.c int setup_mac_address(void) · line 142

Quoted 10 lines
board/dhelectronics/dh_stm32mp1/board.c +7 -0
+	writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2);
+	cider = readw(reg);
+	if ((cider & 0xfff0) != CIDER_ID) {
+		skip_eth1 = true;
+		goto out_set_ethaddr;
+	}
+
  	writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2);
  	ccr = readw(reg);
  	if (ccr & KS_CCR_EEPROM) {

Thanks
Patrick

#3 lore raw
In reply to Marek Vasut

Hi,

Quoted 9 lines · Marek Vasut

Currently the code sets eth1addr only if /ethernet1 alias exists in DT, the node pointed to by the alias has "micrel,ks8851-mll" compatible string, and the KSZ8851 CCR register read indicates programmed EEPROM is not connected.

This is not sufficient to detect cases where the DT still contains the KSZ8851 nodes, but the chip itself is not present. Extend the detection to handle these cases.

Quoted 7 lines
Cc Patrice Chotard <[email protected]>
Cc Patrick Delaunay <[email protected]>
---
  board/dhelectronics/dh_stm32mp1/board.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)

Applied to u-boot-stm/master, thanks!

Regards
Patrick