From patchwork Tue May 21 22:47:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1103033 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Udmm5yg/"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 457rWJ1dJfz9s55 for ; Wed, 22 May 2019 08:47:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727622AbfEUWre (ORCPT ); Tue, 21 May 2019 18:47:34 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45780 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbfEUWrc (ORCPT ); Tue, 21 May 2019 18:47:32 -0400 Received: by mail-pg1-f195.google.com with SMTP id i21so217561pgi.12; Tue, 21 May 2019 15:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KPCQBC1rKCqFaAEIlFwql0LyVN8PELXsYd3kP67cssk=; b=Udmm5yg/ApuyfLp1rRhOukwfN3Z9W3ShMpcZwtqm2cs9ZXzod2Pv+fW2gZ28PxfdZQ 4mmVi0pDzcNoC6e6IAU/M2C/AeCrtqPc8VsWiKVvRpRRRdmZJtixFkGMI4BR4Ri8mmWZ CL5qXZ1ugdMbGhR/ojayD0xEFdXiEVaWWiMCo08bmYYRowQLt/Cl/IhKtfjDIolOTTdQ fTp/66eVCYsm5/8skT+dALrkXytWhwPUdVwItzoBvfOD10p6uBCpvjOElB/LHtDqQAUM dnYYGNIb5GsbdRe0VSxuGdGenEa2Z2C1FVVLKJOBtKhtOACaqLeHD1GpS1my3271NYkr WTvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KPCQBC1rKCqFaAEIlFwql0LyVN8PELXsYd3kP67cssk=; b=Crdg2mcgtTapGftZP/najrma70b8jMSsekuRiv4aq58hECBde1mrThL4gI2+xPLR2z 6d+XxK+SCEPHGNceBiBoS8kSXy1ZBc2SctKQPBSklNnkxpNUwMxDMARJadYW76JZXTQl AvyNH4szpeq/9yNWkqaeqlGxf9KXICn0aUh0PKW2k0eghcg6kxs2B6wV7yGffIlH0QJZ xSqCgQNB6IwqTdwguRXX7YYS8iB+gm+oLW85EUyhVbU9Doq/Ip+ktVewKgsAqxM7OUmw KIseSGMLnNrg6eMD7kpeFD1O8ekPmyiLFQLvynKgjvQK3wUeHJV3YayBJtC3B2gt/RdJ MTBA== X-Gm-Message-State: APjAAAUd+bU0akzSuvNOGWqyBBkH4ZBYAGP/cSTg02Q1i54f49Ugc/Cj wppnEso+tY4ZzvVrSIRb4w5agXW5 X-Google-Smtp-Source: APXvYqwVgHuPi6mP4qCf1V2SDZ7DbdqQSVsYuQJHxDAiyWa2o5ODHQb0rQCwxoDwOUSVIhc1M56GPw== X-Received: by 2002:a62:2b94:: with SMTP id r142mr483032pfr.184.1558478851080; Tue, 21 May 2019 15:47:31 -0700 (PDT) Received: from localhost.localdomain (c-73-222-71-142.hsd1.ca.comcast.net. [73.222.71.142]) by smtp.gmail.com with ESMTPSA id r29sm34122419pgn.14.2019.05.21.15.47.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 15:47:30 -0700 (PDT) From: Richard Cochran To: netdev@vger.kernel.org Cc: David Miller , devicetree@vger.kernel.org, Andrew Lunn , Florian Fainelli , Jacob Keller , Mark Rutland , Miroslav Lichvar , Rob Herring , Willem de Bruijn Subject: [PATCH V3 net-next 4/6] dt-bindings: ptp: Introduce MII time stamping devices. Date: Tue, 21 May 2019 15:47:21 -0700 Message-Id: <20190521224723.6116-5-richardcochran@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This patch add a new binding that allows non-PHY MII time stamping devices to find their buses. The new documentation covers both the generic binding and one upcoming user. Signed-off-by: Richard Cochran Reviewed-by: Andrew Lunn --- Documentation/devicetree/bindings/ptp/ptp-ines.txt | 35 ++++++++++++++++++ .../devicetree/bindings/ptp/timestamper.txt | 41 ++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/ptp/ptp-ines.txt create mode 100644 Documentation/devicetree/bindings/ptp/timestamper.txt diff --git a/Documentation/devicetree/bindings/ptp/ptp-ines.txt b/Documentation/devicetree/bindings/ptp/ptp-ines.txt new file mode 100644 index 000000000000..4dee9eb89455 --- /dev/null +++ b/Documentation/devicetree/bindings/ptp/ptp-ines.txt @@ -0,0 +1,35 @@ +ZHAW InES PTP time stamping IP core + +The IP core needs two different kinds of nodes. The control node +lives somewhere in the memory map and specifies the address of the +control registers. There can be up to three port handles placed as +attributes of PHY nodes. These associate a particular MII bus with a +port index within the IP core. + +Required properties of the control node: + +- compatible: "ines,ptp-ctrl" +- reg: physical address and size of the register bank + +Required format of the port handle within the PHY node: + +- timestamper: provides control node reference and + the port channel within the IP core + +Example: + + tstamper: timestamper@60000000 { + compatible = "ines,ptp-ctrl"; + reg = <0x60000000 0x80>; + }; + + ethernet@80000000 { + ... + mdio { + ... + phy@3 { + ... + timestamper = <&tstamper 0>; + }; + }; + }; diff --git a/Documentation/devicetree/bindings/ptp/timestamper.txt b/Documentation/devicetree/bindings/ptp/timestamper.txt new file mode 100644 index 000000000000..88ea0bc7d662 --- /dev/null +++ b/Documentation/devicetree/bindings/ptp/timestamper.txt @@ -0,0 +1,41 @@ +Time stamps from MII bus snooping devices + +This binding supports non-PHY devices that snoop the MII bus and +provide time stamps. In contrast to PHY time stamping drivers (which +can simply attach their interface directly to the PHY instance), stand +alone MII time stamping drivers use this binding to specify the +connection between the snooping device and a given network interface. + +Non-PHY MII time stamping drivers typically talk to the control +interface over another bus like I2C, SPI, UART, or via a memory mapped +peripheral. This controller device is associated with one or more +time stamping channels, each of which snoops on a MII bus. + +The "timestamper" property lives in a phy node and links a time +stamping channel from the controller device to that phy's MII bus. + +Example: + + tstamper: timestamper@10000000 { + compatible = "bigcorp,ts-ctrl"; + }; + + ethernet@20000000 { + mdio { + phy@1 { + timestamper = <&tstamper 0>; + }; + }; + }; + + ethernet@30000000 { + mdio { + phy@2 { + timestamper = <&tstamper 1>; + }; + }; + }; + +In this example, time stamps from the MII bus attached to phy@1 will +appear on time stamp channel 0 (zero), and those from phy@2 appear on +channel 1. From patchwork Tue May 21 22:47:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1103035 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HCy5iDZk"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 457rWQ6YQWz9sBV for ; Wed, 22 May 2019 08:47:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727269AbfEUWrj (ORCPT ); Tue, 21 May 2019 18:47:39 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37481 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbfEUWrd (ORCPT ); Tue, 21 May 2019 18:47:33 -0400 Received: by mail-pf1-f194.google.com with SMTP id a23so206549pff.4; Tue, 21 May 2019 15:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lzg0QOFg5tZ6dvh54DcZawapBEZVzAMWtzXZVVv9sp0=; b=HCy5iDZkYsrdGRrFxUMfInlmlRmTrlwmj3R6QAQ4W66T7w88YtrV4oCfU/Dfi9OzrD /McGADQU7XAY0TxTVFjkNDPqb+XgSz6EFFALygM+exgYSNHbDDqslytRxKpw3c1JPEgQ 54ExLbSGtd6kiFP78VhOfreqaNLev5GtcVXulgnbdgOfwK17kwrhpymLpil4GzZ2w8La VJAGDIMmoRUhSQElK2EbSxniad2WjHiphG2f4tAbvOhvlp1FnlLIQXnIrzr0pYTXj2RQ 9s0mnXPFJz0U681RY2guqdrEuktpV8FbsbreL5jt1mM5Umv5A1YQhdOEvrSUI/SmF3C2 as5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lzg0QOFg5tZ6dvh54DcZawapBEZVzAMWtzXZVVv9sp0=; b=fmzFEe5Q72gADFVJywBrWYPZxtxFN+czYEUt3p5tuylUW4yOXOYY8dPRJVQ0n33x2B t6DxXLxwvkwGwWVSSm+x7cDdY2DGcUEbzVdPO4z3LsWN5RannQ9MlZ/ghLjNBXJuehif 2s5TcDxN/Egeg3LhJhO+RJiBxLAAmgvioyp3Qn5DNtmyTouOWZ7/hneRsbBrt8ksDxtb 2kAZO+YXrNaTFYboQ6yd1pi+TTcTVgqVBnrORm1H0+DHk1GFpYD3nnQSbSeCjL1bJ+EA ksU7Z/b1Ct3tIan927s9voyzMSV6CO067qIgSAEOb1bCBJz0IdexlcxLW1bwekynwaKn OD2A== X-Gm-Message-State: APjAAAXYY+YyRQMuuoV1GXgkHo9LJJitHNt8FKhpQkJqQLvvAz3HQdW/ AN3RDVq2loBpDYy9cc4aNzx98pTm X-Google-Smtp-Source: APXvYqypQjNAKalfLdreWjJgmUOa4VTghdJcFRveY1h4YapX7e4bx/1qOFNvNBCj03Q9uClQBjQO/w== X-Received: by 2002:aa7:86c3:: with SMTP id h3mr89215810pfo.169.1558478852376; Tue, 21 May 2019 15:47:32 -0700 (PDT) Received: from localhost.localdomain (c-73-222-71-142.hsd1.ca.comcast.net. [73.222.71.142]) by smtp.gmail.com with ESMTPSA id r29sm34122419pgn.14.2019.05.21.15.47.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 May 2019 15:47:31 -0700 (PDT) From: Richard Cochran To: netdev@vger.kernel.org Cc: David Miller , devicetree@vger.kernel.org, Andrew Lunn , Florian Fainelli , Jacob Keller , Mark Rutland , Miroslav Lichvar , Rob Herring , Willem de Bruijn Subject: [PATCH V3 net-next 5/6] net: mdio: of: Register discovered MII time stampers. Date: Tue, 21 May 2019 15:47:22 -0700 Message-Id: <20190521224723.6116-6-richardcochran@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org When parsing a PHY node, register its time stamper, if any, and attach the instance to the PHY device. Signed-off-by: Richard Cochran --- drivers/net/phy/phy_device.c | 3 +++ drivers/of/of_mdio.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9d6468bae6b4..a7dd76a91289 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -877,6 +877,9 @@ EXPORT_SYMBOL(phy_device_register); */ void phy_device_remove(struct phy_device *phydev) { + if (phydev->mii_ts) + unregister_mii_timestamper(phydev->mii_ts); + device_del(&phydev->mdio.dev); /* Assert the reset signal */ diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index fcf25e32b1ed..c18629b1a72a 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -43,14 +43,37 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id) return -EINVAL; } +struct mii_timestamper *of_find_mii_timestamper(struct device_node *node) +{ + struct of_phandle_args arg; + int err; + + err = of_parse_phandle_with_fixed_args(node, "timestamper", 1, 0, &arg); + + if (err == -ENOENT) + return NULL; + else if (err) + return ERR_PTR(err); + + if (arg.args_count != 1) + return ERR_PTR(-EINVAL); + + return register_mii_timestamper(arg.np, arg.args[0]); +} + static int of_mdiobus_register_phy(struct mii_bus *mdio, struct device_node *child, u32 addr) { + struct mii_timestamper *mii_ts; struct phy_device *phy; bool is_c45; int rc; u32 phy_id; + mii_ts = of_find_mii_timestamper(child); + if (IS_ERR(mii_ts)) + return PTR_ERR(mii_ts); + is_c45 = of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45"); @@ -95,6 +118,7 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio, of_node_put(child); return rc; } + phy->mii_ts = mii_ts; dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n", child, addr);