From patchwork Tue Feb 7 22:53:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 13132180 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB5F0C636CD for ; Tue, 7 Feb 2023 22:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fpPX5bQLqWye+38AfXreyUGAwig5LNsOcq3RUsBuW1A=; b=bEbPEWB9GSgkGM +5hJlwesfKQV7zCBrBx5Gx1ic0OfbsQH0+KU0xuc/DskYtkOb6maXJI4+TAtRdNdiUj6ZIJ7EY5LF 5GnDT4aH+aoCHAASHPg796nSwt7mOXDN8g8Jm1/uMBrXmLYjJq8hrhqFZiQWis6jJtwytqj066p0Z NA1nhcSfcAgik0mxls+maz/WF6ldYjO6x0NZk7pN4Q0/cmO8w2UZcUFU8nfvcSNl1tl2ae9NKs/fB ey/7tJamHg3a5MAMYbmafdTcS6JaKP33OlBl6kfrcsVnLbHAoTW7xqhsuPvoSNLkda9o6yCXg59dH 8qNiqtdj6vhTvz0g/9sQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPWqi-00DbBb-Vt; Tue, 07 Feb 2023 22:54:05 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPWqf-00DbA0-8z for linux-arm-kernel@lists.infradead.org; Tue, 07 Feb 2023 22:54:02 +0000 Received: by mail-ej1-x634.google.com with SMTP id ml19so46937898ejb.0 for ; Tue, 07 Feb 2023 14:53:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fCqExVtxIQ8fx2PtH4CD+ssBUWyleyM+Y/yJC5Su3to=; b=ARzyMCa57hmvHj2qiZ4Y0X13C2pc3k0DK/F2SzSo1J3Kh73G8GiPLEp9M/eWhfoboU oJLFipPSnGer6Pi3m4oPdjzsgWPxlEDqn3pSJCphmLxWCZj6+egr4cvyWcoIc2FKctnN t2BWYV+kCIKA1yPkqdr2XUs39eIYx86OrZe+edReKl84nvQlqLabsVqKACLsvnP+uCrq rRstHEk37Y+ea138gvu0Gow3zAoNSjN1G2TwKHAbHWuhMoXgtUH1y3IVX6G6UbLFEb/R 6V+VrhoB8W3sAGoMReTaH8+ufnYLkq4U2UNa53CPU/qlcUAu3tSk5Akz6B6GkxSmgLED cvsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fCqExVtxIQ8fx2PtH4CD+ssBUWyleyM+Y/yJC5Su3to=; b=X5RxWJSq+dsJXBi7os4dEivmnHFPAx4STugjD+fcWtvIHty6RikasF7D6Lad3Er4OM YnZL4++v9FU9chlZd/LYXZrq34TXpva4PrC7dBZoSWBNaj/7liFaVxCHmJiQj4C+za+0 u6gOUysOEKoTxnRTXW+QHqk6QU5rUbnrtZiKrtRwuUn6Woo5tGNSluESW/T6uRRGTAzz ruETJhCcR65ptrgS7ErwOaDkHNYhyGHc8S/Y/Hn3A6c1/oDHQI7C9Blzv7o/Up5fdmsq pUZT+TAECfcXvLIGZ8muBWOBowoElxfs6MbFmj+YEd5pMHXA85PAR+ScAo0jvacB6b24 5SCQ== X-Gm-Message-State: AO0yUKVwTCD/g6udNkmwYBLriCc/MNl15Lkrp1CRH5+Nf4zCGmxss7KD 07DSNNizB7HPmVP6owgdGhI= X-Google-Smtp-Source: AK7set858wdCN1RRt53CZdx+41ECs55QkbWbM6xU5QVfjUe3stU2UAoU/eH6rUPXzk3fuQ6uujlvNw== X-Received: by 2002:a17:907:20cb:b0:87f:89f2:c012 with SMTP id qq11-20020a17090720cb00b0087f89f2c012mr5670236ejb.24.1675810437547; Tue, 07 Feb 2023 14:53:57 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id b21-20020a170906195500b008779b5c7db6sm7437785eje.107.2023.02.07.14.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 14:53:56 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= Subject: [PATCH RFC] bgmac: fix *initial* chip reset to support BCM5358 Date: Tue, 7 Feb 2023 23:53:27 +0100 Message-Id: <20230207225327.27534-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230207_145401_359596_A475565D X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org While bringing hardware up we should perform a full reset including the switch bit (BGMAC_BCMA_IOCTL_SW_RESET aka SICF_SWRST). It's what specification says and what reference driver does. This seems to be critical for the BCM5358. Without this hardware doesn't get initialized properly and doesn't seem to transmit or receive any packets. Signed-off-by: Rafał Miłecki --- RFC: What do you think about adding that "bool initial" parameter? Is that OK? As an alternative I could use something like u16 flags; BGMAC_FLAGS_INITIAL_RESET --- drivers/net/ethernet/broadcom/bgmac.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c index 3038386a5afd..4963fdbad31b 100644 --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c @@ -876,7 +876,7 @@ static void bgmac_miiconfig(struct bgmac *bgmac) } } -static void bgmac_chip_reset_idm_config(struct bgmac *bgmac) +static void bgmac_chip_reset_idm_config(struct bgmac *bgmac, bool initial) { u32 iost; @@ -890,20 +890,20 @@ static void bgmac_chip_reset_idm_config(struct bgmac *bgmac) if (iost & BGMAC_BCMA_IOST_ATTACHED) { flags = BGMAC_BCMA_IOCTL_SW_CLKEN; - if (!bgmac->has_robosw) + if (initial || !bgmac->has_robosw) flags |= BGMAC_BCMA_IOCTL_SW_RESET; } bgmac_clk_enable(bgmac, flags); } - if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw) + if (iost & BGMAC_BCMA_IOST_ATTACHED && (initial || !bgmac->has_robosw)) bgmac_idm_write(bgmac, BCMA_IOCTL, bgmac_idm_read(bgmac, BCMA_IOCTL) & ~BGMAC_BCMA_IOCTL_SW_RESET); } /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */ -static void bgmac_chip_reset(struct bgmac *bgmac) +static void bgmac_chip_reset(struct bgmac *bgmac, bool initial) { u32 cmdcfg_sr; int i; @@ -927,7 +927,7 @@ static void bgmac_chip_reset(struct bgmac *bgmac) } if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) - bgmac_chip_reset_idm_config(bgmac); + bgmac_chip_reset_idm_config(bgmac, initial); /* Request Misc PLL for corerev > 2 */ if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) { @@ -1177,7 +1177,7 @@ static int bgmac_open(struct net_device *net_dev) struct bgmac *bgmac = netdev_priv(net_dev); int err = 0; - bgmac_chip_reset(bgmac); + bgmac_chip_reset(bgmac, false); err = bgmac_dma_init(bgmac); if (err) @@ -1214,7 +1214,7 @@ static int bgmac_stop(struct net_device *net_dev) bgmac_chip_intrs_off(bgmac); free_irq(bgmac->irq, net_dev); - bgmac_chip_reset(bgmac); + bgmac_chip_reset(bgmac, false); bgmac_dma_cleanup(bgmac); return 0; @@ -1515,7 +1515,7 @@ int bgmac_enet_probe(struct bgmac *bgmac) bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86); } - bgmac_chip_reset(bgmac); + bgmac_chip_reset(bgmac, true); err = bgmac_dma_alloc(bgmac); if (err) { @@ -1587,7 +1587,7 @@ int bgmac_enet_suspend(struct bgmac *bgmac) netif_tx_unlock(bgmac->net_dev); bgmac_chip_intrs_off(bgmac); - bgmac_chip_reset(bgmac); + bgmac_chip_reset(bgmac, false); bgmac_dma_cleanup(bgmac); return 0;