Skip to content

Commit d865295

Browse files
linuswdavem330
authored andcommitted
net: dsa: realtek-smi: Add Realtek SMI driver
This adds a driver core for the Realtek SMI chips and a subdriver for the RTL8366RB. I just added this chip simply because it is all I can test. The code is a massaged variant of the code that has been sitting out-of-tree in OpenWRT for years in the absence of a proper switch subsystem. This creates a DSA driver for it. I have tried to credit the original authors wherever possible. The main changes I've done from the OpenWRT code: - Added an IRQ chip inside the RTL8366RB switch to demux and handle the line state IRQs. - Distributed the phy handling out to the PHY driver. - Added some RTL8366RB code that was missing in the driver at the time, such as setting up "green ethernet" with a funny jam table and forcing MAC5 (the CPU port) into 1 GBit. - Select jam table and add the default jam table from the vendor driver, also for ASIC "version 0" if need be. - Do not store jam tables in the device tree, store them in the driver. - Pick in the "initvals" jam tables from OpenWRT's driver and make those get selected per compatible for the whole system. It's apparently about electrical settings for this system and whatnot, not really configuration from device tree. - Implemented LED control: beware of bugs because there are no LEDs on the device I am using! We do not implement custom DSA tags. This is explained in a comment in the driver as well: this "tagging protocol" is not simply a few extra bytes tagged on to the ethernet frame as DSA is used to. Instead, enabling the CPU tags will make the switch start talking Realtek RRCP internally. For example a simple ping will make this kind of packets appear inside the switch: 0000 ff ff ff ff ff ff bc ae c5 6b a8 3d 88 99 a2 00 0010 08 06 00 01 08 00 06 04 00 01 bc ae c5 6b a8 3d 0020 a9 fe 01 01 00 00 00 00 00 00 a9 fe 01 02 00 00 0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 As you can see a custom "8899" tagged packet using the protocol 0xa2. Norm RRCP appears to always have this protocol set to 0x01 according to OpenRRCP. You can also see that this is not a ping packet at all, instead the switch is starting to talk network management issues with the CPU port. So for now custom "tagging" is disabled. This was tested on the D-Link DIR-685 with initramfs and OpenWRT userspaces and works fine on all the LAN ports (lan0 .. lan3). The WAN port is yet not working. Cc: Antti Seppälä <[email protected]> Cc: Roman Yeryomin <[email protected]> Cc: Colin Leitner <[email protected]> Cc: Gabor Juhos <[email protected]> Cc: Florian Fainelli <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3b3b6b4 commit d865295

File tree

7 files changed

+2591
-0
lines changed

7 files changed

+2591
-0
lines changed

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12063,6 +12063,13 @@ S: Maintained
1206312063
F: sound/soc/codecs/rt*
1206412064
F: include/sound/rt*.h
1206512065

12066+
REALTEK RTL83xx SMI DSA ROUTER CHIPS
12067+
M: Linus Walleij <[email protected]>
12068+
S: Maintained
12069+
F: Documentation/devicetree/bindings/net/dsa/realtek-smi.txt
12070+
F: drivers/net/dsa/realtek-smi*
12071+
F: drivers/net/dsa/rtl83*
12072+
1206612073
REGISTER MAP ABSTRACTION
1206712074
M: Mark Brown <[email protected]>
1206812075

drivers/net/dsa/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ config NET_DSA_QCA8K
5252
This enables support for the Qualcomm Atheros QCA8K Ethernet
5353
switch chips.
5454

55+
config NET_DSA_REALTEK_SMI
56+
tristate "Realtek SMI Ethernet switch family support"
57+
depends on NET_DSA
58+
select FIXED_PHY
59+
select IRQ_DOMAIN
60+
select REALTEK_PHY
61+
select REGMAP
62+
---help---
63+
This enables support for the Realtek SMI-based switch
64+
chips, currently only RTL8366RB.
65+
5566
config NET_DSA_SMSC_LAN9303
5667
tristate
5768
select NET_DSA_TAG_LAN9303

drivers/net/dsa/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ endif
88
obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o
99
obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
1010
obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o
11+
obj-$(CONFIG_NET_DSA_REALTEK_SMI) += realtek.o
12+
realtek-objs := realtek-smi.o rtl8366.o rtl8366rb.o
1113
obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o
1214
obj-$(CONFIG_NET_DSA_SMSC_LAN9303_I2C) += lan9303_i2c.o
1315
obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o

0 commit comments

Comments
 (0)