From patchwork Thu Jun 14 12:35:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138566 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2058427lji; Thu, 14 Jun 2018 05:37:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJIhDLYKaczwDPayujVtkAbSAZu4hBTS/UwzKwjGcV0Ml/m6Z/5fb4HzZjdl75Xtl1FrnSp X-Received: by 2002:a17:902:a416:: with SMTP id p22-v6mr2892848plq.228.1528979869214; Thu, 14 Jun 2018 05:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528979869; cv=none; d=google.com; s=arc-20160816; b=IyrNmHTS3F3gDlgHIAHdvhUHIyl03NCgBsrFpI5flqrDbfb7cRQaTV4cSF2M3/6XPG H8y1CMtDya65k8cjV8XpJxeq86ZFEOXTZjrRUtpKfWb7gIqyEJ9yxz8Zn9Q0wrcrPA/n m4KJrLVwe7M3TlEtZ0gLOHRwYbW0GbTzyzxoPdzqHlA1bbbP9X3KFI/fwZuxl/y2Ds3u nVCwf237LhVUW+Wcl9J1Ehu/qJlT9uW7uBRkIWbZMGZgxS65/2aDcBW2UNWgumWlEU/2 upQVv6nhf39vkcNCXWPlNHABYH9LQPK1g4Trpla10OihxBORTKIRZKC9HPY0FvTtjT9m a1BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=9xiNggNDr9nTN1BDK0IcX3lp8ap8TV3bT06YtpTi2hA=; b=MHKCZEPskblzdW9rxpRN9YoA+O/dVWF6kT1flQSz+tT7ArwIdnl0dSuLzyrWGpkHnW /GckSU6nH2Y5zH3/WjVegQ4Ch+ClGF5NJhL6KbHSvXsrnGtkQqMu1iwIx+wm/ZmTpug7 a5B4ydzcR6CTvNEHea7FSuhMvOLcoRKbt3SpgaXfxDCy+O8oDNXlweqh7YQD69Zy6hgn dg2Dcsz4Ve2fHIswxdIDJ6mtUCmCPoE+HV0mjRwsHKxH/M3veW0ydVsFnQKKPvCUPd7Y rRDqdLWWgjjJInxXMAtZhHgl+Eznb59VeKKLPhWvDzTyBodSnUa9ekygla8skstS+ONm SyBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1+P10KR; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e72-v6si5462466pfd.352.2018.06.14.05.37.48; Thu, 14 Jun 2018 05:37:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f1+P10KR; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755057AbeFNMhq (ORCPT + 9 others); Thu, 14 Jun 2018 08:37:46 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:38380 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754901AbeFNMhp (ORCPT ); Thu, 14 Jun 2018 08:37:45 -0400 Received: by mail-lf0-f68.google.com with SMTP id i83-v6so9184579lfh.5 for ; Thu, 14 Jun 2018 05:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=9xiNggNDr9nTN1BDK0IcX3lp8ap8TV3bT06YtpTi2hA=; b=f1+P10KREL4ck49KCD8dKKTXCjGporxFjeQTmy1AtPpB//Xw20Nb2KAzNfQE7xSQmy xNVHfVoGnvwpw/talXkvKK+WPT5jJ6i7bY4C51I7RjGtUJPK/ltQ85waNeYGKLPbb8RQ orKq1Ei/zCfmnA/A+msPe5IoVtGTrGqY1oGhw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9xiNggNDr9nTN1BDK0IcX3lp8ap8TV3bT06YtpTi2hA=; b=BxweOkRR67Tj4/l81uklf98s8TLN4CsqLkiKBrXNWIn3+xIrpuPqLqBO/AHVyQE+4K 9D8qOCkMct3Gevrt+jDCnGiNmTzQkE/PoLR08Hf67E5qyg0e4xuRrmuI1xkVVGX7g9UG Z6Gtv4da3Y43AIhcxyF5/aAHuLadFRbFkwDi2+fkc8PiZKTkKreH6XoyhMXh/SCwaas6 xf9cO7KmiJ0jrysYMa3NW+9hetvCIQiNg/M3Nf5MnyrNqaAFtdhOa5sLEU5/pkZ6sOAo miHQLUq3+wvBnFg2EO91yIYz5zOy0SEREPMMV/n4DeJs9sdUq4YRuTLuhqNXhMJINg9r eh9w== X-Gm-Message-State: APt69E2hhLU9LgxTw4M2uknGwmmFmy5Ot4KJeuY4TIdgWTfSEO7ZYvlJ XOG4ekCYDRN7CPOE383UOZdypA== X-Received: by 2002:a19:2583:: with SMTP id l125-v6mr6240607lfl.146.1528979864057; Thu, 14 Jun 2018 05:37:44 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id g17-v6sm937152ljg.27.2018.06.14.05.37.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 05:37:42 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, openwrt-devel@lists.openwrt.org, LEDE Development List , Gabor Juhos , Linus Walleij Subject: [PATCH 0/3] DSA driver for Vitesse VSC73xx Date: Thu, 14 Jun 2018 14:35:31 +0200 Message-Id: <20180614123534.8063-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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