From patchwork Mon Nov 26 00:15:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 10697207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55B3413BF for ; Mon, 26 Nov 2018 00:16:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43AEB28E04 for ; Mon, 26 Nov 2018 00:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 373C828EC7; Mon, 26 Nov 2018 00:16:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A6B6F28E04 for ; Mon, 26 Nov 2018 00:16:11 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject: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=lp9bLC4FRnDF2Xj7EOMK1J0c2C+tXqm6NLXPmMX4qV0=; b=dv11SCtSKA8BkD zkyt3NB5RVUwy0Cg7Zcw5hUt9QPIZ2s+piDEAAkDQ4e+u3gheYSthu8SCFZbIiA2NfrMmH3Ig2uG/ EGmvxIP2lcAUvwXFOTqo39/BNgLZ/VyIsRKR6U+eD0xZ7cv590evzFRcD0UY/OuR537KZbeU/b6rT Eat1FzXYl/nf2X+OnyZ5nHfcSG8Snw6cV9t61qpVh9lALQbuAr8WL4p5LHg4Hk+E8VfPfLc6gmX67 5szbjyuZhZ5hVD0UQmWU1wsSkXjRb6o3EVVWogzoEQlvlRX1uY5SSVj3UXOG3azxo6UMlWZI/HpvK RUGOrVLvAzDwveuDtVOQ==; 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 1gR4ZI-0004gO-0o; Mon, 26 Nov 2018 00:16:04 +0000 Received: from fllv0016.ext.ti.com ([198.47.19.142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gR4Z4-0004W2-FI for linux-arm-kernel@lists.infradead.org; Mon, 26 Nov 2018 00:15:52 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id wAQ0FXgh097194; Sun, 25 Nov 2018 18:15:33 -0600 Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id wAQ0FXha126518 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 25 Nov 2018 18:15:33 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Sun, 25 Nov 2018 18:15:32 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Sun, 25 Nov 2018 18:15:33 -0600 Received: from legion.dal.desgin.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id wAQ0FWna030819; Sun, 25 Nov 2018 18:15:32 -0600 Received: from localhost (uda0226610.dhcp.ti.com [128.247.59.147]) by legion.dal.desgin.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id wAQ0FWU04334; Sun, 25 Nov 2018 18:15:32 -0600 (CST) From: Grygorii Strashko To: "David S. Miller" , Tony Lindgren , Kishon Vijay Abraham I , Rob Herring Subject: [PATCH linux-next 00/10] net: ethernet: ti: cpsw: replace cpsw-phy-sel with phy driver Date: Sun, 25 Nov 2018 18:15:21 -0600 Message-ID: <20181126001531.12974-1-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.10.5 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181125_161550_628693_9F84F087 X-CRM114-Status: GOOD ( 13.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Grygorii Strashko , Andrew Lunn , netdev@vger.kernel.org, Sekhar Nori , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP TI am335x/am437x/dra7(am5)/dm814x CPSW3G Ethernet Subsystem supports two 10/100/1000 Ethernet ports with selectable G/MII, RMII, and RGMII interfaces. The interface mode is selected by configuring the MII mode selection register(s) (GMII_SEL) in the System Control Module chapter (SCM). +--------------+ +-------------------------------+ |SCM | | CPSW | | +---------+ | | +--------------------------------+gmii_sel | | | | | | +---------+ | | +----v---+ +--------+ | +--------------+ | |Port 1..<--+-->GMII/MII<-------> | | | | | | | | +--------+ | +--------+ | | | | | | +--------+ | | | | RMII <-------> | +--> | | | | +--------+ | | | | | | +--------+ | | | | RGMII <-------> | +--> | | | +--------+ | +-------------------------------+ GMII_SEL register(s) and bit fields placement in SCM are different between SoCs while fields meaning is the same. GMII_SEL(s) allows to select - Port GMII/MII/RMII/RGMII Mode; RGMII Internal Delay Mode (SoC dependant) and RMII Reference Clock Output mode (SoC dependant). Historically CPSW external Port's interface mode selection configuartion was introduced using custom driver and API cpsw-phy-sel.c. This leads to unnecessary driver, DT binding and custom API support effort. Moreover, even definition of cpsw-phy-sel node in DTs is logically incorrect [1] mac: ethernet@4a100000 { compatible = "ti,am4372-cpsw","ti,cpsw"; ... phy_sel: cpsw-phy-sel@44e10650 { compatible = "ti,am43xx-cpsw-phy-sel"; reg= <0x44e10650 0x4>; reg-names = "gmii-sel"; }; }; This series replaces custom CPSW Port interface selection implementation (cpsw-phy-sel.c) with well defined Linux PHY framework interface instead. It introduces CPSW Port's PHY Interface Mode selection Driver (phy-gmii-sel) which implements standard Linux PHY interface. The phy-gmii-sel PHY device should defined as child device of SCM node (scm_conf) and can be attached to each CPSW port node using standard PHY bindings (cell 1 - port number, cell 2 - RMII refclk mode). scm_conf: scm_conf@0 { compatible = "syscon", "simple-bus"; gmii_sel_phy: cpsw-sel-netif { compatible = "ti,am43xx-gmii-sel-phy"; syscon-scm = <&scm_conf>; #phy-cells = <2>; }; }; mac: ethernet@4a100000 { compatible = "ti,am4372-cpsw","ti,cpsw"; cpsw_emac0: slave@4a100200 { phy-mode = "rgmii"; phys = <&gmii_sel_phy 1 0>; }; }; The CPSW driver requests phy-gmii-sel PHY for each external port and uses recently introduced PHY API phy_set_mode_ext() [1] for port interface mode selection when netdev is opened. slave->data->gmii_sel_phy = devm_of_phy_get(&pdev->dev, port_node, NULL); slave->data->phy_if = of_get_phy_mode(port_node); cpsw_ndo_open() phy_set_mode_ext(slave->data->gmii_sel_phy, PHY_MODE_ETHERNET, slave->data->phy_if); Note. CPSW Port interface has to be reconfigured every time netdev is opened for proper System Suspend support where CPSW can lose context. [1] https://patchwork.kernel.org/cover/10689739/ Cc: Kishon Vijay Abraham I Cc: Tony Lindgren Grygorii Strashko (10): dt-bindings: phy: add cpsw port interface mode selection phy bindings phy: ti: introduce phy-gmii-sel driver dt-bindings: net: ti: cpsw: switch to use phy-gmii-sel phy net: ethernet: ti: cpsw: add support for port interface mode selection phy ARM: dts: dra7: switch to use phy-gmii-sel ARM: dts: dm814x: switch to use phy-gmii-sel ARM: dts: am4372: switch to use phy-gmii-sel ARM: dts: am335x: switch to use phy-gmii-sel dt-bindings: net: ti: deprecate cpsw-phy-sel bindings net: ethernet: ti: cpsw: deprecate cpsw-phy-sel driver .../devicetree/bindings/net/cpsw-phy-sel.txt | 2 +- Documentation/devicetree/bindings/net/cpsw.txt | 8 +- .../devicetree/bindings/phy/ti-phy-gmii-sel.txt | 68 ++++ arch/arm/boot/dts/am335x-baltos-ir2110.dts | 4 - arch/arm/boot/dts/am335x-baltos-ir3220.dts | 4 - arch/arm/boot/dts/am335x-baltos-ir5221.dts | 4 - arch/arm/boot/dts/am335x-chiliboard.dts | 4 - arch/arm/boot/dts/am335x-icev2.dts | 4 - arch/arm/boot/dts/am335x-igep0033.dtsi | 4 - arch/arm/boot/dts/am335x-lxm.dts | 4 - arch/arm/boot/dts/am335x-moxa-uc-2100-common.dtsi | 5 - arch/arm/boot/dts/am335x-moxa-uc-8100-me-t.dts | 5 - arch/arm/boot/dts/am335x-phycore-som.dtsi | 4 - arch/arm/boot/dts/am33xx-l4.dtsi | 15 +- arch/arm/boot/dts/am437x-l4.dtsi | 17 +- arch/arm/boot/dts/am43x-epos-evm.dts | 5 +- arch/arm/boot/dts/dm814x.dtsi | 15 +- arch/arm/boot/dts/dra7-l4.dtsi | 15 +- drivers/net/ethernet/ti/Kconfig | 6 +- drivers/net/ethernet/ti/cpsw.c | 19 +- drivers/net/ethernet/ti/cpsw.h | 6 + drivers/phy/ti/Kconfig | 10 + drivers/phy/ti/Makefile | 1 + drivers/phy/ti/phy-gmii-sel.c | 349 +++++++++++++++++++++ 24 files changed, 498 insertions(+), 80 deletions(-) create mode 100644 Documentation/devicetree/bindings/phy/ti-phy-gmii-sel.txt create mode 100644 drivers/phy/ti/phy-gmii-sel.c