From patchwork Sat Feb 3 12:16:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wu X-Patchwork-Id: 868889 X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.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=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zYXxQ3nh0z9t5s for ; Sat, 3 Feb 2018 23:20:26 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E30C1C21E18; Sat, 3 Feb 2018 12:18:23 +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=RCVD_IN_DNSWL_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 4E96CC21DD9; Sat, 3 Feb 2018 12:17:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AA5EFC21E5A; Sat, 3 Feb 2018 12:17:04 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.139]) by lists.denx.de (Postfix) with ESMTPS id D2B90C21C8F for ; Sat, 3 Feb 2018 12:16:59 +0000 (UTC) Received: from david.wu?rock-chips.com (unknown [192.168.167.78]) by regular1.263xmail.com (Postfix) with ESMTP id A719D543F; Sat, 3 Feb 2018 20:16:54 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 5DF2F3A6; Sat, 3 Feb 2018 20:16:56 +0800 (CST) X-RL-SENDER: david.wu@rock-chips.com X-FST-TO: philipp.tomsich@theobroma-systems.com X-SENDER-IP: 220.200.40.59 X-LOGIN-NAME: david.wu@rock-chips.com X-UNIQUE-TAG: <318aa1b7637c6cb6ee4be864fc7ef109> X-ATTACHMENT-NUM: 0 X-SENDER: wdc@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [220.200.40.59]) by smtp.263.net (Postfix) whith SMTP id 66260AKIGS; Sat, 03 Feb 2018 20:16:57 +0800 (CST) From: David Wu To: philipp.tomsich@theobroma-systems.com Date: Sat, 3 Feb 2018 20:16:35 +0800 Message-Id: <1517660196-21802-4-git-send-email-david.wu@rock-chips.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517660196-21802-1-git-send-email-david.wu@rock-chips.com> References: <1517660196-21802-1-git-send-email-david.wu@rock-chips.com> Cc: u-boot@lists.denx.de, David Wu Subject: [U-Boot] [PATCH 03/14] net: rockchip: Add integrated phy ops 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" Some rockchio Socs have integrated phy inside, to support it, add the integrated phy ops. Signed-off-by: David Wu Acked-by: Philipp Tomsich --- drivers/net/gmac_rockchip.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/gmac_rockchip.c b/drivers/net/gmac_rockchip.c index 5afc415..bca0a2a 100644 --- a/drivers/net/gmac_rockchip.c +++ b/drivers/net/gmac_rockchip.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,7 @@ #include #include #include +#include #include #include "designware.h" @@ -35,6 +37,8 @@ DECLARE_GLOBAL_DATA_PTR; struct gmac_rockchip_platdata { struct dw_eth_pdata dw_eth_pdata; bool clock_input; + bool integrated_phy; + struct reset_ctl phy_reset; int tx_delay; int rx_delay; }; @@ -46,13 +50,16 @@ struct rk_gmac_ops { struct dw_eth_dev *priv); void (*set_to_rmii)(struct gmac_rockchip_platdata *pdata); void (*set_to_rgmii)(struct gmac_rockchip_platdata *pdata); + void (*integrated_phy_powerup)(struct gmac_rockchip_platdata *pdata); }; static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) { struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev); + struct ofnode_phandle_args args; const char *string; + int ret; string = dev_read_string(dev, "clock_in_out"); if (!strcmp(string, "input")) @@ -60,6 +67,25 @@ static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev) else pdata->clock_input = false; + /* If phy-handle property is passed from DT, use it as the PHY */ + ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, &args); + if (ret) { + debug("Cannot get phy phandle: ret=%d\n", ret); + pdata->integrated_phy = dev_read_bool(dev, "phy-is-integrated"); + } else { + debug("Found phy-handle subnode\n"); + pdata->integrated_phy = ofnode_read_bool(args.node, + "phy-is-integrated"); + } + + if (pdata->integrated_phy) { + ret = reset_get_by_name(dev, "mac-phy", &pdata->phy_reset); + if (ret) { + debug("No PHY reset control found: ret=%d\n", ret); + return ret; + } + } + /* Check the new naming-style first... */ pdata->tx_delay = dev_read_u32_default(dev, "tx_delay", -ENOENT); pdata->rx_delay = dev_read_u32_default(dev, "rx_delay", -ENOENT); @@ -572,6 +598,9 @@ static int gmac_rockchip_probe(struct udevice *dev) if (ret) return ret; + if (pdata->integrated_phy && ops->integrated_phy_powerup) + ops->integrated_phy_powerup(pdata); + switch (eth_pdata->phy_interface) { case PHY_INTERFACE_MODE_RGMII: /*