From patchwork Thu Sep 19 08:16:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 1164446 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=fail (p=quarantine dis=none) header.from=ti.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="L4nBrlWR"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46YrLd6tYhz9sP3 for ; Thu, 19 Sep 2019 18:56:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 46EEFC21EBD; Thu, 19 Sep 2019 08:17:48 +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=T_DKIM_INVALID 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 04C01C21E70; Thu, 19 Sep 2019 08:17:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id EDC63C21E1D; Thu, 19 Sep 2019 08:17:07 +0000 (UTC) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lists.denx.de (Postfix) with ESMTPS id 3D430C21E50 for ; Thu, 19 Sep 2019 08:17:05 +0000 (UTC) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x8J8H3J2068811; Thu, 19 Sep 2019 03:17:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1568881023; bh=9dQ4dCY4hTfy7PiAdRgKS9YGxQwHVHk+oby42GT7IDI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=L4nBrlWR8UIQBkNMF0ZlcKRZoSSg7RwAH0Lg87f2WHkoeqY3OOA39BOghtK+DAMKL 4hxV6i7LwKxFGmsr222UK2W6cDvj+olwhyXUgKvRFTxljaXB1e0O/045u0BY0FIvxu QBDctrpJ6IxDyrOX5/1NCyPCKXCl3nM+1mne2QHA= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x8J8H3cU116266 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Sep 2019 03:17:03 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 19 Sep 2019 03:16:59 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 19 Sep 2019 03:16:59 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x8J8H1VW020080; Thu, 19 Sep 2019 03:17:02 -0500 From: Grygorii Strashko To: Joe Hershberger , Lokesh Vutla , Tom Rini Date: Thu, 19 Sep 2019 11:16:39 +0300 Message-ID: <20190919081642.21038-4-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919081642.21038-1-grygorii.strashko@ti.com> References: <20190919081642.21038-1-grygorii.strashko@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 3/6] net: ti: cpsw: add support for standard eth "max-speed" dt property 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch adds support for standard Ethernet "max-speed" DT property to allow PHY link speed limitation. Signed-off-by: Grygorii Strashko --- drivers/net/ti/cpsw.c | 15 +++++++++++++++ include/cpsw.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c index 533c167995..24265360e6 100644 --- a/drivers/net/ti/cpsw.c +++ b/drivers/net/ti/cpsw.c @@ -839,6 +839,7 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave) { struct phy_device *phydev; u32 supported = PHY_GBIT_FEATURES; + int ret; phydev = phy_connect(priv->bus, slave->data->phy_addr, @@ -849,6 +850,13 @@ static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave) return -1; phydev->supported &= supported; + if (slave->data->max_speed) { + ret = phy_set_supported(phydev, slave->data->max_speed); + if (ret) + return ret; + dev_dbg(priv->dev, "Port %u speed forced to %uMbit\n", + slave->slave_num + 1, slave->data->max_speed); + } phydev->advertising = phydev->supported; #ifdef CONFIG_DM_ETH @@ -1185,6 +1193,7 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data, struct cpsw_slave_data *slave_data; const void *fdt = gd->fdt_blob; const char *phy_mode; + int max_speed = -1; u32 phy_id[2]; slave_data = &data->slave_data[slave_index]; @@ -1206,6 +1215,12 @@ static void cpsw_eth_of_parse_slave(struct cpsw_platform_data *data, phy_id, 2); slave_data->phy_addr = phy_id[1]; } + + slave_data->max_speed = 0; + max_speed = fdtdec_get_int(fdt, subnode, + "max-speed", max_speed); + if (max_speed > 0) + slave_data->max_speed = max_speed; } static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) diff --git a/include/cpsw.h b/include/cpsw.h index 96ff254f98..c7532fc866 100644 --- a/include/cpsw.h +++ b/include/cpsw.h @@ -39,6 +39,7 @@ struct cpsw_slave_data { int phy_addr; int phy_if; int phy_of_handle; + int max_speed; }; enum {