rockchip_pm/variants/
_macros.rs

1#[macro_export(local_inner_macros)]
2macro_rules! map {
3    // 空 map
4    () => {
5        {
6            ::alloc::collections::BTreeMap::new()
7        }
8    };
9    // 支持多个键值对
10    ( $( $key:expr => $value:expr ),+ $(,)? ) => {{
11        let mut map = ::alloc::collections::BTreeMap::new();
12        $( map.insert($key.into(), $value); )*
13        map
14    }};
15}
16
17/// Define power domain constants with documentation
18macro_rules! define_power_domains {
19    (
20        $(
21            $(#[$meta:meta])*
22            $name:ident = $id:expr
23        ),* $(,)?
24    ) => {
25        $(
26            $(#[$meta])*
27            pub const $name: PowerDomain = PowerDomain($id);
28        )*
29    };
30}
31
32macro_rules! bit {
33    ($n:expr) => {
34        (1 << $n)
35    };
36    () => {};
37}
38
39// Make sure RockchipDomainInfo is in scope
40use super::RockchipDomainInfo;
41
42#[allow(clippy::too_many_arguments)]
43pub fn domain_m_o_r(
44    name: &'static str,
45    pwr_offset: u32,
46    pwr: i32,
47    status: i32,
48    mem_offset: u32,
49    mem_status: i32,
50    repair_status: i32,
51    req_offset: u32,
52    req: i32,
53    idle: i32,
54    ack: i32,
55    wakeup: bool,
56    keepon: bool,
57) -> RockchipDomainInfo {
58    RockchipDomainInfo {
59        name,
60        pwr_offset,
61        pwr_w_mask: (pwr << 16),
62        pwr_mask: pwr,
63        status_mask: status,
64        mem_offset,
65        mem_status_mask: mem_status,
66        repair_status_mask: repair_status,
67        req_offset,
68        req_w_mask: (req << 16),
69        req_mask: req,
70        idle_mask: idle,
71        ack_mask: ack,
72        active_wakeup: wakeup,
73        keepon_startup: keepon,
74        ..Default::default()
75    }
76}