hc
2023-11-06 9df731a176aab8e03b984b681b1bea01ccff6644
u-boot/arch/arm/mach-rockchip/rk3588/rk3588.c
....@@ -19,20 +19,31 @@
1919 #define FIREWALL_DDR_BASE 0xfe030000
2020 #define FW_DDR_MST5_REG 0x54
2121 #define FW_DDR_MST13_REG 0x74
22
+#define FW_DDR_MST19_REG 0x8c
2223 #define FW_DDR_MST21_REG 0x94
2324 #define FW_DDR_MST26_REG 0xa8
2425 #define FW_DDR_MST27_REG 0xac
2526 #define FIREWALL_SYSMEM_BASE 0xfe038000
2627 #define FW_SYSM_MST5_REG 0x54
2728 #define FW_SYSM_MST13_REG 0x74
29
+#define FW_SYSM_MST19_REG 0x8c
2830 #define FW_SYSM_MST21_REG 0x94
2931 #define FW_SYSM_MST26_REG 0xa8
3032 #define FW_SYSM_MST27_REG 0xac
33
+#define PMU1_SGRF_BASE 0xfd582000
34
+#define PMU1_SGRF_SOC_CON0 0x0
35
+#define PMU1_SGRF_SOC_CON6 0x18
36
+#define PMU1_SGRF_SOC_CON7 0x1c
37
+#define PMU1_SGRF_SOC_CON8 0x20
38
+#define PMU1_SGRF_SOC_CON9 0x24
39
+#define PMU1_SGRF_SOC_CON10 0x28
40
+#define PMU1_SGRF_SOC_CON13 0x34
3141 #define SYS_GRF_BASE 0xfd58c000
3242 #define SYS_GRF_SOC_CON6 0x0318
3343 #define USBGRF_BASE 0xfd5ac000
3444 #define USB_GRF_USB3OTG0_CON1 0x001c
3545 #define BUS_SGRF_BASE 0xfd586000
46
+#define BUS_SGRF_SOC_CON2 0x08
3647 #define BUS_SGRF_FIREWALL_CON18 0x288
3748 #define PMU_BASE 0xfd8d0000
3849 #define PMU_PWR_GATE_SFTCON1 0x8150
....@@ -66,14 +77,21 @@
6677 #define EMMC_IOC_GPIO2D_DS_H 0x5c
6778
6879 #define CRU_BASE 0xfd7c0000
80
+#define CRU_GPLL_CON1 0x01c4
6981 #define CRU_SOFTRST_CON77 0x0b34
82
+#define CRU_GLB_RST_CON 0x0c10
7083
7184 #define PMU1CRU_BASE 0xfd7f0000
85
+#define PMU1CRU_SOFTRST_CON00 0x0a00
7286 #define PMU1CRU_SOFTRST_CON03 0x0a0c
7387 #define PMU1CRU_SOFTRST_CON04 0x0a10
7488
7589 #define HDMIRX_NODE_FDT_PATH "/hdmirx-controller@fdee0000"
7690 #define RK3588_PHY_CONFIG 0xfdee00c0
91
+
92
+#define VOP_M0_PRIORITY_REG 0xfdf82008
93
+#define VOP_M1_PRIORITY_REG 0xfdf82208
94
+#define QOS_PRIORITY_LEVEL(h, l) ((((h) & 7) << 8) | ((l) & 7))
7795
7896 #ifdef CONFIG_ARM64
7997 #include <asm/armv8/mmu.h>
....@@ -865,8 +883,15 @@
865883 secure_reg &= 0xffff0000;
866884 writel(secure_reg, FIREWALL_SYSMEM_BASE + FW_SYSM_MST27_REG);
867885
868
- /* Select clk_tx source as default for i2s2/i2s3 */
869
- writel(0x03400340, SYS_GRF_BASE + SYS_GRF_SOC_CON6);
886
+ /*
887
+ * Select clk_tx source as default for i2s2/i2s3
888
+ * Set I2Sx_MCLK as input default
889
+ *
890
+ * It's safe to set mclk as input default to avoid high freq glitch
891
+ * which may make devices work unexpected. And then enabled by
892
+ * kernel stage or any state where user use it.
893
+ */
894
+ writel(0x03c703c7, SYS_GRF_BASE + SYS_GRF_SOC_CON6);
870895
871896 if (readl(BUS_IOC_BASE + BUS_IOC_GPIO2D_IOMUX_SEL_L) == 0x2222) {
872897 /* Set the fspi m0 io ds level to 55ohm */
....@@ -922,7 +947,14 @@
922947 writel(0xffff1111, BUS_IOC_BASE + BUS_IOC_GPIO2D_IOMUX_SEL_L);
923948 writel(0xffff1111, BUS_IOC_BASE + BUS_IOC_GPIO2D_IOMUX_SEL_H);
924949 #endif
925
-
950
+ /*
951
+ * set VOP M0 and VOP M1 to priority 0x303,then
952
+ * Peri > VOP/MCU > ISP/VICAP > other
953
+ * Note: VOP priority can only be modified during the u-boot stage,
954
+ * as VOP default power down, and power up after trust.
955
+ */
956
+ writel(QOS_PRIORITY_LEVEL(3, 3), VOP_M0_PRIORITY_REG);
957
+ writel(QOS_PRIORITY_LEVEL(3, 3), VOP_M1_PRIORITY_REG);
926958 #endif
927959
928960 /* Select usb otg0 phy status to 0 that make rockusb can work at high-speed */
....@@ -1245,31 +1277,36 @@
12451277 #ifdef CONFIG_SPL_BUILD
12461278 int spl_fit_standalone_release(char *id, uintptr_t entry_point)
12471279 {
1248
- /* gpll enable */
1249
- writel(0x00f00042, 0xfd7c01c4);
1280
+ u32 val;
1281
+
1282
+ /* pmu m0 configuration: */
1283
+ /* set gpll */
1284
+ writel(0x00f00042, CRU_BASE + CRU_GPLL_CON1);
1285
+ /* set pmu mcu to access ddr memory */
1286
+ val = readl(FIREWALL_DDR_BASE + FW_DDR_MST19_REG);
1287
+ writel(val & 0x0000ffff, FIREWALL_DDR_BASE + FW_DDR_MST19_REG);
1288
+ /* set pmu mcu to access system memory */
1289
+ val = readl(FIREWALL_SYSMEM_BASE + FW_SYSM_MST19_REG);
1290
+ writel(val & 0x000000ff, FIREWALL_SYSMEM_BASE + FW_SYSM_MST19_REG);
1291
+ /* set pmu mcu to secure */
1292
+ writel(0x00080000, PMU1_SGRF_BASE + PMU1_SGRF_SOC_CON0);
12501293 /* set start addr, pmu_mcu_code_addr_start */
1251
- writel(0xFFFF0000 | (entry_point >> 16), 0xFD582024);
1252
- /* pmu_mcu_sram_addr_start */
1253
- writel(0xFFFF2000, 0xFD582028);
1254
- /* pmu_mcu_tcm_addr_start */
1255
- writel(0xFFFF2000, 0xFD582034);
1256
- /* set mcu secure */
1257
- writel(0x00080000, 0xFD582000);
1294
+ writel(0xFFFF0000 | (entry_point >> 16), PMU1_SGRF_BASE + PMU1_SGRF_SOC_CON9);
1295
+ /* set pmu_mcu_sram_addr_start */
1296
+ writel(0xFFFF2000, PMU1_SGRF_BASE + PMU1_SGRF_SOC_CON10);
1297
+ /* set pmu_mcu_tcm_addr_start */
1298
+ writel(0xFFFF2000, PMU1_SGRF_BASE + PMU1_SGRF_SOC_CON13);
12581299 /* set cache cache_peripheral_addr */
1259
- writel(0xffff0000, 0xFD582018);
1260
- writel(0xffffee00, 0xFD58201c);
1261
- writel(0x00ff00ff, 0xFD582020); /* 0xf0000000 ~ 0xfee00000 */
1262
- /* mcupmu access DDR secure control, each bit for a region. */
1263
- writel(0x0000ffff, 0xFE03008C);
1264
- /* mcupmu access DDR secure control, each bit for a region. */
1265
- writel(0x000000ff, 0xFE03808C);
1266
- /* PMU WDT reset system enable */
1267
- writel(0x02000200, 0xFD586008);
1268
- /* WDT trigger global reset. */
1269
- writel(0x08400840, 0xFD7C0C10);
1270
- /* Spl helps to load the mcu image, but not need to release
1271
- * mcu for rk3588.
1272
- */
1300
+ /* 0xf0000000 ~ 0xfee00000 */
1301
+ writel(0xffff0000, PMU1_SGRF_BASE + PMU1_SGRF_SOC_CON6);
1302
+ writel(0xffffee00, PMU1_SGRF_BASE + PMU1_SGRF_SOC_CON7);
1303
+ writel(0x00ff00ff, PMU1_SGRF_BASE + PMU1_SGRF_SOC_CON8);
1304
+ /* enable PMU WDT reset system */
1305
+ writel(0x02000200, BUS_SGRF_BASE + BUS_SGRF_SOC_CON2);
1306
+ /* select WDT trigger global reset. */
1307
+ writel(0x08400840, CRU_BASE + CRU_GLB_RST_CON);
1308
+ /* release pmu mcu */
1309
+ /* writel(0x20000000, PMU1CRU_BASE + PMU1CRU_SOFTRST_CON00); */
12731310
12741311 return 0;
12751312 }