Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6515882yba; Tue, 14 May 2019 08:49:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQb3aaw89gGyaE5HldqCxAhHrUXiyoMpW+wXJL+FPTtkHkqFroJuePOjVRjEk34Gk54hmE X-Received: by 2002:a63:d0e:: with SMTP id c14mr39131521pgl.345.1557848962165; Tue, 14 May 2019 08:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557848962; cv=none; d=google.com; s=arc-20160816; b=ldVmiKHUPDjiTX6VEo8Q0SecYTOFHrsIbR/JQRH8GB1WcQOwwzKThLBKK/z1Yt9Ik+ 22YtmBXGatRIxyJbNXCUS3JXwAiev3ePmPBh8doXPcn/TmcszXC989KjAYy3xWA1pjHs gOiRJ4fCRH8DY+juTjnZ+KqUyWngfqR84qDqekE5hUU7m+ZdE/jQmeKoeEEXh3b3c/OI U6DxF2WGjgzRpQLeBUIgvYuUepQ5vkLkdEiWMmZ64QcE8aLQ3BPOHlHdKWQg3fwrxcTV 9stR2Bnm3lYPjzBtt6fy8kRK8QNGQ7qblwkfVGAbgZAfoori7IsoCHG76WXxluWA8qv4 XPCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=n9mVGWntF8bthpSyCOWU6BqXj7IUW9BsLTT1wx7eeoA=; b=FgPJEtn4oXeXds6Yw81XakYJozlnoZHrraIwDN7MwhXZn718IIRoGs77z69OsPaFXd v5EjKaPWGWEJohp55xA3B12fdZtPy5egDSaelLBUkSmRujStlFQEJzkErgmpov+1ATQr rRVkPTZl8BisQrkEpujAuhIDFXlgBR7BLVcBMh0ImsOQFZ7u8sgObNGNRtmfkQJdeJdk /7crFTk7dcrxLXxClWFKof+cik/01i057hWIEypw3wrOHNX8nzQZ/QzK/2r9qMp2jSW1 EnkqnyMKgdaVNn+pBjNGxARAF8NsaqxTK4sg/mZrUo+6R2NwIAtsTn7MAIi0XLtuk4oB kpRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=YozXMVuv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j22si21173652pfi.167.2019.05.14.08.49.07; Tue, 14 May 2019 08:49:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=YozXMVuv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726466AbfENPpm (ORCPT + 99 others); Tue, 14 May 2019 11:45:42 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.47.102]:36286 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbfENPpl (ORCPT ); Tue, 14 May 2019 11:45:41 -0400 Received: from mailhost.synopsys.com (dc2-mailhost2.synopsys.com [10.12.135.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 999EDC00A7; Tue, 14 May 2019 15:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1557848745; bh=vMtkeGJYR0zyPoI1aSHR7lqITOvxpI1w439NYnSYuo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=YozXMVuv1ooSEG2+PF0c2F3nI3N9sR746VeBW5LsLDXxpFoaxqBY3Z9z0Dsu7K5Hz VU/B9RKSrBh833gXbAYqqdati/UmowFKl64VDfivE3T2Z+azSPCGQwm+3PD9edth7D kTO8/fEtsjKoe7T0Efgt7BDykKrBT4R3HGuQDOj5MC8RBqGjU69nLk8guCseLYeB4h //J4+hgmVnu3eALtvETwNPag3UK3HdX/wSc+nXLRm7qcEOF+6ak4H6ndC8hcGA+QQd hyyGdMwAQDWiW32Po/sXBEf/aX04PbGkWNlpK+ZcAoPgRFSgzYal7ZLloMCBTJbqgU 1gFLWMiw2B84w== Received: from de02.synopsys.com (de02.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id 1FA5BA00A9; Tue, 14 May 2019 15:45:40 +0000 (UTC) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id 5350E3EA1B; Tue, 14 May 2019 17:45:39 +0200 (CEST) From: Jose Abreu To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jose Abreu , Joao Pinto , "David S . Miller" , Giuseppe Cavallaro , Alexandre Torgue , Corentin Labbe Subject: [RFC net-next v2 04/14] net: stmmac: dwmac4/5: Add MAC loopback support Date: Tue, 14 May 2019 17:45:26 +0200 Message-Id: <9c72f71da5c8e2bfdcd251aaaf5ad8d4dba25e69.1557848472.git.joabreu@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for the addition of stmmac selftests we implement the MAC loopback callback in dwmac4/5 cores. Signed-off-by: Jose Abreu Cc: Joao Pinto Cc: David S. Miller Cc: Giuseppe Cavallaro Cc: Alexandre Torgue Cc: Corentin Labbe --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index eb013d54025a..3dddd7902b0f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -160,6 +160,7 @@ enum power_event { #define GMAC_CONFIG_PS BIT(15) #define GMAC_CONFIG_FES BIT(14) #define GMAC_CONFIG_DM BIT(13) +#define GMAC_CONFIG_LM BIT(12) #define GMAC_CONFIG_DCRS BIT(9) #define GMAC_CONFIG_TE BIT(1) #define GMAC_CONFIG_RE BIT(0) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 7e5d5db0d516..2f1a2a6f9b33 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -701,6 +701,18 @@ static void dwmac4_debug(void __iomem *ioaddr, struct stmmac_extra_stats *x, x->mac_gmii_rx_proto_engine++; } +static void dwmac4_set_mac_loopback(void __iomem *ioaddr, bool enable) +{ + u32 value = readl(ioaddr + GMAC_CONFIG); + + if (enable) + value |= GMAC_CONFIG_LM; + else + value &= ~GMAC_CONFIG_LM; + + writel(value, ioaddr + GMAC_CONFIG); +} + const struct stmmac_ops dwmac4_ops = { .core_init = dwmac4_core_init, .set_mac = stmmac_set_mac, @@ -730,6 +742,7 @@ const struct stmmac_ops dwmac4_ops = { .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, + .set_mac_loopback = dwmac4_set_mac_loopback, }; const struct stmmac_ops dwmac410_ops = { @@ -761,6 +774,7 @@ const struct stmmac_ops dwmac410_ops = { .pcs_get_adv_lp = dwmac4_get_adv_lp, .debug = dwmac4_debug, .set_filter = dwmac4_set_filter, + .set_mac_loopback = dwmac4_set_mac_loopback, }; const struct stmmac_ops dwmac510_ops = { @@ -797,6 +811,7 @@ const struct stmmac_ops dwmac510_ops = { .safety_feat_dump = dwmac5_safety_feat_dump, .rxp_config = dwmac5_rxp_config, .flex_pps_config = dwmac5_flex_pps_config, + .set_mac_loopback = dwmac4_set_mac_loopback, }; int dwmac4_setup(struct stmmac_priv *priv) -- 2.7.4