mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 10:46:25 +00:00
platform: add Guard utils for Clock/Reset/Power
These utilities simplify the control of clocks, resets, and power domains from within the platform driver. This is needed when driving a low-level device directly from the platform driver, for example for driving the mbox mechanism to access the system-control processor of the PinePhone.
This commit is contained in:
parent
add4990044
commit
eb6a745a18
@ -60,6 +60,13 @@ class Driver::Clock : Clocks::Element, Interface
|
|||||||
|
|
||||||
void enable() { _switch.use(); }
|
void enable() { _switch.use(); }
|
||||||
void disable() { _switch.unuse(); }
|
void disable() { _switch.unuse(); }
|
||||||
|
|
||||||
|
struct Guard : Genode::Noncopyable
|
||||||
|
{
|
||||||
|
Clock &_clock;
|
||||||
|
Guard(Clock &clock) : _clock(clock) { _clock.enable(); }
|
||||||
|
~Guard() { _clock.disable(); }
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +51,13 @@ class Driver::Power : Powers::Element, Interface
|
|||||||
|
|
||||||
void on() { _switch.use(); }
|
void on() { _switch.use(); }
|
||||||
void off() { _switch.unuse(); }
|
void off() { _switch.unuse(); }
|
||||||
|
|
||||||
|
struct Guard : Genode::Noncopyable
|
||||||
|
{
|
||||||
|
Power &_power;
|
||||||
|
Guard(Power &power) : _power(power) { _power.on(); }
|
||||||
|
~Guard() { _power.off(); }
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _POWER_H_ */
|
#endif /* _POWER_H_ */
|
||||||
|
@ -51,6 +51,13 @@ class Driver::Reset : Resets::Element, Interface
|
|||||||
|
|
||||||
void deassert() { _switch.use(); }
|
void deassert() { _switch.use(); }
|
||||||
void assert() { _switch.unuse(); }
|
void assert() { _switch.unuse(); }
|
||||||
|
|
||||||
|
struct Guard : Genode::Noncopyable
|
||||||
|
{
|
||||||
|
Reset &_reset;
|
||||||
|
Guard(Reset &reset) : _reset(reset) { _reset.deassert(); }
|
||||||
|
~Guard() { _reset.assert(); }
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _RESET_H_ */
|
#endif /* _RESET_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user