From patchwork Tue Aug 28 06:25:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janine Hagemann X-Patchwork-Id: 962742 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=phytec.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41zzQZ1vqLz9s2P for ; Tue, 28 Aug 2018 16:30:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E5C40C21C3F; Tue, 28 Aug 2018 06:26:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B5F31C21C29; Tue, 28 Aug 2018 06:25:14 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C202FC21C57; Tue, 28 Aug 2018 06:25:11 +0000 (UTC) Received: from root.phytec.de (mail.visioncatalog.de [217.6.246.34]) by lists.denx.de (Postfix) with ESMTP id 6D8B9C21C29 for ; Tue, 28 Aug 2018 06:25:11 +0000 (UTC) Received: from idefix.phytec.de (idefix.phytec.de [172.16.0.10]) by root.phytec.de (Postfix) with ESMTP id 1B86DA006D7; Tue, 28 Aug 2018 08:25:49 +0200 (CEST) Received: from augenblix.phytec.de ([172.16.0.56]) by idefix.phytec.de (IBM Domino Release 9.0.1FP7) with ESMTP id 2018082808251093-807289 ; Tue, 28 Aug 2018 08:25:10 +0200 From: Janine Hagemann To: u-boot@lists.denx.de, grygorii.strashko@ti.com, albert.u.boot@aribaud.net, sjg@chromium.org, philipp.tomisch@theobram-systems.com, w.egorov@phytec.de, joe.hershberger@ni.com Date: Tue, 28 Aug 2018 08:25:01 +0200 Message-Id: <1535437505-32297-4-git-send-email-j.hagemann@phytec.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535437505-32297-1-git-send-email-j.hagemann@phytec.de> References: <1535437505-32297-1-git-send-email-j.hagemann@phytec.de> X-MIMETrack: Itemize by SMTP Server on Idefix/Phytec(Release 9.0.1FP7|August 17, 2016) at 28.08.2018 08:25:11, Serialize by Router on Idefix/Phytec(Release 9.0.1FP7|August 17, 2016) at 28.08.2018 08:25:11, Serialize complete at 28.08.2018 08:25:11 X-TNEFEvaluated: 1 Subject: [U-Boot] [PATCH v4 3/7] drivers: net: designware: Add reading of DT phy-handle node X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add the ability to read the phy-handle node of the gmac. Upon reading this handle the phy-id can be stored based on the reg node in the DT. The phy-handle also needs to be stored and passed to the phy to access any phy data that is available. Signed-off-by: Janine Hagemann Acked-by: Joe Hershberger --- v4: Change used function from dev_set_of_offset( ) to offset_to_ofnode( ) --- drivers/net/designware.c | 11 ++++++++++- drivers/net/designware.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 19db0a8..bba12f2 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -477,7 +477,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev) { struct phy_device *phydev; int mask = 0xffffffff, ret; - + struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev); #ifdef CONFIG_PHY_ADDR mask = 1 << CONFIG_PHY_ADDR; #endif @@ -496,6 +496,11 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev) } phydev->advertising = phydev->supported; +#ifdef CONFIG_DM_ETH + if (dw_pdata->phy_of_handle) + phydev->node = offset_to_ofnode(dw_pdata->phy_of_handle); +#endif + priv->phydev = phydev; phy_config(phydev); @@ -803,6 +808,7 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev) int reset_flags = GPIOD_IS_OUT; #endif int ret = 0; + int node = dev_of_offset(dev); pdata->iobase = dev_read_addr(dev); pdata->phy_interface = -1; @@ -814,6 +820,9 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev) return -EINVAL; } + dw_pdata->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, node, + "phy-handle"); + pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0); #ifdef CONFIG_DM_GPIO diff --git a/drivers/net/designware.h b/drivers/net/designware.h index dea12b7..a6b0443 100644 --- a/drivers/net/designware.h +++ b/drivers/net/designware.h @@ -255,6 +255,7 @@ extern const struct eth_ops designware_eth_ops; struct dw_eth_pdata { struct eth_pdata eth_pdata; u32 reset_delays[3]; + int phy_of_handle; }; int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr);