mbox series

[0/3] DSA driver for Vitesse VSC73xx

Message ID 20180614123534.8063-1-linus.walleij@linaro.org
Headers show
Series DSA driver for Vitesse VSC73xx | expand

Message

Linus Walleij June 14, 2018, 12:35 p.m. UTC
This is my effort to get the VSC73xx switch chips working with
Linux.

It works for me with this device:
https://dflund.se/~triad/krad/itian-squareone/
Which has Vitesse VSC7395 embedded in it.

I got this device from Florian Fainelli who got it from Tomasz
Figa I think. It's cute.

The device has been run with custom firmware blobs in OpenWRT
ar71xx for years. Those download some code to the 8051 CPU
and that starts to run the show.
https://github.com/openwrt/openwrt/blob/master/target/linux/ar71xx/files/drivers/spi/spi-vsc7385.c

I strongly suspect these devices can just use this driver as
well and toss out that firmware, Linux will just step in and take
control instead. It's not even much traffic over SPI going on.
It also makes it possible for us to implement VLAN support on
top of this if there is interest.

The firmware mostly makes sense when using this device with
an EEPROM inside a stand-alone switch anyway. Linux should be
in control when we use it.

We can write our own firmware for this thing if we want. It's
not even hard (well for some definition of hard) it just requires
patience and time. Until then, just taking control of it using
SPI and disabling the 8051 CPU works just fine. The target device
was using exactly this method: SPI nothing else.

I boot it:
vsc73xx spi0.0: VSC7395 (rev: 0) switch found
vsc73xx spi0.0: iCPU disabled, no external memory
vsc73xx spi0.0: MAC for control frames: B2:BF:79:2F:A3:E1
vsc73xx spi0.0: set up the switch
libphy: dsa slave smi: probed
vsc73xx spi0.0: reset PHY - disallowed
Vitesse VSC7395 dsa-0.0:00: attached PHY driver [Vitesse VSC7395] (mii_bus:phy_addr=dsa-0.0:00, irq=POLL)
vsc73xx spi0.0: reset PHY - disallowed
Vitesse VSC7395 dsa-0.0:01: attached PHY driver [Vitesse VSC7395] (mii_bus:phy_addr=dsa-0.0:01, irq=POLL)
vsc73xx spi0.0: reset PHY - disallowed
Vitesse VSC7395 dsa-0.0:02: attached PHY driver [Vitesse VSC7395] (mii_bus:phy_addr=dsa-0.0:02, irq=POLL)
vsc73xx spi0.0: reset PHY - disallowed
Vitesse VSC7395 dsa-0.0:03: attached PHY driver [Vitesse VSC7395] (mii_bus:phy_addr=dsa-0.0:03, irq=POLL)
vsc73xx spi0.0: port 6: 1000 Mbit mode full duplex
DSA: tree 0 setup

Then I do like this:

ifconfig eth1 169.254.1.2 netmask 255.255.255.0 up

gemini-ethernet-port 6000c000.ethernet-port eth1: connected to PHY "fixed-0:00"
Generic PHY fixed-0:00: attached PHY driver [Generic PHY] (mii_bus:phy_addr=fixed-0:00, irq=POLL)
phy_id=0x00000000, phy_mode=rgmii
gemini-ethernet-port 6000c000.ethernet-port: set GMAC0 and GMAC1 to MII/RGMII mode
gemini-ethernet-port 6000c000.ethernet-port eth1: connect to RGMII
gemini-ethernet-port 6000c000.ethernet-port eth1: gmac_enable_irq device 1 enable
gemini-ethernet-port 6000c000.ethernet-port eth1: opened
IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
root@gemini:/ gemini-ethernet-port 6000c000.ethernet-port eth1: connect to RGMII @ 1Gbit
IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready

Hey it works.

ifconfig lan1 up
vsc73xx spi0.0: enable port 0
IPv6: ADDRCONF(NETDEV_UP): lan1: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): lan1: link becomes ready
vsc73xx spi0.0: port 0: 100 Mbit mode full duplex
vsc73xx spi0.0 lan1: Link is Up - 100Mbps/Full - flow control rx/tx

ifconfig
eth0      Link encap:Ethernet  HWaddr F2:07:A7:EC:84:88
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:28

eth1      Link encap:Ethernet  HWaddr FE:7F:EB:C9:05:DF
          inet addr:169.254.1.2  Bcast:169.254.1.255  Mask:255.255.255.0
          inet6 addr: fe80::fe7f:eb00:1c9:5df/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:58 errors:0 dropped:6 overruns:0 frame:0
          TX packets:75 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5532 (5.4 KiB)  TX bytes:6814 (6.6 KiB)
          Interrupt:29

lan1      Link encap:Ethernet  HWaddr FE:7F:EB:C9:05:DF
          inet6 addr: fe80::fc7f:ebff:fec9:5df/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:726 (726.0 B)

ethtool -S lan1
NIC statistics:
     tx_packets: 13
     tx_bytes: 1006
     rx_packets: 0
     rx_bytes: 0
     RxEtherStatsOctets: 88396
     RxEtherStatsPkts: 887
     RxBroadcast+MulticastPkts: 34
     RxTotalErrorPackets: 0
     TxEtherStatsOctets: 86860
     TxEtherStatsPkts: 874
     TxBroadcast+MulticastPkts: 20
     TxTotalErrorPackets: 0

Linus Walleij (3):
  net: dsa: Add DT bindings for Vitesse VSC73xx switches
  net: phy: vitesse: Add support for VSC73xx
  net: dsa: Add Vitesse VSC73xx DSA router driver

 .../bindings/net/dsa/vitesse,vsc73xx.txt      |   81 +
 .../devicetree/bindings/vendor-prefixes.txt   |    1 +
 drivers/net/dsa/Kconfig                       |   12 +
 drivers/net/dsa/Makefile                      |    1 +
 drivers/net/dsa/vitesse-vsc73xx.c             | 1362 +++++++++++++++++
 drivers/net/phy/vitesse.c                     |  162 ++
 6 files changed, 1619 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/dsa/vitesse,vsc73xx.txt
 create mode 100644 drivers/net/dsa/vitesse-vsc73xx.c

-- 
2.17.1