From patchwork Wed Oct 22 18:26:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Hesselbarth X-Patchwork-Id: 402255 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6F49D140076 for ; Thu, 23 Oct 2014 05:32:12 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xh0eQ-0002zt-0x; Wed, 22 Oct 2014 18:28:50 +0000 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xh0d3-0002Zr-Bc for linux-arm-kernel@lists.infradead.org; Wed, 22 Oct 2014 18:27:28 +0000 Received: by mail-wi0-f170.google.com with SMTP id n3so1538532wiv.5 for ; Wed, 22 Oct 2014 11:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :content-type:content-transfer-encoding; bh=aj34vgrtg3OlnI4GfkNJiD3zwL+yEsZ7VJi3bTBGV1E=; b=0i1v9CTdDhxKsFOaTkMeopVtcE1u4ViD4IQjpzU4meuEphtd5cZ3yiOziGopm0i0+i PUn9rFoQl8Js1aLEEWpQZBLzGdNuB9vAJX9+rw/UzldkF5DEOree6FmrSlXF3Vx/guc3 g1AmLs5H2saYpXAfqSO6cmyI+TGngYut4ZXrNWM3fPAtqKk4IlvaCxFBpKewcDYr/VI7 DZnYt7secUO+gmdfWcX0PcTn4yuTPDnErCJ5KfmlsVXV9qJvqd66dDEr70apXh77s2aL VMuaq224DieND07LDXWIafAXcZC+eyP0IQu3o1khjewI5STQ3Isal5aB2L34Dz9Acmic qROA== X-Received: by 10.180.99.67 with SMTP id eo3mr7658043wib.82.1414002422759; Wed, 22 Oct 2014 11:27:02 -0700 (PDT) Received: from topkick.lan (f050234052.adsl.alicedsl.de. [78.50.234.52]) by mx.google.com with ESMTPSA id p3sm13689093wjf.49.2014.10.22.11.27.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Oct 2014 11:27:00 -0700 (PDT) From: Sebastian Hesselbarth To: Sebastian Hesselbarth Subject: [PATCH v2 3/9] net: pxa168_eth: Prepare proper libphy handling Date: Wed, 22 Oct 2014 20:26:46 +0200 Message-Id: <1414002412-13615-4-git-send-email-sebastian.hesselbarth@gmail.com> In-Reply-To: <1414002412-13615-1-git-send-email-sebastian.hesselbarth@gmail.com> References: <1414002412-13615-1-git-send-email-sebastian.hesselbarth@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141022_112725_584266_8B4E2AD7 X-CRM114-Status: GOOD ( 17.87 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c05:0:0:0:22a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (sebastian.hesselbarth[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Cc: Florian Fainelli , Eric Miao , netdev@vger.kernel.org, =?UTF-8?q?Antoine=20T=C3=A9nart?= , linux-kernel@vger.kernel.org, Haojian Zhuang , "David S. Miller" , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Current libphy handling in pxa168_eth lacks proper phy_connect. Prepare to fix this by first moving phy properties from platform_data to private driver data. Tested-by: Antoine Ténart Reviewed-by: Florian Fainelli Signed-off-by: Sebastian Hesselbarth --- Changelog: v1->v2: - get phy-connection-type from controller node instead of PHY node (Reported by Sergei Shtylyov) Cc: "David S. Miller" Cc: "Antoine Ténart" Cc: Florian Fainelli Cc: Eric Miao Cc: Haojian Zhuang Cc: linux-arm-kernel@lists.infradead.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/net/ethernet/marvell/pxa168_eth.c | 38 +++++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index c3b209cd0660..3918887e09c5 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -197,6 +197,9 @@ struct tx_desc { struct pxa168_eth_private { int port_num; /* User Ethernet port number */ int phy_addr; + int phy_speed; + int phy_duplex; + phy_interface_t phy_intf; int rx_resource_err; /* Rx ring resource error flag */ @@ -1394,19 +1397,17 @@ static void phy_init(struct pxa168_eth_private *pep) { struct phy_device *phy = pep->phy; - phy_attach(pep->dev, dev_name(&phy->dev), PHY_INTERFACE_MODE_MII); + phy_attach(pep->dev, dev_name(&phy->dev), pep->phy_intf); - if (pep->pd && pep->pd->speed != 0) { + phy->speed = pep->phy_speed; + phy->duplex = pep->phy_duplex; + phy->autoneg = AUTONEG_ENABLE; + phy->supported &= PHY_BASIC_FEATURES; + phy->advertising = phy->supported | ADVERTISED_Autoneg; + + if (pep->phy_speed != 0) { phy->autoneg = AUTONEG_DISABLE; phy->advertising = 0; - phy->speed = pep->pd->speed; - phy->duplex = pep->pd->duplex; - } else { - phy->autoneg = AUTONEG_ENABLE; - phy->speed = 0; - phy->duplex = 0; - phy->supported &= PHY_BASIC_FEATURES; - phy->advertising = phy->supported | ADVERTISED_Autoneg; } phy_start_aneg(phy); @@ -1416,9 +1417,6 @@ static int ethernet_phy_setup(struct net_device *dev) { struct pxa168_eth_private *pep = netdev_priv(dev); - if (pep->pd && pep->pd->init) - pep->pd->init(); - pep->phy = phy_scan(pep, pep->phy_addr & 0x1f); if (pep->phy != NULL) phy_init(pep); @@ -1552,13 +1550,23 @@ static int pxa168_eth_probe(struct platform_device *pdev) pep->port_num = pep->pd->port_number; pep->phy_addr = pep->pd->phy_addr; + pep->phy_speed = pep->pd->speed; + pep->phy_duplex = pep->pd->duplex; + pep->phy_intf = pep->pd->intf; + + if (pep->pd->init) + pep->pd->init(); } else if (pdev->dev.of_node) { of_property_read_u32(pdev->dev.of_node, "port-id", &pep->port_num); np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); - if (np) - of_property_read_u32(np, "reg", &pep->phy_addr); + if (!np) { + dev_err(&pdev->dev, "missing phy-handle\n"); + return -EINVAL; + } + of_property_read_u32(np, "reg", &pep->phy_addr); + pep->phy_intf = of_get_phy_mode(pdev->dev.of_node); } /* Hardware supports only 3 ports */