Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
61dbb028
Commit
61dbb028
authored
Apr 06, 2016
by
danh-arm
Browse files
Merge pull request #581 from rockchip-linux/rockchip-atf-20160405
Support for Rockchip's family SoCs
parents
af711c1e
6fba6e04
Changes
31
Show whitespace changes
Inline
Side-by-side
plat/rockchip/rk3368/drivers/soc/soc.h
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SOC_H__
#define __SOC_H__
enum
plls_id
{
ABPLL_ID
=
0
,
ALPLL_ID
,
DPLL_ID
,
CPLL_ID
,
GPLL_ID
,
NPLL_ID
,
END_PLL_ID
,
};
/*****************************************************************************
* secure timer
*****************************************************************************/
#define TIMER_LOADE_COUNT0 0x00
#define TIMER_LOADE_COUNT1 0x04
#define TIMER_CURRENT_VALUE0 0x08
#define TIMER_CURRENT_VALUE1 0x0C
#define TIMER_CONTROL_REG 0x10
#define TIMER_INTSTATUS 0x18
#define TIMER_EN 0x1
#define STIMER1_BASE (STIME_BASE + 0x20)
#define CYCL_24M_CNT_US(us) (24 * us)
#define CYCL_24M_CNT_MS(ms) (ms * CYCL_24M_CNT_US(1000))
/*****************************************************************************
* sgrf reg, offset
*****************************************************************************/
#define SGRF_SOC_CON(n) (0x0 + (n) * 4)
#define SGRF_BUSDMAC_CON(n) (0x100 + (n) * 4)
#define SGRF_SOC_CON_NS 0xffff0000
/*****************************************************************************
* con6[2]pmusram is security.
* con6[6]stimer is security.
*****************************************************************************/
#define PMUSRAM_S_SHIFT 2
#define PMUSRAM_S 1
#define STIMER_S_SHIFT 6
#define STIMER_S 1
#define SGRF_SOC_CON7_BITS ((0xffff << 16) | \
(PMUSRAM_S << PMUSRAM_S_SHIFT) | \
(STIMER_S << STIMER_S_SHIFT))
#define SGRF_BUSDMAC_CON0_NS 0xfffcfff8
#define SGRF_BUSDMAC_CON1_NS 0xffff0fff
/*
* sgrf_soc_con1~2, mask and offset
*/
#define CPU_BOOT_ADDR_WMASK 0xffff0000
#define CPU_BOOT_ADDR_ALIGN 16
/*****************************************************************************
* cru reg, offset
*****************************************************************************/
#define CRU_SOFTRST_CON 0x300
#define CRU_SOFTRSTS_CON(n) (CRU_SOFTRST_CON + ((n) * 4))
#define CRU_SOFTRSTS_CON_CNT 15
#define SOFTRST_DMA1 0x40004
#define SOFTRST_DMA2 0x10001
#define RST_DMA1_MSK 0x4
#define RST_DMA2_MSK 0x0
#define CRU_CLKSEL_CON 0x100
#define CRU_CLKSELS_CON(i) (CRU_CLKSEL_CON + ((i) * 4))
#define CRU_CLKSEL_CON_CNT 56
#define CRU_CLKGATE_CON 0x200
#define CRU_CLKGATES_CON(i) (CRU_CLKGATE_CON + ((i) * 4))
#define CRU_CLKGATES_CON_CNT 25
#define CRU_GLB_SRST_FST 0x280
#define CRU_GLB_SRST_SND 0x284
#define CRU_GLB_RST_CON 0x388
#define CRU_CONS_GATEID(i) (16 * (i))
#define GATE_ID(reg, bit) ((reg * 16) + bit)
#define PMU_RST_BY_SECOND_SFT (BIT(1) << 2)
#define PMU_RST_NOT_BY_SFT (BIT(1) << 2)
/***************************************************************************
* pll
***************************************************************************/
#define PLL_PWR_DN_MSK (0x1 << 1)
#define PLL_PWR_DN REG_WMSK_BITS(1, 1, 0x1)
#define PLL_PWR_ON REG_WMSK_BITS(0, 1, 0x1)
#define PLL_RESET REG_WMSK_BITS(1, 5, 0x1)
#define PLL_RESET_RESUME REG_WMSK_BITS(0, 5, 0x1)
#define PLL_BYPASS_MSK (0x1 << 0)
#define PLL_BYPASS_W_MSK (PLL_BYPASS_MSK << 16)
#define PLL_BYPASS REG_WMSK_BITS(1, 0, 0x1)
#define PLL_NO_BYPASS REG_WMSK_BITS(0, 0, 0x1)
#define PLL_MODE_SHIFT 8
#define PLL_MODE_MSK 0x3
#define PLLS_MODE_WMASK (PLL_MODE_MSK << (16 + PLL_MODE_SHIFT))
#define PLL_SLOW 0x0
#define PLL_NORM 0x1
#define PLL_DEEP 0x2
#define PLL_SLOW_BITS REG_WMSK_BITS(PLL_SLOW, 8, 0x3)
#define PLL_NORM_BITS REG_WMSK_BITS(PLL_NORM, 8, 0x3)
#define PLL_DEEP_BITS REG_WMSK_BITS(PLL_DEEP, 8, 0x3)
#define PLL_CONS(id, i) ((id) * 0x10 + ((i) * 4))
#define REG_W_MSK(bits_shift, msk) \
((msk) << ((bits_shift) + 16))
#define REG_VAL_CLRBITS(val, bits_shift, msk) \
(val & (~(msk << bits_shift)))
#define REG_SET_BITS(bits, bits_shift, msk) \
(((bits) & (msk)) << (bits_shift))
#define REG_WMSK_BITS(bits, bits_shift, msk) \
(REG_W_MSK(bits_shift, msk) | \
REG_SET_BITS(bits, bits_shift, msk))
#define regs_updata_bit_set(addr, shift) \
regs_updata_bits((addr), 0x1, 0x1, (shift))
#define regs_updata_bit_clr(addr, shift) \
regs_updata_bits((addr), 0x0, 0x1, (shift))
void
__dead2
soc_sys_global_soft_reset
(
void
);
void
regs_updata_bits
(
uintptr_t
addr
,
uint32_t
val
,
uint32_t
mask
,
uint32_t
shift
);
void
soc_sleep_config
(
void
);
void
pm_plls_resume
(
void
);
#endif
/* __SOC_H__ */
plat/rockchip/rk3368/include/platform_def.h
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PLATFORM_DEF_H__
#define __PLATFORM_DEF_H__
#include <arch.h>
#include <common_def.h>
#include <rk3368_def.h>
#define DEBUG_XLAT_TABLE 0
/*******************************************************************************
* Platform binary types for linking
******************************************************************************/
#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
#define PLATFORM_LINKER_ARCH aarch64
/*******************************************************************************
* Generic platform constants
******************************************************************************/
/* Size of cacheable stacks */
#if DEBUG_XLAT_TABLE
#define PLATFORM_STACK_SIZE 0x800
#elif IMAGE_BL1
#define PLATFORM_STACK_SIZE 0x440
#elif IMAGE_BL2
#define PLATFORM_STACK_SIZE 0x400
#elif IMAGE_BL31
#define PLATFORM_STACK_SIZE 0x800
#elif IMAGE_BL32
#define PLATFORM_STACK_SIZE 0x440
#endif
#define FIRMWARE_WELCOME_STR "Booting Trusted Firmware\n"
#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
#define PLATFORM_SYSTEM_COUNT 1
#define PLATFORM_CLUSTER_COUNT 2
#define PLATFORM_CLUSTER0_CORE_COUNT 4
#define PLATFORM_CLUSTER1_CORE_COUNT 4
#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
PLATFORM_CLUSTER0_CORE_COUNT)
#define PLATFORM_MAX_CPUS_PER_CLUSTER 4
#define PLATFORM_NUM_AFFS (PLATFORM_SYSTEM_COUNT + \
PLATFORM_CLUSTER_COUNT + \
PLATFORM_CORE_COUNT)
#define PLAT_MAX_PWR_LVL MPIDR_AFFLVL2
/*
* This macro defines the deepest retention state possible. A higher state
* id will represent an invalid or a power down state.
*/
#define PLAT_MAX_RET_STATE 1
/*
* This macro defines the deepest power down states possible. Any state ID
* higher than this is invalid.
*/
#define PLAT_MAX_OFF_STATE 2
/*******************************************************************************
* Platform memory map related constants
******************************************************************************/
/* TF txet, ro, rw, Size: 512KB */
#define TZRAM_BASE (0x0)
#define TZRAM_SIZE (0x80000)
/*******************************************************************************
* BL31 specific defines.
******************************************************************************/
/*
* Put BL3-1 at the top of the Trusted RAM
*/
#define BL31_BASE (TZRAM_BASE + 0x8000)
#define BL31_LIMIT (TZRAM_BASE + TZRAM_SIZE)
/*******************************************************************************
* Platform specific page table and MMU setup constants
******************************************************************************/
#define ADDR_SPACE_SIZE (1ull << 32)
#define MAX_XLAT_TABLES 8
#define MAX_MMAP_REGIONS 16
/*******************************************************************************
* Declarations and constants to access the mailboxes safely. Each mailbox is
* aligned on the biggest cache line size in the platform. This is known only
* to the platform as it might have a combination of integrated and external
* caches. Such alignment ensures that two maiboxes do not sit on the same cache
* line at any cache level. They could belong to different cpus/clusters &
* get written while being protected by different locks causing corruption of
* a valid mailbox address.
******************************************************************************/
#define CACHE_WRITEBACK_SHIFT 6
#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
/*
* Define GICD and GICC and GICR base
*/
#define PLAT_RK_GICD_BASE RK3368_GICD_BASE
#define PLAT_RK_GICC_BASE RK3368_GICC_BASE
/*
* Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
* terminology. On a GICv2 system or mode, the lists will be merged and treated
* as Group 0 interrupts.
*/
#define PLAT_RK_G1S_IRQS RK_G1S_IRQS
#define PLAT_RK_UART_BASE RK3368_UART2_BASE
#define PLAT_RK_UART_CLOCK RK3368_UART_CLOCK
#define PLAT_RK_UART_BAUDRATE RK3368_BAUDRATE
#define PLAT_RK_CCI_BASE CCI400_BASE
#define PLAT_RK_PRIMARY_CPU 0x0
#define RK_PLAT_AARCH_CFG RK_PLAT_CFG0
#endif
/* __PLATFORM_DEF_H__ */
plat/rockchip/rk3368/platform.mk
0 → 100644
View file @
61dbb028
#
# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of ARM nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
RK_PLAT
:=
plat/rockchip
RK_PLAT_SOC
:=
${RK_PLAT}
/
${PLAT}
RK_PLAT_COMMON
:=
${RK_PLAT}
/common
PLAT_INCLUDES
:=
-I
${RK_PLAT_COMMON}
/
\
-I
${RK_PLAT_COMMON}
/include/
\
-I
${RK_PLAT_COMMON}
/pmusram
\
-I
${RK_PLAT_COMMON}
/drivers/pmu/
\
-I
${RK_PLAT_SOC}
/
\
-I
${RK_PLAT_SOC}
/drivers/pmu/
\
-I
${RK_PLAT_SOC}
/drivers/soc/
\
-I
${RK_PLAT_SOC}
/drivers/ddr/
\
-I
${RK_PLAT_SOC}
/include/
RK_GIC_SOURCES
:=
drivers/arm/gic/common/gic_common.c
\
drivers/arm/gic/v2/gicv2_main.c
\
drivers/arm/gic/v2/gicv2_helpers.c
\
plat/common/plat_gicv2.c
\
${RK_PLAT}
/common/rockchip_gicv2.c
PLAT_BL_COMMON_SOURCES
:=
lib/aarch64/xlat_tables.c
\
plat/common/aarch64/plat_common.c
\
plat/common/aarch64/plat_psci_common.c
BL31_SOURCES
+=
${RK_GIC_SOURCES}
\
drivers/arm/cci/cci.c
\
drivers/console/console.S
\
drivers/ti/uart/16550_console.S
\
drivers/delay_timer/delay_timer.c
\
lib/cpus/aarch64/cortex_a53.S
\
plat/common/aarch64/platform_mp_stack.S
\
${RK_PLAT_COMMON}
/aarch64/plat_helpers.S
\
${RK_PLAT_COMMON}
/bl31_plat_setup.c
\
${RK_PLAT_COMMON}
/pmusram/pmu_sram_cpus_on.S
\
${RK_PLAT_COMMON}
/pmusram/pmu_sram.c
\
${RK_PLAT_COMMON}
/plat_delay_timer.c
\
${RK_PLAT_COMMON}
/plat_pm.c
\
${RK_PLAT_COMMON}
/plat_topology.c
\
${RK_PLAT_COMMON}
/aarch64/platform_common.c
\
${RK_PLAT_SOC}
/drivers/pmu/pmu.c
\
${RK_PLAT_SOC}
/drivers/soc/soc.c
\
${RK_PLAT_SOC}
/drivers/ddr/ddr_rk3368.c
\
ENABLE_PLAT_COMPAT
:=
0
plat/rockchip/rk3368/rk3368_def.h
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PLAT_DEF_H__
#define __PLAT_DEF_H__
/* Special value used to verify platform parameters from BL2 to BL3-1 */
#define RK_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL
#define CCI400_BASE 0xffb90000
#define CCI400_SIZE 0x10000
#define GIC400_BASE 0xffb70000
#define GIC400_SIZE 0x10000
#define STIME_BASE 0xff830000
#define STIME_SIZE 0x10000
#define CRU_BASE 0xff760000
#define CRU_SIZE 0x10000
#define GRF_BASE 0xff770000
#define GRF_SIZE 0x10000
#define SGRF_BASE 0xff740000
#define SGRF_SIZE 0x10000
#define PMU_BASE 0xff730000
#define PMU_GRF_BASE 0xff738000
#define PMU_SIZE 0x10000
#define RK_INTMEM_BASE 0xff8c0000
#define RK_INTMEM_SIZE 0x10000
#define UART_DBG_BASE 0xff690000
#define UART_DBG_SIZE 0x10000
#define CRU_BASE 0xff760000
#define PMUSRAM_BASE 0xff720000
#define PMUSRAM_SIZE 0x10000
#define PMUSRAM_RSIZE 0x1000
#define DDR_PCTL_BASE 0xff610000
#define DDR_PCTL_SIZE 0x10000
#define DDR_PHY_BASE 0xff620000
#define DDR_PHY_SIZE 0x10000
#define SERVICE_BUS_BASE 0xffac0000
#define SERVICE_BUS_SISE 0x50000
#define COLD_BOOT_BASE 0xffff0000
/**************************************************************************
* UART related constants
**************************************************************************/
#define RK3368_UART2_BASE UART_DBG_BASE
#define RK3368_BAUDRATE 115200
#define RK3368_UART_CLOCK 24000000
/******************************************************************************
* System counter frequency related constants
******************************************************************************/
#define SYS_COUNTER_FREQ_IN_TICKS 24000000
#define SYS_COUNTER_FREQ_IN_MHZ 24
/******************************************************************************
* GIC-400 & interrupt handling related constants
******************************************************************************/
/* Base rk_platform compatible GIC memory map */
#define RK3368_GICD_BASE (GIC400_BASE + 0x1000)
#define RK3368_GICC_BASE (GIC400_BASE + 0x2000)
#define RK3368_GICR_BASE 0
/* no GICR in GIC-400 */
/*****************************************************************************
* CCI-400 related constants
******************************************************************************/
#define PLAT_RK_CCI_CLUSTER0_SL_IFACE_IX 3
#define PLAT_RK_CCI_CLUSTER1_SL_IFACE_IX 4
/******************************************************************************
* cpu up status
******************************************************************************/
#define PMU_CPU_HOTPLUG 0xdeadbeaf
#define PMU_CPU_AUTO_PWRDN 0xabcdef12
/******************************************************************************
* sgi, ppi
******************************************************************************/
#define RK_IRQ_SEC_PHY_TIMER 29
#define RK_IRQ_SEC_SGI_0 8
#define RK_IRQ_SEC_SGI_1 9
#define RK_IRQ_SEC_SGI_2 10
#define RK_IRQ_SEC_SGI_3 11
#define RK_IRQ_SEC_SGI_4 12
#define RK_IRQ_SEC_SGI_5 13
#define RK_IRQ_SEC_SGI_6 14
#define RK_IRQ_SEC_SGI_7 15
/*
* Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
* terminology. On a GICv2 system or mode, the lists will be merged and treated
* as Group 0 interrupts.
*/
#define RK_G1S_IRQS (RK_IRQ_SEC_PHY_TIMER)
#endif
/* __PLAT_DEF_H__ */
plat/rockchip/rk3399/drivers/pmu/pmu.c
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <arch_helpers.h>
#include <assert.h>
#include <bakery_lock.h>
#include <debug.h>
#include <delay_timer.h>
#include <errno.h>
#include <mmio.h>
#include <platform.h>
#include <platform_def.h>
#include <plat_private.h>
#include <rk3399_def.h>
#include <pmu_sram.h>
#include <soc.h>
#include <pmu.h>
#include <pmu_com.h>
static
struct
psram_data_t
*
psram_sleep_cfg
=
(
struct
psram_data_t
*
)
PSRAM_DT_BASE
;
/*
* There are two ways to powering on or off on core.
* 1) Control it power domain into on or off in PMU_PWRDN_CON reg,
* it is core_pwr_pd mode
* 2) Enable the core power manage in PMU_CORE_PM_CON reg,
* then, if the core enter into wfi, it power domain will be
* powered off automatically. it is core_pwr_wfi or core_pwr_wfi_int mode
* so we need core_pm_cfg_info to distinguish which method be used now.
*/
static
uint32_t
core_pm_cfg_info
[
PLATFORM_CORE_COUNT
]
#if USE_COHERENT_MEM
__attribute__
((
section
(
"tzfw_coherent_mem"
)))
#endif
;
/* coheront */
void
plat_rockchip_pmusram_prepare
(
void
)
{
uint32_t
*
sram_dst
,
*
sram_src
;
size_t
sram_size
=
2
;
/*
* pmu sram code and data prepare
*/
sram_dst
=
(
uint32_t
*
)
PMUSRAM_BASE
;
sram_src
=
(
uint32_t
*
)
&
pmu_cpuson_entrypoint_start
;
sram_size
=
(
uint32_t
*
)
&
pmu_cpuson_entrypoint_end
-
(
uint32_t
*
)
sram_src
;
u32_align_cpy
(
sram_dst
,
sram_src
,
sram_size
);
psram_sleep_cfg
->
sp
=
PSRAM_DT_BASE
;
}
static
inline
uint32_t
get_cpus_pwr_domain_cfg_info
(
uint32_t
cpu_id
)
{
return
core_pm_cfg_info
[
cpu_id
];
}
static
inline
void
set_cpus_pwr_domain_cfg_info
(
uint32_t
cpu_id
,
uint32_t
value
)
{
core_pm_cfg_info
[
cpu_id
]
=
value
;
#if !USE_COHERENT_MEM
flush_dcache_range
((
uintptr_t
)
&
core_pm_cfg_info
[
cpu_id
],
sizeof
(
uint32_t
));
#endif
}
static
int
cpus_power_domain_on
(
uint32_t
cpu_id
)
{
uint32_t
cfg_info
;
uint32_t
cpu_pd
=
PD_CPUL0
+
cpu_id
;
/*
* There are two ways to powering on or off on core.
* 1) Control it power domain into on or off in PMU_PWRDN_CON reg
* 2) Enable the core power manage in PMU_CORE_PM_CON reg,
* then, if the core enter into wfi, it power domain will be
* powered off automatically.
*/
cfg_info
=
get_cpus_pwr_domain_cfg_info
(
cpu_id
);
if
(
cfg_info
==
core_pwr_pd
)
{
/* disable core_pm cfg */
mmio_write_32
(
PMU_BASE
+
PMU_CORE_PM_CON
(
cpu_id
),
CORES_PM_DISABLE
);
/* if the cores have be on, power off it firstly */
if
(
pmu_power_domain_st
(
cpu_pd
)
==
pmu_pd_on
)
{
mmio_write_32
(
PMU_BASE
+
PMU_CORE_PM_CON
(
cpu_id
),
0
);
pmu_power_domain_ctr
(
cpu_pd
,
pmu_pd_off
);
}
pmu_power_domain_ctr
(
cpu_pd
,
pmu_pd_on
);
}
else
{
if
(
pmu_power_domain_st
(
cpu_pd
)
==
pmu_pd_on
)
{
WARN
(
"%s: cpu%d is not in off,!
\n
"
,
__func__
,
cpu_id
);
return
-
EINVAL
;
}
mmio_write_32
(
PMU_BASE
+
PMU_CORE_PM_CON
(
cpu_id
),
BIT
(
core_pm_sft_wakeup_en
));
}
return
0
;
}
static
int
cpus_power_domain_off
(
uint32_t
cpu_id
,
uint32_t
pd_cfg
)
{
uint32_t
cpu_pd
;
uint32_t
core_pm_value
;
cpu_pd
=
PD_CPUL0
+
cpu_id
;
if
(
pmu_power_domain_st
(
cpu_pd
)
==
pmu_pd_off
)
return
0
;
if
(
pd_cfg
==
core_pwr_pd
)
{
if
(
check_cpu_wfie
(
cpu_id
,
CKECK_WFEI_MSK
))
return
-
EINVAL
;
/* disable core_pm cfg */
mmio_write_32
(
PMU_BASE
+
PMU_CORE_PM_CON
(
cpu_id
),
CORES_PM_DISABLE
);
set_cpus_pwr_domain_cfg_info
(
cpu_id
,
pd_cfg
);
pmu_power_domain_ctr
(
cpu_pd
,
pmu_pd_off
);
}
else
{
set_cpus_pwr_domain_cfg_info
(
cpu_id
,
pd_cfg
);
core_pm_value
=
BIT
(
core_pm_en
);
if
(
pd_cfg
==
core_pwr_wfi_int
)
core_pm_value
|=
BIT
(
core_pm_int_wakeup_en
);
mmio_write_32
(
PMU_BASE
+
PMU_CORE_PM_CON
(
cpu_id
),
core_pm_value
);
}
return
0
;
}
static
void
nonboot_cpus_off
(
void
)
{
uint32_t
boot_cpu
,
cpu
;
boot_cpu
=
plat_my_core_pos
();
/* turn off noboot cpus */
for
(
cpu
=
0
;
cpu
<
PLATFORM_CORE_COUNT
;
cpu
++
)
{
if
(
cpu
==
boot_cpu
)
continue
;
cpus_power_domain_off
(
cpu
,
core_pwr_pd
);
}
}
static
int
cores_pwr_domain_on
(
unsigned
long
mpidr
,
uint64_t
entrypoint
)
{
uint32_t
cpu_id
=
plat_core_pos_by_mpidr
(
mpidr
);
assert
(
cpuson_flags
[
cpu_id
]
==
0
);
cpuson_flags
[
cpu_id
]
=
PMU_CPU_HOTPLUG
;
cpuson_entry_point
[
cpu_id
]
=
entrypoint
;
dsb
();
cpus_power_domain_on
(
cpu_id
);
return
0
;
}
static
int
cores_pwr_domain_off
(
void
)
{
uint32_t
cpu_id
=
plat_my_core_pos
();
cpus_power_domain_off
(
cpu_id
,
core_pwr_wfi
);
return
0
;
}
static
int
cores_pwr_domain_suspend
(
void
)
{
uint32_t
cpu_id
=
plat_my_core_pos
();
assert
(
cpuson_flags
[
cpu_id
]
==
0
);
cpuson_flags
[
cpu_id
]
=
PMU_CPU_AUTO_PWRDN
;
cpuson_entry_point
[
cpu_id
]
=
(
uintptr_t
)
psci_entrypoint
;
dsb
();
cpus_power_domain_off
(
cpu_id
,
core_pwr_wfi_int
);
return
0
;
}
static
int
cores_pwr_domain_on_finish
(
void
)
{
uint32_t
cpu_id
=
plat_my_core_pos
();
cpuson_flags
[
cpu_id
]
=
0
;
cpuson_entry_point
[
cpu_id
]
=
0
;
/* Disable core_pm */
mmio_write_32
(
PMU_BASE
+
PMU_CORE_PM_CON
(
cpu_id
),
CORES_PM_DISABLE
);
return
0
;
}
static
int
cores_pwr_domain_resume
(
void
)
{
uint32_t
cpu_id
=
plat_my_core_pos
();
cpuson_flags
[
cpu_id
]
=
0
;
cpuson_entry_point
[
cpu_id
]
=
0
;
/* Disable core_pm */
mmio_write_32
(
PMU_BASE
+
PMU_CORE_PM_CON
(
cpu_id
),
CORES_PM_DISABLE
);
return
0
;
}
static
void
sys_slp_config
(
void
)
{
uint32_t
slp_mode_cfg
=
0
;
slp_mode_cfg
=
PMU_PWR_MODE_EN
|
PMU_CPU0_PD_EN
|
PMU_L2_FLUSH_EN
|
PMU_L2_IDLE_EN
|
PMU_SCU_PD_EN
|
PMU_CLK_CORE_SRC_GATE_EN
;
mmio_setbits_32
(
PMU_BASE
+
PMU_WKUP_CFG4
,
PMU_CLUSTER_L_WKUP_EN
);
mmio_setbits_32
(
PMU_BASE
+
PMU_WKUP_CFG4
,
PMU_CLUSTER_B_WKUP_EN
);
mmio_clrbits_32
(
PMU_BASE
+
PMU_WKUP_CFG4
,
PMU_GPIO_WKUP_EN
);
mmio_write_32
(
PMU_BASE
+
PMU_PWRMODE_CON
,
slp_mode_cfg
);
}
static
int
sys_pwr_domain_suspend
(
void
)
{
sys_slp_config
();
plls_suspend
();
psram_sleep_cfg
->
sys_mode
=
PMU_SYS_SLP_MODE
;
pmu_sgrf_rst_hld
();
return
0
;
}
static
int
sys_pwr_domain_resume
(
void
)
{
pmu_sgrf_rst_hld_release
();
psram_sleep_cfg
->
sys_mode
=
PMU_SYS_ON_MODE
;
plls_resume
();
return
0
;
}
static
struct
rockchip_pm_ops_cb
pm_ops
=
{
.
cores_pwr_dm_on
=
cores_pwr_domain_on
,
.
cores_pwr_dm_off
=
cores_pwr_domain_off
,
.
cores_pwr_dm_on_finish
=
cores_pwr_domain_on_finish
,
.
cores_pwr_dm_suspend
=
cores_pwr_domain_suspend
,
.
cores_pwr_dm_resume
=
cores_pwr_domain_resume
,
.
sys_pwr_dm_suspend
=
sys_pwr_domain_suspend
,
.
sys_pwr_dm_resume
=
sys_pwr_domain_resume
,
.
sys_gbl_soft_reset
=
soc_global_soft_reset
,
};
void
plat_rockchip_pmu_init
(
void
)
{
uint32_t
cpu
;
rockchip_pd_lock_init
();
plat_setup_rockchip_pm_ops
(
&
pm_ops
);
for
(
cpu
=
0
;
cpu
<
PLATFORM_CORE_COUNT
;
cpu
++
)
cpuson_flags
[
cpu
]
=
0
;
psram_sleep_cfg
->
sys_mode
=
PMU_SYS_ON_MODE
;
psram_sleep_cfg
->
boot_mpidr
=
read_mpidr_el1
()
&
0xffff
;
/* cpu boot from pmusram */
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON0_1
(
1
),
(
PMUSRAM_BASE
>>
CPU_BOOT_ADDR_ALIGN
)
|
CPU_BOOT_ADDR_WMASK
);
nonboot_cpus_off
();
INFO
(
"%s(%d): pd status %x
\n
"
,
__func__
,
__LINE__
,
mmio_read_32
(
PMU_BASE
+
PMU_PWRDN_ST
));
}
plat/rockchip/rk3399/drivers/pmu/pmu.h
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PMU_H__
#define __PMU_H__
/* Allocate sp reginon in pmusram */
#define PSRAM_SP_SIZE 0x80
#define PSRAM_SP_BOTTOM (PSRAM_SP_TOP - PSRAM_SP_SIZE)
/*****************************************************************************
* Common define for per soc pmu.h
*****************************************************************************/
/* The ways of cores power domain contorlling */
enum
cores_pm_ctr_mode
{
core_pwr_pd
=
0
,
core_pwr_wfi
=
1
,
core_pwr_wfi_int
=
2
};
/*****************************************************************************
* pmu con,reg
*****************************************************************************/
#define PMU_WKUP_CFG(n) ((n) * 4)
#define PMU_CORE_PM_CON(cpu) (0xc0 + (cpu * 4))
/* the shift of bits for cores status */
enum
pmu_core_pwrst_shift
{
clstl_cpu_wfe
=
2
,
clstl_cpu_wfi
=
6
,
clstb_cpu_wfe
=
12
,
clstb_cpu_wfi
=
16
};
#define CKECK_WFE_MSK 0x1
#define CKECK_WFI_MSK 0x10
#define CKECK_WFEI_MSK 0x11
enum
pmu_powerdomain_id
{
PD_CPUL0
=
0
,
PD_CPUL1
,
PD_CPUL2
,
PD_CPUL3
,
PD_CPUB0
,
PD_CPUB1
,
PD_SCUL
,
PD_SCUB
,
PD_TCPD0
,
PD_TCPD1
,
PD_CCI
,
PD_PERILP
,
PD_PERIHP
,
PD_CENTER
,
PD_VIO
,
PD_GPU
,
PD_VCODEC
,
PD_VDU
,
PD_RGA
,
PD_IEP
,
PD_VO
,
PD_ISP0
=
22
,
PD_ISP1
,
PD_HDCP
,
PD_GMAC
,
PD_EMMC
,
PD_USB3
,
PD_EDP
,
PD_GIC
,
PD_SD
,
PD_SDIOAUDIO
,
PD_END
};
enum
powerdomain_state
{
PMU_POWER_ON
=
0
,
PMU_POWER_OFF
,
};
enum
pmu_bus_id
{
BUS_ID_GPU
=
0
,
BUS_ID_PERILP
,
BUS_ID_PERIHP
,
BUS_ID_VCODEC
,
BUS_ID_VDU
,
BUS_ID_RGA
,
BUS_ID_IEP
,
BUS_ID_VOPB
,
BUS_ID_VOPL
,
BUS_ID_ISP0
,
BUS_ID_ISP1
,
BUS_ID_HDCP
,
BUS_ID_USB3
,
BUS_ID_PERILPM0
,
BUS_ID_CENTER
,
BUS_ID_CCIM0
,
BUS_ID_CCIM1
,
BUS_ID_VIO
,
BUS_ID_MSCH0
,
BUS_ID_MSCH1
,
BUS_ID_ALIVE
,
BUS_ID_PMU
,
BUS_ID_EDP
,
BUS_ID_GMAC
,
BUS_ID_EMMC
,
BUS_ID_CENTER1
,
BUS_ID_PMUM0
,
BUS_ID_GIC
,
BUS_ID_SD
,
BUS_ID_SDIOAUDIO
,
};
enum
pmu_bus_state
{
BUS_ACTIVE
,
BUS_IDLE
,
};
/* pmu_cpuapm bit */
enum
pmu_cores_pm_by_wfi
{
core_pm_en
=
0
,
core_pm_int_wakeup_en
,
core_pm_resv
,
core_pm_sft_wakeup_en
};
enum
pmu_wkup_cfg0
{
PMU_GPIO0A_POSE_WKUP_EN
=
0
,
PMU_GPIO0B_POSE_WKUP_EN
=
8
,
PMU_GPIO0C_POSE_WKUP_EN
=
16
,
PMU_GPIO0D_POSE_WKUP_EN
=
24
,
};
enum
pmu_wkup_cfg1
{
PMU_GPIO0A_NEGEDGE_WKUP_EN
=
0
,
PMU_GPIO0B_NEGEDGE_WKUP_EN
=
7
,
PMU_GPIO0C_NEGEDGE_WKUP_EN
=
16
,
PMU_GPIO0D_NEGEDGE_WKUP_EN
=
24
,
};
enum
pmu_wkup_cfg2
{
PMU_GPIO1A_POSE_WKUP_EN
=
0
,
PMU_GPIO1B_POSE_WKUP_EN
=
7
,
PMU_GPIO1C_POSE_WKUP_EN
=
16
,
PMU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ST
,
};
enum
pmu_gpio0_pos_int_con
{
PMU_GPIO0A_POS_INT_EN
=
0
,
PMU_GPIO0B_POS_INT_EN
=
8
,
PMU_GPIO0C_POS_INT_EN
=
16
,
PMU_GPIO0D_POS_INT_EN
=
24
,
};
enum
pmu_gpio0_neg_int_con
{
PMU_GPIO0A_NEG_INT_EN
=
0
,
PMU_GPIO0B_NEG_INT_EN
=
8
,
PMU_GPIO0C_NEG_INT_EN
=
16
,
PMU_GPIO0D_NEG_INT_EN
=
24
,
};
enum
pmu_gpio1_pos_int_con
{
PMU_GPIO1A_POS_INT_EN
=
0
,
PMU_GPIO1B_POS_INT_EN
=
8
,
PMU_GPIO1C_POS_INT_EN
=
16
,
PMU_GPIO1D_POS_INT_EN
=
24
,
};
enum
pmu_gpio1_neg_int_con
{
PMU_GPIO1A_NEG_INT_EN
=
0
,
PMU_GPIO1B_NEG_INT_EN
=
8
,
PMU_GPIO1C_NEG_INT_EN
=
16
,
PMU_GPIO1D_NEG_INT_EN
=
24
,
};
enum
pmu_gpio0_pos_int_st
{
PMU_GPIO0A_POS_INT_ST
=
0
,
PMU_GPIO0B_POS_INT_ST
=
8
,
PMU_GPIO0C_POS_INT_ST
=
16
,
PMU_GPIO0D_POS_INT_ST
=
24
,
};
enum
pmu_gpio0_neg_int_st
{
PMU_GPIO0A_NEG_INT_ST
=
0
,
PMU_GPIO0B_NEG_INT_ST
=
8
,
PMU_GPIO0C_NEG_INT_ST
=
16
,
PMU_GPIO0D_NEG_INT_ST
=
24
,
};
enum
pmu_gpio1_pos_int_st
{
PMU_GPIO1A_POS_INT_ST
=
0
,
PMU_GPIO1B_POS_INT_ST
=
8
,
PMU_GPIO1C_POS_INT_ST
=
16
,
PMU_GPIO1D_POS_INT_ST
=
24
,
};
enum
pmu_gpio1_neg_int_st
{
PMU_GPIO1A_NEG_INT_ST
=
0
,
PMU_GPIO1B_NEG_INT_ST
=
8
,
PMU_GPIO1C_NEG_INT_ST
=
16
,
PMU_GPIO1D_NEG_INT_ST
=
24
,
};
/* pmu power down configure register 0x0050 */
enum
pmu_pwrdn_inten
{
PMU_A53_L0_PWR_SWITCH_INT_EN
=
0
,
PMU_A53_L1_PWR_SWITCH_INT_EN
,
PMU_A53_L2_PWR_SWITCH_INT_EN
,
PMU_A53_L3_PWR_SWITCH_INT_EN
,
PMU_A72_B0_PWR_SWITCH_INT_EN
,
PMU_A72_B1_PWR_SWITCH_INT_EN
,
PMU_SCU_L_PWR_SWITCH_INT_EN
,
PMU_SCU_B_PWR_SWITCH_INT_EN
,
PMU_TCPD0_PWR_SWITCH_INT_EN
,
PMU_TCPD1_PWR_SWITCH_INT_EN
,
PMU_CCI_PWR_SWITCH_INT_EN
,
PMU_PERILP_PWR_SWITCH_INT_EN
,
PMU_PERIHP_PWR_SWITCH_INT_EN
,
PMU_CENTER_PWR_SWITCH_INT_EN
,
PMU_VIO_PWR_SWITCH_INT_EN
,
PMU_GPU_PWR_SWITCH_INT_EN
,
PMU_VCODEC_PWR_SWITCH_INT_EN
,
PMU_VDU_PWR_SWITCH_INT_EN
,
PMU_RGA_PWR_SWITCH_INT_EN
,
PMU_IEP_PWR_SWITCH_INT_EN
,
PMU_VO_PWR_SWITCH_INT_EN
,
PMU_ISP0_PWR_SWITCH_INT_EN
=
22
,
PMU_ISP1_PWR_SWITCH_INT_EN
,
PMU_HDCP_PWR_SWITCH_INT_EN
,
PMU_GMAC_PWR_SWITCH_INT_EN
,
PMU_EMMC_PWR_SWITCH_INT_EN
,
PMU_USB3_PWR_SWITCH_INT_EN
,
PMU_EDP_PWR_SWITCH_INT_EN
,
PMU_GIC_PWR_SWITCH_INT_EN
,
PMU_SD_PWR_SWITCH_INT_EN
,
PMU_SDIOAUDIO_PWR_SWITCH_INT_EN
,
};
enum
pmu_wkup_status
{
PMU_WKUP_BY_CLSTER_L_INT
=
0
,
PMU_WKUP_BY_CLSTER_b_INT
,
PMU_WKUP_BY_GPIO_INT
,
PMU_WKUP_BY_SDIO_DET
,
PMU_WKUP_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ACK_IEP
,
PMU_IDLE_ACK_VOPB
,
PMU_IDLE_ACK_VOPL
,
PMU_IDLE_ACK_ISP0
,
PMU_IDLE_ACK_ISP1
,
PMU_IDLE_ACK_HDCP
,
PMU_IDLE_ACK_USB3
,
PMU_IDLE_ACK_PERILPM0
,
PMU_IDLE_ACK_CENTER
,
PMU_IDLE_ACK_CCIM0
,
PMU_IDLE_ACK_CCIM1
,
PMU_IDLE_ACK_VIO
,
PMU_IDLE_ACK_MSCH0
,
PMU_IDLE_ACK_MSCH1
,
PMU_IDLE_ACK_ALIVE
,
PMU_IDLE_ACK_PMU
,
PMU_IDLE_ACK_EDP
,
PMU_IDLE_ACK_GMAC
,
PMU_IDLE_ACK_EMMC
,
PMU_IDLE_ACK_CENTER1
,
PMU_IDLE_ACK_PMUM0
,
PMU_IDLE_ACK_GIC
,
PMU_IDLE_ACK_SD
,
PMU_IDLE_ACK_SDIOAUDIO
,
};
enum
pmu_pwrdn_con1
{
PMU_VD_SCU_L_PWRDN_EN
=
0
,
PMU_VD_SCU_B_PWRDN_EN
,
PMU_VD_CENTER_PWRDN_EN
,
};
#define PMU_WKUP_CFG0 0x00
#define PMU_WKUP_CFG1 0x04
#define PMU_WKUP_CFG2 0x08
#define PMU_WKUP_CFG3 0x0c
#define PMU_WKUP_CFG4 0x10
#define PMU_PWRDN_CON 0x14
#define PMU_PWRDN_ST 0x18
#define PMU_PLL_CON 0x1c
#define PMU_PWRMODE_CON 0x20
#define PMU_SFT_CON 0x24
#define PMU_INT_CON 0x28
#define PMU_INT_ST 0x2c
#define PMU_GPIO0_POS_INT_CON 0x30
#define PMU_GPIO0_NEG_INT_CON 0x34
#define PMU_GPIO1_POS_INT_CON 0x38
#define PMU_GPIO1_NEG_INT_CON 0x3c
#define PMU_GPIO0_POS_INT_ST 0x40
#define PMU_GPIO0_NEG_INT_ST 0x44
#define PMU_GPIO1_POS_INT_ST 0x48
#define PMU_GPIO1_NEG_INT_ST 0x4c
#define PMU_PWRDN_INTEN 0x50
#define PMU_PWRDN_STATUS 0x54
#define PMU_WAKEUP_STATUS 0x58
#define PMU_BUS_CLR 0x5c
#define PMU_BUS_IDLE_REQ 0x60
#define PMU_BUS_IDLE_ST 0x64
#define PMU_BUS_IDLE_ACK 0x68
#define PMU_CCI500_CON 0x6c
#define PMU_ADB400_CON 0x70
#define PMU_ADB400_ST 0x74
#define PMU_POWER_ST 0x78
#define PMU_CORE_PWR_ST 0x7c
#define PMU_OSC_CNT 0x80
#define PMU_PLLLOCK_CNT 0x84
#define PMU_PLLRST_CNT 0x88
#define PMU_STABLE_CNT 0x8c
#define PMU_DDRIO_PWRON_CNT 0x90
#define PMU_WAKEUP_RST_CLR_CNT 0x94
#define PMU_DDR_SREF_ST 0x98
#define PMU_SCU_L_PWRDN_CNT 0x9c
#define PMU_SCU_L_PWRUP_CNT 0xa0
#define PMU_SCU_B_PWRDN_CNT 0xa4
#define PMU_SCU_B_PWRUP_CNT 0xa8
#define PMU_GPU_PWRDN_CNT 0xac
#define PMU_GPU_PWRUP_CNT 0xb0
#define PMU_CENTER_PWRDN_CNT 0xb4
#define PMU_CENTER_PWRUP_CNT 0xb8
#define PMU_TIMEOUT_CNT 0xbc
#define PMU_CPU0APM_CON 0xc0
#define PMU_CPU1APM_CON 0xc4
#define PMU_CPU2APM_CON 0xc8
#define PMU_CPU3APM_CON 0xcc
#define PMU_CPU0BPM_CON 0xd0
#define PMU_CPU1BPM_CON 0xd4
#define PMU_NOC_AUTO_ENA 0xd8
#define PMU_PWRDN_CON1 0xdc
#define CORES_PM_DISABLE 0x0
#define PD_CTR_LOOP 500
#define CHK_CPU_LOOP 500
#endif
/* __PMU_H__ */
plat/rockchip/rk3399/drivers/soc/soc.c
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <arch_helpers.h>
#include <debug.h>
#include <delay_timer.h>
#include <mmio.h>
#include <platform_def.h>
#include <plat_private.h>
#include <rk3399_def.h>
#include <soc.h>
/* Table of regions to map using the MMU. */
const
mmap_region_t
plat_rk_mmap
[]
=
{
MAP_REGION_FLAT
(
GIC500_BASE
,
GIC500_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_SECURE
),
MAP_REGION_FLAT
(
CCI500_BASE
,
CCI500_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_SECURE
),
MAP_REGION_FLAT
(
STIME_BASE
,
STIME_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_SECURE
),
MAP_REGION_FLAT
(
CRUS_BASE
,
CRUS_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_SECURE
),
MAP_REGION_FLAT
(
SGRF_BASE
,
SGRF_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_SECURE
),
MAP_REGION_FLAT
(
PMU_BASE
,
PMU_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_NS
),
MAP_REGION_FLAT
(
PMUSRAM_BASE
,
PMUSRAM_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_SECURE
),
MAP_REGION_FLAT
(
RK3399_UART2_BASE
,
RK3399_UART2_SIZE
,
MT_DEVICE
|
MT_RW
|
MT_SECURE
),
{
0
}
};
/* The RockChip power domain tree descriptor */
const
unsigned
char
rockchip_power_domain_tree_desc
[]
=
{
/* No of root nodes */
PLATFORM_SYSTEM_COUNT
,
/* No of children for the root node */
PLATFORM_CLUSTER_COUNT
,
/* No of children for the first cluster node */
PLATFORM_CLUSTER0_CORE_COUNT
,
/* No of children for the second cluster node */
PLATFORM_CLUSTER1_CORE_COUNT
};
void
secure_timer_init
(
void
)
{
mmio_write_32
(
STIMER1_CHN_BASE
(
5
)
+
TIMER_END_COUNT0
,
0xffffffff
);
mmio_write_32
(
STIMER1_CHN_BASE
(
5
)
+
TIMER_END_COUNT1
,
0xffffffff
);
mmio_write_32
(
STIMER1_CHN_BASE
(
5
)
+
TIMER_INIT_COUNT0
,
0x0
);
mmio_write_32
(
STIMER1_CHN_BASE
(
5
)
+
TIMER_INIT_COUNT0
,
0x0
);
/* auto reload & enable the timer */
mmio_write_32
(
STIMER1_CHN_BASE
(
5
)
+
TIMER_CONTROL_REG
,
TIMER_EN
|
TIMER_FMODE
);
}
void
sgrf_init
(
void
)
{
/* security config for master */
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON3_7
(
5
),
SGRF_SOC_CON_WMSK
|
SGRF_SOC_ALLMST_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON3_7
(
6
),
SGRF_SOC_CON_WMSK
|
SGRF_SOC_ALLMST_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON3_7
(
7
),
SGRF_SOC_CON_WMSK
|
SGRF_SOC_ALLMST_NS
);
/* security config for slave */
mmio_write_32
(
SGRF_BASE
+
SGRF_PMU_SLV_CON0_1
(
0
),
SGRF_PMU_SLV_S_CFGED
|
SGRF_PMU_SLV_CRYPTO1_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_PMU_SLV_CON0_1
(
1
),
SGRF_PMU_SLV_CON1_CFG
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SLV_SECURE_CON0_4
(
0
),
SGRF_SLV_S_WMSK
|
SGRF_SLV_S_ALL_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SLV_SECURE_CON0_4
(
1
),
SGRF_SLV_S_WMSK
|
SGRF_SLV_S_ALL_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SLV_SECURE_CON0_4
(
2
),
SGRF_SLV_S_WMSK
|
SGRF_SLV_S_ALL_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SLV_SECURE_CON0_4
(
3
),
SGRF_SLV_S_WMSK
|
SGRF_SLV_S_ALL_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SLV_SECURE_CON0_4
(
4
),
SGRF_SLV_S_WMSK
|
SGRF_SLV_S_ALL_NS
);
/* security config for ddr memery */
mmio_write_32
(
SGRF_BASE
+
SGRF_DDRRGN_CON0_16
(
16
),
SGRF_DDR_RGN_BYPS
);
}
static
void
dma_secure_cfg
(
uint32_t
secure
)
{
if
(
secure
)
{
/* rgn0 secure for dmac0 and dmac1 */
mmio_write_32
(
SGRF_BASE
+
SGRF_DDRRGN_CON20_34
(
22
),
SGRF_L_MST_S_DDR_RGN
(
0
)
|
/* dmac0 */
SGRF_H_MST_S_DDR_RGN
(
0
)
/* dmac1 */
);
/* set dmac0 boot, under secure state */
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
8
),
SGRF_DMAC_CFG_S
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
9
),
SGRF_DMAC_CFG_S
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
10
),
SGRF_DMAC_CFG_S
);
/* dmac0 soft reset */
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC0_RST
);
udelay
(
5
);
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC0_RST_RLS
);
/* set dmac1 boot, under secure state */
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
11
),
SGRF_DMAC_CFG_S
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
12
),
SGRF_DMAC_CFG_S
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
13
),
SGRF_DMAC_CFG_S
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
14
),
SGRF_DMAC_CFG_S
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
15
),
SGRF_DMAC_CFG_S
);
/* dmac1 soft reset */
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC1_RST
);
udelay
(
5
);
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC1_RST_RLS
);
}
else
{
/* rgn non-secure for dmac0 and dmac1 */
mmio_write_32
(
SGRF_BASE
+
SGRF_DDRRGN_CON20_34
(
22
),
DMAC1_RGN_NS
|
DMAC0_RGN_NS
);
/* set dmac0 boot, under non-secure state */
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
8
),
DMAC0_BOOT_CFG_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
9
),
DMAC0_BOOT_PERIPH_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
10
),
DMAC0_BOOT_ADDR_NS
);
/* dmac0 soft reset */
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC0_RST
);
udelay
(
5
);
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC0_RST_RLS
);
/* set dmac1 boot, under non-secure state */
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
11
),
DMAC1_BOOT_CFG_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
12
),
DMAC1_BOOT_PERIPH_L_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
13
),
DMAC1_BOOT_ADDR_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
14
),
DMAC1_BOOT_PERIPH_H_NS
);
mmio_write_32
(
SGRF_BASE
+
SGRF_SOC_CON8_15
(
15
),
DMAC1_BOOT_IRQ_NS
);
/* dmac1 soft reset */
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC1_RST
);
udelay
(
5
);
mmio_write_32
(
CRU_BASE
+
CRU_SOFTRST_CON
(
10
),
CRU_DMAC1_RST_RLS
);
}
}
/* pll suspend */
struct
deepsleep_data_s
slp_data
;
static
void
pll_suspend_prepare
(
uint32_t
pll_id
)
{
int
i
;
if
(
pll_id
==
PPLL_ID
)
for
(
i
=
0
;
i
<
PLL_CON_COUNT
;
i
++
)
slp_data
.
plls_con
[
pll_id
][
i
]
=
mmio_read_32
(
PMUCRU_BASE
+
PMUCRU_PPLL_CON
(
i
));
else
for
(
i
=
0
;
i
<
PLL_CON_COUNT
;
i
++
)
slp_data
.
plls_con
[
pll_id
][
i
]
=
mmio_read_32
(
CRU_BASE
+
CRU_PLL_CON
(
pll_id
,
i
));
}
static
void
set_pll_slow_mode
(
uint32_t
pll_id
)
{
if
(
pll_id
==
PPLL_ID
)
mmio_write_32
(
PMUCRU_BASE
+
PMUCRU_PPLL_CON
(
3
),
PLL_SLOW_MODE
);
else
mmio_write_32
((
CRU_BASE
+
CRU_PLL_CON
(
pll_id
,
3
)),
PLL_SLOW_MODE
);
}
static
void
set_pll_normal_mode
(
uint32_t
pll_id
)
{
if
(
pll_id
==
PPLL_ID
)
mmio_write_32
(
PMUCRU_BASE
+
PMUCRU_PPLL_CON
(
3
),
PLL_NOMAL_MODE
);
else
mmio_write_32
(
CRU_BASE
+
CRU_PLL_CON
(
pll_id
,
3
),
PLL_NOMAL_MODE
);
}
static
void
set_pll_bypass
(
uint32_t
pll_id
)
{
if
(
pll_id
==
PPLL_ID
)
mmio_write_32
(
PMUCRU_BASE
+
PMUCRU_PPLL_CON
(
3
),
PLL_BYPASS_MODE
);
else
mmio_write_32
(
CRU_BASE
+
CRU_PLL_CON
(
pll_id
,
3
),
PLL_BYPASS_MODE
);
}
static
void
_pll_suspend
(
uint32_t
pll_id
)
{
set_pll_slow_mode
(
pll_id
);
set_pll_bypass
(
pll_id
);
}
void
plls_suspend
(
void
)
{
uint32_t
i
,
pll_id
;
for
(
pll_id
=
ALPLL_ID
;
pll_id
<
END_PLL_ID
;
pll_id
++
)
pll_suspend_prepare
(
pll_id
);
for
(
i
=
0
;
i
<
CRU_CLKSEL_COUNT
;
i
++
)
slp_data
.
cru_clksel_con
[
i
]
=
mmio_read_32
(
CRU_BASE
+
CRU_CLKSEL_OFFSET
+
i
*
REG_SIZE
);
for
(
i
=
0
;
i
<
PMUCRU_CLKSEL_CONUT
;
i
++
)
slp_data
.
pmucru_clksel_con
[
i
]
=
mmio_read_32
(
PMUCRU_BASE
+
PMUCRU_CLKSEL_OFFSET
+
i
*
REG_SIZE
);
_pll_suspend
(
CPLL_ID
);
_pll_suspend
(
NPLL_ID
);
_pll_suspend
(
VPLL_ID
);
_pll_suspend
(
PPLL_ID
);
_pll_suspend
(
GPLL_ID
);
_pll_suspend
(
ABPLL_ID
);
_pll_suspend
(
ALPLL_ID
);
}
static
void
set_plls_nobypass
(
uint32_t
pll_id
)
{
if
(
pll_id
==
PPLL_ID
)
mmio_write_32
(
PMUCRU_BASE
+
PMUCRU_PPLL_CON
(
3
),
PLL_NO_BYPASS_MODE
);
else
mmio_write_32
(
CRU_BASE
+
CRU_PLL_CON
(
pll_id
,
3
),
PLL_NO_BYPASS_MODE
);
}
static
void
plls_resume_prepare
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
CRU_CLKSEL_COUNT
;
i
++
)
mmio_write_32
((
CRU_BASE
+
CRU_CLKSEL_OFFSET
+
i
*
REG_SIZE
),
REG_SOC_WMSK
|
slp_data
.
cru_clksel_con
[
i
]);
for
(
i
=
0
;
i
<
PMUCRU_CLKSEL_CONUT
;
i
++
)
mmio_write_32
((
PMUCRU_BASE
+
PMUCRU_CLKSEL_OFFSET
+
i
*
REG_SIZE
),
REG_SOC_WMSK
|
slp_data
.
pmucru_clksel_con
[
i
]);
}
void
plls_resume
(
void
)
{
int
pll_id
;
plls_resume_prepare
();
for
(
pll_id
=
ALPLL_ID
;
pll_id
<
END_PLL_ID
;
pll_id
++
)
{
set_plls_nobypass
(
pll_id
);
set_pll_normal_mode
(
pll_id
);
}
}
void
soc_global_soft_reset_init
(
void
)
{
mmio_write_32
(
PMUCRU_BASE
+
CRU_PMU_RSTHOLD_CON
(
1
),
CRU_PMU_SGRF_RST_RLS
);
}
void
__dead2
soc_global_soft_reset
(
void
)
{
uint32_t
temp_val
;
set_pll_slow_mode
(
VPLL_ID
);
set_pll_slow_mode
(
NPLL_ID
);
set_pll_slow_mode
(
GPLL_ID
);
set_pll_slow_mode
(
CPLL_ID
);
set_pll_slow_mode
(
PPLL_ID
);
set_pll_slow_mode
(
ABPLL_ID
);
set_pll_slow_mode
(
ALPLL_ID
);
temp_val
=
mmio_read_32
(
CRU_BASE
+
CRU_GLB_RST_CON
)
|
PMU_RST_BY_FIRST_SFT
;
mmio_write_32
(
CRU_BASE
+
CRU_GLB_RST_CON
,
temp_val
);
mmio_write_32
(
CRU_BASE
+
CRU_GLB_SRST_FST
,
GLB_SRST_FST_CFG_VAL
);
/*
* Maybe the HW needs some times to reset the system,
* so we do not hope the core to excute valid codes.
*/
while
(
1
)
;
}
void
plat_rockchip_soc_init
(
void
)
{
secure_timer_init
();
dma_secure_cfg
(
0
);
sgrf_init
();
soc_global_soft_reset_init
();
}
plat/rockchip/rk3399/drivers/soc/soc.h
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SOC_H__
#define __SOC_H__
#define GLB_SRST_FST_CFG_VAL 0xfdb9
#define GLB_SRST_SND_CFG_VAL 0xeca8
#define PMUCRU_PPLL_CON_OFFSET 0x000
#define PMUCRU_PPLL_CON_BASE_ADDR (PMUCRU_BASE + PMUCRU_PPLL_CON_OFFSET)
#define PMUCRU_PPLL_CON_CONUT 0x06
#define PMUCRU_PPLL_CON(num) (PMUCRU_PPLL_CON_BASE_ADDR + num * 4)
#define CRU_PLL_CON(pll_id, num) (CRU_BASE + pll_id * 0x20 + num * 4)
#define PLL_MODE_MSK 0x03
#define PLL_MODE_SHIFT 0x08
#define PLL_BYPASS_MSK 0x01
#define PLL_BYPASS_SHIFT 0x01
#define PLL_PWRDN_MSK 0x01
#define PLL_PWRDN_SHIFT 0x0
#define PLL_BYPASS BIT(1)
#define PLL_PWRDN BIT(0)
#define NO_PLL_BYPASS (0x00)
#define NO_PLL_PWRDN (0x00)
#define PLL_SLOW_MODE BITS_WITH_WMASK(PLL_MODE_MSK,\
SLOW_MODE, PLL_MODE_SHIFT)
#define PLL_BYPASS_MODE BITS_WITH_WMASK(PLL_BYPASS_MSK,\
PLL_BYPASS, PLL_BYPASS_SHIFT)
#define PLL_NO_BYPASS_MODE BITS_WITH_WMASK(PLL_BYPASS_MSK,\
NO_PLL_BYPASS, PLL_BYPASS_SHIFT)
#define PLL_NOMAL_MODE BITS_WITH_WMASK(PLL_MODE_MSK,\
NORMAL_MODE, PLL_MODE_SHIFT)
#define PLL_CON_COUNT 0x06
#define CRU_CLKSEL_COUNT 0x108
#define CRU_CLKSEL_OFFSET 0x300
#define PMUCRU_CLKSEL_CONUT 0x06
#define PMUCRU_CLKSEL_OFFSET 0x080
#define REG_SIZE 0x04
#define REG_SOC_WMSK 0xffff0000
enum
plls_id
{
ALPLL_ID
=
0
,
ABPLL_ID
,
DPLL_ID
,
CPLL_ID
,
GPLL_ID
,
NPLL_ID
,
VPLL_ID
,
PPLL_ID
,
END_PLL_ID
,
};
enum
pll_work_mode
{
SLOW_MODE
=
0x00
,
NORMAL_MODE
=
0x01
,
DEEP_SLOW_MODE
=
0x02
,
};
enum
glb_sft_reset
{
PMU_RST_BY_FIRST_SFT
,
PMU_RST_BY_SECOND_SFT
=
BIT
(
2
),
PMU_RST_NOT_BY_SFT
=
BIT
(
3
),
};
struct
deepsleep_data_s
{
uint32_t
plls_con
[
END_PLL_ID
][
PLL_CON_COUNT
];
uint32_t
pmucru_clksel_con
[
PMUCRU_CLKSEL_CONUT
];
uint32_t
cru_clksel_con
[
CRU_CLKSEL_COUNT
];
};
/**************************************************
* secure timer
**************************************************/
/* chanal0~5 */
#define STIMER0_CHN_BASE(n) (STIME_BASE + 0x20 * (n))
/* chanal6~11 */
#define STIMER1_CHN_BASE(n) (STIME_BASE + 0x8000 + 0x20 * (n))
/* low 32 bits */
#define TIMER_END_COUNT0 0x00
/* high 32 bits */
#define TIMER_END_COUNT1 0x04
#define TIMER_CURRENT_VALUE0 0x08
#define TIMER_CURRENT_VALUE1 0x0C
/* low 32 bits */
#define TIMER_INIT_COUNT0 0x10
/* high 32 bits */
#define TIMER_INIT_COUNT1 0x14
#define TIMER_INTSTATUS 0x18
#define TIMER_CONTROL_REG 0x1c
#define TIMER_EN 0x1
#define TIMER_FMODE (0x0 << 1)
#define TIMER_RMODE (0x1 << 1)
/**************************************************
* cru reg, offset
**************************************************/
#define CRU_SOFTRST_CON(n) (0x400 + (n) * 4)
#define CRU_DMAC0_RST BIT_WITH_WMSK(3)
/* reset release*/
#define CRU_DMAC0_RST_RLS WMSK_BIT(3)
#define CRU_DMAC1_RST BIT_WITH_WMSK(4)
/* reset release*/
#define CRU_DMAC1_RST_RLS WMSK_BIT(4)
#define CRU_GLB_RST_CON 0x0510
#define CRU_GLB_SRST_FST 0x0500
#define CRU_GLB_SRST_SND 0x0504
/**************************************************
* pmu cru reg, offset
**************************************************/
#define CRU_PMU_RSTHOLD_CON(n) (0x120 + n * 4)
/* reset hold*/
#define CRU_PMU_SGRF_RST_HOLD BIT_WITH_WMSK(6)
/* reset hold release*/
#define CRU_PMU_SGRF_RST_RLS WMSK_BIT(6)
/**************************************************
* sgrf reg, offset
**************************************************/
#define SGRF_SOC_CON0_1(n) (0xc000 + (n) * 4)
#define SGRF_SOC_CON3_7(n) (0xe00c + ((n) - 3) * 4)
#define SGRF_SOC_CON8_15(n) (0x8020 + ((n) - 8) * 4)
#define SGRF_PMU_SLV_CON0_1(n) (0xc240 + ((n) - 0) * 4)
#define SGRF_SLV_SECURE_CON0_4(n) (0xe3c0 + ((n) - 0) * 4)
#define SGRF_DDRRGN_CON0_16(n) ((n) * 4)
#define SGRF_DDRRGN_CON20_34(n) (0x50 + ((n) - 20) * 4)
/* security config for master */
#define SGRF_SOC_CON_WMSK 0xffff0000
/* All of master in ns */
#define SGRF_SOC_ALLMST_NS 0xffff
/* security config for slave */
#define SGRF_SLV_S_WMSK 0xffff0000
#define SGRF_SLV_S_ALL_NS 0x0
/* security config pmu slave ip */
/* All of slaves is ns */
#define SGRF_PMU_SLV_S_NS BIT_WITH_WMSK(0)
/* slaves secure attr is configed */
#define SGRF_PMU_SLV_S_CFGED WMSK_BIT(0)
#define SGRF_PMU_SLV_CRYPTO1_NS WMSK_BIT(1)
#define SGRF_PMUSRAM_S BIT(8)
#define SGRF_PMU_SLV_CON1_CFG (SGRF_SLV_S_WMSK | \
SGRF_PMUSRAM_S)
/* ddr region */
#define SGRF_DDR_RGN_BYPS BIT_WITH_WMSK(9)
/* All of ddr rgn is ns */
/* The MST access the ddr rgn n with secure attribution */
#define SGRF_L_MST_S_DDR_RGN(n) BIT_WITH_WMSK((n))
/* bits[16:8]*/
#define SGRF_H_MST_S_DDR_RGN(n) BIT_WITH_WMSK((n) + 8)
/* dmac to periph s or ns*/
#define SGRF_DMAC_CFG_S 0xffff0000
#define DMAC1_RGN_NS 0xff000000
#define DMAC0_RGN_NS 0x00ff0000
#define DMAC0_BOOT_CFG_NS 0xfffffff8
#define DMAC0_BOOT_PERIPH_NS 0xffff0fff
#define DMAC0_BOOT_ADDR_NS 0xffff0000
#define DMAC1_BOOT_CFG_NS 0xffff0008
#define DMAC1_BOOT_PERIPH_L_NS 0xffff0fff
#define DMAC1_BOOT_ADDR_NS 0xffff0000
#define DMAC1_BOOT_PERIPH_H_NS 0xffffffff
#define DMAC1_BOOT_IRQ_NS 0xffffffff
#define CPU_BOOT_ADDR_WMASK 0xffff0000
#define CPU_BOOT_ADDR_ALIGN 16
/*
* When system reset in running state, we want the cpus to be reboot
* from maskrom (system reboot),
* the pmusgrf reset-hold bits needs to be released.
* When system wake up from system deep suspend, some soc will be reset
* when waked up,
* we want the bootcpu to be reboot from pmusram,
* the pmusgrf reset-hold bits needs to be held.
*/
static
inline
void
pmu_sgrf_rst_hld_release
(
void
)
{
mmio_write_32
(
PMUCRU_BASE
+
CRU_PMU_RSTHOLD_CON
(
1
),
CRU_PMU_SGRF_RST_RLS
);
}
static
inline
void
pmu_sgrf_rst_hld
(
void
)
{
mmio_write_32
(
PMUCRU_BASE
+
CRU_PMU_RSTHOLD_CON
(
1
),
CRU_PMU_SGRF_RST_HOLD
);
}
/* funciton*/
void
__dead2
soc_global_soft_reset
(
void
);
void
plls_resume
(
void
);
void
plls_suspend
(
void
);
#endif
/* __SOC_H__ */
plat/rockchip/rk3399/include/platform_def.h
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PLATFORM_DEF_H__
#define __PLATFORM_DEF_H__
#include <arch.h>
#include <common_def.h>
#include <rk3399_def.h>
#define DEBUG_XLAT_TABLE 0
/*******************************************************************************
* Platform binary types for linking
******************************************************************************/
#define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
#define PLATFORM_LINKER_ARCH aarch64
/*******************************************************************************
* Generic platform constants
******************************************************************************/
/* Size of cacheable stacks */
#if DEBUG_XLAT_TABLE
#define PLATFORM_STACK_SIZE 0x800
#elif IMAGE_BL1
#define PLATFORM_STACK_SIZE 0x440
#elif IMAGE_BL2
#define PLATFORM_STACK_SIZE 0x400
#elif IMAGE_BL31
#define PLATFORM_STACK_SIZE 0x800
#elif IMAGE_BL32
#define PLATFORM_STACK_SIZE 0x440
#endif
#define FIRMWARE_WELCOME_STR "Booting Trusted Firmware\n"
#define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL2
#define PLATFORM_SYSTEM_COUNT 1
#define PLATFORM_CLUSTER_COUNT 2
#define PLATFORM_CLUSTER0_CORE_COUNT 4
#define PLATFORM_CLUSTER1_CORE_COUNT 2
#define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
PLATFORM_CLUSTER0_CORE_COUNT)
#define PLATFORM_MAX_CPUS_PER_CLUSTER 4
#define PLATFORM_NUM_AFFS (PLATFORM_SYSTEM_COUNT + \
PLATFORM_CLUSTER_COUNT + \
PLATFORM_CORE_COUNT)
#define PLAT_MAX_PWR_LVL MPIDR_AFFLVL2
/*
* This macro defines the deepest retention state possible. A higher state
* id will represent an invalid or a power down state.
*/
#define PLAT_MAX_RET_STATE 1
/*
* This macro defines the deepest power down states possible. Any state ID
* higher than this is invalid.
*/
#define PLAT_MAX_OFF_STATE 2
/*******************************************************************************
* Platform memory map related constants
******************************************************************************/
/* TF txet, ro, rw, Size: 512KB */
#define TZRAM_BASE (0x0)
#define TZRAM_SIZE (0x80000)
/*******************************************************************************
* BL31 specific defines.
******************************************************************************/
/*
* Put BL3-1 at the top of the Trusted RAM
*/
#define BL31_BASE (TZRAM_BASE + 0x8000)
#define BL31_LIMIT (TZRAM_BASE + TZRAM_SIZE)
/*******************************************************************************
* Platform specific page table and MMU setup constants
******************************************************************************/
#define ADDR_SPACE_SIZE (1ull << 32)
#define MAX_XLAT_TABLES 20
#define MAX_MMAP_REGIONS 16
/*******************************************************************************
* Declarations and constants to access the mailboxes safely. Each mailbox is
* aligned on the biggest cache line size in the platform. This is known only
* to the platform as it might have a combination of integrated and external
* caches. Such alignment ensures that two maiboxes do not sit on the same cache
* line at any cache level. They could belong to different cpus/clusters &
* get written while being protected by different locks causing corruption of
* a valid mailbox address.
******************************************************************************/
#define CACHE_WRITEBACK_SHIFT 6
#define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
/*
* Define GICD and GICC and GICR base
*/
#define PLAT_RK_GICD_BASE BASE_GICD_BASE
#define PLAT_RK_GICR_BASE BASE_GICR_BASE
#define PLAT_RK_GICC_BASE 0
/*
* Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
* terminology. On a GICv2 system or mode, the lists will be merged and treated
* as Group 0 interrupts.
*/
#define PLAT_RK_G1S_IRQS RK3399_G1S_IRQS
#define PLAT_RK_G0_IRQS RK3399_G0_IRQS
#define PLAT_RK_UART_BASE RK3399_UART2_BASE
#define PLAT_RK_UART_CLOCK RK3399_UART_CLOCK
#define PLAT_RK_UART_BAUDRATE RK3399_BAUDRATE
#define PLAT_RK_CCI_BASE CCI500_BASE
#define PLAT_RK_PRIMARY_CPU 0x0
#define RK_PLAT_AARCH_CFG RK_PLAT_CFG1
#endif
/* __PLATFORM_DEF_H__ */
plat/rockchip/rk3399/platform.mk
0 → 100644
View file @
61dbb028
#
# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of ARM nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
RK_PLAT
:=
plat/rockchip
RK_PLAT_SOC
:=
${RK_PLAT}
/
${PLAT}
RK_PLAT_COMMON
:=
${RK_PLAT}
/common
PLAT_INCLUDES
:=
-I
${RK_PLAT_COMMON}
/
\
-I
${RK_PLAT_COMMON}
/include/
\
-I
${RK_PLAT_COMMON}
/pmusram
\
-I
${RK_PLAT_COMMON}
/drivers/pmu/
\
-I
${RK_PLAT_SOC}
/
\
-I
${RK_PLAT_SOC}
/drivers/pmu/
\
-I
${RK_PLAT_SOC}
/drivers/soc/
\
-I
${RK_PLAT_SOC}
/include/
\
RK_GIC_SOURCES
:=
drivers/arm/gic/common/gic_common.c
\
drivers/arm/gic/v3/gicv3_main.c
\
drivers/arm/gic/v3/gicv3_helpers.c
\
plat/common/plat_gicv3.c
\
${RK_PLAT}
/common/rockchip_gicv3.c
PLAT_BL_COMMON_SOURCES
:=
lib/aarch64/xlat_tables.c
\
plat/common/aarch64/plat_common.c
\
plat/common/aarch64/plat_psci_common.c
BL31_SOURCES
+=
${RK_GIC_SOURCES}
\
drivers/arm/cci/cci.c
\
drivers/console/console.S
\
drivers/ti/uart/16550_console.S
\
drivers/delay_timer/delay_timer.c
\
lib/cpus/aarch64/cortex_a53.S
\
lib/cpus/aarch64/cortex_a72.S
\
plat/common/aarch64/platform_mp_stack.S
\
${RK_PLAT_COMMON}
/aarch64/plat_helpers.S
\
${RK_PLAT_COMMON}
/bl31_plat_setup.c
\
${RK_PLAT_COMMON}
/pmusram/pmu_sram_cpus_on.S
\
${RK_PLAT_COMMON}
/pmusram/pmu_sram.c
\
${RK_PLAT_COMMON}
/plat_delay_timer.c
\
${RK_PLAT_COMMON}
/plat_pm.c
\
${RK_PLAT_COMMON}
/plat_topology.c
\
${RK_PLAT_COMMON}
/aarch64/platform_common.c
\
${RK_PLAT_SOC}
/drivers/pmu/pmu.c
\
${RK_PLAT_SOC}
/drivers/soc/soc.c
ENABLE_PLAT_COMPAT
:=
0
plat/rockchip/rk3399/rk3399_def.h
0 → 100644
View file @
61dbb028
/*
* Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of ARM nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PLAT_DEF_H__
#define __PLAT_DEF_H__
#define RK3399_PRIMARY_CPU 0x0
/* Special value used to verify platform parameters from BL2 to BL3-1 */
#define RK_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL
#define SIZE_K(n) ((n) * 1024)
#define SIZE_M(n) ((n) * 1024 * 1024)
#define CCI500_BASE 0xffb00000
#define CCI500_SIZE SIZE_M(1)
#define GIC500_BASE 0xfee00000
#define GIC500_SIZE SIZE_M(2)
#define STIME_BASE 0xff860000
#define STIME_SIZE SIZE_K(64)
#define CRUS_BASE 0xff750000
#define CRUS_SIZE SIZE_K(128)
#define SGRF_BASE 0xff330000
#define SGRF_SIZE SIZE_K(64)
#define PMU_BASE 0xff310000
#define PMU_SIZE SIZE_K(64)
#define PMUSRAM_BASE 0xff3b0000
#define PMUSRAM_SIZE SIZE_K(64)
#define PMUSRAM_RSIZE SIZE_K(8)
/*
* include i2c pmu/audio, pwm0-3 rkpwm0-3 uart_dbg,mailbox scr
* 0xff650000 -0xff6c0000
*/
#define PD_BUS0_BASE 0xff650000
#define PD_BUS0_SIZE 0x70000
#define PMUCRU_BASE 0xff750000
#define CRU_BASE 0xff760000
#define COLD_BOOT_BASE 0xffff0000
/**************************************************************************
* UART related constants
**************************************************************************/
#define RK3399_UART2_BASE (0xff1a0000)
#define RK3399_UART2_SIZE SIZE_K(64)
#define RK3399_BAUDRATE (1500000)
#define RK3399_UART_CLOCK (24000000)
/******************************************************************************
* System counter frequency related constants
******************************************************************************/
#define SYS_COUNTER_FREQ_IN_TICKS 24000000
#define SYS_COUNTER_FREQ_IN_MHZ 24
/* Base rockchip_platform compatible GIC memory map */
#define BASE_GICD_BASE (GIC500_BASE)
#define BASE_GICR_BASE (GIC500_BASE + SIZE_M(1))
/*****************************************************************************
* CCI-400 related constants
******************************************************************************/
#define PLAT_RK_CCI_CLUSTER0_SL_IFACE_IX 0
#define PLAT_RK_CCI_CLUSTER1_SL_IFACE_IX 1
/******************************************************************************
* cpu up status
******************************************************************************/
#define PMU_CPU_HOTPLUG 0xdeadbeaf
#define PMU_CPU_AUTO_PWRDN 0xabcdef12
/******************************************************************************
* sgi, ppi
******************************************************************************/
#define ARM_IRQ_SEC_PHY_TIMER 29
#define ARM_IRQ_SEC_SGI_0 8
#define ARM_IRQ_SEC_SGI_1 9
#define ARM_IRQ_SEC_SGI_2 10
#define ARM_IRQ_SEC_SGI_3 11
#define ARM_IRQ_SEC_SGI_4 12
#define ARM_IRQ_SEC_SGI_5 13
#define ARM_IRQ_SEC_SGI_6 14
#define ARM_IRQ_SEC_SGI_7 15
/*
* Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
* terminology. On a GICv2 system or mode, the lists will be merged and treated
* as Group 0 interrupts.
*/
#define RK3399_G1S_IRQS ARM_IRQ_SEC_PHY_TIMER
#define RK3399_G0_IRQS ARM_IRQ_SEC_SGI_6
#endif
/* __PLAT_DEF_H__ */
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment