The Pedigree Project  0.1
Prcm.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "pedigree/kernel/processor/MemoryRegion.h"
21 #include "pedigree/kernel/processor/types.h"
22 
27 class Prcm
28 {
29  public:
30  Prcm();
31  virtual ~Prcm();
32 
33  static Prcm &instance()
34  {
35  return m_Instance;
36  }
37 
38  enum Clock
39  {
40  FCLK_32K = 0,
41  SYS_CLK = 1,
42 
43  L3_CLK_DIV1 = 1,
44  L3_CLK_DIV2 = 2,
45  };
46 
47  enum ModuleBases
48  {
49  IVA2_CM = 0x0000,
50  OCP_System_Reg_CM = 0x0800,
51  MPU_CM = 0x0900,
52  CORE_CM = 0x0A00,
53  SGX_CM = 0x0B00,
54  WKUP_CM = 0x0C00,
55  Clock_Control_Reg_CM = 0x0D00,
56  DSS_CM = 0x0E00,
57  CAM_CM = 0x0F00,
58  PER_CM = 0x1000,
59  EMU_CM = 0x1100,
60  Global_Reg_CM = 0x1200,
61  NEON_CM = 0x1300,
62  USBHOST_CM = 0x1400,
63  };
64 
65  enum Registers_PER
66  {
67  CM_FCLKEN_PER = 0x00, // RW
68  CM_ICLKEN_PER = 0x10, // RW
69  CM_IDLEST_PER = 0x20, // R
70  CM_AUTOIDLE_PER = 0x30, // RW
71  CM_CLKSEL_PER = 0x40, // RW
72  CM_SLEEPDEP_PER = 0x44, // RW
73  CM_CLKSTCRL_PER = 0x48, // RW
74  CM_CLKSTST_PER = 0x4C, // R
75  };
76 
77  enum Register_CORE
78  {
79  CM_FCLKEN1_CORE = 0x00, // RW
80  CM_FCLKEN3_CORE = 0x08, // RW
81  CM_ICLKEN1_CORE = 0x10, // RW
82  CM_ICLKEN3_CORE = 0x18, // RW
83  CM_IDLEST1_CORE = 0x20, // R
84  CM_IDLEST3_CORE = 0x28, // R
85  CM_AUTOIDLE1_CORE = 0x30, // RW
86  CM_AUTOIDLE3_CORE = 0x38, // RW
87  CM_CLKSEL_CORE = 0x40, // RW
88  CM_CLKSTCTRL_CORE = 0x48, // RW
89  CM_CLKSTST_CORE = 0x4C, // R
90  };
91 
92  enum Registers_PLL
93  {
94  CM_CLKEN_PLL = 0x00, // RW
95  CM_CLKEN2_PLL = 0x04, // RW
96  CM_IDLEST_CKGEN = 0x20, // R
97  CM_IDLEST2_CKGEN = 0x24, // R
98  CM_AUTOIDLE_PLL = 0x30, // RW
99  CM_AUTOIDLE2_PLL = 0x34, // RW
100  CM_CLKSEL1_PLL = 0x40, // RW
101  CM_CLKSEL2_PLL = 0x44, // RW
102  CM_CLKSEL3_PLL = 0x48, // RW
103  CM_CLKSEL4_PLL = 0x4C, // RW
104  CM_CLKSEL5_PLL = 0x50, // RW
105  CM_CLKOUT_CTRL = 0x70, // RW
106  };
107 
109  void initialise(uintptr_t base);
110 
112  void SelectClockPER(size_t clock, Clock which);
113 
115  void SetFuncClockPER(size_t clock, bool enabled);
116 
118  void SetIfaceClockPER(size_t clock, bool enabled);
119 
121  void SetFuncClockCORE(size_t n, size_t clock, bool enabled);
122 
124  void SetIfaceClockCORE(size_t n, size_t clock, bool enabled);
125 
127  void WaitCoreIdleStatus(size_t n, size_t clock, bool waitForOn);
128 
130  void WaitPllIdleStatus(size_t n, size_t clock, bool waitForOn);
131 
133  void SelectClockCORE(size_t clock, Clock which);
134 
136  void SetClockPLL(size_t n, size_t value);
137 
140  void SelectClockPLL(size_t n, size_t value);
141 
142  private:
143  static Prcm m_Instance;
144 
145  MemoryRegion m_Base;
146 };
void WaitPllIdleStatus(size_t n, size_t clock, bool waitForOn)
Definition: Prcm.cc:269
void SetClockPLL(size_t n, size_t value)
Definition: Prcm.cc:335
void SetIfaceClockPER(size_t clock, bool enabled)
Definition: Prcm.cc:138
void SelectClockPLL(size_t n, size_t value)
Definition: Prcm.cc:308
void SetFuncClockCORE(size_t n, size_t clock, bool enabled)
Definition: Prcm.cc:166
void SetFuncClockPER(size_t clock, bool enabled)
Definition: Prcm.cc:110
void initialise(uintptr_t base)
Definition: Prcm.cc:36
void SelectClockCORE(size_t clock, Clock which)
Definition: Prcm.cc:78
Special memory entity in the kernel's virtual address space.
Definition: MemoryRegion.h:35
void WaitCoreIdleStatus(size_t n, size_t clock, bool waitForOn)
Definition: Prcm.cc:234
Definition: Prcm.h:27
void SetIfaceClockCORE(size_t n, size_t clock, bool enabled)
Definition: Prcm.cc:200
void SelectClockPER(size_t clock, Clock which)
Definition: Prcm.cc:50