mb/google/nissa/var/rull: Add 6W and 15W DPTF parameters
[coreboot.git] / src / soc / intel / baytrail / iosf.c
blob21060eee1a640d1648cb269ced3cac73f7d85b8d
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <stdint.h>
4 #include <device/pci_ops.h>
5 #include <soc/iosf.h>
7 static inline void write_iosf_reg(int reg, uint32_t value)
9 pci_s_write_config32(IOSF_PCI_DEV, reg, value);
12 static inline uint32_t read_iosf_reg(int reg)
14 return pci_s_read_config32(IOSF_PCI_DEV, reg);
17 /* Common sequences for all the port accesses. */
18 uint32_t iosf_read_port(uint32_t cr, int reg)
20 cr |= IOSF_REG(reg) | IOSF_BYTE_EN;
21 write_iosf_reg(MCRX_REG, IOSF_REG_UPPER(reg));
22 write_iosf_reg(MCR_REG, cr);
23 return read_iosf_reg(MDR_REG);
26 void iosf_write_port(uint32_t cr, int reg, uint32_t val)
28 cr |= IOSF_REG(reg) | IOSF_BYTE_EN;
29 write_iosf_reg(MDR_REG, val);
30 write_iosf_reg(MCRX_REG, IOSF_REG_UPPER(reg));
31 write_iosf_reg(MCR_REG, cr);
34 #define IOSF_READ(port) \
35 (IOSF_OPCODE(IOSF_OP_READ_##port) | IOSF_PORT(IOSF_PORT_##port))
36 #define IOSF_WRITE(port) \
37 (IOSF_OPCODE(IOSF_OP_WRITE_##port) | IOSF_PORT(IOSF_PORT_##port))
39 uint32_t iosf_bunit_read(int reg)
41 return iosf_read_port(IOSF_READ(BUNIT), reg);
44 void iosf_bunit_write(int reg, uint32_t val)
46 iosf_write_port(IOSF_WRITE(BUNIT), reg, val);
49 uint32_t iosf_dunit_read(int reg)
51 return iosf_read_port(IOSF_READ(SYSMEMC), reg);
54 uint32_t iosf_dunit_ch0_read(int reg)
56 return iosf_dunit_read(reg);
59 uint32_t iosf_dunit_ch1_read(int reg)
61 uint32_t cr = IOSF_OPCODE(IOSF_OP_READ_SYSMEMC) |
62 IOSF_PORT(IOSF_PORT_DUNIT_CH1);
63 return iosf_read_port(cr, reg);
66 void iosf_dunit_write(int reg, uint32_t val)
68 iosf_write_port(IOSF_WRITE(SYSMEMC), reg, val);
71 uint32_t iosf_cunit_read(int reg)
73 return iosf_read_port(IOSF_READ(CUNIT), reg);
76 void iosf_cunit_write(int reg, uint32_t val)
78 iosf_write_port(IOSF_WRITE(CUNIT), reg, val);
81 uint32_t iosf_punit_read(int reg)
83 return iosf_read_port(IOSF_READ(PMC), reg);
86 void iosf_punit_write(int reg, uint32_t val)
88 iosf_write_port(IOSF_WRITE(PMC), reg, val);
91 uint32_t iosf_usbphy_read(int reg)
93 return iosf_read_port(IOSF_READ(USBPHY), reg);
96 void iosf_usbphy_write(int reg, uint32_t val)
98 iosf_write_port(IOSF_WRITE(USBPHY), reg, val);
101 uint32_t iosf_ushphy_read(int reg)
103 return iosf_read_port(IOSF_READ(USHPHY), reg);
106 void iosf_ushphy_write(int reg, uint32_t val)
108 iosf_write_port(IOSF_WRITE(USHPHY), reg, val);
111 uint32_t iosf_lpss_read(int reg)
113 return iosf_read_port(IOSF_READ(LPSS), reg);
116 void iosf_lpss_write(int reg, uint32_t val)
118 iosf_write_port(IOSF_WRITE(LPSS), reg, val);
121 uint32_t iosf_ccu_read(int reg)
123 return iosf_read_port(IOSF_READ(CCU), reg);
126 void iosf_ccu_write(int reg, uint32_t val)
128 iosf_write_port(IOSF_WRITE(CCU), reg, val);
131 uint32_t iosf_score_read(int reg)
133 return iosf_read_port(IOSF_READ(SCORE), reg);
136 void iosf_score_write(int reg, uint32_t val)
138 iosf_write_port(IOSF_WRITE(SCORE), reg, val);
141 uint32_t iosf_scc_read(int reg)
143 return iosf_read_port(IOSF_READ(SCC), reg);
146 void iosf_scc_write(int reg, uint32_t val)
148 iosf_write_port(IOSF_WRITE(SCC), reg, val);
151 uint32_t iosf_aunit_read(int reg)
153 return iosf_read_port(IOSF_READ(AUNIT), reg);
156 void iosf_aunit_write(int reg, uint32_t val)
158 iosf_write_port(IOSF_WRITE(AUNIT), reg, val);
161 uint32_t iosf_cpu_bus_read(int reg)
163 return iosf_read_port(IOSF_READ(CPU_BUS), reg);
166 void iosf_cpu_bus_write(int reg, uint32_t val)
168 iosf_write_port(IOSF_WRITE(CPU_BUS), reg, val);
171 uint32_t iosf_sec_read(int reg)
173 return iosf_read_port(IOSF_READ(SEC), reg);
176 void iosf_sec_write(int reg, uint32_t val)
178 iosf_write_port(IOSF_WRITE(SEC), reg, val);
181 uint32_t iosf_port45_read(int reg)
183 return iosf_read_port(IOSF_READ(0x45), reg);
186 void iosf_port45_write(int reg, uint32_t val)
188 iosf_write_port(IOSF_WRITE(0x45), reg, val);
191 uint32_t iosf_port46_read(int reg)
193 return iosf_read_port(IOSF_READ(0x46), reg);
196 void iosf_port46_write(int reg, uint32_t val)
198 iosf_write_port(IOSF_WRITE(0x46), reg, val);
201 uint32_t iosf_port47_read(int reg)
203 return iosf_read_port(IOSF_READ(0x47), reg);
206 void iosf_port47_write(int reg, uint32_t val)
208 iosf_write_port(IOSF_WRITE(0x47), reg, val);
211 uint32_t iosf_port55_read(int reg)
213 return iosf_read_port(IOSF_READ(0x55), reg);
216 void iosf_port55_write(int reg, uint32_t val)
218 iosf_write_port(IOSF_WRITE(0x55), reg, val);
221 uint32_t iosf_port58_read(int reg)
223 return iosf_read_port(IOSF_READ(0x58), reg);
226 void iosf_port58_write(int reg, uint32_t val)
228 iosf_write_port(IOSF_WRITE(0x58), reg, val);
231 uint32_t iosf_port59_read(int reg)
233 return iosf_read_port(IOSF_READ(0x59), reg);
236 void iosf_port59_write(int reg, uint32_t val)
238 iosf_write_port(IOSF_WRITE(0x59), reg, val);
241 uint32_t iosf_port5a_read(int reg)
243 return iosf_read_port(IOSF_READ(0x5a), reg);
246 void iosf_port5a_write(int reg, uint32_t val)
248 iosf_write_port(IOSF_WRITE(0x5a), reg, val);
251 uint32_t iosf_porta2_read(int reg)
253 return iosf_read_port(IOSF_READ(0xa2), reg);
256 void iosf_porta2_write(int reg, uint32_t val)
258 iosf_write_port(IOSF_WRITE(0xa2), reg, val);
261 uint32_t iosf_ssus_read(int reg)
263 return iosf_read_port(IOSF_READ(SSUS), reg);
266 void iosf_ssus_write(int reg, uint32_t val)
268 iosf_write_port(IOSF_WRITE(SSUS), reg, val);