21 #include "pedigree/kernel/Log.h" 22 #include "pedigree/kernel/processor/PhysicalMemoryManager.h" 23 #include "pedigree/kernel/processor/Processor.h" 24 #include "pedigree/kernel/processor/VirtualAddressSpace.h" 26 Prcm Prcm::m_Instance;
28 Prcm::Prcm() : m_Base(
"PRCM Module")
54 ERROR(
"PRCM: Not initialised");
61 uint32_t bit = 1 << clock;
64 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
66 vaddr += CM_CLKSEL_PER;
67 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
70 uint32_t val = *clksel;
71 if ((which == FCLK_32K) && (val & bit))
73 else if ((which == SYS_CLK) && (!(val & bit)))
82 ERROR(
"PRCM: Not initialised");
86 uint32_t bit = 1 << clock;
87 uint32_t
set = which << clock;
98 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
100 vaddr += CM_CLKSEL_CORE;
101 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
104 uint32_t val = *clksel;
114 ERROR(
"PRCM: Not initialised");
121 uint32_t bit = 1 << clock;
124 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
126 vaddr += CM_FCLKEN_PER;
127 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
130 uint32_t val = *clksel;
131 if ((!enabled) && (val & bit))
133 else if (enabled && (!(val & bit)))
142 ERROR(
"PRCM: Not initialised");
149 uint32_t bit = 1 << clock;
152 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
154 vaddr += CM_ICLKEN_PER;
155 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
158 uint32_t val = *clksel;
159 if ((!enabled) && (val & bit))
161 else if (enabled && (!(val & bit)))
170 ERROR(
"PRCM: Not initialised");
175 uint32_t bit = 1 << clock;
178 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
181 vaddr += CM_FCLKEN1_CORE;
183 vaddr += CM_FCLKEN3_CORE;
186 WARNING(
"PRCM: Invalid functional clock enable bank (CORE domain)");
189 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
192 uint32_t val = *clksel;
193 if ((!enabled) && (val & bit))
195 else if (enabled && (!(val & bit)))
204 ERROR(
"PRCM: Not initialised");
209 uint32_t bit = 1 << clock;
212 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
215 vaddr += CM_ICLKEN1_CORE;
217 vaddr += CM_ICLKEN3_CORE;
220 WARNING(
"PRCM: Invalid interface clock enable bank (CORE domain)");
223 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
226 uint32_t val = *clksel;
227 if ((!enabled) && (val & bit))
229 else if (enabled && (!(val & bit)))
238 ERROR(
"PRCM: Not initialised");
243 uint32_t bit = 1 << clock;
246 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
249 vaddr += CM_IDLEST1_CORE;
251 vaddr += CM_IDLEST3_CORE;
254 WARNING(
"PRCM: Invalid idle status bank (CORE domain)");
257 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
262 while (*clksel & bit)
265 while (!(*clksel & bit))
273 ERROR(
"PRCM: Not initialised");
278 uint32_t bit = 1 << clock;
281 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
282 vaddr += Clock_Control_Reg_CM;
284 vaddr += CM_IDLEST_CKGEN;
286 vaddr += CM_IDLEST2_CKGEN;
289 WARNING(
"PRCM: Invalid idle status bank (CORE domain)");
292 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
298 while (!(*clksel & bit))
303 while (*clksel & bit)
312 ERROR(
"PRCM: Not initialised");
317 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
318 vaddr += Clock_Control_Reg_CM;
320 vaddr += CM_CLKSEL1_PLL;
322 vaddr += CM_CLKSEL2_PLL;
324 vaddr += CM_CLKSEL3_PLL;
326 vaddr += CM_CLKSEL4_PLL;
328 vaddr += CM_CLKSEL5_PLL;
329 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
339 ERROR(
"PRCM: Not initialised");
344 uintptr_t vaddr =
reinterpret_cast<uintptr_t
>(m_Base.virtualAddress());
345 vaddr += Clock_Control_Reg_CM;
347 vaddr += CM_CLKEN_PLL;
349 vaddr += CM_CLKEN2_PLL;
352 WARNING(
"PRCM: Invalid interface clock enable bank (CORE domain)");
355 volatile uint32_t *clksel =
reinterpret_cast<volatile uint32_t *
>(vaddr);
static PhysicalMemoryManager & instance()
void WaitPllIdleStatus(size_t n, size_t clock, bool waitForOn)
void SetClockPLL(size_t n, size_t value)
void SetIfaceClockPER(size_t clock, bool enabled)
static const size_t continuous
void SelectClockPLL(size_t n, size_t value)
void SetFuncClockCORE(size_t n, size_t clock, bool enabled)
void SetFuncClockPER(size_t clock, bool enabled)
void initialise(uintptr_t base)
static const size_t Write
void SelectClockCORE(size_t clock, Clock which)
static const size_t KernelMode
void WaitCoreIdleStatus(size_t n, size_t clock, bool waitForOn)
void SetIfaceClockCORE(size_t n, size_t clock, bool enabled)
void SelectClockPER(size_t clock, Clock which)