From patchwork Thu Feb 15 03:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201257 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp240127dyb; Thu, 15 Feb 2024 00:07:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWV5iuhPjwAd6/DOJHgs2PuF1r7rXD5v5s4Mx7lUJ78QJZLQTjCAw0Ji/BgijHmmlpwZbDZjlSsMQM11D8yu3AaZdgoFQ== X-Google-Smtp-Source: AGHT+IGUPPGCPxzM4dQSveJUdWKCzcrze+NAlDI2mfBLGqZoOHGtjbd40nzUeQAU94EKJBN4wgO1 X-Received: by 2002:a17:902:6841:b0:1db:28dd:a428 with SMTP id f1-20020a170902684100b001db28dda428mr930188pln.23.1707984465714; Thu, 15 Feb 2024 00:07:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707984465; cv=pass; d=google.com; s=arc-20160816; b=wGTe1kyX7b8uV+C/PkomRm9MLdGXcLubkY3UgqOXoHYwLWdwx4aMlhuvjP3yv6VSZT DMO9zgB0rhQ1TDpksekmOTjDOp/AYTkws6SxkctZFI3vPFU020UBhynv41yjKfh1sZTh 3MBUE0Bk2rSj9BqITs7PjIB1/+gpzBk4felqm5mww4mO74EQzC7EoXrVZA6KzeC5fZsc pnEuLnAYWz94gVEAluDwgflP4+rQrPXoHrGOamjaH9+5CcAuaclZ5UccP9tyLXcEKC1o ZswqsME6Ng4lLBSde5WrG3KCOpBmRUJq2ahDld+YsntFvOfX2yfua595apGoGIP/5F3B GtQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eeJEAN5Ez1X1BISwoi7jY8ezbgEUvbop9By/UAKZa0g=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=e87hdd9gome8a3YGJEGw3BewRB4ItMJ4bNBOl2krOV4U+ylXOGpPlR/rl2gflCE/jt 17KMzh1N9RyPztQlX4JFyVh9B8jaNVXCp33SwBjfarlaleN/ElF5KsGns/+PFi0Q/kWk 6rHifZpGN5ukDESyfAgI5qL8b6qXoqwTEEnFiA6+NTPOGhCD58voh0PHxVSU1qoBcUP3 13a7FFp6pSyrpTduU/2V2yx+tl0eGV+SeCcqQFMeflWADPv0c22rl0hlMnDBUd6uuNNM QsT4CRMlmSjR0bPpCL3xmIQqKn0DaFzaPy+EN0JFhvqoYuYo21AJKlavKIk6FIIEYDEC biWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JHe5034D; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u5-20020a170903124500b001d9bdc912ffsi724376plh.403.2024.02.15.00.07.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 00:07:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JHe5034D; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D121EB2902A for ; Thu, 15 Feb 2024 03:08:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE755C142; Thu, 15 Feb 2024 03:07:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JHe5034D" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 788EB8C1E; Thu, 15 Feb 2024 03:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966459; cv=none; b=R4/yTjGaZ0K4dbyoLRPJgrK/tlbHpCbwZ/AnL8cACrAuKCE+QGOjiuDreepMZYvmRna3SnBizNOJnE257NH2v8vsKjHHkVQPqS92ltGiEyZOIx7vUx6FDVYHh5pW0qNyujJlWI8pv8J9nnoRElESinMoxl9IWkaa5j5sGyzV9xE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966459; c=relaxed/simple; bh=Id7jaa6k0BX7PLQJS3cBe6qIs2K9RSyvcFT8QOa3qkE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UpQA4hHPZXNyohAs/NxgeJLwzqMEdlsjObqZW2Bi/lbHirWAC2FqNFNDfnoWis9KE87j+kBzhAbiv05h5qgdIQocub68sun07KPxrNk2keltIY1uZmIv1LB/pKTgIC/umnH1uUex1w+6NKoyhvhGA+TTMsnGVAgsATlSE/brhus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JHe5034D; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966458; x=1739502458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Id7jaa6k0BX7PLQJS3cBe6qIs2K9RSyvcFT8QOa3qkE=; b=JHe5034DGy5+/NTfiQ+rcMVtiGInq6FV40vtQMCJ4K+BbzD6suj/hiIS QQDv7H4Wd9aoMQxN2e0vZTeBAF1IAeDh/BlVCVu9JP/hoKGWr0Lk8/pSV /8JAgRRMQWDO4oKMvAxf75/y154zDtQrCcoAayfcvLVEFEZwMY/D4rIgu TjnA+hPffMPRMym1g2CI8tE5on7GWlAFsobwpi7tOjrnbuSXDmGyal+o0 PV6dOdNDVQD0fq42zORh8oU75HWpzuM4tl1GjcvmDOktMuKUVTW+L8erT 19KBesVneWJcBN942puWCa0kgWVQbm+ZfR9klckCUXfAXAsKvi0ipQxco Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461225" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461225" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:07:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385660" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:07:29 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 1/9] net: phylink: provide mac_get_pcs_neg_mode() function Date: Thu, 15 Feb 2024 11:04:51 +0800 Message-Id: <20240215030500.3067426-2-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790951518977346059 X-GMAIL-MSGID: 1790951518977346059 Phylink invokes the 'mac_get_pcs_neg_mode' function during interface mode switching and initial startup. This function is optional; if 'phylink_pcs_neg_mode' fails to accurately reflect the current PCS negotiation mode, the MAC driver can determine the mode based on the interface mode, current link negotiation mode, and advertising link mode. For instance, if the interface switches from 2500baseX to SGMII mode, and the current link mode is MLO_AN_PHY, calling 'phylink_pcs_neg_mode' would yield PHYLINK_PCS_NEG_OUTBAND. Since the MAC and PCS driver require PHYLINK_PCS_NEG_INBAND_ENABLED, the 'mac_get_pcs_neg_mode' function will calculate the mode based on the interface, current link negotiation mode, and advertising link mode, returning PHYLINK_PCS_NEG_OUTBAND to enable the PCS to configure the correct settings. Signed-off-by: Choong Yong Liang --- drivers/net/phy/phylink.c | 14 +++++++++++--- include/linux/phylink.h | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 503fd7c40523..b38b39a6d1f0 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1151,9 +1151,17 @@ static void phylink_major_config(struct phylink *pl, bool restart, phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); - pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode, - state->interface, - state->advertising); + if (pl->mac_ops->mac_get_pcs_neg_mode) { + pl->pcs_neg_mode = pl->mac_ops->mac_get_pcs_neg_mode + (pl->config, + pl->cur_link_an_mode, + state->interface, + state->advertising); + } else { + pl->pcs_neg_mode = phylink_pcs_neg_mode(pl->cur_link_an_mode, + state->interface, + state->advertising); + } if (pl->using_mac_select_pcs) { pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface); diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 6ba411732a0d..f0a6c00e8dab 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -168,6 +168,7 @@ void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed); * @mac_finish: finish a major reconfiguration of the interface. * @mac_link_down: take the link down. * @mac_link_up: allow the link to come up. + * @mac_get_pcs_neg_mode: Get PCS negotiation mode for interface mode. * * The individual methods are described more fully below. */ @@ -188,6 +189,10 @@ struct phylink_mac_ops { struct phy_device *phy, unsigned int mode, phy_interface_t interface, int speed, int duplex, bool tx_pause, bool rx_pause); + unsigned int (*mac_get_pcs_neg_mode)(struct phylink_config *config, + unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising); }; #if 0 /* For kernel-doc purposes only. */ From patchwork Thu Feb 15 03:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp159391dyb; Wed, 14 Feb 2024 20:11:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVWwQbv9mRM7JBdm/SdJZgIytdbZpVl7oaYmAaNTcsFtJgu9tFPO1gsn72XdzmJ2g6H/pWHDYizTjn5hjpK8Ta4wcIbNw== X-Google-Smtp-Source: AGHT+IFhDX8pfv8/dROMSw++kIKekZ4lsVuOsxkdt/dXk67pZuLy4XKTBRPCGR4msr3fjSoZJy53 X-Received: by 2002:a17:90a:db93:b0:298:d21c:902c with SMTP id h19-20020a17090adb9300b00298d21c902cmr689125pjv.20.1707970301901; Wed, 14 Feb 2024 20:11:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707970301; cv=pass; d=google.com; s=arc-20160816; b=srJk4tXjcj5Cldfbw/KjLfoVVkcD4ITZOpp89+DvxSppvznFdKHoQAGjmeNtrPP2wC rddSfdpVBPua9ujLadjpKd5hMFJaGnHfIJl7TrkkMn5hATGBagvRahd2ycDVriFcfYPd 8p5+LnsjNN7uc7wCbQjicVucC1b9yxJ30IjlAdzPVhyofhq0c76HoTYxXetEYr+U26nb qQ6xiV6CrHBcRfs8WgvbAP4j/5KvyRrv/0JRzEZFBlfRHwQkUdOwhG9Z4LDANumUQybr sPB91Msu+RKS9jMvOoVHUYz5ZgPnsMPUUhmPChdNFOHm/mU1PjxZB8h9hS4Lnb6I6hea Ky1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fRpdKdLzeNihx2i2mUCYONthNS7LZawYrqe2DW2cY5M=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=M0FqQuYuTtTdxDoCL+6SgYVtjCGCw5TzBPwdf61tMfYCLwGPb4HZAFKMqV6JyAEafQ hzqrkmljRBSfbcshNxBXA1OOzDDiqKa6BYemBiSyLYiw+zUY2plmbI7ZTic+xPr4be5m qt3xaXg/YuEev+J7tVNsQY120j6j3dyWdtQrqibdl0aKxHKjd1Z9NnPRKLCMUSTDZAC5 c/gamZ/E2ll+8k4yXclP5Vl5CKwmznclhb9LSl9osky6EjKkoBtovVzeH9k+ViZ1TPIV D3K7bwvtOrTtAtSV5r/16QHkEazXTkV9RAoipXqZMX3rm2x/jKaJS56PKYcwwfjfrP3M yaVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="FPo1/xsa"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66253-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66253-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h11-20020a17090aea8b00b0029712e1ba1dsi2346338pjz.72.2024.02.14.20.11.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 20:11:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66253-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="FPo1/xsa"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66253-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66253-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6FA33291073 for ; Thu, 15 Feb 2024 03:08:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19D77DDAE; Thu, 15 Feb 2024 03:07:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FPo1/xsa" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5727D272; Thu, 15 Feb 2024 03:07:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966467; cv=none; b=mJhIO9I+gmd3vRSPGfu/Cr2F7v5yxJn+lGiJ2UkxNlC9KVdcCgM/qhHe4FmYIuHDvjNi1z+n4fR3VpjhL1AL99QV9+qMhd8kN2XArODwtDuKQIHa10WQXaXLb19oKMC6u4A/yByK+hdUnK9084GMWFnSOc/kkaOKXmPZUV70K8c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966467; c=relaxed/simple; bh=3uXE9YXcC/HOZsioY0h0ZRSdXv1l7hsMeVekHYZK4p0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hT94t570p7cLEOt9VGGOYyKe1FbFU/QmHUMjOdySWveaQsy9V3x+uC0ffTnWXjlvKrxyvwdwfkvIh54vr+OzfjQ9ickK0ck+80/Y28lFydWKCMeeju/Vmg20ML5cYg4dJFrbnWQ1xvBe/bH3loNVAjQmns5OcPOvaP4PobLtPZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FPo1/xsa; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966466; x=1739502466; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3uXE9YXcC/HOZsioY0h0ZRSdXv1l7hsMeVekHYZK4p0=; b=FPo1/xsabVzfNkc78eab5CvDzzDRKLb4a/ZG9dJVb+tWjN9XY2Li12Sa i38P//KJOFrrw8773MBBV982IERagFhZUa7lcslMYxT4q1uXwtGBn7Snb jEmCZMxgfd6A0wpFRJw1Ny4o10O7spmTA31M0gQMF0kXTUkDVuvbvEFt8 O+wPEmT2+eDr6Yw7DEUj+YpMVNx4XBOacWNlzYkS31s4jkNPORjK5BdUQ /k/Elb9VEMh4NGcA0tQe/KwSMV5WI3qkyw0mzagJrVmeCpwtOqTMr0Ahx F3N949Ftj7ZfWKcauNXMqAnzQLo6sj+uBBiofuqvpuzdJTkMOhY8dNUZL w==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461247" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461247" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:07:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385671" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:07:38 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 2/9] net: phylink: add phylink_pcs_neg_mode() declaration into phylink.h Date: Thu, 15 Feb 2024 11:04:52 +0800 Message-Id: <20240215030500.3067426-3-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790936667318488719 X-GMAIL-MSGID: 1790936667318488719 Add phylink_pcs_neg_mode() declaration to the header file for other modules to call the function. Signed-off-by: Choong Yong Liang --- drivers/net/phy/phylink.c | 7 ++++--- include/linux/phylink.h | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index b38b39a6d1f0..b4345042d3fe 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1093,9 +1093,9 @@ static void phylink_pcs_an_restart(struct phylink *pl) * Note: this is for cases where the PCS itself is involved in negotiation * (e.g. Clause 37, SGMII and similar) not Clause 73. */ -static unsigned int phylink_pcs_neg_mode(unsigned int mode, - phy_interface_t interface, - const unsigned long *advertising) +unsigned int phylink_pcs_neg_mode(unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising) { unsigned int neg_mode; @@ -1139,6 +1139,7 @@ static unsigned int phylink_pcs_neg_mode(unsigned int mode, return neg_mode; } +EXPORT_SYMBOL_GPL(phylink_pcs_neg_mode); static void phylink_major_config(struct phylink *pl, bool restart, const struct phylink_link_state *state) diff --git a/include/linux/phylink.h b/include/linux/phylink.h index f0a6c00e8dab..74af8cfbdd92 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -594,6 +594,9 @@ int phylink_ethtool_set_eee(struct phylink *link, struct ethtool_keee *eee); int phylink_mii_ioctl(struct phylink *, struct ifreq *, int); int phylink_speed_down(struct phylink *pl, bool sync); int phylink_speed_up(struct phylink *pl); +unsigned int phylink_pcs_neg_mode(unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising); #define phylink_zero(bm) \ bitmap_zero(bm, __ETHTOOL_LINK_MODE_MASK_NBITS) From patchwork Thu Feb 15 03:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201234 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp161066dyb; Wed, 14 Feb 2024 20:17:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUH7hb6saCBryySFRvWY7oBs0TU/+/+iH4v1bH01GRVDTQWsDz5iKZg/QIquOHIHgje4S+g7ovgj+2HmBCMHebMKA/Uaw== X-Google-Smtp-Source: AGHT+IGadCr3dNkRnbITvG/KBZ8WklNLiIqH14KC9/nzwFADs5VgVyCwdDke2/lSSuTzMIC2whOa X-Received: by 2002:a17:90a:9f93:b0:296:a7ac:8b56 with SMTP id o19-20020a17090a9f9300b00296a7ac8b56mr635003pjp.28.1707970625702; Wed, 14 Feb 2024 20:17:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707970625; cv=pass; d=google.com; s=arc-20160816; b=eU4eAPje4ZzW/bmC3KS7lyrCvkbcSdFHzF4aIIfwhoYsjZK4V+bx739YcUMESlpa/U DUTE75jVA9VoaSPv3BAAMwUqKPaSJTTXeqC2igvyLANaQeMXEcLhOD2OxfrBn5P4rcRj pDSix3dz/+pRa2C3icH/9s3XvKO9ha+rUOeYJpCJjhNsy9qELedTdRMH/FuIWgHjDfAL q7d5EUSNKLp2EQAmNe1SqmNb0BxsCOjpXbM66WVVUsXlffkOQ3YjCl/Z37sirlca1LAA nRPyh0hT9LpA7t0ld0CJljhO7r3OlqRNpytjqjLb5inKSNMprPpyLZKZ9yZ/phO9d8K8 wuWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LWzK1mPSa0bhhFNwrXlPNqf0jxdc6pE7kZAIhUx5Bjs=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=WUHc6uDCbfmhOuKj/Jr5Ayovo34j9lu8Wdn+RSeKYnXGVyZC8wIIfvPzAjqISXfF5B DenDOOxdBaJ+I/ZTJXkRW5jvCt/JO34zo1suGuqJfsY43WhoNghPJfvKzw4UFoqDstR2 ZxwqjRQgQfQVxw+MGA6mN2+jyaCEZsLepCUBsk845AXjKUvjHkpy+af3PyNe3H2heFNg JAWUofNQK0wBXvXC94bjOmNl+0c5CEQ/2F8h9t/9Fyh7L8THAWCeo2T9s3Uz+ZKn9vGV yK7Zj/WdyrKmlpo+XI3DBsFJVzWl9V1fgkl6jl0EBidx+5K1BhH+HiC3uNoLFU8983gV Qruw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kD+Qn0ZP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66254-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66254-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id li1-20020a17090b48c100b00297f281691asi509038pjb.98.2024.02.14.20.17.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 20:17:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66254-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kD+Qn0ZP; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66254-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66254-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CE2C129149A for ; Thu, 15 Feb 2024 03:09:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3797111A0; Thu, 15 Feb 2024 03:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kD+Qn0ZP" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C1D9DDD1; Thu, 15 Feb 2024 03:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966475; cv=none; b=CHJySDgchONrqwGRFQatn9/aVrzWe0xkyDwRWmUCjhfCSYMVFd1ctVyND3s4dD1Bce9CBeVwBsqoGKLYsBs3MsOk2PawajUaWP4eT2BdH4Wp0s9wfcMxO3V6wvFeflgKD7a+pXRbi4F2l6XwvrjeRjcsIBmMykEbcYwOtAPrCJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966475; c=relaxed/simple; bh=v3YcIHzlZFo38gIzLCM5tNLAmbkmNuWw2PgAfJFV8dc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BZu70Pl7MSPbsMAiSQXuOw0TMjWsjvypE5XCpDTPDyKNrOeEE+fFcnpx3OLDpzClh364CAKEIyrmH23pwZzMDHRlFFUdFoYivXc1Trb3/BT6sfuYwuS+8DbCvmNMhNQaPzATSKDZRJw0ucBPmqgT37SHXnIGvu8BPVRU65pCTN4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kD+Qn0ZP; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966475; x=1739502475; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v3YcIHzlZFo38gIzLCM5tNLAmbkmNuWw2PgAfJFV8dc=; b=kD+Qn0ZPy188G8KIREi7TNKTp9fMm/mZ8bjO4FdyFbEjsMK2Lv6sDbxt IokgGEOjqEUjG0WkAUVKuhbTWgNSpXpCx4e6W8cZgvWKNXeh30EHkBSA3 ncld2BkCl4A1MH9mq/czA7JMD/Toatd+/F8zCYbgsjbxfzARdwt/KLXsz Y+4a3J3B1UtzuFoVjrRiJls+cN/7H8Z1Xx4igk5VU/1ZKWgs2VNNDR8ei Hqe/OoWJtwNeGR4LPP00uzYtwV0l+fkVe06llFsgc0GCHyfIfv2dQQcS7 tzLS7r42TtfEyA45AVtaCpX0ZwREmIXuThtvbCFAquzQOdPygmnuKp8UK A==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461278" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461278" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:07:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385692" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:07:46 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 3/9] net: stmmac: select PCS negotiation mode according to the interface mode Date: Thu, 15 Feb 2024 11:04:53 +0800 Message-Id: <20240215030500.3067426-4-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790937006990437247 X-GMAIL-MSGID: 1790937006990437247 The 'stmmac_get_pcs_neg_mode' is invoked during link initialization or interface mode changes. In cases where 'priv->plat->get_pcs_neg_mode' is absent, the default 'phylink_pcs_neg_mode' function is utilized. Additionally, the 'intel_get_pcs_neg_mode' function is available to determine the PCS negotiation mode based on the provided interface mode. Signed-off-by: Choong Yong Liang --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 48 +++++++++++++++---- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 17 +++++++ include/linux/stmmac.h | 2 + 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 60283543ffc8..6f12e80b8a05 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -414,6 +414,39 @@ static void intel_mgbe_pse_crossts_adj(struct intel_priv_data *intel_priv, } } +static bool is_fixed_link(struct pci_dev *pdev) +{ + struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); + bool is_fixed_link = false; + + if (fwnode) { + struct fwnode_handle *fixed_node; + + fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link"); + if (fixed_node) + is_fixed_link = true; + + fwnode_handle_put(fixed_node); + } + + return is_fixed_link; +} + +static unsigned int intel_get_pcs_neg_mode(phy_interface_t interface, + struct pci_dev *pdev) +{ + unsigned int neg_mode; + + if ((interface == PHY_INTERFACE_MODE_SGMII || + interface == PHY_INTERFACE_MODE_1000BASEX) && + !is_fixed_link(pdev)) + neg_mode = PHYLINK_PCS_NEG_INBAND_ENABLED; + else + neg_mode = PHYLINK_PCS_NEG_OUTBAND; + + return neg_mode; +} + static void common_default_data(struct plat_stmmacenet_data *plat) { plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ @@ -590,15 +623,8 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, } /* For fixed-link setup, we clear xpcs_an_inband */ - if (fwnode) { - struct fwnode_handle *fixed_node; - - fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link"); - if (fixed_node) - plat->mdio_bus_data->xpcs_an_inband = false; - - fwnode_handle_put(fixed_node); - } + if (is_fixed_link(pdev)) + plat->mdio_bus_data->xpcs_an_inband = false; /* Ensure mdio bus scan skips intel serdes and pcs-xpcs */ plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; @@ -649,7 +675,7 @@ static int ehl_sgmii_data(struct pci_dev *pdev, plat->speed_mode_2500 = intel_speed_mode_2500; plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; - + plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; plat->clk_ptp_rate = 204800000; return ehl_common_data(pdev, plat); @@ -708,6 +734,7 @@ static int ehl_pse0_sgmii1g_data(struct pci_dev *pdev, plat->speed_mode_2500 = intel_speed_mode_2500; plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; + plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; return ehl_pse0_common_data(pdev, plat); } @@ -749,6 +776,7 @@ static int ehl_pse1_sgmii1g_data(struct pci_dev *pdev, plat->speed_mode_2500 = intel_speed_mode_2500; plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; + plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; return ehl_pse1_common_data(pdev, plat); } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ae2ffa9595d6..dbd16fc38888 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1104,11 +1104,28 @@ static void stmmac_mac_link_up(struct phylink_config *config, stmmac_hwtstamp_correct_latency(priv, priv); } +static unsigned int stmmac_get_pcs_neg_mode(struct phylink_config *config, + unsigned int mode, + phy_interface_t interface, + const unsigned long *advertising) +{ + struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); + unsigned int neg_mode; + + if (priv->plat->get_pcs_neg_mode) + neg_mode = priv->plat->get_pcs_neg_mode(interface, priv->plat->pdev); + else + neg_mode = phylink_pcs_neg_mode(mode, interface, advertising); + + return neg_mode; +} + static const struct phylink_mac_ops stmmac_phylink_mac_ops = { .mac_select_pcs = stmmac_mac_select_pcs, .mac_config = stmmac_mac_config, .mac_link_down = stmmac_mac_link_down, .mac_link_up = stmmac_mac_link_up, + .mac_get_pcs_neg_mode = stmmac_get_pcs_neg_mode, }; /** diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index dfa1828cd756..ffd66722eeda 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -277,6 +277,8 @@ struct plat_stmmacenet_data { int (*serdes_powerup)(struct net_device *ndev, void *priv); void (*serdes_powerdown)(struct net_device *ndev, void *priv); void (*speed_mode_2500)(struct net_device *ndev, void *priv); + unsigned int (*get_pcs_neg_mode)(phy_interface_t interface, + struct pci_dev *pdev); void (*ptp_clk_freq_config)(struct stmmac_priv *priv); int (*init)(struct platform_device *pdev, void *priv); void (*exit)(struct platform_device *pdev, void *priv); From patchwork Thu Feb 15 03:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201255 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp234532dyb; Wed, 14 Feb 2024 23:56:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVakX/pNwYyUuIErGXYftftexf/LeTf617EHLXugPmXzDE0FaPIUOxZsz1rZLLv+lJa1vHFZ7EiBiM3x1V9dm/pk7WioQ== X-Google-Smtp-Source: AGHT+IF/2lCU6gQvZz42vhkVGC0X5+WlvwW1FmHov3igR9pZ5XDlslEZOS7K7R0TrzBcD/LnFf2E X-Received: by 2002:a05:6102:3588:b0:46c:b0d6:6037 with SMTP id h8-20020a056102358800b0046cb0d66037mr1520185vsu.7.1707983775668; Wed, 14 Feb 2024 23:56:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707983775; cv=pass; d=google.com; s=arc-20160816; b=HthgWPMHvknn/TEBbSH6SmFkBO/2uN/UOKliKcYp2ETtVYJLdSW0kIdhlKWRUq9dwm d2HG2WkXE/zxG8iB2NAda62gYrylg5cDo8IqTNSs0ltztIZ8MXkQnPWSQOLQ8vAcF1tz 2q4jr3yKcoZZ8nIh40Cax439ltxnPbHLOcdSCaZ1lVwOLJgSp70xtx6i9RMb7me0Or4p 5agn4e/xOQBfIfeEkGxDLlB2h250JbuwtHYEfY/0sT9QLKvpPWKe88qCUfw9W9wZaSUT 6S1O0lbzL6e/u0JeaiqbdtyzbqV3DEGDGd4d7sByj/vdKvDZGDvRWptsV17hzRv4RxnG BbyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=rYzxDIVTt4KsEJZQwSjnMZPhzk3vtEW92o6eFqXyAy0=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=yxbpwa9OxTbi9szhpe6b8rURaCrpREeCKsPGKyTo6QijqBsPcQbOTTEMYotsCNIBUd a10SHtXGO0T/s+6xTGUjbWUq3G0unLIOBDVUjKJAkTVavbFu0aYr5xRJAgFaMbfv8FEt uGz2+N+4/JlGEhdncIrjRrXwc5Zdpts/tjXbhTiAFNe6VpEXHCPQnUbHSCUx6ljyTOvo mjHibIr1zBh+xdKlT84LX8TP/buRxYOzs8IcpMe4O9fl5Va9mYxk8LkACtAJUrooliQG /IBRGMZ7Qwc9P5zIROtioRN2Jfb+c9CtDE7jdSK1rx1PEZS+mhYkfoJaPn40sKdzbBau M0WA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iDsRkvRQ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66255-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66255-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m13-20020ac8688d000000b0042c7f344adcsi800131qtq.464.2024.02.14.23.56.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 23:56:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66255-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iDsRkvRQ; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66255-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66255-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7B2D81C29C91 for ; Thu, 15 Feb 2024 03:09:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA9CF134C8; Thu, 15 Feb 2024 03:08:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iDsRkvRQ" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A4EA12B7C; Thu, 15 Feb 2024 03:08:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966484; cv=none; b=cA2m/k5lWD/ZDiIVbxCvSWG0TTt8NnDn6a/CK1YHmfSs6be1RJ8zMmqLFGgWwu8jN8mndUANyoCnb0NcnKkfKRV+vJpjstEc7Yz3WCwt+EIr8C4/twOJRqm+Yp3J3MJPpK2nJCgdZ2r6MGlWh/7rqgbbsDuQPAvnzqKsAvCjivw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966484; c=relaxed/simple; bh=N38loWFo7GWrJwwLm4tKbNOCG6/JHGqNKZcHVjVV0zo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DES4+nRyxsLDhAjSqpjc7v0WK/j6/inkJT74npSl6yBq2TJ9YJhsvxy1UpWtwbWTbP3SHbPJ7SCi3NMkP2dQACANaX9ewBdoJdETFtl4LPZFBkOsNQy2vCgB7U9g9zzQ3C20mdvCaMPeT5cpT81DmMiMAIOEGg1EdKc8NBwE1Co= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iDsRkvRQ; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966483; x=1739502483; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N38loWFo7GWrJwwLm4tKbNOCG6/JHGqNKZcHVjVV0zo=; b=iDsRkvRQMDRa+uQ6VV67mkQvEDkDeEbnAasWg8LIEFnDvPvhOsmNl7XA b377T/RuiCJ9vJlPTN33zoHKaaAnOpz5hGhRwn1DfoVxVIBfFfLl/Kbwx nCkn5sZgYIkbYYQMzZ2vPxFClkul/KcqKgFJRf9bTzYFcH2vqx41/HsJP 6dSXI4YQd6Z5YR0b8hPaDLk0vNgip0DflIaCsqRWmEhfloBUgLiOiB6J0 optO2e/GOD3uioY3j4oE7t+KVaJ/qcjD8XXeZiRf8KRe3aBhQ/YyEufAR 94I6Soow2ECfXsNqkYghonej4M/QqOYCmRGBO6YSjoxxfWAwLzM+VUEfW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461309" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461309" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:08:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385742" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:07:54 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 4/9] net: pcs: xpcs: re-initiate clause 37 Auto-negotiation Date: Thu, 15 Feb 2024 11:04:54 +0800 Message-Id: <20240215030500.3067426-5-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790950795294828155 X-GMAIL-MSGID: 1790950795294828155 According to the XPCS datasheet, a soft reset is required to initiate Clause 37 auto-negotiation when the XPCS switches interface modes. When the interface mode is set to 2500BASE-X, Clause 37 Auto-Negotiation is turned off. Subsequently, when the interface mode switches from 2500BASE-X to SGMII, re-initiating Clause 37 auto-negotiation is required for the SGMII interface mode to function properly. Signed-off-by: Choong Yong Liang --- drivers/net/pcs/pcs-xpcs.c | 62 +++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 52a7757ee419..cf1ed89d6418 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -848,6 +848,60 @@ static int xpcs_config_2500basex(struct dw_xpcs *xpcs) return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, ret); } +static int xpcs_switch_to_aneg_c37_sgmii(const struct xpcs_compat *compat, + struct dw_xpcs *xpcs, + unsigned int neg_mode) +{ + bool an_c37_enabled; + int ret, mdio_ctrl; + + if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED) { + mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL); + if (mdio_ctrl < 0) + return mdio_ctrl; + + an_c37_enabled = mdio_ctrl & AN_CL37_EN; + if (!an_c37_enabled) { + //Perform soft reset to initiate C37 auto-negotiation + ret = xpcs_soft_reset(xpcs, compat); + if (ret) + return ret; + } + } + return 0; +} + +static int xpcs_switch_interface_mode(const struct xpcs_compat *compat, + struct dw_xpcs *xpcs, + phy_interface_t interface, + unsigned int neg_mode) +{ + int ret; + + if (xpcs->dev_flag == DW_DEV_TXGBE) { + ret = txgbe_xpcs_switch_mode(xpcs, interface); + if (ret) + return ret; + } else { + if (xpcs->interface != interface) { + xpcs->interface = interface; + + switch (compat->an_mode) { + case DW_AN_C37_SGMII: + ret = xpcs_switch_to_aneg_c37_sgmii(compat, + xpcs, + neg_mode); + if (ret) + return ret; + break; + default: + return 0; + } + } + } + return 0; +} + int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, const unsigned long *advertising, unsigned int neg_mode) { @@ -858,11 +912,9 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, if (!compat) return -ENODEV; - if (xpcs->dev_flag == DW_DEV_TXGBE) { - ret = txgbe_xpcs_switch_mode(xpcs, interface); - if (ret) - return ret; - } + ret = xpcs_switch_interface_mode(compat, xpcs, interface, neg_mode); + if (ret) + return ret; switch (compat->an_mode) { case DW_10GBASER: From patchwork Thu Feb 15 03:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp158671dyb; Wed, 14 Feb 2024 20:10:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXCdEv655dyhMY63o0OlGtQxs0/eJtgqYzeeYXd1XMIIBKiO9U3nWGilZMRVTbcRy/3pczR0HzHYKu7+rBfV7CGA5MpLQ== X-Google-Smtp-Source: AGHT+IF1D9bO5d12pRI3Af+rcFrLGXcARbg94kjZsO7vNJiekaE57Bv0K5kBUQZcgOXgrMX+kE19 X-Received: by 2002:aa7:8705:0:b0:6e1:1f94:3c15 with SMTP id b5-20020aa78705000000b006e11f943c15mr878021pfo.22.1707970201456; Wed, 14 Feb 2024 20:10:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707970201; cv=pass; d=google.com; s=arc-20160816; b=J0JeWI7QxHGCGxOkgha6feaoJ+Q5magCmD03fZJ4AxxU+QR3qelEzLQjMcLj9MwxkD jeHszd1hc5LbYj32DtI9u65NkSAFeoirc0mz9P9AHvLPHtcrbfTJm1YXuaI8r07Nx1z2 Z3ZcOFjlx535ajGWmMma5Qok5zZlS+0AZLqCq5PkSKdupyMOB4s4mbkJB4U55Lt8NfQZ o9Vf7zBOlUDFe6Nd6oq49Z52bwk2lBXq3WI0WXBPxPEmvdGS+eGvhXYoqXMFOsylcsBz nkDbHU4D0kQd8j57V47Bc9SsCyYy3FbnV0s147Sl6Ulibvc/NW7PV5KwEgjZ2L4CI6FX nmvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UyOLJWVYVMu7oOwt8Ab32SRDyX7ptLOsTex5cQ0XDpU=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=YpA46+WX+caJUYaq73zCzCgEplbY+EJsz80EavoGEDV0BKLv0wJcDc1OoEAsm7ooxB lBz/3IfjTOplSqv+wN9siljh6pQWV574c612xNV3k1rfZ05CgX/48I3QYzldaC9prS0d bJ2lfreJ4zVX2aKji3Co7yNp7gfUjxOw6nkYrRpMGIdw8dYDXL6TywckPtb1zoXVZLFS yTBTyaBdtl0DgUpZv2snvLcSwQ/Thh/3DnD3IM/RKlTSjZP3qE1/VSpz4ZaO8ApNXjCw zv3gXUJbFFzhmT/ZpcNs5lEZD8BZJYPxITOkl+e21/XEE2iIgl0hfY/lwIocRKKYQu3x iKQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wwh153S9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66256-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66256-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ln14-20020a056a003cce00b006e09331f02dsi432819pfb.300.2024.02.14.20.10.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 20:10:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66256-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Wwh153S9; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66256-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66256-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8E947B269E6 for ; Thu, 15 Feb 2024 03:09:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67CA213FE4; Thu, 15 Feb 2024 03:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Wwh153S9" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E2388F68; Thu, 15 Feb 2024 03:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966493; cv=none; b=HATGunwvAixTwUSVl3t5rWoT+fJey1Wpd7IFYzKzjdyYGx92BoaQ5oZBEhwl0W13qJ6TQU7VYVcR/S84CB5oxTEcqPYE76cp3fcaBQHJhrbvYDpG35ETKYsSRqS+6uxbm/dXRAkg/rbgnTB+eH43vEsX7/J8zkePSQX4B2LktCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966493; c=relaxed/simple; bh=74BgQfGIQ9eFHmrbRL0VFPUvmEq6wbG/DaTUmCN+X3E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OmbtclEyFzwuKydpR8wicn9k/GvLkOoj+q7Hply0mvBYOAgduIQZz6DIvb9CjeWoTCHLzrD2MeBUivBIvX90OIMiomXX6i6AVAwTGYru0KGmLYvp3HGbWu/uHUGg4DtGUm7cWfi++mO8iha8CjbMn4xSj66+rTHGJ7+DS70Kayg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Wwh153S9; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966492; x=1739502492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=74BgQfGIQ9eFHmrbRL0VFPUvmEq6wbG/DaTUmCN+X3E=; b=Wwh153S9H6/clyvNgP6HBvC/66+RlcuXmw73vz2iG0c2iAobLweSj3lz FrEhjVcy12ArjU+9rukjZJQ9aUHrUS2DN17teivyMW58TB4XEV/rfm+wO Hoe8gpTwGkVjNcTFvYEzjWral4H/0qA9khzRh5vyw9auoDD9uAgyXkr3G 6tSPo9AYI/uLZ8MvK2sN3sBpUjQ9sCOF+Osq1n0F70XiOwnHHkyzRIzMd 5mJdrH2zJF1qOxqsDUWMe1oJhBCEacoYQr0czhGRjvt6mLNFDvZZiQWti Y2YhSeNjYQxhAll2w0BxuetzNF5JQ6Fl4OZ5IIa4rQdsEtFxAmb3syxii Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461332" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461332" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:08:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385795" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:08:02 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 5/9] arch: x86: Add IPC mailbox accessor function and add SoC register access Date: Thu, 15 Feb 2024 11:04:55 +0800 Message-Id: <20240215030500.3067426-6-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790936561815995760 X-GMAIL-MSGID: 1790936561815995760 From: "David E. Box" - Exports intel_pmc_ipc() for host access to the PMC IPC mailbox - Add support to use IPC command allows host to access SoC registers through PMC firmware that are otherwise inaccessible to the host due to security policies. Signed-off-by: David E. Box Signed-off-by: Chao Qin Signed-off-by: Choong Yong Liang --- MAINTAINERS | 2 + arch/x86/Kconfig | 9 +++ arch/x86/platform/intel/Makefile | 1 + arch/x86/platform/intel/pmc_ipc.c | 75 +++++++++++++++++++ .../linux/platform_data/x86/intel_pmc_ipc.h | 34 +++++++++ 5 files changed, 121 insertions(+) create mode 100644 arch/x86/platform/intel/pmc_ipc.c create mode 100644 include/linux/platform_data/x86/intel_pmc_ipc.h diff --git a/MAINTAINERS b/MAINTAINERS index 2b775f4369e0..0276f1d53caf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10996,8 +10996,10 @@ M: Rajneesh Bhardwaj M: David E Box L: platform-driver-x86@vger.kernel.org S: Maintained +F: arch/x86/platform/intel/pmc_ipc.c F: Documentation/ABI/testing/sysfs-platform-intel-pmc F: drivers/platform/x86/intel/pmc/ +F: linux/platform_data/x86/intel_pmc_ipc.h INTEL PMIC GPIO DRIVERS M: Andy Shevchenko diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 5edec175b9bf..bceae28b9381 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -666,6 +666,15 @@ config X86_AMD_PLATFORM_DEVICE I2C and UART depend on COMMON_CLK to set clock. GPIO driver is implemented under PINCTRL subsystem. +config INTEL_PMC_IPC + tristate "Intel Core SoC Power Management Controller IPC mailbox" + depends on ACPI + help + This option enables sideband register access support for Intel SoC + power management controller IPC mailbox. + + If you don't require the option or are in doubt, say N. + config IOSF_MBI tristate "Intel SoC IOSF Sideband support for SoC platforms" depends on PCI diff --git a/arch/x86/platform/intel/Makefile b/arch/x86/platform/intel/Makefile index dbee3b00f9d0..470fc68de6ba 100644 --- a/arch/x86/platform/intel/Makefile +++ b/arch/x86/platform/intel/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_IOSF_MBI) += iosf_mbi.o +obj-$(CONFIG_INTEL_PMC_IPC) += pmc_ipc.o \ No newline at end of file diff --git a/arch/x86/platform/intel/pmc_ipc.c b/arch/x86/platform/intel/pmc_ipc.c new file mode 100644 index 000000000000..a96234982710 --- /dev/null +++ b/arch/x86/platform/intel/pmc_ipc.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Intel Core SoC Power Management Controller IPC mailbox + * + * Copyright (c) 2023, Intel Corporation. + * All Rights Reserved. + * + * Authors: Choong Yong Liang + * David E. Box + */ +#include +#include +#include + +#define PMC_IPCS_PARAM_COUNT 7 + +int intel_pmc_ipc(struct pmc_ipc_cmd *ipc_cmd, u32 *rbuf) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object params[PMC_IPCS_PARAM_COUNT] = { + {.type = ACPI_TYPE_INTEGER,}, + {.type = ACPI_TYPE_INTEGER,}, + {.type = ACPI_TYPE_INTEGER,}, + {.type = ACPI_TYPE_INTEGER,}, + {.type = ACPI_TYPE_INTEGER,}, + {.type = ACPI_TYPE_INTEGER,}, + {.type = ACPI_TYPE_INTEGER,}, + }; + struct acpi_object_list arg_list = { PMC_IPCS_PARAM_COUNT, params }; + union acpi_object *obj; + int status; + + if (!ipc_cmd || !rbuf) + return -EINVAL; + + /* + * 0: IPC Command + * 1: IPC Sub Command + * 2: Size + * 3-6: Write Buffer for offset + */ + params[0].integer.value = ipc_cmd->cmd; + params[1].integer.value = ipc_cmd->sub_cmd; + params[2].integer.value = ipc_cmd->size; + params[3].integer.value = ipc_cmd->wbuf[0]; + params[4].integer.value = ipc_cmd->wbuf[1]; + params[5].integer.value = ipc_cmd->wbuf[2]; + params[6].integer.value = ipc_cmd->wbuf[3]; + + status = acpi_evaluate_object(NULL, "\\IPCS", &arg_list, &buffer); + if (ACPI_FAILURE(status)) + return -ENODEV; + + obj = buffer.pointer; + /* Check if the number of elements in package is 5 */ + if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 5) { + const union acpi_object *objs = obj->package.elements; + + if ((u8)objs[0].integer.value != 0) + return -EINVAL; + + rbuf[0] = objs[1].integer.value; + rbuf[1] = objs[2].integer.value; + rbuf[2] = objs[3].integer.value; + rbuf[3] = objs[4].integer.value; + } else { + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL(intel_pmc_ipc); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Intel PMC IPC Mailbox accessor"); diff --git a/include/linux/platform_data/x86/intel_pmc_ipc.h b/include/linux/platform_data/x86/intel_pmc_ipc.h new file mode 100644 index 000000000000..d47b89f873fc --- /dev/null +++ b/include/linux/platform_data/x86/intel_pmc_ipc.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Intel Core SoC Power Management Controller Header File + * + * Copyright (c) 2023, Intel Corporation. + * All Rights Reserved. + * + * Authors: Choong Yong Liang + * David E. Box + */ +#ifndef INTEL_PMC_IPC_H +#define INTEL_PMC_IPC_H + +#define IPC_SOC_REGISTER_ACCESS 0xAA +#define IPC_SOC_SUB_CMD_READ 0x00 +#define IPC_SOC_SUB_CMD_WRITE 0x01 + +struct pmc_ipc_cmd { + u32 cmd; + u32 sub_cmd; + u32 size; + u32 wbuf[4]; +}; + +/** + * intel_pmc_ipc() - PMC IPC Mailbox accessor + * @ipc_cmd: struct pmc_ipc_cmd prepared with input to send + * @rbuf: Allocated u32[4] array for returned IPC data + * + * Return: 0 on success. Non-zero on mailbox error + */ +int intel_pmc_ipc(struct pmc_ipc_cmd *ipc_cmd, u32 *rbuf); + +#endif /* INTEL_PMC_IPC_H */ From patchwork Thu Feb 15 03:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp218285dyb; Wed, 14 Feb 2024 23:13:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXAf0yvfy7pLl5/ZimfQJw1UUiEIIQeFc/uo8/IE9tqy4yWm/NRBeU5qd2eHQItHZntB/r56NLJXZKeyADbJrwO/BS3nw== X-Google-Smtp-Source: AGHT+IHL6rdsCnEmKbnSBrg3IBb7Tn+VN6xPjCscr2p8c7KeomBKBYI7FGjZYQw1wjSWJHNTAdVA X-Received: by 2002:a17:903:2349:b0:1d7:428f:50fd with SMTP id c9-20020a170903234900b001d7428f50fdmr1152380plh.31.1707981227067; Wed, 14 Feb 2024 23:13:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707981227; cv=pass; d=google.com; s=arc-20160816; b=KalyDcA3tY4CKYWc+PW4EwiEmLfAVuIGlDfh3jlR2BvV6Owx+f9ZCgXUNMFjh/jQ8A rwV32uSMf/qzc9/IeKxJAKsw0cayq9Nk0jOms1GUG0zV+CEbaK/HL/1dsM6Q6qGQ5X7g 6Cbx+tnyTeaisRPUxeqE2GLXhc9CRLNZXamhWOR9gcDN6u4vlFKkUFg/MJ/e+DPKnZAS w9T0N+r7QAU8R6sJN2PW4hi2JoGTeUEy1J96GLkWt7rKxSlFkOGIiO3va+pX7iAGJz8i U9Gzj/d4u6AVHA3N/INxcdtmwbVn0YNhmbiQC9hyYiDzuoSt7YxLbBLapDhvblDeCUDm ij2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TTakV/5bnIstZwzO7KNO+VigYOS+w86gAAnqWolw8fo=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=YKfM24u2zAGaz84byRdZLYW4x3v9oDRviU/VaHUU1VV+wXikRDC3RX3EQHQz3V8LJZ LCJqidKdLffFPwAh+PG3ginXgPRMPocOOUbYV3jdSdQIV5Dd9JIvb49WiNO2fr92Z2wy k9IO2sppopvJgUeQClInrfadBHHCD0YCTiwaP8AUZoYQxKps/nC1rmhoa8cQxn/r2glw FkQAakEXXw4h7WBZzQ9xFxTt2y8oHRru3Efc0nbCnWmLUvPyUvtHhgAdMbp5RhqR8NeE D+8DXYeMHxl0lCFnGs7HCQtTVrp6V/fVWm3oehznY3VqkTR51FNq+jW4KmzSKhwCnZpY xOcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gZ7I4WHg; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66257-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66257-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m16-20020a170902db1000b001d9b8bc0fd8si676769plx.68.2024.02.14.23.13.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 23:13:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66257-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gZ7I4WHg; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66257-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66257-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 76F3629039D for ; Thu, 15 Feb 2024 03:10:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68E6517735; Thu, 15 Feb 2024 03:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gZ7I4WHg" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63A11BA2E; Thu, 15 Feb 2024 03:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966500; cv=none; b=pPBGtcvh/k9PiYjfoYF3On/GAXsg5gajzLExh7m39f2UPaKZl6tCncqfRulkPT6QQaUTOHXFU1hiQaUVA49njUKqvISwWg7MGlgdAvfQG4HFtZNrh0E2AZ7dqhpT8BbVE3TKwlEVxTUcDRInuGfHA3vLQECsFOkcQxCeGMi1QwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966500; c=relaxed/simple; bh=vvpIPgH1K2PujTnqInvxE+a2W/xss8TF8nrQRvP6KiQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YhfxIY2y2iepAuVg5LU3z9dinbQyIvibPGuuutDhrxGhwPpYlVZlftwS61VeS9nTgd7Z05UbzxUdAoaN/uhHHm8yEK+QZdREVARS0XdrDSlyvzzkScrcpI73oWG35bSeHsXtsHxtpmXBkE0ylvM3Ny554SOJiX7mmFDTVnRy/Xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gZ7I4WHg; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966500; x=1739502500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vvpIPgH1K2PujTnqInvxE+a2W/xss8TF8nrQRvP6KiQ=; b=gZ7I4WHgYWomjcwBvI1Pjb0NLZQYZEmzbWXGCQZKyEj2P4MKAkgb/Pfi BlEVr/JgsVAfuWbocwM9DaBkvP4urpvi/dBJqeKy4TN1P+ZTHThCYjULj fHyQxZgwRT2pgeNDu2x/cIFUujAgeBAMCCnktlCIWvccOzeKCK/48GGIF /VEmgEshCibmvuz7Aoy8/Dz6/t7WixABW3KFyKdvDfC/0SwWs6fpQcv7/ KcnVIHuytBZ7hLxztv4btdhYanLxvRdIEIVZZ7CdrjOFwklUqQK3++K3R i1Vh322HTQ7qM9Mc451O/q34JDzu9F9NPY6fZzgytyrgvslirvI3mKpcb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461373" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461373" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:08:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385820" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:08:11 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 6/9] net: stmmac: configure SerDes on mac_finish Date: Thu, 15 Feb 2024 11:04:56 +0800 Message-Id: <20240215030500.3067426-7-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790948123253533684 X-GMAIL-MSGID: 1790948123253533684 SerDes will configure according to the provided interface mode after finish a major reconfiguration of the interface mode. Signed-off-by: Choong Yong Liang --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +++++++++++++ include/linux/stmmac.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index dbd16fc38888..69a33e9f1a5c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1120,12 +1120,25 @@ static unsigned int stmmac_get_pcs_neg_mode(struct phylink_config *config, return neg_mode; } +static int stmmac_mac_finish(struct phylink_config *config, unsigned int mode, + phy_interface_t interface) +{ + struct net_device *ndev = to_net_dev(config->dev); + struct stmmac_priv *priv = netdev_priv(ndev); + + if (priv->plat->config_serdes) + priv->plat->config_serdes(ndev, priv->plat->bsp_priv, interface); + + return 0; +} + static const struct phylink_mac_ops stmmac_phylink_mac_ops = { .mac_select_pcs = stmmac_mac_select_pcs, .mac_config = stmmac_mac_config, .mac_link_down = stmmac_mac_link_down, .mac_link_up = stmmac_mac_link_up, .mac_get_pcs_neg_mode = stmmac_get_pcs_neg_mode, + .mac_finish = stmmac_mac_finish, }; /** diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index ffd66722eeda..fd3d7d25f871 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -279,6 +279,9 @@ struct plat_stmmacenet_data { void (*speed_mode_2500)(struct net_device *ndev, void *priv); unsigned int (*get_pcs_neg_mode)(phy_interface_t interface, struct pci_dev *pdev); + int (*config_serdes)(struct net_device *ndev, + void *priv, + phy_interface_t interface); void (*ptp_clk_freq_config)(struct stmmac_priv *priv); int (*init)(struct platform_device *pdev, void *priv); void (*exit)(struct platform_device *pdev, void *priv); From patchwork Thu Feb 15 03:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201317 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp281399dyb; Thu, 15 Feb 2024 01:46:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWPrPldvoXKVZoMXeqxKJ6PYPjXdwOVXBPwOE15ShzZdxrcG3/YPSOH1sp2YwbWNTFc+S+T/AgISh4Gp10F0DTxxI8rvg== X-Google-Smtp-Source: AGHT+IG90xO2W1pYMX6wnjn5GkdhJGWpORpOByr4Uf6ooEeMiSyl4T18LaixoJKJZ17n0SpFnw/Q X-Received: by 2002:a05:6402:14c5:b0:562:6c9:c4cc with SMTP id f5-20020a05640214c500b0056206c9c4ccmr814010edx.24.1707990389205; Thu, 15 Feb 2024 01:46:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707990389; cv=pass; d=google.com; s=arc-20160816; b=z8BtuWiAiJaYjxar+VMyfpBjH90orWap34ZGebaONpClw54D7FseaMV92rVyS6prXG 9NXB9tSYkkCdcpWiwvtTyZUY1HSfHXLzOTL1sK2C+JgVAJPh4qbMbnvcFvWEjNjGL634 ZgV4ZnNRHQBqs6tFOrC4nz5OOXg2ZxBW5pICggLEH99j1V+3kGfNfM+aBarq2AljZcyv fdPRAghpcu8pn5DJD58W7ElCJw/dSZe5ujGB+OhPH9PG8A0zJAXk5ZgEmZAKIpi5KkRq fxkovUkIF/FR5JsD1jxV1t0CJ2DRizJLV+0ywKSMQOwYuizQCcPZihAONX3Vq6E28WoQ 1zew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7Whyw/v1YzMRRmPfTkLCWWiceRY19l9E9unpzWR+ckQ=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=mP/rHBsnJkJqrwS/9ZDSVhEQPE83ZsVa0fF0us4sFTT3UBS5RqJQzfOjc9V5uqsq0y Uy3Pqf9GqBkee6SsogaO1UtA7PsaAQ55g8uk6dGk2CoxSMt9MY+Fwr0zAff/aJGocuak Z2/q1TQmf8Aet2LKMdr3pN/pJzXJCPFHi14naLr1jMoYn2yye/164bO13Jq9/IkhbUi/ cKe63wjYwnesSr+ID7NMjiCwJV16XV3YH/Fcj10dTwAUqPU5m68Lt2un1Ft4ZqKkA20J 9F+MRX7oRJVG50Lrxdx29m/Pp0lxcFfzxehUWUoi+W34PfWaZY72prmq0pBIpQSAa9X4 V5zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UYuhYYKR; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66258-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66258-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x23-20020aa7dad7000000b00562151fc6desi470574eds.250.2024.02.15.01.46.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 01:46:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66258-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UYuhYYKR; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66258-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66258-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0775E1F2A9E4 for ; Thu, 15 Feb 2024 03:11:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 63D5C1BC59; Thu, 15 Feb 2024 03:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UYuhYYKR" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44C68182DD; Thu, 15 Feb 2024 03:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966509; cv=none; b=DmucObqI0K7YyJK+FtGyeeVlWswSbwKUB1v3dQj1dy6rNS5gdy/tLz1p2nTzQl+telj0JsmFxU/QB846uTBd2bbYhmN8rON4oKYReKF+SLPJqMPoEN8mRYHKVI/Ru6nBfmM8dHsDXZo3uGhwHVXuYgMKkJ07Up1jWimb2Xru4dM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966509; c=relaxed/simple; bh=fumAyhQKjC1W9BaMP5HdTDN5H3s/uIB2V97WkllaS/4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dnxHJVPoqnB9Ek24SDdiO7pCLEUyFgNUffpoG1AyLvdS/A2hrTCi05krH0oWLtEXINdGmEZqOQzEbYO4VEKgZtn5a1StbHIkrfJ1ya8MXQn+vLoKMU9hyRk3Z26gOz+VHivQIajWCLJ/1h+BYPaBeOZFN3j/+g185kBr2kndzrs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UYuhYYKR; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966508; x=1739502508; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fumAyhQKjC1W9BaMP5HdTDN5H3s/uIB2V97WkllaS/4=; b=UYuhYYKR9StN7zO0KXoPz+e6/DM5O1VS9d/MDi9COPIiYdJ/i6701N02 JJ++DKk+IAyAKBKSr4HbLrmmFVsz4uuLWKf4o8+ZTeVO2AG9qd5mFr6o4 xMwwjx0CI1PTIdrJnSXVk6JBBLpwAT6AMBtopo6dzGYfedP1ofL7noThv KzFgV68Zq6gGg9k1xpf8RPCqCBgLSCgEEaaCV8ZS6nnsfRaIFPMlJqhB0 se8SrJmVx8d4hY0bPOWx01wvzXsCeRc+h4D/2IjgiXQdXhWUNrwGMwziJ vULdISOIPHb5R8bpLF6kLVgBIT8Yrj8E7w54JvbxSPvaXaOfpzdTxYx0G Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461394" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461394" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:08:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385830" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:08:19 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 7/9] stmmac: intel: configure SerDes according to the interface mode Date: Thu, 15 Feb 2024 11:04:57 +0800 Message-Id: <20240215030500.3067426-8-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790957730119844550 X-GMAIL-MSGID: 1790957730119844550 From: "Tan, Tee Min" Intel platform will configure the SerDes through PMC api based on the provided interface mode. This patch adds several new functions below:- - intel_tsn_interface_is_available(): This new function reads FIA lane ownership registers and common lane registers through IPC commands to know which lane the mGbE port is assigned to. - intel_config_serdes(): To configure the SerDes based on the assigned lane and latest interface mode, it sends IPC command to the PMC through PMC driver/API. The PMC acts as a proxy for R/W on behalf of the driver. - intel_set_reg_access(): Set the register access to the available TSN interface. Signed-off-by: Tan, Tee Min Signed-off-by: Choong Yong Liang --- drivers/net/ethernet/stmicro/stmmac/Kconfig | 2 + .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 115 +++++++++++++++++- .../net/ethernet/stmicro/stmmac/dwmac-intel.h | 75 ++++++++++++ 3 files changed, 191 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 4ec61f1ee71a..25405c305a21 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -273,6 +273,8 @@ config DWMAC_INTEL default X86 depends on X86 && STMMAC_ETH && PCI depends on COMMON_CLK + depends on ACPI + select INTEL_PMC_IPC help This selects the Intel platform specific bus support for the stmmac driver. This driver is used for Intel Quark/EHL/TGL. diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 6f12e80b8a05..74cc0aa96faf 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "dwmac-intel.h" #include "dwmac4.h" #include "stmmac.h" @@ -14,6 +15,9 @@ struct intel_priv_data { int mdio_adhoc_addr; /* mdio address for serdes & etc */ unsigned long crossts_adj; bool is_pse; + const int *tsn_lane_registers; + int max_tsn_lane_registers; + int pid_modphy; }; /* This struct is used to associate PCI Function of MAC controller on a board, @@ -93,7 +97,7 @@ static int intel_serdes_powerup(struct net_device *ndev, void *priv_data) data &= ~SERDES_RATE_MASK; data &= ~SERDES_PCLK_MASK; - if (priv->plat->max_speed == 2500) + if (priv->plat->phy_interface == PHY_INTERFACE_MODE_2500BASEX) data |= SERDES_RATE_PCIE_GEN2 << SERDES_RATE_PCIE_SHIFT | SERDES_PCLK_37p5MHZ << SERDES_PCLK_SHIFT; else @@ -447,6 +451,103 @@ static unsigned int intel_get_pcs_neg_mode(phy_interface_t interface, return neg_mode; } +static bool intel_tsn_interface_is_available(struct net_device *ndev, + struct intel_priv_data *intel_priv) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + struct pmc_ipc_cmd tmp = {0}; + u32 rbuf[4] = {0}; + int ret, i, j; + + if (priv->plat->serdes_powerup) { + tmp.cmd = IPC_SOC_REGISTER_ACCESS; + tmp.sub_cmd = IPC_SOC_SUB_CMD_READ; + + for (i = 0; i < 5; i++) { + tmp.wbuf[0] = R_PCH_FIA_15_PCR_LOS1_REG_BASE + i; + + ret = intel_pmc_ipc(&tmp, rbuf); + if (ret < 0) { + netdev_info(priv->dev, + "Failed to read from PMC.\n"); + return false; + } + + for (j = 0; j <= intel_priv->max_tsn_lane_registers; j++) + if ((rbuf[0] >> + (4 * (intel_priv->tsn_lane_registers[j] % 8)) & + B_PCH_FIA_PCR_L0O) == 0xB) + return true; + } + } + return false; +} + +static int intel_set_reg_access(const struct pmc_serdes_regs *regs, int max_regs) +{ + int ret = 0, i; + + for (i = 0; i < max_regs; i++) { + struct pmc_ipc_cmd tmp = {0}; + u32 buf[4] = {0}; + + tmp.cmd = IPC_SOC_REGISTER_ACCESS; + tmp.sub_cmd = IPC_SOC_SUB_CMD_WRITE; + tmp.wbuf[0] = (u32)regs[i].index; + tmp.wbuf[1] = regs[i].val; + + ret = intel_pmc_ipc(&tmp, buf); + if (ret < 0) + return ret; + } + + return ret; +} + +static int intel_config_serdes(struct net_device *ndev, + void *intel_data, + phy_interface_t interface) +{ + struct intel_priv_data *intel_priv = intel_data; + struct stmmac_priv *priv = netdev_priv(ndev); + int ret = 0; + + if (!intel_tsn_interface_is_available(ndev, intel_priv)) { + netdev_info(priv->dev, + "No TSN interface available to set the registers.\n"); + goto pmc_read_error; + } + + if (intel_priv->pid_modphy == PID_MODPHY1) { + if (interface == PHY_INTERFACE_MODE_2500BASEX) { + ret = intel_set_reg_access(pid_modphy1_2p5g_regs, + ARRAY_SIZE(pid_modphy1_2p5g_regs)); + } else { + ret = intel_set_reg_access(pid_modphy1_1g_regs, + ARRAY_SIZE(pid_modphy1_1g_regs)); + } + } else { + if (interface == PHY_INTERFACE_MODE_2500BASEX) { + ret = intel_set_reg_access(pid_modphy3_2p5g_regs, + ARRAY_SIZE(pid_modphy3_2p5g_regs)); + } else { + ret = intel_set_reg_access(pid_modphy3_1g_regs, + ARRAY_SIZE(pid_modphy3_1g_regs)); + } + } + + priv->plat->phy_interface = interface; + + if (ret < 0) + goto pmc_read_error; + +pmc_read_error: + intel_serdes_powerdown(ndev, intel_priv); + intel_serdes_powerup(ndev, intel_priv); + + return ret; +} + static void common_default_data(struct plat_stmmacenet_data *plat) { plat->clk_csr = 2; /* clk_csr_i = 20-35MHz & MDC = clk_csr_i/16 */ @@ -622,6 +723,15 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->mdio_bus_data->xpcs_an_inband = true; } + /* When the platform is able to switch between PHY_INTERFACE_MODE_SGMII + * and PHY_INTERFACE_MODE_2500BASEX interfaces, we clear xpcs_an_inband + * for PHY_INTERFACE_MODE_2500BASEX interface + */ + if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII && + plat->max_speed == 2500) { + plat->mdio_bus_data->xpcs_an_inband = false; + } + /* For fixed-link setup, we clear xpcs_an_inband */ if (is_fixed_link(pdev)) plat->mdio_bus_data->xpcs_an_inband = false; @@ -676,6 +786,7 @@ static int ehl_sgmii_data(struct pci_dev *pdev, plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; + plat->config_serdes = intel_config_serdes; plat->clk_ptp_rate = 204800000; return ehl_common_data(pdev, plat); @@ -735,6 +846,7 @@ static int ehl_pse0_sgmii1g_data(struct pci_dev *pdev, plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; + plat->config_serdes = intel_config_serdes; return ehl_pse0_common_data(pdev, plat); } @@ -777,6 +889,7 @@ static int ehl_pse1_sgmii1g_data(struct pci_dev *pdev, plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; + plat->config_serdes = intel_config_serdes; return ehl_pse1_common_data(pdev, plat); } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h index 0a37987478c1..79c35ba969ea 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h @@ -50,4 +50,79 @@ #define PCH_PTP_CLK_FREQ_19_2MHZ (GMAC_GPO0) #define PCH_PTP_CLK_FREQ_200MHZ (0) +#define PID_MODPHY1 0xAA +#define PID_MODPHY3 0xA8 + +#if IS_ENABLED(CONFIG_INTEL_PMC_IPC) +struct pmc_serdes_regs { + u8 index; + u32 val; +}; + +/* Modphy Register index */ +#define R_PCH_FIA_15_PCR_LOS1_REG_BASE 8 +#define R_PCH_FIA_15_PCR_LOS2_REG_BASE 9 +#define R_PCH_FIA_15_PCR_LOS3_REG_BASE 10 +#define R_PCH_FIA_15_PCR_LOS4_REG_BASE 11 +#define R_PCH_FIA_15_PCR_LOS5_REG_BASE 12 +#define B_PCH_FIA_PCR_L0O GENMASK(3, 0) +#define PID_MODPHY1_B_MODPHY_PCR_LCPLL_DWORD0 13 +#define PID_MODPHY1_N_MODPHY_PCR_LCPLL_DWORD2 14 +#define PID_MODPHY1_N_MODPHY_PCR_LCPLL_DWORD7 15 +#define PID_MODPHY1_N_MODPHY_PCR_LPPLL_DWORD10 16 +#define PID_MODPHY1_N_MODPHY_PCR_CMN_ANA_DWORD30 17 +#define PID_MODPHY3_B_MODPHY_PCR_LCPLL_DWORD0 18 +#define PID_MODPHY3_N_MODPHY_PCR_LCPLL_DWORD2 19 +#define PID_MODPHY3_N_MODPHY_PCR_LCPLL_DWORD7 20 +#define PID_MODPHY3_N_MODPHY_PCR_LPPLL_DWORD10 21 +#define PID_MODPHY3_N_MODPHY_PCR_CMN_ANA_DWORD30 22 + +#define B_MODPHY_PCR_LCPLL_DWORD0_1G 0x46AAAA41 +#define N_MODPHY_PCR_LCPLL_DWORD2_1G 0x00000139 +#define N_MODPHY_PCR_LCPLL_DWORD7_1G 0x002A0003 +#define N_MODPHY_PCR_LPPLL_DWORD10_1G 0x00170008 +#define N_MODPHY_PCR_CMN_ANA_DWORD30_1G 0x0000D4AC +#define B_MODPHY_PCR_LCPLL_DWORD0_2P5G 0x58555551 +#define N_MODPHY_PCR_LCPLL_DWORD2_2P5G 0x0000012D +#define N_MODPHY_PCR_LCPLL_DWORD7_2P5G 0x001F0003 +#define N_MODPHY_PCR_LPPLL_DWORD10_2P5G 0x00170008 +#define N_MODPHY_PCR_CMN_ANA_DWORD30_2P5G 0x8200ACAC + +static const struct pmc_serdes_regs pid_modphy3_1g_regs[] = { + { PID_MODPHY3_B_MODPHY_PCR_LCPLL_DWORD0, B_MODPHY_PCR_LCPLL_DWORD0_1G }, + { PID_MODPHY3_N_MODPHY_PCR_LCPLL_DWORD2, N_MODPHY_PCR_LCPLL_DWORD2_1G }, + { PID_MODPHY3_N_MODPHY_PCR_LCPLL_DWORD7, N_MODPHY_PCR_LCPLL_DWORD7_1G }, + { PID_MODPHY3_N_MODPHY_PCR_LPPLL_DWORD10, N_MODPHY_PCR_LPPLL_DWORD10_1G }, + { PID_MODPHY3_N_MODPHY_PCR_CMN_ANA_DWORD30, N_MODPHY_PCR_CMN_ANA_DWORD30_1G }, + {} +}; + +static const struct pmc_serdes_regs pid_modphy3_2p5g_regs[] = { + { PID_MODPHY3_B_MODPHY_PCR_LCPLL_DWORD0, B_MODPHY_PCR_LCPLL_DWORD0_2P5G }, + { PID_MODPHY3_N_MODPHY_PCR_LCPLL_DWORD2, N_MODPHY_PCR_LCPLL_DWORD2_2P5G }, + { PID_MODPHY3_N_MODPHY_PCR_LCPLL_DWORD7, N_MODPHY_PCR_LCPLL_DWORD7_2P5G }, + { PID_MODPHY3_N_MODPHY_PCR_LPPLL_DWORD10, N_MODPHY_PCR_LPPLL_DWORD10_2P5G }, + { PID_MODPHY3_N_MODPHY_PCR_CMN_ANA_DWORD30, N_MODPHY_PCR_CMN_ANA_DWORD30_2P5G }, + {} +}; + +static const struct pmc_serdes_regs pid_modphy1_1g_regs[] = { + { PID_MODPHY1_B_MODPHY_PCR_LCPLL_DWORD0, B_MODPHY_PCR_LCPLL_DWORD0_1G }, + { PID_MODPHY1_N_MODPHY_PCR_LCPLL_DWORD2, N_MODPHY_PCR_LCPLL_DWORD2_1G }, + { PID_MODPHY1_N_MODPHY_PCR_LCPLL_DWORD7, N_MODPHY_PCR_LCPLL_DWORD7_1G }, + { PID_MODPHY1_N_MODPHY_PCR_LPPLL_DWORD10, N_MODPHY_PCR_LPPLL_DWORD10_1G }, + { PID_MODPHY1_N_MODPHY_PCR_CMN_ANA_DWORD30, N_MODPHY_PCR_CMN_ANA_DWORD30_1G }, + {} +}; + +static const struct pmc_serdes_regs pid_modphy1_2p5g_regs[] = { + { PID_MODPHY1_B_MODPHY_PCR_LCPLL_DWORD0, B_MODPHY_PCR_LCPLL_DWORD0_2P5G }, + { PID_MODPHY1_N_MODPHY_PCR_LCPLL_DWORD2, N_MODPHY_PCR_LCPLL_DWORD2_2P5G }, + { PID_MODPHY1_N_MODPHY_PCR_LCPLL_DWORD7, N_MODPHY_PCR_LCPLL_DWORD7_2P5G }, + { PID_MODPHY1_N_MODPHY_PCR_LPPLL_DWORD10, N_MODPHY_PCR_LPPLL_DWORD10_2P5G }, + { PID_MODPHY1_N_MODPHY_PCR_CMN_ANA_DWORD30, N_MODPHY_PCR_CMN_ANA_DWORD30_2P5G }, + {} +}; +#endif /* CONFIG_INTEL_PMC_IPC */ + #endif /* __DWMAC_INTEL_H__ */ From patchwork Thu Feb 15 03:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201249 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp197769dyb; Wed, 14 Feb 2024 22:13:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVUa8z1b0mFhd1nwqokSyL/l824Erv2MvU4RIVgRRZhB+lRwCjzKUgjuA1iUgQMq9+SefYEs3m3bW8S1NK4lp8MxuvICA== X-Google-Smtp-Source: AGHT+IGQ/YFc+Yi3jpgzO5TIcHfpi+JBOBRu09nba0dYrMktsTs4vecUz7u0V/4NzWZS8XWRhyHv X-Received: by 2002:a17:906:7196:b0:a3d:1899:ec3 with SMTP id h22-20020a170906719600b00a3d18990ec3mr509047ejk.35.1707977583150; Wed, 14 Feb 2024 22:13:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707977583; cv=pass; d=google.com; s=arc-20160816; b=rqZTLRJ+vokO++GBY6g3kAEbKAhR6amEcVWI55WNYjYjcAhUuuew+nKCCyjWgDjO9h PzQ7sJi9UZTLSeRv5ZEVAPwgdTmAENh5jEVgN9oaJw8VlVfQfVf0cXVJJoMnwumtEpdY R1RYpG115hYWTxI8SoGTMZrBZTjQl4fRORKogMLognIdF7EY/vumT9WoeFdqh/cMOUNI oQVG8KWBzjA1I8n+IGIhvvAGuYv/TDcgUWXZdnXmRErzv2HeyNvo5/j+GUh/nf2WT7wH Ibg6mJPU9ekxgFEINmIoYSZMQZsaqRyS2JiY7YT5tigjtnqcl7I8ql9RZacMDQR5XnAb 5Sdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LmYrQJ7OelvEGpKp/xSNQi8aWOVnYn2uifgbLBSS4sI=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=zjsJwnWdtCObVJmhzaAaTyXpvdH0I2zYtTrjv6YKpws+74jRpLZxVtvIMB0qM+O5Hy ZNVzu1xtBC08qsNlV9Q1TWkN5UYwk6Tk36As8yJduHAHRlpDTUa8tT9Te7mjxGgCF7BV 9MDrDlbRa2UXi9MQKXEfKOETwS1qmHp90ZAuWyls1sc/lXcAxwAUrKn+8a2EfXXNCo5U Gmp1EphnhrhL9aHdbUPgJno7eF9gDmlfPpIn2DIg+sw4jBz1Mk3AJa89tW9LLKSZ8oQj zGdH7FXK+6ypEvGQ9AXUJvwFU7oaBcCIQ0ePkK3o/nhnXIv7L6QolIWqV9tOx1qjlrQM B+2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c8ou8Ps6; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66259-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66259-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cw14-20020a170906c78e00b00a3729de2a94si315768ejb.141.2024.02.14.22.13.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:13:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66259-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=c8ou8Ps6; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66259-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66259-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C540B1F2CD76 for ; Thu, 15 Feb 2024 03:12:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2BDFA1C29F; Thu, 15 Feb 2024 03:08:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="c8ou8Ps6" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6A611BDED; Thu, 15 Feb 2024 03:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966517; cv=none; b=kj3L27NDpunDL0n0HLFswJGlu1keraDIhkWu862Hxl2J/tpec2EYBHRbpHhaLPeMF2qrOcQeJ+Aamb1YTVeiuPVUBB2B1M5A1e+/pQsvTNi6bWueFFHFNQ8EDvyEdeHwtymGNUlpjniFGzsA2evfIY5qSyNHerbrmASGSiGj0xA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966517; c=relaxed/simple; bh=p/Gbsm0iaL+b0K2OX9Vd+27SSh2PBN4zKcqid0GWmkM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sAYUdOpANpt3XGSe9n/snszntEex/4tn4aYy3Sb4lrYJxsS3KVo8y1D/XV5P5bvydvHkqApFQ7/qHCx0XODCeOWzwehr7bQNF4a2G4mMVxvhVOdcreLeHXZfmyz7+dDk2gDCP0ADucaRK5Z38cmriPbHKRN/4vqcn0eADiBcQyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=c8ou8Ps6; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966516; x=1739502516; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p/Gbsm0iaL+b0K2OX9Vd+27SSh2PBN4zKcqid0GWmkM=; b=c8ou8Ps6nZqZi6AgGD0LLNGKXTY/WjLKrW/xnO1y0WalHDVKgNHtao1O PhDO+lC+Hm9dhyg7DmiUCQ52/Y3Ot60MLsur6Q+pH74f4bkNIw6dSxDYB J0WSmRL35DY6KlUktg6NcBVfP2dJKxYuRTYrqDtw4XC1wC5ymRV01plAT DJQwnGgDGGwE0Tw5jFp86miDr6TVRZbtqTvGYOH+qUw3IWrtoOCz5Uibz KuBwd5OdImfKX/6NZMjO6rCSS6RFRc8bw+0isGXzNYG7sZO0nniwsOEpc HRSDr+KPHdfbL+6nRdq5dt/3LmeYdRGyP4pfUXsLV/1yn1367K040Cdsw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461428" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461428" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:08:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385846" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:08:27 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 8/9] stmmac: intel: interface switching support for EHL platform Date: Thu, 15 Feb 2024 11:04:58 +0800 Message-Id: <20240215030500.3067426-9-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790944302651552075 X-GMAIL-MSGID: 1790944302651552075 'intel_get_pcs_neg_mode' and 'intel_config_serdes' was provided to handle interface mode change for EHL platform. Modphy register lane was provided to configure serdes on interface mode changing. Signed-off-by: Choong Yong Liang --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 21 +++++++++++++++++-- .../net/ethernet/stmicro/stmmac/dwmac-intel.h | 4 ++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 74cc0aa96faf..c79d8e3c3b24 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -759,6 +759,8 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, static int ehl_common_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + struct intel_priv_data *intel_priv = plat->bsp_priv; + plat->rx_queues_to_use = 8; plat->tx_queues_to_use = 8; plat->flags |= STMMAC_FLAG_USE_PHY_WOL; @@ -774,21 +776,28 @@ static int ehl_common_data(struct pci_dev *pdev, plat->safety_feat_cfg->prtyen = 0; plat->safety_feat_cfg->tmouten = 0; + intel_priv->tsn_lane_registers = ehl_tsn_lane_registers; + intel_priv->max_tsn_lane_registers = ARRAY_SIZE(ehl_tsn_lane_registers); + return intel_mgbe_common_data(pdev, plat); } static int ehl_sgmii_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + struct intel_priv_data *intel_priv = plat->bsp_priv; + plat->bus_id = 1; plat->phy_interface = PHY_INTERFACE_MODE_SGMII; - plat->speed_mode_2500 = intel_speed_mode_2500; + plat->max_speed = SPEED_2500; plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; plat->config_serdes = intel_config_serdes; plat->clk_ptp_rate = 204800000; + intel_priv->pid_modphy = PID_MODPHY3; + return ehl_common_data(pdev, plat); } @@ -841,12 +850,16 @@ static struct stmmac_pci_info ehl_pse0_rgmii1g_info = { static int ehl_pse0_sgmii1g_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + struct intel_priv_data *intel_priv = plat->bsp_priv; + plat->phy_interface = PHY_INTERFACE_MODE_SGMII; - plat->speed_mode_2500 = intel_speed_mode_2500; + plat->max_speed = SPEED_2500; plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; plat->config_serdes = intel_config_serdes; + intel_priv->pid_modphy = PID_MODPHY1; + return ehl_pse0_common_data(pdev, plat); } @@ -884,12 +897,16 @@ static struct stmmac_pci_info ehl_pse1_rgmii1g_info = { static int ehl_pse1_sgmii1g_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + struct intel_priv_data *intel_priv = plat->bsp_priv; + plat->phy_interface = PHY_INTERFACE_MODE_SGMII; plat->speed_mode_2500 = intel_speed_mode_2500; plat->serdes_powerup = intel_serdes_powerup; plat->serdes_powerdown = intel_serdes_powerdown; plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; plat->config_serdes = intel_config_serdes; + intel_priv->pid_modphy = PID_MODPHY1; + return ehl_pse1_common_data(pdev, plat); } diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h index 79c35ba969ea..093eed977ab0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h @@ -123,6 +123,10 @@ static const struct pmc_serdes_regs pid_modphy1_2p5g_regs[] = { { PID_MODPHY1_N_MODPHY_PCR_CMN_ANA_DWORD30, N_MODPHY_PCR_CMN_ANA_DWORD30_2P5G }, {} }; + +static const int ehl_tsn_lane_registers[] = {7, 8, 9, 10, 11}; +#else +static const int ehl_tsn_lane_registers[] = {}; #endif /* CONFIG_INTEL_PMC_IPC */ #endif /* __DWMAC_INTEL_H__ */ From patchwork Thu Feb 15 03:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Choong Yong Liang X-Patchwork-Id: 201252 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp220057dyb; Wed, 14 Feb 2024 23:18:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVRhTmkcP8xB4vROyOPGqV+BnVEBY5oF/LAbdZb8InpuaBbWVCoYxxjfeLYzHp8OkkdC+R5ME42qyqw+ByAzLWsNe0DQ== X-Google-Smtp-Source: AGHT+IHLa1OUdEfHSbaxQiWW4X+kXSEZXzTiQ4tvBxhb3W70TyQD6Msmi11hB2J0+Wb6918ADF1/ X-Received: by 2002:a17:906:a298:b0:a3d:8366:e31f with SMTP id i24-20020a170906a29800b00a3d8366e31fmr565073ejz.42.1707981499954; Wed, 14 Feb 2024 23:18:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707981499; cv=pass; d=google.com; s=arc-20160816; b=Gff+pbCD87uu//lui2WKOaFfcJ2H/GSuSA3lzLT3c3zxDm/kxihv1bT6kFpTz6PPSQ KN7PiyAkJvhejLi9iSeOOolo98U1U1LvkJbmOk2KHuXRFVYGHcQB8LweITXdBcpAWrjk X/1aBQn81ha4vssD90rYVxu6zl7LkXiRIY38sBQ0UUuH/boAJgsZt2Z6uSA+PeCFuXii TCD+WlvVG4D3G9NnUq+4hI8MOEFp/ncrWLRARxog9ctpqwoeWvbzW4/WChLLmFDmg7iH PpqetxOeBDfl33aIVKFfkQWPAph+OQDy9W1mLtRqmrDZ3mD7IkZSqFx6u2prTx26s4Me q/3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1RJAG0YKQ2elvvfP1burGLa+E173ziVQ7i+i8k/F1w4=; fh=chTeah25dtsI+fnQYorT/69F850asxoXrFC8SVATgvA=; b=e+J3BxKw7JOQ+uxQZ78NtY5IoJf2Z9YVdXubPRnirazthgbKIy4JRiRl9mwwnNzpKs f6x64gP88XaqjCq0bK/oHHYmRQTwmHu3Jb+x8kDaO5ajR2jw1p3VIlTNsb/Y+EW0OVd1 5jcz8xPfxp5x34CH9WV51fqqW9tntVDaHlWoD/rRWYHsxRZns1qaQG1APp26q9ppOFbd xFrjkliLlHnAdQO89oxLJdCPJHwTGkTjvBRnyChtmdYBhZMS16FSCtsV4nxrNEAOb42M zMaJXilh0oYFOo5fnhDWyqthY7Khmd63JMqGng/xnfgZzvlrniFna693sozXSok+dQW/ sJLw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vsl1yFIr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66260-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66260-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x22-20020a1709065ad600b00a3d216b9108si385682ejs.32.2024.02.14.23.18.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 23:18:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66260-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Vsl1yFIr; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66260-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66260-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0FEDA1F2A922 for ; Thu, 15 Feb 2024 03:12:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4DD31C68C; Thu, 15 Feb 2024 03:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Vsl1yFIr" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 525B3611B; Thu, 15 Feb 2024 03:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966533; cv=none; b=b7d+ZQ+ZdxstqR72As7cd8cqUKT1IExZenJmv974hft1OvRpUCYdTbU/FdEb1cctDLjbxl3Wi51HzKBN0/khsTugPfxQD+uijZ+UF4WTmRfnR/qvV1ACOTMCQNganY3bQb4cBYfKMB1lIEEfIfUWtkqp0wS74p+qxWxPBNZkSe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707966533; c=relaxed/simple; bh=qvmE9ozt+922Am67EghiGlMAntqBBBPRw+LPiyCAFes=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hx1NARbaEEZZ+y9qvvzGn9gv440KdljKsMddgcabRwIAdmyRzvcTvmzqBbh0co3YM0zKMo+EJFS1IO/RXXrzrYpeV4URJZXdNw7zF27Cl6/aD7K8IF6O3vsxSR0tMdfTCYQ3ixORaQBm/H89slJckjTr+wQPP7cJIBw5Ub/Duh4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Vsl1yFIr; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707966532; x=1739502532; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qvmE9ozt+922Am67EghiGlMAntqBBBPRw+LPiyCAFes=; b=Vsl1yFIrzGyB74w6qHdmSe/75lA/Y91AMd/wze4YnSKqCyO1X5CssomT +sDLZbk4EDil7qThVTwxstsX5KGjIFtOv/+MuX9vwiBi8+kAXe/pzDThB GcPblx2k1nstDqF8xuDmRwTRDoWRXjelIdUhwI+gIuRUB72n3LZdfsfwO vDZiifomVst5GFCaWpz8PZfVdb4eW8txWamopT9xQYjSgopR8Fz1bHSJ5 /nqXn7AoFcz1jcvvCVPXAXsZ2FglZ3Eva92kbU7rgGIh9v9TpNL5dImf/ jNmKyb6GXJGQ6H/GkiYS48akk5ddilcDoejfwjkkdDpOZDtP8z1L0JPYQ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="19461453" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="19461453" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 19:08:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="3385871" Received: from yongliang-ubuntu20-ilbpg12.png.intel.com ([10.88.229.33]) by fmviesa009.fm.intel.com with ESMTP; 14 Feb 2024 19:08:35 -0800 From: Choong Yong Liang To: Rajneesh Bhardwaj , David E Box , Hans de Goede , Mark Gross , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran , Russell King , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Andrew Lunn , Heiner Kallweit , Philipp Zabel Cc: Andrew Halaney , Serge Semin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, bpf@vger.kernel.org, Voon Wei Feng , Michael Sit Wei Hong , Lai Peter Jun Ann , Abdul Rahim Faizal Subject: [PATCH net-next v5 9/9] stmmac: intel: interface switching support for ADL-N platform Date: Thu, 15 Feb 2024 11:04:59 +0800 Message-Id: <20240215030500.3067426-10-yong.liang.choong@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> References: <20240215030500.3067426-1-yong.liang.choong@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790948409692235470 X-GMAIL-MSGID: 1790948409692235470 'intel_get_pcs_neg_mode' and 'intel_config_serdes' was provided to handle interface mode change for ADL-S platform. Modphy register lane was provided to configure serdes on interface mode changing. Signed-off-by: Michael Sit Wei Hong Signed-off-by: Choong Yong Liang --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 49 ++++++++++++++++++- .../net/ethernet/stmicro/stmmac/dwmac-intel.h | 2 + 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index c79d8e3c3b24..f0f3d35bdb69 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -992,6 +992,53 @@ static int adls_sgmii_phy1_data(struct pci_dev *pdev, static struct stmmac_pci_info adls_sgmii1g_phy1_info = { .setup = adls_sgmii_phy1_data, }; + +static int adln_common_data(struct pci_dev *pdev, + struct plat_stmmacenet_data *plat) +{ + struct intel_priv_data *intel_priv = plat->bsp_priv; + + plat->rx_queues_to_use = 6; + plat->tx_queues_to_use = 4; + plat->clk_ptp_rate = 204800000; + + plat->safety_feat_cfg->tsoee = 1; + plat->safety_feat_cfg->mrxpee = 0; + plat->safety_feat_cfg->mestee = 1; + plat->safety_feat_cfg->mrxee = 1; + plat->safety_feat_cfg->mtxee = 1; + plat->safety_feat_cfg->epsi = 0; + plat->safety_feat_cfg->edpp = 0; + plat->safety_feat_cfg->prtyen = 0; + plat->safety_feat_cfg->tmouten = 0; + + intel_priv->tsn_lane_registers = adln_tsn_lane_registers; + intel_priv->max_tsn_lane_registers = ARRAY_SIZE(adln_tsn_lane_registers); + + return intel_mgbe_common_data(pdev, plat); +} + +static int adln_sgmii_phy0_data(struct pci_dev *pdev, + struct plat_stmmacenet_data *plat) +{ + struct intel_priv_data *intel_priv = plat->bsp_priv; + + plat->bus_id = 1; + plat->phy_interface = PHY_INTERFACE_MODE_SGMII; + plat->max_speed = SPEED_2500; + plat->serdes_powerup = intel_serdes_powerup; + plat->serdes_powerdown = intel_serdes_powerdown; + plat->get_pcs_neg_mode = intel_get_pcs_neg_mode; + plat->config_serdes = intel_config_serdes; + intel_priv->pid_modphy = PID_MODPHY1; + + return adln_common_data(pdev, plat); +} + +static struct stmmac_pci_info adln_sgmii1g_phy0_info = { + .setup = adln_sgmii_phy0_data, +}; + static const struct stmmac_pci_func_data galileo_stmmac_func_data[] = { { .func = 6, @@ -1374,7 +1421,7 @@ static const struct pci_device_id intel_eth_pci_id_table[] = { { PCI_DEVICE_DATA(INTEL, TGLH_SGMII1G_1, &tgl_sgmii1g_phy1_info) }, { PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_0, &adls_sgmii1g_phy0_info) }, { PCI_DEVICE_DATA(INTEL, ADLS_SGMII1G_1, &adls_sgmii1g_phy1_info) }, - { PCI_DEVICE_DATA(INTEL, ADLN_SGMII1G, &tgl_sgmii1g_phy0_info) }, + { PCI_DEVICE_DATA(INTEL, ADLN_SGMII1G, &adln_sgmii1g_phy0_info) }, { PCI_DEVICE_DATA(INTEL, RPLP_SGMII1G, &tgl_sgmii1g_phy0_info) }, {} }; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h index 093eed977ab0..2c6b50958988 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.h @@ -124,8 +124,10 @@ static const struct pmc_serdes_regs pid_modphy1_2p5g_regs[] = { {} }; +static const int adln_tsn_lane_registers[] = {6}; static const int ehl_tsn_lane_registers[] = {7, 8, 9, 10, 11}; #else +static const int adln_tsn_lane_registers[] = {}; static const int ehl_tsn_lane_registers[] = {}; #endif /* CONFIG_INTEL_PMC_IPC */