diff options
author | Tom Rini <trini@konsulko.com> | 2018-08-04 19:41:30 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-08-04 19:41:30 -0400 |
commit | 0cba6e906a5a94b68dc4b42dc5e9bca8e77798f7 (patch) | |
tree | f5160ba496f6e75862800726c989a616f5551547 /arch/arm/include/asm/arch-sunxi | |
parent | d64caaf77dec2f0a576d0d1f7c7f4f463ebc7de8 (diff) | |
parent | 89a897fc4d78e31332e5899e977d8bf3c82abafa (diff) |
Merge branch 'master' of git://git.denx.de/u-boot-sunxi
Diffstat (limited to 'arch/arm/include/asm/arch-sunxi')
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/boot0.h | 4 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/clock.h | 2 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h | 320 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/cpu.h | 2 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h | 73 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/dram.h | 2 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h | 297 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/gpio.h | 1 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/mmc.h | 2 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/spl.h | 6 | ||||
-rw-r--r-- | arch/arm/include/asm/arch-sunxi/timer.h | 2 |
11 files changed, 704 insertions, 7 deletions
diff --git a/arch/arm/include/asm/arch-sunxi/boot0.h b/arch/arm/include/asm/arch-sunxi/boot0.h index c826fec415..54c144afd8 100644 --- a/arch/arm/include/asm/arch-sunxi/boot0.h +++ b/arch/arm/include/asm/arch-sunxi/boot0.h @@ -26,7 +26,11 @@ .word 0xf57ff06f // isb sy .word 0xe320f003 // wfi .word 0xeafffffd // b @wfi +#ifndef CONFIG_MACH_SUN50I_H6 .word 0x017000a0 // writeable RVBAR mapping address +#else + .word 0x09010040 // writeable RVBAR mapping address +#endif #ifdef CONFIG_SPL_BUILD .word CONFIG_SPL_TEXT_BASE #else diff --git a/arch/arm/include/asm/arch-sunxi/clock.h b/arch/arm/include/asm/arch-sunxi/clock.h index 46c3eed377..5994130e6b 100644 --- a/arch/arm/include/asm/arch-sunxi/clock.h +++ b/arch/arm/include/asm/arch-sunxi/clock.h @@ -16,6 +16,8 @@ /* clock control module regs definition */ #if defined(CONFIG_MACH_SUN8I_A83T) #include <asm/arch/clock_sun8i_a83t.h> +#elif defined(CONFIG_MACH_SUN50I_H6) +#include <asm/arch/clock_sun50i_h6.h> #elif defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN8I) || \ defined(CONFIG_MACH_SUN50I) #include <asm/arch/clock_sun6i.h> diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h b/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h new file mode 100644 index 0000000000..e36937059b --- /dev/null +++ b/arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h @@ -0,0 +1,320 @@ +/* + * Allwinner H6 clock register definitions + * + * (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _SUNXI_CLOCK_SUN50I_H6_H +#define _SUNXI_CLOCK_SUN50I_H6_H + +struct sunxi_ccm_reg { + u32 pll1_cfg; /* 0x000 pll1 (cpux) control */ + u8 reserved_0x004[12]; + u32 pll5_cfg; /* 0x010 pll5 (ddr) control */ + u8 reserved_0x014[12]; + u32 pll6_cfg; /* 0x020 pll6 (periph0) control */ + u8 reserved_0x020[4]; + u32 pll_periph1_cfg; /* 0x028 pll periph1 control */ + u8 reserved_0x028[4]; + u32 pll7_cfg; /* 0x030 pll7 (gpu) control */ + u8 reserved_0x034[12]; + u32 pll3_cfg; /* 0x040 pll3 (video0) control */ + u8 reserved_0x044[4]; + u32 pll_video1_cfg; /* 0x048 pll video1 control */ + u8 reserved_0x04c[12]; + u32 pll4_cfg; /* 0x058 pll4 (ve) control */ + u8 reserved_0x05c[4]; + u32 pll10_cfg; /* 0x060 pll10 (de) control */ + u8 reserved_0x064[12]; + u32 pll9_cfg; /* 0x070 pll9 (hsic) control */ + u8 reserved_0x074[4]; + u32 pll2_cfg; /* 0x078 pll2 (audio) control */ + u8 reserved_0x07c[148]; + u32 pll5_pat; /* 0x110 pll5 (ddr) pattern */ + u8 reserved_0x114[20]; + u32 pll_periph1_pat0; /* 0x128 pll periph1 pattern0 */ + u32 pll_periph1_pat1; /* 0x12c pll periph1 pattern1 */ + u32 pll7_pat0; /* 0x130 pll7 (gpu) pattern0 */ + u32 pll7_pat1; /* 0x134 pll7 (gpu) pattern1 */ + u8 reserved_0x138[8]; + u32 pll3_pat0; /* 0x140 pll3 (video0) pattern0 */ + u32 pll3_pat1; /* 0x144 pll3 (video0) pattern1 */ + u32 pll_video1_pat0; /* 0x148 pll video1 pattern0 */ + u32 pll_video1_pat1; /* 0x14c pll video1 pattern1 */ + u8 reserved_0x150[8]; + u32 pll4_pat0; /* 0x158 pll4 (ve) pattern0 */ + u32 pll4_pat1; /* 0x15c pll4 (ve) pattern1 */ + u32 pll10_pat0; /* 0x160 pll10 (de) pattern0 */ + u32 pll10_pat1; /* 0x164 pll10 (de) pattern1 */ + u8 reserved_0x168[8]; + u32 pll9_pat0; /* 0x170 pll9 (hsic) pattern0 */ + u32 pll9_pat1; /* 0x174 pll9 (hsic) pattern1 */ + u32 pll2_pat0; /* 0x178 pll2 (audio) pattern0 */ + u32 pll2_pat1; /* 0x17c pll2 (audio) pattern1 */ + u8 reserved_0x180[384]; + u32 pll1_bias; /* 0x300 pll1 (cpux) bias */ + u8 reserved_0x304[12]; + u32 pll5_bias; /* 0x310 pll5 (ddr) bias */ + u8 reserved_0x314[12]; + u32 pll6_bias; /* 0x320 pll6 (periph0) bias */ + u8 reserved_0x324[4]; + u32 pll_periph1_bias; /* 0x328 pll periph1 bias */ + u8 reserved_0x32c[4]; + u32 pll7_bias; /* 0x330 pll7 (gpu) bias */ + u8 reserved_0x334[12]; + u32 pll3_bias; /* 0x340 pll3 (video0) bias */ + u8 reserved_0x344[4]; + u32 pll_video1_bias; /* 0x348 pll video1 bias */ + u8 reserved_0x34c[12]; + u32 pll4_bias; /* 0x358 pll4 (ve) bias */ + u8 reserved_0x35c[4]; + u32 pll10_bias; /* 0x360 pll10 (de) bias */ + u8 reserved_0x364[12]; + u32 pll9_bias; /* 0x370 pll9 (hsic) bias */ + u8 reserved_0x374[4]; + u32 pll2_bias; /* 0x378 pll2 (audio) bias */ + u8 reserved_0x37c[132]; + u32 pll1_tun; /* 0x400 pll1 (cpux) tunning */ + u8 reserved_0x404[252]; + u32 cpu_axi_cfg; /* 0x500 CPUX/AXI clock control*/ + u8 reserved_0x504[12]; + u32 psi_ahb1_ahb2_cfg; /* 0x510 PSI/AHB1/AHB2 clock control */ + u8 reserved_0x514[8]; + u32 ahb3_cfg; /* 0x51c AHB3 clock control */ + u32 apb1_cfg; /* 0x520 APB1 clock control */ + u32 apb2_cfg; /* 0x524 APB2 clock control */ + u8 reserved_0x528[24]; + u32 mbus_cfg; /* 0x540 MBUS clock control */ + u8 reserved_0x544[188]; + u32 de_clk_cfg; /* 0x600 DE clock control */ + u8 reserved_0x604[8]; + u32 de_gate_reset; /* 0x60c DE gate/reset control */ + u8 reserved_0x610[16]; + u32 di_clk_cfg; /* 0x620 DI clock control */ + u8 reserved_0x024[8]; + u32 di_gate_reset; /* 0x62c DI gate/reset control */ + u8 reserved_0x630[64]; + u32 gpu_clk_cfg; /* 0x670 GPU clock control */ + u8 reserved_0x674[8]; + u32 gpu_gate_reset; /* 0x67c GPU gate/reset control */ + u32 ce_clk_cfg; /* 0x680 CE clock control */ + u8 reserved_0x684[8]; + u32 ce_gate_reset; /* 0x68c CE gate/reset control */ + u32 ve_clk_cfg; /* 0x690 VE clock control */ + u8 reserved_0x694[8]; + u32 ve_gate_reset; /* 0x69c VE gate/reset control */ + u8 reserved_0x6a0[16]; + u32 emce_clk_cfg; /* 0x6b0 EMCE clock control */ + u8 reserved_0x6b4[8]; + u32 emce_gate_reset; /* 0x6bc EMCE gate/reset control */ + u32 vp9_clk_cfg; /* 0x6c0 VP9 clock control */ + u8 reserved_0x6c4[8]; + u32 vp9_gate_reset; /* 0x6cc VP9 gate/reset control */ + u8 reserved_0x6d0[60]; + u32 dma_gate_reset; /* 0x70c DMA gate/reset control */ + u8 reserved_0x710[12]; + u32 msgbox_gate_reset; /* 0x71c Message Box gate/reset control */ + u8 reserved_0x720[12]; + u32 spinlock_gate_reset;/* 0x72c Spinlock gate/reset control */ + u8 reserved_0x730[12]; + u32 hstimer_gate_reset; /* 0x73c HS Timer gate/reset control */ + u32 avs_gate_reset; /* 0x740 AVS gate/reset control */ + u8 reserved_0x744[72]; + u32 dbgsys_gate_reset; /* 0x78c Debugging system gate/reset control */ + u8 reserved_0x790[12]; + u32 psi_gate_reset; /* 0x79c PSI gate/reset control */ + u8 reserved_0x7a0[12]; + u32 pwm_gate_reset; /* 0x7ac PWM gate/reset control */ + u8 reserved_0x7b0[12]; + u32 iommu_gate_reset; /* 0x7bc IOMMU gate/reset control */ + u8 reserved_0x7c0[64]; + u32 dram_clk_cfg; /* 0x800 DRAM clock control */ + u32 mbus_gate; /* 0x804 MBUS gate control */ + u8 reserved_0x808[4]; + u32 dram_gate_reset; /* 0x80c DRAM gate/reset control */ + u32 nand0_clk_cfg; /* 0x810 NAND0 clock control */ + u32 nand1_clk_cfg; /* 0x814 NAND1 clock control */ + u8 reserved_0x818[20]; + u32 nand_gate_reset; /* 0x82c NAND gate/reset control */ + u32 sd0_clk_cfg; /* 0x830 MMC0 clock control */ + u32 sd1_clk_cfg; /* 0x834 MMC1 clock control */ + u32 sd2_clk_cfg; /* 0x838 MMC2 clock control */ + u8 reserved_0x83c[16]; + u32 sd_gate_reset; /* 0x84c MMC gate/reset control */ + u8 reserved_0x850[188]; + u32 uart_gate_reset; /* 0x90c UART gate/reset control */ + u8 reserved_0x910[12]; + u32 twi_gate_reset; /* 0x91c I2C gate/reset control */ + u8 reserved_0x920[28]; + u32 scr_gate_reset; /* 0x93c SCR gate/reset control */ + u32 spi0_clk_cfg; /* 0x940 SPI0 clock control */ + u32 spi1_clk_cfg; /* 0x944 SPI1 clock control */ + u8 reserved_0x948[36]; + u32 spi_gate_reset; /* 0x96c SPI gate/reset control */ + u8 reserved_0x970[12]; + u32 emac_gate_reset; /* 0x97c EMAC gate/reset control */ + u8 reserved_0x980[48]; + u32 ts_clk_cfg; /* 0x9b0 TS clock control */ + u8 reserved_0x9b4[8]; + u32 ts_gate_reset; /* 0x9bc TS gate/reset control */ + u32 irtx_clk_cfg; /* 0x9c0 IR TX clock control */ + u8 reserved_0x9c4[8]; + u32 irtx_gate_reset; /* 0x9cc IR TX gate/reset control */ + u8 reserved_0x9d0[44]; + u32 ths_gate_reset; /* 0x9fc THS gate/reset control */ + u8 reserved_0xa00[12]; + u32 i2s3_clk_cfg; /* 0xa0c I2S3 clock control */ + u32 i2s0_clk_cfg; /* 0xa10 I2S0 clock control */ + u32 i2s1_clk_cfg; /* 0xa14 I2S1 clock control */ + u32 i2s2_clk_cfg; /* 0xa18 I2S2 clock control */ + u32 i2s_gate_reset; /* 0xa1c I2S gate/reset control */ + u32 spdif_clk_cfg; /* 0xa20 SPDIF clock control */ + u8 reserved_0xa24[8]; + u32 spdif_gate_reset; /* 0xa2c SPDIF gate/reset control */ + u8 reserved_0xa30[16]; + u32 dmic_clk_cfg; /* 0xa40 DMIC clock control */ + u8 reserved_0xa44[8]; + u32 dmic_gate_reset; /* 0xa4c DMIC gate/reset control */ + u8 reserved_0xa50[16]; + u32 ahub_clk_cfg; /* 0xa60 Audio HUB clock control */ + u8 reserved_0xa64[8]; + u32 ahub_gate_reset; /* 0xa6c Audio HUB gate/reset control */ + u32 usb0_clk_cfg; /* 0xa70 USB0(OTG) clock control */ + u32 usb1_clk_cfg; /* 0xa74 USB1(XHCI) clock control */ + u8 reserved_0xa78[4]; + u32 usb3_clk_cfg; /* 0xa78 USB3 clock control */ + u8 reserved_0xa80[12]; + u32 usb_gate_reset; /* 0xa8c USB gate/reset control */ + u8 reserved_0xa90[32]; + u32 pcie_ref_clk_cfg; /* 0xab0 PCIE REF clock control */ + u32 pcie_axi_clk_cfg; /* 0xab4 PCIE AXI clock control */ + u32 pcie_aux_clk_cfg; /* 0xab8 PCIE AUX clock control */ + u32 pcie_gate_reset; /* 0xabc PCIE gate/reset control */ + u8 reserved_0xac0[64]; + u32 hdmi_clk_cfg; /* 0xb00 HDMI clock control */ + u32 hdmi_slow_clk_cfg; /* 0xb04 HDMI slow clock control */ + u8 reserved_0xb08[8]; + u32 hdmi_cec_clk_cfg; /* 0xb10 HDMI CEC clock control */ + u8 reserved_0xb14[8]; + u32 hdmi_gate_reset; /* 0xb1c HDMI gate/reset control */ + u8 reserved_0xb20[60]; + u32 tcon_top_gate_reset;/* 0xb5c TCON TOP gate/reset control */ + u32 tcon_lcd0_clk_cfg; /* 0xb60 TCON LCD0 clock control */ + u8 reserved_0xb64[24]; + u32 tcon_lcd_gate_reset;/* 0xb7c TCON LCD gate/reset control */ + u32 tcon_tv0_clk_cfg; /* 0xb80 TCON TV0 clock control */ + u8 reserved_0xb84[24]; + u32 tcon_tv_gate_reset; /* 0xb9c TCON TV gate/reset control */ + u8 reserved_0xba0[96]; + u32 csi_misc_clk_cfg; /* 0xc00 CSI MISC clock control */ + u32 csi_top_clk_cfg; /* 0xc04 CSI TOP clock control */ + u32 csi_mclk_cfg; /* 0xc08 CSI Master clock control */ + u8 reserved_0xc0c[32]; + u32 csi_gate_reset; /* 0xc2c CSI gate/reset control */ + u8 reserved_0xc30[16]; + u32 hdcp_clk_cfg; /* 0xc40 HDCP clock control */ + u8 reserved_0xc44[8]; + u32 hdcp_gate_reset; /* 0xc4c HDCP gate/reset control */ + u8 reserved_0xc50[688]; + u32 ccu_sec_switch; /* 0xf00 CCU security switch */ + u32 pll_lock_dbg_ctrl; /* 0xf04 PLL lock debugging control */ +}; + +/* pll1 bit field */ +#define CCM_PLL1_CTRL_EN BIT(31) +#define CCM_PLL1_LOCK_EN BIT(29) +#define CCM_PLL1_LOCK BIT(28) +#define CCM_PLL1_CLOCK_TIME_2 (2 << 24) +#define CCM_PLL1_CTRL_P(p) ((p) << 16) +#define CCM_PLL1_CTRL_N(n) ((n) << 8) + +/* pll5 bit field */ +#define CCM_PLL5_CTRL_EN BIT(31) +#define CCM_PLL5_LOCK_EN BIT(29) +#define CCM_PLL5_LOCK BIT(28) +#define CCM_PLL5_CTRL_N(n) ((n) << 8) +#define CCM_PLL5_CTRL_DIV1(div1) ((div1) << 0) +#define CCM_PLL5_CTRL_DIV2(div0) ((div0) << 1) + +/* pll6 bit field */ +#define CCM_PLL6_CTRL_EN BIT(31) +#define CCM_PLL6_LOCK_EN BIT(29) +#define CCM_PLL6_LOCK BIT(28) +#define CCM_PLL6_CTRL_N_SHIFT 8 +#define CCM_PLL6_CTRL_N_MASK (0xff << CCM_PLL6_CTRL_N_SHIFT) +#define CCM_PLL6_CTRL_DIV1_SHIFT 0 +#define CCM_PLL6_CTRL_DIV1_MASK (0x1 << CCM_PLL6_CTRL_DIV1_SHIFT) +#define CCM_PLL6_CTRL_DIV2_SHIFT 1 +#define CCM_PLL6_CTRL_DIV2_MASK (0x1 << CCM_PLL6_CTRL_DIV2_SHIFT) +#define CCM_PLL6_DEFAULT 0xa0006300 + +/* cpu_axi bit field*/ +#define CCM_CPU_AXI_MUX_MASK (0x3 << 24) +#define CCM_CPU_AXI_MUX_OSC24M (0x0 << 24) +#define CCM_CPU_AXI_MUX_PLL_CPUX (0x3 << 24) +#define CCM_CPU_AXI_APB_MASK 0x300 +#define CCM_CPU_AXI_AXI_MASK 0x3 +#define CCM_CPU_AXI_DEFAULT_FACTORS 0x301 + +/* psi_ahb1_ahb2 bit field */ +#define CCM_PSI_AHB1_AHB2_DEFAULT 0x03000102 + +/* ahb3 bit field */ +#define CCM_AHB3_DEFAULT 0x03000002 + +/* apb1 bit field */ +#define CCM_APB1_DEFAULT 0x03000102 + +/* apb2 bit field */ +#define APB2_CLK_SRC_OSC24M (0x0 << 24) +#define APB2_CLK_SRC_OSC32K (0x1 << 24) +#define APB2_CLK_SRC_PSI (0x2 << 24) +#define APB2_CLK_SRC_PLL6 (0x3 << 24) +#define APB2_CLK_SRC_MASK (0x3 << 24) +#define APB2_CLK_RATE_N_1 (0x0 << 8) +#define APB2_CLK_RATE_N_2 (0x1 << 8) +#define APB2_CLK_RATE_N_4 (0x2 << 8) +#define APB2_CLK_RATE_N_8 (0x3 << 8) +#define APB2_CLK_RATE_N_MASK (3 << 8) +#define APB2_CLK_RATE_M(m) (((m)-1) << 0) +#define APB2_CLK_RATE_M_MASK (3 << 0) + +/* MBUS clock bit field */ +#define MBUS_ENABLE BIT(31) +#define MBUS_RESET BIT(30) +#define MBUS_CLK_SRC_MASK GENMASK(25, 24) +#define MBUS_CLK_SRC_OSCM24 (0 << 24) +#define MBUS_CLK_SRC_PLL6X2 (1 << 24) +#define MBUS_CLK_SRC_PLL5 (2 << 24) +#define MBUS_CLK_SRC_PLL6X4 (3 << 24) +#define MBUS_CLK_M(m) (((m)-1) << 0) + +/* Module gate/reset shift*/ +#define RESET_SHIFT (16) + +/* DRAM clock bit field */ +#define DRAM_MOD_RESET BIT(30) +#define DRAM_CLK_UPDATE BIT(27) +#define DRAM_CLK_SRC_MASK GENMASK(25, 24) +#define DRAM_CLK_SRC_PLL5 (0 << 24) +#define DRAM_CLK_M(m) (((m)-1) << 0) + +/* MMC clock bit field */ +#define CCM_MMC_CTRL_M(x) ((x) - 1) +#define CCM_MMC_CTRL_N(x) ((x) << 8) +#define CCM_MMC_CTRL_OSCM24 (0x0 << 24) +#define CCM_MMC_CTRL_PLL6X2 (0x1 << 24) +#define CCM_MMC_CTRL_PLL_PERIPH2X2 (0x2 << 24) +#define CCM_MMC_CTRL_ENABLE (0x1 << 31) +/* H6 doesn't have these delays */ +#define CCM_MMC_CTRL_OCLK_DLY(a) ((void) (a), 0) +#define CCM_MMC_CTRL_SCLK_DLY(a) ((void) (a), 0) + +#ifndef __ASSEMBLY__ +void clock_set_pll1(unsigned int hz); +unsigned int clock_get_pll6(void); +#endif + +#endif /* _SUNXI_CLOCK_SUN50I_H6_H */ diff --git a/arch/arm/include/asm/arch-sunxi/cpu.h b/arch/arm/include/asm/arch-sunxi/cpu.h index 0534ccc8da..4c399b0a15 100644 --- a/arch/arm/include/asm/arch-sunxi/cpu.h +++ b/arch/arm/include/asm/arch-sunxi/cpu.h @@ -8,6 +8,8 @@ #if defined(CONFIG_MACH_SUN9I) #include <asm/arch/cpu_sun9i.h> +#elif defined(CONFIG_MACH_SUN50I_H6) +#include <asm/arch/cpu_sun50i_h6.h> #else #include <asm/arch/cpu_sun4i.h> #endif diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h new file mode 100644 index 0000000000..f568def8b4 --- /dev/null +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h @@ -0,0 +1,73 @@ +/* + * (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _SUNXI_CPU_SUN50I_H6_H +#define _SUNXI_CPU_SUN50I_H6_H + +#define SUNXI_SRAM_A1_BASE CONFIG_SUNXI_SRAM_ADDRESS +#define SUNXI_SRAM_C_BASE 0x00028000 +#define SUNXI_SRAM_A2_BASE 0x00100000 + +#define SUNXI_DE3_BASE 0x01000000 +#define SUNXI_SS_BASE 0x01904000 +#define SUNXI_EMCE_BASE 0x01905000 + +#define SUNXI_SRAMC_BASE 0x03000000 +#define SUNXI_CCM_BASE 0x03001000 +#define SUNXI_DMA_BASE 0x03002000 +/* SID address space starts at 0x03006000, but e-fuse is at offset 0x200 */ +#define SUNXI_SIDC_BASE 0x03006000 +#define SNUXI_SID_BASE 0x03006200 +#define SUNXI_TIMER_BASE 0x03009000 +#define SUNXI_PIO_BASE 0x0300B000 +#define SUNXI_PSI_BASE 0x0300C000 + +#define SUNXI_GIC400_BASE 0x03020000 +#define SUNXI_IOMMU_BASE 0x030F0000 + +#define SUNXI_DRAM_COM_BASE 0x04002000 +#define SUNXI_DRAM_CTL0_BASE 0x04003000 +#define SUNXI_DRAM_PHY0_BASE 0x04005000 +#define SUNXI_NFC_BASE 0x04011000 +#define SUNXI_MMC0_BASE 0x04020000 +#define SUNXI_MMC1_BASE 0x04021000 +#define SUNXI_MMC2_BASE 0x04022000 + +#define SUNXI_UART0_BASE 0x05000000 +#define SUNXI_UART1_BASE 0x05000400 +#define SUNXI_UART2_BASE 0x05000800 +#define SUNXI_UART3_BASE 0x05000C00 +#define SUNXI_TWI0_BASE 0x05002000 +#define SUNXI_TWI1_BASE 0x05002400 +#define SUNXI_TWI2_BASE 0x05002800 +#define SUNXI_TWI3_BASE 0x05002C00 +#define SUNXI_SPI0_BASE 0x05010000 +#define SUNXI_SPI1_BASE 0x05011000 +#define SUNXI_GMAC_BASE 0x05020000 +#define SUNXI_USB0_BASE 0x05100000 +#define SUNXI_XHCI_BASE 0x05200000 +#define SUNXI_USB3_BASE 0x05311000 +#define SUNXI_PCIE_BASE 0x05400000 + +#define SUNXI_HDMI_BASE 0x06000000 +#define SUNXI_TCON_TOP_BASE 0x06510000 +#define SUNXI_TCON_LCD0_BASE 0x06511000 +#define SUNXI_TCON_TV0_BASE 0x06515000 + +#define SUNXI_RTC_BASE 0x07000000 +#define SUNXI_R_CPUCFG_BASE 0x07000400 +#define SUNXI_PRCM_BASE 0x07010000 +#define SUNXI_R_PIO_BASE 0x07022000 +#define SUNXI_R_UART_BASE 0x07080000 +#define SUNXI_R_TWI_BASE 0x07081400 + +#ifndef __ASSEMBLY__ +void sunxi_board_init(void); +void sunxi_reset(void); +int sunxi_get_sid(unsigned int *sid); +#endif + +#endif /* _SUNXI_CPU_SUN9I_H */ diff --git a/arch/arm/include/asm/arch-sunxi/dram.h b/arch/arm/include/asm/arch-sunxi/dram.h index a5c091eeaa..8002b7efdc 100644 --- a/arch/arm/include/asm/arch-sunxi/dram.h +++ b/arch/arm/include/asm/arch-sunxi/dram.h @@ -27,6 +27,8 @@ #include <asm/arch/dram_sunxi_dw.h> #elif defined(CONFIG_MACH_SUN9I) #include <asm/arch/dram_sun9i.h> +#elif defined(CONFIG_MACH_SUN50I_H6) +#include <asm/arch/dram_sun50i_h6.h> #else #include <asm/arch/dram_sun4i.h> #endif diff --git a/arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h b/arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h new file mode 100644 index 0000000000..eeb4da5c3f --- /dev/null +++ b/arch/arm/include/asm/arch-sunxi/dram_sun50i_h6.h @@ -0,0 +1,297 @@ +/* + * H6 dram controller register and constant defines + * + * (C) Copyright 2017 Icenowy Zheng <icenowy@aosc.io> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _SUNXI_DRAM_SUN50I_H6_H +#define _SUNXI_DRAM_SUN50I_H6_H + +enum sunxi_dram_type { + SUNXI_DRAM_TYPE_DDR3 = 3, + SUNXI_DRAM_TYPE_DDR4, + SUNXI_DRAM_TYPE_LPDDR2 = 6, + SUNXI_DRAM_TYPE_LPDDR3, +}; + +/* + * The following information is mainly retrieved by disassembly and some FPGA + * test code of sun50iw3 platform. + */ +struct sunxi_mctl_com_reg { + u32 cr; /* 0x000 control register */ + u8 reserved_0x004[4]; /* 0x004 */ + u32 unk_0x008; /* 0x008 */ + u32 tmr; /* 0x00c timer register */ + u8 reserved_0x010[4]; /* 0x010 */ + u32 unk_0x014; /* 0x014 */ + u8 reserved_0x018[8]; /* 0x018 */ + u32 maer0; /* 0x020 master enable register 0 */ + u32 maer1; /* 0x024 master enable register 1 */ + u32 maer2; /* 0x028 master enable register 2 */ + u8 reserved_0x02c[468]; /* 0x02c */ + u32 bwcr; /* 0x200 bandwidth control register */ + u8 reserved_0x204[12]; /* 0x204 */ + /* + * The last master configured by BSP libdram is at 0x49x, so the + * size of this struct array is set to 41 (0x29) now. + */ + struct { + u32 cfg0; /* 0x0 */ + u32 cfg1; /* 0x4 */ + u8 reserved_0x8[8]; /* 0x8 */ + } master[41]; /* 0x210 + index * 0x10 */ +}; +check_member(sunxi_mctl_com_reg, master[40].reserved_0x8, 0x498); + +/* + * The following register information are retrieved from some similar DRAM + * controllers, including the DRAM controllers in Allwinner A23/A80 SoCs, + * Rockchip RK3328 SoC, NXP i.MX7 SoCs and Xilinx Zynq UltraScale+ SoCs. + * + * The DRAM controller in Allwinner A23/A80 SoCs and NXP i.MX7 SoCs seems + * to be older than the one in Allwinner H6, as the DRAMTMG9 register + * is missing in these SoCs. (From the product specifications of these + * SoCs they're not capable of DDR4) + * + * Information sources: + * - dram_sun9i.h and dram_sun8i_a23.h in the same directory. + * - sdram_rk3328.h from the RK3328 TPL DRAM patchset + * - i.MX 7Solo Applications Processor Reference Manual (IMX7SRM) + * - Zynq UltraScale+ MPSoC Register Reference (UG1087) + */ +struct sunxi_mctl_ctl_reg { + u32 mstr; /* 0x000 */ + u32 statr; /* 0x004 unused */ + u32 mstr1; /* 0x008 unused */ + u32 unk_0x00c; /* 0x00c */ + u32 mrctrl0; /* 0x010 unused */ + u32 mrctrl1; /* 0x014 unused */ + u32 mrstatr; /* 0x018 unused */ + u32 mrctrl2; /* 0x01c unused */ + u32 derateen; /* 0x020 unused */ + u32 derateint; /* 0x024 unused */ + u8 reserved_0x028[8]; /* 0x028 */ + u32 pwrctl; /* 0x030 unused */ + u32 pwrtmg; /* 0x034 unused */ + u32 hwlpctl; /* 0x038 unused */ + u8 reserved_0x03c[20]; /* 0x03c */ + u32 rfshctl0; /* 0x050 unused */ + u32 rfshctl1; /* 0x054 unused */ + u8 reserved_0x058[8]; /* 0x05c */ + u32 rfshctl3; /* 0x060 */ + u32 rfshtmg; /* 0x064 */ + u8 reserved_0x068[104]; /* 0x068 reserved for ECC&CRC (from ZynqMP) */ + u32 init[8]; /* 0x0d0 */ + u32 dimmctl; /* 0x0f0 unused */ + u32 rankctl; /* 0x0f4 */ + u8 reserved_0x0f8[8]; /* 0x0f8 */ + u32 dramtmg[17]; /* 0x100 */ + u8 reserved_0x144[60]; /* 0x144 */ + u32 zqctl[3]; /* 0x180 */ + u32 zqstat; /* 0x18c unused */ + u32 dfitmg0; /* 0x190 */ + u32 dfitmg1; /* 0x194 */ + u32 dfilpcfg[2]; /* 0x198 unused */ + u32 dfiupd[3]; /* 0x1a0 */ + u32 reserved_0x1ac; /* 0x1ac */ + u32 dfimisc; /* 0x1b0 */ + u32 dfitmg2; /* 0x1b4 unused, may not exist */ + u8 reserved_0x1b8[8]; /* 0x1b8 */ + u32 dbictl; /* 0x1c0 */ + u8 reserved_0x1c4[60]; /* 0x1c4 */ + u32 addrmap[12]; /* 0x200 */ + u8 reserved_0x230[16]; /* 0x230 */ + u32 odtcfg; /* 0x240 */ + u32 odtmap; /* 0x244 */ + u8 reserved_0x248[8]; /* 0x248 */ + u32 sched[2]; /* 0x250 */ + u8 reserved_0x258[180]; /* 0x258 */ + u32 dbgcmd; /* 0x30c unused */ + u32 dbgstat; /* 0x310 unused */ + u8 reserved_0x314[12]; /* 0x314 */ + u32 swctl; /* 0x320 */ + u32 swstat; /* 0x324 */ +}; +check_member(sunxi_mctl_ctl_reg, swstat, 0x324); + +#define MSTR_DEVICETYPE_DDR3 BIT(0) +#define MSTR_DEVICETYPE_LPDDR2 BIT(2) +#define MSTR_DEVICETYPE_LPDDR3 BIT(3) +#define MSTR_DEVICETYPE_DDR4 BIT(4) +#define MSTR_DEVICETYPE_MASK GENMASK(5, 0) +#define MSTR_2TMODE BIT(10) +#define MSTR_BUSWIDTH_FULL (0 << 12) +#define MSTR_BUSWIDTH_HALF (1 << 12) +#define MSTR_ACTIVE_RANKS(x) (((x == 2) ? 3 : 1) << 24) +#define MSTR_BURST_LENGTH(x) (((x) >> 1) << 16) + +/* + * The following register information is based on Zynq UltraScale+ + * MPSoC Register Reference, as it's the currently only known + * DDR PHY similar to the one used in H6; however although the + * map is similar, the bit fields definitions are different. + * + * Other DesignWare DDR PHY's have similar register names, but the + * offset and definitions are both different. + */ +struct sunxi_mctl_phy_reg { + u32 ver; /* 0x000 guess based on similar PHYs */ + u32 pir; /* 0x004 */ + u8 reserved_0x008[8]; /* 0x008 */ + /* + * The ZynqMP manual didn't document PGCR1, however this register + * exists on H6 and referenced by libdram. + */ + u32 pgcr[8]; /* 0x010 */ + /* + * By comparing the hardware and the ZynqMP manual, the PGSR seems + * to start at 0x34 on H6. + */ + u8 reserved_0x030[4]; /* 0x030 */ + u32 pgsr[3]; /* 0x034 */ + u32 ptr[7]; /* 0x040 */ + /* + * According to ZynqMP reference there's PLLCR0~6 in this area, + * but they're tagged "Type B PLL Only" and H6 seems to have + * no them. + * 0x080 is not present in ZynqMP reference but it seems to be + * present on H6. + */ + u8 reserved_0x05c[36]; /* 0x05c */ + u32 unk_0x080; /* 0x080 */ + u8 reserved_0x084[4]; /* 0x084 */ + u32 dxccr; /* 0x088 */ + u8 reserved_0x08c[4]; /* 0x08c */ + u32 dsgcr; /* 0x090 */ + u8 reserved_0x094[4]; /* 0x094 */ + u32 odtcr; /* 0x098 */ + u8 reserved_0x09c[4]; /* 0x09c */ + u32 aacr; /* 0x0a0 */ + u8 reserved_0x0a4[32]; /* 0x0a4 */ + u32 gpr1; /* 0x0c4 */ + u8 reserved_0x0c8[56]; /* 0x0c8 */ + u32 dcr; /* 0x100 */ + u8 reserved_0x104[12]; /* 0x104 */ + u32 dtpr[7]; /* 0x110 */ + u8 reserved_0x12c[20]; /* 0x12c */ + u32 rdimmgcr[3]; /* 0x140 */ + u8 reserved_0x14c[4]; /* 0x14c */ + u32 rdimmcr[5]; /* 0x150 */ + u8 reserved_0x164[4]; /* 0x164 */ + u32 schcr[2]; /* 0x168 */ + u8 reserved_0x170[16]; /* 0x170 */ + /* + * The ZynqMP manual documents MR0~7, 11~14 and 22. + */ + u32 mr[23]; /* 0x180 */ + u8 reserved_0x1dc[36]; /* 0x1dc */ + u32 dtcr[2]; /* 0x200 */ + u32 dtar[3]; /* 0x208 */ + u8 reserved_0x214[4]; /* 0x214 */ + u32 dtdr[2]; /* 0x218 */ + u8 reserved_0x220[16]; /* 0x220 */ + u32 dtedr0; /* 0x230 */ + u32 dtedr1; /* 0x234 */ + u32 dtedr2; /* 0x238 */ + u32 vtdr; /* 0x23c */ + u32 catr[2]; /* 0x240 */ + u8 reserved_0x248[8]; + u32 dqsdr[3]; /* 0x250 */ + u32 dtedr3; /* 0x25c */ + u8 reserved_0x260[160]; /* 0x260 */ + u32 dcuar; /* 0x300 */ + u32 dcudr; /* 0x304 */ + u32 dcurr; /* 0x308 */ + u32 dculr; /* 0x30c */ + u32 dcugcr; /* 0x310 */ + u32 dcutpr; /* 0x314 */ + u32 dcusr[2]; /* 0x318 */ + u8 reserved_0x320[444]; /* 0x320 */ + u32 rankidr; /* 0x4dc */ + u32 riocr[6]; /* 0x4e0 */ + u8 reserved_0x4f8[8]; /* 0x4f8 */ + u32 aciocr[6]; /* 0x500 */ + u8 reserved_0x518[8]; /* 0x518 */ + u32 iovcr[2]; /* 0x520 */ + u32 vtcr[2]; /* 0x528 */ + u8 reserved_0x530[16]; /* 0x530 */ + u32 acbdlr[17]; /* 0x540 */ + u32 aclcdlr; /* 0x584 */ + u8 reserved_0x588[24]; /* 0x588 */ + u32 acmdlr[2]; /* 0x5a0 */ + u8 reserved_0x5a8[216]; /* 0x5a8 */ + struct { + u32 zqcr; /* 0x00 only the first one valid */ + u32 zqpr[2]; /* 0x04 */ + u32 zqdr[2]; /* 0x0c */ + u32 zqor[2]; /* 0x14 */ + u32 zqsr; /* 0x1c */ + } zq[2]; /* 0x680, 0x6a0 */ + u8 reserved_0x6c0[64]; /* 0x6c0 */ + struct { + u32 gcr[7]; /* 0x00 */ + u8 reserved_0x1c[36]; /* 0x1c */ + u32 bdlr0; /* 0x40 */ + u32 bdlr1; /* 0x44 */ + u32 bdlr2; /* 0x48 */ + u8 reserved_0x4c[4]; /* 0x4c */ + u32 bdlr3; /* 0x50 */ + u32 bdlr4; /* 0x54 */ + u32 bdlr5; /* 0x58 */ + u8 reserved_0x5c[4]; /* 0x5c */ + u32 bdlr6; /* 0x60 */ + u8 reserved_0x64[28]; /* 0x64 */ + u32 lcdlr[6]; /* 0x80 */ + u8 reserved_0x98[8]; /* 0x98 */ + u32 mdlr[2]; /* 0xa0 */ + u8 reserved_0xa8[24]; /* 0xa8 */ + u32 gtr0; /* 0xc0 */ + u8 reserved_0xc4[12]; /* 0xc4 */ + /* + * DXnRSR0 is not documented in ZynqMP manual but + * it's used in libdram. + */ + u32 rsr[4]; /* 0xd0 */ + u32 gsr[4]; /* 0xe0 */ + u8 reserved_0xf0[16]; /* 0xf0 */ + } dx[4]; /* 0x700, 0x800, 0x900, 0xa00 */ +}; +check_member(sunxi_mctl_phy_reg, dx[3].reserved_0xf0, 0xaf0); + +#define PIR_INIT BIT(0) +#define PIR_ZCAL BIT(1) +#define PIR_CA BIT(2) +#define PIR_PLLINIT BIT(4) +#define PIR_DCAL BIT(5) +#define PIR_PHYRST BIT(6) +#define PIR_DRAMRST BIT(7) +#define PIR_DRAMINIT BIT(8) +#define PIR_WL BIT(9) +#define PIR_QSGATE BIT(10) +#define PIR_WLADJ BIT(11) +#define PIR_RDDSKW BIT(12) +#define PIR_WRDSKW BIT(13) +#define PIR_RDEYE BIT(14) +#define PIR_WREYE BIT(15) +#define PIR_VREF BIT(17) +#define PIR_CTLDINIT BIT(18) +#define PIR_DQS2DQ BIT(20) +#define PIR_DCALPSE BIT(29) +#define PIR_ZCALBYP BIT(30) + +#define DCR_LPDDR3 (1 << 0) +#define DCR_DDR3 (3 << 0) +#define DCR_DDR4 (4 << 0) +#define DCR_DDR8BANK BIT(3) + +static inline int ns_to_t(int nanoseconds) +{ + const unsigned int ctrl_freq = CONFIG_DRAM_CLK / 2; + + return DIV_ROUND_UP(ctrl_freq * nanoseconds, 1000); +} + +#endif /* _SUNXI_DRAM_SUN50I_H6_H */ diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h index e4fe54d8b8..6a5eafc3d3 100644 --- a/arch/arm/include/asm/arch-sunxi/gpio.h +++ b/arch/arm/include/asm/arch-sunxi/gpio.h @@ -198,6 +198,7 @@ enum sunxi_gpio_number { #define SUN6I_GPH_TWI2 2 #define SUN6I_GPH_UART0 2 #define SUN9I_GPH_UART0 2 +#define SUN50I_H6_GPH_UART0 2 #define SUNXI_GPI_SDC3 2 #define SUN7I_GPI_TWI3 3 diff --git a/arch/arm/include/asm/arch-sunxi/mmc.h b/arch/arm/include/asm/arch-sunxi/mmc.h index 1574b8e8fe..d98c53faaa 100644 --- a/arch/arm/include/asm/arch-sunxi/mmc.h +++ b/arch/arm/include/asm/arch-sunxi/mmc.h @@ -45,7 +45,7 @@ struct sunxi_mmc { u32 chda; /* 0x90 */ u32 cbda; /* 0x94 */ u32 res2[26]; -#ifdef CONFIG_SUNXI_GEN_SUN6I +#if defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_MACH_SUN50I_H6) u32 res3[64]; #endif u32 fifo; /* 0x100 / 0x200 FIFO access address */ diff --git a/arch/arm/include/asm/arch-sunxi/spl.h b/arch/arm/include/asm/arch-sunxi/spl.h index 4277d836e5..55f2deb18d 100644 --- a/arch/arm/include/asm/arch-sunxi/spl.h +++ b/arch/arm/include/asm/arch-sunxi/spl.h @@ -11,11 +11,7 @@ #define SPL_SIGNATURE "SPL" /* marks "sunxi" SPL header */ #define SPL_HEADER_VERSION 2 -#ifdef CONFIG_SUNXI_HIGH_SRAM -#define SPL_ADDR 0x10000 -#else -#define SPL_ADDR 0x0 -#endif +#define SPL_ADDR CONFIG_SUNXI_SRAM_ADDRESS /* The low 8-bits of the 'boot_media' field in the SPL header */ #define SUNXI_BOOTED_FROM_MMC0 0 diff --git a/arch/arm/include/asm/arch-sunxi/timer.h b/arch/arm/include/asm/arch-sunxi/timer.h index cb02dd8bf8..6f138d04b8 100644 --- a/arch/arm/include/asm/arch-sunxi/timer.h +++ b/arch/arm/include/asm/arch-sunxi/timer.h @@ -76,7 +76,7 @@ struct sunxi_timer_reg { struct sunxi_tgp tgp[4]; u8 res5[8]; u32 cpu_cfg; -#elif defined(CONFIG_SUNXI_GEN_SUN6I) +#elif defined(CONFIG_SUNXI_GEN_SUN6I) || defined(CONFIG_MACH_SUN50I_H6) u8 res3[16]; struct sunxi_wdog wdog[5]; /* We have 5 watchdogs */ #endif |