From patchwork Thu May 30 10:28:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 247527 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4AC752C0097 for ; Thu, 30 May 2013 20:28:37 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030353Ab3E3K2d (ORCPT ); Thu, 30 May 2013 06:28:33 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:39288 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968201Ab3E3K2R (ORCPT ); Thu, 30 May 2013 06:28:17 -0400 Received: by mail-wg0-f45.google.com with SMTP id n12so68093wgh.0 for ; Thu, 30 May 2013 03:28:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:content-type:x-gm-message-state; bh=gAxSOkh1on/XizX2FeOtKTwjI2qy5+929dD9Bb/O2GU=; b=T3zaaJ3bKCe86sxtGxW2fc2mJ3IEE+3xPNasYWzdv3QAYG/SDWKpA/t+l14YFBDC/J nIohrMixCwWBvho760zJZTmUe30JluA8lkEsTRsfi/oF+Jsvn5ProLp01ls4uMFAi2gF 0V0/0nURFjYCIPnaQ1xfVi5tor4SZgLbgKToB3ZoKjiPBudVVQwolOKMAdfREwm1nkp8 rN4PTLfR5bWxbZMg8CPYmIxbW8EPCFQp1EzcqmTt+mXeOt0pKGZKyRg++UR0h0OgPJp7 HIcbwR5WgFAHhh49Fs4Z63cGUiMS9hE/X2OZubJf5XaHSiLsDmUkMwFN70KXnZoYP5a8 +3TA== X-Received: by 10.194.59.4 with SMTP id v4mr3947163wjq.44.1369909695663; Thu, 30 May 2013 03:28:15 -0700 (PDT) Received: from localhost (nat-63.starnet.cz. [178.255.168.63]) by mx.google.com with ESMTPSA id h8sm36956248wiz.9.2013.05.30.03.28.14 for (version=TLSv1.1 cipher=RC4-SHA bits=128/128); Thu, 30 May 2013 03:28:15 -0700 (PDT) From: Michal Simek To: linux-kernel@vger.kernel.org Cc: Michal Simek , Michal Simek , renner@efe-gmbh.de, Bill Pemberton , Greg Kroah-Hartman , netdev@vger.kernel.org Subject: [PATCH v2 2/6] net: emaclite: Support multiple phys connected to one MDIO bus Date: Thu, 30 May 2013 12:28:04 +0200 Message-Id: <803bba7dfb86277c18cfb455518f22fb35bd5eb6.1369909618.git.michal.simek@xilinx.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQm+Gig0KSkl35k9YLQgOLXdVCk9DzaKFyodQjT3CCCbv7vTmGBO44FWyw4vpW/INTNjais6 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For system which contains at least two ethernet IP where one IP manage MDIO bus with several PHYs. Example dts node: ethernet_mac0: ethernet@81000000 { compatible = "xlnx,xps-ethernetlite-1.00.a"; device_type = "network"; interrupt-parent = <&xps_intc_0>; interrupts = < 1 0 >; local-mac-address = [ 00 0a 35 00 db bb ]; phy-handle = <ðernet_mac0_phy0>; reg = < 0x81000000 0x10000 >; xlnx,duplex = <0x1>; xlnx,family = "spartan3e"; xlnx,include-internal-loopback = <0x0>; xlnx,include-mdio = <0x1>; xlnx,rx-ping-pong = <0x0>; xlnx,tx-ping-pong = <0x0>; ethernet_mac0_mdio { #address-cells = <1>; #size-cells = <0>; ethernet_mac0_phy0: phy@1 { reg = <0x1>; } ; ethernet_mac0_phy1: phy@3 { reg = <0x3>; } ; } ; } ; ethernet_mac2: ethernet@81040000 { compatible = "xlnx,xps-ethernetlite-1.00.a"; device_type = "network"; interrupt-parent = <&xps_intc_0>; interrupts = < 11 0 >; local-mac-address = [ 00 0a 35 00 db bb ]; phy-handle = <ðernet_mac0_phy1>; reg = < 0x81040000 0x10000 >; xlnx,duplex = <0x1>; xlnx,family = "spartan3e"; xlnx,include-internal-loopback = <0x0>; xlnx,include-mdio = <0x0>; xlnx,rx-ping-pong = <0x0>; xlnx,tx-ping-pong = <0x0>; } ; Signed-off-by: Michal Simek --- Changes in v2: None drivers/net/ethernet/xilinx/xilinx_emaclite.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 1.8.2.3 diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c index a16dc35..fcd1e0b 100644 --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c @@ -848,6 +848,7 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev) int rc; struct resource res; struct device_node *np = of_get_parent(lp->phy_node); + struct device_node *npp; /* Don't register the MDIO bus if the phy_node or its parent node * can't be found. @@ -856,6 +857,17 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev) dev_err(dev, "Failed to register mdio bus.\n"); return -ENODEV; } + npp = of_get_parent(np); + + of_address_to_resource(npp, 0, &res); + if (lp->ndev->mem_start != res.start) { + struct phy_device *phydev; + phydev = of_phy_find_device(lp->phy_node); + if (!phydev) + dev_info(dev, + "MDIO of the phy is not registered yet\n"); + return 0; + } /* Enable the MDIO bus by asserting the enable bit in MDIO Control * register. @@ -869,7 +881,6 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev) return -ENOMEM; } - of_address_to_resource(np, 0, &res); snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx", (unsigned long long)res.start); bus->priv = lp;