1 /* SPDX-License-Identifier: GPL-2.0+ */
2 #ifndef _ASM_ARCH_SCU_AST2400_H
3 #define _ASM_ARCH_SCU_AST2400_H
4 
5 #define SCU_UNLOCK_VALUE		0x1688a8a8
6 
7 #define SCU_HWSTRAP_VGAMEM_SHIFT	2
8 #define SCU_HWSTRAP_VGAMEM_MASK		(3 << SCU_HWSTRAP_VGAMEM_SHIFT)
9 #define SCU_HWSTRAP_MAC1_RGMII		(1 << 6)
10 #define SCU_HWSTRAP_MAC2_RGMII		(1 << 7)
11 #define SCU_HWSTRAP_DDR4		(1 << 24)
12 #define SCU_HWSTRAP_CLKIN_25MHZ		(1 << 23)
13 
14 #define SCU_MPLL_DENUM_SHIFT		0
15 #define SCU_MPLL_DENUM_MASK		0x1f
16 #define SCU_MPLL_NUM_SHIFT		5
17 #define SCU_MPLL_NUM_MASK		(0xff << SCU_MPLL_NUM_SHIFT)
18 #define SCU_MPLL_POST_SHIFT		13
19 #define SCU_MPLL_POST_MASK		(0x3f << SCU_MPLL_POST_SHIFT)
20 #define SCU_PCLK_DIV_SHIFT		23
21 #define SCU_PCLK_DIV_MASK		(7 << SCU_PCLK_DIV_SHIFT)
22 #define SCU_HPLL_DENUM_SHIFT		0
23 #define SCU_HPLL_DENUM_MASK		0x1f
24 #define SCU_HPLL_NUM_SHIFT		5
25 #define SCU_HPLL_NUM_MASK		(0xff << SCU_HPLL_NUM_SHIFT)
26 #define SCU_HPLL_POST_SHIFT		13
27 #define SCU_HPLL_POST_MASK		(0x3f << SCU_HPLL_POST_SHIFT)
28 
29 #define SCU_MACCLK_SHIFT		16
30 #define SCU_MACCLK_MASK			(7 << SCU_MACCLK_SHIFT)
31 
32 #define SCU_MISC2_RGMII_HPLL		(1 << 23)
33 #define SCU_MISC2_RGMII_CLKDIV_SHIFT	20
34 #define SCU_MISC2_RGMII_CLKDIV_MASK	(3 << SCU_MISC2_RGMII_CLKDIV_SHIFT)
35 #define SCU_MISC2_RMII_MPLL		(1 << 19)
36 #define SCU_MISC2_RMII_CLKDIV_SHIFT	16
37 #define SCU_MISC2_RMII_CLKDIV_MASK	(3 << SCU_MISC2_RMII_CLKDIV_SHIFT)
38 #define SCU_MISC2_UARTCLK_SHIFT		24
39 
40 #define SCU_MISC_D2PLL_OFF		(1 << 4)
41 #define SCU_MISC_UARTCLK_DIV13		(1 << 12)
42 #define SCU_MISC_GCRT_USB20CLK		(1 << 21)
43 
44 #define SCU_MICDS_MAC1RGMII_TXDLY_SHIFT	0
45 #define SCU_MICDS_MAC1RGMII_TXDLY_MASK	(0x3f\
46 					 << SCU_MICDS_MAC1RGMII_TXDLY_SHIFT)
47 #define SCU_MICDS_MAC2RGMII_TXDLY_SHIFT	6
48 #define SCU_MICDS_MAC2RGMII_TXDLY_MASK	(0x3f\
49 					 << SCU_MICDS_MAC2RGMII_TXDLY_SHIFT)
50 #define SCU_MICDS_MAC1RMII_RDLY_SHIFT	12
51 #define SCU_MICDS_MAC1RMII_RDLY_MASK	(0x3f << SCU_MICDS_MAC1RMII_RDLY_SHIFT)
52 #define SCU_MICDS_MAC2RMII_RDLY_SHIFT	18
53 #define SCU_MICDS_MAC2RMII_RDLY_MASK	(0x3f << SCU_MICDS_MAC2RMII_RDLY_SHIFT)
54 #define SCU_MICDS_MAC1RMII_TXFALL	(1 << 24)
55 #define SCU_MICDS_MAC2RMII_TXFALL	(1 << 25)
56 #define SCU_MICDS_RMII1_RCLKEN		(1 << 29)
57 #define SCU_MICDS_RMII2_RCLKEN		(1 << 30)
58 #define SCU_MICDS_RGMIIPLL		(1 << 31)
59 
60 
61 
62 /* Bits 16-27 in the register control pin functions for I2C devices 3-14 */
63 #define SCU_PINMUX_CTRL5_I2C		(1 << 16)
64 
65 /*
66  * The values are grouped by function, not by register.
67  * They are actually scattered across multiple loosely related registers.
68  */
69 #define SCU_PIN_FUN_MAC1_MDC		(1 << 30)
70 #define SCU_PIN_FUN_MAC1_MDIO		(1 << 31)
71 #define SCU_PIN_FUN_MAC1_PHY_LINK	(1 << 0)
72 #define SCU_PIN_FUN_MAC2_MDIO		(1 << 2)
73 #define SCU_PIN_FUN_MAC2_PHY_LINK	(1 << 1)
74 #define SCU_PIN_FUN_SCL1		(1 << 12)
75 #define SCU_PIN_FUN_SCL2		(1 << 14)
76 #define SCU_PIN_FUN_SDA1		(1 << 13)
77 #define SCU_PIN_FUN_SDA2		(1 << 15)
78 
79 #define SCU_D2PLL_EXT1_OFF		(1 << 0)
80 #define SCU_D2PLL_EXT1_BYPASS		(1 << 1)
81 #define SCU_D2PLL_EXT1_RESET		(1 << 2)
82 #define SCU_D2PLL_EXT1_MODE_SHIFT	3
83 #define SCU_D2PLL_EXT1_MODE_MASK	(3 << SCU_D2PLL_EXT1_MODE_SHIFT)
84 #define SCU_D2PLL_EXT1_PARAM_SHIFT	5
85 #define SCU_D2PLL_EXT1_PARAM_MASK	(0x1ff << SCU_D2PLL_EXT1_PARAM_SHIFT)
86 
87 #define SCU_D2PLL_NUM_SHIFT		0
88 #define SCU_D2PLL_NUM_MASK		(0xff << SCU_D2PLL_NUM_SHIFT)
89 #define SCU_D2PLL_DENUM_SHIFT		8
90 #define SCU_D2PLL_DENUM_MASK		(0x1f << SCU_D2PLL_DENUM_SHIFT)
91 #define SCU_D2PLL_POST_SHIFT		13
92 #define SCU_D2PLL_POST_MASK		(0x3f << SCU_D2PLL_POST_SHIFT)
93 #define SCU_D2PLL_ODIV_SHIFT		19
94 #define SCU_D2PLL_ODIV_MASK		(7 << SCU_D2PLL_ODIV_SHIFT)
95 #define SCU_D2PLL_SIC_SHIFT		22
96 #define SCU_D2PLL_SIC_MASK		(0x1f << SCU_D2PLL_SIC_SHIFT)
97 #define SCU_D2PLL_SIP_SHIFT		27
98 #define SCU_D2PLL_SIP_MASK		(0x1f << SCU_D2PLL_SIP_SHIFT)
99 
100 #define SCU_CLKDUTY_DCLK_SHIFT		0
101 #define SCU_CLKDUTY_DCLK_MASK		(0x3f << SCU_CLKDUTY_DCLK_SHIFT)
102 #define SCU_CLKDUTY_RGMII1TXCK_SHIFT	8
103 #define SCU_CLKDUTY_RGMII1TXCK_MASK	(0x7f << SCU_CLKDUTY_RGMII1TXCK_SHIFT)
104 #define SCU_CLKDUTY_RGMII2TXCK_SHIFT	16
105 #define SCU_CLKDUTY_RGMII2TXCK_MASK	(0x7f << SCU_CLKDUTY_RGMII2TXCK_SHIFT)
106 
107 struct ast2400_clk_priv {
108 	struct ast2400_scu *scu;
109 };
110 
111 struct ast2400_scu {
112 	u32 protection_key;			/* 0x00 */
113 	u32 sysreset_ctrl1;			/* 0x04 */
114 	u32 clk_sel1;				/* 0x08 */
115 	u32 clk_stop_ctrl1;			/* 0x0C */
116 	u32 freq_counter_ctrl;		/* 0x10 */
117 	u32 freq_counter_measure;	/* 0x14 */
118 	u32 intr_ctrl;				/* 0x18 */
119 	u32 d2_pll_param;			/* 0x1C */
120 	u32 m_pll_param;			/* 0x20 */
121 	u32 h_pll_param;			/* 0x24 */
122 	u32 freq_counter_cmp;		/* 0x28 */
123 	u32 misc_ctrl1;				/* 0x2C */
124 	u32 pci_config[3];			/* 0x30 */
125 	u32 sysreset_status;		/* 0x3C */
126 	u32 vga_handshake[2];		/* 0x40 */
127 	u32 mac_clk_delay;			/* 0x48 */
128 	u32 misc_ctrl2;				/* 0x4C */
129 	u32 vga_scratch[8];			/* 0x50 */
130 	u32 hwstrap;				/* 0x70 */
131 	u32 rng_ctrl;				/* 0x74 */
132 	u32 rng_data;				/* 0x78 */
133 	u32 rev_id;					/* 0x7C */
134 	u32 pinmux_ctrl[6];			/* 0x80 */
135 	u32 reserved0;				/* 0x98 */
136 	u32 wdt_rst_sel;			/* 0x9C */
137 	u32 pinmux_ctrl1[3];		/* 0xA0 */
138 	u32 reserved1[5];			/* 0xAC */
139 	u32 wakeup_enable;			/* 0xC0 */
140 	u32 wakeup_control;			/* 0xC4 */
141 	u32 reserved2[2];			/* 0xC8 */
142 	u32 hwstrap2;				/* 0xD0 */
143 	u32 reserved3[3];			/* 0xD4 */
144 	u32 freerun_counter;		/* 0xE0 */
145 	u32 freerun_counter_ext;	/* 0xE4 */
146 	//E8/EC
147 	//F0/F4/F8/FC
148 	u32 reserved4[6];			/* 0xE8 */
149 	/* The next registers are not key-protected */
150 	struct ast2400_cpu2 {		/* 0x100 */
151 		u32 ctrl;
152 		u32 base_addr[5];
153 		u32 cache_ctrl;
154 	} cpu2;
155 	u32 reserved5[17];			/* 0x11C */
156 	//11C/
157 	//120/124/128/12c
158 	//130/134/138/13c
159 	//140/144/148/14c
160 	//150/154/158/15c
161 	u32 uart_clk_ctrl;			/* 0x160 */
162 	u32 reserved7[7];
163 	u32 pcie_config;			/* 0x180 */
164 	u32 mmio_decode;
165 	u32 reloc_ctrl_decode[2];
166 	u32 mailbox_addr;
167 	u32 shared_sram_decode[2];
168 	u32 bmc_rev_id;
169 	u32 reserved8;
170 	u32 bmc_device_id;
171 	u32 reserved9[13];
172 	u32 clk_duty_sel;
173 };
174 
175 #endif  /* _ASM_ARCH_SCU_AST2400_H */
176