xref: /rk3399_rockchip-uboot/arch/arm/include/asm/arch-aspeed/scu_ast2500.h (revision 858d4976293f0b3d72e5dcf0e8a1a973efafeee3)
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_MASK		3
1214e4b149Smaxims@google.com #define SCU_HWSTRAP_VGAMEM_SHIFT	2
1314e4b149Smaxims@google.com #define SCU_HWSTRAP_DDR4		(1 << 24)
1414e4b149Smaxims@google.com #define SCU_HWSTRAP_CLKIN_25MHZ		(1 << 23)
1514e4b149Smaxims@google.com 
1614e4b149Smaxims@google.com #define SCU_MPLL_DENUM_SHIFT		0
1714e4b149Smaxims@google.com #define SCU_MPLL_DENUM_MASK		0x1f
1814e4b149Smaxims@google.com #define SCU_MPLL_NUM_SHIFT		5
1914e4b149Smaxims@google.com #define SCU_MPLL_NUM_MASK		0xff
2014e4b149Smaxims@google.com #define SCU_MPLL_POST_SHIFT		13
2114e4b149Smaxims@google.com #define SCU_MPLL_POST_MASK		0x3f
2214e4b149Smaxims@google.com 
2314e4b149Smaxims@google.com #define SCU_HPLL_DENUM_SHIFT		0
2414e4b149Smaxims@google.com #define SCU_HPLL_DENUM_MASK		0x1f
2514e4b149Smaxims@google.com #define SCU_HPLL_NUM_SHIFT		5
2614e4b149Smaxims@google.com #define SCU_HPLL_NUM_MASK		0xff
2714e4b149Smaxims@google.com #define SCU_HPLL_POST_SHIFT		13
2814e4b149Smaxims@google.com #define SCU_HPLL_POST_MASK		0x3f
2914e4b149Smaxims@google.com 
3014e4b149Smaxims@google.com #define SCU_MISC2_UARTCLK_SHIFT		24
3114e4b149Smaxims@google.com 
3214e4b149Smaxims@google.com #define SCU_MISC_UARTCLK_DIV13		(1 << 12)
3314e4b149Smaxims@google.com 
34*858d4976Smaxims@google.com /*
35*858d4976Smaxims@google.com  * SYSRESET is actually more like a Power register,
36*858d4976Smaxims@google.com  * except that corresponding bit set to 1 means that
37*858d4976Smaxims@google.com  * the peripheral is off.
38*858d4976Smaxims@google.com  */
39*858d4976Smaxims@google.com #define SCU_SYSRESET_XDMA		(1 << 25)
40*858d4976Smaxims@google.com #define SCU_SYSRESET_MCTP		(1 << 24)
41*858d4976Smaxims@google.com #define SCU_SYSRESET_ADC		(1 << 23)
42*858d4976Smaxims@google.com #define SCU_SYSRESET_JTAG		(1 << 22)
43*858d4976Smaxims@google.com #define SCU_SYSRESET_MIC		(1 << 18)
44*858d4976Smaxims@google.com #define SCU_SYSRESET_SDIO		(1 << 16)
45*858d4976Smaxims@google.com #define SCU_SYSRESET_USB11HOST		(1 << 15)
46*858d4976Smaxims@google.com #define SCU_SYSRESET_USBHUB		(1 << 14)
47*858d4976Smaxims@google.com #define SCU_SYSRESET_CRT		(1 << 13)
48*858d4976Smaxims@google.com #define SCU_SYSRESET_MAC2		(1 << 12)
49*858d4976Smaxims@google.com #define SCU_SYSRESET_MAC1		(1 << 11)
50*858d4976Smaxims@google.com #define SCU_SYSRESET_PECI		(1 << 10)
51*858d4976Smaxims@google.com #define SCU_SYSRESET_PWM		(1 << 9)
52*858d4976Smaxims@google.com #define SCU_SYSRESET_PCI_VGA		(1 << 8)
53*858d4976Smaxims@google.com #define SCU_SYSRESET_2D			(1 << 7)
54*858d4976Smaxims@google.com #define SCU_SYSRESET_VIDEO		(1 << 6)
55*858d4976Smaxims@google.com #define SCU_SYSRESET_LPC		(1 << 5)
56*858d4976Smaxims@google.com #define SCU_SYSRESET_HAC		(1 << 4)
57*858d4976Smaxims@google.com #define SCU_SYSRESET_USBHID		(1 << 3)
58*858d4976Smaxims@google.com #define SCU_SYSRESET_I2C		(1 << 2)
59*858d4976Smaxims@google.com #define SCU_SYSRESET_AHB		(1 << 1)
60*858d4976Smaxims@google.com #define SCU_SYSRESET_SDRAM_WDT		(1 << 0)
61*858d4976Smaxims@google.com 
6214e4b149Smaxims@google.com #ifndef __ASSEMBLY__
6314e4b149Smaxims@google.com 
6414e4b149Smaxims@google.com struct ast2500_clk_priv {
6514e4b149Smaxims@google.com 	struct ast2500_scu *scu;
6614e4b149Smaxims@google.com };
6714e4b149Smaxims@google.com 
6814e4b149Smaxims@google.com struct ast2500_scu {
6914e4b149Smaxims@google.com 	u32 protection_key;
7014e4b149Smaxims@google.com 	u32 sysreset_ctrl1;
7114e4b149Smaxims@google.com 	u32 clk_sel1;
7214e4b149Smaxims@google.com 	u32 clk_stop_ctrl1;
7314e4b149Smaxims@google.com 	u32 freq_counter_ctrl;
7414e4b149Smaxims@google.com 	u32 freq_counter_cmp;
7514e4b149Smaxims@google.com 	u32 intr_ctrl;
7614e4b149Smaxims@google.com 	u32 d2_pll_param;
7714e4b149Smaxims@google.com 	u32 m_pll_param;
7814e4b149Smaxims@google.com 	u32 h_pll_param;
7914e4b149Smaxims@google.com 	u32 d_pll_param;
8014e4b149Smaxims@google.com 	u32 misc_ctrl1;
8114e4b149Smaxims@google.com 	u32 pci_config[3];
8214e4b149Smaxims@google.com 	u32 sysreset_status;
8314e4b149Smaxims@google.com 	u32 vga_handshake[2];
8414e4b149Smaxims@google.com 	u32 mac_clk_delay;
8514e4b149Smaxims@google.com 	u32 misc_ctrl2;
8614e4b149Smaxims@google.com 	u32 vga_scratch[8];
8714e4b149Smaxims@google.com 	u32 hwstrap;
8814e4b149Smaxims@google.com 	u32 rng_ctrl;
8914e4b149Smaxims@google.com 	u32 rng_data;
9014e4b149Smaxims@google.com 	u32 rev_id;
9114e4b149Smaxims@google.com 	u32 pinmux_ctrl[6];
9214e4b149Smaxims@google.com 	u32 reserved0;
9314e4b149Smaxims@google.com 	u32 extrst_sel;
9414e4b149Smaxims@google.com 	u32 pinmux_ctrl1[4];
9514e4b149Smaxims@google.com 	u32 reserved1[2];
9614e4b149Smaxims@google.com 	u32 mac_clk_delay_100M;
9714e4b149Smaxims@google.com 	u32 mac_clk_delay_10M;
9814e4b149Smaxims@google.com 	u32 wakeup_enable;
9914e4b149Smaxims@google.com 	u32 wakeup_control;
10014e4b149Smaxims@google.com 	u32 reserved2[3];
10114e4b149Smaxims@google.com 	u32 sysreset_ctrl2;
10214e4b149Smaxims@google.com 	u32 clk_sel2;
10314e4b149Smaxims@google.com 	u32 clk_stop_ctrl2;
10414e4b149Smaxims@google.com 	u32 freerun_counter;
10514e4b149Smaxims@google.com 	u32 freerun_counter_ext;
10614e4b149Smaxims@google.com 	u32 clk_duty_meas_ctrl;
10714e4b149Smaxims@google.com 	u32 clk_duty_meas_res;
10814e4b149Smaxims@google.com 	u32 reserved3[4];
10914e4b149Smaxims@google.com 	/* The next registers are not key-protected */
11014e4b149Smaxims@google.com 	struct ast2500_cpu2 {
11114e4b149Smaxims@google.com 		u32 ctrl;
11214e4b149Smaxims@google.com 		u32 base_addr[9];
11314e4b149Smaxims@google.com 		u32 cache_ctrl;
11414e4b149Smaxims@google.com 	} cpu2;
11514e4b149Smaxims@google.com 	u32 reserved4;
11614e4b149Smaxims@google.com 	u32 d_pll_ext_param[3];
11714e4b149Smaxims@google.com 	u32 d2_pll_ext_param[3];
11814e4b149Smaxims@google.com 	u32 mh_pll_ext_param;
11914e4b149Smaxims@google.com 	u32 reserved5;
12014e4b149Smaxims@google.com 	u32 chip_id[2];
12114e4b149Smaxims@google.com 	u32 reserved6[2];
12214e4b149Smaxims@google.com 	u32 uart_clk_ctrl;
12314e4b149Smaxims@google.com 	u32 reserved7[7];
12414e4b149Smaxims@google.com 	u32 pcie_config;
12514e4b149Smaxims@google.com 	u32 mmio_decode;
12614e4b149Smaxims@google.com 	u32 reloc_ctrl_decode[2];
12714e4b149Smaxims@google.com 	u32 mailbox_addr;
12814e4b149Smaxims@google.com 	u32 shared_sram_decode[2];
12914e4b149Smaxims@google.com 	u32 bmc_rev_id;
13014e4b149Smaxims@google.com 	u32 reserved8;
13114e4b149Smaxims@google.com 	u32 bmc_device_id;
13214e4b149Smaxims@google.com 	u32 reserved9[13];
13314e4b149Smaxims@google.com 	u32 clk_duty_sel;
13414e4b149Smaxims@google.com };
13514e4b149Smaxims@google.com 
13614e4b149Smaxims@google.com /**
13714e4b149Smaxims@google.com  * ast_get_clk() - get a pointer to Clock Driver
13814e4b149Smaxims@google.com  *
13914e4b149Smaxims@google.com  * @devp, OUT - pointer to Clock Driver
14014e4b149Smaxims@google.com  * @return zero on success, error code (< 0) otherwise.
14114e4b149Smaxims@google.com  */
14214e4b149Smaxims@google.com int ast_get_clk(struct udevice **devp);
14314e4b149Smaxims@google.com 
14414e4b149Smaxims@google.com /**
14514e4b149Smaxims@google.com  * ast_get_scu() - get a pointer to SCU registers
14614e4b149Smaxims@google.com  *
14714e4b149Smaxims@google.com  * @return pointer to struct ast2500_scu on success, ERR_PTR otherwise
14814e4b149Smaxims@google.com  */
14914e4b149Smaxims@google.com void *ast_get_scu(void);
15014e4b149Smaxims@google.com 
151413353b3Smaxims@google.com /**
152413353b3Smaxims@google.com  * ast_scu_unlock() - unlock protected registers
153413353b3Smaxims@google.com  *
154413353b3Smaxims@google.com  * @scu, pointer to ast2500_scu
155413353b3Smaxims@google.com  */
156413353b3Smaxims@google.com void ast_scu_unlock(struct ast2500_scu *scu);
157413353b3Smaxims@google.com 
158413353b3Smaxims@google.com /**
159413353b3Smaxims@google.com  * ast_scu_lock() - lock protected registers
160413353b3Smaxims@google.com  *
161413353b3Smaxims@google.com  * @scu, pointer to ast2500_scu
162413353b3Smaxims@google.com  */
163413353b3Smaxims@google.com void ast_scu_lock(struct ast2500_scu *scu);
164413353b3Smaxims@google.com 
16514e4b149Smaxims@google.com #endif  /* __ASSEMBLY__ */
16614e4b149Smaxims@google.com 
16714e4b149Smaxims@google.com #endif  /* _ASM_ARCH_SCU_AST2500_H */
168