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: 929407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="A7mBkRha"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="f1+P10KR"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41637L4XvQz9s3q for ; Thu, 14 Jun 2018 22:38:06 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eLvj98eCdxkKSn7nBD0t1JLx9NA8Vr8Zn2CROIu0qLg=; b=A7mBkRhac9wv5b ZvwzNwFIjWEkZPjUB88jZ3d7o8RCT+zNu6rYw1JpOYVOy2u8nro0cEwrbSTAnjv2bYANQuMhGdCk+ jEEoMtUkYASBjKVsMKWwtFrGb/CJyCZlEg1fnymh08WN8Ef/fOdkM97Ym37SmnE8DZHTqspUAkTi5 8khUcOJxYWHwAuqaAWYrz/ar2SN7KaqZGONGHlaRf/nh8YHpu0bp0YS9zSiibA07rcE2vzmd8rFmp 9r34OZU823ACBCW97KUoc7MQ8hHA6CXSwuEOmPlAMP7XKhSs99Jvl74ErSnE7BQmGuEgjWUqPpq51 sxPS3oCb2qAPLUvaft8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTRVp-0005N4-0a; Thu, 14 Jun 2018 12:38:01 +0000 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTRVk-0005KW-CR for openwrt-devel@lists.openwrt.org; Thu, 14 Jun 2018 12:37:59 +0000 Received: by mail-lf0-x242.google.com with SMTP id n15-v6so9151746lfn.10 for ; Thu, 14 Jun 2018 05:37:45 -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=oE+1ymKobGUQlmPJW8Om6tLts3qUUpBUhxcG7uSr9RydYUY7pQwUld0K37OLx6O65n u85xoTHWyiINxeZDNYHdn0SAcq9C+8kbvrlOerkovt4o6KksiIOunzxC+3cLWvdXo7zs b0gynY4bDByR5zCyyp035uCIq10AbBsBcbIunSztyX1yX9RkMfAC9yqdIrYjO/tOsvOY cOjR7PKD+32+VsCC1AeIh0OnAyGws3UDxqB27wutj3uBBOaXmEhqIKvmEJxW9sQjQiVq /xL6ElihFolv348JnPnLz8Dl2DQfIJcYiaF0W/sDNWP7T7r8jigKwEssoDvFbhjAuxWr PDjw== X-Gm-Message-State: APt69E2KBR6aDONJ0eIZCQGmIh0x6qOtP39anYhpkDpEWxRNsG9wcAuz nIzWv//3U+xKfK6CWLviGwJEMQ== X-Google-Smtp-Source: ADUXVKIc0M8s+wM4yoDRixIDOSbWdNHaScy5X/Tm0oEetpLx4UD5IsEgukyBHixwljIpX0aFdL715w== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180614_053756_417658_E4A79BC4 X-CRM114-Status: GOOD ( 17.19 ) X-Spam-Score: -0.6 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c07:0:0:0:242 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid Subject: [OpenWrt-Devel] [PATCH 0/3] DSA driver for Vitesse VSC73xx X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, Linus Walleij , LEDE Development List , Gabor Juhos MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.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