Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp351828rdb; Thu, 1 Feb 2024 10:12:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJwyVWT+/k1l67Dj4yc3Msfyytt1YU993oajam29ic0MLUyrPktvUC3B3MBbR0nS9WG9/R X-Received: by 2002:a05:6214:c65:b0:68c:4dcb:844 with SMTP id t5-20020a0562140c6500b0068c4dcb0844mr5546493qvj.51.1706811134127; Thu, 01 Feb 2024 10:12:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706811134; cv=pass; d=google.com; s=arc-20160816; b=JKuerfIqPjuWW87iBI6MZMeDNzyPWGdYxMzgoyXQypQgANGtJ5+YsLe9lxSYxTD2d0 ZsgviOP5ybyxyQJQqtgmPXhhTR8Dsvnrk3xUvzEiJZVqRLtfkldGFXmYFKA29edbU5E7 HUY8QhisQYUOEA+iUi9xrHDgdIiD1UAE590Ch26KmGrL9LOLCfw+hkaX1ttFii/YznIS asXWos6jdQu33RTKMNV6LzkjWqClQqmMOAGK+9TIdZl6pXbepdlCpkOTlL7w1KZvvxl/ Ds0dWISB+1daqlD1UZpR2N3f2JnU2QIkk72itiW3w2i+w4TSe16U2e8qf99zECT2zqNj 1IuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from; bh=rOGJnW1Y3sstBbNLAHZIrTq5TeNI341gGvKrgGutEOM=; fh=VoGqLvE3eVgrW9BUjWW+8KJgnCsKjRqUPI6GO5ZCyVo=; b=0NWqCu5nnPE7FofT1xp4w4/fOCcR2udNRKAUZeny+SoOg2kfGIZaFRtrY22GLuVDNO rHfNlbZo460MPeXWI+tJKNdqIIldI7EzW+V1nlReoIVlrdtV/UlgwbXxwfGkY74q/mzA Q2iqxpKoKslNn/M0q5O4OoyILWaYBH9V7Jlr/Xh9iDP1wxH303L7H7buZ1QezuQ4nmJv pijqJ8WbtgCfO1NGJSDqEosBxT7w7ho2n321dfsXwtRdk14/m/3se2HZZ/dHe+xAhbnR LNGGKDUJml32/uFpQ4XhuA6f0PRTSbJ/UYQdefNDqiFNZN8GK9KfqIbg0TZ24uQNuu9+ p7ZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=christina-quast.de); spf=pass (google.com: domain of linux-kernel+bounces-48664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48664-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWSorC+bIrcy0AU8u3Bb4ShwLJVWesoUQnji/qh6vI21pH9HT6spHH8L6Evhbuq8swgR/N9OCUKz3gzMAbAw/krTc68Ce4hesIoGYNqoA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o2-20020a0cfa82000000b0068c552de773si30928qvn.29.2024.02.01.10.12.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:12:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=christina-quast.de); spf=pass (google.com: domain of linux-kernel+bounces-48664-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48664-linux.lists.archive=gmail.com@vger.kernel.org" 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 4C86E1C2A3DF for ; Thu, 1 Feb 2024 18:11:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38DCD12E1F0; Thu, 1 Feb 2024 18:07:21 +0000 (UTC) Received: from mail.someserver.de (mail.someserver.de [116.202.193.223]) (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 92BD912D162; Thu, 1 Feb 2024 18:07:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.202.193.223 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810840; cv=none; b=pkILYfYFNi0HBtzkjay0rnbJ49sWc9EiexE1DD7dIAD1mP6LVy2qKllt2t8B6LPWYikpQuwaBc85tJhBlokfX7Qy6cBwjVWFNzU4jhf9x/3WEOhZovTcs3va2vn91zNqiaH+8Z+6YzTtT05+qR19H6ANVQ9rOlHcprWgbWbGAmM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706810840; c=relaxed/simple; bh=lj9jzLLyVHFhew0Zi2auFkzyMGCjvKyZGt3bltSvs9k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k4VGjZ2pnk5iCCMCGeMU/0p8uDuMlUNDG+fSbj1/PQD184tSW0/7JrDGfNpzKZ5e6So9D27to0iNNLujv5e8d4y/29D/G7ZW3YPjsOJ6qLgouAXGOQh+Yqpz6hMXcA02pCG4k7IwLSi+e7Bm/y0QZ3M6EUsPGDPraGB1X2T1pJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=christina-quast.de; spf=pass smtp.mailfrom=christina-quast.de; arc=none smtp.client-ip=116.202.193.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=christina-quast.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=christina-quast.de Received: from localhost (unknown [195.162.191.218]) by mail.someserver.de (Postfix) with ESMTPSA id 8B6DAA2250; Thu, 1 Feb 2024 19:07:15 +0100 (CET) From: Christina Quast Date: Thu, 01 Feb 2024 19:06:59 +0100 Subject: [PATCH v2 2/3] rust: phy: add some phy_driver and genphy_ functions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240201-rockchip-rust-phy_depend-v2-2-c5fa4faab924@christina-quast.de> References: <20240201-rockchip-rust-phy_depend-v2-0-c5fa4faab924@christina-quast.de> In-Reply-To: <20240201-rockchip-rust-phy_depend-v2-0-c5fa4faab924@christina-quast.de> To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , FUJITA Tomonori , Trevor Gross , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiko Stuebner Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, Christina Quast X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706810819; l=2422; i=contact@christina-quast.de; s=20240130; h=from:subject:message-id; bh=lj9jzLLyVHFhew0Zi2auFkzyMGCjvKyZGt3bltSvs9k=; b=aBY8aB9sq9C6dAXsUFZ7GKm0DaKOL3Rg4HPRhXog0o3VGGiSAUmMpGA4nPU0r6SNJlN/kCQ8Q 6lt+pqrQgCmB3oQRdIWJxLCdbPCslYHVrYtUjsrYQoPoH+xjpDn+Imd X-Developer-Key: i=contact@christina-quast.de; a=ed25519; pk=aoQfinjbnr265vCkIZdYteLDcmIqLBhY1m74WfFUU9E= Those functions are need for the rockchip_rust.rs implementation. Added functions: genphy_config_aneg config_init Getter functions for mdix and speed. Signed-off-by: Christina Quast --- rust/kernel/net/phy.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs index e457b3c7cb2f..373a4d358e9f 100644 --- a/rust/kernel/net/phy.rs +++ b/rust/kernel/net/phy.rs @@ -95,6 +95,22 @@ pub fn phy_id(&self) -> u32 { unsafe { (*phydev).phy_id } } + /// Gets the current crossover of the PHY. + pub fn mdix(&self) -> u8 { + let phydev = self.0.get(); + // SAFETY: The struct invariant ensures that we may access + // this field without additional synchronization. + unsafe { (*phydev).mdix } + } + + /// Gets the speed of the PHY. + pub fn speed(&mut self) -> u32 { + let phydev = self.0.get(); + // SAFETY: The struct invariant ensures that we may access + // this field without additional synchronization. + unsafe { (*phydev).speed as u32 } + } + /// Gets the state of PHY state machine states. pub fn state(&self) -> DeviceState { let phydev = self.0.get(); @@ -300,6 +316,15 @@ pub fn genphy_read_abilities(&mut self) -> Result { // So it's just an FFI call. to_result(unsafe { bindings::genphy_read_abilities(phydev) }) } + + /// Writes BMCR + pub fn genphy_config_aneg(&mut self) -> Result { + let phydev = self.0.get(); + // SAFETY: `phydev` is pointing to a valid object by the type invariant of `Self`. + // So it's just an FFI call. + // second param = false => autoneg not requested + to_result(unsafe { bindings::__genphy_config_aneg(phydev, false) }) + } } /// Defines certain other features this PHY supports (like interrupts). @@ -583,6 +608,12 @@ fn soft_reset(_dev: &mut Device) -> Result { Err(code::ENOTSUPP) } + /// Called to initialize the PHY, + /// including after a reset + fn config_init(_dev: &mut Device) -> Result { + Err(code::ENOTSUPP) + } + /// Probes the hardware to determine what abilities it has. fn get_features(_dev: &mut Device) -> Result { Err(code::ENOTSUPP) -- 2.43.0