From patchwork Sat Jul 16 14:29:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamie Lentin X-Patchwork-Id: 9233221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 49B876075E for ; Sat, 16 Jul 2016 14:32:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A2C72223E for ; Sat, 16 Jul 2016 14:32:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DF48223A5; Sat, 16 Jul 2016 14:32:06 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E0D102223E for ; Sat, 16 Jul 2016 14:32:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bOQbz-0000gX-IK; Sat, 16 Jul 2016 14:30:35 +0000 Received: from marmot.wormnet.eu ([2a03:9800:10:2d:3203:b3a5:8bdc:5b68]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bOQbQ-0007q8-97 for linux-arm-kernel@lists.infradead.org; Sat, 16 Jul 2016 14:30:02 +0000 Received: from mijo.vandergast.wormnet.eu ([80.229.158.163] helo=gonzo.vandergast.wormnet.eu) by marmot.wormnet.eu with esmtpa (Exim 4.86) (envelope-from ) id 1bOQat-0008IE-DD; Sat, 16 Jul 2016 15:29:27 +0100 From: Jamie Lentin To: Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Imre Kaloz , Florian Fainelli Subject: [PATCH v0 08/10] net: phy: Try looking for a phy-handle property to find the OF node Date: Sat, 16 Jul 2016 15:29:06 +0100 Message-Id: <1468679348-10522-9-git-send-email-jm@lentin.co.uk> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1468679348-10522-1-git-send-email-jm@lentin.co.uk> References: <1468679348-10522-1-git-send-email-jm@lentin.co.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160716_073000_642510_BFD94A0B X-CRM114-Status: GOOD ( 10.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Jamie Lentin , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org MIME-Version: 1.0 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 If PHY is registered via. a DSA switch, the MDIO bus the phy is on does not exist in devicetree, but there may be a reference to the PHY node on the physical MDIO bus to use. Signed-off-by: Jamie Lentin --- drivers/net/phy/marvell.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 280e879..c2ca347 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -302,14 +302,24 @@ static int marvell_config_aneg(struct phy_device *phydev) */ static int marvell_of_reg_init(struct phy_device *phydev) { - const __be32 *paddr; + const __be32 *paddr = NULL; int len, i, saved_page, current_page, page_changed, ret; + struct device_node *phy_dn; + + if (phydev->mdio.dev.of_node) + paddr = of_get_property(phydev->mdio.dev.of_node, + "marvell,reg-init", &len); + else if (phydev->attached_dev->dev.of_node) { + /* A DSA slave-mii-bus has no OF node, but the PHY might */ + phy_dn = of_parse_phandle(phydev->attached_dev->dev.of_node, + "phy-handle", 0); + if (phy_dn) { + paddr = of_get_property(phy_dn, + "marvell,reg-init", &len); + of_node_put(phy_dn); + } + } - if (!phydev->mdio.dev.of_node) - return 0; - - paddr = of_get_property(phydev->mdio.dev.of_node, - "marvell,reg-init", &len); if (!paddr || len < (4 * sizeof(*paddr))) return 0;