diff mbox series

net: dsa: rtl8366rb: Support port 4 (WAN)

Message ID 20180808123855.18729-1-linus.walleij@linaro.org
State New
Headers show
Series net: dsa: rtl8366rb: Support port 4 (WAN) | expand

Commit Message

Linus Walleij Aug. 8, 2018, 12:38 p.m. UTC
The totally undocumented IO mode needs to be set to enumerator
0 to enable port 4 also known as WAN in most configurations,
for ordinary traffic. The 3 bits in the register come up as
010 after reset, but need to be set to 000.

The Realtek source code contains a name for these bits, but
no explanation of what the 8 different IO modes may be.

Set it to zero for the time being and drop a comment so
people know what is going on if they run into trouble. This
"mode zero" works fine with the D-Link DIR-685 with
RTL8366RB.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/net/dsa/rtl8366rb.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

-- 
2.17.1

Comments

Andrew Lunn Aug. 8, 2018, 12:57 p.m. UTC | #1
On Wed, Aug 08, 2018 at 02:38:55PM +0200, Linus Walleij wrote:
> The totally undocumented IO mode needs to be set to enumerator

> 0 to enable port 4 also known as WAN in most configurations,

> for ordinary traffic. The 3 bits in the register come up as

> 010 after reset, but need to be set to 000.

> 

> The Realtek source code contains a name for these bits, but

> no explanation of what the 8 different IO modes may be.


Hi Linus

I'm guessing this is MII, RMII, GMII, RGMII etc.

If it is, using phy-mode would be good. But that can wait until we
actually know.
 
> Set it to zero for the time being and drop a comment so

> people know what is going on if they run into trouble. This

> "mode zero" works fine with the D-Link DIR-685 with

> RTL8366RB.

> 

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


Reviewed-by: Andrew Lunn <andrew@lunn.ch>


    Andrew
David Miller Aug. 9, 2018, 9:15 p.m. UTC | #2
From: Linus Walleij <linus.walleij@linaro.org>

Date: Wed,  8 Aug 2018 14:38:55 +0200

> The totally undocumented IO mode needs to be set to enumerator

> 0 to enable port 4 also known as WAN in most configurations,

> for ordinary traffic. The 3 bits in the register come up as

> 010 after reset, but need to be set to 000.

> 

> The Realtek source code contains a name for these bits, but

> no explanation of what the 8 different IO modes may be.

> 

> Set it to zero for the time being and drop a comment so

> people know what is going on if they run into trouble. This

> "mode zero" works fine with the D-Link DIR-685 with

> RTL8366RB.

> 

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


Applied to net-next, thank you.
diff mbox series

Patch

diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c
index 1e55b9bf8b56..a4d5049df692 100644
--- a/drivers/net/dsa/rtl8366rb.c
+++ b/drivers/net/dsa/rtl8366rb.c
@@ -48,6 +48,23 @@ 
 #define RTL8366RB_SSCR2				0x0004
 #define RTL8366RB_SSCR2_DROP_UNKNOWN_DA		BIT(0)
 
+/* Port Mode Control registers */
+#define RTL8366RB_PMC0				0x0005
+#define RTL8366RB_PMC0_SPI			BIT(0)
+#define RTL8366RB_PMC0_EN_AUTOLOAD		BIT(1)
+#define RTL8366RB_PMC0_PROBE			BIT(2)
+#define RTL8366RB_PMC0_DIS_BISR			BIT(3)
+#define RTL8366RB_PMC0_ADCTEST			BIT(4)
+#define RTL8366RB_PMC0_SRAM_DIAG		BIT(5)
+#define RTL8366RB_PMC0_EN_SCAN			BIT(6)
+#define RTL8366RB_PMC0_P4_IOMODE_SHIFT		7
+#define RTL8366RB_PMC0_P4_IOMODE_MASK		GENMASK(9, 7)
+#define RTL8366RB_PMC0_P5_IOMODE_SHIFT		10
+#define RTL8366RB_PMC0_P5_IOMODE_MASK		GENMASK(12, 10)
+#define RTL8366RB_PMC0_SDSMODE_SHIFT		13
+#define RTL8366RB_PMC0_SDSMODE_MASK		GENMASK(15, 13)
+#define RTL8366RB_PMC1				0x0006
+
 /* Port Mirror Control Register */
 #define RTL8366RB_PMCR				0x0007
 #define RTL8366RB_PMCR_SOURCE_PORT(a)		(a)
@@ -860,6 +877,19 @@  static int rtl8366rb_setup(struct dsa_switch *ds)
 	if (ret)
 		return ret;
 
+	/* Port 4 setup: this enables Port 4, usually the WAN port,
+	 * common PHY IO mode is apparently mode 0, and this is not what
+	 * the port is initialized to. There is no explanation of the
+	 * IO modes in the Realtek source code, if your WAN port is
+	 * connected to something exotic such as fiber, then this might
+	 * be worth experimenting with.
+	 */
+	ret = regmap_update_bits(smi->map, RTL8366RB_PMC0,
+				 RTL8366RB_PMC0_P4_IOMODE_MASK,
+				 0 << RTL8366RB_PMC0_P4_IOMODE_SHIFT);
+	if (ret)
+		return ret;
+
 	/* Discard VLAN tagged packets if the port is not a member of
 	 * the VLAN with which the packets is associated.
 	 */