From patchwork Tue Feb 6 17:31:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197561 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1700344dyb; Tue, 6 Feb 2024 09:33:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaaH+OM/HCRFfFLacaWEdox23Mptmbknl99VTiFHQcjHFcEzAkhqAjk9raO4qDjtuPXCDm X-Received: by 2002:a19:f805:0:b0:50e:ac97:8bbe with SMTP id a5-20020a19f805000000b0050eac978bbemr2345339lff.45.1707240831499; Tue, 06 Feb 2024 09:33:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240831; cv=pass; d=google.com; s=arc-20160816; b=Yr3HGWKm4BgQhGz6f2QjNekT6g14vrOS0CjEUKKyYAmZl1vH+rwb+ZbFXsKVlgaJL4 Pqqku3M15hJbwS+jRhZSzkoCVDScvePDP1wXtrWvqlewMqN1mvqrKfqQvIvC2Drl/zQd 4EDAYclyWt0PUWBAPlAWfrWHbwagrwPSBZ3CURyjZYBvyQgjwnIpfytfN0v3+itBVCkA +PWhSP5foK2qyCZGgU8dzQ7/4cOHM7YfYdJNfdnuPgB/U+4IEGqUFUdbMwsHAiM28DSW 1L2UxIP++mpA7KgYCUCxOuAiS0mV/GN5Tu12IZrM2QHrqCOv4kcgAP9dD05q56g3DtDp 913Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=ozVMLwHgKVfJzWQo5tW7oNNWQr0MV/j4f/0n469yn4M=; fh=5agbyBIylKTVT8IPlZRop/7MTa+GZp8k61TBPkeF/Ro=; b=1JSnLWJyLpU8bWcG6j2j4Kp+gMSLc9nrbaQrhnMvowo9pU3Rzk8pQDvYN64wFrniyb jpDPZqLBAb/bWKPPZeWdBAUBAyilWd0esju/4EuIiPVnsU1uevH8W+QPzIAEEWCwCN4V Yjg1WrmLax4kweJ57Wpp73rseOu/phBCB9IhRXtsWqi02JSr71dChTiwZ7d6VR26PPWt hZ9OtKqGIzqjwh+FOR+WG7IWMif8ZHqxxu2dEITzYKWxWjrTTkmkBZ+1JcPBSArazO6s aYFSMA2WirAvk+07OVHqlOwqigw7DEbS5q27+OIXfooKAM+nbgTWyxWLubFMSdPIND9Y IAEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dP6l12jE; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55384-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55384-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCVlLVuX+5Y0fGMjDLnRbidW2W6gDMgUPT/3NylN2TClGN95OkHZ+NWApwn8XXe/fZinjGKU6hD6yg9a/ekawuKd+mWtdw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d22-20020aa7c1d6000000b00560768f22d7si1335450edp.518.2024.02.06.09.33.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55384-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dP6l12jE; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55384-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55384-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E61351F27073 for ; Tue, 6 Feb 2024 17:33:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9177E13AD1; Tue, 6 Feb 2024 17:32:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dP6l12jE" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19F20DDD1; Tue, 6 Feb 2024 17:32:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240771; cv=none; b=mq8xwMeCFuNy3+v+fI8661bjWIZ/cHKSxCAjEaTy2w5PxyfwaTJ6qlhxn6qWkRcJ9Vo72Ep6DIttojLnWA6ueK7aQ1hxIfsVPTWZ0yQC9k7VyYqCy4M351Joty113lbKpr+jpWlbPO+MMXUAlJY585EjmZjEuAQy2oj9Pk6a1FY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240771; c=relaxed/simple; bh=QUMd/pymTNWROMEPvOP0tST5nIvBnoIZpBFhJ64dhxw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OBHqz+aDmbKEJ1v6KI2phuNQBkFNf8O7lXUWv+CUIBO0IUcpWGY2X8e60W52bilGTXILUrH3uFJ3S2Rss6c4pJII9QkY7AtfvGV+mS66mXBMZAJ+q6wwqq9AjFfVPABtLopN5j/eUpW5Ibi1relvhHjBQxA9ARGy9aFeRqzw9MQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dP6l12jE; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40fc549ab9bso40290525e9.0; Tue, 06 Feb 2024 09:32:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240768; x=1707845568; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ozVMLwHgKVfJzWQo5tW7oNNWQr0MV/j4f/0n469yn4M=; b=dP6l12jEDwL0nFb2AG91RjSGYMfHO++HC1L4NsGxRLDj9d3W9XmKMTDNXNYqq0vrXa ZSXu0UIqjSyNgSmvmFwahQa974iHwCTPLr5g7hOeG9st8+Zk42c2gvTFclOCr1sDhXD0 e9hE5k601cg4gIGQqTbF0vgtQsKXMMKD4iDuzMkqJ/DM494IguOZSXLrncUQ0A9setDS 9iX5/zT+T8UhxrejNS84PdcM/cAoy9DozoewJ9dOaIg/wq4Ii1kHbtQjkLnIpA7/aIdy ARuNXZ59dQ3CIBcMIRrc/lVXlXv8V4+3c9EEzpwrUQae4JBdPg/ln8iXCk50bJEhJZSR oS0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240768; x=1707845568; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ozVMLwHgKVfJzWQo5tW7oNNWQr0MV/j4f/0n469yn4M=; b=LVP/l9mJQqs3tI7Q1rjtQAV8QS/qo3u/9kxZEZPHZuwYgf0WGT5KFh0FsIlNwNst6I xGv69RR1WeFV4bu7r1vVH5z5IJ6N8nwPL0KbEyIptov5DQhaG2ipuBQf46tV5mscCCTX g1qYF9aLOz+478pNsSTHFxMJMcUFpxSElwvPxcxb8vwdSY5efntr83MB6s/p3t8ZGwt9 4xobkXSCz4njYMkeSQPHa45hSFxqs52Ch2AC8uJZBwtGpJFBigXO/MwiH73E611BBCko J3Yiq8r1TraxxgYFU8rOsox96zxHuf+q+b06c/HJzwja3zAAWvgCQtrKjURzh23lcR7r lCPw== X-Gm-Message-State: AOJu0YxES0I8iZrW5RFSP41nY4PC5Hx3HJk9JLHX+zOn+kqsametl2A1 9WCERznsiFqh3NwIiEyK3DW/PsIOVxg1i7nJuN8jDf3SS5W2QAgv X-Received: by 2002:a05:600c:3110:b0:40f:b45c:85a5 with SMTP id g16-20020a05600c311000b0040fb45c85a5mr2638988wmo.22.1707240768263; Tue, 06 Feb 2024 09:32:48 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWMk2tfBb85O2ZSqSWF0VUoKPMlWjcKdDOxIqrvE6crIr3rihFepAjlUmvhZDBIFrlXguD2NHeHPdmVd0IdxtcrUb2XCSn/TegFddWNlmB4U2vLZPq/TZzGm2go2JowvzVEflqddhd5TOQkPXQfjVa3r0LVu/AphoxVVW2PqibxLivJKLjzhF9K1OsaMwG3K70LeedXZQbaA1eqSGIXq2X5WgqgV6A/kDdnV0iJJPbXsKr/9uo2vyk0OpYCndVB32U/PlEl9uvfY1aAFO2CEfcSUxzHlpB7n7U2UB9/TDUJdqygdAKd6OguxeTi3MyKGHfZkPDhsKkhHaO8EMHFdkA1ehhc8q+4lTNdXepnPrqS6O3ZIwYSd3A3oc9RiY7/CFr+/fYp7LkMQ+hmMf8t0IdQObX6AUzWpaSwlPxzYRNZgUNkz58xbCuEQgTHwHPuppnbob7zMFAr8CqmLt5gBbKVOIjXDKa7l1pixeza86o2uNWbdQpPqdn53JfXD5kd+IubhBfP3fFe+evqukCtlibhHR5xeuKoY0sItFjQhTfh7ccpxB8jdabPKyeXcLnJMY60MDGNBW8qhJpJ4d0nPmLzqV4fMDMsHdsXzrL2nrb99G7XNp8oz+N0tD0nNqfbptTgxA0L65lT2IrQFeLhXGV/eAejtLGfaL1qTthHv5Z7aSxZd0yWMQ== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:32:35 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 02/10] net: phy: add support for scanning PHY in PHY packages nodes Date: Tue, 6 Feb 2024 18:31:05 +0100 Message-ID: <20240206173115.7654-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171761878543798 X-GMAIL-MSGID: 1790171761878543798 Add support for scanning PHY in PHY package nodes. PHY packages nodes are just container for actual PHY on the MDIO bus. Their PHY address defined in the PHY package node are absolute and reflect the address on the MDIO bus. mdio_bus.c and of_mdio.c is updated to now support and parse also PHY package subnode by checking if the node name match "ethernet-phy-package". As PHY package reg is mandatory and each PHY in the PHY package must have a reg, every invalid PHY Package node is ignored and will be skipped by the autoscan fallback. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/mdio/of_mdio.c | 79 +++++++++++++++++++++++++++----------- drivers/net/phy/mdio_bus.c | 44 +++++++++++++++++---- 2 files changed, 92 insertions(+), 31 deletions(-) diff --git a/drivers/net/mdio/of_mdio.c b/drivers/net/mdio/of_mdio.c index 64ebcb6d235c..08e607f62e10 100644 --- a/drivers/net/mdio/of_mdio.c +++ b/drivers/net/mdio/of_mdio.c @@ -139,6 +139,53 @@ bool of_mdiobus_child_is_phy(struct device_node *child) } EXPORT_SYMBOL(of_mdiobus_child_is_phy); +static int __of_mdiobus_parse_phys(struct mii_bus *mdio, struct device_node *np, + bool *scanphys) +{ + struct device_node *child; + int addr, rc = 0; + + /* Loop over the child nodes and register a phy_device for each phy */ + for_each_available_child_of_node(np, child) { + if (of_node_name_eq(child, "ethernet-phy-package")) { + /* Ignore invalid ethernet-phy-package node */ + if (!of_property_present(child, "reg")) + continue; + + rc = __of_mdiobus_parse_phys(mdio, child, NULL); + if (rc && rc != -ENODEV) + goto exit; + + continue; + } + + addr = of_mdio_parse_addr(&mdio->dev, child); + if (addr < 0) { + /* Skip scanning for invalid ethernet-phy-package node */ + if (scanphys) + *scanphys = true; + continue; + } + + if (of_mdiobus_child_is_phy(child)) + rc = of_mdiobus_register_phy(mdio, child, addr); + else + rc = of_mdiobus_register_device(mdio, child, addr); + + if (rc == -ENODEV) + dev_err(&mdio->dev, + "MDIO device at address %d is missing.\n", + addr); + else if (rc) + goto exit; + } + + return 0; +exit: + of_node_put(child); + return rc; +} + /** * __of_mdiobus_register - Register mii_bus and create PHYs from the device tree * @mdio: pointer to mii_bus structure @@ -180,33 +227,18 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np, return rc; /* Loop over the child nodes and register a phy_device for each phy */ - for_each_available_child_of_node(np, child) { - addr = of_mdio_parse_addr(&mdio->dev, child); - if (addr < 0) { - scanphys = true; - continue; - } - - if (of_mdiobus_child_is_phy(child)) - rc = of_mdiobus_register_phy(mdio, child, addr); - else - rc = of_mdiobus_register_device(mdio, child, addr); - - if (rc == -ENODEV) - dev_err(&mdio->dev, - "MDIO device at address %d is missing.\n", - addr); - else if (rc) - goto unregister; - } + rc = __of_mdiobus_parse_phys(mdio, np, &scanphys); + if (rc) + goto unregister; if (!scanphys) return 0; /* auto scan for PHYs with empty reg property */ for_each_available_child_of_node(np, child) { - /* Skip PHYs with reg property set */ - if (of_property_present(child, "reg")) + /* Skip PHYs with reg property set or ethernet-phy-package node */ + if (of_property_present(child, "reg") || + of_node_name_eq(child, "ethernet-phy-package")) continue; for (addr = 0; addr < PHY_MAX_ADDR; addr++) { @@ -227,15 +259,16 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np, if (!rc) break; if (rc != -ENODEV) - goto unregister; + goto put_unregister; } } } return 0; -unregister: +put_unregister: of_node_put(child); +unregister: mdiobus_unregister(mdio); return rc; } diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index afbad1ad8683..08624f073014 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -459,19 +459,34 @@ EXPORT_SYMBOL(of_mdio_find_bus); * found, set the of_node pointer for the mdio device. This allows * auto-probed phy devices to be supplied with information passed in * via DT. + * If a PHY package is found, PHY is searched also there. */ -static void of_mdiobus_link_mdiodev(struct mii_bus *bus, - struct mdio_device *mdiodev) +static int of_mdiobus_find_phy(struct device *dev, struct mdio_device *mdiodev, + struct device_node *np) { - struct device *dev = &mdiodev->dev; struct device_node *child; - if (dev->of_node || !bus->dev.of_node) - return; - - for_each_available_child_of_node(bus->dev.of_node, child) { + for_each_available_child_of_node(np, child) { int addr; + if (of_node_name_eq(child, "ethernet-phy-package")) { + /* Validate PHY package reg presence */ + if (!of_property_present(child, "reg")) { + of_node_put(child); + return -EINVAL; + } + + if (!of_mdiobus_find_phy(dev, mdiodev, child)) { + /* The refcount for the PHY package will be + * incremented later when PHY join the Package. + */ + of_node_put(child); + return 0; + } + + continue; + } + addr = of_mdio_parse_addr(dev, child); if (addr < 0) continue; @@ -481,9 +496,22 @@ static void of_mdiobus_link_mdiodev(struct mii_bus *bus, /* The refcount on "child" is passed to the mdio * device. Do _not_ use of_node_put(child) here. */ - return; + return 0; } } + + return -ENODEV; +} + +static void of_mdiobus_link_mdiodev(struct mii_bus *bus, + struct mdio_device *mdiodev) +{ + struct device *dev = &mdiodev->dev; + + if (dev->of_node || !bus->dev.of_node) + return; + + of_mdiobus_find_phy(dev, mdiodev, bus->dev.of_node); } #else /* !IS_ENABLED(CONFIG_OF_MDIO) */ static inline void of_mdiobus_link_mdiodev(struct mii_bus *mdio, From patchwork Tue Feb 6 17:31:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1700948dyb; Tue, 6 Feb 2024 09:34:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqjZzjh7DqGTEUnp3ccMLWJ8NV5M3ZPpjBPz0yWWfoJ5Qe22pSAWhs6OYMRv8lZ3OrTIl0 X-Received: by 2002:a05:6a20:be8f:b0:19a:508a:7f70 with SMTP id gf15-20020a056a20be8f00b0019a508a7f70mr1707235pzb.30.1707240888769; Tue, 06 Feb 2024 09:34:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240888; cv=pass; d=google.com; s=arc-20160816; b=TJRX0MgkaUNkypWceSmyTKcIB4WGvgiC5xR639iTqbOGy2nEacsGplNYuv7C1AAQMZ rHcJw0iVWCEIQknSOuy4snwPKmi5h14az0B76xaOQ64RN8vxKYAZ60Y0xQ474+IFEapI 8bhbrZjSecm62+oH3tBeA6qQNm0SrCdgVyv9cDOwF8+uo76krEp9SYA2YklmLZG1uIiu IXDZWZll9VtqjZJg3x1z36zag1xhgm1cE4wj7PYvTx8T1u+U8AA79U15C/wvIXqtVXfL 1Kl1Qug04Vv63T8SoatpALqsHHmvSc89E+m1AXWswd0WwwGrT8Y+sZQcRhivvVPHwya5 /Qiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=vvEq+NsiNLdpqkcur7fcDxX3BE0a2LiFsPz8eCkRlBo=; fh=0lBvrGRiiLG30zfW8ZGhsuG8RDlcJ5UMRGKj0Cf17Ro=; b=M0jSD/EAd95YuDGhUHcMovSnzQkn7Psl0p6UVENB/UtwnQbIEDtLyP7yTz+SJYt5m6 U0OONKm0Ul3nWdDSTNkjX0G30HxaFN3rw+h/DBfnf0CTsIEplBtcgwNuAu5MtPLMfn9f r8Lqsw/qpzlbMWZOivFIU0F8a8GK8MJEZlmsYGw1tzRQtlWU2HDRfkBTf51GO9RnV4Bb KlYGDDnU13g9FkAnPOwxfvaKSVNpKn7J3VAP/iW+strEPFrCrp9TOpAxBnFEXoKxI0+9 1xroa4rPJkSs9Z2iR3eDAoGYEVvXQBbQVwjysdDFtmZMguXrxpyPq6+HQkkPnczFGZY5 Kozg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OedQnV7k; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55385-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55385-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCV1VqQwscEl9o9BIF1Np5sXMP0ZXx0LZI6HSDEQDYU4U59sn+XtF7rFLSYsxZDcYaQLB+h6W5ERhqcvpJjl4Z6zeNfy1A== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h30-20020a63f91e000000b005d8bc1d9b5esi1951896pgi.313.2024.02.06.09.34.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:34:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55385-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OedQnV7k; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55385-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55385-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EE6F8288817 for ; Tue, 6 Feb 2024 17:34:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF62314266; Tue, 6 Feb 2024 17:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OedQnV7k" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA4868F7D; Tue, 6 Feb 2024 17:32:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240781; cv=none; b=IZTKYALQNMCkb+AD5/pLu45JfG2H4/h8EJ6fIRwZ14igxU4828m2WeFHfpnISYnZyvCabU8hXj8cQf8nBjoLtgAreXG0+C0i1tRBd1Z+ctxJJ2IqxZYa0Ac7h8V5lM7qQgJFCit8zuMZt0dttOn0lOKfvrH1mvjlAXOlvBQk/Ng= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240781; c=relaxed/simple; bh=J78yXE5qwS90R4EgpQlY1uiAZERyB7nhqi/EFAgqCCk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YRm32180BK9RRg6jdnzTDn02sv4aa58tqIGoCuNUKgGZWt490jA8A44VbtYQ75tr/3BRHia3A0N9vdLoFit2HQCFpfq86M8ywcGHia+8QL3aGOaeeIwW5sTmzZ+Uu9vYXKeXXxpkahCMFAEapCLBlsfvYM4CJt4ZNUF/PMHc7CY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OedQnV7k; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-40ffce2ceffso1264875e9.2; Tue, 06 Feb 2024 09:32:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240778; x=1707845578; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vvEq+NsiNLdpqkcur7fcDxX3BE0a2LiFsPz8eCkRlBo=; b=OedQnV7k8e7/zr7s4ciBPgBTBB+m7AICc/7IOG/01lBzPfzT6ZC+WybrvVJiN3AJfs n/dIZlLe4MnJoWaD+BUU2QuJeqQXi7HKmEnzEtPTmKVZs3871GWwDdRQ0jrWGBwG8/Ct 58HnGr7UqJscSZ8geBf+5ZVKt5iaKpGPMnIFvCTniVmoU63cSmXQCK7hpju16BwrrRug sTUqThNgvKh1AJdTi52FD6LXxYRjWOdU9HKZmdCL2pYsOr5txV2jXlfbPRlWtST2V8pd X6/PoAAO/plNG7KAnG6jLU6aB6YCe9ntChD3qxza0mgaW5JoLzNB1W6eausXT5AZN94I pXKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240778; x=1707845578; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vvEq+NsiNLdpqkcur7fcDxX3BE0a2LiFsPz8eCkRlBo=; b=a5Kgjh9y2Hhro1PGkpszL0RuWpcrexx1z/dnsNMdzvS8VECOZs3qEzMlzQlHTD6NoZ /gstdj7EICdzF1uearL8nyVFgGCFU6k5HSVLqjWWkbN9GXjDvkxEMkOq3L1Mnh0dtNXR rXrzdzb4MkLoN2HWNl58BD+VXu3/bEyVMOUAz23bhyyGLorZMcjyFv4qQfceCAV1flUv /1s7ySRpfYMh24iU6f/PsyGbCXtaxmv1TQdvPnwm9PONT11uVVV9OpaBPDANcktNH5QQ cVkD5XIRNapYMvqEWOCu0+2OUrLRzpQ2ZPNsOAz9lqIrwPWObzeA8M5mAd/lVyBZZooB Yy5w== X-Gm-Message-State: AOJu0Yzpgmm83h/1gf+d9023vN4F4KSEWsjF3a6XY7VaQINCuvgQosN1 TWluZGOtzHqhqHhJ8vknWlM1hZTfOgxwyN5WguRyv8rmSO0a+tJv X-Received: by 2002:a05:600c:4f0e:b0:40f:dde8:1663 with SMTP id l14-20020a05600c4f0e00b0040fdde81663mr2935082wmq.19.1707240777897; Tue, 06 Feb 2024 09:32:57 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXlA35Uq5N1Nys7Xu67Fa9mPzf3mhp/AXnH7iE2VN7PZO7oPKHnCPkdteXwzbMr7qPwz0sOtgsbs/gHTrfpl5Qzegr77KvWSiiBOToICtNxvzSDzwVlWJMv92zJW6KcpvQYl2GsM4DH4S/NwSZbF9YaJpGOS2g0TXpH3gL0Z0xxkopxmB8FrmXJQMHjc7qBTbVyJrcq6Zxt8L6sj91IXI0U+GpR4BEdIeSDbLd79DBmyeXzpVHPVvOLdXPQ8Q7ftKnpldwRkZVhEaRtIL132BAxYaZXofJgUHPLDAuAxMEZHMxz+tlYWDemF1WC86Wh7f0dfdOuZBTEGmIV9L4jZrDD1x09FncsX7s8bwmDpGQw0JWKOzWpGFOFAJS5guV3wjbOqy3HeAWJohDsYUUyAtjR4m4Kozj305Hj3TaYbBrcoIaoxZzQCzKUN5UVqBgVlTUsZGyICcYKl0QzpmDTsgQgqeOPvwZKOt90PBGWBYHElzt6iJjMy5V1z44mFgp0goN08X311Zr8++Q5pKevUwVzKW2thdYv4YzfGO9Du8CwLY2eKbbSJClzezOGSbD236XgljgB0CQx4kwQmwcos1OOKSNBARNTR+J+QrlB9bTJuJUCsm3SoPu7Oyhxihzn9XuYgwALF2DjbMx9DDtSZAdlageTT9T2CpPe3tdw3rc0Iksp0EqjYg== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:32:56 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 03/10] net: phy: add devm/of_phy_package_join helper Date: Tue, 6 Feb 2024 18:31:06 +0100 Message-ID: <20240206173115.7654-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171821997595158 X-GMAIL-MSGID: 1790171821997595158 Add devm/of_phy_package_join helper to join PHYs in a PHY package. These are variant of the manual phy_package_join with the difference that these will use DT nodes to derive the base_addr instead of manually passing an hardcoded value. An additional value is added in phy_package_shared, "np" to reference the PHY package node pointer in specific PHY driver probe_once and config_init_once functions to make use of additional specific properties defined in the PHY package node in DT. The np value is filled only with of_phy_package_join if a valid PHY package node is found. A valid PHY package node must have the node name set to "ethernet-phy-package". Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/phy/phy_device.c | 96 ++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 6 +++ 2 files changed, 102 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 2eed8f03621d..9014ac3c0fc8 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1708,6 +1708,7 @@ int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size) shared->priv_size = priv_size; } shared->base_addr = base_addr; + shared->np = NULL; refcount_set(&shared->refcnt, 1); bus->shared[base_addr] = shared; } else { @@ -1730,6 +1731,63 @@ int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size) } EXPORT_SYMBOL_GPL(phy_package_join); +/** + * of_phy_package_join - join a common PHY group in PHY package + * @phydev: target phy_device struct + * @priv_size: if non-zero allocate this amount of bytes for private data + * + * This is a variant of phy_package_join for PHY package defined in DT. + * + * The parent node of the @phydev is checked as a valid PHY package node + * structure (by matching the node name "ethernet-phy-package") and the + * base_addr for the PHY package is passed to phy_package_join. + * + * With this configuration the shared struct will also have the np value + * filled to use additional DT defined properties in PHY specific + * probe_once and config_init_once PHY package OPs. + * + * Returns < 0 on error, 0 on success. Esp. calling phy_package_join() + * with the same cookie but a different priv_size is an error. Or a parent + * node is not detected or is not valid or doesn't match the expected node + * name for PHY package. + */ +int of_phy_package_join(struct phy_device *phydev, size_t priv_size) +{ + struct device_node *node = phydev->mdio.dev.of_node; + struct device_node *package_node; + u32 base_addr; + int ret; + + if (!node) + return -EINVAL; + + package_node = of_get_parent(node); + if (!package_node) + return -EINVAL; + + if (!of_node_name_eq(package_node, "ethernet-phy-package")) { + ret = -EINVAL; + goto exit; + } + + if (of_property_read_u32(package_node, "reg", &base_addr)) { + ret = -EINVAL; + goto exit; + } + + ret = phy_package_join(phydev, base_addr, priv_size); + if (ret) + goto exit; + + phydev->shared->np = package_node; + + return 0; +exit: + of_node_put(package_node); + return ret; +} +EXPORT_SYMBOL_GPL(of_phy_package_join); + /** * phy_package_leave - leave a common PHY group * @phydev: target phy_device struct @@ -1746,6 +1804,10 @@ void phy_package_leave(struct phy_device *phydev) if (!shared) return; + /* Decrease the node refcount on leave if present */ + if (shared->np) + of_node_put(shared->np); + if (refcount_dec_and_mutex_lock(&shared->refcnt, &bus->shared_lock)) { bus->shared[shared->base_addr] = NULL; mutex_unlock(&bus->shared_lock); @@ -1798,6 +1860,40 @@ int devm_phy_package_join(struct device *dev, struct phy_device *phydev, } EXPORT_SYMBOL_GPL(devm_phy_package_join); +/** + * devm_of_phy_package_join - resource managed of_phy_package_join() + * @dev: device that is registering this PHY package + * @phydev: target phy_device struct + * @priv_size: if non-zero allocate this amount of bytes for private data + * + * Managed of_phy_package_join(). Shared storage fetched by this function, + * phy_package_leave() is automatically called on driver detach. See + * of_phy_package_join() for more information. + */ +int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev, + size_t priv_size) +{ + struct phy_device **ptr; + int ret; + + ptr = devres_alloc(devm_phy_package_leave, sizeof(*ptr), + GFP_KERNEL); + if (!ptr) + return -ENOMEM; + + ret = of_phy_package_join(phydev, priv_size); + + if (!ret) { + *ptr = phydev; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return ret; +} +EXPORT_SYMBOL_GPL(devm_of_phy_package_join); + /** * phy_detach - detach a PHY device from its network device * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index ad93f8b1b128..f8ce8a757ed0 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -329,6 +329,7 @@ struct mdio_bus_stats { * struct phy_package_shared - Shared information in PHY packages * @base_addr: Base PHY address of PHY package used to combine PHYs * in one package and for offset calculation of phy_package_read/write + * @np: Pointer to the Device Node if PHY package defined in DT * @refcnt: Number of PHYs connected to this shared data * @flags: Initialization of PHY package * @priv_size: Size of the shared private data @priv @@ -340,6 +341,8 @@ struct mdio_bus_stats { */ struct phy_package_shared { u8 base_addr; + /* With PHY package defined in DT this points to the PHY package node */ + struct device_node *np; refcount_t refcnt; unsigned long flags; size_t priv_size; @@ -1999,9 +2002,12 @@ int phy_ethtool_set_link_ksettings(struct net_device *ndev, const struct ethtool_link_ksettings *cmd); int phy_ethtool_nway_reset(struct net_device *ndev); int phy_package_join(struct phy_device *phydev, int base_addr, size_t priv_size); +int of_phy_package_join(struct phy_device *phydev, size_t priv_size); void phy_package_leave(struct phy_device *phydev); int devm_phy_package_join(struct device *dev, struct phy_device *phydev, int base_addr, size_t priv_size); +int devm_of_phy_package_join(struct device *dev, struct phy_device *phydev, + size_t priv_size); int __init mdio_bus_init(void); void mdio_bus_exit(void); From patchwork Tue Feb 6 17:31:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1701470dyb; Tue, 6 Feb 2024 09:35:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1+0z0zMXOQaOSItmAlx2R0tuPCWl5aF9Tv0E6qITrjFJor3h4VlWJzOEIXccxHc2QICe3 X-Received: by 2002:ac8:528d:0:b0:42c:699:a2c with SMTP id s13-20020ac8528d000000b0042c06990a2cmr2640518qtn.64.1707240936697; Tue, 06 Feb 2024 09:35:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240936; cv=pass; d=google.com; s=arc-20160816; b=a3THETwdmoPtfdwbruxk+MpVd0lPmb3hdTizvHbwkopSZtKiyRQamUFwPdMN3VYSM7 aMDrFo+cLSHpefYK7RKPjelSwe8GwfJOFMmI+NgANgg8TVfLxBi1U5SnKbZjNOB0qrY+ WoC06qxzNj2tSmMsVD7di+j7ELPqA2WPpM3sAhKd9XMACilW4ND88AfZRQWAx6hoHZXg Vpt+41FVcE2QhkepaNFiQapXrRxkZ6DbBUBN+XfO4qSCaMF33V01umQZ0w9Bgrf3k+Hy HDwZTVYLryx8lvopM5w7K2cAipxbOHAJYC+0I3GcRDL380vj3UGMmHxv1BadrPuUE+tG aP7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=Kbh8rqeYY03RgbOQ94/D59JmMRtePccIdeL610jMQyY=; fh=Amx8O0cJDr3PnClUEjLp6C71UDhW3vUP+66Q0gLTTBQ=; b=D0Bjv6EQ+2sYjKiHKr/aIMSvUcOw71E7L8v9Jtnrn6ox1bSRa4BitJdG+1mP0epaX/ bYdzr2b9linu2iim/EYpCO4KhfhKJYN5Ekv3yQRbrSiT3hBvlTTDdrzxaxFKqd61EyXG qYRLBwOBVOfL1djChszsMZn/41qnBx+0+Uf54DbqGWduFSmDXCdqzoYyjfB/aq0zHN7B 9VMwERSB2gU10ZSRYg6xFmrjwO08M9CQZWPKfmcebrF/MdB4lgu3tLg/jwYCdK1pfMOk JDGXLIixtUPUWR43+AgEUdr4DlBNSunO1OSQFyc+pREYS2+58pwpmvnFpaNp3mUstxYN zxXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XnhBsyPA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55386-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55386-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCV2MwDfTV8IgnebeBDxtcuY3Ib+Lq4Chb5e1yFzlSTIb/+0dJZBZZQ3s0wmMBd7klnSY6bESJydtNeZlhajxp4lh+lWww== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k18-20020ac85fd2000000b0042c32e8db9bsi2439372qta.374.2024.02.06.09.35.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:35:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55386-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XnhBsyPA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55386-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55386-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2A1FB1C24D5A for ; Tue, 6 Feb 2024 17:35:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9541217BDD; Tue, 6 Feb 2024 17:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XnhBsyPA" Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C57BABA3F; Tue, 6 Feb 2024 17:33:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240784; cv=none; b=Vjqak4N3gUj4ifwKcwcZ/GyjWscHOhLGaLZhPthflrwVWgvFnGKECHzGkDDCHVGWTEat11nDP6OjLgVPMtkviyxMyOAq5yipBrox9wb6QLeYiagW44LFpzmguInYtzDSKBBvd4UUF9+exTNeYUaocP+fiIovSwn+h8/JecZQP/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240784; c=relaxed/simple; bh=oPxMEZWAyg2qRL0yS2P7u9xEpG6GttLt28qXdFKsViI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HDbd1oJqhpXRq0fFT+AFUPnsEv2fJUBBmfovdJdwaPLeR4/+G55gFDJQSRQa7/ckfNrpfIbpFrDrBj7t5eeEdHx3zJ4xCPru9ROG7gXszM/TKF449jw7w57PHRR0K+CVBvLywy42ClMNbeh/s10KhTQ9vApDhF+Ix8hj608aVag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XnhBsyPA; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3394ca0c874so4181354f8f.2; Tue, 06 Feb 2024 09:33:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240780; x=1707845580; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Kbh8rqeYY03RgbOQ94/D59JmMRtePccIdeL610jMQyY=; b=XnhBsyPAyGyNeYp2vwMizQ2ODj9/MA3TunQmdb3rkSj5BEz/JhfrD9rHU0Fq8mv0cd ZpncUz2b8unTXIt+/Zo/F+/B+iJUiYX5o38FDuvXhCarBplGd/Ov5vPY7d9GQJvpueVc 42caA1iklXD8EsQxGXERkmoK7lwjMSt+29cwnw7jN0wnmsZNz2ddNt/0fQgvnCNoE7vX tL53P0VA5dEw8jNsoDSXU74n411mXp7HkilL1Y6WbRIA1kYW6ccro34j8bmismKe+bR0 QSUyndnwdAVeIlMwnNa9VT5fMsgIUL3gfUplL9O8Mjwc0f54zhySfNrlAmL/NclyxfyL GhsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240780; x=1707845580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kbh8rqeYY03RgbOQ94/D59JmMRtePccIdeL610jMQyY=; b=aX/XBhrCdJD9uqt6ffS0kgY8vZs2P7VbzFB4Tr+j2HtpDBZb0v3K9zgglaGvNTOJkZ 7Gx0N9Ndd7ERMuvOCI1XccBQudtMiVfQHCS7eXonHpho4AZ3whRR8jHfMlhjkZquVVsX wmA5U+Lv0BFJ6fWvIYyTygKP9bmh7L1EJrRMM5qL9Bygy52blnb5Z73x0mwgMZq+ci65 WWRzEuFrZHxVlHBgOEkyGUuovxU2jELeyTpcyZPDz6pdsVTAm0jdCsJ3bIJ6e60Gll+l FpX8VEqP5jFyD3AGhZHEpR9vTjVI/ESMt4ejriV1+lEvvVvZrIvorLgg7yHaTszZ7nKc I1Uw== X-Gm-Message-State: AOJu0YzyychnIK/ot9654FG6Za28vSFKgcoU/Ma6ACyNfU2niDa++BKM BnzV5aqrRYOAYmoPJmLftl3zFzYM+890RGMahKLx5flJzzQiSXAk X-Received: by 2002:adf:ea89:0:b0:33b:1e84:9684 with SMTP id s9-20020adfea89000000b0033b1e849684mr1560918wrm.70.1707240779922; Tue, 06 Feb 2024 09:32:59 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVEGblCQWkfcbhgR/sx5JvYJbCwI4SdioML7hbLp9WuHnzW5RJsDeOz1ZEg2ekoM36/MJWvp0AafMT37w6Bec/RetsfUI66J2Z/zoNjUsYilBNc0bceRS2Budu/E0rrsH9ppaYSA/adgmpwgYxzMJ9rVr7IzJW8d+RGbClGrd/Dd/QfZ6M64++6rWhiuohDa/d6VfuTxyQxVyEvjSKXGwKM4VW/vRMTHmInjsd+iPi0tiX5f7yux7WQvtdQPciveRqy/jL1Y8Ufv6+LPdfarLAH4Q3BXqmcp1ddt8jEzQ7UFRB+8AZvrO0iXvQ6o1dfmaOVzZw43/WX4jGvF5cP611Krg6+7L9L2v6f2nvP4qCrOMaYo/LyPjfuubW5aQJwYTBUHIdDc8oxYl9jG3oNkon5SzenP2IiDxgj0gTYcBD2gN01W1ASDTCe1MnFVj/XJKQLkeXtMgxTGY0UNrL6wd+ICYjDnsqQtEeEDEl4CdXOIhRg88wH/EyUQ7Ux2+JvNqS+PoIritC4Xc+tobtLDFJoi16KwvRYBGqT2TNiv8hsqJ3BRJ2dAHDkO1iLGr27fdkIc5vqVzxCI9YNTpqmZD15oCOng5pYj9OkdyDqGwUUYKHQWscm/QRUYGUObl/vtbHymbPG+Ovb2yyjtBYAfiJiteuMJ3oT8Szx//Zm/00y2yFrxBvB5w== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:32:58 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 04/10] net: phy: qcom: move more function to shared library Date: Tue, 6 Feb 2024 18:31:07 +0100 Message-ID: <20240206173115.7654-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171872654281976 X-GMAIL-MSGID: 1790171872654281976 Move more function to shared library in preparation for introduction of new PHY Family qca807x that will make use of both functions from at803x and qca808x as it's a transition PHY with some implementation of at803x and some from the new qca808x. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/phy/qcom/at803x.c | 35 ----- drivers/net/phy/qcom/qca808x.c | 205 ---------------------------- drivers/net/phy/qcom/qcom-phy-lib.c | 193 ++++++++++++++++++++++++++ drivers/net/phy/qcom/qcom.h | 51 +++++++ 4 files changed, 244 insertions(+), 240 deletions(-) diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c index 36b70e88394e..3e3ee4c1d4bc 100644 --- a/drivers/net/phy/qcom/at803x.c +++ b/drivers/net/phy/qcom/at803x.c @@ -504,41 +504,6 @@ static void at803x_link_change_notify(struct phy_device *phydev) } } -static int at803x_read_status(struct phy_device *phydev) -{ - struct at803x_ss_mask ss_mask = { 0 }; - int err, old_link = phydev->link; - - /* Update the link, but return if there was an error */ - err = genphy_update_link(phydev); - if (err) - return err; - - /* why bother the PHY if nothing can have changed */ - if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) - return 0; - - phydev->speed = SPEED_UNKNOWN; - phydev->duplex = DUPLEX_UNKNOWN; - phydev->pause = 0; - phydev->asym_pause = 0; - - err = genphy_read_lpa(phydev); - if (err < 0) - return err; - - ss_mask.speed_mask = AT803X_SS_SPEED_MASK; - ss_mask.speed_shift = __bf_shf(AT803X_SS_SPEED_MASK); - err = at803x_read_specific_status(phydev, ss_mask); - if (err < 0) - return err; - - if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) - phy_resolve_aneg_pause(phydev); - - return 0; -} - static int at803x_config_aneg(struct phy_device *phydev) { struct at803x_priv *priv = phydev->priv; diff --git a/drivers/net/phy/qcom/qca808x.c b/drivers/net/phy/qcom/qca808x.c index d88e04278fc4..8377325f157e 100644 --- a/drivers/net/phy/qcom/qca808x.c +++ b/drivers/net/phy/qcom/qca808x.c @@ -2,7 +2,6 @@ #include #include -#include #include "qcom.h" @@ -63,55 +62,6 @@ #define QCA808X_DBG_AN_TEST 0xb #define QCA808X_HIBERNATION_EN BIT(15) -#define QCA808X_CDT_ENABLE_TEST BIT(15) -#define QCA808X_CDT_INTER_CHECK_DIS BIT(13) -#define QCA808X_CDT_STATUS BIT(11) -#define QCA808X_CDT_LENGTH_UNIT BIT(10) - -#define QCA808X_MMD3_CDT_STATUS 0x8064 -#define QCA808X_MMD3_CDT_DIAG_PAIR_A 0x8065 -#define QCA808X_MMD3_CDT_DIAG_PAIR_B 0x8066 -#define QCA808X_MMD3_CDT_DIAG_PAIR_C 0x8067 -#define QCA808X_MMD3_CDT_DIAG_PAIR_D 0x8068 -#define QCA808X_CDT_DIAG_LENGTH_SAME_SHORT GENMASK(15, 8) -#define QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT GENMASK(7, 0) - -#define QCA808X_CDT_CODE_PAIR_A GENMASK(15, 12) -#define QCA808X_CDT_CODE_PAIR_B GENMASK(11, 8) -#define QCA808X_CDT_CODE_PAIR_C GENMASK(7, 4) -#define QCA808X_CDT_CODE_PAIR_D GENMASK(3, 0) - -#define QCA808X_CDT_STATUS_STAT_TYPE GENMASK(1, 0) -#define QCA808X_CDT_STATUS_STAT_FAIL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 0) -#define QCA808X_CDT_STATUS_STAT_NORMAL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 1) -#define QCA808X_CDT_STATUS_STAT_SAME_OPEN FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 2) -#define QCA808X_CDT_STATUS_STAT_SAME_SHORT FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 3) - -#define QCA808X_CDT_STATUS_STAT_MDI GENMASK(3, 2) -#define QCA808X_CDT_STATUS_STAT_MDI1 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 1) -#define QCA808X_CDT_STATUS_STAT_MDI2 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 2) -#define QCA808X_CDT_STATUS_STAT_MDI3 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 3) - -/* NORMAL are MDI with type set to 0 */ -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI1 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ - QCA808X_CDT_STATUS_STAT_MDI1) -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ - QCA808X_CDT_STATUS_STAT_MDI1) -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI2 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ - QCA808X_CDT_STATUS_STAT_MDI2) -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ - QCA808X_CDT_STATUS_STAT_MDI2) -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI3 -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ - QCA808X_CDT_STATUS_STAT_MDI3) -#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ - QCA808X_CDT_STATUS_STAT_MDI3) - -/* Added for reference of existence but should be handled by wait_for_completion already */ -#define QCA808X_CDT_STATUS_STAT_BUSY (BIT(1) | BIT(3)) - #define QCA808X_MMD7_LED_GLOBAL 0x8073 #define QCA808X_LED_BLINK_1 GENMASK(11, 6) #define QCA808X_LED_BLINK_2 GENMASK(5, 0) @@ -406,86 +356,6 @@ static int qca808x_soft_reset(struct phy_device *phydev) return ret; } -static bool qca808x_cdt_fault_length_valid(int cdt_code) -{ - switch (cdt_code) { - case QCA808X_CDT_STATUS_STAT_SAME_SHORT: - case QCA808X_CDT_STATUS_STAT_SAME_OPEN: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT: - return true; - default: - return false; - } -} - -static int qca808x_cable_test_result_trans(int cdt_code) -{ - switch (cdt_code) { - case QCA808X_CDT_STATUS_STAT_NORMAL: - return ETHTOOL_A_CABLE_RESULT_CODE_OK; - case QCA808X_CDT_STATUS_STAT_SAME_SHORT: - return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT; - case QCA808X_CDT_STATUS_STAT_SAME_OPEN: - return ETHTOOL_A_CABLE_RESULT_CODE_OPEN; - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN: - case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT: - return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT; - case QCA808X_CDT_STATUS_STAT_FAIL: - default: - return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC; - } -} - -static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair, - int result) -{ - int val; - u32 cdt_length_reg = 0; - - switch (pair) { - case ETHTOOL_A_CABLE_PAIR_A: - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_A; - break; - case ETHTOOL_A_CABLE_PAIR_B: - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_B; - break; - case ETHTOOL_A_CABLE_PAIR_C: - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_C; - break; - case ETHTOOL_A_CABLE_PAIR_D: - cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_D; - break; - default: - return -EINVAL; - } - - val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg); - if (val < 0) - return val; - - if (result == ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT) - val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_SAME_SHORT, val); - else - val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT, val); - - return at803x_cdt_fault_length(val); -} - static int qca808x_cable_test_start(struct phy_device *phydev) { int ret; @@ -527,81 +397,6 @@ static int qca808x_cable_test_start(struct phy_device *phydev) return 0; } -static int qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair, - u16 status) -{ - int length, result; - u16 pair_code; - - switch (pair) { - case ETHTOOL_A_CABLE_PAIR_A: - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_A, status); - break; - case ETHTOOL_A_CABLE_PAIR_B: - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_B, status); - break; - case ETHTOOL_A_CABLE_PAIR_C: - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_C, status); - break; - case ETHTOOL_A_CABLE_PAIR_D: - pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_D, status); - break; - default: - return -EINVAL; - } - - result = qca808x_cable_test_result_trans(pair_code); - ethnl_cable_test_result(phydev, pair, result); - - if (qca808x_cdt_fault_length_valid(pair_code)) { - length = qca808x_cdt_fault_length(phydev, pair, result); - ethnl_cable_test_fault_length(phydev, pair, length); - } - - return 0; -} - -static int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) -{ - int ret, val; - - *finished = false; - - val = QCA808X_CDT_ENABLE_TEST | - QCA808X_CDT_LENGTH_UNIT; - ret = at803x_cdt_start(phydev, val); - if (ret) - return ret; - - ret = at803x_cdt_wait_for_completion(phydev, QCA808X_CDT_ENABLE_TEST); - if (ret) - return ret; - - val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS); - if (val < 0) - return val; - - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_A, val); - if (ret) - return ret; - - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_B, val); - if (ret) - return ret; - - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_C, val); - if (ret) - return ret; - - ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_D, val); - if (ret) - return ret; - - *finished = true; - - return 0; -} - static int qca808x_get_features(struct phy_device *phydev) { int ret; diff --git a/drivers/net/phy/qcom/qcom-phy-lib.c b/drivers/net/phy/qcom/qcom-phy-lib.c index e0295d4b4a51..786bfc39912c 100644 --- a/drivers/net/phy/qcom/qcom-phy-lib.c +++ b/drivers/net/phy/qcom/qcom-phy-lib.c @@ -5,6 +5,7 @@ #include #include +#include #include "qcom.h" @@ -311,6 +312,42 @@ int at803x_prepare_config_aneg(struct phy_device *phydev) } EXPORT_SYMBOL_GPL(at803x_prepare_config_aneg); +int at803x_read_status(struct phy_device *phydev) +{ + struct at803x_ss_mask ss_mask = { 0 }; + int err, old_link = phydev->link; + + /* Update the link, but return if there was an error */ + err = genphy_update_link(phydev); + if (err) + return err; + + /* why bother the PHY if nothing can have changed */ + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) + return 0; + + phydev->speed = SPEED_UNKNOWN; + phydev->duplex = DUPLEX_UNKNOWN; + phydev->pause = 0; + phydev->asym_pause = 0; + + err = genphy_read_lpa(phydev); + if (err < 0) + return err; + + ss_mask.speed_mask = AT803X_SS_SPEED_MASK; + ss_mask.speed_shift = __bf_shf(AT803X_SS_SPEED_MASK); + err = at803x_read_specific_status(phydev, ss_mask); + if (err < 0) + return err; + + if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) + phy_resolve_aneg_pause(phydev); + + return 0; +} +EXPORT_SYMBOL_GPL(at803x_read_status); + static int at803x_get_downshift(struct phy_device *phydev, u8 *d) { int val; @@ -427,3 +464,159 @@ int at803x_cdt_wait_for_completion(struct phy_device *phydev, return ret < 0 ? ret : 0; } EXPORT_SYMBOL_GPL(at803x_cdt_wait_for_completion); + +static bool qca808x_cdt_fault_length_valid(int cdt_code) +{ + switch (cdt_code) { + case QCA808X_CDT_STATUS_STAT_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT: + return true; + default: + return false; + } +} + +static int qca808x_cable_test_result_trans(int cdt_code) +{ + switch (cdt_code) { + case QCA808X_CDT_STATUS_STAT_NORMAL: + return ETHTOOL_A_CABLE_RESULT_CODE_OK; + case QCA808X_CDT_STATUS_STAT_SAME_SHORT: + return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT; + case QCA808X_CDT_STATUS_STAT_SAME_OPEN: + return ETHTOOL_A_CABLE_RESULT_CODE_OPEN; + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN: + case QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT: + return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT; + case QCA808X_CDT_STATUS_STAT_FAIL: + default: + return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC; + } +} + +static int qca808x_cdt_fault_length(struct phy_device *phydev, int pair, + int result) +{ + int val; + u32 cdt_length_reg = 0; + + switch (pair) { + case ETHTOOL_A_CABLE_PAIR_A: + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_A; + break; + case ETHTOOL_A_CABLE_PAIR_B: + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_B; + break; + case ETHTOOL_A_CABLE_PAIR_C: + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_C; + break; + case ETHTOOL_A_CABLE_PAIR_D: + cdt_length_reg = QCA808X_MMD3_CDT_DIAG_PAIR_D; + break; + default: + return -EINVAL; + } + + val = phy_read_mmd(phydev, MDIO_MMD_PCS, cdt_length_reg); + if (val < 0) + return val; + + if (result == ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT) + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_SAME_SHORT, val); + else + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT, val); + + return at803x_cdt_fault_length(val); +} + +static int qca808x_cable_test_get_pair_status(struct phy_device *phydev, u8 pair, + u16 status) +{ + int length, result; + u16 pair_code; + + switch (pair) { + case ETHTOOL_A_CABLE_PAIR_A: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_A, status); + break; + case ETHTOOL_A_CABLE_PAIR_B: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_B, status); + break; + case ETHTOOL_A_CABLE_PAIR_C: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_C, status); + break; + case ETHTOOL_A_CABLE_PAIR_D: + pair_code = FIELD_GET(QCA808X_CDT_CODE_PAIR_D, status); + break; + default: + return -EINVAL; + } + + result = qca808x_cable_test_result_trans(pair_code); + ethnl_cable_test_result(phydev, pair, result); + + if (qca808x_cdt_fault_length_valid(pair_code)) { + length = qca808x_cdt_fault_length(phydev, pair, result); + ethnl_cable_test_fault_length(phydev, pair, length); + } + + return 0; +} + +int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) +{ + int ret, val; + + *finished = false; + + val = QCA808X_CDT_ENABLE_TEST | + QCA808X_CDT_LENGTH_UNIT; + ret = at803x_cdt_start(phydev, val); + if (ret) + return ret; + + ret = at803x_cdt_wait_for_completion(phydev, QCA808X_CDT_ENABLE_TEST); + if (ret) + return ret; + + val = phy_read_mmd(phydev, MDIO_MMD_PCS, QCA808X_MMD3_CDT_STATUS); + if (val < 0) + return val; + + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_A, val); + if (ret) + return ret; + + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_B, val); + if (ret) + return ret; + + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_C, val); + if (ret) + return ret; + + ret = qca808x_cable_test_get_pair_status(phydev, ETHTOOL_A_CABLE_PAIR_D, val); + if (ret) + return ret; + + *finished = true; + + return 0; +} +EXPORT_SYMBOL_GPL(qca808x_cable_test_get_status); diff --git a/drivers/net/phy/qcom/qcom.h b/drivers/net/phy/qcom/qcom.h index c127d8f50f0f..dc259bbf0678 100644 --- a/drivers/net/phy/qcom/qcom.h +++ b/drivers/net/phy/qcom/qcom.h @@ -54,6 +54,55 @@ #define AT803X_CDT_STATUS_STAT_MASK GENMASK(9, 8) #define AT803X_CDT_STATUS_DELTA_TIME_MASK GENMASK(7, 0) +#define QCA808X_CDT_ENABLE_TEST BIT(15) +#define QCA808X_CDT_INTER_CHECK_DIS BIT(13) +#define QCA808X_CDT_STATUS BIT(11) +#define QCA808X_CDT_LENGTH_UNIT BIT(10) + +#define QCA808X_MMD3_CDT_STATUS 0x8064 +#define QCA808X_MMD3_CDT_DIAG_PAIR_A 0x8065 +#define QCA808X_MMD3_CDT_DIAG_PAIR_B 0x8066 +#define QCA808X_MMD3_CDT_DIAG_PAIR_C 0x8067 +#define QCA808X_MMD3_CDT_DIAG_PAIR_D 0x8068 +#define QCA808X_CDT_DIAG_LENGTH_SAME_SHORT GENMASK(15, 8) +#define QCA808X_CDT_DIAG_LENGTH_CROSS_SHORT GENMASK(7, 0) + +#define QCA808X_CDT_CODE_PAIR_A GENMASK(15, 12) +#define QCA808X_CDT_CODE_PAIR_B GENMASK(11, 8) +#define QCA808X_CDT_CODE_PAIR_C GENMASK(7, 4) +#define QCA808X_CDT_CODE_PAIR_D GENMASK(3, 0) + +#define QCA808X_CDT_STATUS_STAT_TYPE GENMASK(1, 0) +#define QCA808X_CDT_STATUS_STAT_FAIL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 0) +#define QCA808X_CDT_STATUS_STAT_NORMAL FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 1) +#define QCA808X_CDT_STATUS_STAT_SAME_OPEN FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 2) +#define QCA808X_CDT_STATUS_STAT_SAME_SHORT FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_TYPE, 3) + +#define QCA808X_CDT_STATUS_STAT_MDI GENMASK(3, 2) +#define QCA808X_CDT_STATUS_STAT_MDI1 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 1) +#define QCA808X_CDT_STATUS_STAT_MDI2 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 2) +#define QCA808X_CDT_STATUS_STAT_MDI3 FIELD_PREP_CONST(QCA808X_CDT_STATUS_STAT_MDI, 3) + +/* NORMAL are MDI with type set to 0 */ +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI1 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ + QCA808X_CDT_STATUS_STAT_MDI1) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI1_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ + QCA808X_CDT_STATUS_STAT_MDI1) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI2 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ + QCA808X_CDT_STATUS_STAT_MDI2) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI2_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ + QCA808X_CDT_STATUS_STAT_MDI2) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_NORMAL QCA808X_CDT_STATUS_STAT_MDI3 +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_OPEN (QCA808X_CDT_STATUS_STAT_SAME_OPEN |\ + QCA808X_CDT_STATUS_STAT_MDI3) +#define QCA808X_CDT_STATUS_STAT_CROSS_SHORT_WITH_MDI3_SAME_SHORT (QCA808X_CDT_STATUS_STAT_SAME_SHORT |\ + QCA808X_CDT_STATUS_STAT_MDI3) + +/* Added for reference of existence but should be handled by wait_for_completion already */ +#define QCA808X_CDT_STATUS_STAT_BUSY (BIT(1) | BIT(3)) + #define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C #define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B #define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A @@ -110,6 +159,7 @@ int at803x_read_specific_status(struct phy_device *phydev, struct at803x_ss_mask ss_mask); int at803x_config_mdix(struct phy_device *phydev, u8 ctrl); int at803x_prepare_config_aneg(struct phy_device *phydev); +int at803x_read_status(struct phy_device *phydev); int at803x_get_tunable(struct phy_device *phydev, struct ethtool_tunable *tuna, void *data); int at803x_set_tunable(struct phy_device *phydev, @@ -118,3 +168,4 @@ int at803x_cdt_fault_length(int dt); int at803x_cdt_start(struct phy_device *phydev, u32 cdt_start); int at803x_cdt_wait_for_completion(struct phy_device *phydev, u32 cdt_en); +int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished); From patchwork Tue Feb 6 17:31:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1701288dyb; Tue, 6 Feb 2024 09:35:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9QcGYZKdWsESywykDD+l4cbCI7/3bCwt5DU8NVbroHCTWdTgyjooip+VRjHNVelbBOMU2 X-Received: by 2002:a05:6a20:72a6:b0:19e:a23f:2977 with SMTP id o38-20020a056a2072a600b0019ea23f2977mr114748pzk.11.1707240921729; Tue, 06 Feb 2024 09:35:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240921; cv=pass; d=google.com; s=arc-20160816; b=0sixDoZ9MPKNvcCQWjlxE191oSf723jU/Z9cTby7fpuY94mSC4MN6C0qSA5Ais8ROQ 2/0NEDilSZnfDhUr7KzqIHPFjTMXOJxXJMutcjXqpRrB7nS4mEyc4EGnvQEI4dHqbGPG yvSLzFfiBDDxHKEK37lfYO04Znxh0J+v37rs2ySIJ1mfMi3IirJBQ3ls+7MsHYRZSrXC +iDfTEL5r+u8GPbagWvaSDrlzklzbqOgBRE4NaQdSrZjeWJauOcHdhjO/eUDJv+FWb1t NWBvSg/KXtcOoux0UQw6vs6RsDnXFN2osSZjY/9Ydb2x2t3l1Gt5kttrByE195yFxZjS E1Dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bUmCO360MsO9JwRC/7FCAnzALXs5wMt0yoX0PpFvJIY=; fh=C5DCVE9Nw8hxODZVJOSq5Yq1VE7/IqUKSLlYkMH4A8c=; b=WF5NMQMyt2ltlSqvdWojVQW0ptRUsyz9ABR2IG0+9fLJN9ZbjIte1kUIxotHc1jk4o DXsNSMyNvhE+B+WBh37SSoQjsNtB2zea7SXNyISZl46uBg1+NvIO948NhXg2QL2V0VOY uCWu15amir/owo5ts5+PGFzqprdYuFFdyP6gELffxqAcwLmhI3ZCHPQNYTUV6qwTwB4M cq4Ra+cvwGNeI5Df50hBwuQfI40IoFSzLAelFd9tZEzCaThIDNTS4Lle1fQFIlobisx2 qQBRHhxSKsFSogPM3o91uVRnWI/vA03DvKkoT38UhAu/QrcLD3rsisGe7iVGdjzqN0sL h2ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mYraO9tY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55387-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55387-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCUom0zUFKJEd/hZHa0O4hi7l1KfNi5f7uUR9XCXT1QSFRNk7siz7yoiUG0GGaoUOCisYLIvDWqY+76NpsgQ60YfiBRTNA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j8-20020a634a48000000b005cdc2cc9a15si1972795pgl.742.2024.02.06.09.35.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:35:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55387-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mYraO9tY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55387-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55387-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EDEA82882A6 for ; Tue, 6 Feb 2024 17:35:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11CCA17742; Tue, 6 Feb 2024 17:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mYraO9tY" Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B177513FEB; Tue, 6 Feb 2024 17:33:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240785; cv=none; b=ru0G1Yz2TbOMVhPJXzy2gt0Ow8X6HDcwLOmWVM2MFP4nEl0CjekZ60KTAVkewFMHHuKn0SNpyRkokogJrAw+HBbANFdVWfxz8lRhAYSWBJJPnPfRTp7q/d++aomHdQPBp8Ay9YU7ieqCobW4DRpKjBMBATZ8CEYCh/yYGwLRPSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240785; c=relaxed/simple; bh=jyM0CHznvQWMvjL8i2pVQYft4g2oYeiCv4EYtUJLp6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g9SKTU9rlzQT26B9rxw0IxccK1XffIc8cvWYsPnVSxJDgm1Yohv79lgiGY5yx2nfydT4/ajjpQq1nk5x7rJ+5vVepPbOalRujxcbkhr17Uzh09bMMIFWxT/DoCyH3t9ItCIqkyW5HnXov+x6e8+DEWx+z0qAjdtmwMeLvcdnoR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mYraO9tY; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-337cc8e72f5so4438530f8f.1; Tue, 06 Feb 2024 09:33:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240782; x=1707845582; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bUmCO360MsO9JwRC/7FCAnzALXs5wMt0yoX0PpFvJIY=; b=mYraO9tYRpBMd77ANgg9cntTtmmEXkE6ZAiJKifnREfcI7SEF/uY0kt70L6H1wHpK8 aBNQEa4Mqpx3uNZFIEYpV9xKci1zmYaSFhtj5ZB6n69Uey6wsHNfG+BsDbQyj4y8YP5c UVuMp2/qD3jsKrCbQLQrb4LcP60E6HryB/PLR5LDS8eUF4OtAc1+S0KyoYWaRbRp8HYv oZudVJ9Z8EEvuUaXYAMg4TPl9zX8K4P7cFo12DNievMAZ26w/uFufCwBjAMlMFBWUsVX N5eRREZjEJJPfhqPUZgadVVsVrE8tDoP/Ft9PdCGO1ep5M0eWRkzxmoYFwWlBcNAjyuO md8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240782; x=1707845582; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bUmCO360MsO9JwRC/7FCAnzALXs5wMt0yoX0PpFvJIY=; b=qQj2WAxVV8H4yZyIKCjI2kRma9Vtno/1+7M5uShRWCHq/wjw+HJC1MGY+PhEfqa6fa NQQRtOJSAssZx4LNi0I9DQ+/fB3lO/o8LVuzHON80xRy87K8nCiYKB2znPWu/uCbzRXC S6aEm4a+K1cg/WDMvof3mgtVY1ST/CMDTjaomIqmMgi1RPMVtMIEfudZV+z3Pz3HD0B+ uIijIcl/P3cVnVdf9ZQTP/DLlUJ5qbP3R88mfxgVvfStuFSa0r8qyZQRjbmkaPPbwP0J m7+Qg5nkTjbT/820RFlMiMDXlugwnluSaEMYWUPdR40oyWDEIiMeJXXT5HYrRe/zmpD0 XXjw== X-Gm-Message-State: AOJu0YwQ+7pQaN7zpl1cZlJBHwd4wBa+2Lb/TPJr7ZntGiE2cKrmraQf MWWN/1dMuFjDjzkAvHZkXVGz6yWgigk9j2pX/nRgM/nA4RsI+V3p X-Received: by 2002:a5d:678d:0:b0:33b:1577:a2d1 with SMTP id v13-20020a5d678d000000b0033b1577a2d1mr1401188wru.1.1707240781987; Tue, 06 Feb 2024 09:33:01 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUvkE6eU+hGhupY2V0J0OGIrCKJLP8PAqF8LlWaNyocxW+0ts+d2UlYoavbzeDD6M0V0Abv21nL4RHBl8CbbibEbjleYvacc//1M/yXNMXZZaEh+uKKa3dRYTZsPMx64jiUvHSTmw+utW1MrWy0Ynlc0lHpxOQHTmBydoaoBAoxlc4DyWTknl7w4rQtE+KEENVT8ThbeU4Oe6FrHf680GaJehPXXxksjEf3eWkOps3Stb2kaJR2rlyRTBtgKlJc3/MrtbxYiGeRmFwguWBNI7vBr0KG1OytBVlvz8Wlc6XtzvzzZ0fUBYqg5DPowoj5UuTVAM/ol30VcFzV107IO+Rh600MT3YkH74pMRUX4ZUE/npUcV8/M/Wpr0C5w2yR0Hfa4WSDaJ2caPMLS11CQfJjYWRiWBe3O2AlgP8g5ohp5JjzuZFy3sn7pa6mQ6nfFLBMtP/TnFdq86/NwivcVz6A4WXdA+dJPvZGcN0aPQ9xhQIMVqZ4VkLlx11o57LqjecYqIrQhC7SSUapXS8YEjxhUhyfJnrqlVcMBbqtVIrTVhEcpgbTVGlXGPC+5LElTgIn0Cq6eocUrhnnc6NXIA+zoP9rP/pQfe7aJrcsFWitZFgATqpS/DEvaM2v8hUIi2FTIl2jCrYl78cUmsfcHDhsVgIGfih0t2f4AqLPt3ePEayChUoh7Q== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:00 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Conor Dooley Subject: [net-next PATCH v7 05/10] dt-bindings: net: Document Qcom QCA807x PHY package Date: Tue, 6 Feb 2024 18:31:08 +0100 Message-ID: <20240206173115.7654-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171856712434104 X-GMAIL-MSGID: 1790171856712434104 Document Qcom QCA807x PHY package. Qualcomm QCA807X Ethernet PHY is PHY package of 2 or 5 IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and 1000BASE-T PHY-s. Document the required property to make the PHY package correctly configure and work. Signed-off-by: Christian Marangi Reviewed-by: Conor Dooley Reviewed-by: Andrew Lunn --- .../devicetree/bindings/net/qcom,qca807x.yaml | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/qcom,qca807x.yaml diff --git a/Documentation/devicetree/bindings/net/qcom,qca807x.yaml b/Documentation/devicetree/bindings/net/qcom,qca807x.yaml new file mode 100644 index 000000000000..7290024024f5 --- /dev/null +++ b/Documentation/devicetree/bindings/net/qcom,qca807x.yaml @@ -0,0 +1,184 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/qcom,qca807x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm QCA807x Ethernet PHY + +maintainers: + - Christian Marangi + - Robert Marko + +description: | + Qualcomm QCA8072/5 Ethernet PHY is PHY package of 2 or 5 + IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and + 1000BASE-T PHY-s. + + They feature 2 SerDes, one for PSGMII or QSGMII connection with + MAC, while second one is SGMII for connection to MAC or fiber. + + Both models have a combo port that supports 1000BASE-X and + 100BASE-FX fiber. + + Each PHY inside of QCA807x series has 4 digitally controlled + output only pins that natively drive LED-s for up to 2 attached + LEDs. Some vendor also use these 4 output for GPIO usage without + attaching LEDs. + + Note that output pins can be set to drive LEDs OR GPIO, mixed + definition are not accepted. + +$ref: ethernet-phy-package.yaml# + +properties: + compatible: + enum: + - qcom,qca8072-package + - qcom,qca8075-package + + qcom,package-mode: + description: | + PHY package can be configured in 3 mode following this table: + + First Serdes mode Second Serdes mode + Option 1 PSGMII for copper Disabled + ports 0-4 + Option 2 PSGMII for copper 1000BASE-X / 100BASE-FX + ports 0-4 + Option 3 QSGMII for copper SGMII for + ports 0-3 copper port 4 + + PSGMII mode (option 1 or 2) is configured dynamically based on + the presence of a connected SFP device. + $ref: /schemas/types.yaml#/definitions/string + enum: + - qsgmii + - psgmii + default: psgmii + + qcom,tx-drive-strength-milliwatt: + description: set the TX Amplifier value in mv. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [140, 160, 180, 200, 220, + 240, 260, 280, 300, 320, + 400, 500, 600] + default: 600 + +patternProperties: + ^ethernet-phy@[a-f0-9]+$: + $ref: ethernet-phy.yaml# + + properties: + qcom,dac-full-amplitude: + description: + Set Analog MDI driver amplitude to FULL. + + With this not defined, amplitude is set to DSP. + (amplitude is adjusted based on cable length) + + With this enabled and qcom,dac-full-bias-current + and qcom,dac-disable-bias-current-tweak disabled, + bias current is half. + type: boolean + + qcom,dac-full-bias-current: + description: + Set Analog MDI driver bias current to FULL. + + With this not defined, bias current is set to DSP. + (bias current is adjusted based on cable length) + + Actual bias current might be different with + qcom,dac-disable-bias-current-tweak disabled. + type: boolean + + qcom,dac-disable-bias-current-tweak: + description: | + Set Analog MDI driver bias current to disable tweak + to bias current. + + With this not defined, bias current tweak are enabled + by default. + + With this enabled the following tweak are NOT applied: + - With both FULL amplitude and FULL bias current: bias current + is set to half. + - With only DSP amplitude: bias current is set to half and + is set to 1/4 with cable < 10m. + - With DSP bias current (included both DSP amplitude and + DSP bias current): bias current is half the detected current + with cable < 10m. + type: boolean + + gpio-controller: true + + '#gpio-cells': + const: 2 + + if: + required: + - gpio-controller + then: + properties: + leds: false + + unevaluatedProperties: false + +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + #include + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy-package@0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,qca8075-package"; + reg = <0>; + + qcom,package-mode = "qsgmii"; + + ethernet-phy@0 { + reg = <0>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_LAN; + default-state = "keep"; + }; + }; + }; + + ethernet-phy@1 { + reg = <1>; + }; + + ethernet-phy@2 { + reg = <2>; + + gpio-controller; + #gpio-cells = <2>; + }; + + ethernet-phy@3 { + reg = <3>; + }; + + ethernet-phy@4 { + reg = <4>; + }; + }; + }; From patchwork Tue Feb 6 17:31:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1701415dyb; Tue, 6 Feb 2024 09:35:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrjmEtSmX4Ry8MYQ7eptg7+kEFPHRpjO/ybcjFcvucAtdz9rf04jnce27SY4BXNlloemoG X-Received: by 2002:a05:6359:4290:b0:176:4ac9:5509 with SMTP id kp16-20020a056359429000b001764ac95509mr241996rwb.13.1707240932524; Tue, 06 Feb 2024 09:35:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240932; cv=pass; d=google.com; s=arc-20160816; b=FGlBCDXGAJMERl8mKttoJbfTnqfFGypbnFHKqQW9PNDDhvqB5mocfeOdtMAo1GExjb p8tbw2BeVd8KnpcQnBvwQlVEtmzAoZ+h61QfkTZqJcoQT0nraRfPEfpgBm3yMrKTznut 2fnJyoihe2YJUaQULOqYT06jP6wIm9hErG3vwW3ysIds4ljibO2flEZrTBz5IQyaS1Uy FHrmCPFiqWrrjk5WkXxodL2jJU06Gtv3JEh/4bBbUX9//IGxCdlpSv/Xk4OrLKV4H1NP 2RAYIDr+cNwLUV58tEMAq1fry4eEfzkFWCQVzLQDRnrS0bB1mpWefpIXJ3il58t1OooI /DHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=f9ktY0liDe4oFr0FI8er2FX43RIFT8krH3jH7tSCLC8=; fh=v4rXDxK705WJ1VV272FGNqJjfcsb67tqmZrEv1esEJk=; b=xv/jvSlsumkVS82cGhoUzJeQ0NUda9eJkslPsIKS6/V/++0e5md5eyXHl/75tn4lx5 tTwt8fs4+9JPnLeWiR8WBhxH/lTYiAVOLI4pRv8SLjGwrPnbj1HToMCuKROg4nnx0kND tApgWiQGDybsIlWcSgpQ5AEOz0SZC/vMGsN4CXqjgxCTktXVk7haB1bAHktSvDXl8z5c KcGQ+oC51xEYAn6tlyMOT1UCEemT+mIfYU5VmdmN1VQ6D0c5GZCSwgyn7cTbM0UJvaHx 3xQqAOIUiEmMdxy9JgdYu5NjcKqtokeCvGCH+M7AWUiF+Jg0PW9MzzWwZiKkHncJucTk gICw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V5AgS47d; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55388-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55388-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCUyYpsxLUtxPAKiheBunuTeSwPhe7MN/ArQtpLxPfSysJ+SaWgEUMxYhlXsJrbPGDfcXot2Ah41hdzIN2pq3DAi1CbOCg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q12-20020a63f94c000000b005cf8d935c1bsi1997962pgk.786.2024.02.06.09.35.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:35:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55388-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=V5AgS47d; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55388-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55388-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DEB822833C4 for ; Tue, 6 Feb 2024 17:35:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B4B017BAE; Tue, 6 Feb 2024 17:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V5AgS47d" Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D19761426E; Tue, 6 Feb 2024 17:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240787; cv=none; b=TEShTPO67NXizj/s9QnpycaiH0XNn88VoLxiMEm2ltoITrOYELz1ZdmqHItTnSn53BLRBVylX4ONTsAVhQ0mo/yTKc05VDJj65PZuCsXX8KzKLwvBtp//tYcF08fLRpgYwzSeRdb3nsVRBbI3V4+xsg2ENh5xUOtzKuB9oR8b8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240787; c=relaxed/simple; bh=GfIE22OybaPa3DRd0WpoTsg7iaxG7t9NSj5FJLsMdVE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kOStpf7uQO0WVLdQ4tcDRXvW8hluX0jxFhrkeHf/vJb6r8WSUyDJLJrnxveVR+BJH/NaXl8pIdaLWklkqSWOWgd78ZjLyyPngVJ00ydWzBoiuKogJAnQ1TRF0QJ77LQOyFZ/fPxSiUHoUOiGURLonzzkvEsaHLAI+YT9sjyto0U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V5AgS47d; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-40fc52c2ae4so41420745e9.3; Tue, 06 Feb 2024 09:33:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240784; x=1707845584; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=f9ktY0liDe4oFr0FI8er2FX43RIFT8krH3jH7tSCLC8=; b=V5AgS47dE0YQ9VIPCO84Zv+BuymMykVRfWmdmtWMBron0blIuK1QLIo/wXIOUpMmNi J0bHUMJSo+DCgoVKj3fG983WohpGyJ8sm2hqGutp2+7MaUbS6Crk49Yy/ZIvtZ7W68VE oPMQNaT0d84qNG7zc6Z0G7iDwPlRrNxzAeo0y4oicHynb5DdqZzfDAaSTRppmLn4vgak Kv2OYqRNbEiGM+goPXM7MVVOpkGAvY2SdF9Yle/GL3uRYkyG5T9pM2KgaKD2fINiWSGB HplADSrKDSlaHID499mPocNGYNkKSwE2ajfg3qWScDroHMfbgFzVapF9fiMVQquTyOiN XJOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240784; x=1707845584; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f9ktY0liDe4oFr0FI8er2FX43RIFT8krH3jH7tSCLC8=; b=T/x15cw/S+O0Hs7hdmMZRuu17xekag2VUaO/U33OkZbEr0Z5OFv2Ir+I5qq+Bpg+zg LEYRPr+IRRzWAQ9VU2DYhza5BTKD0G4q7gw8n/omq68hoyFKLN8Uc0uBT2zkNiHoydvQ LPsvWICEuCRnNXd9dg7UigYMGDIS0tOtclomEuNxJMXVCOrj5t1MMJRTH04iytimKYW2 zLtwqoHBpjJVrgf1GEh+NJoFH66bH80cdgiQruaWt77ZYGCzPuWHx0Uj49p47vkFFs3C TFzPdX5kzDUzpO1wqmpn3ym6+GoPKH87+uRokJzL0V+/yZMHpLPUqpAv+fh9Kw9pihOV dQDg== X-Gm-Message-State: AOJu0YwxscUaB9MpCIuV84WM5JcFOM2+cQ80NvzFkO0xGm1Qqa3+/G6v We11HvEZPPRYXRB4ftnu2YUD1vgdGAFJ4VkYHH4kubVUo/VNyh5Z X-Received: by 2002:a05:600c:354d:b0:40f:d3da:85cf with SMTP id i13-20020a05600c354d00b0040fd3da85cfmr2754650wmq.8.1707240783927; Tue, 06 Feb 2024 09:33:03 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCX+MB19xzCAzIriGYNzEELPb3JpNFynCloU7S3gPgqQ8tnwvzzVkYC5N1tCNw6sT/z4XoeekTXsXXcC+AIkRsvx3ubvP5OvPvkYGMn/2KRYrF5bp2NpIH2GjKfQHPIEPdKRu9Nd0dtEIpJVobSRI6kqRepGGw/9hzRxNfhWhFJ4oBxv8N3hw+zSKPWoP4RvDNNZOSKDYL4jR0ccQDC5Z++dscCcMirEA8gL7iKVon73anKMIRKe+ZzNZ8uJvoEA5aLaNvtSiwfPxreC6tqmwyASfSXsO48zNUo4U1l+xsMHCBzVx2ZImphHbb58dWIkR06I0ARWpty91iNWY2j/EMjfVI+IoTnDOY3o3XQeQDuk/MFuabp0YyqEGVLFH1H9EeSNqCKeqJBS0KKsrR92S+/bZuL2dxa3ir9JGyyzPAtsg0GpwCApXLjFwi6gSad8BE7Kup3k/Yi1EOF26UrXItq67fd8Xti4uh4DNw1f3a2Oq5gcAVCDfChcZw0sClaVTFYgR/8VEa9VBEwc7DHdxTQAnCfgPJ8+n79WKZbXVrp4KP7VLJvmWGRi/FBldorwj4YwJssFWoiaNpCHrA/9NIkt7MAJeXOf7/JD4Q4Hr8ambqv2gEy2QW96DOeeExM6aUDJkugQG/z+CMAixpMVqIY4i0Y8OQRFcSWQseN4NKUm3l2fkddRFw== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:02 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 06/10] net: phy: provide whether link has changed in c37_read_status Date: Tue, 6 Feb 2024 18:31:09 +0100 Message-ID: <20240206173115.7654-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171868389535473 X-GMAIL-MSGID: 1790171868389535473 Some PHY driver might require additional regs call after genphy_c37_read_status() is called. Expand genphy_c37_read_status to provide a bool wheather the link has changed or not to permit PHY driver to skip additional regs call if nothing has changed. Every user of genphy_c37_read_status() is updated with the new additional bool. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/phy/broadcom.c | 3 ++- drivers/net/phy/phy_device.c | 11 +++++++++-- drivers/net/phy/qcom/at803x.c | 3 ++- include/linux/phy.h | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 312a8bb35d78..370e4ed45098 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -665,10 +665,11 @@ static int bcm54616s_config_aneg(struct phy_device *phydev) static int bcm54616s_read_status(struct phy_device *phydev) { struct bcm54616s_phy_priv *priv = phydev->priv; + bool changed; int err; if (priv->mode_1000bx_en) - err = genphy_c37_read_status(phydev); + err = genphy_c37_read_status(phydev, &changed); else err = genphy_read_status(phydev); diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 9014ac3c0fc8..861b09cff3f7 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2617,12 +2617,15 @@ EXPORT_SYMBOL(genphy_read_status); /** * genphy_c37_read_status - check the link status and update current link state * @phydev: target phy_device struct + * @changed: pointer where to store if link changed * * Description: Check the link, then figure out the current state * by comparing what we advertise with what the link partner * advertises. This function is for Clause 37 1000Base-X mode. + * + * If link has changed, @changed is set to true, false otherwise. */ -int genphy_c37_read_status(struct phy_device *phydev) +int genphy_c37_read_status(struct phy_device *phydev, bool *changed) { int lpa, err, old_link = phydev->link; @@ -2632,9 +2635,13 @@ int genphy_c37_read_status(struct phy_device *phydev) return err; /* why bother the PHY if nothing can have changed */ - if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) + if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) { + *changed = false; return 0; + } + /* Signal link has changed */ + *changed = true; phydev->duplex = DUPLEX_UNKNOWN; phydev->pause = 0; phydev->asym_pause = 0; diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c index 3e3ee4c1d4bc..4717c59d51d0 100644 --- a/drivers/net/phy/qcom/at803x.c +++ b/drivers/net/phy/qcom/at803x.c @@ -912,9 +912,10 @@ static int at8031_config_intr(struct phy_device *phydev) static int at8031_read_status(struct phy_device *phydev) { struct at803x_priv *priv = phydev->priv; + bool changed; if (priv->is_1000basex) - return genphy_c37_read_status(phydev); + return genphy_c37_read_status(phydev, &changed); return at803x_read_status(phydev); } diff --git a/include/linux/phy.h b/include/linux/phy.h index f8ce8a757ed0..e9aaa0dfe675 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1876,7 +1876,7 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, /* Clause 37 */ int genphy_c37_config_aneg(struct phy_device *phydev); -int genphy_c37_read_status(struct phy_device *phydev); +int genphy_c37_read_status(struct phy_device *phydev, bool *changed); /* Clause 45 PHY */ int genphy_c45_restart_aneg(struct phy_device *phydev); From patchwork Tue Feb 6 17:31:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1702063dyb; Tue, 6 Feb 2024 09:36:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEseZCv3MpHBumqtWPrSQ+6fdhGOCAApWSy8xLET53aKubQAFIl1Vl5ohtnK0oXS2oLo0MU X-Received: by 2002:a05:6a21:a593:b0:19e:32fa:b178 with SMTP id gd19-20020a056a21a59300b0019e32fab178mr2191841pzc.31.1707240990903; Tue, 06 Feb 2024 09:36:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240990; cv=pass; d=google.com; s=arc-20160816; b=nXkRmj7/mSyAT4aiGcy+SattzqbHtieAOtmymv+3Lof1NqaITgDhc1htg4DTCKrd+H Lrf/fQd0xZ9HbTQXDaamwEatC+axISa8+Li2qeZDdWfbfvOLT/3sf1dSpycauklBwaEb M7Py8X8do3lYjBzco9VXEqZaT/A9MquYdav945f/q0hJsfgKHmu6Te8cgbxzWOsyDmb7 fDE9posejeYVA+4VSwMw43Dd4QjqemLlx2pj7MW3uAOfIuDk3uGf5m776fk2s5M4P2a7 e9ASFshPHZg2nnVlAIjW407dPWm8OMbwJm/NKKYlwXSXb6EOzUhG3q+UPwblq0N/p/zH 0Srg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=PUDKgqKuLVdcqW+r3q8aBq+kKkEgLeSn0XaqiRPMSlA=; fh=6ANlIdHUFo/vOqQCX+Xl0Rvu/vLQS0vVnYXD3REW7ns=; b=lytEQ6IuYvputyDJmu89q4miJibCI9Mnxjp7GhmwXgZ6UX1biPCe9SqQXPNj2qst7M PMSc2jtDzAnL2IqlPmLqAGutPzVnC72JbSJy+wyeKiRnYSaKIWjxLyHXnGR4qv373SMo sxd1MC8xodSQc3WsaMLBugvsJip0mFBopwzdqk31aYkPoZxK8PuWn5BT9y1Jp8nfguev AuKxm6ydabLF1WCaes0Ws7+5xF8oxy+HbKxwRVExlQK2WCyr3jDhXCt4yNPXaSymialg 7GYJ3xWlUzqoEH+C7xHjwHcng6ZttXInGyP3JI2pmqNqWpJ1k/pQR7XDIZyRP/3Gt/1t 24aQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=h9s5RVmG; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55389-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55389-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCWtmO6gfgPMnvvHwk/StohoJFmYObRYmhCTSyLwqltqLDfugJP5rPUXFloBniSz9FH33+bK6Vi6VGmVvnjjAH7CLiryAw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j8-20020a634a48000000b005cdc2cc9a15si1972795pgl.742.2024.02.06.09.36.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55389-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=h9s5RVmG; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55389-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55389-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8D152287A88 for ; Tue, 6 Feb 2024 17:36:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 647E41B977; Tue, 6 Feb 2024 17:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h9s5RVmG" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AA64168BA; Tue, 6 Feb 2024 17:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240790; cv=none; b=UEnkLqdEWiDr2y6rh+q5BJgi7mFEuOEIf+TVg7OGv6a4W+iTZe3von+0c00AQXadpitGRZQmPdgjXQTT15wAp2S2lHYqx7P2u6KQrXDJUjc4pGCM6/W0OSCY1zNtRs2RIURFYivPgyBoZv5Uzn8E7IMN8GQ/7NC+2w7Lt61+BfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240790; c=relaxed/simple; bh=Ae4QGhSKhFkw8cl/A+6Rcw17tpPOwIZgu5VCFIaSz+g=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EUGu1DHgUjfB1/GCniFICFPGUXlZMxF2ViRsOOlT0QehY+SxoeQ0vUk/5KJXG8bTWpYSYOPlocf96HtbY1qUyirMo+sMe+OghQSjLrx8ndqr0LqUq1P7JTB1RgqqQDngOa9QZMVP5NbRRoibPkNo1146JymrLMfr1XJq4ZTMUAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h9s5RVmG; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40efcb37373so10005555e9.2; Tue, 06 Feb 2024 09:33:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240786; x=1707845586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PUDKgqKuLVdcqW+r3q8aBq+kKkEgLeSn0XaqiRPMSlA=; b=h9s5RVmGyDp5INXmKNjTyFFg7w4IzICqW1QKSqhSB+t8FfAxMlvvXSiRZxLYhfxpkh dgCftDPaE/rSkTf+8+qQO/qUqXj8ZY2yuwjMvxIA4QjeYSexa1XT0MqtYkC63TbMKgTN OhkZSEWAgnwD34ukrUxtNCxIOIVi5WbXfpJxBlRBYGS+eQJqvxBmRkWvKP0zLHObcZOx 6FO43xztst2RYi0KCb6tPM4oGt/55YLCJKB05gmVEN5MxcczP+KiJX5Imr6jGw8rUhwH 6GTWIz1CgRmV0mMJagIlMavcg+MKRORZAmjSoG7OHp7XXaeNZsoXjtDxkPMVLyeIqfX8 hIVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240786; x=1707845586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PUDKgqKuLVdcqW+r3q8aBq+kKkEgLeSn0XaqiRPMSlA=; b=dPtHxfGkOpUP1J+UMOCal4Fl0bRr/4GWXTPGiwyNSe5XqKwystuss6/bljvUz1zjLB H89k61MQAznUewCUhvSJ5vi8EcyydKl/316am535dlcEn39VwlFx7BlULp2IsO4EJfoL lY4ySzbqTDAM0eh2iLzN+rKc5qAvPrHK0r9UBfw6caUktXYIos3x7zxdBw5aOXDhAuql muyT/t1mLqQxWXdbo7dUJezVp6TQ/9HjsBsbRppN6tV6Iqd4ajByfE7W1iq2jIdW2/70 2mL32UcvW20/UrN9fceqUv6O9c5fh/4BJ3vsJYo6DtOXnFfbYIb9IpUkgTqJxLWCbn+2 Z0ZA== X-Gm-Message-State: AOJu0YwXSd4ie77cEhSAKtH5HFfB31jmoCTH4ZgVCP9T+KTqO/Sz8oUw y667C+BsCk2Zc6OL3h+dKiGXMfMeUPao1nFyt7jsjgng81n4zuC3ss46JWuD X-Received: by 2002:a05:600c:a41:b0:40e:f46d:ad35 with SMTP id c1-20020a05600c0a4100b0040ef46dad35mr2834307wmq.36.1707240785809; Tue, 06 Feb 2024 09:33:05 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVm9/IscC4PHuLqMjb6pAl8SWJzO1Efsp/Zl7pFT+nX7Hd/ZJZU+VsW4ycG7o9F5qIbLVtsa4r2bZMKv+OLLNYQl+nJr3FRNm9fOuSNYJ0UwQR67QwBgWb+XvEU2vLjSdvl7wUaBEErKi8EyzL9gH3pBkk9w6GIjfh1a8pJtmvc6xWbxtUs/XUWGg+ONrBTNAJCZMIYkTf2CQZuetLnNUaQ0cNh2qtBHLi7AzGytu9bDoS7DgbZ5CZq/I4CuSfu8poRmJfb/TIlY81nUq2k/XB8K1PjEoY9Px/4zVOcoNokvZhVxQAKZ5mG4qH/NPGaK9YJ8iY5NHSi+f55tp688GfQHAV51KxGK5zSdAckufYhto/4RxziuVEUL4Vo5J/AZH3TtJJ/khZLI+114089ZJmfqwnBE1d7Z/iPQkcYGoYO6zvs84rYoijkU8sjjcZx7xQnFykKxcSywafeGEnAX0YhEt4ETdqHJ2yht29CDJHN9iHdyvmG/T5NxuUBTNfmcuRuZSAuW09PBue06eZ7dEpa8gWnrqyiBSu/1vSRbpxIzur+HK5jbG9rtois0N7t6sykxwBWYf3jgYz/4tK/jm8kKEloLTMc6nG8wT2Gl8vMJ+Rinn/Ps+Mp4WUkI7YMw9q6+xOHWLjtfFHYOsS5H0Yt6+JKau1xPIPHyJWqhF7lcTUQBPQvyA== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:04 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 07/10] net: phy: qcom: add support for QCA807x PHY Family Date: Tue, 6 Feb 2024 18:31:10 +0100 Message-ID: <20240206173115.7654-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171929215434819 X-GMAIL-MSGID: 1790171929215434819 From: Robert Marko This adds driver for the Qualcomm QCA8072 and QCA8075 PHY-s. They are 2 or 5 port IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and 1000BASE-T PHY-s. They feature 2 SerDes, one for PSGMII or QSGMII connection with MAC, while second one is SGMII for connection to MAC or fiber. Both models have a combo port that supports 1000BASE-X and 100BASE-FX fiber. PHY package can be configured in 3 mode following this table: First Serdes mode Second Serdes mode Option 1 PSGMII for copper Disabled ports 0-4 Option 2 PSGMII for copper 1000BASE-X / 100BASE-FX ports 0-4 Option 3 QSGMII for copper SGMII for ports 0-3 copper port 4 Each PHY inside of QCA807x series has 4 digitally controlled output only pins that natively drive LED-s. But some vendors used these to driver generic LED-s controlled by userspace, so lets enable registering each PHY as GPIO controller and add driver for it. These are commonly used in Qualcomm IPQ40xx, IPQ60xx and IPQ807x boards. Co-developed-by: Christian Marangi Signed-off-by: Robert Marko Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/phy/qcom/Kconfig | 8 + drivers/net/phy/qcom/Makefile | 1 + drivers/net/phy/qcom/qca807x.c | 597 +++++++++++++++++++++++++++++++++ 3 files changed, 606 insertions(+) create mode 100644 drivers/net/phy/qcom/qca807x.c diff --git a/drivers/net/phy/qcom/Kconfig b/drivers/net/phy/qcom/Kconfig index 80db24deb689..570626cc8e14 100644 --- a/drivers/net/phy/qcom/Kconfig +++ b/drivers/net/phy/qcom/Kconfig @@ -20,3 +20,11 @@ config QCA808X_PHY select QCOM_NET_PHYLIB help Currently supports the QCA8081 model + +config QCA807X_PHY + tristate "Qualcomm QCA807x PHYs" + select QCOM_NET_PHYLIB + depends on OF_MDIO + help + Currently supports the Qualcomm QCA8072, QCA8075 and the PSGMII + control PHY. diff --git a/drivers/net/phy/qcom/Makefile b/drivers/net/phy/qcom/Makefile index 0362d7ed47be..f24fb550babd 100644 --- a/drivers/net/phy/qcom/Makefile +++ b/drivers/net/phy/qcom/Makefile @@ -3,3 +3,4 @@ obj-$(CONFIG_QCOM_NET_PHYLIB) += qcom-phy-lib.o obj-$(CONFIG_AT803X_PHY) += at803x.o obj-$(CONFIG_QCA83XX_PHY) += qca83xx.o obj-$(CONFIG_QCA808X_PHY) += qca808x.o +obj-$(CONFIG_QCA807X_PHY) += qca807x.o diff --git a/drivers/net/phy/qcom/qca807x.c b/drivers/net/phy/qcom/qca807x.c new file mode 100644 index 000000000000..43fc9cddd975 --- /dev/null +++ b/drivers/net/phy/qcom/qca807x.c @@ -0,0 +1,597 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2023 Sartura Ltd. + * + * Author: Robert Marko + * Christian Marangi + * + * Qualcomm QCA8072 and QCA8075 PHY driver + */ + +#include +#include +#include +#include +#include +#include + +#include "qcom.h" + +#define QCA807X_CHIP_CONFIGURATION 0x1f +#define QCA807X_BT_BX_REG_SEL BIT(15) +#define QCA807X_BT_BX_REG_SEL_FIBER 0 +#define QCA807X_BT_BX_REG_SEL_COPPER 1 +#define QCA807X_CHIP_CONFIGURATION_MODE_CFG_MASK GENMASK(3, 0) +#define QCA807X_CHIP_CONFIGURATION_MODE_QSGMII_SGMII 4 +#define QCA807X_CHIP_CONFIGURATION_MODE_PSGMII_FIBER 3 +#define QCA807X_CHIP_CONFIGURATION_MODE_PSGMII_ALL_COPPER 0 + +#define QCA807X_MEDIA_SELECT_STATUS 0x1a +#define QCA807X_MEDIA_DETECTED_COPPER BIT(5) +#define QCA807X_MEDIA_DETECTED_1000_BASE_X BIT(4) +#define QCA807X_MEDIA_DETECTED_100_BASE_FX BIT(3) + +#define QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION 0x807e +#define QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION_EN BIT(0) + +#define QCA807X_MMD7_1000BASE_T_POWER_SAVE_PER_CABLE_LENGTH 0x801a +#define QCA807X_CONTROL_DAC_MASK GENMASK(2, 0) +/* List of tweaks enabled by this bit: + * - With both FULL amplitude and FULL bias current: bias current + * is set to half. + * - With only DSP amplitude: bias current is set to half and + * is set to 1/4 with cable < 10m. + * - With DSP bias current (included both DSP amplitude and + * DSP bias current): bias current is half the detected current + * with cable < 10m. + */ +#define QCA807X_CONTROL_DAC_BIAS_CURRENT_TWEAK BIT(2) +#define QCA807X_CONTROL_DAC_DSP_BIAS_CURRENT BIT(1) +#define QCA807X_CONTROL_DAC_DSP_AMPLITUDE BIT(0) + +#define QCA807X_MMD7_LED_100N_1 0x8074 +#define QCA807X_MMD7_LED_100N_2 0x8075 +#define QCA807X_MMD7_LED_1000N_1 0x8076 +#define QCA807X_MMD7_LED_1000N_2 0x8077 + +#define QCA807X_MMD7_LED_CTRL(x) (0x8074 + ((x) * 2)) +#define QCA807X_MMD7_LED_FORCE_CTRL(x) (0x8075 + ((x) * 2)) + +#define QCA807X_GPIO_FORCE_EN BIT(15) +#define QCA807X_GPIO_FORCE_MODE_MASK GENMASK(14, 13) + +#define QCA807X_FUNCTION_CONTROL 0x10 +#define QCA807X_FC_MDI_CROSSOVER_MODE_MASK GENMASK(6, 5) +#define QCA807X_FC_MDI_CROSSOVER_AUTO 3 +#define QCA807X_FC_MDI_CROSSOVER_MANUAL_MDIX 1 +#define QCA807X_FC_MDI_CROSSOVER_MANUAL_MDI 0 + +/* PQSGMII Analog PHY specific */ +#define PQSGMII_CTRL_REG 0x0 +#define PQSGMII_ANALOG_SW_RESET BIT(6) +#define PQSGMII_DRIVE_CONTROL_1 0xb +#define PQSGMII_TX_DRIVER_MASK GENMASK(7, 4) +#define PQSGMII_TX_DRIVER_140MV 0x0 +#define PQSGMII_TX_DRIVER_160MV 0x1 +#define PQSGMII_TX_DRIVER_180MV 0x2 +#define PQSGMII_TX_DRIVER_200MV 0x3 +#define PQSGMII_TX_DRIVER_220MV 0x4 +#define PQSGMII_TX_DRIVER_240MV 0x5 +#define PQSGMII_TX_DRIVER_260MV 0x6 +#define PQSGMII_TX_DRIVER_280MV 0x7 +#define PQSGMII_TX_DRIVER_300MV 0x8 +#define PQSGMII_TX_DRIVER_320MV 0x9 +#define PQSGMII_TX_DRIVER_400MV 0xa +#define PQSGMII_TX_DRIVER_500MV 0xb +#define PQSGMII_TX_DRIVER_600MV 0xc +#define PQSGMII_MODE_CTRL 0x6d +#define PQSGMII_MODE_CTRL_AZ_WORKAROUND_MASK BIT(0) +#define PQSGMII_MMD3_SERDES_CONTROL 0x805a + +#define PHY_ID_QCA8072 0x004dd0b2 +#define PHY_ID_QCA8075 0x004dd0b1 + +#define QCA807X_COMBO_ADDR_OFFSET 4 +#define QCA807X_PQSGMII_ADDR_OFFSET 5 +#define SERDES_RESET_SLEEP 100 + +enum qca807x_global_phy { + QCA807X_COMBO_ADDR = 4, + QCA807X_PQSGMII_ADDR = 5, +}; + +struct qca807x_shared_priv { + unsigned int package_mode; + u32 tx_drive_strength; +}; + +struct qca807x_gpio_priv { + struct phy_device *phy; +}; + +struct qca807x_priv { + bool dac_full_amplitude; + bool dac_full_bias_current; + bool dac_disable_bias_current_tweak; +}; + +static int qca807x_cable_test_start(struct phy_device *phydev) +{ + /* we do all the (time consuming) work later */ + return 0; +} + +#ifdef CONFIG_GPIOLIB +static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) +{ + return GPIO_LINE_DIRECTION_OUT; +} + +static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset) +{ + struct qca807x_gpio_priv *priv = gpiochip_get_data(gc); + u16 reg; + int val; + + reg = QCA807X_MMD7_LED_FORCE_CTRL(offset); + val = phy_read_mmd(priv->phy, MDIO_MMD_AN, reg); + + return FIELD_GET(QCA807X_GPIO_FORCE_MODE_MASK, val); +} + +static void qca807x_gpio_set(struct gpio_chip *gc, unsigned int offset, int value) +{ + struct qca807x_gpio_priv *priv = gpiochip_get_data(gc); + u16 reg; + int val; + + reg = QCA807X_MMD7_LED_FORCE_CTRL(offset); + + val = phy_read_mmd(priv->phy, MDIO_MMD_AN, reg); + val &= ~QCA807X_GPIO_FORCE_MODE_MASK; + val |= QCA807X_GPIO_FORCE_EN; + val |= FIELD_PREP(QCA807X_GPIO_FORCE_MODE_MASK, value); + + phy_write_mmd(priv->phy, MDIO_MMD_AN, reg, val); +} + +static int qca807x_gpio_dir_out(struct gpio_chip *gc, unsigned int offset, int value) +{ + qca807x_gpio_set(gc, offset, value); + + return 0; +} + +static int qca807x_gpio(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + struct qca807x_gpio_priv *priv; + struct gpio_chip *gc; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->phy = phydev; + + gc = devm_kzalloc(dev, sizeof(*gc), GFP_KERNEL); + if (!gc) + return -ENOMEM; + + gc->label = dev_name(dev); + gc->base = -1; + gc->ngpio = 2; + gc->parent = dev; + gc->owner = THIS_MODULE; + gc->can_sleep = true; + gc->get_direction = qca807x_gpio_get_direction; + gc->direction_output = qca807x_gpio_dir_out; + gc->get = qca807x_gpio_get; + gc->set = qca807x_gpio_set; + + return devm_gpiochip_add_data(dev, gc, priv); +} +#endif + +static int qca807x_read_fiber_status(struct phy_device *phydev) +{ + bool changed; + int ss, err; + + err = genphy_c37_read_status(phydev, &changed); + if (err || !changed) + return err; + + /* Read the QCA807x PHY-Specific Status register fiber page, + * which indicates the speed and duplex that the PHY is actually + * using, irrespective of whether we are in autoneg mode or not. + */ + ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); + if (ss < 0) + return ss; + + phydev->speed = SPEED_UNKNOWN; + phydev->duplex = DUPLEX_UNKNOWN; + if (ss & AT803X_SS_SPEED_DUPLEX_RESOLVED) { + switch (FIELD_GET(AT803X_SS_SPEED_MASK, ss)) { + case AT803X_SS_SPEED_100: + phydev->speed = SPEED_100; + break; + case AT803X_SS_SPEED_1000: + phydev->speed = SPEED_1000; + break; + } + + if (ss & AT803X_SS_DUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + } + + return 0; +} + +static int qca807x_read_status(struct phy_device *phydev) +{ + if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported)) { + switch (phydev->port) { + case PORT_FIBRE: + return qca807x_read_fiber_status(phydev); + case PORT_TP: + return at803x_read_status(phydev); + default: + return -EINVAL; + } + } + + return at803x_read_status(phydev); +} + +static int qca807x_phy_package_probe_once(struct phy_device *phydev) +{ + struct phy_package_shared *shared = phydev->shared; + struct qca807x_shared_priv *priv = shared->priv; + unsigned int tx_drive_strength; + const char *package_mode_name; + + /* Default to 600mw if not defined */ + if (of_property_read_u32(shared->np, "qcom,tx-drive-strength-milliwatt", + &tx_drive_strength)) + tx_drive_strength = 600; + + switch (tx_drive_strength) { + case 140: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_140MV; + break; + case 160: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_160MV; + break; + case 180: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_180MV; + break; + case 200: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_200MV; + break; + case 220: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_220MV; + break; + case 240: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_240MV; + break; + case 260: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_260MV; + break; + case 280: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_280MV; + break; + case 300: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_300MV; + break; + case 320: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_320MV; + break; + case 400: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_400MV; + break; + case 500: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_500MV; + break; + case 600: + priv->tx_drive_strength = PQSGMII_TX_DRIVER_600MV; + break; + default: + return -EINVAL; + } + + priv->package_mode = PHY_INTERFACE_MODE_NA; + if (!of_property_read_string(shared->np, "qcom,package-mode", + &package_mode_name)) { + if (!strcasecmp(package_mode_name, + phy_modes(PHY_INTERFACE_MODE_PSGMII))) + priv->package_mode = PHY_INTERFACE_MODE_PSGMII; + else if (!strcasecmp(package_mode_name, + phy_modes(PHY_INTERFACE_MODE_QSGMII))) + priv->package_mode = PHY_INTERFACE_MODE_QSGMII; + else + return -EINVAL; + } + + return 0; +} + +static int qca807x_phy_package_config_init_once(struct phy_device *phydev) +{ + struct phy_package_shared *shared = phydev->shared; + struct qca807x_shared_priv *priv = shared->priv; + int val, ret; + + phy_lock_mdio_bus(phydev); + + /* Set correct PHY package mode */ + val = __phy_package_read(phydev, QCA807X_COMBO_ADDR, + QCA807X_CHIP_CONFIGURATION); + val &= ~QCA807X_CHIP_CONFIGURATION_MODE_CFG_MASK; + /* package_mode can be QSGMII or PSGMII and we validate + * this in probe_once. + * With package_mode to NA, we default to PSGMII. + */ + switch (priv->package_mode) { + case PHY_INTERFACE_MODE_QSGMII: + val |= QCA807X_CHIP_CONFIGURATION_MODE_QSGMII_SGMII; + break; + case PHY_INTERFACE_MODE_PSGMII: + default: + val |= QCA807X_CHIP_CONFIGURATION_MODE_PSGMII_ALL_COPPER; + } + ret = __phy_package_write(phydev, QCA807X_COMBO_ADDR, + QCA807X_CHIP_CONFIGURATION, val); + if (ret) + goto exit; + + /* After mode change Serdes reset is required */ + val = __phy_package_read(phydev, QCA807X_PQSGMII_ADDR, + PQSGMII_CTRL_REG); + val &= ~PQSGMII_ANALOG_SW_RESET; + ret = __phy_package_write(phydev, QCA807X_PQSGMII_ADDR, + PQSGMII_CTRL_REG, val); + if (ret) + goto exit; + + msleep(SERDES_RESET_SLEEP); + + val = __phy_package_read(phydev, QCA807X_PQSGMII_ADDR, + PQSGMII_CTRL_REG); + val |= PQSGMII_ANALOG_SW_RESET; + ret = __phy_package_write(phydev, QCA807X_PQSGMII_ADDR, + PQSGMII_CTRL_REG, val); + if (ret) + goto exit; + + /* Workaround to enable AZ transmitting ability */ + val = __phy_package_read_mmd(phydev, QCA807X_PQSGMII_ADDR, + MDIO_MMD_PMAPMD, PQSGMII_MODE_CTRL); + val &= ~PQSGMII_MODE_CTRL_AZ_WORKAROUND_MASK; + ret = __phy_package_write_mmd(phydev, QCA807X_PQSGMII_ADDR, + MDIO_MMD_PMAPMD, PQSGMII_MODE_CTRL, val); + if (ret) + goto exit; + + /* Set PQSGMII TX AMP strength */ + val = __phy_package_read(phydev, QCA807X_PQSGMII_ADDR, + PQSGMII_DRIVE_CONTROL_1); + val &= ~PQSGMII_TX_DRIVER_MASK; + val |= FIELD_PREP(PQSGMII_TX_DRIVER_MASK, priv->tx_drive_strength); + ret = __phy_package_write(phydev, QCA807X_PQSGMII_ADDR, + PQSGMII_DRIVE_CONTROL_1, val); + if (ret) + goto exit; + + /* Prevent PSGMII going into hibernation via PSGMII self test */ + val = __phy_package_read_mmd(phydev, QCA807X_COMBO_ADDR, + MDIO_MMD_PCS, PQSGMII_MMD3_SERDES_CONTROL); + val &= ~BIT(1); + ret = __phy_package_write_mmd(phydev, QCA807X_COMBO_ADDR, + MDIO_MMD_PCS, PQSGMII_MMD3_SERDES_CONTROL, val); + +exit: + phy_unlock_mdio_bus(phydev); + + return ret; +} + +static int qca807x_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) +{ + struct phy_device *phydev = upstream; + __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; + phy_interface_t iface; + int ret; + DECLARE_PHY_INTERFACE_MASK(interfaces); + + sfp_parse_support(phydev->sfp_bus, id, support, interfaces); + iface = sfp_select_interface(phydev->sfp_bus, support); + + dev_info(&phydev->mdio.dev, "%s SFP module inserted\n", phy_modes(iface)); + + switch (iface) { + case PHY_INTERFACE_MODE_1000BASEX: + case PHY_INTERFACE_MODE_100BASEX: + /* Set PHY mode to PSGMII combo (1/4 copper + combo ports) mode */ + ret = phy_modify(phydev, + QCA807X_CHIP_CONFIGURATION, + QCA807X_CHIP_CONFIGURATION_MODE_CFG_MASK, + QCA807X_CHIP_CONFIGURATION_MODE_PSGMII_FIBER); + /* Enable fiber mode autodection (1000Base-X or 100Base-FX) */ + ret = phy_set_bits_mmd(phydev, + MDIO_MMD_AN, + QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION, + QCA807X_MMD7_FIBER_MODE_AUTO_DETECTION_EN); + /* Select fiber page */ + ret = phy_clear_bits(phydev, + QCA807X_CHIP_CONFIGURATION, + QCA807X_BT_BX_REG_SEL); + + phydev->port = PORT_FIBRE; + break; + default: + dev_err(&phydev->mdio.dev, "Incompatible SFP module inserted\n"); + return -EINVAL; + } + + return ret; +} + +static void qca807x_sfp_remove(void *upstream) +{ + struct phy_device *phydev = upstream; + + /* Select copper page */ + phy_set_bits(phydev, + QCA807X_CHIP_CONFIGURATION, + QCA807X_BT_BX_REG_SEL); + + phydev->port = PORT_TP; +} + +static const struct sfp_upstream_ops qca807x_sfp_ops = { + .attach = phy_sfp_attach, + .detach = phy_sfp_detach, + .module_insert = qca807x_sfp_insert, + .module_remove = qca807x_sfp_remove, +}; + +static int qca807x_probe(struct phy_device *phydev) +{ + struct device_node *node = phydev->mdio.dev.of_node; + struct qca807x_shared_priv *shared_priv; + struct device *dev = &phydev->mdio.dev; + struct phy_package_shared *shared; + struct qca807x_priv *priv; + int ret; + + ret = devm_of_phy_package_join(dev, phydev, sizeof(*shared_priv)); + if (ret) + return ret; + + if (phy_package_probe_once(phydev)) { + ret = qca807x_phy_package_probe_once(phydev); + if (ret) + return ret; + } + + shared = phydev->shared; + shared_priv = shared->priv; + + /* Make sure PHY follow PHY package mode if enforced */ + if (shared_priv->package_mode != PHY_INTERFACE_MODE_NA && + phydev->interface != shared_priv->package_mode) + return -EINVAL; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dac_full_amplitude = of_property_read_bool(node, "qcom,dac-full-amplitude"); + priv->dac_full_bias_current = of_property_read_bool(node, "qcom,dac-full-bias-current"); + priv->dac_disable_bias_current_tweak = of_property_read_bool(node, + "qcom,dac-disable-bias-current-tweak"); + + if (IS_ENABLED(CONFIG_GPIOLIB)) { + /* Do not register a GPIO controller unless flagged for it */ + if (of_property_read_bool(node, "gpio-controller")) { + ret = qca807x_gpio(phydev); + if (ret) + return ret; + } + } + + /* Attach SFP bus on combo port*/ + if (phy_read(phydev, QCA807X_CHIP_CONFIGURATION)) { + ret = phy_sfp_probe(phydev, &qca807x_sfp_ops); + if (ret) + return ret; + linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->supported); + linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, phydev->advertising); + } + + phydev->priv = priv; + + return 0; +} + +static int qca807x_config_init(struct phy_device *phydev) +{ + struct qca807x_priv *priv = phydev->priv; + u16 control_dac; + int ret; + + if (phy_package_init_once(phydev)) { + ret = qca807x_phy_package_config_init_once(phydev); + if (ret) + return ret; + } + + control_dac = phy_read_mmd(phydev, MDIO_MMD_AN, + QCA807X_MMD7_1000BASE_T_POWER_SAVE_PER_CABLE_LENGTH); + control_dac &= ~QCA807X_CONTROL_DAC_MASK; + if (!priv->dac_full_amplitude) + control_dac |= QCA807X_CONTROL_DAC_DSP_AMPLITUDE; + if (!priv->dac_full_amplitude) + control_dac |= QCA807X_CONTROL_DAC_DSP_BIAS_CURRENT; + if (!priv->dac_disable_bias_current_tweak) + control_dac |= QCA807X_CONTROL_DAC_BIAS_CURRENT_TWEAK; + return phy_write_mmd(phydev, MDIO_MMD_AN, + QCA807X_MMD7_1000BASE_T_POWER_SAVE_PER_CABLE_LENGTH, + control_dac); +} + +static struct phy_driver qca807x_drivers[] = { + { + PHY_ID_MATCH_EXACT(PHY_ID_QCA8072), + .name = "Qualcomm QCA8072", + .flags = PHY_POLL_CABLE_TEST, + /* PHY_GBIT_FEATURES */ + .probe = qca807x_probe, + .config_init = qca807x_config_init, + .read_status = qca807x_read_status, + .config_intr = at803x_config_intr, + .handle_interrupt = at803x_handle_interrupt, + .soft_reset = genphy_soft_reset, + .get_tunable = at803x_get_tunable, + .set_tunable = at803x_set_tunable, + .resume = genphy_resume, + .suspend = genphy_suspend, + .cable_test_start = qca807x_cable_test_start, + .cable_test_get_status = qca808x_cable_test_get_status, + }, + { + PHY_ID_MATCH_EXACT(PHY_ID_QCA8075), + .name = "Qualcomm QCA8075", + .flags = PHY_POLL_CABLE_TEST, + /* PHY_GBIT_FEATURES */ + .probe = qca807x_probe, + .config_init = qca807x_config_init, + .read_status = qca807x_read_status, + .config_intr = at803x_config_intr, + .handle_interrupt = at803x_handle_interrupt, + .soft_reset = genphy_soft_reset, + .get_tunable = at803x_get_tunable, + .set_tunable = at803x_set_tunable, + .resume = genphy_resume, + .suspend = genphy_suspend, + .cable_test_start = qca807x_cable_test_start, + .cable_test_get_status = qca808x_cable_test_get_status, + }, +}; +module_phy_driver(qca807x_drivers); + +static struct mdio_device_id __maybe_unused qca807x_tbl[] = { + { PHY_ID_MATCH_EXACT(PHY_ID_QCA8072) }, + { PHY_ID_MATCH_EXACT(PHY_ID_QCA8075) }, + { } +}; + +MODULE_AUTHOR("Robert Marko "); +MODULE_AUTHOR("Christian Marangi "); +MODULE_DESCRIPTION("Qualcomm QCA807x PHY driver"); +MODULE_DEVICE_TABLE(mdio, qca807x_tbl); +MODULE_LICENSE("GPL"); From patchwork Tue Feb 6 17:31:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197566 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1701954dyb; Tue, 6 Feb 2024 09:36:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQLAvcLl9UfYfRLbZYiMu8PSe9LOhO8/eJ4ofddS7Ms9ZOaKBaQpYYXkWiN6fCh2IeKOs6 X-Received: by 2002:ac8:4e49:0:b0:42b:f724:3e07 with SMTP id e9-20020ac84e49000000b0042bf7243e07mr4386475qtw.44.1707240982076; Tue, 06 Feb 2024 09:36:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240982; cv=pass; d=google.com; s=arc-20160816; b=vrqdKUcKmGHJITjODWf9irUmAA1ASTjSp8ecYU7XRuG8r3bKXu15eK6Q3EUkooXV7J XcChlR/0i6CRe3B5s+vdTdMqEf9p16YOPhe2Dw9RlIc2aj7jXzD1/ruaqDK86x2/3T8D V5OvNpb0yxQcmsokYrTnaqJDFBYsPOz3uEDzjRjYZBwZAjQ0BvEsYyT6aej/Cd5k0Pxp EVxFpiQ5MjkHGW9Jgcfe+u6qu6p0QhI0DE8Q8FtKFzE+DvUKxSnKz1agZhjVfNMaO7gc BEw1kCuQCOuG4SA+03MlNBcc6mFqFZ0X1ogOTmZ0+d1sHM4zELklIHK8VRUS/roEBYxW 3MUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=D+uG+lQkYimwcDSoDF7+dFgWl6aqy23p/8S2SEBQxPM=; fh=ni0JcA6jxrK1Gybyh7YMUOgvMFj5fe9bi0Uv/vLR8LA=; b=hLCEqugCgVQzw7Z3MSmfzfr/7WQiGhCjaiMzakfg3XNpgy1qMVNacNaIeWxng2k9he 9fLNDZdlSssRNpXRYDxCD9+AttThx0gtjSP7he3Yl+tEBR4sAxxifz8QF78FFU9sKKRY 0TiWUovXjuHInl63nLGs+n41otpQwBLtJwNbhqwjOzTZ2ucy9Vu2rH7DpOA/nRZRboss /+hJO/hcjXl4HB8fJu//gRXWYYUPcIOSNNIdNoVZDEJ4j4nnUpUl/OdahXhNQvZ2L8wb /RJrdPGhPUweV4rgDmGYXbITiVoK4YsAq+QlEW4+x1QWx/29Dbue4AvJNqt2N4LCXwYG mxHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KNEdB704; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55390-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55390-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCVjh/8kt4XyEYv6lH3gGmOyaQlbNR1y8LR15bXepyWtnIF0e4r1kT9M/h+8skyFmeFpBHEGemIE0KRBYtvK04R6VqBbQQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z9-20020a05622a060900b0042c2dd43f88si2770104qta.75.2024.02.06.09.36.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:36:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55390-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KNEdB704; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55390-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55390-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C8DD51C230E4 for ; Tue, 6 Feb 2024 17:36:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95F131B953; Tue, 6 Feb 2024 17:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KNEdB704" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A18D017732; Tue, 6 Feb 2024 17:33:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240791; cv=none; b=gPPTJ4d2Sy6uCspMyZmS5BhmvXvpwTcsqpW12cQ+QYzrWSx36g7WwNTMJNzM85QAJq9bcwTI+7dvTf11lrH0l0QeN6IyBeXPJfVeDPNHaoeRe/fD2kWeXYQNGRksmwlGl0slLEC19A/lIaD3RAi3VH9LVggI+xtYPQ5dKNOGelg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240791; c=relaxed/simple; bh=flkeDF+JPxHobUBxumlcD1UVCicUGHIenpbz2WlOayE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hq5IfvsXYpKEgHbsvjXaktgLcRFeGMMpO2kpCNUa6kARZFzmo1+VhVQOQMB4MiDGlkZspqy/6dvYiyRclzlEZe6tF0rCJEcmo+6SnhOs0s9futEF68kFKCjmTND57sznm+pjPKVjmn7wmnNPUXJdI93JFPsJef2lrtaFycUsS/g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KNEdB704; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-40ff940b456so2605165e9.2; Tue, 06 Feb 2024 09:33:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240788; x=1707845588; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=D+uG+lQkYimwcDSoDF7+dFgWl6aqy23p/8S2SEBQxPM=; b=KNEdB704Ccr6aaCJObTjg2pJvnH+wKvGe/55boajbl+an5Q3zTsqoo5uykHZPJDXUH jHCGqd98BnyKQcx/4r5pfd3/dl/4W5dJCs5e/p0U5DiEVGgTOSWp7wH9lt/kqDe34Kr0 exRYsL+GKK2UrI1RdyLxbjEYU6khQHYitNFHOZb3VOj7409aDOxwOZPm3iT27XoihkLB 4UEup2hwHI1GA1vE+Q3VhSqhf864LtDjh/TbLgaleVnxG5RVMY57GvoeqiYSAx+riBIw Miy0HGmOz8LB5wo2ikjLosykjwJVbjIzwY7NT0EQ7JQQWKQWkW1qIEUJKg7Z8XjIN8Fg MDUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240788; x=1707845588; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D+uG+lQkYimwcDSoDF7+dFgWl6aqy23p/8S2SEBQxPM=; b=XCgGa9JZxTg0veIeTfqkAiehVzPvPkLgGwRnUCc3391gR7NJoxvbyxwGTEe4FG6yqv kmPO+yf0o9dqlCjpFNgpxp7OJm2lflGUknDTtQoPvq0cCLIolY/wHNsBDJFXUpZFywbl 91OhiTBE9bCDn4uTcqjgDnqKWK7z59CpODqA0xVXh09z7LgYndFp8WkrncPOMApxvMmM TXNbJUotzGcsGad2hgJCWV4R6ZH0+Npjq369O/9DhvTjs6Jeg7ZcqcaKI2uDVPArU0Cn Y8hY2HJrUHVZf04FUBMB3SFNRHQVUnBdgUdJh0wdF22NgjcAr26EP8e1tYZaX9r6cQ/C FgpQ== X-Gm-Message-State: AOJu0YzZ8rAGs/HK23xmBIpnuMq9IL5zpaRro3mDwlAyMArJ2dnCugUf YzwGC6afpiRruFuxGAseU1SQPMgGT+271vlRGMV7nPO7P72kVM/b X-Received: by 2002:a05:600c:4688:b0:40f:d1e4:6074 with SMTP id p8-20020a05600c468800b0040fd1e46074mr2242189wmo.8.1707240787879; Tue, 06 Feb 2024 09:33:07 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWHyAcLL2ixuJVTpL+nIbjE2McS9pDDJMfhKKcn6mrAQn1ZTLIAPIbd6rpWkRmd6MH+b14aF4HSI0I5pVAYbYGYra1YJdgkxP3hiQUMS24SV7AD6eVT6FZJNdYhHcOkivBrREdMCk/KxdTzUoqDLHjyrxK6xMGbKdesNIT2J4wRykvs0zEW6HYcpagp93iIR/CB61tYHhIL+vjSJ+2gPk5/uQRNMElArMGXILoGfkfYR5LDTrkrPaN5wgEUxZjPQVA5VEdsGk6aCZQ71w0J4CUGuSf51Bb3TpQyuzbjCn8/DLtKzBe/n15U+1nqtV0HC90tF9iUt2Iu5c5H3XnMlShBEm8KAvSn9gCrN7luv1ChiJx/2T0VNa++FkOui6cxQgy37Z9nYq8UMoQAdk4z0pTKfbqfb56echUmgfeKi6LR/W5sD98NBUJ91ExEvx4iemw8oy5dYvOYVpXIRk4QnsbkUG2lp4OE8FOx6/G3uN3bs3ls3OuDZ9E3FhPCD8ZF/8HJJBjTJzUpRRj8Fao/3BoFB1FP0fYJWgIhe+alOu44VBWaufLiO0tCu0IIBY6FMvnlkZhyaHkARd604ZTYDCQ05fs9Pgli+ZzOoVQWKAfOP63Yet7D/KiWG5RiOtK9mBiUpT8uXb6gjg7PPFOIaT5FjXoFJOXOwUfcQh4WYSmvNmaIRTkcBw== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:06 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 08/10] net: phy: qcom: move common qca808x LED define to shared header Date: Tue, 6 Feb 2024 18:31:11 +0100 Message-ID: <20240206173115.7654-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171920278862792 X-GMAIL-MSGID: 1790171920278862792 The LED implementation of qca808x and qca807x is the same but qca807x supports also Fiber port and have different hw control bits for Fiber port. In preparation for qca807x introduction, move all the common define to shared header. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/phy/qcom/qca808x.c | 65 ---------------------------------- drivers/net/phy/qcom/qcom.h | 65 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/drivers/net/phy/qcom/qca808x.c b/drivers/net/phy/qcom/qca808x.c index 8377325f157e..f1edff6b6bfc 100644 --- a/drivers/net/phy/qcom/qca808x.c +++ b/drivers/net/phy/qcom/qca808x.c @@ -62,29 +62,6 @@ #define QCA808X_DBG_AN_TEST 0xb #define QCA808X_HIBERNATION_EN BIT(15) -#define QCA808X_MMD7_LED_GLOBAL 0x8073 -#define QCA808X_LED_BLINK_1 GENMASK(11, 6) -#define QCA808X_LED_BLINK_2 GENMASK(5, 0) -/* Values are the same for both BLINK_1 and BLINK_2 */ -#define QCA808X_LED_BLINK_FREQ_MASK GENMASK(5, 3) -#define QCA808X_LED_BLINK_FREQ_2HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x0) -#define QCA808X_LED_BLINK_FREQ_4HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x1) -#define QCA808X_LED_BLINK_FREQ_8HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x2) -#define QCA808X_LED_BLINK_FREQ_16HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x3) -#define QCA808X_LED_BLINK_FREQ_32HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x4) -#define QCA808X_LED_BLINK_FREQ_64HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x5) -#define QCA808X_LED_BLINK_FREQ_128HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x6) -#define QCA808X_LED_BLINK_FREQ_256HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x7) -#define QCA808X_LED_BLINK_DUTY_MASK GENMASK(2, 0) -#define QCA808X_LED_BLINK_DUTY_50_50 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x0) -#define QCA808X_LED_BLINK_DUTY_75_25 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x1) -#define QCA808X_LED_BLINK_DUTY_25_75 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x2) -#define QCA808X_LED_BLINK_DUTY_33_67 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x3) -#define QCA808X_LED_BLINK_DUTY_67_33 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x4) -#define QCA808X_LED_BLINK_DUTY_17_83 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x5) -#define QCA808X_LED_BLINK_DUTY_83_17 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x6) -#define QCA808X_LED_BLINK_DUTY_8_92 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x7) - #define QCA808X_MMD7_LED2_CTRL 0x8074 #define QCA808X_MMD7_LED2_FORCE_CTRL 0x8075 #define QCA808X_MMD7_LED1_CTRL 0x8076 @@ -92,51 +69,9 @@ #define QCA808X_MMD7_LED0_CTRL 0x8078 #define QCA808X_MMD7_LED_CTRL(x) (0x8078 - ((x) * 2)) -/* LED hw control pattern is the same for every LED */ -#define QCA808X_LED_PATTERN_MASK GENMASK(15, 0) -#define QCA808X_LED_SPEED2500_ON BIT(15) -#define QCA808X_LED_SPEED2500_BLINK BIT(14) -/* Follow blink trigger even if duplex or speed condition doesn't match */ -#define QCA808X_LED_BLINK_CHECK_BYPASS BIT(13) -#define QCA808X_LED_FULL_DUPLEX_ON BIT(12) -#define QCA808X_LED_HALF_DUPLEX_ON BIT(11) -#define QCA808X_LED_TX_BLINK BIT(10) -#define QCA808X_LED_RX_BLINK BIT(9) -#define QCA808X_LED_TX_ON_10MS BIT(8) -#define QCA808X_LED_RX_ON_10MS BIT(7) -#define QCA808X_LED_SPEED1000_ON BIT(6) -#define QCA808X_LED_SPEED100_ON BIT(5) -#define QCA808X_LED_SPEED10_ON BIT(4) -#define QCA808X_LED_COLLISION_BLINK BIT(3) -#define QCA808X_LED_SPEED1000_BLINK BIT(2) -#define QCA808X_LED_SPEED100_BLINK BIT(1) -#define QCA808X_LED_SPEED10_BLINK BIT(0) - #define QCA808X_MMD7_LED0_FORCE_CTRL 0x8079 #define QCA808X_MMD7_LED_FORCE_CTRL(x) (0x8079 - ((x) * 2)) -/* LED force ctrl is the same for every LED - * No documentation exist for this, not even internal one - * with NDA as QCOM gives only info about configuring - * hw control pattern rules and doesn't indicate any way - * to force the LED to specific mode. - * These define comes from reverse and testing and maybe - * lack of some info or some info are not entirely correct. - * For the basic LED control and hw control these finding - * are enough to support LED control in all the required APIs. - * - * On doing some comparison with implementation with qca807x, - * it was found that it's 1:1 equal to it and confirms all the - * reverse done. It was also found further specification with the - * force mode and the blink modes. - */ -#define QCA808X_LED_FORCE_EN BIT(15) -#define QCA808X_LED_FORCE_MODE_MASK GENMASK(14, 13) -#define QCA808X_LED_FORCE_BLINK_1 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x3) -#define QCA808X_LED_FORCE_BLINK_2 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x2) -#define QCA808X_LED_FORCE_ON FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x1) -#define QCA808X_LED_FORCE_OFF FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x0) - #define QCA808X_MMD7_LED_POLARITY_CTRL 0x901a /* QSDK sets by default 0x46 to this reg that sets BIT 6 for * LED to active high. It's not clear what BIT 3 and BIT 4 does. diff --git a/drivers/net/phy/qcom/qcom.h b/drivers/net/phy/qcom/qcom.h index dc259bbf0678..9e24997c355f 100644 --- a/drivers/net/phy/qcom/qcom.h +++ b/drivers/net/phy/qcom/qcom.h @@ -103,6 +103,71 @@ /* Added for reference of existence but should be handled by wait_for_completion already */ #define QCA808X_CDT_STATUS_STAT_BUSY (BIT(1) | BIT(3)) +#define QCA808X_MMD7_LED_GLOBAL 0x8073 +#define QCA808X_LED_BLINK_1 GENMASK(11, 6) +#define QCA808X_LED_BLINK_2 GENMASK(5, 0) +/* Values are the same for both BLINK_1 and BLINK_2 */ +#define QCA808X_LED_BLINK_FREQ_MASK GENMASK(5, 3) +#define QCA808X_LED_BLINK_FREQ_2HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x0) +#define QCA808X_LED_BLINK_FREQ_4HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x1) +#define QCA808X_LED_BLINK_FREQ_8HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x2) +#define QCA808X_LED_BLINK_FREQ_16HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x3) +#define QCA808X_LED_BLINK_FREQ_32HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x4) +#define QCA808X_LED_BLINK_FREQ_64HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x5) +#define QCA808X_LED_BLINK_FREQ_128HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x6) +#define QCA808X_LED_BLINK_FREQ_256HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x7) +#define QCA808X_LED_BLINK_DUTY_MASK GENMASK(2, 0) +#define QCA808X_LED_BLINK_DUTY_50_50 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x0) +#define QCA808X_LED_BLINK_DUTY_75_25 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x1) +#define QCA808X_LED_BLINK_DUTY_25_75 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x2) +#define QCA808X_LED_BLINK_DUTY_33_67 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x3) +#define QCA808X_LED_BLINK_DUTY_67_33 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x4) +#define QCA808X_LED_BLINK_DUTY_17_83 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x5) +#define QCA808X_LED_BLINK_DUTY_83_17 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x6) +#define QCA808X_LED_BLINK_DUTY_8_92 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x7) + +/* LED hw control pattern is the same for every LED */ +#define QCA808X_LED_PATTERN_MASK GENMASK(15, 0) +#define QCA808X_LED_SPEED2500_ON BIT(15) +#define QCA808X_LED_SPEED2500_BLINK BIT(14) +/* Follow blink trigger even if duplex or speed condition doesn't match */ +#define QCA808X_LED_BLINK_CHECK_BYPASS BIT(13) +#define QCA808X_LED_FULL_DUPLEX_ON BIT(12) +#define QCA808X_LED_HALF_DUPLEX_ON BIT(11) +#define QCA808X_LED_TX_BLINK BIT(10) +#define QCA808X_LED_RX_BLINK BIT(9) +#define QCA808X_LED_TX_ON_10MS BIT(8) +#define QCA808X_LED_RX_ON_10MS BIT(7) +#define QCA808X_LED_SPEED1000_ON BIT(6) +#define QCA808X_LED_SPEED100_ON BIT(5) +#define QCA808X_LED_SPEED10_ON BIT(4) +#define QCA808X_LED_COLLISION_BLINK BIT(3) +#define QCA808X_LED_SPEED1000_BLINK BIT(2) +#define QCA808X_LED_SPEED100_BLINK BIT(1) +#define QCA808X_LED_SPEED10_BLINK BIT(0) + +/* LED force ctrl is the same for every LED + * No documentation exist for this, not even internal one + * with NDA as QCOM gives only info about configuring + * hw control pattern rules and doesn't indicate any way + * to force the LED to specific mode. + * These define comes from reverse and testing and maybe + * lack of some info or some info are not entirely correct. + * For the basic LED control and hw control these finding + * are enough to support LED control in all the required APIs. + * + * On doing some comparison with implementation with qca807x, + * it was found that it's 1:1 equal to it and confirms all the + * reverse done. It was also found further specification with the + * force mode and the blink modes. + */ +#define QCA808X_LED_FORCE_EN BIT(15) +#define QCA808X_LED_FORCE_MODE_MASK GENMASK(14, 13) +#define QCA808X_LED_FORCE_BLINK_1 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x3) +#define QCA808X_LED_FORCE_BLINK_2 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x2) +#define QCA808X_LED_FORCE_ON FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x1) +#define QCA808X_LED_FORCE_OFF FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x0) + #define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C #define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B #define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A From patchwork Tue Feb 6 17:31:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1702120dyb; Tue, 6 Feb 2024 09:36:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IH84KqE6fdRzjq6DFyW7lpA7nhwDcI1VHO4j9s6pMpApWdwjzPDP9cBVhc3uLh9Zr5tdvOf X-Received: by 2002:a17:902:e9cd:b0:1d8:d478:8b90 with SMTP id 13-20020a170902e9cd00b001d8d4788b90mr1907127plk.16.1707240994972; Tue, 06 Feb 2024 09:36:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707240994; cv=pass; d=google.com; s=arc-20160816; b=K3qUo55QELTvUTbdXHkPouRJHLxMGvy2jWwU3YCPyXI1ZMi+n4H9azSqFSW8Z6v1lb aF40H9N7jXTsj6nGHCcVRg8rcM2wcUE8RXmKDt3CU/+8MkEk4t30zMMzeH/YVNkfSEfF pna6UDVCAwlO34qUbUphtJxImyDUw2RHPyGnTru1Nybb/r1b5oE4SHkqLammnDOkVlh0 eICXC8Z5Ug8qxW1L+nKgs1SqTg18CDx8gOn2dYgtOkkKSMmHJV5tuLlqBiIs1dnrXLZb 9f0xlFwBBcG1ODng1HJpU5qzWi3ki23ic2sT+TOmka5ByLYsAbwa0IzLtU7dh5s8VU7g ykzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=3WoCJEsbiVlNOq1w7ZYfzlKdo640PAaFTQAV/jxjbsU=; fh=vh7g65RyMb+xKEHRdLNZs2Lu8CgtDf9LZEMFQRzTzxU=; b=VmKJ2G4vZYemRg2buRqn2j2LkjF4nUM9ycnnwphgBzWUPlDdo8tXcgUsS4aEXg8lZ7 jDBAT6EfQNXqPFNrArTTEW6PRZ2TGJ0GnA4N+8A9YDiDVUEQz8ySFlnmY4RzKFpDK5DH X70huReco7tDNx8UbX3uf8Mm6SpjFUIwIYcmKpJNygEcGUpY9M0hrTCa5uSGWGgtkDam ssEso5uveJbzm72iHUOm124PqwW0RiGQagYvw3A9z1uwXUj9PBwB7GechDrK4vMEe1xT Z4otTx1i3omDgLHkx2Ohj/Z2DbuDvrzrODyNPPBzQ5qULFApZtNBlDvnS261t0LPAp6C sb3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mPm4T2nB; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55391-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55391-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCUSyCbqu3kidLi9Ho+AX5eCkjPgKxtTusdNl6+KV1yus1ci1N2CAwHxoLiOJtFsmpdeY+4quoL5pEHUwvRs3NE9wWRGeg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b1-20020a170902d50100b001d93b748a55si2083884plg.25.2024.02.06.09.36.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:36:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55391-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mPm4T2nB; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55391-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55391-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B7FF7284EE4 for ; Tue, 6 Feb 2024 17:36:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9A901BC41; Tue, 6 Feb 2024 17:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mPm4T2nB" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D82BF1802E; Tue, 6 Feb 2024 17:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240793; cv=none; b=kJt5j8ZphqQ8IuvOphj15fW59chZt0TWUmZ20mA0u2mvg1ZsRp8Tsp//ltg6VN4MhzwSqz72u9UvJ7zy9ZmAvpe5rvRB3T/mtU9ppHwudlqioNCxKQjb/qCkN7eYVGBunwOdCte99J3eyYxpWcu4GFxcmv0EhpPpFJ8UCcyk1Ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240793; c=relaxed/simple; bh=IF0oo1ZQ82QB95MrqtNsrEE2S8zMLUpGhSkd5BwFGAc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tms8ZkzXzGInG4wAFgmxvzRhAfbOftMXrShrFlG5gzI/xMy5ojXK0dMADOKgbW259sArTodOLTG1jYb2NW91/DjenoloPuNV2SKVnu78AXMQep9gpIidD3MY79563TEFzW4RJE09c54ltMx52MOTaXiF8rzlov4THgQdcc729P8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mPm4T2nB; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-33934567777so909076f8f.1; Tue, 06 Feb 2024 09:33:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240790; x=1707845590; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3WoCJEsbiVlNOq1w7ZYfzlKdo640PAaFTQAV/jxjbsU=; b=mPm4T2nBDdSele7bZ1GN3VMsOprwVqRVK5loDfzElxcNNBPPvJRLFcTo75GgOAKuTH VNtMKo8DQ8+c4jsc9aeQFKZ1NLX4CaWsWxDkwSYu5t0/XNJxxFmJ2tG7pZOfGaVrIDCw 6Ek+WZCN+Rd+2jlMcyps3ohYv6U8kqZWzFNQ93xhIIEeYoxZB5evpff2CvTbNjE6Y2yE hqm4WxOspJFpTUPv3G9+6qBt+vg2SJWhKIFbH4r05QH9EEchnYfy6xq37Bn7n00MxCUC lJKE5SUcCp98NDM9nfIuC7To/hWnSc65IE4gyPC+jsHDrsxf1+isUw62ubi0HUSxHZcx VReQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240790; x=1707845590; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3WoCJEsbiVlNOq1w7ZYfzlKdo640PAaFTQAV/jxjbsU=; b=tyHhADW2CALZ39I23ztUtOV71T7SqbIyzw3pfw2yq6E3VFuId6XEZqXMkOQA8z+ikn j9mAsv38gSr9TlcGEfYgFEOn+PNMHQae4Sh6y+Q7eQOe4+EWzusvyDztAymbBaGYy7M5 nTtAcqTroAjDagTclYS/FjrZBdoCuK1I8oyuRDAxxKaiUwnGIx3FADT/KczVaL7RqPZ3 sA+sLMkR+dP9bWObDipE/VRXLFiN3N8o2YObiBmmwoga1SPjyN5MqpM8HSypDHyEYEI6 QLgPhBmt1IKXmFbPUDwoQNDFU23HCjvE5BM/G8kebSg2L61JkCKVImTzEqc4Da0mhtnQ a3aA== X-Gm-Message-State: AOJu0YyinwDqX1pr69f5OQJ723wSEkQOBWlhhLSyyfyKhb5LGo8wmZ/P 6HTnVYVnPIpZh1nDqzqnVjrkWxNDLFDzbrQxjiCiTGGLl4fVWUx8 X-Received: by 2002:adf:fc92:0:b0:33b:36d6:90cc with SMTP id g18-20020adffc92000000b0033b36d690ccmr1455336wrr.28.1707240789750; Tue, 06 Feb 2024 09:33:09 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWkV1MrnrNr1a6IZO0zm4JrvsAAnme+HWTseqI6Yn1WM8oIjj54bOmuHXvTkGI6sa1qTCFogCBX2yxIwMlp4MaoxlX/B8Gp1zOc/w1dOHgNYDWWPtn4Me0EqUJ5ExtLZ7ovxozsMkIdyv4xHEEOcRmZxjjzib5ocr2HUYWlMl40PfaS/MwMFYwMlrb3swQhFHR1ucH7uEfeK1rxT577d896sgZmqTUPEFdK0gcKIqBVDiHlefqxFm0h/TOTPLOSmP04iFlUXidSjfLPt16CXsKtk/ZObu3iSY5pnWSYTuE7Tm0yH1U3p6EJDazL8o5Si6NtwJaszFCtnJfvyCQjAkLEJXs317m5dVhNbyh5PnD0FJe+ePx0C27VZVVxAoPhYOi6l66pHRPVbCKoc04ywYIqlEXxKLg53861FuQ4+D+gD77E84XvP5Ohi/B/2pt6opl/xTn5ggZ4SLmTcqQLcOWZUhvvqMQXAhJYSuh/fpuqqfe1qvYfTAycBedJd0brects+fVtK2mZCcwTQlZ5UTLPSP2YwhDw3HI06fSqtVwSQmlsCRgwjf89app9lzWA7R2jFu6aBcGHzWpF7oCISuNt1X0dHlRGz72t7QvciK9v/QrJsclpyRWBZQseK2tzSxp/ji4hV6CVMmEDaDMjNGLqhL4qPqV0qm9wNU0oGQgSRbjQRDNnEg== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:08 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 09/10] net: phy: qcom: generalize some qca808x LED functions Date: Tue, 6 Feb 2024 18:31:12 +0100 Message-ID: <20240206173115.7654-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171933660413375 X-GMAIL-MSGID: 1790171933660413375 Generalize some qca808x LED functions in preparation for qca807x LED support. The LED implementation of qca808x and qca807x is the same but qca807x supports also Fiber port and have different hw control bits for Fiber port. To limit code duplication introduce micro functions that takes reg instead of LED index to tweak all the supported LED modes. Signed-off-by: Christian Marangi --- drivers/net/phy/qcom/qca808x.c | 38 +++----------------- drivers/net/phy/qcom/qcom-phy-lib.c | 54 +++++++++++++++++++++++++++++ drivers/net/phy/qcom/qcom.h | 7 ++++ 3 files changed, 65 insertions(+), 34 deletions(-) diff --git a/drivers/net/phy/qcom/qca808x.c b/drivers/net/phy/qcom/qca808x.c index f1edff6b6bfc..2acf852fb4de 100644 --- a/drivers/net/phy/qcom/qca808x.c +++ b/drivers/net/phy/qcom/qca808x.c @@ -437,9 +437,7 @@ static int qca808x_led_hw_control_enable(struct phy_device *phydev, u8 index) return -EINVAL; reg = QCA808X_MMD7_LED_FORCE_CTRL(index); - - return phy_clear_bits_mmd(phydev, MDIO_MMD_AN, reg, - QCA808X_LED_FORCE_EN); + return qca808x_led_reg_hw_control_enable(phydev, reg); } static int qca808x_led_hw_is_supported(struct phy_device *phydev, u8 index, @@ -480,16 +478,12 @@ static int qca808x_led_hw_control_set(struct phy_device *phydev, u8 index, static bool qca808x_led_hw_control_status(struct phy_device *phydev, u8 index) { u16 reg; - int val; if (index > 2) return false; reg = QCA808X_MMD7_LED_FORCE_CTRL(index); - - val = phy_read_mmd(phydev, MDIO_MMD_AN, reg); - - return !(val & QCA808X_LED_FORCE_EN); + return qca808x_led_reg_hw_control_status(phydev, reg); } static int qca808x_led_hw_control_get(struct phy_device *phydev, u8 index, @@ -557,44 +551,20 @@ static int qca808x_led_brightness_set(struct phy_device *phydev, } reg = QCA808X_MMD7_LED_FORCE_CTRL(index); - - return phy_modify_mmd(phydev, MDIO_MMD_AN, reg, - QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_MODE_MASK, - QCA808X_LED_FORCE_EN | (value ? QCA808X_LED_FORCE_ON : - QCA808X_LED_FORCE_OFF)); + return qca808x_led_reg_brightness_set(phydev, reg, value); } static int qca808x_led_blink_set(struct phy_device *phydev, u8 index, unsigned long *delay_on, unsigned long *delay_off) { - int ret; u16 reg; if (index > 2) return -EINVAL; reg = QCA808X_MMD7_LED_FORCE_CTRL(index); - - /* Set blink to 50% off, 50% on at 4Hz by default */ - ret = phy_modify_mmd(phydev, MDIO_MMD_AN, QCA808X_MMD7_LED_GLOBAL, - QCA808X_LED_BLINK_FREQ_MASK | QCA808X_LED_BLINK_DUTY_MASK, - QCA808X_LED_BLINK_FREQ_4HZ | QCA808X_LED_BLINK_DUTY_50_50); - if (ret) - return ret; - - /* We use BLINK_1 for normal blinking */ - ret = phy_modify_mmd(phydev, MDIO_MMD_AN, reg, - QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_MODE_MASK, - QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_BLINK_1); - if (ret) - return ret; - - /* We set blink to 4Hz, aka 250ms */ - *delay_on = 250 / 2; - *delay_off = 250 / 2; - - return 0; + return qca808x_led_reg_blink_set(phydev, reg, delay_on, delay_off); } static int qca808x_led_polarity_set(struct phy_device *phydev, int index, diff --git a/drivers/net/phy/qcom/qcom-phy-lib.c b/drivers/net/phy/qcom/qcom-phy-lib.c index 786bfc39912c..d28815ef56bb 100644 --- a/drivers/net/phy/qcom/qcom-phy-lib.c +++ b/drivers/net/phy/qcom/qcom-phy-lib.c @@ -620,3 +620,57 @@ int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished) return 0; } EXPORT_SYMBOL_GPL(qca808x_cable_test_get_status); + +int qca808x_led_reg_hw_control_enable(struct phy_device *phydev, u16 reg) +{ + return phy_clear_bits_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_FORCE_EN); +} +EXPORT_SYMBOL_GPL(qca808x_led_reg_hw_control_enable); + +bool qca808x_led_reg_hw_control_status(struct phy_device *phydev, u16 reg) +{ + int val; + + val = phy_read_mmd(phydev, MDIO_MMD_AN, reg); + return !(val & QCA808X_LED_FORCE_EN); +} +EXPORT_SYMBOL_GPL(qca808x_led_reg_hw_control_status); + +int qca808x_led_reg_brightness_set(struct phy_device *phydev, + u16 reg, enum led_brightness value) +{ + return phy_modify_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_MODE_MASK, + QCA808X_LED_FORCE_EN | (value ? QCA808X_LED_FORCE_ON : + QCA808X_LED_FORCE_OFF)); +} +EXPORT_SYMBOL_GPL(qca808x_led_reg_brightness_set); + +int qca808x_led_reg_blink_set(struct phy_device *phydev, u16 reg, + unsigned long *delay_on, + unsigned long *delay_off) +{ + int ret; + + /* Set blink to 50% off, 50% on at 4Hz by default */ + ret = phy_modify_mmd(phydev, MDIO_MMD_AN, QCA808X_MMD7_LED_GLOBAL, + QCA808X_LED_BLINK_FREQ_MASK | QCA808X_LED_BLINK_DUTY_MASK, + QCA808X_LED_BLINK_FREQ_4HZ | QCA808X_LED_BLINK_DUTY_50_50); + if (ret) + return ret; + + /* We use BLINK_1 for normal blinking */ + ret = phy_modify_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_MODE_MASK, + QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_BLINK_1); + if (ret) + return ret; + + /* We set blink to 4Hz, aka 250ms */ + *delay_on = 250 / 2; + *delay_off = 250 / 2; + + return 0; +} +EXPORT_SYMBOL_GPL(qca808x_led_reg_blink_set); diff --git a/drivers/net/phy/qcom/qcom.h b/drivers/net/phy/qcom/qcom.h index 9e24997c355f..4bb541728846 100644 --- a/drivers/net/phy/qcom/qcom.h +++ b/drivers/net/phy/qcom/qcom.h @@ -234,3 +234,10 @@ int at803x_cdt_start(struct phy_device *phydev, u32 cdt_start); int at803x_cdt_wait_for_completion(struct phy_device *phydev, u32 cdt_en); int qca808x_cable_test_get_status(struct phy_device *phydev, bool *finished); +int qca808x_led_reg_hw_control_enable(struct phy_device *phydev, u16 reg); +bool qca808x_led_reg_hw_control_status(struct phy_device *phydev, u16 reg); +int qca808x_led_reg_brightness_set(struct phy_device *phydev, + u16 reg, enum led_brightness value); +int qca808x_led_reg_blink_set(struct phy_device *phydev, u16 reg, + unsigned long *delay_on, + unsigned long *delay_off); From patchwork Tue Feb 6 17:31:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 197569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1702214dyb; Tue, 6 Feb 2024 09:36:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIksoI/RWbFIW8HHVK3G43PIOHHyTE89TR807ogMorp2KNZN7cod7Gxd5nL5SrfjZzoGT/ X-Received: by 2002:a05:620a:391:b0:785:5f1a:7e37 with SMTP id q17-20020a05620a039100b007855f1a7e37mr3246923qkm.63.1707241005641; Tue, 06 Feb 2024 09:36:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707241005; cv=pass; d=google.com; s=arc-20160816; b=v+JKJtmgQtZGbm7tSDGgikFBLp9G9dQlob/koMzFr1pP7WcbQI8XcfsDGDhphCPe2F JPz7PkuIwY1m2Jd64QLIfd1rkcvgsBqR/Nm3okABI7/hjZqsUMqnSC4id4ikdlrhGIMz Td+Ss1y7Mh8FDJSQzPV/ne/kYGGZ4c9WOVBnVGpg1pJx4uP3kFZdJW6eCLNh/qTzvxiy C4i9mr/jYdJCcczzTFcb3FiDgCnvnxlKAWTs+W4Qxb00HmUY5phk0F8ZseMT29unHOJ4 qhDjaj+W7QEEjFPoNX2CZN4me9udguyKt61Jmbp/TinaT38Y+kj3lJFbzaaDXTIdKk75 glJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=2bPb64tk5SB/C0z8w9KrOUZ8DDcTcGxxTiQl9YBAiAg=; fh=fMNSEtGBcdEypUbG3Fntvv4Kdi38iXxFBIPwkuupUDg=; b=vpvzQGUdQMxyLAYynHIloWgZ1oWvCaXTWnfhPEZR0bpxG0iG+yDA3j4w1tBKcnrZsZ 6/gU9IJnIZB6f7KEpVpCxcdZc47DQuWHxL5Y/2L3lsJ9Zlhq49+eBo98ATFyV3aqGEAm pLXhSHsybhKjdVI57WRGwbluls340L8WJlrun4aXgyik7fA/1fjRrZyWkRvNxKsrms5V Zq4hwIyla/WZ5PIEstX9Kk0Cw99o3HwBT61/tbd/84pSEdp0Flhzje8EEUtpg5X9XiD0 kwCCHJRmrZwANMb8f0vkG71QoIkBTOZNHMW/hHXu2l5UgMR/vPcGnkVAdYROAxc9NVvf JNdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gAa3+ia+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55392-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCXF3pefOioNQdVSSP/3eeVwz/9bChwBFbZCUpCaWyI4hnULXf8T9C3hFPICj6Hnlr565t6qqvmjdlHoJsbRHx/HJrSpvA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v22-20020a05620a0a9600b00783f74e71a5si2626332qkg.649.2024.02.06.09.36.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:36:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55392-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=gAa3+ia+; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-55392-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 609F71C237D6 for ; Tue, 6 Feb 2024 17:36:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8709C1BF3C; Tue, 6 Feb 2024 17:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gAa3+ia+" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9A5B1B286; Tue, 6 Feb 2024 17:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240795; cv=none; b=dGGaHh3TNK82/BgKT1GEh6b0QIB771Bl6HGU/xWmv9EQnmGSM3Y+/5G+T8NCuux7Kf1ghIntB0SWAnesl7vA58Acuf05VNe3WvSvtQAZce+cLNyZZOHZZN4TFoerSQygwGl2FGACY11UaeielyZTyxkA40ey4/E/8NifRGRHdpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707240795; c=relaxed/simple; bh=lVnD2FLt87Y7Be9LDp9rQeARP6jlrGEoL4hF4rwexN8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dycFiU3H4UlMJLlv3YRQ/5ypVan88RRpPByC12PgwVTia+pKqqjGQaLS0Q+hFac6FrteoLk3YLVZ1Un1BUNq205wak2XbJ+oRLV6ysm/ueJ6d7NiH4eIcy8eoUm5Zo+UVuT3naawbLKYh+wq80F/NUmGI97F70DccK4+Gru6Pok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gAa3+ia+; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40ff812442aso2814895e9.2; Tue, 06 Feb 2024 09:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707240792; x=1707845592; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2bPb64tk5SB/C0z8w9KrOUZ8DDcTcGxxTiQl9YBAiAg=; b=gAa3+ia+ttcOabJQw2nDPsvioRq/wUBKRlKgh5SnPVIWcsgaK8kdXmey6isqSihXD4 znxruIKEbX7rIByBlbqTFSVypb6sLNNMbgb5eXq+4ibo3RiIcKNrx9ltulf7X0kPz1qR 07PqEGhO/Dpin8NCQqIYVYjWHwBqP8slursYTQ0ib0V3GJdVaZ+QG14t7dzYS4DS7lZg RBiBFMQ5ag6Fm5ye3GlGrBQ5+M82BBj1d+YGvIVe9vSw+i5V85Di2Ggfo+ZnHz/1XVLY klsK3zIi1vORt/fvDO4yb4GE4rFIK+WHtDQ5xuHh2F95UtAJ+TxUB24uzPU48QnoNK16 gsJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707240792; x=1707845592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2bPb64tk5SB/C0z8w9KrOUZ8DDcTcGxxTiQl9YBAiAg=; b=qOxG3Wwn3GKi+mKDF2tdXjqgLIUNnEy3nemOfJJizYETaFDV8IU3R+gmavLlr23zcE kmFvSCR60egCYjl4jsNcwmazRIzVyNd9b8yrthLIeF4ab1dTEi5hN9FmRO2FUaa38uo/ 5kyI85dOKBjnnUn9w/e7avaeNzJUWL4qg1RFKJ8j52kxM/bju++4nmt6l1DwS8RmYvYi sRIPLUqWblBEbSl9FiJH4qtDBKDvXWrxObRo3vGy4syx0DFHZQdIoOGmLB7THnJWLrhc A+D6YPL7aVb1/0l5/A+V2aPdtS5TzRaa5YPdeHvHTiwUbgujxwaRzbdH2nkF8196jGJj akqA== X-Gm-Message-State: AOJu0Yw/MDCZMMyRCiUWGjGgNNwOKYhzP++y6ywtbnCg+S02SS0jCIV5 lENCZ6qzhIr0Ot2Pik/irxPzTt0GqHHG0687x4JMJiLY/55fbIzWv4i1KsNH X-Received: by 2002:a05:600c:a3a4:b0:40f:dc50:aea5 with SMTP id hn36-20020a05600ca3a400b0040fdc50aea5mr2139106wmb.22.1707240791890; Tue, 06 Feb 2024 09:33:11 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWgjwEI0YWxlE5wEa5UzzHoRfc14OADrBTi6J5gQtvGeUF7lJ/zNovU6G9wHTFGTG5MQdD/H8RwaJ5ob0gQAVjAr7mpTuUV+LDvASwawQU9VnY08E/BVeWFt6jvRLLDxdhopDMuv+b5YYF9VwdN/+CHNhAGweBloHY5n1WgU+Zy4hxPy9KWNWnXdG9r9172bGKJTamq4xuw/+Dtzp/p5ConyEF5Q1r1QPFvVrgr9c8SqTP0PJkCE3grKFvyCsdJl2iCdpeutSI7n7eZrIGtsY6VFPiP2k7z7oTVgSf2QZXW+wmuzyyJKR0m4uiSrxXNGhNnBZaA1ObziL7IQQpC+k8YdwH+5vrGqF+Bayk7HQ10H0SwWizZgwKVSPw2sAaoMsj2ZxstF7ZEGh2PMhK+H+FAeOyYHDBzFi/DHVw93b5ykJDrU5WZh6+8rl942cCnJ5E2SHCfYs2MGday6NidOYz0N1UOGcuJpvqOhGnF/UhoGT5VqVM9UQU9yqSYe9qJqj7BPmsp4EDWLqUA5jDCs/hME5xb97kjxFLemjb6pznkOcQ0etK+1G8scaskJSPApNLppcL3stPTdQyT2gwzuYudm1q1obTrSomTVjH90MzcQLZIhP5a9E8MUTmaeiox4i+D8tmr2RDChyDmCBDaYCR0msht45GxByivm5rf6B3jw9sO+tTYOg== Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id l14-20020a05600c4f0e00b0040fc56712e8sm2621215wmq.17.2024.02.06.09.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 09:33:10 -0800 (PST) From: Christian Marangi To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio , Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Broadcom internal kernel review list , Christian Marangi , Robert Marko , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v7 10/10] net: phy: qca807x: add support for configurable LED Date: Tue, 6 Feb 2024 18:31:13 +0100 Message-ID: <20240206173115.7654-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206173115.7654-1-ansuelsmth@gmail.com> References: <20240206173115.7654-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790171944721899568 X-GMAIL-MSGID: 1790171944721899568 QCA8072/5 have up to 2 LEDs attached for PHY. LEDs can be configured to be ON/hw blink or be set to HW control. Hw blink mode is set to blink at 4Hz or 250ms. PHY can support both copper (TP) or fiber (FIBRE) kind and supports different HW control modes based on the port type. HW control modes supported for netdev trigger for copper ports are: - LINK_10 - LINK_100 - LINK_1000 - TX - RX - FULL_DUPLEX - HALF_DUPLEX HW control modes supported for netdev trigger for fiber ports are: - LINK_100 - LINK_1000 - TX - RX - FULL_DUPLEX - HALF_DUPLEX LED support conflicts with GPIO controller feature and must be disabled if gpio-controller is used for the PHY. Signed-off-by: Christian Marangi --- drivers/net/phy/qcom/qca807x.c | 256 ++++++++++++++++++++++++++++++++- 1 file changed, 254 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/qcom/qca807x.c b/drivers/net/phy/qcom/qca807x.c index 43fc9cddd975..01815f947060 100644 --- a/drivers/net/phy/qcom/qca807x.c +++ b/drivers/net/phy/qcom/qca807x.c @@ -57,8 +57,18 @@ #define QCA807X_MMD7_LED_CTRL(x) (0x8074 + ((x) * 2)) #define QCA807X_MMD7_LED_FORCE_CTRL(x) (0x8075 + ((x) * 2)) -#define QCA807X_GPIO_FORCE_EN BIT(15) -#define QCA807X_GPIO_FORCE_MODE_MASK GENMASK(14, 13) +/* LED hw control pattern for fiber port */ +#define QCA807X_LED_FIBER_PATTERN_MASK GENMASK(11, 1) +#define QCA807X_LED_FIBER_TXACT_BLK_EN BIT(10) +#define QCA807X_LED_FIBER_RXACT_BLK_EN BIT(9) +#define QCA807X_LED_FIBER_FDX_ON_EN BIT(6) +#define QCA807X_LED_FIBER_HDX_ON_EN BIT(5) +#define QCA807X_LED_FIBER_1000BX_ON_EN BIT(2) +#define QCA807X_LED_FIBER_100FX_ON_EN BIT(1) + +/* Some device repurpose the LED as GPIO out */ +#define QCA807X_GPIO_FORCE_EN QCA808X_LED_FORCE_EN +#define QCA807X_GPIO_FORCE_MODE_MASK QCA808X_LED_FORCE_MODE_MASK #define QCA807X_FUNCTION_CONTROL 0x10 #define QCA807X_FC_MDI_CROSSOVER_MODE_MASK GENMASK(6, 5) @@ -121,6 +131,233 @@ static int qca807x_cable_test_start(struct phy_device *phydev) return 0; } +static int qca807x_led_parse_netdev(struct phy_device *phydev, unsigned long rules, + u16 *offload_trigger) +{ + /* Parsing specific to netdev trigger */ + switch (phydev->port) { + case PORT_TP: + if (test_bit(TRIGGER_NETDEV_TX, &rules)) + *offload_trigger |= QCA808X_LED_TX_BLINK; + if (test_bit(TRIGGER_NETDEV_RX, &rules)) + *offload_trigger |= QCA808X_LED_RX_BLINK; + if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) + *offload_trigger |= QCA808X_LED_SPEED10_ON; + if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) + *offload_trigger |= QCA808X_LED_SPEED100_ON; + if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) + *offload_trigger |= QCA808X_LED_SPEED1000_ON; + if (test_bit(TRIGGER_NETDEV_HALF_DUPLEX, &rules)) + *offload_trigger |= QCA808X_LED_HALF_DUPLEX_ON; + if (test_bit(TRIGGER_NETDEV_FULL_DUPLEX, &rules)) + *offload_trigger |= QCA808X_LED_FULL_DUPLEX_ON; + break; + case PORT_FIBRE: + if (test_bit(TRIGGER_NETDEV_TX, &rules)) + *offload_trigger |= QCA807X_LED_FIBER_TXACT_BLK_EN; + if (test_bit(TRIGGER_NETDEV_RX, &rules)) + *offload_trigger |= QCA807X_LED_FIBER_RXACT_BLK_EN; + if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) + *offload_trigger |= QCA807X_LED_FIBER_100FX_ON_EN; + if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) + *offload_trigger |= QCA807X_LED_FIBER_1000BX_ON_EN; + if (test_bit(TRIGGER_NETDEV_HALF_DUPLEX, &rules)) + *offload_trigger |= QCA807X_LED_FIBER_HDX_ON_EN; + if (test_bit(TRIGGER_NETDEV_FULL_DUPLEX, &rules)) + *offload_trigger |= QCA807X_LED_FIBER_FDX_ON_EN; + break; + default: + return -EOPNOTSUPP; + } + + if (rules && !*offload_trigger) + return -EOPNOTSUPP; + + return 0; +} + +static int qca807x_led_hw_control_enable(struct phy_device *phydev, u8 index) +{ + u16 reg; + + if (index > 1) + return -EINVAL; + + reg = QCA807X_MMD7_LED_FORCE_CTRL(index); + return qca808x_led_reg_hw_control_enable(phydev, reg); +} + +static int qca807x_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules) +{ + u16 offload_trigger = 0; + + if (index > 1) + return -EINVAL; + + return qca807x_led_parse_netdev(phydev, rules, &offload_trigger); +} + +static int qca807x_led_hw_control_set(struct phy_device *phydev, u8 index, + unsigned long rules) +{ + u16 reg, mask, offload_trigger = 0; + int ret; + + if (index > 1) + return -EINVAL; + + ret = qca807x_led_parse_netdev(phydev, rules, &offload_trigger); + if (ret) + return ret; + + ret = qca807x_led_hw_control_enable(phydev, index); + if (ret) + return ret; + + switch (phydev->port) { + case PORT_TP: + reg = QCA807X_MMD7_LED_CTRL(index); + mask = QCA808X_LED_PATTERN_MASK; + break; + case PORT_FIBRE: + /* HW control pattern bits are in LED FORCE reg */ + reg = QCA807X_MMD7_LED_FORCE_CTRL(index); + mask = QCA807X_LED_FIBER_PATTERN_MASK; + break; + default: + return -EINVAL; + } + + return phy_modify_mmd(phydev, MDIO_MMD_AN, reg, mask, + offload_trigger); +} + +static bool qca807x_led_hw_control_status(struct phy_device *phydev, u8 index) +{ + u16 reg; + + if (index > 1) + return false; + + reg = QCA807X_MMD7_LED_FORCE_CTRL(index); + return qca808x_led_reg_hw_control_status(phydev, reg); +} + +static int qca807x_led_hw_control_get(struct phy_device *phydev, u8 index, + unsigned long *rules) +{ + u16 reg; + int val; + + if (index > 1) + return -EINVAL; + + /* Check if we have hw control enabled */ + if (qca807x_led_hw_control_status(phydev, index)) + return -EINVAL; + + /* Parsing specific to netdev trigger */ + switch (phydev->port) { + case PORT_TP: + reg = QCA807X_MMD7_LED_CTRL(index); + val = phy_read_mmd(phydev, MDIO_MMD_AN, reg); + if (val & QCA808X_LED_TX_BLINK) + set_bit(TRIGGER_NETDEV_TX, rules); + if (val & QCA808X_LED_RX_BLINK) + set_bit(TRIGGER_NETDEV_RX, rules); + if (val & QCA808X_LED_SPEED10_ON) + set_bit(TRIGGER_NETDEV_LINK_10, rules); + if (val & QCA808X_LED_SPEED100_ON) + set_bit(TRIGGER_NETDEV_LINK_100, rules); + if (val & QCA808X_LED_SPEED1000_ON) + set_bit(TRIGGER_NETDEV_LINK_1000, rules); + if (val & QCA808X_LED_HALF_DUPLEX_ON) + set_bit(TRIGGER_NETDEV_HALF_DUPLEX, rules); + if (val & QCA808X_LED_FULL_DUPLEX_ON) + set_bit(TRIGGER_NETDEV_FULL_DUPLEX, rules); + break; + case PORT_FIBRE: + /* HW control pattern bits are in LED FORCE reg */ + reg = QCA807X_MMD7_LED_FORCE_CTRL(index); + val = phy_read_mmd(phydev, MDIO_MMD_AN, reg); + if (val & QCA807X_LED_FIBER_TXACT_BLK_EN) + set_bit(TRIGGER_NETDEV_TX, rules); + if (val & QCA807X_LED_FIBER_RXACT_BLK_EN) + set_bit(TRIGGER_NETDEV_RX, rules); + if (val & QCA807X_LED_FIBER_100FX_ON_EN) + set_bit(TRIGGER_NETDEV_LINK_100, rules); + if (val & QCA807X_LED_FIBER_1000BX_ON_EN) + set_bit(TRIGGER_NETDEV_LINK_1000, rules); + if (val & QCA807X_LED_FIBER_HDX_ON_EN) + set_bit(TRIGGER_NETDEV_HALF_DUPLEX, rules); + if (val & QCA807X_LED_FIBER_FDX_ON_EN) + set_bit(TRIGGER_NETDEV_FULL_DUPLEX, rules); + break; + default: + return -EINVAL; + } + + return 0; +} + +static int qca807x_led_hw_control_reset(struct phy_device *phydev, u8 index) +{ + u16 reg, mask; + + if (index > 1) + return -EINVAL; + + switch (phydev->port) { + case PORT_TP: + reg = QCA807X_MMD7_LED_CTRL(index); + mask = QCA808X_LED_PATTERN_MASK; + break; + case PORT_FIBRE: + /* HW control pattern bits are in LED FORCE reg */ + reg = QCA807X_MMD7_LED_FORCE_CTRL(index); + mask = QCA807X_LED_FIBER_PATTERN_MASK; + break; + default: + return -EINVAL; + } + + return phy_clear_bits_mmd(phydev, MDIO_MMD_AN, reg, mask); +} + +static int qca807x_led_brightness_set(struct phy_device *phydev, + u8 index, enum led_brightness value) +{ + u16 reg; + int ret; + + if (index > 1) + return -EINVAL; + + /* If we are setting off the LED reset any hw control rule */ + if (!value) { + ret = qca807x_led_hw_control_reset(phydev, index); + if (ret) + return ret; + } + + reg = QCA807X_MMD7_LED_FORCE_CTRL(index); + return qca808x_led_reg_brightness_set(phydev, reg, value); +} + +static int qca807x_led_blink_set(struct phy_device *phydev, u8 index, + unsigned long *delay_on, + unsigned long *delay_off) +{ + u16 reg; + + if (index > 1) + return -EINVAL; + + reg = QCA807X_MMD7_LED_FORCE_CTRL(index); + return qca808x_led_reg_blink_set(phydev, reg, delay_on, delay_off); +} + #ifdef CONFIG_GPIOLIB static int qca807x_gpio_get_direction(struct gpio_chip *gc, unsigned int offset) { @@ -496,6 +733,16 @@ static int qca807x_probe(struct phy_device *phydev) "qcom,dac-disable-bias-current-tweak"); if (IS_ENABLED(CONFIG_GPIOLIB)) { + /* Make sure we don't have mixed leds node and gpio-controller + * to prevent registering leds and having gpio-controller usage + * conflicting with them. + */ + if (of_find_property(node, "leds", NULL) && + of_find_property(node, "gpio-controller", NULL)) { + phydev_err(phydev, "Invalid property detected. LEDs and gpio-controller are mutually exclusive."); + return -EINVAL; + } + /* Do not register a GPIO controller unless flagged for it */ if (of_property_read_bool(node, "gpio-controller")) { ret = qca807x_gpio(phydev); @@ -580,6 +827,11 @@ static struct phy_driver qca807x_drivers[] = { .suspend = genphy_suspend, .cable_test_start = qca807x_cable_test_start, .cable_test_get_status = qca808x_cable_test_get_status, + .led_brightness_set = qca807x_led_brightness_set, + .led_blink_set = qca807x_led_blink_set, + .led_hw_is_supported = qca807x_led_hw_is_supported, + .led_hw_control_set = qca807x_led_hw_control_set, + .led_hw_control_get = qca807x_led_hw_control_get, }, }; module_phy_driver(qca807x_drivers);