xref: /rk3399_ARM-atf/plat/nvidia/tegra/include/drivers/flowctrl.h (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
108438e24SVarun Wadekar /*
250e91633SAnthony Zhou  * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
308438e24SVarun Wadekar  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
508438e24SVarun Wadekar  */
608438e24SVarun Wadekar 
7c3cf06f1SAntonio Nino Diaz #ifndef FLOWCTRL_H
8c3cf06f1SAntonio Nino Diaz #define FLOWCTRL_H
908438e24SVarun Wadekar 
10*09d40e0eSAntonio Nino Diaz #include <lib/mmio.h>
11*09d40e0eSAntonio Nino Diaz 
1208438e24SVarun Wadekar #include <tegra_def.h>
1308438e24SVarun Wadekar 
1450e91633SAnthony Zhou #define FLOWCTRL_HALT_CPU0_EVENTS	0x0U
1550e91633SAnthony Zhou #define  FLOWCTRL_WAITEVENT		(2U << 29)
1650e91633SAnthony Zhou #define  FLOWCTRL_WAIT_FOR_INTERRUPT	(4U << 29)
1750e91633SAnthony Zhou #define  FLOWCTRL_JTAG_RESUME		(1U << 28)
1850e91633SAnthony Zhou #define  FLOWCTRL_HALT_SCLK		(1U << 27)
1950e91633SAnthony Zhou #define  FLOWCTRL_HALT_LIC_IRQ		(1U << 11)
2050e91633SAnthony Zhou #define  FLOWCTRL_HALT_LIC_FIQ		(1U << 10)
2150e91633SAnthony Zhou #define  FLOWCTRL_HALT_GIC_IRQ		(1U << 9)
2250e91633SAnthony Zhou #define  FLOWCTRL_HALT_GIC_FIQ		(1U << 8)
2350e91633SAnthony Zhou #define FLOWCTRL_HALT_BPMP_EVENTS	0x4U
2450e91633SAnthony Zhou #define FLOWCTRL_CPU0_CSR		0x8U
2550e91633SAnthony Zhou #define  FLOW_CTRL_CSR_PWR_OFF_STS	(1U << 16)
2650e91633SAnthony Zhou #define  FLOWCTRL_CSR_INTR_FLAG		(1U << 15)
2750e91633SAnthony Zhou #define  FLOWCTRL_CSR_EVENT_FLAG	(1U << 14)
2850e91633SAnthony Zhou #define  FLOWCTRL_CSR_IMMEDIATE_WAKE	(1U << 3)
2950e91633SAnthony Zhou #define  FLOWCTRL_CSR_ENABLE		(1U << 0)
3050e91633SAnthony Zhou #define FLOWCTRL_HALT_CPU1_EVENTS	0x14U
3150e91633SAnthony Zhou #define FLOWCTRL_CPU1_CSR		0x18U
3250e91633SAnthony Zhou #define FLOWCTRL_CC4_CORE0_CTRL		0x6cU
3350e91633SAnthony Zhou #define FLOWCTRL_WAIT_WFI_BITMAP	0x100U
3450e91633SAnthony Zhou #define FLOWCTRL_L2_FLUSH_CONTROL	0x94U
3550e91633SAnthony Zhou #define FLOWCTRL_BPMP_CLUSTER_CONTROL	0x98U
3650e91633SAnthony Zhou #define  FLOWCTRL_BPMP_CLUSTER_PWRON_LOCK	(1U << 2)
3708438e24SVarun Wadekar 
3850e91633SAnthony Zhou #define FLOWCTRL_ENABLE_EXT		12U
3950e91633SAnthony Zhou #define FLOWCTRL_ENABLE_EXT_MASK	3U
4050e91633SAnthony Zhou #define FLOWCTRL_PG_CPU_NONCPU		0x1U
4150e91633SAnthony Zhou #define FLOWCTRL_TURNOFF_CPURAIL	0x2U
4208438e24SVarun Wadekar 
4308438e24SVarun Wadekar static inline uint32_t tegra_fc_read_32(uint32_t off)
4408438e24SVarun Wadekar {
4508438e24SVarun Wadekar 	return mmio_read_32(TEGRA_FLOWCTRL_BASE + off);
4608438e24SVarun Wadekar }
4708438e24SVarun Wadekar 
4808438e24SVarun Wadekar static inline void tegra_fc_write_32(uint32_t off, uint32_t val)
4908438e24SVarun Wadekar {
5008438e24SVarun Wadekar 	mmio_write_32(TEGRA_FLOWCTRL_BASE + off, val);
5108438e24SVarun Wadekar }
5208438e24SVarun Wadekar 
5308438e24SVarun Wadekar void tegra_fc_cluster_idle(uint32_t midr);
54864ab0fdSVarun Wadekar void tegra_fc_cpu_powerdn(uint32_t mpidr);
5508438e24SVarun Wadekar void tegra_fc_cluster_powerdn(uint32_t midr);
5608438e24SVarun Wadekar void tegra_fc_soc_powerdn(uint32_t midr);
5708438e24SVarun Wadekar void tegra_fc_cpu_on(int cpu);
5808438e24SVarun Wadekar void tegra_fc_cpu_off(int cpu);
5908438e24SVarun Wadekar void tegra_fc_lock_active_cluster(void);
6008438e24SVarun Wadekar void tegra_fc_reset_bpmp(void);
6108438e24SVarun Wadekar 
62c3cf06f1SAntonio Nino Diaz #endif /* FLOWCTRL_H */
63