diff --git a/plat/rockchip/common/drivers/pmu/pmu_com.h b/plat/rockchip/common/drivers/pmu/pmu_com.h index 022bb024a..84f942151 100644 --- a/plat/rockchip/common/drivers/pmu/pmu_com.h +++ b/plat/rockchip/common/drivers/pmu/pmu_com.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2024, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -32,8 +32,6 @@ enum pmu_pd_state { }; #pragma weak plat_ic_get_pending_interrupt_id -#pragma weak pmu_power_domain_ctr -#pragma weak check_cpu_wfie static inline uint32_t pmu_power_domain_st(uint32_t pd) { diff --git a/plat/rockchip/px30/drivers/pmu/pmu.c b/plat/rockchip/px30/drivers/pmu/pmu.c index 8770b2e11..0d8e8b689 100644 --- a/plat/rockchip/px30/drivers/pmu/pmu.c +++ b/plat/rockchip/px30/drivers/pmu/pmu.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2019-2024, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -867,18 +867,6 @@ static inline void pm_pll_wait_lock(uint32_t pll_base, uint32_t pll_id) ERROR("Can't wait pll:%d lock\n", pll_id); } -static inline void pll_pwr_ctr(uint32_t pll_base, uint32_t pll_id, uint32_t pd) -{ - mmio_write_32(pll_base + PLL_CON(1), - BITS_WITH_WMASK(1, 1U, 15)); - if (pd) - mmio_write_32(pll_base + PLL_CON(1), - BITS_WITH_WMASK(1, 1, 14)); - else - mmio_write_32(pll_base + PLL_CON(1), - BITS_WITH_WMASK(0, 1, 14)); -} - static inline void pll_set_mode(uint32_t pll_id, uint32_t mode) { uint32_t val = BITS_WITH_WMASK(mode, 0x3, PLL_MODE_SHIFT(pll_id)); diff --git a/plat/rockchip/rk3288/drivers/pmu/pmu.c b/plat/rockchip/rk3288/drivers/pmu/pmu.c index 085976c16..9e17cffe0 100644 --- a/plat/rockchip/rk3288/drivers/pmu/pmu.c +++ b/plat/rockchip/rk3288/drivers/pmu/pmu.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2024, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -36,90 +36,6 @@ enum { ROCKCHIP_ARM_OFF_LOGIC_DEEP = 1, }; -static inline int rk3288_pmu_bus_idle(uint32_t req, uint32_t idle) -{ - uint32_t mask = BIT(req); - uint32_t idle_mask = 0; - uint32_t idle_target = 0; - uint32_t val; - uint32_t wait_cnt = 0; - - switch (req) { - case bus_ide_req_gpu: - idle_mask = BIT(pmu_idle_ack_gpu) | BIT(pmu_idle_gpu); - idle_target = (idle << pmu_idle_ack_gpu) | - (idle << pmu_idle_gpu); - break; - case bus_ide_req_core: - idle_mask = BIT(pmu_idle_ack_core) | BIT(pmu_idle_core); - idle_target = (idle << pmu_idle_ack_core) | - (idle << pmu_idle_core); - break; - case bus_ide_req_cpup: - idle_mask = BIT(pmu_idle_ack_cpup) | BIT(pmu_idle_cpup); - idle_target = (idle << pmu_idle_ack_cpup) | - (idle << pmu_idle_cpup); - break; - case bus_ide_req_bus: - idle_mask = BIT(pmu_idle_ack_bus) | BIT(pmu_idle_bus); - idle_target = (idle << pmu_idle_ack_bus) | - (idle << pmu_idle_bus); - break; - case bus_ide_req_dma: - idle_mask = BIT(pmu_idle_ack_dma) | BIT(pmu_idle_dma); - idle_target = (idle << pmu_idle_ack_dma) | - (idle << pmu_idle_dma); - break; - case bus_ide_req_peri: - idle_mask = BIT(pmu_idle_ack_peri) | BIT(pmu_idle_peri); - idle_target = (idle << pmu_idle_ack_peri) | - (idle << pmu_idle_peri); - break; - case bus_ide_req_video: - idle_mask = BIT(pmu_idle_ack_video) | BIT(pmu_idle_video); - idle_target = (idle << pmu_idle_ack_video) | - (idle << pmu_idle_video); - break; - case bus_ide_req_hevc: - idle_mask = BIT(pmu_idle_ack_hevc) | BIT(pmu_idle_hevc); - idle_target = (idle << pmu_idle_ack_hevc) | - (idle << pmu_idle_hevc); - break; - case bus_ide_req_vio: - idle_mask = BIT(pmu_idle_ack_vio) | BIT(pmu_idle_vio); - idle_target = (pmu_idle_ack_vio) | - (idle << pmu_idle_vio); - break; - case bus_ide_req_alive: - idle_mask = BIT(pmu_idle_ack_alive) | BIT(pmu_idle_alive); - idle_target = (idle << pmu_idle_ack_alive) | - (idle << pmu_idle_alive); - break; - default: - ERROR("%s: Unsupported the idle request\n", __func__); - break; - } - - val = mmio_read_32(PMU_BASE + PMU_BUS_IDE_REQ); - if (idle) - val |= mask; - else - val &= ~mask; - - mmio_write_32(PMU_BASE + PMU_BUS_IDE_REQ, val); - - while ((mmio_read_32(PMU_BASE + - PMU_BUS_IDE_ST) & idle_mask) != idle_target) { - wait_cnt++; - if (!(wait_cnt % MAX_WAIT_CONUT)) - WARN("%s:st=%x(%x)\n", __func__, - mmio_read_32(PMU_BASE + PMU_BUS_IDE_ST), - idle_mask); - } - - return 0; -} - static bool rk3288_sleep_disable_osc(void) { static const uint32_t reg_offset[] = { GRF_UOC0_CON0, GRF_UOC1_CON0, diff --git a/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c b/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c index 3cdb7a296..49faba86f 100644 --- a/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c +++ b/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2024, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -778,7 +778,7 @@ static void lpddr3_get_parameter(struct timing_related_config *timing_config, else if (twr_tmp <= 8) twr_tmp = 8; else if (twr_tmp <= 12) - twr_tmp = twr_tmp; + ; /* do nothing */ else if (twr_tmp <= 14) twr_tmp = 14; else diff --git a/plat/rockchip/rk3399/drivers/m0/Makefile b/plat/rockchip/rk3399/drivers/m0/Makefile index 7913190bb..2bc87ae18 100644 --- a/plat/rockchip/rk3399/drivers/m0/Makefile +++ b/plat/rockchip/rk3399/drivers/m0/Makefile @@ -5,13 +5,11 @@ # include ../../../../../make_helpers/common.mk +include ../../../../../make_helpers/build_macros.mk include ../../../../../make_helpers/toolchain.mk -# Cross Compile -M0_CROSS_COMPILE ?= arm-none-eabi- - # Build architecture -ARCH := cortex-m0 +ARCH := rk3399-m0 # Build platform PLAT_M0 ?= rk3399m0 @@ -27,10 +25,13 @@ C_SOURCES := src/dram.c \ C_SOURCES_PMU := src/suspend.c # Flags definition -COMMON_FLAGS := -g -mcpu=$(ARCH) -mthumb -Wall -O3 -nostdlib -mfloat-abi=soft +COMMON_FLAGS := -g -mcpu=cortex-m0 -mthumb -Wall -O3 -nostdlib -mfloat-abi=soft CFLAGS := -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-common -ASFLAGS := -Wa,--gdwarf-2 -LDFLAGS := -Wl,--gc-sections -Wl,--build-id=none +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523 +CFLAGS += $(call cc_option, --param=min-pagesize=0) +ASFLAGS := -Wa,--gdwarf-2 -Wa,--fatal-warnings +LDFLAGS := -Wl,--gc-sections -Wl,--build-id=none -Wl,--fatal-warnings -z noexecstack +LDFLAGS += $(call ld_option,-Xlinker --no-warn-rwx-segments) # NOTE: The line continuation '\' is required in the next define otherwise we # end up with a line-feed characer at the end of the last c filename. @@ -62,7 +63,7 @@ $(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) $(OBJ) : $(2) $(s)echo " CC $$<" - $$(q)$(rk3399-m0-cc) $$(COMMON_FLAGS) $$(CFLAGS) $$(INCLUDES) -MMD -MT $$@ -c $$< -o $$@ + $$(q)$($(ARCH)-cc) $$(COMMON_FLAGS) $$(CFLAGS) $$(INCLUDES) -MMD -MT $$@ -c $$< -o $$@ endef define MAKE_S @@ -70,7 +71,7 @@ $(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) $(OBJ) : $(2) $(s)echo " AS $$<" - $$(q)$(rk3399-m0-cc) -x assembler-with-cpp $$(COMMON_FLAGS) $$(ASFLAGS) -c $$< -o $$@ + $$(q)$($(ARCH)-as) -x assembler-with-cpp $$(COMMON_FLAGS) $$(ASFLAGS) -c $$< -o $$@ endef define MAKE_OBJS @@ -91,20 +92,20 @@ all: $(BIN) $(BIN_PMU) .DEFAULT_GOAL := all $(LINKERFILE): $(LINKERFILE_SRC) - $(rk3399-m0-cc) $(COMMON_FLAGS) $(INCLUDES) -P -E -D__LINKER__ -MMD -MF $@.d -MT $@ -o $@ $< + $(q)$($(ARCH)-cc) $(COMMON_FLAGS) $(INCLUDES) -P -E -D__LINKER__ -MMD -MF $@.d -MT $@ -o $@ $< -include $(LINKERFILE).d $(ELF) : $(OBJS) $(OBJS_COMMON) $(LINKERFILE) $(s)echo " LD $@" - $(q)$(rk3399-m0-cc) -o $@ $(COMMON_FLAGS) $(LDFLAGS) -Wl,-Map=$(MAPFILE) -Wl,-T$(LINKERFILE) $(OBJS) $(OBJS_COMMON) + $(q)$($(ARCH)-ld) -o $@ $(COMMON_FLAGS) $(LDFLAGS) -Wl,-Map=$(MAPFILE) -Wl,-T$(LINKERFILE) $(OBJS) $(OBJS_COMMON) %.bin : %.elf $(s)echo " BIN $@" - $(q)$(rk3399-m0-oc) -O binary $< $@ + $(q)$($(ARCH)-oc) -O binary $< $@ $(ELF_PMU) : $(OBJS_COMMON) $(OBJS_PMU) $(LINKERFILE) $(s)echo " LD $@" - $(q)$(rk3399-m0-cc) -o $@ $(COMMON_FLAGS) $(LDFLAGS) -Wl,-Map=$(MAPFILE_PMU) -Wl,-T$(LINKERFILE) $(OBJS_PMU) $(OBJS_COMMON) + $(q)$($(ARCH)-ld) -o $@ $(COMMON_FLAGS) $(LDFLAGS) -Wl,-Map=$(MAPFILE_PMU) -Wl,-T$(LINKERFILE) $(OBJS_PMU) $(OBJS_COMMON) $(eval $(call MAKE_OBJS,$(BUILD),$(SOURCES_COMMON),$(1))) $(eval $(call MAKE_OBJS,$(BUILD),$(SOURCES),$(1))) diff --git a/plat/rockchip/rk3588/drivers/pmu/pmu.c b/plat/rockchip/rk3588/drivers/pmu/pmu.c index f693dbdf0..a4128b214 100644 --- a/plat/rockchip/rk3588/drivers/pmu/pmu.c +++ b/plat/rockchip/rk3588/drivers/pmu/pmu.c @@ -760,10 +760,10 @@ static inline void cpus_pd_req_enter_wfi(void) "mrs x0, S3_0_C15_C2_7\n" "orr x0, x0, #0x1\n" "msr S3_0_C15_C2_7, x0\n" - "wfi_loop:\n" + "1:\n" "isb\n" "wfi\n" - "b wfi_loop\n"); + "b 1b\n"); } static void nonboot_cpus_off(void)