[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240201-rockchip-rust-phy_depend-v2-2-c5fa4faab924@christina-quast.de>
Date: Thu, 01 Feb 2024 19:06:59 +0100
From: Christina Quast <contact@...istina-quast.de>
To: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...sung.com>,
Alice Ryhl <aliceryhl@...gle.com>,
FUJITA Tomonori <fujita.tomonori@...il.com>,
Trevor Gross <tmgross@...ch.edu>, Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Heiko Stuebner <heiko@...ech.de>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-rockchip@...ts.infradead.org,
Christina Quast <contact@...istina-quast.de>
Subject: [PATCH v2 2/3] rust: phy: add some phy_driver and genphy_
functions
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 <contact@...istina-quast.de>
---
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
Powered by blists - more mailing lists