xref: /rk3399_rockchip-uboot/arch/arm/include/asm/arch-aspeed/scu_ast2500.h (revision 4f66e09bb9fbc47b73f67c3cc08ee2663e8fcdb1)
114e4b149Smaxims@google.com /*
214e4b149Smaxims@google.com  * Copyright (c) 2016 Google, Inc
314e4b149Smaxims@google.com  *
414e4b149Smaxims@google.com  * SPDX-License-Identifier:	GPL-2.0+
514e4b149Smaxims@google.com  */
614e4b149Smaxims@google.com #ifndef _ASM_ARCH_SCU_AST2500_H
714e4b149Smaxims@google.com #define _ASM_ARCH_SCU_AST2500_H
814e4b149Smaxims@google.com 
914e4b149Smaxims@google.com #define SCU_UNLOCK_VALUE		0x1688a8a8
1014e4b149Smaxims@google.com 
1114e4b149Smaxims@google.com #define SCU_HWSTRAP_VGAMEM_SHIFT	2
12*defb1849Smaxims@google.com #define SCU_HWSTRAP_VGAMEM_MASK		(3 << SCU_HWSTRAP_VGAMEM_SHIFT)
134f0e44e4Smaxims@google.com #define SCU_HWSTRAP_MAC1_RGMII		(1 << 6)
144f0e44e4Smaxims@google.com #define SCU_HWSTRAP_MAC2_RGMII		(1 << 7)
1514e4b149Smaxims@google.com #define SCU_HWSTRAP_DDR4		(1 << 24)
1614e4b149Smaxims@google.com #define SCU_HWSTRAP_CLKIN_25MHZ		(1 << 23)
1714e4b149Smaxims@google.com 
1814e4b149Smaxims@google.com #define SCU_MPLL_DENUM_SHIFT		0
1914e4b149Smaxims@google.com #define SCU_MPLL_DENUM_MASK		0x1f
2014e4b149Smaxims@google.com #define SCU_MPLL_NUM_SHIFT		5
21*defb1849Smaxims@google.com #define SCU_MPLL_NUM_MASK		(0xff << SCU_MPLL_NUM_SHIFT)
2214e4b149Smaxims@google.com #define SCU_MPLL_POST_SHIFT		13
23*defb1849Smaxims@google.com #define SCU_MPLL_POST_MASK		(0x3f << SCU_MPLL_POST_SHIFT)
244999bb06Smaxims@google.com #define SCU_PCLK_DIV_SHIFT		23
25*defb1849Smaxims@google.com #define SCU_PCLK_DIV_MASK		(7 << SCU_PCLK_DIV_SHIFT)
2614e4b149Smaxims@google.com #define SCU_HPLL_DENUM_SHIFT		0
2714e4b149Smaxims@google.com #define SCU_HPLL_DENUM_MASK		0x1f
2814e4b149Smaxims@google.com #define SCU_HPLL_NUM_SHIFT		5
29*defb1849Smaxims@google.com #define SCU_HPLL_NUM_MASK		(0xff << SCU_HPLL_NUM_SHIFT)
3014e4b149Smaxims@google.com #define SCU_HPLL_POST_SHIFT		13
31*defb1849Smaxims@google.com #define SCU_HPLL_POST_MASK		(0x3f << SCU_HPLL_POST_SHIFT)
3214e4b149Smaxims@google.com 
333b95902dSmaxims@google.com #define SCU_MACCLK_SHIFT		16
343b95902dSmaxims@google.com #define SCU_MACCLK_MASK			(7 << SCU_MACCLK_SHIFT)
353b95902dSmaxims@google.com 
363b95902dSmaxims@google.com #define SCU_MISC2_RGMII_HPLL		(1 << 23)
373b95902dSmaxims@google.com #define SCU_MISC2_RGMII_CLKDIV_SHIFT	20
383b95902dSmaxims@google.com #define SCU_MISC2_RGMII_CLKDIV_MASK	(3 << SCU_MISC2_RGMII_CLKDIV_SHIFT)
393b95902dSmaxims@google.com #define SCU_MISC2_RMII_MPLL		(1 << 19)
403b95902dSmaxims@google.com #define SCU_MISC2_RMII_CLKDIV_SHIFT	16
413b95902dSmaxims@google.com #define SCU_MISC2_RMII_CLKDIV_MASK	(3 << SCU_MISC2_RMII_CLKDIV_SHIFT)
4214e4b149Smaxims@google.com #define SCU_MISC2_UARTCLK_SHIFT		24
4314e4b149Smaxims@google.com 
443b95902dSmaxims@google.com #define SCU_MISC_D2PLL_OFF		(1 << 4)
4514e4b149Smaxims@google.com #define SCU_MISC_UARTCLK_DIV13		(1 << 12)
463b95902dSmaxims@google.com #define SCU_MISC_GCRT_USB20CLK		(1 << 21)
473b95902dSmaxims@google.com 
483b95902dSmaxims@google.com #define SCU_MICDS_MAC1RGMII_TXDLY_SHIFT	0
493b95902dSmaxims@google.com #define SCU_MICDS_MAC1RGMII_TXDLY_MASK	(0x3f\
503b95902dSmaxims@google.com 					 << SCU_MICDS_MAC1RGMII_TXDLY_SHIFT)
513b95902dSmaxims@google.com #define SCU_MICDS_MAC2RGMII_TXDLY_SHIFT	6
523b95902dSmaxims@google.com #define SCU_MICDS_MAC2RGMII_TXDLY_MASK	(0x3f\
533b95902dSmaxims@google.com 					 << SCU_MICDS_MAC2RGMII_TXDLY_SHIFT)
543b95902dSmaxims@google.com #define SCU_MICDS_MAC1RMII_RDLY_SHIFT	12
553b95902dSmaxims@google.com #define SCU_MICDS_MAC1RMII_RDLY_MASK	(0x3f << SCU_MICDS_MAC1RMII_RDLY_SHIFT)
563b95902dSmaxims@google.com #define SCU_MICDS_MAC2RMII_RDLY_SHIFT	18
573b95902dSmaxims@google.com #define SCU_MICDS_MAC2RMII_RDLY_MASK	(0x3f << SCU_MICDS_MAC2RMII_RDLY_SHIFT)
583b95902dSmaxims@google.com #define SCU_MICDS_MAC1RMII_TXFALL	(1 << 24)
593b95902dSmaxims@google.com #define SCU_MICDS_MAC2RMII_TXFALL	(1 << 25)
603b95902dSmaxims@google.com #define SCU_MICDS_RMII1_RCLKEN		(1 << 29)
613b95902dSmaxims@google.com #define SCU_MICDS_RMII2_RCLKEN		(1 << 30)
623b95902dSmaxims@google.com #define SCU_MICDS_RGMIIPLL		(1 << 31)
6314e4b149Smaxims@google.com 
64858d4976Smaxims@google.com /*
65858d4976Smaxims@google.com  * SYSRESET is actually more like a Power register,
66858d4976Smaxims@google.com  * except that corresponding bit set to 1 means that
67858d4976Smaxims@google.com  * the peripheral is off.
68858d4976Smaxims@google.com  */
69858d4976Smaxims@google.com #define SCU_SYSRESET_XDMA		(1 << 25)
70858d4976Smaxims@google.com #define SCU_SYSRESET_MCTP		(1 << 24)
71858d4976Smaxims@google.com #define SCU_SYSRESET_ADC		(1 << 23)
72858d4976Smaxims@google.com #define SCU_SYSRESET_JTAG		(1 << 22)
73858d4976Smaxims@google.com #define SCU_SYSRESET_MIC		(1 << 18)
74858d4976Smaxims@google.com #define SCU_SYSRESET_SDIO		(1 << 16)
75858d4976Smaxims@google.com #define SCU_SYSRESET_USB11HOST		(1 << 15)
76858d4976Smaxims@google.com #define SCU_SYSRESET_USBHUB		(1 << 14)
77858d4976Smaxims@google.com #define SCU_SYSRESET_CRT		(1 << 13)
78858d4976Smaxims@google.com #define SCU_SYSRESET_MAC2		(1 << 12)
79858d4976Smaxims@google.com #define SCU_SYSRESET_MAC1		(1 << 11)
80858d4976Smaxims@google.com #define SCU_SYSRESET_PECI		(1 << 10)
81858d4976Smaxims@google.com #define SCU_SYSRESET_PWM		(1 << 9)
82858d4976Smaxims@google.com #define SCU_SYSRESET_PCI_VGA		(1 << 8)
83858d4976Smaxims@google.com #define SCU_SYSRESET_2D			(1 << 7)
84858d4976Smaxims@google.com #define SCU_SYSRESET_VIDEO		(1 << 6)
85858d4976Smaxims@google.com #define SCU_SYSRESET_LPC		(1 << 5)
86858d4976Smaxims@google.com #define SCU_SYSRESET_HAC		(1 << 4)
87858d4976Smaxims@google.com #define SCU_SYSRESET_USBHID		(1 << 3)
88858d4976Smaxims@google.com #define SCU_SYSRESET_I2C		(1 << 2)
89858d4976Smaxims@google.com #define SCU_SYSRESET_AHB		(1 << 1)
90858d4976Smaxims@google.com #define SCU_SYSRESET_SDRAM_WDT		(1 << 0)
91858d4976Smaxims@google.com 
924f0e44e4Smaxims@google.com /* Bits 16-27 in the register control pin functions for I2C devices 3-14 */
934f0e44e4Smaxims@google.com #define SCU_PINMUX_CTRL5_I2C		(1 << 16)
944f0e44e4Smaxims@google.com 
954f0e44e4Smaxims@google.com /*
964f0e44e4Smaxims@google.com  * The values are grouped by function, not by register.
974f0e44e4Smaxims@google.com  * They are actually scattered across multiple loosely related registers.
984f0e44e4Smaxims@google.com  */
994f0e44e4Smaxims@google.com #define SCU_PIN_FUN_MAC1_MDC		(1 << 30)
1004f0e44e4Smaxims@google.com #define SCU_PIN_FUN_MAC1_MDIO		(1 << 31)
1014f0e44e4Smaxims@google.com #define SCU_PIN_FUN_MAC1_PHY_LINK	(1 << 0)
1024f0e44e4Smaxims@google.com #define SCU_PIN_FUN_MAC2_MDIO		(1 << 2)
1034f0e44e4Smaxims@google.com #define SCU_PIN_FUN_MAC2_PHY_LINK	(1 << 1)
1044f0e44e4Smaxims@google.com #define SCU_PIN_FUN_SCL1		(1 << 12)
1054f0e44e4Smaxims@google.com #define SCU_PIN_FUN_SCL2		(1 << 14)
1064f0e44e4Smaxims@google.com #define SCU_PIN_FUN_SDA1		(1 << 13)
1074f0e44e4Smaxims@google.com #define SCU_PIN_FUN_SDA2		(1 << 15)
1084f0e44e4Smaxims@google.com 
1093b95902dSmaxims@google.com #define SCU_CLKSTOP_MAC1		(1 << 20)
1103b95902dSmaxims@google.com #define SCU_CLKSTOP_MAC2		(1 << 21)
1113b95902dSmaxims@google.com 
1123b95902dSmaxims@google.com #define SCU_D2PLL_EXT1_OFF		(1 << 0)
1133b95902dSmaxims@google.com #define SCU_D2PLL_EXT1_BYPASS		(1 << 1)
1143b95902dSmaxims@google.com #define SCU_D2PLL_EXT1_RESET		(1 << 2)
1153b95902dSmaxims@google.com #define SCU_D2PLL_EXT1_MODE_SHIFT	3
1163b95902dSmaxims@google.com #define SCU_D2PLL_EXT1_MODE_MASK	(3 << SCU_D2PLL_EXT1_MODE_SHIFT)
1173b95902dSmaxims@google.com #define SCU_D2PLL_EXT1_PARAM_SHIFT	5
1183b95902dSmaxims@google.com #define SCU_D2PLL_EXT1_PARAM_MASK	(0x1ff << SCU_D2PLL_EXT1_PARAM_SHIFT)
1193b95902dSmaxims@google.com 
1203b95902dSmaxims@google.com #define SCU_D2PLL_NUM_SHIFT		0
1213b95902dSmaxims@google.com #define SCU_D2PLL_NUM_MASK		(0xff << SCU_D2PLL_NUM_SHIFT)
1223b95902dSmaxims@google.com #define SCU_D2PLL_DENUM_SHIFT		8
1233b95902dSmaxims@google.com #define SCU_D2PLL_DENUM_MASK		(0x1f << SCU_D2PLL_DENUM_SHIFT)
1243b95902dSmaxims@google.com #define SCU_D2PLL_POST_SHIFT		13
1253b95902dSmaxims@google.com #define SCU_D2PLL_POST_MASK		(0x3f << SCU_D2PLL_POST_SHIFT)
1263b95902dSmaxims@google.com #define SCU_D2PLL_ODIV_SHIFT		19
1273b95902dSmaxims@google.com #define SCU_D2PLL_ODIV_MASK		(7 << SCU_D2PLL_ODIV_SHIFT)
1283b95902dSmaxims@google.com #define SCU_D2PLL_SIC_SHIFT		22
1293b95902dSmaxims@google.com #define SCU_D2PLL_SIC_MASK		(0x1f << SCU_D2PLL_SIC_SHIFT)
1303b95902dSmaxims@google.com #define SCU_D2PLL_SIP_SHIFT		27
1313b95902dSmaxims@google.com #define SCU_D2PLL_SIP_MASK		(0x1f << SCU_D2PLL_SIP_SHIFT)
1323b95902dSmaxims@google.com 
1333b95902dSmaxims@google.com #define SCU_CLKDUTY_DCLK_SHIFT		0
1343b95902dSmaxims@google.com #define SCU_CLKDUTY_DCLK_MASK		(0x3f << SCU_CLKDUTY_DCLK_SHIFT)
1353b95902dSmaxims@google.com #define SCU_CLKDUTY_RGMII1TXCK_SHIFT	8
1363b95902dSmaxims@google.com #define SCU_CLKDUTY_RGMII1TXCK_MASK	(0x7f << SCU_CLKDUTY_RGMII1TXCK_SHIFT)
1373b95902dSmaxims@google.com #define SCU_CLKDUTY_RGMII2TXCK_SHIFT	16
1383b95902dSmaxims@google.com #define SCU_CLKDUTY_RGMII2TXCK_MASK	(0x7f << SCU_CLKDUTY_RGMII2TXCK_SHIFT)
1393b95902dSmaxims@google.com 
14014e4b149Smaxims@google.com #ifndef __ASSEMBLY__
14114e4b149Smaxims@google.com 
14214e4b149Smaxims@google.com struct ast2500_clk_priv {
14314e4b149Smaxims@google.com 	struct ast2500_scu *scu;
14414e4b149Smaxims@google.com };
14514e4b149Smaxims@google.com 
14614e4b149Smaxims@google.com struct ast2500_scu {
14714e4b149Smaxims@google.com 	u32 protection_key;
14814e4b149Smaxims@google.com 	u32 sysreset_ctrl1;
14914e4b149Smaxims@google.com 	u32 clk_sel1;
15014e4b149Smaxims@google.com 	u32 clk_stop_ctrl1;
15114e4b149Smaxims@google.com 	u32 freq_counter_ctrl;
15214e4b149Smaxims@google.com 	u32 freq_counter_cmp;
15314e4b149Smaxims@google.com 	u32 intr_ctrl;
15414e4b149Smaxims@google.com 	u32 d2_pll_param;
15514e4b149Smaxims@google.com 	u32 m_pll_param;
15614e4b149Smaxims@google.com 	u32 h_pll_param;
15714e4b149Smaxims@google.com 	u32 d_pll_param;
15814e4b149Smaxims@google.com 	u32 misc_ctrl1;
15914e4b149Smaxims@google.com 	u32 pci_config[3];
16014e4b149Smaxims@google.com 	u32 sysreset_status;
16114e4b149Smaxims@google.com 	u32 vga_handshake[2];
16214e4b149Smaxims@google.com 	u32 mac_clk_delay;
16314e4b149Smaxims@google.com 	u32 misc_ctrl2;
16414e4b149Smaxims@google.com 	u32 vga_scratch[8];
16514e4b149Smaxims@google.com 	u32 hwstrap;
16614e4b149Smaxims@google.com 	u32 rng_ctrl;
16714e4b149Smaxims@google.com 	u32 rng_data;
16814e4b149Smaxims@google.com 	u32 rev_id;
16914e4b149Smaxims@google.com 	u32 pinmux_ctrl[6];
17014e4b149Smaxims@google.com 	u32 reserved0;
17114e4b149Smaxims@google.com 	u32 extrst_sel;
17214e4b149Smaxims@google.com 	u32 pinmux_ctrl1[4];
17314e4b149Smaxims@google.com 	u32 reserved1[2];
17414e4b149Smaxims@google.com 	u32 mac_clk_delay_100M;
17514e4b149Smaxims@google.com 	u32 mac_clk_delay_10M;
17614e4b149Smaxims@google.com 	u32 wakeup_enable;
17714e4b149Smaxims@google.com 	u32 wakeup_control;
17814e4b149Smaxims@google.com 	u32 reserved2[3];
17914e4b149Smaxims@google.com 	u32 sysreset_ctrl2;
18014e4b149Smaxims@google.com 	u32 clk_sel2;
18114e4b149Smaxims@google.com 	u32 clk_stop_ctrl2;
18214e4b149Smaxims@google.com 	u32 freerun_counter;
18314e4b149Smaxims@google.com 	u32 freerun_counter_ext;
18414e4b149Smaxims@google.com 	u32 clk_duty_meas_ctrl;
18514e4b149Smaxims@google.com 	u32 clk_duty_meas_res;
18614e4b149Smaxims@google.com 	u32 reserved3[4];
18714e4b149Smaxims@google.com 	/* The next registers are not key-protected */
18814e4b149Smaxims@google.com 	struct ast2500_cpu2 {
18914e4b149Smaxims@google.com 		u32 ctrl;
19014e4b149Smaxims@google.com 		u32 base_addr[9];
19114e4b149Smaxims@google.com 		u32 cache_ctrl;
19214e4b149Smaxims@google.com 	} cpu2;
19314e4b149Smaxims@google.com 	u32 reserved4;
19414e4b149Smaxims@google.com 	u32 d_pll_ext_param[3];
19514e4b149Smaxims@google.com 	u32 d2_pll_ext_param[3];
19614e4b149Smaxims@google.com 	u32 mh_pll_ext_param;
19714e4b149Smaxims@google.com 	u32 reserved5;
19814e4b149Smaxims@google.com 	u32 chip_id[2];
19914e4b149Smaxims@google.com 	u32 reserved6[2];
20014e4b149Smaxims@google.com 	u32 uart_clk_ctrl;
20114e4b149Smaxims@google.com 	u32 reserved7[7];
20214e4b149Smaxims@google.com 	u32 pcie_config;
20314e4b149Smaxims@google.com 	u32 mmio_decode;
20414e4b149Smaxims@google.com 	u32 reloc_ctrl_decode[2];
20514e4b149Smaxims@google.com 	u32 mailbox_addr;
20614e4b149Smaxims@google.com 	u32 shared_sram_decode[2];
20714e4b149Smaxims@google.com 	u32 bmc_rev_id;
20814e4b149Smaxims@google.com 	u32 reserved8;
20914e4b149Smaxims@google.com 	u32 bmc_device_id;
21014e4b149Smaxims@google.com 	u32 reserved9[13];
21114e4b149Smaxims@google.com 	u32 clk_duty_sel;
21214e4b149Smaxims@google.com };
21314e4b149Smaxims@google.com 
21414e4b149Smaxims@google.com /**
21514e4b149Smaxims@google.com  * ast_get_clk() - get a pointer to Clock Driver
21614e4b149Smaxims@google.com  *
21714e4b149Smaxims@google.com  * @devp, OUT - pointer to Clock Driver
21814e4b149Smaxims@google.com  * @return zero on success, error code (< 0) otherwise.
21914e4b149Smaxims@google.com  */
22014e4b149Smaxims@google.com int ast_get_clk(struct udevice **devp);
22114e4b149Smaxims@google.com 
22214e4b149Smaxims@google.com /**
22314e4b149Smaxims@google.com  * ast_get_scu() - get a pointer to SCU registers
22414e4b149Smaxims@google.com  *
22514e4b149Smaxims@google.com  * @return pointer to struct ast2500_scu on success, ERR_PTR otherwise
22614e4b149Smaxims@google.com  */
22714e4b149Smaxims@google.com void *ast_get_scu(void);
22814e4b149Smaxims@google.com 
229413353b3Smaxims@google.com /**
230413353b3Smaxims@google.com  * ast_scu_unlock() - unlock protected registers
231413353b3Smaxims@google.com  *
232413353b3Smaxims@google.com  * @scu, pointer to ast2500_scu
233413353b3Smaxims@google.com  */
234413353b3Smaxims@google.com void ast_scu_unlock(struct ast2500_scu *scu);
235413353b3Smaxims@google.com 
236413353b3Smaxims@google.com /**
237413353b3Smaxims@google.com  * ast_scu_lock() - lock protected registers
238413353b3Smaxims@google.com  *
239413353b3Smaxims@google.com  * @scu, pointer to ast2500_scu
240413353b3Smaxims@google.com  */
241413353b3Smaxims@google.com void ast_scu_lock(struct ast2500_scu *scu);
242413353b3Smaxims@google.com 
24314e4b149Smaxims@google.com #endif  /* __ASSEMBLY__ */
24414e4b149Smaxims@google.com 
24514e4b149Smaxims@google.com #endif  /* _ASM_ARCH_SCU_AST2500_H */
246