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: 54102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3121911wrn; Tue, 7 Feb 2023 14:55:03 -0800 (PST) X-Google-Smtp-Source: AK7set/FDlW1LWVKT9ZrR3uZGtL2gJAttayUKGylVZ++VXbtcQ+lG79ovcdR4ac4g8zSgwS7N5s7 X-Received: by 2002:a17:906:1b04:b0:871:d59d:4f54 with SMTP id o4-20020a1709061b0400b00871d59d4f54mr4306715ejg.27.1675810503660; Tue, 07 Feb 2023 14:55:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675810503; cv=none; d=google.com; s=arc-20160816; b=teOS3jBB9bf/aBU32/KrDc4cKC3fI6vM5Qc1V8GvAxJcfqoz+PiUex2dRpOFAb6pZ/ P3cJFjtLXt0zFwasM3S/K4k4sLB2ZHbs27avtkbgd29OmQgVrOXuOZfNKJ7lNmDrFUbQ tNQR71JyjRgA+zpkpqR/4KIxmpohmJbpV1CfUJDrLC7DIm805As+FtGPD/8GJngjU/XB 60zVaC8DOS2xUH8jsiTwcdyRHd7GOBYuwWSYBR9Rmo93z1/I7LDIsOF7wuTxsbqHMMLU s6TgRb6IfobQrk8xKrDox1jcWc55yGfcf7lpmEwDFWEzqfdmAgrXVw6atHnUn9HKBZNn IcrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fCqExVtxIQ8fx2PtH4CD+ssBUWyleyM+Y/yJC5Su3to=; b=MQasbYGShzzXuxmthoHTN9DIFnOUJrL2saUjovrmHXJ8vmgaqwL9QQQm/gsHeWZMBp CU3STnIwWPdxnYfbcrhwsRJFzyDumVM+39WEsbl3l/Tdk4yWZ5wVBdLvJtK7P/Ofe4DV hVTm5X31O7W2yayqOGYzoYetfd8vcSufu9v5t0k0GBHmmYj8GsZy23917jlQQkDDIMGl dFkcEj6YdeK4D6UBGWcQYCd5cVg7wycO7FXc1NAL93MWUmRGNpv0s/miS1aVZSKZ/mXk hQByS7sYt12EGtU8Yo94wBJIgsbUmqKQcF7VqICRdcPeHK8O+LA58Z2vTwvXWhI/BKx/ wvNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ARzyMCa5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n5-20020a17090673c500b0087bd1423fdasi23155308ejl.910.2023.02.07.14.54.39; Tue, 07 Feb 2023 14:55:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ARzyMCa5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbjBGWyC (ORCPT + 99 others); Tue, 7 Feb 2023 17:54:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjBGWyA (ORCPT ); Tue, 7 Feb 2023 17:54:00 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16F9322A03; Tue, 7 Feb 2023 14:53:59 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id dr8so46697591ejc.12; Tue, 07 Feb 2023 14:53:59 -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=g+XICN+wIH6ALaIr8Zke59RzAHcEa3Xwib6X70+NObYnvxUt0VRJ/kGNykoxcMGPHv FY5rl7KK/5E3PhFxD/s+B+s+74XIMBot596bKztqmA8emX79i2Jl/oA/EsWVUdElQakr 0R1rpWmPlnnMfGsF+gj0+mzacZ+PvLOV05CErPHo1Wi1rX0wE8tjmYMGmeVxi4VJ5apN KdBwHWPWH1DgEHRegfuUETU1Tl0SPSHqjp/13XIw4ZrNUjx5vJsbBpeDrbYrCpriMdRu yyGsVTQvJk2uSmXpB1r6DW5uw3DMTqAq2nsrCpudaao55/M/vUmj72S/WmAsJRFshibG MuHg== X-Gm-Message-State: AO0yUKXjqVD+dNAFCIgmNRGsNeann+PaZATgipoq7KNeGAfDiLhhEZOM gZi0vLnLGQBLHOENgn+5CF0= 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-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757214674569611546?= X-GMAIL-MSGID: =?utf-8?q?1757214674569611546?= 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;