From patchwork Wed Jun 17 18:20:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 190888 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688664ilo; Wed, 17 Jun 2020 11:21:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxyCGkv/F9CzhbiwhRYYTGHVOEq9ezNoiwrM2qS05QMud5anFmLCVruNzl/Gk9YoQDAxhr X-Received: by 2002:a17:906:bcf3:: with SMTP id op19mr445468ejb.208.1592418073999; Wed, 17 Jun 2020 11:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592418073; cv=none; d=google.com; s=arc-20160816; b=eVDiXR1HkO3bDdL3p3O/ESrNX9NUkIcov5mXNbhht5E7DC2VcV7Lgajk6me7pElIgI Fcz5WpNOqq8zNe9fDWp2BOkMCKZIKyRgazy8N6GiqicN2coPF9B3hjja6D1oK0rsCj8T RL5lDGOsnA50tJHYnSAd8gVT2nWk101TeiT9/6Yp2sMNeejrn5SoITqkbz6EDzbv6z0F DdalTW6VnF1kOsH0rkJJNpAPIwVd62axD3dDE595/n2aN2g/y+vqfpr8c4WHqLDU8lqy RuWKPOvFxcMZ8L1H8BlDlUcyC/Rf7bfjjLGZEerxDipZMeCThZOUR9xrbHnYRBRQLO4Y tS/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Eui6gMDXRbqI+3Gto0iGF+/V7yAE/pLSF5Iag/APeDc=; b=TJdRpECEv+8LxVPUI7yz/HMI5Yx5RZzEqZXHNFfPkRblVb5uizrr1vALnTkLAshBvM 4QaHJaidjztqKc1FWJzEcnBkX0oMeXob0+ZLzrNYcLSMxiksF+4AW8qhvgeWwZEg9bpH ZmapKRrE42e/pApSYBlh6P6s03mTCSo2Mk+70Ogn6bPmqxkeCS7nUAMwi6ah6mGmmy5a cuowcjMGujiJhAmPAiD39ltZfiGbHA3lG0Ve+jXIGdAF0I0NZ5UwjKIu+vQZHhztVm3t QE/Fe0MnO+v4/2lmXcCcN0264bP2yNjddRWKjVei5Qsan2QZeTruW920h/VwR2vdKtLy xUbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xUcCL+V+; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si497831edu.279.2020.06.17.11.21.13; Wed, 17 Jun 2020 11:21:13 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xUcCL+V+; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727772AbgFQSUl (ORCPT + 9 others); Wed, 17 Jun 2020 14:20:41 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:37730 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgFQSUi (ORCPT ); Wed, 17 Jun 2020 14:20:38 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKVbG058170; Wed, 17 Jun 2020 13:20:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1592418031; bh=Eui6gMDXRbqI+3Gto0iGF+/V7yAE/pLSF5Iag/APeDc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xUcCL+V+x8hqpN9oA19mVYO0xxq0P5M7MEHNV3TIcHO5nJh12FYMkzldhQixY+eKG W/uUsQiwFZYYRwxN+T3eKp9cbWrmQc8djYc0tIPQIugI2c1P4fM0J1P3M6OfNWbUgu k1r71OKS7FcHCiP8IgETgL63g0TDlrEksBcs5D9I= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 05HIKV30115931 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Jun 2020 13:20:31 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 17 Jun 2020 13:20:31 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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.1979.3 via Frontend Transport; Wed, 17 Jun 2020 13:20:31 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKV3a064256; Wed, 17 Jun 2020 13:20:31 -0500 From: Dan Murphy To: , , , , CC: , , , Dan Murphy Subject: [PATCH net-next v7 1/6] dt-bindings: net: Add tx and rx internal delays Date: Wed, 17 Jun 2020 13:20:14 -0500 Message-ID: <20200617182019.6790-2-dmurphy@ti.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617182019.6790-1-dmurphy@ti.com> References: <20200617182019.6790-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org tx-internal-delays and rx-internal-delays are a common setting for RGMII capable devices. These properties are used when the phy-mode or phy-controller is set to rgmii-id, rgmii-rxid or rgmii-txid. These modes indicate to the controller that the PHY will add the internal delay for the connection. Signed-off-by: Dan Murphy --- .../devicetree/bindings/net/ethernet-phy.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.26.2 Reviewed-by: Andrew Lunn diff --git a/Documentation/devicetree/bindings/net/ethernet-phy.yaml b/Documentation/devicetree/bindings/net/ethernet-phy.yaml index 9b1f1147ca36..b2887476fe6a 100644 --- a/Documentation/devicetree/bindings/net/ethernet-phy.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-phy.yaml @@ -162,6 +162,17 @@ properties: description: Specifies a reference to a node representing a SFP cage. + + rx-internal-delay-ps: + description: | + RGMII Receive PHY Clock Delay defined in pico seconds. This is used for + PHY's that have configurable RX internal delays. + + tx-internal-delay-ps: + description: | + RGMII Transmit PHY Clock Delay defined in pico seconds. This is used for + PHY's that have configurable TX internal delays. + required: - reg From patchwork Wed Jun 17 18:20:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 190889 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688721ilo; Wed, 17 Jun 2020 11:21:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNJGGLQZ2wEVHeJn2DJm85FiIENFGJGt3iConfiQG4y0PfZJSsNZ6axYi6oMLM45eYJGjj X-Received: by 2002:a17:906:9257:: with SMTP id c23mr462314ejx.86.1592418078842; Wed, 17 Jun 2020 11:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592418078; cv=none; d=google.com; s=arc-20160816; b=OKGC5aoeWPzk0ajAjQc6R9KvFdm8r4O3pT9IAzQeZmLq/tJpIhKgd14Ys7IFHOblQd /w0zvOz0KXMFCFinuhvBC7REaifzFPMPoBd1ov/EUDFpXXUTxL3v6SLiLdVB5uaydllU 6v0otC1hXw6ti9MQvugXEZwRaVrYztPdKMlhjYt/zRMpQNsdQbxXg8k6eqyME0cR2JvO rhVyPF6M03Q0GrmR3TVM2rAaaZF7HWU3ZBzwTMO0ewoRUILtPbFapiZtAE3I9qMckykA Zd2wq1Oxt3QTGgjykpR4P9jueUWwTBYlLJ0ddLW+cXlTIUbAJ4Iq0c1KERKWCFgKBsZb Hgew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZNakNO/yn9w134SOd5ynDhx+3+mu8fsJN9YSibNbl20=; b=G5eP/Ae2UTjNQkPYccV0BVieyZL+LUoJdsYWjcV13B2HzuaD/Fj0s1jAABM47MTbuN maqAYGHMmKlygH116lP15hIIMzYnBJdlmp5rIdnzK7Brq0sqslhg1WHVh38vVQ7LpeXB bXhV5EXDusNNSC4udX6kDEPWqLOoPeCyVvWDW1KM0kMlZS+XDsf9mF/yMrhske9Ch9US yEic3vv6XoO53ZCbZyMhcjttsxHfTaPk9HnIBLaF9cglUqCDcpMCatO2iKSFeENm5ZLH WKrGaFmSZZJLM1InihF83Rr+EjMQJG5MCQvOJkowkfJ4/X0uSccovWI+cSJdpeoem+89 UL5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ir7fAGqY; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f18si377646ejx.476.2020.06.17.11.21.18; Wed, 17 Jun 2020 11:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ir7fAGqY; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727870AbgFQSVO (ORCPT + 9 others); Wed, 17 Jun 2020 14:21:14 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:58074 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727782AbgFQSUo (ORCPT ); Wed, 17 Jun 2020 14:20:44 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKaE4039691; Wed, 17 Jun 2020 13:20:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1592418036; bh=ZNakNO/yn9w134SOd5ynDhx+3+mu8fsJN9YSibNbl20=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ir7fAGqYjfCLlRirA0pQf3ozgPGgdkVp1TWvl33vI40UcEexF++LixsgC7KDKypiB no2IfGSEFofaoYvrbwfeEAftIz2kAk5H1eqfUx+fK85o+jOv5pp1Ghfs7dpjinRkPM xI4PxZB9zyS9tHLUu3DAejyPLsS793SHmK2dsTr8= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 05HIKaNA001355 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Jun 2020 13:20:36 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) 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.1979.3; Wed, 17 Jun 2020 13:20:36 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 17 Jun 2020 13:20:36 -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 05HIKash068354; Wed, 17 Jun 2020 13:20:36 -0500 From: Dan Murphy To: , , , , CC: , , , Dan Murphy Subject: [PATCH net-next v7 2/6] net: phy: Add a helper to return the index for of the internal delay Date: Wed, 17 Jun 2020 13:20:15 -0500 Message-ID: <20200617182019.6790-3-dmurphy@ti.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617182019.6790-1-dmurphy@ti.com> References: <20200617182019.6790-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a helper function that will return the index in the array for the passed in internal delay value. The helper requires the array, size and delay value. The helper will then return the index for the exact match or return the index for the index to the closest smaller value. Signed-off-by: Dan Murphy --- drivers/net/phy/phy_device.c | 68 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 4 +++ 2 files changed, 72 insertions(+) -- 2.26.2 diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 04946de74fa0..611d4e68e3c6 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -31,6 +31,7 @@ #include #include #include +#include MODULE_DESCRIPTION("PHY library"); MODULE_AUTHOR("Andy Fleming"); @@ -2657,6 +2658,73 @@ void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause) } EXPORT_SYMBOL(phy_get_pause); +/** + * phy_get_delay_index - returns the index of the internal delay + * @phydev: phy_device struct + * @dev: pointer to the devices device struct + * @delay_values: array of delays the PHY supports + * @size: the size of the delay array + * @is_rx: boolean to indicate to get the rx internal delay + * + * Returns the index within the array of internal delay passed in. + * Or if size == 0 then the delay read from the firmware is returned. + * The array must be in ascending order. + * Return errno if the delay is invalid or cannot be found. + */ +s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev, + const int *delay_values, int size, bool is_rx) +{ + int ret; + int i; + s32 delay; + + if (is_rx) + ret = device_property_read_u32(dev, "rx-internal-delay-ps", + &delay); + else + ret = device_property_read_u32(dev, "tx-internal-delay-ps", + &delay); + if (ret) { + phydev_err(phydev, "internal delay not defined\n"); + return -EINVAL; + } + + if (delay < 0) + return -EINVAL; + + if (size <= 0) + return delay; + + if (delay < delay_values[0] || delay > delay_values[size - 1]) { + phydev_err(phydev, "Delay %d is out of range\n", delay); + return -EINVAL; + } + + if (delay == delay_values[0]) + return 0; + + for (i = 1; i < size; i++) { + if (delay == delay_values[i]) + return i; + + /* Find an approximate index by looking up the table */ + if (delay > delay_values[i - 1] && + delay < delay_values[i]) { + if (delay - delay_values[i - 1] < + delay_values[i] - delay) + return i - 1; + else + return i; + } + } + + phydev_err(phydev, "error finding internal delay index for %d\n", + delay); + + return -EINVAL; +} +EXPORT_SYMBOL(phy_get_internal_delay); + static bool phy_drv_supports_irq(struct phy_driver *phydrv) { return phydrv->config_intr && phydrv->ack_interrupt; diff --git a/include/linux/phy.h b/include/linux/phy.h index 8c05d0fb5c00..917bfd422e06 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1430,6 +1430,10 @@ void phy_set_asym_pause(struct phy_device *phydev, bool rx, bool tx); bool phy_validate_pause(struct phy_device *phydev, struct ethtool_pauseparam *pp); void phy_get_pause(struct phy_device *phydev, bool *tx_pause, bool *rx_pause); + +s32 phy_get_internal_delay(struct phy_device *phydev, struct device *dev, + const int *delay_values, int size, bool is_rx); + void phy_resolve_pause(unsigned long *local_adv, unsigned long *partner_adv, bool *tx_pause, bool *rx_pause); From patchwork Wed Jun 17 18:20:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 190884 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688295ilo; Wed, 17 Jun 2020 11:20:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXtg0JpxHM5IiIT4OikS/yCX8uRDS05WtmjvslVdYWjGy45VSzs/+CzvYxgu/TrCldZomE X-Received: by 2002:a17:906:ae14:: with SMTP id le20mr382825ejb.307.1592418047514; Wed, 17 Jun 2020 11:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592418047; cv=none; d=google.com; s=arc-20160816; b=ujcB/UTbHaw4F0UhBpojHgm5CJxav/+AdkjCo9/PvsseR4hDod6xyNEVjbVBjkKkxr pNwZMI3u8/CQzKWOL0+gi6/lKReU3y8hdtr4fGlDbRZ2QYadUEEWDPVMDPhQiYJO88QP uSMXecAeWGkFHT61sp/bIUeA0SoRIsi3onQ4TtnJnQ6InQtiLV9RTzCDW5+H4XdLwNHp ivrscK2gEeLVEyqP7HXCWBItZtbQxNYpfIgYVSZLIuSzCvvn+r7HpWweON/eAIjPc7r/ Fy4QM+MVQTghUEA8RzuDNYFbUfEvjEeu79Ln7S3jyoBQbQ7MiSopVMg4gE6b3JDiwvK8 UdKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eShyx82GLaQ3xsgsj9ve463coidBb5dHGAfrzfcrN0w=; b=nXnfhwjFBw2wGOsn78vgN4Qm7Wbh6O+RrEelyXNqNhBkP3nFZJVR7ucDGojwZsmaui jpvTGI+8D+gSk3mbiG/TMsOfaF1SgWD1pMsvAgkl7Cj8m9wwZAlugZDbDOWU6urMwmJi rqJzWlStSjSRp8XKbzWUIya3STHY8WT4R6IiAQLL+ZEHv0YqxHUL3e1gYxkomvqFue+l HWytUPi6ECyQVG2hrS6fGYSEPXshcWZJTJ0NDXmz6mXeRROvh3ihF2xhm0rzn1KGTNHg 9jg6CryBJyw+2xGcAIGZ+RbX6tandO3vBgSBNMiYI9nmVsK3VIiK6AK6/1g36S683Qz0 3YAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CuhflzfH; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gl21si362791ejb.739.2020.06.17.11.20.47; Wed, 17 Jun 2020 11:20:47 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=CuhflzfH; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727797AbgFQSUq (ORCPT + 9 others); Wed, 17 Jun 2020 14:20:46 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:58076 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727783AbgFQSUn (ORCPT ); Wed, 17 Jun 2020 14:20:43 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKbrb039695; Wed, 17 Jun 2020 13:20:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1592418037; bh=eShyx82GLaQ3xsgsj9ve463coidBb5dHGAfrzfcrN0w=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=CuhflzfH3KGtts3hBJp6xAbsM+VP1UrLxbm3Q575CuspRCdiTJtUcIC+4bcdsFqkH n5ECLwVgizVW2CDGO/6Wl4ZIA24JFwf6IQ9XkxMFjZ0I6xiL7YtAMcDgiHo4GfjqrH qVyCSjFRsKBJJDgvMMVwC0TSukJZACDDPzRWwwro= Received: from DFLE113.ent.ti.com (dfle113.ent.ti.com [10.64.6.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 05HIKab0115987 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Jun 2020 13:20:37 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE113.ent.ti.com (10.64.6.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 17 Jun 2020 13:20:36 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 17 Jun 2020 13:20:36 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKaUC129480; Wed, 17 Jun 2020 13:20:36 -0500 From: Dan Murphy To: , , , , CC: , , , Dan Murphy Subject: [PATCH net-next v7 3/6] dt-bindings: net: Add RGMII internal delay for DP83869 Date: Wed, 17 Jun 2020 13:20:16 -0500 Message-ID: <20200617182019.6790-4-dmurphy@ti.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617182019.6790-1-dmurphy@ti.com> References: <20200617182019.6790-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add the internal delay values into the header and update the binding with the internal delay properties. Signed-off-by: Dan Murphy --- .../devicetree/bindings/net/ti,dp83869.yaml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.26.2 diff --git a/Documentation/devicetree/bindings/net/ti,dp83869.yaml b/Documentation/devicetree/bindings/net/ti,dp83869.yaml index 5b69ef03bbf7..71e90a3e4652 100644 --- a/Documentation/devicetree/bindings/net/ti,dp83869.yaml +++ b/Documentation/devicetree/bindings/net/ti,dp83869.yaml @@ -8,7 +8,7 @@ $schema: "http://devicetree.org/meta-schemas/core.yaml#" title: TI DP83869 ethernet PHY allOf: - - $ref: "ethernet-controller.yaml#" + - $ref: "ethernet-phy.yaml#" maintainers: - Dan Murphy @@ -64,6 +64,18 @@ properties: Operational mode for the PHY. If this is not set then the operational mode is set by the straps. see dt-bindings/net/ti-dp83869.h for values + rx-internal-delay-ps: + description: Delay is in pico seconds + enum: [ 250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, + 3250, 3500, 3750, 4000 ] + default: 2000 + + tx-internal-delay-ps: + description: Delay is in pico seconds + enum: [ 250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, + 3250, 3500, 3750, 4000 ] + default: 2000 + required: - reg @@ -80,5 +92,7 @@ examples: ti,op-mode = ; ti,max-output-impedance = "true"; ti,clk-output-sel = ; + rx-internal-delay-ps = <2000>; + tx-internal-delay-ps = <2000>; }; }; From patchwork Wed Jun 17 18:20:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 190885 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688411ilo; Wed, 17 Jun 2020 11:20:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwKwfI3kQN3fSHKjigkNOy4UTFpbIjNm9Cxjbt+Dg6iNlqyAROW8lIdgOr+H6DTIqnW7Cj X-Received: by 2002:a50:951d:: with SMTP id u29mr406673eda.333.1592418055944; Wed, 17 Jun 2020 11:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592418055; cv=none; d=google.com; s=arc-20160816; b=OyuVehL4AZ/iUDgfBVpcZPUd5CSC6aqdGpp7poDN+hB0CmRkssJq7K3fLGRkL3B3PM hUeBr3ww0pYqBDUgCrrzgzGfQOjutM4YyGgmppFoxH+EODczGKa71EaZtiPmKWFX4Jix U7WvUkq2vVgbiIuDHXIhoXC1kJM0WwCgb3puRJ0zZr1RB4uSaLPYK7l93IUKhPF7T5Bt 10/kAs0FU4E/lDDPplb8aUKZGwW4dfiVeLAGj+ldZNbSnnU4FNkE4Jel7uOLXI7wB4KE Y41S8mPsG0XqREh9+wfHJwNsH9w2E+dXo5QXG/9iOQGkA86BBYOJP2OgfJnbDwWcA23r phQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8ldmEbdRdqBSmsWutIagzim4imJTiXwBunnkDlcTWn0=; b=kYZ2MsRLQO5FyoLiq0Bc1E+7Vutjb5ZEYJ2ubqS1OPTZbR3ClIb6u6p4E/LsT4aftO WBwkGBH0mCs39MFPhzk/RwNBud5NQSxXRL6HZjZY4CJAYlS7rZRl4bxhRlhTsvAfMMks FGEIhV7D3eDy6gmT8Zcw7KemKQsTQsFDm9BBuqOyR5Xz0hzgBnQ9/29+h/hH8rNml3IU b4F6ekE9umvJ8akf57/rJPfZAUUv1GVM8px5F9XygxR6IBDKkqghkDcDyB3rvnBGo2Sb m2Atalqw6fkY7BoieWW0UgODGayzD2elujWXpqAvYbgaDaP+x0w2OIZn81Ho3FmnsaIC kPJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=tCyy2klQ; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si426916edq.475.2020.06.17.11.20.55; Wed, 17 Jun 2020 11:20:55 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=tCyy2klQ; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727818AbgFQSUv (ORCPT + 9 others); Wed, 17 Jun 2020 14:20:51 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:37746 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgFQSUt (ORCPT ); Wed, 17 Jun 2020 14:20:49 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKg5J058195; Wed, 17 Jun 2020 13:20:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1592418042; bh=8ldmEbdRdqBSmsWutIagzim4imJTiXwBunnkDlcTWn0=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=tCyy2klQXRtteVGDfkk9dqtH9pkNeRaASXemFHjqgt4EpPTvXP0fViPQZLqXygf/E ATsQTJ0V+Rcvu0gQROBbJydB03Yyz84NEolSO6BEwE7VTfIRCG9JQYcZJZdm+LiFqF ooLmEasEAuEbEDtof5f7MXAAySU8VKRFSPXzAMHs= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 05HIKgaA001427 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Jun 2020 13:20:42 -0500 Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 17 Jun 2020 13:20:42 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 17 Jun 2020 13:20:41 -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 05HIKfCn068419; Wed, 17 Jun 2020 13:20:41 -0500 From: Dan Murphy To: , , , , CC: , , , Dan Murphy Subject: [PATCH net-next v7 4/6] net: dp83869: Add RGMII internal delay configuration Date: Wed, 17 Jun 2020 13:20:17 -0500 Message-ID: <20200617182019.6790-5-dmurphy@ti.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617182019.6790-1-dmurphy@ti.com> References: <20200617182019.6790-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add RGMII internal delay configuration for Rx and Tx. Signed-off-by: Dan Murphy --- drivers/net/phy/dp83869.c | 53 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) -- 2.26.2 diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c index 53ed3abc26c9..2c651bcc440d 100644 --- a/drivers/net/phy/dp83869.c +++ b/drivers/net/phy/dp83869.c @@ -64,6 +64,10 @@ #define DP83869_RGMII_TX_CLK_DELAY_EN BIT(1) #define DP83869_RGMII_RX_CLK_DELAY_EN BIT(0) +/* RGMIIDCTL */ +#define DP83869_RGMII_CLK_DELAY_SHIFT 4 +#define DP83869_CLK_DELAY_DEF 7 + /* STRAP_STS1 bits */ #define DP83869_STRAP_OP_MODE_MASK GENMASK(2, 0) #define DP83869_STRAP_STS1_RESERVED BIT(11) @@ -78,9 +82,6 @@ #define DP83869_PHYCR_FIFO_DEPTH_MASK GENMASK(15, 12) #define DP83869_PHYCR_RESERVED_MASK BIT(11) -/* RGMIIDCTL bits */ -#define DP83869_RGMII_TX_CLK_DELAY_SHIFT 4 - /* IO_MUX_CFG bits */ #define DP83869_IO_MUX_CFG_IO_IMPEDANCE_CTRL 0x1f @@ -99,6 +100,10 @@ #define DP83869_OP_MODE_MII BIT(5) #define DP83869_SGMII_RGMII_BRIDGE BIT(6) +static const int dp83869_internal_delay[] = {250, 500, 750, 1000, 1250, 1500, + 1750, 2000, 2250, 2500, 2750, 3000, + 3250, 3500, 3750, 4000}; + enum { DP83869_PORT_MIRRORING_KEEP, DP83869_PORT_MIRRORING_EN, @@ -108,6 +113,8 @@ enum { struct dp83869_private { int tx_fifo_depth; int rx_fifo_depth; + s32 rx_int_delay; + s32 tx_int_delay; int io_impedance; int port_mirroring; bool rxctrl_strap_quirk; @@ -182,6 +189,7 @@ static int dp83869_of_init(struct phy_device *phydev) struct dp83869_private *dp83869 = phydev->priv; struct device *dev = &phydev->mdio.dev; struct device_node *of_node = dev->of_node; + int delay_size = ARRAY_SIZE(dp83869_internal_delay); int ret; if (!of_node) @@ -235,6 +243,20 @@ static int dp83869_of_init(struct phy_device *phydev) &dp83869->tx_fifo_depth)) dp83869->tx_fifo_depth = DP83869_PHYCR_FIFO_DEPTH_4_B_NIB; + dp83869->rx_int_delay = phy_get_internal_delay(phydev, dev, + &dp83869_internal_delay[0], + delay_size, true); + if (dp83869->rx_int_delay < 0) + dp83869->rx_int_delay = + dp83869_internal_delay[DP83869_CLK_DELAY_DEF]; + + dp83869->tx_int_delay = phy_get_internal_delay(phydev, dev, + &dp83869_internal_delay[0], + delay_size, false); + if (dp83869->tx_int_delay < 0) + dp83869->tx_int_delay = + dp83869_internal_delay[DP83869_CLK_DELAY_DEF]; + return ret; } #else @@ -397,6 +419,31 @@ static int dp83869_config_init(struct phy_device *phydev) dp83869->clk_output_sel << DP83869_IO_MUX_CFG_CLK_O_SEL_SHIFT); + if (phy_interface_is_rgmii(phydev)) { + ret = phy_write_mmd(phydev, DP83869_DEVADDR, DP83869_RGMIIDCTL, + dp83869->rx_int_delay | + dp83869->tx_int_delay << DP83869_RGMII_CLK_DELAY_SHIFT); + if (ret) + return ret; + + val = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_RGMIICTL); + val &= ~(DP83869_RGMII_TX_CLK_DELAY_EN | + DP83869_RGMII_RX_CLK_DELAY_EN); + + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) + val |= (DP83869_RGMII_TX_CLK_DELAY_EN | + DP83869_RGMII_RX_CLK_DELAY_EN); + + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) + val |= DP83869_RGMII_TX_CLK_DELAY_EN; + + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) + val |= DP83869_RGMII_RX_CLK_DELAY_EN; + + ret = phy_write_mmd(phydev, DP83869_DEVADDR, DP83869_RGMIICTL, + val); + } + return ret; } From patchwork Wed Jun 17 18:20:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 190886 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688454ilo; Wed, 17 Jun 2020 11:20:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxu0uPhSSyf0AGbM6jDk5xbkPB4z9pdEnF5dvTqWVN6ricDNW463xHSd0nmZZRzk3VWElyK X-Received: by 2002:a17:906:4c81:: with SMTP id q1mr401186eju.273.1592418059009; Wed, 17 Jun 2020 11:20:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592418059; cv=none; d=google.com; s=arc-20160816; b=PnFCR/rpbs+ZfFOQ1S/VBKSy9RDBbfLIdq+Y4YXvH9Lgi7nPKtmgDazvNmTYRShdbn h1AuHIW+MLLIttMM+fAYBVm+1YCv6PNzeszUGySUtYLWgaPL+U5iPpHQfw+DwElrskdF ACOequOtyxtkz8n54oIyzUyBednADX8WnAaKPzxJVVLZtdfVFxukgR3dVDlY5IJDrmKB 0/VWT7VnFfS2V6DJKvsvQMHXX0OELbrU/fBtHNMSIBHiSrlebVfMNVqR1aklZJhlHjRR KblZBN/ORR6bi5vLYJ26cI5o585yjqNISVRGn4x9Ap0sxiZF31WUjCd2HLm/o7CsmQpO Bxgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9YzsGgvzf8JqwO3Rel1UX3fG2CArvUoADEzxwh+jRns=; b=IfVuLZdvGysqcIvM574EbYqyC5DCvwOe1ZXbf+2rZNGOs27wcgdvs4CRKSVUa1bqhb v6dkPtSzniDeRCqY3uPt7vupPvO9DwTXbSnZ+bU/U0l/uNxNLKTrUQWXorvh5MLFzq21 cbbre7lEZybXOGiVUzw46ozbGA07L9LhppvDkkGD4X5h9gV2eedujw2Y4jCED8CyAHPj LQv9xlKSl/AE/ubq09ufToBjofwuxsz3AOmW6loLXofLoJ698kG6rDSmf+4aBAh27hY/ yRDJSqf95X5vZw+3k3Iprn9UyFJYNIiHABL7jC5bLO+e4is8TrOvBYgr+UoM6mJevzum T3Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ID1EvhNo; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si426916edq.475.2020.06.17.11.20.58; Wed, 17 Jun 2020 11:20:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ID1EvhNo; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727833AbgFQSU4 (ORCPT + 9 others); Wed, 17 Jun 2020 14:20:56 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:51610 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgFQSUz (ORCPT ); Wed, 17 Jun 2020 14:20:55 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKlau058353; Wed, 17 Jun 2020 13:20:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1592418047; bh=9YzsGgvzf8JqwO3Rel1UX3fG2CArvUoADEzxwh+jRns=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ID1EvhNoBZ5WzZrXWjfC27EQB1VHfWa4hlNkAhytWMjKuebDV7u9bU4oyJKJEyK7O i/tirq5iqf2HBv9k3rg6tPueLW2EBk2kqBsybzCdtm8HgJvhjEOovWqDhnMudR4AYl y9qrRhkblZ8sinZ67k6TgAqMnAwU6RT2wXaET6Bs= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 05HIKlDR116158 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Jun 2020 13:20:47 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 17 Jun 2020 13:20:47 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 17 Jun 2020 13:20:47 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKlL8129580; Wed, 17 Jun 2020 13:20:47 -0500 From: Dan Murphy To: , , , , CC: , , , Dan Murphy Subject: [PATCH net-next v7 5/6] dt-bindings: net: dp83822: Add TI dp83822 phy Date: Wed, 17 Jun 2020 13:20:18 -0500 Message-ID: <20200617182019.6790-6-dmurphy@ti.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617182019.6790-1-dmurphy@ti.com> References: <20200617182019.6790-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a dt binding for the TI dp83822 ethernet phy device. Signed-off-by: Dan Murphy --- .../devicetree/bindings/net/ti,dp83822.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ti,dp83822.yaml -- 2.26.2 Reviewed-by: Rob Herring diff --git a/Documentation/devicetree/bindings/net/ti,dp83822.yaml b/Documentation/devicetree/bindings/net/ti,dp83822.yaml new file mode 100644 index 000000000000..09e0e5fd88e3 --- /dev/null +++ b/Documentation/devicetree/bindings/net/ti,dp83822.yaml @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0+ OR BSD-2-Clause) +# Copyright (C) 2020 Texas Instruments Incorporated +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/net/ti,dp83822.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: TI DP83822 ethernet PHY + +allOf: + - $ref: "ethernet-phy.yaml#" + +maintainers: + - Dan Murphy + +description: | + The DP83822 is a low-power, single-port, 10/100 Mbps Ethernet PHY. It + provides all of the physical layer functions needed to transmit and receive + data over standard, twisted-pair cables or to connect to an external, + fiber-optic transceiver. Additionally, the DP83822 provides flexibility to + connect to a MAC through a standard MII, RMII, or RGMII interface + + Specifications about the charger can be found at: + http://www.ti.com/lit/ds/symlink/dp83822i.pdf + +properties: + reg: + maxItems: 1 + + rx-internal-delay-ps: + description: Enables the RX fixed internal delay of 3.5ns. + default: 3500 + + tx-internal-delay-ps: + description: Enables the TX fixed internal delay of 3.5ns. + default: 3500 + +required: + - reg + +examples: + - | + mdio0 { + #address-cells = <1>; + #size-cells = <0>; + ethphy0: ethernet-phy@0 { + reg = <0>; + rx-internal-delay-ps = <3500>; + tx-internal-delay-ps = <3500>; + }; + }; From patchwork Wed Jun 17 18:20:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Murphy X-Patchwork-Id: 190887 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp688502ilo; Wed, 17 Jun 2020 11:21:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiHR0lGl6y3ReG/26H2GI57wbDZbnh/dkIPE29dPt/1wkayucmgGx96gI2RQF0JNEIgHc8 X-Received: by 2002:a05:6402:b37:: with SMTP id bo23mr489194edb.24.1592418063484; Wed, 17 Jun 2020 11:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592418063; cv=none; d=google.com; s=arc-20160816; b=Pwjo5cqPWrOXhMywb6s4SRGnwCh+JKcmWbcQg8LslTELvJnpYO8z1obOguZDoXJo8F EIItBbLuu/SPsqEPuj7ONpN9v1rREtriwXcOD7ATkZv9VQccqdXkX/QwTZbmz8gzsOfn y1Z6sh0BlZ4d4ZdDy4En/0qVZm5chtU/YpQZo6iMrrIDA3n8yeURp1s9f/SUpWLVrgHt 2DAATjsr+8q9xhZyOwqQU3xZkUosxmSYfzTjaVOdtukSYSpCWNi27LyL1cnAFyekseUn EuthqUh2fNIZPHkna75zH6x0xdJrZ43WZcOIlgaCm5pZTd/KyY5m3/bSd5gFf/ESHUPA 8G4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q18jyvzqApf66tsiB+/Qj+MdPJclLJLBC0R/semOBOI=; b=D8CQhw2ctir0QU79mKGe0GBqfVVU0aOG9XL0GGMTNOIqh0QtdMOvCYCaB06mm4lVpw F29CUaXVZlZRPqxEW7k6enuUJ8fvEiB1DLqMcXrmU+MMjZckda2i8/AA7njhQPnlsdJv NBxeeaURu0HA18yJt8O+sHDtpo5rVRom6SJyOqSUBfbVvulzR6KZCa4Zmj7ehC+kMyDk Pe5hHeNsSBrksKoHqIrvLi+FQc/2r4XHi4o2W/34ybfHIHAQE+Bl1Xfqe155x4Jb01Er x1gptVds4EIA9GxS4cK7bwIFSnnDPjLAN7iFTMEytDCfTpME4tpzDaqfbZaC0Bmrcul/ WXlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BeVPW8aX; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si426916edq.475.2020.06.17.11.21.03; Wed, 17 Jun 2020 11:21:03 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BeVPW8aX; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbgFQSVA (ORCPT + 9 others); Wed, 17 Jun 2020 14:21:00 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:37796 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgFQSU6 (ORCPT ); Wed, 17 Jun 2020 14:20:58 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05HIKq4r013011; Wed, 17 Jun 2020 13:20:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1592418052; bh=q18jyvzqApf66tsiB+/Qj+MdPJclLJLBC0R/semOBOI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BeVPW8aXQ7RpHNo+w/QNO14rDd2iHW51ds6LC30NWrWNVuL6MxwOeaF0y5TAYvkwg c3GmSGDSIm5rLo7xzEeya6iB8QjWsGuisZ6SmGD/aYhgxYyiZIotV78bd/J/IEtraz 3AEmXafbCYo51XmTDFIR3MvOVxzTAoIWXbsGcd8c= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 05HIKqQa001494 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 17 Jun 2020 13:20:52 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 17 Jun 2020 13:20:52 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Wed, 17 Jun 2020 13:20:52 -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 05HIKqxC068519; Wed, 17 Jun 2020 13:20:52 -0500 From: Dan Murphy To: , , , , CC: , , , Dan Murphy Subject: [PATCH net-next v7 6/6] net: phy: DP83822: Add ability to advertise Fiber connection Date: Wed, 17 Jun 2020 13:20:19 -0500 Message-ID: <20200617182019.6790-7-dmurphy@ti.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200617182019.6790-1-dmurphy@ti.com> References: <20200617182019.6790-1-dmurphy@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The DP83822 can be configured to use the RGMII interface. There are independent fixed 3.5ns clock shift (aka internal delay) for the TX and RX paths. This allow either one to be set if the MII interface is RGMII and the value is set in the firmware node. Signed-off-by: Dan Murphy --- drivers/net/phy/dp83822.c | 108 +++++++++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 8 deletions(-) -- 2.26.2 diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index 1dd19d0cb269..49574c3df9ca 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -26,7 +26,9 @@ #define MII_DP83822_PHYSCR 0x11 #define MII_DP83822_MISR1 0x12 #define MII_DP83822_MISR2 0x13 +#define MII_DP83822_RCSR 0x17 #define MII_DP83822_RESET_CTRL 0x1f +#define MII_DP83822_GENCFG 0x465 #define DP83822_HW_RESET BIT(15) #define DP83822_SW_RESET BIT(14) @@ -77,6 +79,15 @@ #define DP83822_WOL_INDICATION_SEL BIT(8) #define DP83822_WOL_CLR_INDICATION BIT(11) +/* RSCR bits */ +#define DP83822_RX_CLK_SHIFT BIT(12) +#define DP83822_TX_CLK_SHIFT BIT(11) + +struct dp83822_private { + int rx_int_delay; + int tx_int_delay; +}; + static int dp83822_ack_interrupt(struct phy_device *phydev) { int err; @@ -255,7 +266,7 @@ static int dp83822_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_DP83822_PHYSCR, physcr_status); } -static int dp83822_config_init(struct phy_device *phydev) +static int dp8382x_disable_wol(struct phy_device *phydev) { int value = DP83822_WOL_EN | DP83822_WOL_MAGIC_EN | DP83822_WOL_SECURE_ON; @@ -264,6 +275,32 @@ static int dp83822_config_init(struct phy_device *phydev) MII_DP83822_WOL_CFG, value); } +static int dp83822_config_init(struct phy_device *phydev) +{ + struct dp83822_private *dp83822 = phydev->priv; + int rgmii_delay; + int err = 0; + + if (phy_interface_is_rgmii(phydev)) { + if (dp83822->rx_int_delay) + rgmii_delay = DP83822_RX_CLK_SHIFT; + + if (dp83822->tx_int_delay) + rgmii_delay |= DP83822_TX_CLK_SHIFT; + + if (rgmii_delay) + err = phy_set_bits_mmd(phydev, DP83822_DEVADDR, + MII_DP83822_RCSR, rgmii_delay); + } + + return dp8382x_disable_wol(phydev); +} + +static int dp8382x_config_init(struct phy_device *phydev) +{ + return dp8382x_disable_wol(phydev); +} + static int dp83822_phy_reset(struct phy_device *phydev) { int err; @@ -272,7 +309,46 @@ static int dp83822_phy_reset(struct phy_device *phydev) if (err < 0) return err; - dp83822_config_init(phydev); + return phydev->drv->config_init(phydev); +} + +#ifdef CONFIG_OF_MDIO +static int dp83822_of_init(struct phy_device *phydev) +{ + struct dp83822_private *dp83822 = phydev->priv; + struct device *dev = &phydev->mdio.dev; + + dp83822->rx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, + true); + if (dp83822->rx_int_delay < 0) + dp83822->rx_int_delay = 0; + + dp83822->tx_int_delay = phy_get_internal_delay(phydev, dev, NULL, 0, + false); + if (dp83822->tx_int_delay < 0) + dp83822->tx_int_delay = 0; + + return 0; +} +#else +static int dp83822_of_init(struct phy_device *phydev) +{ + return 0; +} +#endif /* CONFIG_OF_MDIO */ + +static int dp83822_probe(struct phy_device *phydev) +{ + struct dp83822_private *dp83822; + + dp83822 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83822), + GFP_KERNEL); + if (!dp83822) + return -ENOMEM; + + phydev->priv = dp83822; + + dp83822_of_init(phydev); return 0; } @@ -308,6 +384,7 @@ static int dp83822_resume(struct phy_device *phydev) PHY_ID_MATCH_MODEL(_id), \ .name = (_name), \ /* PHY_BASIC_FEATURES */ \ + .probe = dp83822_probe, \ .soft_reset = dp83822_phy_reset, \ .config_init = dp83822_config_init, \ .get_wol = dp83822_get_wol, \ @@ -318,14 +395,29 @@ static int dp83822_resume(struct phy_device *phydev) .resume = dp83822_resume, \ } +#define DP8382X_PHY_DRIVER(_id, _name) \ + { \ + PHY_ID_MATCH_MODEL(_id), \ + .name = (_name), \ + /* PHY_BASIC_FEATURES */ \ + .soft_reset = dp83822_phy_reset, \ + .config_init = dp8382x_config_init, \ + .get_wol = dp83822_get_wol, \ + .set_wol = dp83822_set_wol, \ + .ack_interrupt = dp83822_ack_interrupt, \ + .config_intr = dp83822_config_intr, \ + .suspend = dp83822_suspend, \ + .resume = dp83822_resume, \ + } + static struct phy_driver dp83822_driver[] = { DP83822_PHY_DRIVER(DP83822_PHY_ID, "TI DP83822"), - DP83822_PHY_DRIVER(DP83825I_PHY_ID, "TI DP83825I"), - DP83822_PHY_DRIVER(DP83826C_PHY_ID, "TI DP83826C"), - DP83822_PHY_DRIVER(DP83826NC_PHY_ID, "TI DP83826NC"), - DP83822_PHY_DRIVER(DP83825S_PHY_ID, "TI DP83825S"), - DP83822_PHY_DRIVER(DP83825CM_PHY_ID, "TI DP83825M"), - DP83822_PHY_DRIVER(DP83825CS_PHY_ID, "TI DP83825CS"), + DP8382X_PHY_DRIVER(DP83825I_PHY_ID, "TI DP83825I"), + DP8382X_PHY_DRIVER(DP83826C_PHY_ID, "TI DP83826C"), + DP8382X_PHY_DRIVER(DP83826NC_PHY_ID, "TI DP83826NC"), + DP8382X_PHY_DRIVER(DP83825S_PHY_ID, "TI DP83825S"), + DP8382X_PHY_DRIVER(DP83825CM_PHY_ID, "TI DP83825M"), + DP8382X_PHY_DRIVER(DP83825CS_PHY_ID, "TI DP83825CS"), }; module_phy_driver(dp83822_driver);