Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4697853yba; Wed, 8 May 2019 00:55:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/NIOR4G9QLvQzp6L8PSZuMQ9ZRIUZsgMYOslX+90yWWPpAVu1jk4YhKwUdbt6fVfr1098 X-Received: by 2002:a62:ee04:: with SMTP id e4mr20013974pfi.232.1557302120796; Wed, 08 May 2019 00:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557302120; cv=none; d=google.com; s=arc-20160816; b=DrKbtQUUjPJ9n1EJ1Gs0qvQXxzkBK8UH8jew+SnaMrRfBgoDvgzmZTk7q06fqgokTD Xmh0VTzV7W/OB/5ca//n9lPRCL2gwcl7kC3eHkyQcFnzgJGH7LUGJ5l4arfH1RMttXBc VYVZksfcUD93Zn79yaeRA11q/Q761pYjlajSghnJ2DSfM9rPGZChwUsbrj6OwcpIkrQq h0V12e5cM54f6pf0P4uEmk/UNn7k2DW/S+iq0mGk30JPk6sFREYg4/VQB6jt+qF3VYr+ pVLhuYZjqdCI/gTePY/NYls5Gt0rT8DleGEB57Z6f9R/PILBSc8kZgugVav7aM0e0ye4 xj3w== 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=SDz/6rVt4WgwwYNowNSD5OAUcHONvMkSUok/FW4R2XA=; b=itM91uHrMQJKAHDxm7pXGYSe3UEEbUspRti46wstIJXJPuCc78ya77LOooAh2nA9JT aLjkaB39SMCg7q6Z5OSiWUIozdXWSUWeFxNvdcVI8dmfhfFrJtn1cOFSwpcYcLH22viz xV0sQSswQ/O7Eytc849PhAbhdlSAj2gqxVnkMznY+kkA6kyvpPrgdUVEk6ygS9iytdOD ShQHbnVC5+woSzog4nSUIQnwKZW023p2zQQ6QPWkd0LpqHL1m1ZQafCuvr6f3hzwwN8p 4S+c4cOmgNOI2YubBBAfW1EJmBr9nt9dWprD3FRVWfSCt6W8nfFqHafy+2pOOTIpX35Z nEbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=GG8f5Ejd; 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 m39si23343333plg.195.2019.05.08.00.55.05; Wed, 08 May 2019 00:55:20 -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=GG8f5Ejd; 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 S1726908AbfEHHwy (ORCPT + 99 others); Wed, 8 May 2019 03:52:54 -0400 Received: from dc2-smtprelay2.synopsys.com ([198.182.61.142]:53836 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726221AbfEHHv3 (ORCPT ); Wed, 8 May 2019 03:51:29 -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 59476C010D; Wed, 8 May 2019 07:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1557301883; bh=g7s+I8un+FY7/k4BwweRm2ebGOtvijMXRTX2Cm1zU7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=GG8f5Ejd9f/sSqYsb8EorFjzCYpYd4ZBW9Mom0NEUOPexU6sV2dSiJOXzstwEAStI MKuaW66yRRFP6nAeiaPq1FI9qb11Lhwb6AZuSATaFB6cl+3LhDrQHxZiTsWJa9v28r 1Aji3UMz9pKmPqwizDUieFcdccWoMnNey/OwD8kPEaKFh8NDzCal/dI4zQeS7OWUr7 sEaibAs9qWHZQaklbX7VPx2WtPQfB1qJw0/CiLacOkv1N+Pm4obC3qjBduKOon10qm Y2WVteEz00GSkZJ8M3Erglf2kUpmWzfX1lBHci7MwkLDxK7Y0t+hsb5BMNoZuKw1pz diEbZlj7f/8iA== Received: from de02.synopsys.com (de02.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id 5EE9EA02D0; Wed, 8 May 2019 07:51:29 +0000 (UTC) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id 9DAE63D523; Wed, 8 May 2019 09:51:27 +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 Subject: [PATCH net-next 05/11] net: stmmac: dwxgmac2: Add MAC loopback support Date: Wed, 8 May 2019 09:51:05 +0200 Message-Id: <12299cb8b9fdd4d4f482ab10e90b77625d70093e.1557300602.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 dwxgmac2 core. Signed-off-by: Jose Abreu Cc: Joao Pinto Cc: David S. Miller Cc: Giuseppe Cavallaro Cc: Alexandre Torgue --- drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 1 + drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h index 085b700a4994..f629ccc8932a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -29,6 +29,7 @@ #define XGMAC_CONFIG_GPSL GENMASK(29, 16) #define XGMAC_CONFIG_GPSL_SHIFT 16 #define XGMAC_CONFIG_S2KP BIT(11) +#define XGMAC_CONFIG_LM BIT(10) #define XGMAC_CONFIG_IPC BIT(9) #define XGMAC_CONFIG_JE BIT(8) #define XGMAC_CONFIG_WD BIT(7) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c index 64b8cb88ea45..c27b3ca052ea 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -321,6 +321,18 @@ static void dwxgmac2_set_filter(struct mac_device_info *hw, writel(value, ioaddr + XGMAC_PACKET_FILTER); } +static void dwxgmac2_set_mac_loopback(void __iomem *ioaddr, bool enable) +{ + u32 value = readl(ioaddr + XGMAC_RX_CONFIG); + + if (enable) + value |= XGMAC_CONFIG_LM; + else + value &= ~XGMAC_CONFIG_LM; + + writel(value, ioaddr + XGMAC_RX_CONFIG); +} + const struct stmmac_ops dwxgmac210_ops = { .core_init = dwxgmac2_core_init, .set_mac = dwxgmac2_set_mac, @@ -350,6 +362,7 @@ const struct stmmac_ops dwxgmac210_ops = { .pcs_get_adv_lp = NULL, .debug = NULL, .set_filter = dwxgmac2_set_filter, + .set_mac_loopback = dwxgmac2_set_mac_loopback, }; int dwxgmac2_setup(struct stmmac_priv *priv) -- 2.7.4