Skip to main content

RockchipPM

Struct RockchipPM 

Source
pub struct RockchipPM { /* private fields */ }
Expand description

Rockchip Power Management Unit driver

This structure provides control over power domains for Rockchip SoCs, allowing dynamic power gating of various IP blocks like GPU, NPU, VCODEC, etc.

Implementations§

Source§

impl RockchipPM

Source

pub fn new(base: NonNull<u8>, board: RkBoard) -> Self

Create a new RockchipPM driver instance

§Arguments
  • base - Base address of the PMU registers
  • board - The specific board type (RK3588 or RK3568)
§Example
use rockchip_pm::{RockchipPM, RkBoard};
use core::ptr::NonNull;

let base = unsafe { NonNull::new_unchecked(0xfd5d8000 as *mut u8) };
let pm = RockchipPM::new(base, RkBoard::Rk3588);
Source

pub fn new_with_compatible(base: NonNull<u8>, compatible: &str) -> Self

Create a new RockchipPM driver instance using device tree compatible string

§Arguments
  • base - Base address of the PMU registers
  • compatible - Device tree compatible string (e.g., “rockchip,rk3588-power-controller”)
§Panics

Panics if the compatible string is not supported

§Example
use rockchip_pm::RockchipPM;
use core::ptr::NonNull;

let base = unsafe { NonNull::new_unchecked(0xfd5d8000 as *mut u8) };
let pm = RockchipPM::new_with_compatible(base, "rockchip,rk3588-power-controller");
Source

pub fn get_power_dowain_by_name(&self, name: &str) -> Option<PowerDomain>

Find a power domain by its name

§Arguments
  • name - Name of the power domain (e.g., “npu”, “gpu”, “vcodec”)
§Returns

Some(PowerDomain) if found, None otherwise

§Example
let domain = pm.get_power_dowain_by_name("npu");
assert_eq!(domain, Some(PowerDomain::NPU));
Source

pub fn power_domain_on(&mut self, domain: PowerDomain) -> PmResult<()>

Turn on the specified power domain

This function enables power to the specified domain, initializing the associated hardware blocks.

§Arguments
  • domain - The power domain to turn on
§Errors

Returns PmError::DomainNotFound if the domain does not exist Returns PmError::Timeout if the power domain fails to turn on within the timeout period

§Example
pm.power_domain_on(PowerDomain::NPU).unwrap();
Source

pub fn power_domain_off(&mut self, domain: PowerDomain) -> PmResult<()>

Turn off the specified power domain

This function cuts power to the specified domain, putting the associated hardware blocks into a low-power state.

§Arguments
  • domain - The power domain to turn off
§Errors

Returns PmError::DomainNotFound if the domain does not exist Returns PmError::Timeout if the power domain fails to turn off within the timeout period

§Example
pm.power_domain_off(PowerDomain::NPU).unwrap();

Trait Implementations§

Source§

impl DriverGeneric for RockchipPM

Source§

fn open(&mut self) -> Result<(), KError>

Source§

fn close(&mut self) -> Result<(), KError>

Source§

fn raw_any(&self) -> Option<&(dyn Any + 'static)>

Subtype casting support, returns subtype as &dyn Any
Source§

fn raw_any_mut(&mut self) -> Option<&mut (dyn Any + 'static)>

Subtype casting support, returns subtype as &mut dyn Any

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.