From patchwork Mon Mar 25 19:30:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13602811 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 EB3E718645 for ; Mon, 25 Mar 2024 19:30:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711395046; cv=none; b=jYDuUfNxgH8E0sCWZ7qwE8O0LbtdOeVf8+5H5L0U4qXj8hliB/E5LPdfNINMtuMdCcvxzvrCw/LPaNIEClj89C7ddcABxgxzCu3rXIil0u4CDN0tSl+YQzyUsfyx2MZYQn+b5bmuB5uO1q5vacpSQsxZDs9TD2VBUF4GFi8ra6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711395046; c=relaxed/simple; bh=FBMXuIzYL3sVByMb6OSrjXnRMs36vLvJJRs8pWF9kk4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Oe1ymq8w4dNKNT19hvv3A1FcxMrpSbIZx6t1LARX1FMpOCQ/oyM4E8g9EGTiuAhB5ktUBEiyEGzQ6bt7Q9XeAupJGW4xZ7t/thWUZudHpJGZP43LjnuM5A5EbbJDK/qa1I0ClReY6Tg3fEIwmRmUJK64mNUst91sR65FK7dcsXc= 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=gkn2jAAm; arc=none smtp.client-ip=209.85.167.171 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gkn2jAAm" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3c35c4d8878so1954985b6e.1 for ; Mon, 25 Mar 2024 12:30:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1711395044; x=1711999844; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/h9nZ9qVLHAFis9t9DwFmltM3uknoACCwP4nAYD05Ic=; b=gkn2jAAmFLnwZG9mbx4hCKsr6YIXNhoftCoAgDI/XZNJlmcgvMuxNoafjMV/AzhBWG B7sLSV0aSrOmppYmoG7QhcOSk5Jrbyz7uWXcCKMX+PAbTOMlJ9VQ2VJYQra6bIT65kN2 WqfVXEbfSgCsJ/vrLSR3wBAQwx1AUZ5QUdGqo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711395044; x=1711999844; h=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=/h9nZ9qVLHAFis9t9DwFmltM3uknoACCwP4nAYD05Ic=; b=deOt4qulHVo8/lMIpODVLLj+k30nSHiIiVL15zcc4T3Xw4U3Kj4X25jrJnvspaOVoE XuCmzKkfAjU0NdOb0zUX5w1jQ/VKxHIEKPvR9mc051C/P8p+Z3baOicEuS+0RuXFeAFz xtkIW9Vf4uNGHEOP+4Fe5neiEH0d75243ocNYOvKcKyUuaNgpdjc0zAfiGVCTYgvN/tg cbp0NfULwq7sAQygFmH6tO6vkawO9YZ+R6+AQf/w8dyGMA+f2t4fQggV96cs59vzdhmV U++G+vJf1I9dGI7PgDrI+0t3iDeah5XQbVeWMYXfEduYm3BiPmlVZbMKaF4t+KFiEv7a MwOQ== X-Gm-Message-State: AOJu0Ywqd8NMf8nsb+HAZAcKQo0rDKZDkGYszOzBnMMy1E8xO/s/0wXb FiRZaPKxYJZ13rSm70vppk7aH/7TuqE+dVq6XSHv7orr9dkfVBPtMhlUGl+pjgD9l6UsJsgfKyz IPmqsbC0Lf8SDMxuad3OIf+JR6G67KpFyhWDUzqwHUig4eyKJVj5CH4e6r/7WfnDJ1Ctq9DBECy QOJ9EY1TQVhkQ1m/8hFBnBLBody+zd4qSKnjTjJvDEqA== X-Google-Smtp-Source: AGHT+IG8R+Xj7/ikggljZ37vdPPws3UjjTJFeFQPyxu+OyBOb9z6UlwN+CE8sI/u32jQFz14ejIHSQ== X-Received: by 2002:a05:6808:278c:b0:3c3:7c52:fc23 with SMTP id es12-20020a056808278c00b003c37c52fc23mr8407886oib.19.1711395043633; Mon, 25 Mar 2024 12:30:43 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id ey5-20020a05622a4c0500b00431612e7111sm689448qtb.41.2024.03.25.12.30.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 12:30:43 -0700 (PDT) From: Justin Chen To: netdev@vger.kernel.org Cc: florian.fainelli@broadcom.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, bcm-kernel-feedback-list@broadcom.com, opendmb@gmail.com, Justin Chen Subject: [PATCH net 1/2] net: bcmasp: Bring up unimac after PHY link up Date: Mon, 25 Mar 2024 12:30:24 -0700 Message-Id: <20240325193025.1540737-2-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325193025.1540737-1-justin.chen@broadcom.com> References: <20240325193025.1540737-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The unimac requires the PHY RX clk during reset or it may be put into a bad state. Bring up the unimac after link up to ensure the PHY RX clk exists. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller") Signed-off-by: Justin Chen --- .../net/ethernet/broadcom/asp2/bcmasp_intf.c | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c index dd06b68b33ed..34e5156762a8 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -392,7 +392,9 @@ static void umac_reset(struct bcmasp_intf *intf) umac_wl(intf, 0x0, UMC_CMD); umac_wl(intf, UMC_CMD_SW_RESET, UMC_CMD); usleep_range(10, 100); - umac_wl(intf, 0x0, UMC_CMD); + /* We hold the umac in reset and bring it out of + * reset when phy link is up. + */ } static void umac_set_hw_addr(struct bcmasp_intf *intf, @@ -412,6 +414,8 @@ static void umac_enable_set(struct bcmasp_intf *intf, u32 mask, u32 reg; reg = umac_rl(intf, UMC_CMD); + if (reg & UMC_CMD_SW_RESET) + return; if (enable) reg |= mask; else @@ -430,7 +434,6 @@ static void umac_init(struct bcmasp_intf *intf) umac_wl(intf, 0x800, UMC_FRM_LEN); umac_wl(intf, 0xffff, UMC_PAUSE_CNTRL); umac_wl(intf, 0x800, UMC_RX_MAX_PKT_SZ); - umac_enable_set(intf, UMC_CMD_PROMISC, 1); } static int bcmasp_tx_poll(struct napi_struct *napi, int budget) @@ -658,6 +661,12 @@ static void bcmasp_adj_link(struct net_device *dev) UMC_CMD_HD_EN | UMC_CMD_RX_PAUSE_IGNORE | UMC_CMD_TX_PAUSE_IGNORE); reg |= cmd_bits; + if (reg & UMC_CMD_SW_RESET) { + reg &= ~UMC_CMD_SW_RESET; + umac_wl(intf, reg, UMC_CMD); + udelay(2); + reg |= UMC_CMD_TX_EN | UMC_CMD_RX_EN | UMC_CMD_PROMISC; + } umac_wl(intf, reg, UMC_CMD); active = phy_init_eee(phydev, 0) >= 0; @@ -1045,9 +1054,6 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) umac_init(intf); - /* Disable the UniMAC RX/TX */ - umac_enable_set(intf, (UMC_CMD_RX_EN | UMC_CMD_TX_EN), 0); - umac_set_hw_addr(intf, dev->dev_addr); intf->old_duplex = -1; @@ -1062,9 +1068,6 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) netif_napi_add(intf->ndev, &intf->rx_napi, bcmasp_rx_poll); bcmasp_enable_rx(intf, 1); - /* Turn on UniMAC TX/RX */ - umac_enable_set(intf, (UMC_CMD_RX_EN | UMC_CMD_TX_EN), 1); - intf->crc_fwd = !!(umac_rl(intf, UMC_CMD) & UMC_CMD_CRC_FWD); bcmasp_netif_start(dev); @@ -1306,7 +1309,14 @@ static void bcmasp_suspend_to_wol(struct bcmasp_intf *intf) if (intf->wolopts & WAKE_FILTER) bcmasp_netfilt_suspend(intf); - /* UniMAC receive needs to be turned on */ + /* Bring UniMAC out of reset if needed and enable RX */ + reg = umac_rl(intf, UMC_CMD); + if (reg & UMC_CMD_SW_RESET) + reg &= ~UMC_CMD_SW_RESET; + + reg |= UMC_CMD_RX_EN | UMC_CMD_PROMISC; + umac_wl(intf, reg, UMC_CMD); + umac_enable_set(intf, UMC_CMD_RX_EN, 1); if (intf->parent->wol_irq > 0) { From patchwork Mon Mar 25 19:30:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13602812 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.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 8BF0A199B4 for ; Mon, 25 Mar 2024 19:30:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711395048; cv=none; b=uNYjWBKy8gPASM0kmEuQJPeVs+QOsladZsluTQnGsPpk+qwcR8+COqK2SVcCgoKrt8zV1o/r8KX24XyarQZqdh3V8Z2bI+UqrTtSk/ZzCoq/RmgR9xRTs8wI/oP2+rULoStwnZ8oZJWt/T48IiHsj6fYZnMF9cpwLMiCiwUR3rI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711395048; c=relaxed/simple; bh=BlOcHiv9z5XeQvVgYenfdbJlonvZWiXF6IudynQnPD4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=RXRsdj/KnB4FpL0+J072h+EYuVttCPMQKg3zb/+Cp9cjjQkEJK52NnxfQxNbaa0XvZ8qI9B4eeyNhhVuTAPAo1PP5WD23hFqVVBeoK1sR9MRw24zz9jDsLxUk31G0e6VQf3S+pLChDohzxULEuTM0E9CiT/tbtVzJxdnSlz2ZIo= 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=QJ7F4zBK; arc=none smtp.client-ip=209.85.160.51 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QJ7F4zBK" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-229cbc52318so2106367fac.2 for ; Mon, 25 Mar 2024 12:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1711395045; x=1711999845; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=G91K+G/ygSra0QGB2/Lw74OkLYKaxosUW0bcOwmdL0o=; b=QJ7F4zBKoyp3olwx7appvWTsQwuLvwo/ScceoGHgArdbO28cDpfvysGUertxGuFxts jsbcc/uoh2pc5sdlrlVPOVvAqioHT+v0ATqqbFhTN5pgbDW6Jz5BGJ1imwBo3HyduM/7 Ui1mW4CT36VjEd76UaLSw7pra6hFsvrRzW3bY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711395045; x=1711999845; h=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=G91K+G/ygSra0QGB2/Lw74OkLYKaxosUW0bcOwmdL0o=; b=POC4zEu8KTD2rzmJZUKIbswL1NNDkWBrNs55yLNO/RWobzxUpX3L1JrZD4zGZfmfWL /+VgSMGE5hN1D+aCmWCdazUJwIGNdSg/1ijny6piux4NJ0NAI33XFqhBmWcxPRp7N1aM dJSWxbvVQqXPqaoIc7/eu2ugJTGVS+AAWFxMWgSStOzMNEB7MyaXrArq8UfE1w15i2k7 YsV24V37dor7P+0hz5WAxSAOPSKwlgV4eHvM5n39p4wmnNsOTvsvHv/iwflcYbLlHp8N hmxmo01L7SV+vwYYpHm8VQNl3wT8Dfhou3NUoooLSnG+jWSt4BW/l3wreAHQABX2xvq6 ia9w== X-Gm-Message-State: AOJu0YyRlB7KVTrAyuxZdN0++lVK2zwxm8h5WugglfI59cmLxvRPUc6y 3oQnFKgw+sYYw4PcUOoEK11fzm3JPK8Qw5Km8I9I1h4D9MIB9o5jyLJaVFM3zeJiDFp4lk0yeY3 iQyP0eNqIR9eI0bnIfwd0G3KW1yRZFR8YRPaPBjAUwY2Q3/708wGrGVw902RExF3e8vXJaBhXH5 FzHG11mmQhrWBkr9YsiTF/TLxtHtmcKrL83Y8O2oZRTg== X-Google-Smtp-Source: AGHT+IFbBIi+0OC2jKcDAB8WNuQVZnOcBoIEn+b8AT9X1U+mQaE5xXKcx99IIeSJW6c+xPahOVJgHA== X-Received: by 2002:a05:6870:14d6:b0:229:f230:ea37 with SMTP id l22-20020a05687014d600b00229f230ea37mr8552317oab.20.1711395045271; Mon, 25 Mar 2024 12:30:45 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id ey5-20020a05622a4c0500b00431612e7111sm689448qtb.41.2024.03.25.12.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 12:30:45 -0700 (PDT) From: Justin Chen To: netdev@vger.kernel.org Cc: florian.fainelli@broadcom.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, bcm-kernel-feedback-list@broadcom.com, opendmb@gmail.com, Justin Chen Subject: [PATCH net 2/2] net: bcmasp: Remove phy_{suspend/resume} Date: Mon, 25 Mar 2024 12:30:25 -0700 Message-Id: <20240325193025.1540737-3-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325193025.1540737-1-justin.chen@broadcom.com> References: <20240325193025.1540737-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org phy_{suspend/resume} is redundant. It gets called from phy_{stop/start}. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller") Signed-off-by: Justin Chen --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c index 34e5156762a8..72ea97c5d5d4 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -1044,10 +1044,6 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) /* Indicate that the MAC is responsible for PHY PM */ phydev->mac_managed_pm = true; - } else if (!intf->wolopts) { - ret = phy_resume(dev->phydev); - if (ret) - goto err_phy_disable; } umac_reset(intf); @@ -1334,7 +1330,6 @@ int bcmasp_interface_suspend(struct bcmasp_intf *intf) { struct device *kdev = &intf->parent->pdev->dev; struct net_device *dev = intf->ndev; - int ret = 0; if (!netif_running(dev)) return 0; @@ -1344,10 +1339,6 @@ int bcmasp_interface_suspend(struct bcmasp_intf *intf) bcmasp_netif_deinit(dev); if (!intf->wolopts) { - ret = phy_suspend(dev->phydev); - if (ret) - goto out; - if (intf->internal_phy) bcmasp_ephy_enable_set(intf, false); else @@ -1364,11 +1355,7 @@ int bcmasp_interface_suspend(struct bcmasp_intf *intf) clk_disable_unprepare(intf->parent->clk); - return ret; - -out: - bcmasp_netif_init(dev, false); - return ret; + return 0; } static void bcmasp_resume_from_wol(struct bcmasp_intf *intf)