1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) ASPEED Technology Inc.
4  */
5 
6 #ifndef _ASM_ARCH_SCU_AST2600_H
7 #define _ASM_ARCH_SCU_AST2600_H
8 
9 #define SCU_UNLOCK_VALUE		0x1688a8a8
10 
11 #define SCU_HWSTRAP_VGAMEM_SHIFT	2
12 #define SCU_HWSTRAP_VGAMEM_MASK		(3 << SCU_HWSTRAP_VGAMEM_SHIFT)
13 #define SCU_HWSTRAP_MAC1_RGMII		(1 << 6)
14 #define SCU_HWSTRAP_MAC2_RGMII		(1 << 7)
15 #define SCU_HWSTRAP_DDR4		(1 << 24)
16 #define SCU_HWSTRAP_CLKIN_25MHZ		(1 << 23)
17 
18 #define SCU_MPLL_DENUM_SHIFT		0
19 #define SCU_MPLL_DENUM_MASK		0x1f
20 #define SCU_MPLL_NUM_SHIFT		5
21 #define SCU_MPLL_NUM_MASK		(0xff << SCU_MPLL_NUM_SHIFT)
22 #define SCU_MPLL_POST_SHIFT		13
23 #define SCU_MPLL_POST_MASK		(0x3f << SCU_MPLL_POST_SHIFT)
24 #define SCU_PCLK_DIV_SHIFT		23
25 #define SCU_PCLK_DIV_MASK		(7 << SCU_PCLK_DIV_SHIFT)
26 #define SCU_HPLL_DENUM_SHIFT		0
27 #define SCU_HPLL_DENUM_MASK		0x1f
28 #define SCU_HPLL_NUM_SHIFT		5
29 #define SCU_HPLL_NUM_MASK		(0xff << SCU_HPLL_NUM_SHIFT)
30 #define SCU_HPLL_POST_SHIFT		13
31 #define SCU_HPLL_POST_MASK		(0x3f << SCU_HPLL_POST_SHIFT)
32 
33 #define SCU_MACCLK_SHIFT		16
34 #define SCU_MACCLK_MASK			(7 << SCU_MACCLK_SHIFT)
35 
36 #define SCU_MISC2_RGMII_HPLL		(1 << 23)
37 #define SCU_MISC2_RGMII_CLKDIV_SHIFT	20
38 #define SCU_MISC2_RGMII_CLKDIV_MASK	(3 << SCU_MISC2_RGMII_CLKDIV_SHIFT)
39 #define SCU_MISC2_RMII_MPLL		(1 << 19)
40 #define SCU_MISC2_RMII_CLKDIV_SHIFT	16
41 #define SCU_MISC2_RMII_CLKDIV_MASK	(3 << SCU_MISC2_RMII_CLKDIV_SHIFT)
42 #define SCU_MISC2_UARTCLK_SHIFT		24
43 
44 #define SCU_MISC_D2PLL_OFF		(1 << 4)
45 #define SCU_MISC_UARTCLK_DIV13		(1 << 12)
46 #define SCU_MISC_GCRT_USB20CLK		(1 << 21)
47 
48 #define SCU_MICDS_MAC1RGMII_TXDLY_SHIFT	0
49 #define SCU_MICDS_MAC1RGMII_TXDLY_MASK	(0x3f\
50 					 << SCU_MICDS_MAC1RGMII_TXDLY_SHIFT)
51 #define SCU_MICDS_MAC2RGMII_TXDLY_SHIFT	6
52 #define SCU_MICDS_MAC2RGMII_TXDLY_MASK	(0x3f\
53 					 << SCU_MICDS_MAC2RGMII_TXDLY_SHIFT)
54 #define SCU_MICDS_MAC1RMII_RDLY_SHIFT	12
55 #define SCU_MICDS_MAC1RMII_RDLY_MASK	(0x3f << SCU_MICDS_MAC1RMII_RDLY_SHIFT)
56 #define SCU_MICDS_MAC2RMII_RDLY_SHIFT	18
57 #define SCU_MICDS_MAC2RMII_RDLY_MASK	(0x3f << SCU_MICDS_MAC2RMII_RDLY_SHIFT)
58 #define SCU_MICDS_MAC1RMII_TXFALL	(1 << 24)
59 #define SCU_MICDS_MAC2RMII_TXFALL	(1 << 25)
60 #define SCU_MICDS_RMII1_RCLKEN		(1 << 29)
61 #define SCU_MICDS_RMII2_RCLKEN		(1 << 30)
62 #define SCU_MICDS_RGMIIPLL		(1 << 31)
63 
64 
65 /* Bits 16-27 in the register control pin functions for I2C devices 3-14 */
66 #define SCU_PINMUX_CTRL5_I2C		(1 << 16)
67 
68 /*
69  * The values are grouped by function, not by register.
70  * They are actually scattered across multiple loosely related registers.
71  */
72 #define SCU_PIN_FUN_MAC1_MDC		(1 << 30)
73 #define SCU_PIN_FUN_MAC1_MDIO		(1 << 31)
74 #define SCU_PIN_FUN_MAC1_PHY_LINK	(1 << 0)
75 #define SCU_PIN_FUN_MAC2_MDIO		(1 << 2)
76 #define SCU_PIN_FUN_MAC2_PHY_LINK	(1 << 1)
77 #define SCU_PIN_FUN_SCL1		(1 << 12)
78 #define SCU_PIN_FUN_SCL2		(1 << 14)
79 #define SCU_PIN_FUN_SDA1		(1 << 13)
80 #define SCU_PIN_FUN_SDA2		(1 << 15)
81 
82 #define SCU_CLKSTOP_MAC1		(1 << 20)
83 #define SCU_CLKSTOP_MAC2		(1 << 21)
84 
85 #define SCU_D2PLL_EXT1_OFF		(1 << 0)
86 #define SCU_D2PLL_EXT1_BYPASS		(1 << 1)
87 #define SCU_D2PLL_EXT1_RESET		(1 << 2)
88 #define SCU_D2PLL_EXT1_MODE_SHIFT	3
89 #define SCU_D2PLL_EXT1_MODE_MASK	(3 << SCU_D2PLL_EXT1_MODE_SHIFT)
90 #define SCU_D2PLL_EXT1_PARAM_SHIFT	5
91 #define SCU_D2PLL_EXT1_PARAM_MASK	(0x1ff << SCU_D2PLL_EXT1_PARAM_SHIFT)
92 
93 #define SCU_D2PLL_NUM_SHIFT		0
94 #define SCU_D2PLL_NUM_MASK		(0xff << SCU_D2PLL_NUM_SHIFT)
95 #define SCU_D2PLL_DENUM_SHIFT		8
96 #define SCU_D2PLL_DENUM_MASK		(0x1f << SCU_D2PLL_DENUM_SHIFT)
97 #define SCU_D2PLL_POST_SHIFT		13
98 #define SCU_D2PLL_POST_MASK		(0x3f << SCU_D2PLL_POST_SHIFT)
99 #define SCU_D2PLL_ODIV_SHIFT		19
100 #define SCU_D2PLL_ODIV_MASK		(7 << SCU_D2PLL_ODIV_SHIFT)
101 #define SCU_D2PLL_SIC_SHIFT		22
102 #define SCU_D2PLL_SIC_MASK		(0x1f << SCU_D2PLL_SIC_SHIFT)
103 #define SCU_D2PLL_SIP_SHIFT		27
104 #define SCU_D2PLL_SIP_MASK		(0x1f << SCU_D2PLL_SIP_SHIFT)
105 
106 #define SCU_CLKDUTY_DCLK_SHIFT		0
107 #define SCU_CLKDUTY_DCLK_MASK		(0x3f << SCU_CLKDUTY_DCLK_SHIFT)
108 #define SCU_CLKDUTY_RGMII1TXCK_SHIFT	8
109 #define SCU_CLKDUTY_RGMII1TXCK_MASK	(0x7f << SCU_CLKDUTY_RGMII1TXCK_SHIFT)
110 #define SCU_CLKDUTY_RGMII2TXCK_SHIFT	16
111 #define SCU_CLKDUTY_RGMII2TXCK_MASK	(0x7f << SCU_CLKDUTY_RGMII2TXCK_SHIFT)
112 
113 #ifndef __ASSEMBLY__
114 
115 struct ast2600_clk_priv {
116 	struct ast2600_scu *scu;
117 };
118 
119 struct hw_strap {
120 	u32 hwstrap;	/* 0x508 */
121 	u32 hwstrap_clr;		/* 0x504 */
122 	u32 hwstrap_protect;	/* 0x508 */
123 };
124 
125 struct ast2600_scu {
126 	u32 protection_key;		/* 0x000 */
127 	u32 chip_id0;			/* 0x004 */
128 	u32 reserve_0x08;		/* 0x008 */
129 	u32 reserve_0x0C;		/* 0x00C */
130 	u32 reserve_0x10;		/* 0x010 */
131 	u32 chip_id1;			/* 0x014 */
132 	u32 reserve_0x18;		/* 0x018 */
133 	u32 reserve_0x1C;		/* 0x01C */
134 	u32 reserve_0x20;		/* 0x020 */
135 	u32 reserve_0x24;		/* 0x024 */
136 	u32 reserve_0x28;		/* 0x028 */
137 	u32 reserve_0x2c;		/* 0x02C */
138 	u32 reserve_0x30;		/* 0x030 */
139 	u32 reserve_0x34;		/* 0x034 */
140 	u32 reserve_0x38;		/* 0x038 */
141 	u32 reserve_0x3C;		/* 0x03C */
142 	u32 sysreset_ctrl1;		/* 0x040 */
143 	u32 sysreset_clr_ctrl1;	/* 0x044 */
144 	u32 reserve_0x48;		/* 0x048 */
145 	u32 reserve_0x4C;		/* 0x04C */
146 	u32 sysreset_ctrl2;		/* 0x050 */
147 	u32 sysreset_clr_ctrl2;	/* 0x054 */
148 	u32 reserve_0x58;		/* 0x058 */
149 	u32 reserve_0x5C;		/* 0x05C */
150 	u32 extrst_sel1;		/* 0x060 */
151 	u32 sysrst_evet_log1_1;	/* 0x064 */
152 	u32 sysrst_evet_log1_2;	/* 0x068 */
153 	u32 reserve_0x6C;		/* 0x06C */
154 	u32 extrst_sel2;		/* 0x070 */
155 	u32 sysrst_evet_log2_1;	/* 0x074 */
156 	u32 sysrst_evet_log2_2;	/* 0x078 */
157 	u32 reserve_0x7C;		/* 0x07C */
158 	u32 clk_stop_ctrl1;		/* 0x080 */
159 	u32 reserve_0x84;		/* 0x084 */
160 	u32 reserve_0x88;		/* 0x088 */
161 	u32 reserve_0x8C;		/* 0x08C */
162 	u32 clk_stop_ctrl2;		/* 0x090 */
163 	u32 reserve_0x94;		/* 0x094 */
164 	u32 reserve_0x98;		/* 0x098 */
165 	u32 reserve_0x9C;		/* 0x09C */
166 	u32 reserve_0xA0;		/* 0x0A0 */
167 	u32 reserve_0xA4;		/* 0x0A4 */
168 	u32 reserve_0xA8;		/* 0x0A8 */
169 	u32 reserve_0xAC;		/* 0x0AC */
170 	u32 reserve_0xB0;		/* 0x0B0 */
171 	u32 reserve_0xB4;		/* 0x0B4 */
172 	u32 reserve_0xB8;		/* 0x0B8 */
173 	u32 reserve_0xBC;		/* 0x0BC */
174 	u32 misc_ctrl1;			/* 0x0C0 */
175 	u32 misc_ctrl2;			/* 0x0C4 */
176 	u32 backdoor_ctrl;		/* 0x0C8 */
177 	u32 reserve_0xCC;		/* 0x0CC */
178 	u32 misc_ctrl3;			/* 0x0D0 */
179 	u32 misc_ctrl4;			/* 0x0D4 */
180 	u32 reserve_0xD8;		/* 0x0D8 */
181 	u32 reserve_0xDC;		/* 0x0DC */
182 	u32 reserve_0xE0;		/* 0x0E0 */
183 	u32 reserve_0xE4;		/* 0x0E4 */
184 	u32 reserve_0xE8;		/* 0x0E8 */
185 	u32 reserve_0xEC;		/* 0x0EC */
186 	u32 reserve_0xF0;		/* 0x0F0 */
187 	u32 reserve_0xF4;		/* 0x0F4 */
188 	u32 reserve_0xF8;		/* 0x0F8 */
189 	u32 reserve_0xFC;		/* 0x0FC */
190 	u32 soc_scratch[4];		/* 0x100 */
191 	u32 reserve_0x110;		/* 0x110 */
192 	u32 reserve_0x114;		/* 0x114 */
193 	u32 reserve_0x118;		/* 0x118 */
194 	u32 reserve_0x11C;		/* 0x11C */
195 	u32 cpu_scratch_wp;		/* 0x120 */
196 	u32 reserve_0x124[23];	/* 0x124 */
197 	u32 cpu_scratch[32];	/* 0x180 */
198 	u32 h_pll_param;		/* 0x200 */
199 	u32 h_pll_ext_param;	/* 0x204 */
200 	u32 reserve_0x208;		/* 0x208 */
201 	u32 reserve_0x20C;		/* 0x20C */
202 	u32 a_pll_param;		/* 0x210 */
203 	u32 a_pll_ext_param;	/* 0x214 */
204 	u32 reserve_0x218;		/* 0x218 */
205 	u32 reserve_0x21C;		/* 0x21C */
206 	u32 m_pll_param;		/* 0x220 */
207 	u32 m_pll_ext_param;	/* 0x224 */
208 	u32 reserve_0x228;		/* 0x228 */
209 	u32 reserve_0x22C;		/* 0x22C */
210 	u32 reserve_0x230[4];	/* 0x230 */
211 	u32 e_pll_param;		/* 0x240 */
212 	u32 e_pll_ext_param;	/* 0x244 */
213 	u32 reserve_0x248;		/* 0x248 */
214 	u32 reserve_0x24C;		/* 0x24C */
215 	u32 reserve_0x250[4];	/* 0x250 */
216 	u32 d_pll_param;		/* 0x260 */
217 	u32 d_pll_ext_param;	/* 0x264 */
218 	u32 reserve_0x268;		/* 0x268 */
219 	u32 reserve_0x26C;		/* 0x26C */
220 	u32 reserve_0x270[36];	/* 0x270 */
221 	u32 clk_sel1;			/* 0x300 */
222 	u32 clk_sel2;			/* 0x304 */
223 	u32 reserve_0x308;		/* 0x308 */
224 	u32 reserve_0x30C;		/* 0x30C */
225 	u32 clk_sel3;			/* 0x310 */
226 	u32 clk_sel4;			/* 0x314 */
227 	u32 reserve_0x318;		/* 0x318 */
228 	u32 reserve_0x31C;		/* 0x31C */
229 	u32 freq_counter_ctrl1;	/* 0x320 */
230 	u32 freq_counter_cmp1;	/* 0x324 */
231 	u32 reserve_0x328;		/* 0x328 */
232 	u32 uart_24m_ref_hpll;	/* 0x32C */
233 	u32 freq_counter_ctrl2;	/* 0x330 */
234 	u32 freq_counter_cmp2;	/* 0x334 */
235 	u32 uart_24m_ref_uxclk;	/* 0x338 */
236 	u32 uart_24m_ref_apll;	/* 0x33C */
237 	u32 mac12_clk_delay;	/* 0x340 */
238 	u32 reserve_0x344;		/* 0x344 */
239 	u32 mac12_clk_delay_100M;/* 0x348 */
240 	u32 mac12_clk_delay_10M;/* 0x34c */
241 	u32 mac34_clk_delay;	/* 0x350 */
242 	u32 reserve_0x354;		/* 0x354 */
243 	u32 mac34_clk_delay_100M;/* 0x358 */
244 	u32 mac34_clk_delay_10M;/* 0x35c */
245 	u32 clk_duty_meas_ctrl;	/* 0x360 */
246 	u32 clk_duty_sel0;		/* 0x364 */
247 	u32 clk_duty_sel1;		/* 0x368 */
248 	u32 clk_duty_meas_res;	/* 0x36C */
249 	u32 clk_duty_meas_ctr2;	/* 0x370 */
250 	u32 clk_duty_sel2;		/* 0x374 */
251 	u32 reserve_0x378[34];	/* 0x378 */
252 	u32 pinmux_ctrl1[64];	/* 0x400 ~ 0x500 */
253 	struct hw_strap hwstrap1; /* 0x500 */
254 	u32 reserve_0x50C;		/* 0x50C */
255 	struct hw_strap hwstrap2; /* 0x510 */
256 	u32 reserve_0x51C;		/* 0x51C */
257 	u32 rng_ctrl;			/* 0x520 */
258 	u32 rng_data;			/* 0x524 */
259 	u32 reserve_0x528[6];	/* 0x528 */
260 	u32 pwr_save_wakeup_en1;/* 0x540 */
261 	u32 pwr_save_wakeup_ctrl1;/* 0x544 */
262 	u32 reserve_0x548[2];	/* 0x548 */
263 	u32 pwr_save_wakeup_en2;/* 0x550 */
264 	u32 pwr_save_wakeup_ctrl2;/* 0x554 */
265 	u32 reserve_0x558[2];	/* 0x558 */
266 	u32 intr1_ctrl_sts;		/* 0x560 */
267 	u32 reserve_0x564[3];	/* 0x564 */
268 	u32 intr2_ctrl_sts;		/* 0x570 */
269 	u32 reserve_0x574[3];	/* 0x574 */
270 	u32 reserve_0x580[4];	/* 0x580 */
271 	u32 opt_ctrl;			/* 0x590 */
272 	u32 hw_config;			/* 0x594 */
273 	u32 reserve_0x598[6];	/* 0x598 */
274 	u32 chip_unique_id[8];	/* 0x5B0 */
275 	u32 reserve_0x5E0[8];	/* 0x5E0 */
276 	u32 disgpio_in_pull_down0;	/* 0x610 */
277 	u32 disgpio_in_pull_down1;	/* 0x614 */
278 	u32 disgpio_in_pull_down2;	/* 0x618 */
279 	u32 disgpio_in_pull_down3;	/* 0x61C */
280 	u32 reserve_0x620[4];	/* 0x620 */
281 	u32 disgpio_in_pull_down4;	/* 0x630 */
282 	u32 disgpio_in_pull_down5;	/* 0x634 */
283 	u32 disgpio_in_pull_down6;	/* 0x638 */
284 	u32 reserve_0x63C[5];	/* 0x63Cs */
285 	u32 sli_driving_strength;	/* 0x650 */
286 	u32 reserve_0x654[235];	/* 0x654 */
287 	u32 cm3_ctrl;			/* 0xA00 */
288 	u32 cm3_base;			/* 0xA04 */
289 	u32 cm3_instr_mem_addr;	/* 0xA08 */
290 	u32 cm3_data_mem_addr;	/* 0xA0C */
291 	u32 reserve_0xA10[12];	/* 0xA10 */
292 	u32 cm3_cache_area;		/* 0xA40 */
293 	u32 cm3_cache_invalid_ctrl;	/* 0xA44 */
294 	u32 cm3_cache_fun_ctrl;	/* 0xA48 */
295 	u32 reserve_0xA4C[108];	/* 0xA4C */
296 	u32 pci_config[3];		/* 0xC00 */
297 	u32 reserve_0xC0C[5];	/* 0xC0C */
298 	u32 pcie_config;		/* 0xC20 */
299 	u32 mmio_decode;		/* 0xC24 */
300 	u32 reloc_ctrl_decode[2]; /* 0xC28 */
301 	u32 reserve_0xC30[4];	/* 0xC30 */
302 	u32 mailbox_addr;		/* 0xC40 */
303 	u32 shared_sram_decode[2];	/* 0xC44 */
304 	u32 bmc_rev_id;			/* 0xC4C */
305 	u32 reserve_0xC50[5];	/* 0xC50 */
306 	u32 bmc_device_id;		/* 0xC64 */
307 	u32 reserve_0xC68[102];	/* 0xC68 */
308 	u32 vga_scratch[8];		/* 0xE00 */
309 };
310 
311 /**
312  * ast_get_clk() - get a pointer to Clock Driver
313  *
314  * @devp, OUT - pointer to Clock Driver
315  * @return zero on success, error code (< 0) otherwise.
316  */
317 int ast_get_clk(struct udevice **devp);
318 
319 /**
320  * ast_get_scu() - get a pointer to SCU registers
321  *
322  * @return pointer to struct ast2600_scu on success, ERR_PTR otherwise
323  */
324 void *ast_get_scu(void);
325 
326 #endif  /* __ASSEMBLY__ */
327 
328 #endif  /* _ASM_ARCH_SCU_AST2600_H */
329