{"id":807488,"url":"http://patchwork.ozlabs.org/api/1.0/patches/807488/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170830082924.3180-5-antoine.tenart@free-electrons.com>","date":"2017-08-30T08:29:15","name":"[net-next,v4,04/13] net: mvpp2: initialize the comphy","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"38d4050fc4a64c50020e0c24f394e9ae535b177b","submitter":{"id":61603,"url":"http://patchwork.ozlabs.org/api/1.0/people/61603/?format=json","name":"Antoine Tenart","email":"antoine.tenart@free-electrons.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.0/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170830082924.3180-5-antoine.tenart@free-electrons.com/mbox/","series":[{"id":550,"url":"http://patchwork.ozlabs.org/api/1.0/series/550/?format=json","date":"2017-08-30T08:29:24","name":"net: mvpp2: comphy configuration","version":4,"mbox":"http://patchwork.ozlabs.org/series/550/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807488/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xhzN12t2tz9sRq\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 18:35:13 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751478AbdH3Ie6 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 30 Aug 2017 04:34:58 -0400","from mail.free-electrons.com ([62.4.15.54]:58112 \"EHLO\n\tmail.free-electrons.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751302AbdH3I3l (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 30 Aug 2017 04:29:41 -0400","by mail.free-electrons.com (Postfix, from userid 110)\n\tid B3D7521F5A; Wed, 30 Aug 2017 10:29:38 +0200 (CEST)","from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr\n\t[90.63.216.87])\n\tby mail.free-electrons.com (Postfix) with ESMTPSA id 87ED621F62;\n\tWed, 30 Aug 2017 10:29:28 +0200 (CEST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on\n\tmail.free-electrons.com","X-Spam-Level":"","X-Spam-Status":"No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT,\n\tURIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0","From":"Antoine Tenart <antoine.tenart@free-electrons.com>","To":"davem@davemloft.net, kishon@ti.com, andrew@lunn.ch,\n\tjason@lakedaemon.net, sebastian.hesselbarth@gmail.com,\n\tgregory.clement@free-electrons.com","Cc":"Antoine Tenart <antoine.tenart@free-electrons.com>,\n\tthomas.petazzoni@free-electrons.com, nadavh@marvell.com,\n\tlinux@armlinux.org.uk, linux-kernel@vger.kernel.org,\n\tmw@semihalf.com, stefanc@marvell.com,\n\tmiquel.raynal@free-electrons.com, netdev@vger.kernel.org","Subject":"[PATCH net-next v4 04/13] net: mvpp2: initialize the comphy","Date":"Wed, 30 Aug 2017 10:29:15 +0200","Message-Id":"<20170830082924.3180-5-antoine.tenart@free-electrons.com>","X-Mailer":"git-send-email 2.13.5","In-Reply-To":"<20170830082924.3180-1-antoine.tenart@free-electrons.com>","References":"<20170830082924.3180-1-antoine.tenart@free-electrons.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"On some platforms, the comphy is between the MAC GoP and the PHYs. The\nmvpp2 driver currently relies on the firmware/bootloader to configure\nthe comphy. As a comphy driver was added to the generic PHY framework,\nthis patch uses it in the mvpp2 driver to configure the comphy at boot\ntime to avoid relying on the bootloader.\n\nSigned-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>\n---\n drivers/net/ethernet/marvell/mvpp2.c | 44 +++++++++++++++++++++++++++++++++++-\n 1 file changed, 43 insertions(+), 1 deletion(-)","diff":"diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c\nindex e312dfc3555b..fab231858a41 100644\n--- a/drivers/net/ethernet/marvell/mvpp2.c\n+++ b/drivers/net/ethernet/marvell/mvpp2.c\n@@ -28,6 +28,7 @@\n #include <linux/of_address.h>\n #include <linux/of_device.h>\n #include <linux/phy.h>\n+#include <linux/phy/phy.h>\n #include <linux/clk.h>\n #include <linux/hrtimer.h>\n #include <linux/ktime.h>\n@@ -861,6 +862,7 @@ struct mvpp2_port {\n \n \tphy_interface_t phy_interface;\n \tstruct device_node *phy_node;\n+\tstruct phy *comphy;\n \tunsigned int link;\n \tunsigned int duplex;\n \tunsigned int speed;\n@@ -4420,6 +4422,32 @@ static int mvpp22_gop_init(struct mvpp2_port *port)\n \treturn -EINVAL;\n }\n \n+static int mvpp22_comphy_init(struct mvpp2_port *port)\n+{\n+\tenum phy_mode mode;\n+\tint ret;\n+\n+\tif (!port->comphy)\n+\t\treturn 0;\n+\n+\tswitch (port->phy_interface) {\n+\tcase PHY_INTERFACE_MODE_SGMII:\n+\t\tmode = PHY_MODE_SGMII;\n+\t\tbreak;\n+\tcase PHY_INTERFACE_MODE_10GKR:\n+\t\tmode = PHY_MODE_10GKR;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tret = phy_set_mode(port->comphy, mode);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\treturn phy_power_on(port->comphy);\n+}\n+\n static void mvpp2_port_mii_gmac_configure_mode(struct mvpp2_port *port)\n {\n \tu32 val;\n@@ -6404,8 +6432,10 @@ static void mvpp2_start_dev(struct mvpp2_port *port)\n \t/* Enable interrupts on all CPUs */\n \tmvpp2_interrupts_enable(port);\n \n-\tif (port->priv->hw_version == MVPP22)\n+\tif (port->priv->hw_version == MVPP22) {\n+\t\tmvpp22_comphy_init(port);\n \t\tmvpp22_gop_init(port);\n+\t}\n \n \tmvpp2_port_mii_set(port);\n \tmvpp2_port_enable(port);\n@@ -6436,6 +6466,7 @@ static void mvpp2_stop_dev(struct mvpp2_port *port)\n \tmvpp2_egress_disable(port);\n \tmvpp2_port_disable(port);\n \tphy_stop(ndev->phydev);\n+\tphy_power_off(port->comphy);\n }\n \n static int mvpp2_check_ringparam_valid(struct net_device *dev,\n@@ -7270,6 +7301,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,\n \t\t\t    struct mvpp2 *priv)\n {\n \tstruct device_node *phy_node;\n+\tstruct phy *comphy;\n \tstruct mvpp2_port *port;\n \tstruct mvpp2_port_pcpu *port_pcpu;\n \tstruct net_device *dev;\n@@ -7311,6 +7343,15 @@ static int mvpp2_port_probe(struct platform_device *pdev,\n \t\tgoto err_free_netdev;\n \t}\n \n+\tcomphy = devm_of_phy_get(&pdev->dev, port_node, NULL);\n+\tif (IS_ERR(comphy)) {\n+\t\tif (PTR_ERR(comphy) == -EPROBE_DEFER) {\n+\t\t\terr = -EPROBE_DEFER;\n+\t\t\tgoto err_free_netdev;\n+\t\t}\n+\t\tcomphy = NULL;\n+\t}\n+\n \tif (of_property_read_u32(port_node, \"port-id\", &id)) {\n \t\terr = -EINVAL;\n \t\tdev_err(&pdev->dev, \"missing port-id value\\n\");\n@@ -7344,6 +7385,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,\n \n \tport->phy_node = phy_node;\n \tport->phy_interface = phy_mode;\n+\tport->comphy = comphy;\n \n \tif (priv->hw_version == MVPP21) {\n \t\tres = platform_get_resource(pdev, IORESOURCE_MEM, 2 + id);\n","prefixes":["net-next","v4","04/13"]}