Lines Matching +full:get +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0
43 /// PHY drivers get duplex information from hardware and update the current state.
45 /// PHY is in full-duplex mode.
47 /// PHY is in half-duplex mode.
62 /// - Referencing a `phy_device` using this struct asserts that you are in
64 /// - This struct always has a valid `self.0.mdio.dev`.
71 // [`Driver::resume`] and [`Driver::suspend`] also are called where only one thread can access
82 /// - the pointer must point at a valid `phy_device`, and the caller
85 /// - `(*ptr).mdio.dev` must be a valid.
86 unsafe fn from_raw<'a>(ptr: *mut bindings::phy_device) -> &'a mut Self { in from_raw()
95 pub fn phy_id(&self) -> u32 { in phy_id()
96 let phydev = self.0.get(); in phy_id()
103 pub fn state(&self) -> DeviceState { in state()
104 let phydev = self.0.get(); in state()
126 pub fn is_link_up(&self) -> bool { in is_link_up()
132 let bit_field = unsafe { &(*self.0.get())._bitfield_1 }; in is_link_up()
133 bit_field.get(14, 1) == LINK_IS_UP in is_link_up()
136 /// Gets the current auto-negotiation configuration.
138 /// It returns true if auto-negotiation is enabled.
139 pub fn is_autoneg_enabled(&self) -> bool { in is_autoneg_enabled()
144 let bit_field = unsafe { &(*self.0.get())._bitfield_1 }; in is_autoneg_enabled()
145 bit_field.get(13, 1) == u64::from(bindings::AUTONEG_ENABLE) in is_autoneg_enabled()
148 /// Gets the current auto-negotiation state.
150 /// It returns true if auto-negotiation is completed.
151 pub fn is_autoneg_completed(&self) -> bool { in is_autoneg_completed()
157 let bit_field = unsafe { &(*self.0.get())._bitfield_1 }; in is_autoneg_completed()
158 bit_field.get(15, 1) == AUTONEG_COMPLETED in is_autoneg_completed()
163 let phydev = self.0.get(); in set_speed()
171 let phydev = self.0.get(); in set_duplex()
184 pub fn read<R: reg::Register>(&mut self, reg: R) -> Result<u16> { in read()
189 pub fn write<R: reg::Register>(&mut self, reg: R, val: u16) -> Result { in write()
194 pub fn read_paged(&mut self, page: u16, regnum: u16) -> Result<u16> { in read_paged()
195 let phydev = self.0.get(); in read_paged()
208 let phydev = self.0.get(); in resolve_aneg_linkmode()
215 pub fn genphy_soft_reset(&mut self) -> Result { in genphy_soft_reset()
216 let phydev = self.0.get(); in genphy_soft_reset()
223 pub fn init_hw(&mut self) -> Result { in init_hw()
224 let phydev = self.0.get(); in init_hw()
230 /// Starts auto-negotiation.
231 pub fn start_aneg(&mut self) -> Result { in start_aneg()
232 let phydev = self.0.get(); in start_aneg()
239 pub fn genphy_resume(&mut self) -> Result { in genphy_resume()
240 let phydev = self.0.get(); in genphy_resume()
247 pub fn genphy_suspend(&mut self) -> Result { in genphy_suspend()
248 let phydev = self.0.get(); in genphy_suspend()
255 pub fn genphy_read_status<R: reg::Register>(&mut self) -> Result<u16> { in genphy_read_status()
260 pub fn genphy_update_link(&mut self) -> Result { in genphy_update_link()
261 let phydev = self.0.get(); in genphy_update_link()
268 pub fn genphy_read_lpa(&mut self) -> Result { in genphy_read_lpa()
269 let phydev = self.0.get(); in genphy_read_lpa()
276 pub fn genphy_read_abilities(&mut self) -> Result { in genphy_read_abilities()
277 let phydev = self.0.get(); in genphy_read_abilities()
285 fn as_ref(&self) -> &kernel::device::Device { in as_ref()
286 let phydev = self.0.get(); in as_ref()
315 unsafe extern "C" fn soft_reset_callback(phydev: *mut bindings::phy_device) -> c_int { in soft_reset_callback()
317 // SAFETY: This callback is called only in contexts in soft_reset_callback()
318 // where we hold `phy_device->lock`, so the accessors on in soft_reset_callback()
329 unsafe extern "C" fn probe_callback(phydev: *mut bindings::phy_device) -> c_int { in probe_callback()
331 // SAFETY: This callback is called only in contexts in probe_callback()
344 unsafe extern "C" fn get_features_callback(phydev: *mut bindings::phy_device) -> c_int { in get_features_callback()
346 // SAFETY: This callback is called only in contexts in get_features_callback()
347 // where we hold `phy_device->lock`, so the accessors on in get_features_callback()
358 unsafe extern "C" fn suspend_callback(phydev: *mut bindings::phy_device) -> c_int { in suspend_callback()
361 // `Device` are okay to call even though `phy_device->lock` in suspend_callback()
372 unsafe extern "C" fn resume_callback(phydev: *mut bindings::phy_device) -> c_int { in resume_callback()
375 // `Device` are okay to call even though `phy_device->lock` in resume_callback()
386 unsafe extern "C" fn config_aneg_callback(phydev: *mut bindings::phy_device) -> c_int { in config_aneg_callback()
388 // SAFETY: This callback is called only in contexts in config_aneg_callback()
389 // where we hold `phy_device->lock`, so the accessors on in config_aneg_callback()
400 unsafe extern "C" fn read_status_callback(phydev: *mut bindings::phy_device) -> c_int { in read_status_callback()
402 // SAFETY: This callback is called only in contexts in read_status_callback()
403 // where we hold `phy_device->lock`, so the accessors on in read_status_callback()
417 ) -> c_int { in match_phy_device_callback()
418 // SAFETY: This callback is called only in contexts in match_phy_device_callback()
419 // where we hold `phy_device->lock`, so the accessors on in match_phy_device_callback()
432 ) -> i32 { in read_mmd_callback()
434 // SAFETY: This callback is called only in contexts in read_mmd_callback()
435 // where we hold `phy_device->lock`, so the accessors on in read_mmd_callback()
452 ) -> i32 { in write_mmd_callback()
454 // SAFETY: This callback is called only in contexts in write_mmd_callback()
455 // where we hold `phy_device->lock`, so the accessors on in write_mmd_callback()
467 // SAFETY: This callback is called only in contexts in link_change_notify_callback()
468 // where we hold `phy_device->lock`, so the accessors on in link_change_notify_callback()
497 pub const fn create_phy_driver<T: Driver>() -> DriverVTable { in create_phy_driver()
577 /// This driver only works for PHYs with IDs which match this field.
582 fn soft_reset(_dev: &mut Device) -> Result { in soft_reset()
586 /// Sets up device-specific structures during discovery.
587 fn probe(_dev: &mut Device) -> Result { in probe()
592 fn get_features(_dev: &mut Device) -> Result { in get_features()
598 fn match_phy_device(_dev: &Device) -> bool { in match_phy_device()
602 /// Configures the advertisement and resets auto-negotiation
603 /// if auto-negotiation is enabled.
604 fn config_aneg(_dev: &mut Device) -> Result { in config_aneg()
609 fn read_status(_dev: &mut Device) -> Result<u16> { in read_status()
614 fn suspend(_dev: &mut Device) -> Result { in suspend()
619 fn resume(_dev: &mut Device) -> Result { in resume()
624 fn read_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16) -> Result<u16> { in read_mmd()
629 fn write_mmd(_dev: &mut Device, _devnum: u8, _regnum: u16, _val: u16) -> Result { in write_mmd()
648 // SAFETY: The only action allowed in a `Registration` instance is dropping it, which is safe to do
657 ) -> Result<Self> { in register()
665 bindings::phy_drivers_register(drivers[0].0.get(), drivers.len().try_into()?, module.0) in register()
677 bindings::phy_drivers_unregister(self.drivers[0].0.get(), self.drivers.len() as i32) in drop()
692 pub const fn new_with_exact_mask(id: u32) -> Self { in new_with_exact_mask()
700 pub const fn new_with_model_mask(id: u32) -> Self { in new_with_model_mask()
708 pub const fn new_with_vendor_mask(id: u32) -> Self { in new_with_vendor_mask()
716 pub const fn new_with_custom_mask(id: u32, mask: u32) -> Self { in new_with_custom_mask()
724 pub const fn new_with_driver<T: Driver>() -> Self { in new_with_driver()
728 /// Get the MDIO device's PHY ID.
729 pub const fn id(&self) -> u32 { in id()
733 /// Get the MDIO device's match mask.
734 pub const fn mask_as_int(&self) -> u32 { in mask_as_int()
738 // macro use only
740 pub const fn mdio_device_id(&self) -> bindings::mdio_device_id { in mdio_device_id()
763 const fn as_int(&self) -> u32 { in as_int()
840 /// fn init(module: &'static ::kernel::ThisModule) -> Result<Self> {
897 fn init(module: &'static $crate::ThisModule) -> Result<Self> {
899 // the `DRIVERS` static. The array is used only in the C side.