From patchwork Tue Apr 2 20:11:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13614557 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F73E15B966; Tue, 2 Apr 2024 20:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712088699; cv=none; b=qZFKvKwGYenN9e0HH1nPh/DDZV8DAshCtTGoARgZHhA8nKOdR/LeHc/k4Twypqn2rGLMMNm2PvJjLax96Un0m1eOI7qztHAhEbdB7mZTpv95nJFfR+EVoUqIimK8200NgIga6KojS9ogibTa6W2WxbNATSstwxJ4EJcnuUo0XNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712088699; c=relaxed/simple; bh=ARVTOUd5GsEZBV4agURD9UrjWRU/ncQ4Or63i0u3E/k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=kBKV35prm2vI+HM6ZlEXvef+jctoUozhw5mlnURtL7JEGDLo1kVsrJ5C8JHfe6gtaLylQU7YCFRnTNKCQqLzBJDwwy5XIzLqa0/H5H3ITJRDoUn+ci99PWPUKIceHGQrW/yhkgKGTd80HpYOmuT+ojSGb38g+U7kZ0PFlnpqb2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FnyGtojL; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FnyGtojL" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-51381021af1so7712468e87.0; Tue, 02 Apr 2024 13:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712088695; x=1712693495; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=h9XGmtr4tKryDcF6zZrLSZqjNQPqsK7oIswVla3FBTc=; b=FnyGtojLUgPY+M0KD9t90ZwiYZZTEZDMDK025GcUSlJjhgzH1L8gaL9zN9x5vxAY2l rBS2kj4YetUHQvD6ayKVqCaGfItFPnDjgIP7Zpm61E7WPngpj86iQwIbhyxKJ0sAc62m VvozqDLSrYdu8jCVn7gSL1SjDGc7l1wqSNq8ZlWZ4tpUzXex+ivFEOjRNlU7BEImfCXS lexw5RYJrnaH1/kY9kRT+2/zZpp7U93aKsYd7i+eaCQhqK1iv9Zx9yIpL+R6EN5un7b7 34S8qCUhiT7KzspLs18l/Wq4huMeT0u2tTdPepmneyGRjKcjwzCropIOxVtyAig/9eyI WO0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712088695; x=1712693495; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=h9XGmtr4tKryDcF6zZrLSZqjNQPqsK7oIswVla3FBTc=; b=akB2myU5rikFkIdMjXi3/C7Ga6cwyKqXwGQkU26Ivofbgj9IgT2t3Tgzx/g8nb6Rlg lyjJf5MQJ66zKywn1LKxxJ97NTwqINiXcUKdJ4lpiVZqEjGsi3nsUw1KU3KI+Vl2YR/g uKlrLcTRwGZ6zBSsUaeO89tFYdYcCIpwFQdpFS8tZHqcgKxJufuamU801/eN/c2UapVD +aSMfosL+NGd/zU5VPQ0TeazVnPl54dcJYvITv+XaSZ4Dty7/40nu4MN1uUOA2bHj9Nh Y7SefsO6oCKSoDkgnOAsttDbsXRXvs8rYrz8higgf+j9RUJo+Cnpa/mOKzvj/wOrhqFt pyww== X-Forwarded-Encrypted: i=1; AJvYcCVZ9qJ3a34WiHHSQv7mFY/GJfhLhpIiPZM+YuPTGqUX5q4ZikdAyj+zeufetGTa2/L6fc2DipB1JoX7MjWGHKo7ECxd1jVaTZXVz4ZU X-Gm-Message-State: AOJu0Yz2eoMbbxdBxPz+F7UdNSwJ3oC73fpDl/FmUI7XiRcXp5E5jFBX 7KSaGuKlWJeTV0EtuXx4mA0KWkyUpqQXkXdXTlz4Lwc+vAHQWB4n5RamMaPMwhg= X-Google-Smtp-Source: AGHT+IEEPAFT+/kOPM/Mp52nF4sjsm7PJK6duhPlAH41iXW4qrQWN6qaA2sLT7guCuQmPutOTMR3BA== X-Received: by 2002:a2e:9790:0:b0:2d4:49d1:38e with SMTP id y16-20020a2e9790000000b002d449d1038emr2248730lji.28.1712088694809; Tue, 02 Apr 2024 13:11:34 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id re26-20020a170906d8da00b00a474ef94fddsm6903829ejb.70.2024.04.02.13.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 13:11:34 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Eichenberger , Dimitri Fedrau , Kory Maincent , Maxime Chevallier , Ahmed Zaki , linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 1/3] net: phy: marvell: add basic support of 88E308X/88E609X family Date: Tue, 2 Apr 2024 22:11:18 +0200 Message-Id: <20240402201123.2961909-1-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This patch implements only basic support. It covers PHY used in multiple IC: PHY: 88E3082, 88E3083 Switch: 88E6096, 88E6097 Signed-off-by: Pawel Dembicki Reviewed-by: Andrew Lunn Reviewed-by: Russell King (Oracle) --- v3,v2: - resend only drivers/net/phy/marvell.c | 13 +++++++++++++ include/linux/marvell_phy.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 42ed013385bf..fae7eb57ee2c 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -3289,6 +3289,18 @@ static struct phy_driver marvell_drivers[] = { .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, }, + { + .phy_id = MARVELL_PHY_ID_88E3082, + .phy_id_mask = MARVELL_PHY_ID_MASK, + .name = "Marvell 88E308X/88E609X Family", + /* PHY_BASIC_FEATURES */ + .probe = marvell_probe, + .config_init = marvell_config_init, + .aneg_done = marvell_aneg_done, + .read_status = marvell_read_status, + .resume = genphy_resume, + .suspend = genphy_suspend, + }, { .phy_id = MARVELL_PHY_ID_88E1112, .phy_id_mask = MARVELL_PHY_ID_MASK, @@ -3742,6 +3754,7 @@ module_phy_driver(marvell_drivers); static struct mdio_device_id __maybe_unused marvell_tbl[] = { { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK }, + { MARVELL_PHY_ID_88E3082, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1111, MARVELL_PHY_ID_MASK }, { MARVELL_PHY_ID_88E1111_FINISAR, MARVELL_PHY_ID_MASK }, diff --git a/include/linux/marvell_phy.h b/include/linux/marvell_phy.h index 693eba9869e4..88254f9aec2b 100644 --- a/include/linux/marvell_phy.h +++ b/include/linux/marvell_phy.h @@ -7,6 +7,7 @@ /* Known PHY IDs */ #define MARVELL_PHY_ID_88E1101 0x01410c60 +#define MARVELL_PHY_ID_88E3082 0x01410c80 #define MARVELL_PHY_ID_88E1112 0x01410c90 #define MARVELL_PHY_ID_88E1111 0x01410cc0 #define MARVELL_PHY_ID_88E1118 0x01410e10 From patchwork Tue Apr 2 20:11:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13614558 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C4D115D5A5; Tue, 2 Apr 2024 20:11:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712088706; cv=none; b=q3O9vJrA2cM2knybP5XofjxckMI/o+cS+c+dRKO6MYJU3stqdbtaNeX01yiSLuaWdYYLqdBjlwDZTyUor5VkFNAezPGyhqnJRvQpjGvQvXTOaOsuVYXK9dA1hm7pTYLRYLkIySx6TjSacLB7vhCDHCuo+Lx1ozsU59VZ3ZIz7l4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712088706; c=relaxed/simple; bh=njDoahP8wBLxSZqQxHLlfZVnZGM9S/TED+Bw5MCaVWM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XVdqS1gw+VJj32N1CRUYXkfg+dlPUb+XWP2cMK+dFyHPK2vvVycHtSoK3+pkLj/ph1sTGxPMJhbN5ah5zn6cmTV5k/b1D74ATd/87wF4CSipbXmEsYmMzHjd3C9z+cw59hoD42F1FwuZ10GUvU0cd5/LpDznHcm3GXCcGRy4VSc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QHsVQlGg; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QHsVQlGg" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a4715d4c2cbso749385866b.1; Tue, 02 Apr 2024 13:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712088703; x=1712693503; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w0KS6ydofhsScnfht3viLl5Uv55eEwrxAUcJ+wfOLjw=; b=QHsVQlGgXjYH1HcEy7X8gXcmyIQgsoQ3mySf8qn2JVzxApNaj2l7bwlu/g62f0FPFA I5NIqQzCSA1c8jiscmcmYh5g+ehaU3rCeIMEdcXFWMQi87W/syVahN19kcGSKkOfN9AB JzdGPzj9HWFO8TjaOUXUT94GZK23mhHqu25oMB9bPgrbvVgG+6We2ODNYdJD5zlcv3a1 1wyBOXsZE9oQTnuVEmpl1vo6swgUw8tm3p+tp/HR6sc7ISjaU8mdz736WKP6RA3Qy6AU MLTDUYHEkPqTOaLBzIomu5OvK91Eiv97t8Fk+jqnwPZhU6XlAvmuVHa/3ELyPaDcrvnV rrAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712088703; x=1712693503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w0KS6ydofhsScnfht3viLl5Uv55eEwrxAUcJ+wfOLjw=; b=H7X1TTh9eZgGnMcpNLBo9K4qHKxRJoeYQpK50AY9H7w96aclLCppuVa1/GdvY+PZ0j JGvfIz/3thK+5/UNsIMkCg0r1mDkqhEWeTZDiE/cPtcyrSY+gMNaqZl/oTOJyu7bktjs v72hl6WAQWoxS3LhWPSrNjriGNEqQN20OEleBLxPzzPz4KnrYRCGflKrED7rkTo45Bbw k349GvbGSiFHiDeJreukmmH/uZfjBoX4vlS+0gGx1D/mnB4aDXvGBCVZyzocX2GiJyFo eJRlw5JsG/7LpRYKFhnsmcGgjdT/v+hPpOi1n4GTOTInccaWJm6MhsGdXbnqZ7Pga2SB FdAA== X-Forwarded-Encrypted: i=1; AJvYcCWGev/Wg1oiFUBaenLIKEnpEBZ9dFQZR2XuHFRIjvNC29kfhvi6a4t7cdyr6Ib9nUdSbbLR8Q9c7EgNYUuc9LAHRBJ7AILXuzzYg6EP X-Gm-Message-State: AOJu0YwZnaPz5fZydQltVcYURCBtL0e5VXkHOIx6C3b7tqeNiNOS10iz G4U/TuG2Qkfj7uCiEAgJD2RG4gbsD94bD5fYbgpDi3BtfCdFvl99A7NNimj7vxo= X-Google-Smtp-Source: AGHT+IHIkEd1n2mtdP7XMIFcy9A8tKM9WltxSInWy9wLMa3WBtkrIOMIO7p5bOPeHywamRq0Gl6MfQ== X-Received: by 2002:a17:906:2b5b:b0:a4e:60c0:6a98 with SMTP id b27-20020a1709062b5b00b00a4e60c06a98mr521371ejg.55.1712088702973; Tue, 02 Apr 2024 13:11:42 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id re26-20020a170906d8da00b00a474ef94fddsm6903829ejb.70.2024.04.02.13.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 13:11:42 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Dimitri Fedrau , Stefan Eichenberger , Kory Maincent , Maxime Chevallier , Ahmed Zaki , linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 2/3] net: ethtool: Add impedance mismatch result code to cable test Date: Tue, 2 Apr 2024 22:11:19 +0200 Message-Id: <20240402201123.2961909-2-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402201123.2961909-1-paweldembicki@gmail.com> References: <20240402201123.2961909-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Some PHYs can recognize during a cable test if the impedance in the cable is okay. They can detect reflections caused by impedance discontinuity between a regular 100 Ohm cable and an abnormal part with a higher or lower impedance. This commit introduces a new result code: ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH, which represents the results of a cable test indicating issues with impedance integrity. Signed-off-by: Pawel Dembicki Reviewed-by: Andrew Lunn --- v3: - added enum description - improve commit message v2: - introduce patch include/uapi/linux/ethtool_netlink.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 3f89074aa06c..accbb1a231df 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -515,6 +515,10 @@ enum { ETHTOOL_A_CABLE_RESULT_CODE_OPEN, ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT, ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT, + /* detected reflection caused by the impedance discontinuity between + * a regular 100 Ohm cable and a part with the abnormal impedance value + */ + ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH, }; enum { From patchwork Tue Apr 2 20:11:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13614559 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23BC815D5D3; Tue, 2 Apr 2024 20:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712088715; cv=none; b=mG6DfVDDQb4I3AVO9NxG1s/Z9CogSs8iybPFEMeI0oaDAj6WgqHdV80pgZGxzPYNs+FjSY9CtFjg5iqvr4wbtyo2RjNAOJsLT4gt+/6OYnm4/8TmWbk0aysF/RXiCtjPfstMxbUyTnB+wEbMP91hGi86e2F75Bk9465drpbRXfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712088715; c=relaxed/simple; bh=Xl1YewxDylWIO2dZkm8zwCYMzPwKRG8PgxV4KCekhtQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OdLscCr3qedC6+bcOJ9EFWsUlX9h8T/H1w4YCBhyt4uyQS7pz5XKcvE+IA9neo9vsAip/VuZd1WGar9B2AvJKBLFcIpVpFZo/uYrP7ih2GgB9ubx62oA13vEQb4Q3+YolS10iZWNaMyOXWSLJhKFY4yauDq5OCQq6YAUUTrf3ec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IegChvxo; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IegChvxo" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-56df9c119a4so447058a12.0; Tue, 02 Apr 2024 13:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712088711; x=1712693511; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XQb6wWI55VWZ7l2V0zWTjrCkmpGa/fvx/M1pkRbMvxw=; b=IegChvxoJHJUAZGqLx8YYkfBnA6kq2BwTPAZO/0MQE0D2fkTkc3jKhqF27a9+sIX07 FB42hwX/AGQM7GFchWBkM9a59Eci2BdV7x+MBNSV1D+j3PFlmLFf84jTHgayAbSQR4g9 VizmsgQWOJ+FgbTPMfKhlDNyRIHA6DYn7LVQxsG9WlCJmVMqj4lTs7foRr1YQ9t3nfAG aB5M6TYEWMqFaoyjMe6+xUyVUObRg3dlHMAgB3mDBEySomtbbfJPpFM98/dzIBTGeqVu SaSToJC56z9msEBXB8X0m65BKqAzjZ8CGNQSHVpTfVLxGYz5sVSZuTD0y/e3kSaAYnAB IxCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712088711; x=1712693511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XQb6wWI55VWZ7l2V0zWTjrCkmpGa/fvx/M1pkRbMvxw=; b=wa3EgZaQU9Bm95tLH1Qu8f3zKG+vaBV5xsTDUHu/6fWhtU+JQqxZJpWWDLWLeuC4kj MoQc6MRuLOP3cTWs6mPp0DzG29kt970r2ob/I4y4uwjagaYlKjehp5jzEWxakwoUCE+U c7/xmRYWYwFc7PBbMmBcT0xIWNdaCG55UAknfty4+Avf7qiQ3xhNQXF2Z+KCgXCmteb1 d5zaKOJi4hQ1MkLr8uxOIGffdU6CoQ2tfqh2xwJ68IZXRaxPJTdMc25c+OPxKnMma3tg 3VIKXBEegxva1n+oIfG90XDgEKvwWeaDr7umdFyrAF93+0CDkXv5AzSMEuSA2bFWYynF gV+A== X-Forwarded-Encrypted: i=1; AJvYcCX3YQ6bWctBQW2S62hsbBQPz5C4Uauxt388A6DVopoA838XZHPBnGLGVHXSq0XiBbrvPh5pEyZdzZNbLQ+jT5ZgSMWkWevSjNhQWXaA X-Gm-Message-State: AOJu0YzY667nXxn9JdgsKt5Q9bVZEfav8xK8TJi3VGicKi3R8oZhWRme +d7H4E3lps3YpnBlPGw8Xe0CHWOVIl8eM+Neo7d5T/y3yKmsGlcXGsrPi/R7X8U= X-Google-Smtp-Source: AGHT+IFkXNBNt8uCe83nWR9wQQkxTjn3pVDhJZ4cnifn/4gyxj1yo4UU7J0DMjy4L2gJL0Q0bx4oRg== X-Received: by 2002:a17:906:6bca:b0:a4e:e4:7b66 with SMTP id t10-20020a1709066bca00b00a4e00e47b66mr495137ejs.19.1712088711052; Tue, 02 Apr 2024 13:11:51 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id re26-20020a170906d8da00b00a474ef94fddsm6903829ejb.70.2024.04.02.13.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 13:11:50 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Stefan Eichenberger , Dimitri Fedrau , Kory Maincent , Maxime Chevallier , Wojciech Drewek , Ahmed Zaki , linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 3/3] net: phy: marvell: implement cable-test for 88E308X/88E609X family Date: Tue, 2 Apr 2024 22:11:20 +0200 Message-Id: <20240402201123.2961909-3-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402201123.2961909-1-paweldembicki@gmail.com> References: <20240402201123.2961909-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This commit implements VCT in 88E308X/88E609X Family. It require two workarounds with some magic configuration. Regular use require only one register configuration. But Open Circuit require second workaround. It cause implementation two phases for fault length measuring. Fast Ethernet PHY have implemented very simple version of VCT. It's complitley different than vct5 or vct7. Signed-off-by: Pawel Dembicki Reviewed-by: Andrew Lunn --- v3: - resend only v2: - change 'm88e3082_vct_distrfln_2_cm' to static - simplify 'm88e3082_vct_cable_test_get_status' - replace magic numbers in MII_BMCR configuration - remove unnecessary backup of MII_BMCR register - use ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH for impedance mismatch drivers/net/phy/marvell.c | 208 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index fae7eb57ee2c..7c00f47e4ded 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -279,6 +279,23 @@ #define MII_VCT7_CTRL_METERS BIT(10) #define MII_VCT7_CTRL_CENTIMETERS 0 +#define MII_VCT_TXPINS 0x1A +#define MII_VCT_RXPINS 0x1B +#define MII_VCT_TXPINS_ENVCT BIT(15) +#define MII_VCT_TXRXPINS_VCTTST GENMASK(14, 13) +#define MII_VCT_TXRXPINS_VCTTST_SHIFT 13 +#define MII_VCT_TXRXPINS_VCTTST_OK 0 +#define MII_VCT_TXRXPINS_VCTTST_SHORT 1 +#define MII_VCT_TXRXPINS_VCTTST_OPEN 2 +#define MII_VCT_TXRXPINS_VCTTST_FAIL 3 +#define MII_VCT_TXRXPINS_AMPRFLN GENMASK(12, 8) +#define MII_VCT_TXRXPINS_AMPRFLN_SHIFT 8 +#define MII_VCT_TXRXPINS_DISTRFLN GENMASK(7, 0) +#define MII_VCT_TXRXPINS_DISTRFLN_MAX 0xff + +#define M88E3082_PAIR_A BIT(0) +#define M88E3082_PAIR_B BIT(1) + #define LPA_PAUSE_FIBER 0x180 #define LPA_PAUSE_ASYM_FIBER 0x100 @@ -301,6 +318,12 @@ static struct marvell_hw_stat marvell_hw_stats[] = { { "phy_receive_errors_fiber", 1, 21, 16}, }; +enum { + M88E3082_VCT_OFF, + M88E3082_VCT_PHASE1, + M88E3082_VCT_PHASE2, +}; + struct marvell_priv { u64 stats[ARRAY_SIZE(marvell_hw_stats)]; char *hwmon_name; @@ -310,6 +333,7 @@ struct marvell_priv { u32 last; u32 step; s8 pair; + u8 vct_phase; }; static int marvell_read_page(struct phy_device *phydev) @@ -2417,6 +2441,188 @@ static int marvell_vct7_cable_test_get_status(struct phy_device *phydev, return 0; } +static int m88e3082_vct_cable_test_start(struct phy_device *phydev) +{ + struct marvell_priv *priv = phydev->priv; + int ret; + + /* It needs some magic workarounds described in VCT manual for this PHY. + */ + ret = phy_write(phydev, 29, 0x0003); + if (ret < 0) + return ret; + + ret = phy_write(phydev, 30, 0x6440); + if (ret < 0) + return ret; + + if (priv->vct_phase == M88E3082_VCT_PHASE1) { + ret = phy_write(phydev, 29, 0x000a); + if (ret < 0) + return ret; + + ret = phy_write(phydev, 30, 0x0002); + if (ret < 0) + return ret; + } + + ret = phy_write(phydev, MII_BMCR, + BMCR_RESET | BMCR_SPEED100 | BMCR_FULLDPLX); + if (ret < 0) + return ret; + + ret = phy_write(phydev, MII_VCT_TXPINS, MII_VCT_TXPINS_ENVCT); + if (ret < 0) + return ret; + + ret = phy_write(phydev, 29, 0x0003); + if (ret < 0) + return ret; + + ret = phy_write(phydev, 30, 0x0); + if (ret < 0) + return ret; + + if (priv->vct_phase == M88E3082_VCT_OFF) { + priv->vct_phase = M88E3082_VCT_PHASE1; + priv->pair = 0; + + return 0; + } + + ret = phy_write(phydev, 29, 0x000a); + if (ret < 0) + return ret; + + ret = phy_write(phydev, 30, 0x0); + if (ret < 0) + return ret; + + priv->vct_phase = M88E3082_VCT_PHASE2; + + return 0; +} + +static int m88e3082_vct_cable_test_report_trans(int result, u8 distance) +{ + switch (result) { + case MII_VCT_TXRXPINS_VCTTST_OK: + if (distance == MII_VCT_TXRXPINS_DISTRFLN_MAX) + return ETHTOOL_A_CABLE_RESULT_CODE_OK; + return ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH; + case MII_VCT_TXRXPINS_VCTTST_SHORT: + return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT; + case MII_VCT_TXRXPINS_VCTTST_OPEN: + return ETHTOOL_A_CABLE_RESULT_CODE_OPEN; + default: + return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC; + } +} + +static u32 m88e3082_vct_distrfln_2_cm(u8 distrfln) +{ + if (distrfln < 24) + return 0; + + /* Original function for meters: y = 0.7861x - 18.862 */ + return (7861 * distrfln - 188620) / 100; +} + +static int m88e3082_vct_cable_test_get_status(struct phy_device *phydev, + bool *finished) +{ + u8 tx_vcttst_res, rx_vcttst_res, tx_distrfln, rx_distrfln; + struct marvell_priv *priv = phydev->priv; + int ret, tx_result, rx_result; + bool done_phase = true; + + *finished = false; + + ret = phy_read(phydev, MII_VCT_TXPINS); + if (ret < 0) + return ret; + else if (ret & MII_VCT_TXPINS_ENVCT) + return 0; + + tx_distrfln = ret & MII_VCT_TXRXPINS_DISTRFLN; + tx_vcttst_res = (ret & MII_VCT_TXRXPINS_VCTTST) >> + MII_VCT_TXRXPINS_VCTTST_SHIFT; + + ret = phy_read(phydev, MII_VCT_RXPINS); + if (ret < 0) + return ret; + + rx_distrfln = ret & MII_VCT_TXRXPINS_DISTRFLN; + rx_vcttst_res = (ret & MII_VCT_TXRXPINS_VCTTST) >> + MII_VCT_TXRXPINS_VCTTST_SHIFT; + + *finished = true; + + switch (priv->vct_phase) { + case M88E3082_VCT_PHASE1: + tx_result = m88e3082_vct_cable_test_report_trans(tx_vcttst_res, + tx_distrfln); + rx_result = m88e3082_vct_cable_test_report_trans(rx_vcttst_res, + rx_distrfln); + + ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_A, + tx_result); + ethnl_cable_test_result(phydev, ETHTOOL_A_CABLE_PAIR_B, + rx_result); + + if (tx_vcttst_res == MII_VCT_TXRXPINS_VCTTST_OPEN) { + done_phase = false; + priv->pair |= M88E3082_PAIR_A; + } else if (tx_distrfln < MII_VCT_TXRXPINS_DISTRFLN_MAX) { + u8 pair = ETHTOOL_A_CABLE_PAIR_A; + u32 cm = m88e3082_vct_distrfln_2_cm(tx_distrfln); + + ethnl_cable_test_fault_length(phydev, pair, cm); + } + + if (rx_vcttst_res == MII_VCT_TXRXPINS_VCTTST_OPEN) { + done_phase = false; + priv->pair |= M88E3082_PAIR_B; + } else if (rx_distrfln < MII_VCT_TXRXPINS_DISTRFLN_MAX) { + u8 pair = ETHTOOL_A_CABLE_PAIR_B; + u32 cm = m88e3082_vct_distrfln_2_cm(rx_distrfln); + + ethnl_cable_test_fault_length(phydev, pair, cm); + } + + break; + case M88E3082_VCT_PHASE2: + if (priv->pair & M88E3082_PAIR_A && + tx_vcttst_res == MII_VCT_TXRXPINS_VCTTST_OPEN && + tx_distrfln < MII_VCT_TXRXPINS_DISTRFLN_MAX) { + u8 pair = ETHTOOL_A_CABLE_PAIR_A; + u32 cm = m88e3082_vct_distrfln_2_cm(tx_distrfln); + + ethnl_cable_test_fault_length(phydev, pair, cm); + } + if (priv->pair & M88E3082_PAIR_B && + rx_vcttst_res == MII_VCT_TXRXPINS_VCTTST_OPEN && + rx_distrfln < MII_VCT_TXRXPINS_DISTRFLN_MAX) { + u8 pair = ETHTOOL_A_CABLE_PAIR_B; + u32 cm = m88e3082_vct_distrfln_2_cm(rx_distrfln); + + ethnl_cable_test_fault_length(phydev, pair, cm); + } + + break; + default: + return -EINVAL; + } + + if (!done_phase) { + *finished = false; + return m88e3082_vct_cable_test_start(phydev); + } + if (*finished) + priv->vct_phase = M88E3082_VCT_OFF; + return 0; +} + #ifdef CONFIG_HWMON struct marvell_hwmon_ops { int (*config)(struct phy_device *phydev); @@ -3300,6 +3506,8 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .resume = genphy_resume, .suspend = genphy_suspend, + .cable_test_start = m88e3082_vct_cable_test_start, + .cable_test_get_status = m88e3082_vct_cable_test_get_status, }, { .phy_id = MARVELL_PHY_ID_88E1112,