Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1325033rwb; Sun, 18 Sep 2022 05:23:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qDBYOqAmVIVbh4CXoKyO0jtYOXLO5JV7x1/QQf2pUbaI9NycNhxknxvTE7J8+ahI+/oMC X-Received: by 2002:a05:6a02:205:b0:420:8b7e:3ff with SMTP id bh5-20020a056a02020500b004208b7e03ffmr11591558pgb.427.1663503815550; Sun, 18 Sep 2022 05:23:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663503815; cv=pass; d=google.com; s=arc-20160816; b=lGGreQ2SpCP6P8zXYcmnGQ1cIGi2h4cdlIp14hlhxIpg31aDbeJkjAk2/1JNuipYdX 8sVufbcCE50AyLEw8qo5D9y9C6IQoc2TWuaK/Chiglt7bxit63+yO/EoCTcHNRC7JLvP cyYeaOjRgo0KPWu1AvSzbvB8oPbhwtC+mD6G5D4y0qNdiquMR28nku/qOvVLWyhNhptZ EpNFWhbD+rBPRZZkqgF45mDLQbMaCK8Trvfh0LOPVWX66w0XmXfPQM0UPtasI8A4BjUg 1U3ePY5BTddOpO8T/wZoYo+jiSQz+u1hCK50QjWRyCv50HlY0PGnuyHYl5m/mXQ8VwX+ gdYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=04ijFyWpNqjr0mVAOzrs4qWtbJFIYTunE57Md0QH6jc=; b=m/aE3DjFr4GDy1crEWVgXrjR14mj/SEeWlmmBnTSZmwXblIuRL4n5qEFs2gsIaEw5S rH9f+ltGEB5ipWNxdetzSbFDe+0txMJiDtPOeq6boVuWJB+2Y7Z7yN41DQmHf/rr2oRz CGGqSQq1y3y2ImZS3glWraHWEzl6MMrR6odpk1wor5y607hOqxexv3mefLHB6FlaiYuI CMgJn4CfOllFyKBMGQnCzpN4IehPBkYcYz3n8SxPM/rI+BL/3Dw/jIBqZi3jNgLFft45 EZa6h9jWgtnwE4gvrRH8WCaEAeLaBW6WFZ1obw8s0otB2ouprwXB33yqCFanmEmcjHkL 3OdQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arinc9.com header.s=zmail header.b=RHVPFeYv; arc=pass (i=1 spf=pass spfdomain=arinc9.com dkim=pass dkdomain=arinc9.com dmarc=pass fromdomain=arinc9.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u131-20020a637989000000b00434dd689f07si28249463pgc.846.2022.09.18.05.23.24; Sun, 18 Sep 2022 05:23:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arinc9.com header.s=zmail header.b=RHVPFeYv; arc=pass (i=1 spf=pass spfdomain=arinc9.com dkim=pass dkdomain=arinc9.com dmarc=pass fromdomain=arinc9.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbiIRL3h (ORCPT + 99 others); Sun, 18 Sep 2022 07:29:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbiIRL3d (ORCPT ); Sun, 18 Sep 2022 07:29:33 -0400 Received: from sender4-op-o14.zoho.com (sender4-op-o14.zoho.com [136.143.188.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1634BF3A; Sun, 18 Sep 2022 04:29:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663500538; cv=none; d=zohomail.com; s=zohoarc; b=ZH7AKVMOwTy5jgBEvz7C3Kikf6uqzifTon+tLb0MxZ1Bh4l1grbzh/fDYOtZRpT6WLW2uxNeAc4ZBQmRSs9OnVytgibE/Lfuw78bA6QU0jA+JUWezJtN0fTMvxXUdene6fsP0DKiIBx02P6PnePnU2eMynSRpge72njjPqDYUA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663500538; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=04ijFyWpNqjr0mVAOzrs4qWtbJFIYTunE57Md0QH6jc=; b=GDHTfDz40RfWjuq1bTxO5t3NcQewILiyk4XH4qRKUP7jgpIOEI4vu2vdhsB4RmA/ZOuI2lFnupswcm6pR7fqUvufEbx2phgZvFx+C1LE/WUtz7gNPVzvpmuQnlw0RC8pFmJLSGPk0a//NJImIBZwIIKPZjyxZJsDXteIgZDjY/s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=arinc9.com; spf=pass smtp.mailfrom=arinc.unal@arinc9.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1663500538; s=zmail; d=arinc9.com; i=arinc.unal@arinc9.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=04ijFyWpNqjr0mVAOzrs4qWtbJFIYTunE57Md0QH6jc=; b=RHVPFeYv1mkXd2h3PfKWfNC6B6r6Y7JA7LZ1jNOfBNIkvzX9H+YQ2J9O8wikP1aO 14HHjb9/fXn8wwtX/8gZNqIF3OLor+/vOkM6Hl/lgm+AkjMtQPvXm700edpJgYezO8N i8l2SpzUUE2xKLYyh6m4G5ZB/jNNvMaXS+N84hK8= Received: from [10.10.10.3] (37.120.152.236 [37.120.152.236]) by mx.zohomail.com with SMTPS id 1663500536617106.7364888322121; Sun, 18 Sep 2022 04:28:56 -0700 (PDT) Message-ID: <4a291389-105a-6288-1347-4f02171b0dd0@arinc9.com> Date: Sun, 18 Sep 2022 14:28:50 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Move MT7530 phy muxing from DSA to PHY driver Content-Language: en-US To: Andrew Lunn Cc: netdev , Linux ARM , "moderated list:ARM/Mediatek SoC support" , linux-kernel , Thibaut , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Sean Wang , Landen Chao , DENG Qingfang , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Matthias Brugger , Philipp Zabel , Sergio Paracuellos References: <0e3ca573-2190-57b0-0e98-7f5b890d328e@arinc9.com> From: =?UTF-8?B?QXLEsW7DpyDDnE5BTA==?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ZohoMailClient: External X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17.09.2022 18:07, Andrew Lunn wrote: >>> Where in the address range is the mux register? Officially, PHY >>> drivers only have access to PHY registers, via MDIO. If the mux >>> register is in the switch address space, it would be better if the >>> switch did the mux configuration. An alternative might be to represent >>> the mux in DT somewhere, and have a mux driver. >> >> I don't know this part very well but it's in the register for hw trap >> modification which, I think, is in the switch address space. >> >> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/mt7530.c?id=1f9a6abecf538cc73635f6082677a2f4dc9c89a4#n941 >> >> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/drivers/net/dsa/mt7530.h?id=1f9a6abecf538cc73635f6082677a2f4dc9c89a4#n500 >> >> Like you said, I don't think we can move away from the DSA driver, and would >> rather keep the driver do the mux configuration. >> >> We could change the check for phy muxing to define the phy muxing bindings >> in the DSA node instead. If I understand correctly, the mdio address for >> PHYs is fake, it's for the sole purpose of making the driver check if >> there's request for phy muxing and which phy to mux. I'm saying this because >> the MT7530 switch works fine at address 0 while also using phy0 as a slave >> interface. >> >> A property could be introduced on the DSA node for the MT7530 DSA driver: >> >> mdio { >> #address-cells = <1>; >> #size-cells = <0>; >> >> switch@0 { >> compatible = "mediatek,mt7530"; >> reg = <0>; >> >> reset-gpios = <&pio 33 0>; >> >> core-supply = <&mt6323_vpa_reg>; >> io-supply = <&mt6323_vemc3v3_reg>; >> >> mt7530,mux-phy = <&sw0_p0>; >> >> ethernet-ports { >> #address-cells = <1>; >> #size-cells = <0>; >> >> sw0_p0: port@0 { >> reg = <0>; >> }; >> }; >> }; >> }; >> >> This would also allow using the phy muxing feature with any ethernet mac. >> Currently, phy muxing check wants the ethernet mac to be gmac1 of a MediaTek >> SoC. However, on a standalone MT7530, the switch can be wired to any SoC's >> ethernet mac. >> >> For the port which is set for PHY muxing, do not bring it as a slave >> interface, just do the phy muxing operation. >> >> Do not fail because there's no CPU port (ethernet property) defined when >> there's only one port defined and it's set for PHY muxing. >> >> I don't know if the ethernet mac needs phy-handle defined in this case. > > From mediatek,mt7530.yaml: > > Port 5 modes/configurations: > 1. Port 5 is disabled and isolated: An external phy can interface to the 2nd > GMAC of the SOC. > In the case of a build-in MT7530 switch, port 5 shares the RGMII bus with 2nd > GMAC and an optional external phy. Mind the GPIO/pinctl settings of the SOC! > 2. Port 5 is muxed to PHY of port 0/4: Port 0/4 interfaces with 2nd GMAC. > It is a simple MAC to PHY interface, port 5 needs to be setup for xMII mode > and RGMII delay. > 3. Port 5 is muxed to GMAC5 and can interface to an external phy. > Port 5 becomes an extra switch port. > Only works on platform where external phy TX<->RX lines are swapped. > Like in the Ubiquiti ER-X-SFP. > 4. Port 5 is muxed to GMAC5 and interfaces with the 2nd GAMC as 2nd CPU port. > Currently a 2nd CPU port is not supported by DSA code. > > So this mux has a scope bigger than the switch, it also affects one of > the SoCs MACs. > > The phy-handle should have all the information you need, but it is > scattered over multiple locations. It could be in switch port 5, or it > could be in the SoC GMAC node. > > Although the mux is in the switches address range, could you have a > tiny driver using that address range. Have this tiny driver export a > function to set the mux. Both the GMAC and the DSA driver make use of > the function, which should be enough to force the tiny driver to load > first. The GMAC and the DSA driver can then look at there phy-handle, > and determine how the mux should be set. The GMAC should probably do > that before register_netdev. The DSA driver before it registers the > switch with the DSA core. > > Does that solve all your ordering issues? I believe it does. > > By using the phy-handle, you don't need any additional properties, so > backwards compatibility should not be a problem. You can change driver > code as much as you want, but ABI like DT is fixed. Understood, thanks Andrew! Arınç