From patchwork Fri Feb 16 18:42:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 202450 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp60870dyc; Fri, 16 Feb 2024 16:00:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUYQtaRsy584KjexnYuB8yd1rwz/kIW2S+NXBWPn4u5xa2gO/gWGLoCuWqNFZInwI5ITqYZb1MEpv1q5SwtEAMls1hxpA== X-Google-Smtp-Source: AGHT+IHMGEXBlcls/JxAsjU8H4Rra0nZV8sxbcS6WtxT8PR35oZQIKmAXYORoriIYog2II3rR1AT X-Received: by 2002:a05:6a21:168d:b0:19e:4e58:b251 with SMTP id np13-20020a056a21168d00b0019e4e58b251mr9039046pzb.10.1708128005921; Fri, 16 Feb 2024 16:00:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708128005; cv=pass; d=google.com; s=arc-20160816; b=ZsyHXhaV3bSEX5xgHMGb4DoL3Buo1UMi6IoGQpI6xDOkXXQr8aIhINvrGgBHoUq6wD RRlC+st1/lOoiMKcsYvsAOqkBoL4n5A4QVgRtfPeHcw9BnpvQpB1B7zxZSHeyHud7Hbc D20bRkpHzPQmKtk7bh3bJqFFTcYyXNRWbQ29pxez20K4g8u5/+bl5V15hCN8zeZTGJt3 CVXkL9n8CJMQweOqJ6QZc6EiGHyCJuhNOQT5/3sjmF0xNeV5vV/auw7XJylNvavQWsnd 6K5PHUH5rWNmywegVO30dbpG3bHV3X1NgAkhJKZFUDikrd40jweyn5hIZOfa63V+2Mg9 dKjQ== 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:dkim-filter; bh=w78yG/yb//zkGQD3U4fBysrUn3c4n/YWOmyicAyKnhY=; fh=qrdLH5V6S6EHhdSAR+OVGwuqNaPW77Tf5cttX4TmYBA=; b=OrFJjSPHtXlGwurh4IlSbX3LgtNJkHpMZJQocu5u1KDjySdirmSFsL6/QzA/DDhaDK jJtnh8olT34RhwGYFD+IYVKSv/4C+rKPf+McGpZQNhqsCJx7gPkb9S8yRLqM5m8z55Dq e9wuOcNe60y/16hE8jxClPOJ2XW6CAYrH0Y1clG9i+ZJrPJjV2PyfYxwZQ2PUl2aHCzR Rrf5fydkMJllaAfw2/75vY1v6egyh2+jfsSyTNdA4s4KZQ4ZFp5NDJ6CoJ/QRQ1nUufm sMwCQi28kRvqGlv1QqWnhCGFZZlGvsI2IYpKW7TPAisOudLZDNlOQjITIKDSuLphKkht cEvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b="IH/yY4oR"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-69193-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69193-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j186-20020a638bc3000000b005cfbdff9195si610208pge.783.2024.02.16.16.00.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:00:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69193-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b="IH/yY4oR"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-69193-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69193-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 610DBB23EB7 for ; Fri, 16 Feb 2024 18:46:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8ECC14A0AF; Fri, 16 Feb 2024 18:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="IH/yY4oR" Received: from relay.smtp-ext.broadcom.com (unknown [192.19.166.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74B5C1350FC; Fri, 16 Feb 2024 18:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.166.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108972; cv=none; b=Smdb7zEZnScd3onrjqVaXwmjMxum3qRuk65cvOoYUIfwUpuqXTdIcehQgcqtsUqvrMeQuRKfntRz2gIfYDpDvlP16Kt+4n/BC5A/CcXHMbHewNdHXZuhaADVOrXgDNmt5VWmUbSvtqVxAMOeQKYzRGEC2ZcqwNSnUrjDa7+olG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108972; c=relaxed/simple; bh=atI59ZlQl2UfZ0o6mIsOBAuc8zQwlqIYK/Qn+yb3SGk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rt6OV6aFcmbxAfANa+e0cnZEfJlKy3+I+Mb/JXRJkqsXxmmJAfcoYUNZJFa5r3Kj6z7JeziZHBKuilgNVaOvXO7gI+WfxbctSojw2ZS57GBxSznfEaZfSdyTad74PtzTLr1kSOUpJjBCMpuY/PzjUi0q744Z4RbmQDU82kmXCW4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=IH/yY4oR; arc=none smtp.client-ip=192.19.166.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: from mail-lvn-it-01.lvn.broadcom.net (mail-lvn-it-01.lvn.broadcom.net [10.36.132.253]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 1A455C001CD0; Fri, 16 Feb 2024 10:42:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 1A455C001CD0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1708108964; bh=atI59ZlQl2UfZ0o6mIsOBAuc8zQwlqIYK/Qn+yb3SGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IH/yY4oRCbR1PpdzdsKDbn7iEBADnVed9AQW/Ci5NmNGXoKqJxvmLJRD8Ay/jQYCo bbNlFG9raduRNTvoaH/Vf6iERQW+qQ4rDTnj+GjWaLtZcgypZgES6iBUrj5HF5NqpI 1k0R1cE3f6wiTdgEotxg7AbBUDFwKVFrVdn5gWXc= Received: from fainelli-desktop.igp.broadcom.net (fainelli-desktop.dhcp.broadcom.net [10.67.48.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail-lvn-it-01.lvn.broadcom.net (Postfix) with ESMTPSA id 8430718041CAC6; Fri, 16 Feb 2024 10:42:42 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , linux-kernel@vger.kernel.org (open list), Justin Chen Subject: [PATCH net-next 1/3] net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses Date: Fri, 16 Feb 2024 10:42:35 -0800 Message-Id: <20240216184237.259954-2-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216184237.259954-1-florian.fainelli@broadcom.com> References: <20240216184237.259954-1-florian.fainelli@broadcom.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: 1791097189574763678 X-GMAIL-MSGID: 1791102031876548977 Up until now we have managed not to have the mdio-bcm-unimac manage its clock except during probe and suspend/resume. This works most of the time, except where it does not. With a fully modular build, we can get into a situation whereby the GENET driver is fully registered, and so is the mdio-bcm-unimac driver, however the Ethernet PHY driver is not yet, because it depends on a resource that is not yet available (e.g.: GPIO provider). In that state, the network device is not usable yet, and so to conserve power, the GENET driver will have turned off its "main" clock which feeds its MDIO controller. When the PHY driver finally probes however, we make an access to the PHY registers to e.g.: disable interrupts, and this causes a bus error within the MDIO controller space because the MDIO controller clock(s) are turned off. To remedy that, we manage the clock around all of the I/O accesses to the hardware which are done exclusively during read, write and clock divider configuration. This ensures that the register space is accessible, and this also ensures that there are not unnecessarily elevated reference counts keeping the clocks active when the network device is administratively turned off. It would be the case with the previous way of managing the clock. Signed-off-by: Florian Fainelli --- drivers/net/mdio/mdio-bcm-unimac.c | 91 ++++++++++--------- include/linux/platform_data/mdio-bcm-unimac.h | 3 + 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c index 68f8ee0ec8ba..0619e5d596d1 100644 --- a/drivers/net/mdio/mdio-bcm-unimac.c +++ b/drivers/net/mdio/mdio-bcm-unimac.c @@ -94,6 +94,10 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg) int ret; u32 cmd; + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; + /* Prepare the read operation */ cmd = MDIO_RD | (phy_id << MDIO_PMD_SHIFT) | (reg << MDIO_REG_SHIFT); unimac_mdio_writel(priv, cmd, MDIO_CMD); @@ -103,7 +107,7 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg) ret = priv->wait_func(priv->wait_func_data); if (ret) - return ret; + goto out; cmd = unimac_mdio_readl(priv, MDIO_CMD); @@ -112,10 +116,15 @@ static int unimac_mdio_read(struct mii_bus *bus, int phy_id, int reg) * that condition here and ignore the MDIO controller read failure * indication. */ - if (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL)) - return -EIO; + if (!(bus->phy_ignore_ta_mask & 1 << phy_id) && (cmd & MDIO_READ_FAIL)) { + ret = -EIO; + goto out; + } - return cmd & 0xffff; + ret = cmd & 0xffff; +out: + clk_disable_unprepare(priv->clk); + return ret; } static int unimac_mdio_write(struct mii_bus *bus, int phy_id, @@ -123,6 +132,11 @@ static int unimac_mdio_write(struct mii_bus *bus, int phy_id, { struct unimac_mdio_priv *priv = bus->priv; u32 cmd; + int ret; + + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; /* Prepare the write operation */ cmd = MDIO_WR | (phy_id << MDIO_PMD_SHIFT) | @@ -131,7 +145,10 @@ static int unimac_mdio_write(struct mii_bus *bus, int phy_id, unimac_mdio_start(priv); - return priv->wait_func(priv->wait_func_data); + ret = priv->wait_func(priv->wait_func_data); + clk_disable_unprepare(priv->clk); + + return ret; } /* Workaround for integrated BCM7xxx Gigabit PHYs which have a problem with @@ -178,14 +195,19 @@ static int unimac_mdio_reset(struct mii_bus *bus) return 0; } -static void unimac_mdio_clk_set(struct unimac_mdio_priv *priv) +static int unimac_mdio_clk_set(struct unimac_mdio_priv *priv) { unsigned long rate; u32 reg, div; + int ret; /* Keep the hardware default values */ if (!priv->clk_freq) - return; + return 0; + + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; if (!priv->clk) rate = 250000000; @@ -195,7 +217,8 @@ static void unimac_mdio_clk_set(struct unimac_mdio_priv *priv) div = (rate / (2 * priv->clk_freq)) - 1; if (div & ~MDIO_CLK_DIV_MASK) { pr_warn("Incorrect MDIO clock frequency, ignoring\n"); - return; + ret = 0; + goto out; } /* The MDIO clock is the reference clock (typically 250Mhz) divided by @@ -205,6 +228,9 @@ static void unimac_mdio_clk_set(struct unimac_mdio_priv *priv) reg &= ~(MDIO_CLK_DIV_MASK << MDIO_CLK_DIV_SHIFT); reg |= div << MDIO_CLK_DIV_SHIFT; unimac_mdio_writel(priv, reg, MDIO_CFG); +out: + clk_disable_unprepare(priv->clk); + return ret; } static int unimac_mdio_probe(struct platform_device *pdev) @@ -235,24 +261,12 @@ static int unimac_mdio_probe(struct platform_device *pdev) return -ENOMEM; } - priv->clk = devm_clk_get_optional(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) - return PTR_ERR(priv->clk); - - ret = clk_prepare_enable(priv->clk); - if (ret) - return ret; - if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq)) priv->clk_freq = 0; - unimac_mdio_clk_set(priv); - priv->mii_bus = mdiobus_alloc(); - if (!priv->mii_bus) { - ret = -ENOMEM; - goto out_clk_disable; - } + if (!priv->mii_bus) + return -ENOMEM; bus = priv->mii_bus; bus->priv = priv; @@ -261,17 +275,27 @@ static int unimac_mdio_probe(struct platform_device *pdev) priv->wait_func = pdata->wait_func; priv->wait_func_data = pdata->wait_func_data; bus->phy_mask = ~pdata->phy_mask; + priv->clk = pdata->clk; } else { bus->name = "unimac MII bus"; priv->wait_func_data = priv; priv->wait_func = unimac_mdio_poll; + priv->clk = devm_clk_get_optional(&pdev->dev, NULL); } + + if (IS_ERR(priv->clk)) + goto out_mdio_free; + bus->parent = &pdev->dev; bus->read = unimac_mdio_read; bus->write = unimac_mdio_write; bus->reset = unimac_mdio_reset; snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d", pdev->name, pdev->id); + ret = unimac_mdio_clk_set(priv); + if (ret) + goto out_mdio_free; + ret = of_mdiobus_register(bus, np); if (ret) { dev_err(&pdev->dev, "MDIO bus registration failed\n"); @@ -286,8 +310,6 @@ static int unimac_mdio_probe(struct platform_device *pdev) out_mdio_free: mdiobus_free(bus); -out_clk_disable: - clk_disable_unprepare(priv->clk); return ret; } @@ -297,34 +319,17 @@ static void unimac_mdio_remove(struct platform_device *pdev) mdiobus_unregister(priv->mii_bus); mdiobus_free(priv->mii_bus); - clk_disable_unprepare(priv->clk); -} - -static int __maybe_unused unimac_mdio_suspend(struct device *d) -{ - struct unimac_mdio_priv *priv = dev_get_drvdata(d); - - clk_disable_unprepare(priv->clk); - - return 0; } static int __maybe_unused unimac_mdio_resume(struct device *d) { struct unimac_mdio_priv *priv = dev_get_drvdata(d); - int ret; - ret = clk_prepare_enable(priv->clk); - if (ret) - return ret; - - unimac_mdio_clk_set(priv); - - return 0; + return unimac_mdio_clk_set(priv); } static SIMPLE_DEV_PM_OPS(unimac_mdio_pm_ops, - unimac_mdio_suspend, unimac_mdio_resume); + NULL, unimac_mdio_resume); static const struct of_device_id unimac_mdio_ids[] = { { .compatible = "brcm,asp-v2.1-mdio", }, diff --git a/include/linux/platform_data/mdio-bcm-unimac.h b/include/linux/platform_data/mdio-bcm-unimac.h index 8a5f9f0b2c52..724e1f57b81f 100644 --- a/include/linux/platform_data/mdio-bcm-unimac.h +++ b/include/linux/platform_data/mdio-bcm-unimac.h @@ -1,11 +1,14 @@ #ifndef __MDIO_BCM_UNIMAC_PDATA_H #define __MDIO_BCM_UNIMAC_PDATA_H +struct clk; + struct unimac_mdio_pdata { u32 phy_mask; int (*wait_func)(void *data); void *wait_func_data; const char *bus_name; + struct clk *clk; }; #define UNIMAC_MDIO_DRV_NAME "unimac-mdio" From patchwork Fri Feb 16 18:42:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 202453 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp66708dyc; Fri, 16 Feb 2024 16:12:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW9vQCsksp6TALmZQa877psENvP7J6K7ZqS79UKLw9/hg0jawXeXDwuz8BfvgHPpHE8VL88Hf1j1PJvlYFT3zM+Mpubug== X-Google-Smtp-Source: AGHT+IHuBIEuDrdlBmkfsoYClcFTeCNxkKhVG3/UYWFdzzmsLX4AArZxTuO6xWcdMgYq6DI0Uj9X X-Received: by 2002:a17:906:d9c8:b0:a3d:4ac5:2012 with SMTP id qk8-20020a170906d9c800b00a3d4ac52012mr4454391ejb.25.1708128734092; Fri, 16 Feb 2024 16:12:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708128734; cv=pass; d=google.com; s=arc-20160816; b=isw/SRpb5F3K+9rdJL7WQ4EdaVtJmBLES/574IBE59RMMBB+wojkQGUhsWWgNvuvWR 7zotIQxxYbyk2BPy1IMoplMy/MXLdSl7eZWHgjfP1pnfx9jMuPtoKYSF/aw1Az//RNon 6+fxwEZrAnZhQBthPDVuVLZZlJsGd/Z0kryYa7J8xSCKn/aNsV3PdoQAHRDUWbli0D01 WJ2/fnPfqCl6foq7ZCs9IQ1EugBB/pN1vgURNh9TjXR7P3WYWj514NAReWd0ijYuQ2qL e989gF2D8KZkkR4suowjXGJlH8ZLN2bk2DYjV85OWWw9euPHIobgKAQGfPfE3CTCwX8C DQZA== 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:dkim-filter; bh=9Kyt2HvLplNXvCF1UNtmucaaOjaedLaQBGW0qxy8u0Q=; fh=qrdLH5V6S6EHhdSAR+OVGwuqNaPW77Tf5cttX4TmYBA=; b=WDBAj6Ly20YSu5WQTRedvfTyEVTrxOWULVZWTkonJSoqgemQTOKOr4CA+pPwgC59WN MAiW8MBw3pqskL0CBMDiC6sxSMg4u+F8N6JIHysjwkeYerM13EydY+rGl261Co445dMR IsuPfIMdO1ACFCocts+9j3pWHYNDcg0pGkBUApscqiYd1qLfJsdNRsM4plhob0lT6PL2 UKa2KfbHtqPj0k7rH9lPV9kXC2zPh6Tpj2lKn6B2RQpnOWQTbyPw5dnw1Am5Q9zQUp2Q CP4Kq4iyDNa+JrVjQGu/1R5i1NuCNNOEQ5z6mOmA71nTmoV9H7EkMl7XT83Ds9SMHlBu B/iQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b=JWlLMDNU; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-69192-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69192-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fx26-20020a170906b75a00b00a3e1226ddd8si251233ejb.996.2024.02.16.16.12.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:12:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69192-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=@broadcom.com header.s=dkimrelay header.b=JWlLMDNU; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-69192-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69192-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.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 039EC1F23722 for ; Fri, 16 Feb 2024 18:46:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 917EC14A089; Fri, 16 Feb 2024 18:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="JWlLMDNU" Received: from relay.smtp-ext.broadcom.com (unknown [192.19.166.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 744C31350FB; Fri, 16 Feb 2024 18:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.166.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108972; cv=none; b=GNdhAIHrb759bNvN09MZdOwfixYdAjJq2nnk34InBJrQeoAsbo5zVqytFJnKREkAxeEEHJt07Kv1lv77buLCxIXDSJnFX9NdNCCVeBj6Iv6TS4yvWgDBXcFiqJYCe5xYtl+4gZpR3yqe/V/fcbH8chaxXgj+r/z5Qlmq/xOp+v4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108972; c=relaxed/simple; bh=i9k3K96piVEikMIz1+hmpkE1mIU1mvLihqfUZnhngpg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Bvk7fqj2erGx6IL/mTH3jrZ8osXEgW/S0Vc7e0SjTpbSE/pT9XNTfqn3bk50pmsYnuqm+yNSchGDKVWnndOF5V0ruO2onRHbuQbQE2KsIdXKDt2SDlqSK67c7POmxa8lK9c9AnL1Q8di29jbqjokPSam5FFqar+hIvkVDubM72o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=JWlLMDNU; arc=none smtp.client-ip=192.19.166.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: from mail-lvn-it-01.lvn.broadcom.net (mail-lvn-it-01.lvn.broadcom.net [10.36.132.253]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 41628C001645; Fri, 16 Feb 2024 10:42:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 41628C001645 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1708108964; bh=i9k3K96piVEikMIz1+hmpkE1mIU1mvLihqfUZnhngpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JWlLMDNUIQVlrb/EVKF/dk8fEIJvopreIsxpUCoO7nxUIkrJ6gOGCuE8aKTcHRE9a 6qD1F2aN7+hE+zbbxuacaz45WZG4SPfUHVrK9wSeLZoOct7ymlGge+lFetseCtfQQc LNY38g7VwzgZv38I7IgGL5TvBdaIXwGDvVaGUX+Y= Received: from fainelli-desktop.igp.broadcom.net (fainelli-desktop.dhcp.broadcom.net [10.67.48.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail-lvn-it-01.lvn.broadcom.net (Postfix) with ESMTPSA id AB8CA18041CAC7; Fri, 16 Feb 2024 10:42:42 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , linux-kernel@vger.kernel.org (open list), Justin Chen Subject: [PATCH net-next 2/3] net: bcmgenet: Pass "main" clock down to the MDIO driver Date: Fri, 16 Feb 2024 10:42:36 -0800 Message-Id: <20240216184237.259954-3-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216184237.259954-1-florian.fainelli@broadcom.com> References: <20240216184237.259954-1-florian.fainelli@broadcom.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: 1791097226603197075 X-GMAIL-MSGID: 1791102795431822424 GENET has historically had to create a MDIO platform device for its controller and pass some auxiliary data to it, like a MDIO completion callback. Now we also pass the "main" clock to allow for the MDIO bus controller to manage that clock adequately around I/O accesses. Signed-off-by: Florian Fainelli --- drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index cbbe004621bc..7a21950da77c 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -476,6 +476,10 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv) ppd.wait_func = bcmgenet_mii_wait; ppd.wait_func_data = priv; ppd.bus_name = "bcmgenet MII bus"; + /* Pass a reference to our "main" clock which is used for MDIO + * transfers + */ + ppd.clk = priv->clk; /* Unimac MDIO bus controller starts at UniMAC offset + MDIO_CMD * and is 2 * 32-bits word long, 8 bytes total. From patchwork Fri Feb 16 18:42:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 202366 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp790749dyb; Fri, 16 Feb 2024 13:16:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU96QFggXRHl5qVh2IXYLXmFzVHChZqXrCBorlplHFMden8YfgkzDT7Iy4jQfgyV0p15jEErKJQwQZKvXxw9drYbi+lXg== X-Google-Smtp-Source: AGHT+IFWIrMjtiaH1TAL3zqbRJ5yYjP+XbbXFwRmJ+EsAEgdoOevBydtA3YBqMDxsb7kzXhhTUG5 X-Received: by 2002:a05:6870:f611:b0:21a:2e98:75ec with SMTP id ek17-20020a056870f61100b0021a2e9875ecmr6345933oab.48.1708118179702; Fri, 16 Feb 2024 13:16:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708118179; cv=pass; d=google.com; s=arc-20160816; b=wQUOpffpVQgT0+/+kbgeNMh66M2sc/oYaRC90WDuGTPeLTxa+vW4UEkbuYVTJAa96l hxF68kBSQP3xUk7jeWgGxsiDoK0vXmyQcntUouhR8AOKo/5kqZJ4Zf9/4m5gmehsV6yp Sipx+EIfEV00BaevrzMcCRclbON1lsVhoWSpsr/4Cjh4VDGU+A56p1pllBuI1VLDjGq4 L6BbbIn4q8CxJv751rvPG6kdB86VEb0papM4Q7GUORoc7ZCzBZKQcOYDwnlIHF7IWwu7 iy0dwKt/3U85w+fj+g+hhw8A18dP9ojqHepivw2CIKEUPhtgH9wFK3RZar8MXw6sQHUr dhVA== 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:dkim-filter; bh=SAnn149WPcRSWlF7+qZT0uD2dxJItI8EU6I6anRlq8E=; fh=qrdLH5V6S6EHhdSAR+OVGwuqNaPW77Tf5cttX4TmYBA=; b=U1AbJJjaag5DApwqigQ/KkBILcnhwgnjaWYdQgkoHNYE9kPoWr+yvoGrVxkDGWjddD pkl0TNG82v5qf9oTWje/hoRLCyUOH/Vbw/VH8QmJzjiHCaQySksz/iQTsU/MH1ueX5HA cK3bjHq0dT7QmZCazTsocWChjKpAwEfvHp9M9eD8gYuQZmxwaT/O5nph06shb9b+TmUe J2x2/N4G1EKkWFjpeIwfBShzsrhMcHy/BQEdl4fKkvux/SoVZ9vdWwOdKiHJMcIyTuqx 9vfSyTMdKxub0JF1IZR+07e/ST9AO76LqeVohYX+rHntLgxoIZr81dh7lVlKMsQKbfBo w1Nw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b="Kosdvd/0"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-69195-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69195-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j19-20020a05620a411300b00785a436c916si958854qko.59.2024.02.16.13.16.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 13:16:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69195-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=dkimrelay header.b="Kosdvd/0"; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-69195-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69195-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.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 7666A1C2313D for ; Fri, 16 Feb 2024 18:46:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4B3414A0A7; Fri, 16 Feb 2024 18:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Kosdvd/0" Received: from relay.smtp-ext.broadcom.com (unknown [192.19.166.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7448212BEA5; Fri, 16 Feb 2024 18:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.19.166.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108973; cv=none; b=pyrV7aETUWV/Vh7Mx0zZGITxZEGqpGBJbmHiEnaKDp4exn/9cQi3/5YyKrN93CD2NdMVFActXz09HayTx7EFWUCeVz1M0CLb2I4z795mqhe1dH/qnmWJhUIIsfCWzZ0Jzpe/3+axfus+dkyK1x1g4K6FgTPjg0s4hIWyp4Swjhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108973; c=relaxed/simple; bh=aYVN0ClhfDjP4lyRugwKQwrba9nObMXNir2vK77i6h8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IGtzpAADf8xzhyfgh/t/NgIIMe3EBAWueffYQyjB2NLPTcrLUYRevkb/GbMhXyKs7nAukcuBirbcaN8tjURRe9gBgZxtZwP823GzwD3Db+ISgiBBWNM1I4AT7wHsw7kCXC6DMjFuCs2gtIEH3Aa+atfZQBUG7NqdYvy70QwLDeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Kosdvd/0; arc=none smtp.client-ip=192.19.166.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: from mail-lvn-it-01.lvn.broadcom.net (mail-lvn-it-01.lvn.broadcom.net [10.36.132.253]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id 5A595C001649; Fri, 16 Feb 2024 10:42:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 5A595C001649 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1708108964; bh=aYVN0ClhfDjP4lyRugwKQwrba9nObMXNir2vK77i6h8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kosdvd/0aXFCgAb/wSbT4QkgQzw0O6+P4UZsh6g9NqKv1Z3YpNL4exLRaPQE3MhHI AJ0JF7oK6feH+Bu4GhKHVOZ8LprE/GpSoOXMo6LCv/KbjCFow+ss96vYdEu77rdeTQ z14x9A9PeTWqUgTG0+jmbk6rf8c12n1gWXecUhhM= Received: from fainelli-desktop.igp.broadcom.net (fainelli-desktop.dhcp.broadcom.net [10.67.48.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail-lvn-it-01.lvn.broadcom.net (Postfix) with ESMTPSA id D2D7518041CAC6; Fri, 16 Feb 2024 10:42:42 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , linux-kernel@vger.kernel.org (open list), Justin Chen Subject: [PATCH net-next 3/3] Revert "net: bcmgenet: Ensure MDIO unregistration has clocks enabled" Date: Fri, 16 Feb 2024 10:42:37 -0800 Message-Id: <20240216184237.259954-4-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240216184237.259954-1-florian.fainelli@broadcom.com> References: <20240216184237.259954-1-florian.fainelli@broadcom.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: 1791091728142580991 X-GMAIL-MSGID: 1791091728142580991 This reverts commit eac0aac07f6af47b8ba57c8064bf04ed6df73d1d ("net: bcmgenet: Ensure MDIO unregistration has clocks enabled"). This is no longer necessary now that the MDIO bus controller has a clock that it can manage around the I/O accesses. Signed-off-by: Florian Fainelli Reviewed-by: Jacob Keller --- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 7a21950da77c..9ada89355747 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -678,7 +678,5 @@ void bcmgenet_mii_exit(struct net_device *dev) if (of_phy_is_fixed_link(dn)) of_phy_deregister_fixed_link(dn); of_node_put(priv->phy_dn); - clk_prepare_enable(priv->clk); platform_device_unregister(priv->mii_pdev); - clk_disable_unprepare(priv->clk); }