libnx  v4.8.0
pcv.h
Go to the documentation of this file.
1 /**
2  * @file pcv.h
3  * @brief PCV service IPC wrapper.
4  * @author SciresM
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../sf/service.h"
10 
11 typedef enum {
12  PcvModule_CpuBus = 0,
13  PcvModule_GPU = 1,
14  PcvModule_I2S1 = 2,
15  PcvModule_I2S2 = 3,
16  PcvModule_I2S3 = 4,
17  PcvModule_PWM = 5,
18  PcvModule_I2C1 = 6,
19  PcvModule_I2C2 = 7,
20  PcvModule_I2C3 = 8,
21  PcvModule_I2C4 = 9,
22  PcvModule_I2C5 = 10,
23  PcvModule_I2C6 = 11,
24  PcvModule_SPI1 = 12,
25  PcvModule_SPI2 = 13,
26  PcvModule_SPI3 = 14,
27  PcvModule_SPI4 = 15,
28  PcvModule_DISP1 = 16,
29  PcvModule_DISP2 = 17,
30  PcvModule_ISP = 18,
31  PcvModule_VI = 19,
32  PcvModule_SDMMC1 = 20,
33  PcvModule_SDMMC2 = 21,
34  PcvModule_SDMMC3 = 22,
35  PcvModule_SDMMC4 = 23,
36  PcvModule_OWR = 24,
37  PcvModule_CSITE = 25,
38  PcvModule_TSEC = 26,
39  PcvModule_MSELECT = 27,
40  PcvModule_HDA2CODEC_2X = 28,
41  PcvModule_ACTMON = 29,
42  PcvModule_I2C_SLOW = 30,
43  PcvModule_SOR1 = 31,
44  PcvModule_SATA = 32,
45  PcvModule_HDA = 33,
46  PcvModule_XUSB_CORE_HOST = 34,
47  PcvModule_XUSB_FALCON = 35,
48  PcvModule_XUSB_FS = 36,
49  PcvModule_XUSB_CORE_DEV = 37,
50  PcvModule_XUSB_SS_HOSTDEV = 38,
51  PcvModule_UARTA = 39,
52  PcvModule_UARTB = 40,
53  PcvModule_UARTC = 41,
54  PcvModule_UARTD = 42,
55  PcvModule_HOST1X = 43,
56  PcvModule_ENTROPY = 44,
57  PcvModule_SOC_THERM = 45,
58  PcvModule_VIC = 46,
59  PcvModule_NVENC = 47,
60  PcvModule_NVJPG = 48,
61  PcvModule_NVDEC = 49,
62  PcvModule_QSPI = 50,
63  PcvModule_VI_I2C = 51,
64  PcvModule_TSECB = 52,
65  PcvModule_APE = 53,
66  PcvModule_ACLK = 54,
67  PcvModule_UARTAPE = 55,
68  PcvModule_EMC = 56,
69  PcvModule_PLLE0_0 = 57,
70  PcvModule_PLLE0_1 = 58,
71  PcvModule_DSI = 59,
72  PcvModule_MAUD = 60,
73  PcvModule_DPAUX1 = 61,
74  PcvModule_MIPI_CAL = 62,
75  PcvModule_UART_FST_MIPI_CAL = 63,
76  PcvModule_OSC = 64,
77  PcvModule_SCLK = 65,
78  PcvModule_SOR_SAFE = 66,
79  PcvModule_XUSB_SS = 67,
80  PcvModule_XUSB_HOST = 68,
81  PcvModule_XUSB_DEV = 69,
82  PcvModule_EXTPERIPH1 = 70,
83  PcvModule_AHUB = 71,
84  PcvModule_HDA2HDMICODEC = 72,
85  PcvModule_PLLP5 = 73,
86  PcvModule_USBD = 74,
87  PcvModule_USB2 = 75,
88  PcvModule_PCIE = 76,
89  PcvModule_AFI = 77,
90  PcvModule_PCIEXCLK = 78,
91  PcvModule_PEX_USB_UPHY = 79,
92  PcvModule_XUSB_PADCTL = 80,
93  PcvModule_APBDMA = 81,
94  PcvModule_USB2_TRK = 82,
95  PcvModule_PLLE0_2 = 83,
96  PcvModule_PLLE0_3 = 84,
97  PcvModule_CEC = 85,
98  PcvModule_EXTPERIPH2 = 86,
99  PcvModule_Count // Not a real module, used to know how many modules there are.
100 } PcvModule;
101 
102 /// Module id returned by [8.0.0+] pcv services
103 /// See also: https://switchbrew.org/wiki/PCV_services#Modules
104 typedef enum {
105  PcvModuleId_CpuBus = 0x40000001,
106  PcvModuleId_GPU = 0x40000002,
107  PcvModuleId_I2S1 = 0x40000003,
108  PcvModuleId_I2S2 = 0x40000004,
109  PcvModuleId_I2S3 = 0x40000005,
110  PcvModuleId_PWM = 0x40000006,
111  PcvModuleId_I2C1 = 0x02000001,
112  PcvModuleId_I2C2 = 0x02000002,
113  PcvModuleId_I2C3 = 0x02000003,
114  PcvModuleId_I2C4 = 0x02000004,
115  PcvModuleId_I2C5 = 0x02000005,
116  PcvModuleId_I2C6 = 0x02000006,
117  PcvModuleId_SPI1 = 0x07000000,
118  PcvModuleId_SPI2 = 0x07000001,
119  PcvModuleId_SPI3 = 0x07000002,
120  PcvModuleId_SPI4 = 0x07000003,
121  PcvModuleId_DISP1 = 0x40000011,
122  PcvModuleId_DISP2 = 0x40000012,
123  PcvModuleId_ISP = 0x40000013,
124  PcvModuleId_VI = 0x40000014,
125  PcvModuleId_SDMMC1 = 0x40000015,
126  PcvModuleId_SDMMC2 = 0x40000016,
127  PcvModuleId_SDMMC3 = 0x40000017,
128  PcvModuleId_SDMMC4 = 0x40000018,
129  PcvModuleId_OWR = 0x40000019,
130  PcvModuleId_CSITE = 0x4000001A,
131  PcvModuleId_TSEC = 0x4000001B,
132  PcvModuleId_MSELECT = 0x4000001C,
133  PcvModuleId_HDA2CODEC_2X = 0x4000001D,
134  PcvModuleId_ACTMON = 0x4000001E,
135  PcvModuleId_I2C_SLOW = 0x4000001F,
136  PcvModuleId_SOR1 = 0x40000020,
137  PcvModuleId_SATA = 0x40000021,
138  PcvModuleId_HDA = 0x40000022,
139  PcvModuleId_XUSB_CORE_HOST = 0x40000023,
140  PcvModuleId_XUSB_FALCON = 0x40000024,
141  PcvModuleId_XUSB_FS = 0x40000025,
142  PcvModuleId_XUSB_CORE_DEV = 0x40000026,
143  PcvModuleId_XUSB_SS_HOSTDEV = 0x40000027,
144  PcvModuleId_UARTA = 0x03000001,
145  PcvModuleId_UARTB = 0x35000405,
146  PcvModuleId_UARTC = 0x3500040F,
147  PcvModuleId_UARTD = 0x37000001,
148  PcvModuleId_HOST1X = 0x4000002C,
149  PcvModuleId_ENTROPY = 0x4000002D,
150  PcvModuleId_SOC_THERM = 0x4000002E,
151  PcvModuleId_VIC = 0x4000002F,
152  PcvModuleId_NVENC = 0x40000030,
153  PcvModuleId_NVJPG = 0x40000031,
154  PcvModuleId_NVDEC = 0x40000032,
155  PcvModuleId_QSPI = 0x40000033,
156  PcvModuleId_VI_I2C = 0x40000034,
157  PcvModuleId_TSECB = 0x40000035,
158  PcvModuleId_APE = 0x40000036,
159  PcvModuleId_ACLK = 0x40000037,
160  PcvModuleId_UARTAPE = 0x40000038,
161  PcvModuleId_EMC = 0x40000039,
162  PcvModuleId_PLLE0_0 = 0x4000003A,
163  PcvModuleId_PLLE0_1 = 0x4000003B,
164  PcvModuleId_DSI = 0x4000003C,
165  PcvModuleId_MAUD = 0x4000003D,
166  PcvModuleId_DPAUX1 = 0x4000003E,
167  PcvModuleId_MIPI_CAL = 0x4000003F,
168  PcvModuleId_UART_FST_MIPI_CAL = 0x40000040,
169  PcvModuleId_OSC = 0x40000041,
170  PcvModuleId_SCLK = 0x40000042,
171  PcvModuleId_SOR_SAFE = 0x40000043,
172  PcvModuleId_XUSB_SS = 0x40000044,
173  PcvModuleId_XUSB_HOST = 0x40000045,
174  PcvModuleId_XUSB_DEV = 0x40000046,
175  PcvModuleId_EXTPERIPH1 = 0x40000047,
176  PcvModuleId_AHUB = 0x40000048,
177  PcvModuleId_HDA2HDMICODEC = 0x40000049,
178  PcvModuleId_PLLP5 = 0x4000004A,
179  PcvModuleId_USBD = 0x4000004B,
180  PcvModuleId_USB2 = 0x4000004C,
181  PcvModuleId_PCIE = 0x4000004D,
182  PcvModuleId_AFI = 0x4000004E,
183  PcvModuleId_PCIEXCLK = 0x4000004F,
184  PcvModuleId_PEX_USB_UPHY = 0x40000050,
185  PcvModuleId_XUSB_PADCTL = 0x40000051,
186  PcvModuleId_APBDMA = 0x40000052,
187  PcvModuleId_USB2_TRK = 0x40000053,
188  PcvModuleId_PLLE0_2 = 0x40000054,
189  PcvModuleId_PLLE0_3 = 0x40000055,
190  PcvModuleId_CEC = 0x40000056,
191  PcvModuleId_EXTPERIPH2 = 0x40000057,
192 } PcvModuleId;
193 
194 // Clock list type returned by GetPossibleClockRates
195 typedef enum {
196  PcvClockRatesListType_Invalid = 0,
197  PcvClockRatesListType_Discrete = 1,
198  PcvClockRatesListType_Range = 2,
199 } PcvClockRatesListType;
200 
201 /// Initialize pcv.
203 
204 /// Exit pcv.
205 void pcvExit(void);
206 
207 /// Gets the Service object for the actual pcv service session.
209 
210 Result pcvGetModuleId(PcvModuleId *module_id, PcvModule module);
211 
212 /// Only available on [1.0.0-7.0.1].
213 Result pcvGetClockRate(PcvModule module, u32 *out_hz);
214 /// Only available on [1.0.0-7.0.1].
215 Result pcvSetClockRate(PcvModule module, u32 hz);
216 /// Only available on [1.0.0-7.0.1].
217 Result pcvSetVoltageEnabled(u32 power_domain, bool state);
218 /// Only available on [1.0.0-7.0.1].
219 Result pcvGetVoltageEnabled(bool *isEnabled, u32 power_domain);
220 /// Only available on [1.0.0-7.0.1].
221 Result pcvGetPossibleClockRates(PcvModule module, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count);
Result pcvGetPossibleClockRates(PcvModule module, u32 *rates, s32 max_count, PcvClockRatesListType *out_type, s32 *out_count)
Only available on [1.0.0-7.0.1].
Result pcvGetVoltageEnabled(bool *isEnabled, u32 power_domain)
Only available on [1.0.0-7.0.1].
Result pcvGetClockRate(PcvModule module, u32 *out_hz)
Only available on [1.0.0-7.0.1].
Service * pcvGetServiceSession(void)
Gets the Service object for the actual pcv service session.
void pcvExit(void)
Exit pcv.
Result pcvSetVoltageEnabled(u32 power_domain, bool state)
Only available on [1.0.0-7.0.1].
Result pcvInitialize(void)
Initialize pcv.
Result pcvSetClockRate(PcvModule module, u32 hz)
Only available on [1.0.0-7.0.1].
PcvModuleId
Module id returned by [8.0.0+] pcv services See also: https://switchbrew.org/wiki/PCV_services#Module...
Definition: pcv.h:104
Service object structure.
Definition: service.h:14
u32 Result
Function error code result type.
Definition: types.h:44
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21