9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] etherbcm: support for newer BCM5717 series cards.
@ 2023-02-22 18:03 james palmer
  2023-02-22 18:54 ` cinap_lenrek
  0 siblings, 1 reply; 6+ messages in thread
From: james palmer @ 2023-02-22 18:03 UTC (permalink / raw)
  To: 9front


talk to the right phy for cards with many ports.
fix pci ids.
---
diff 9f6096b4319bbeb81b74ffd83ffa6edc22b7890e b67c008fa3829c6a1cb1f0c4ee20560d48b7c1a6
--- a/sys/src/9/pc/etherbcm.c
+++ b/sys/src/9/pc/etherbcm.c
@@ -218,7 +218,7 @@
 	BCM5705_2 = 0x1654, 
 	BCM5717 = 0x1655, 
 	BCM5718 = 0x1656, 
-	BCM5720 = 0x1658, 
+	BCM5719 = 0x1657,
 	BCM5721 = 0x1659, 
 	BCM5722 = 0x165a, 
 	BCM5723 = 0x165b, 
@@ -225,6 +225,7 @@
 	BCM5724 = 0x165c, 
 	BCM5705M = 0x165d, 
 	BCM5705M_2 = 0x165e, 
+	BCM5720 = 0x165f,
 	BCM5714 = 0x1668, 
 	BCM5780 = 0x166a, 
 	BCM5780S = 0x166b, 
@@ -289,11 +290,26 @@
 	return x;
 }
 
+static uint
+phyno(Ctlr *ctlr)
+{
+	uint pa;
+	switch(ctlr->pdev->did) {
+	case BCM5717:
+	case BCM5718:
+	case BCM5719:
+	case BCM5720:
+		pa = BUSFNO(ctlr->pdev->tbdf) + 1;
+	}
+
+	return pa;
+}
+
 static int
 miir(Ctlr *ctlr, int ra)
 {
 	while(csr32(ctlr, MIComm) & (1<<29));
-	csr32(ctlr, MIComm) = (ra << 16) | (1 << 21) | (1 << 27) | (1 << 29);
+	csr32(ctlr, MIComm) = (ra << 16) | (phyno(ctlr) << 21) | (1 << 27) | (1 << 29);
 	while(csr32(ctlr, MIComm) & (1<<29));
 	if(csr32(ctlr, MIComm) & (1<<28)) return -1;
 	return csr32(ctlr, MIComm) & 0xFFFF;
@@ -303,7 +319,7 @@
 miiw(Ctlr *ctlr, int ra, int value)
 {
 	while(csr32(ctlr, MIComm) & (1<<29));
-	csr32(ctlr, MIComm) = (value & 0xFFFF) | (ra << 16) | (1 << 21) | (1 << 27) | (1 << 29);
+	csr32(ctlr, MIComm) = (value & 0xFFFF) | (ra << 16) | (phyno(ctlr) << 21) | (1 << 27) | (1 << 29);
 	while(csr32(ctlr, MIComm) & (1<<29));
 	return 0;
 }
@@ -599,8 +615,21 @@
 	pa = PCIWADDR(ctlr->recvprod);
 	csr32(ctlr, ReceiveBDHostAddr + 0) = pa >> 32;
 	csr32(ctlr, ReceiveBDHostAddr + 4) = pa;
-	csr32(ctlr, ReceiveBDFlags) = RecvProdRingLen << 16;
-	csr32(ctlr, ReceiveBDNIC) = 0x6000;
+	switch(ctlr->pdev->did) {
+	case BCM5717:
+	case BCM5718:
+	case BCM5719:
+	case BCM5720:
+		/* 5717 series have a different receive bd nic addr,
+		 * and a max frame length field in bits 2 to 15. */
+		csr32(ctlr, ReceiveBDFlags) = RecvProdRingLen << 16 | 1536 << 2;
+		csr32(ctlr, ReceiveBDNIC) = 0x40000;
+		break;
+	default:
+		csr32(ctlr, ReceiveBDFlags) = RecvProdRingLen << 16;
+		csr32(ctlr, ReceiveBDNIC) = 0x6000;
+	}
+
 	csr32(ctlr, ReceiveBDRepl) = 25;
 	csr32(ctlr, SendBDRingHostIndex) = 0;
 	csr32(ctlr, SendBDRingHostIndex+4) = 0;
@@ -743,7 +772,7 @@
 		case BCM5705_2:
 		case BCM5717:
 		case BCM5718:
-		case BCM5720:
+		case BCM5719:
 		case BCM5721:
 		case BCM5722:
 		case BCM5723:
@@ -750,6 +779,7 @@
 		case BCM5724:
 		case BCM5705M:
 		case BCM5705M_2:
+		case BCM5720:
 		case BCM5714:
 		case BCM5780:
 		case BCM5780S:

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-23  0:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 18:03 [9front] [PATCH] etherbcm: support for newer BCM5717 series cards james palmer
2023-02-22 18:54 ` cinap_lenrek
2023-02-22 19:36   ` [9front] " james palmer
2023-02-22 21:01     ` james palmer
2023-02-23  0:12       ` cinap_lenrek
2023-02-23  0:08     ` [9front] " cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).