Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 1 | /* |
Jacky Bai | a940799 | 2020-01-08 16:56:01 +0800 | [diff] [blame] | 2 | * Copyright (c) 2018-2023, ARM Limited and Contributors. All rights reserved. |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef IMX8M_GPC_H |
| 8 | #define IMX8M_GPC_H |
| 9 | |
Jacky Bai | d3d7972 | 2020-06-03 14:24:38 +0800 | [diff] [blame] | 10 | #include <gpc_reg.h> |
Jacky Bai | 9bd2f84 | 2019-11-28 13:16:33 +0800 | [diff] [blame] | 11 | |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 12 | /* helper macro */ |
| 13 | #define A53_LPM_MASK U(0xF) |
| 14 | #define A53_LPM_WAIT U(0x5) |
| 15 | #define A53_LPM_STOP U(0xA) |
Jacky Bai | f7dc401 | 2019-03-06 16:58:18 +0800 | [diff] [blame] | 16 | #define LPM_MODE(local_state) ((local_state) == PLAT_WAIT_RET_STATE ? A53_LPM_WAIT : A53_LPM_STOP) |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 17 | |
| 18 | #define DSM_MODE_MASK BIT(31) |
Jacky Bai | d3d7972 | 2020-06-03 14:24:38 +0800 | [diff] [blame] | 19 | #define CORE_WKUP_FROM_GIC (IRQ_SRC_C0 | IRQ_SRC_C1 | IRQ_SRC_C2 | IRQ_SRC_C3) |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 20 | #define A53_CORE_WUP_SRC(core_id) (1 << ((core_id) < 2 ? 28 + (core_id) : 22 + (core_id) - 2)) |
| 21 | #define COREx_PGC_PCR(core_id) (0x800 + (core_id) * 0x40) |
| 22 | #define COREx_WFI_PDN(core_id) (1 << ((core_id) < 2 ? (core_id) * 2 : ((core_id) - 2) * 2 + 16)) |
| 23 | #define COREx_IRQ_WUP(core_id) ((core_id) < 2 ? (1 << ((core_id) * 2 + 8)) : (1 << ((core_id) * 2 + 20))) |
| 24 | #define COREx_LPM_PUP(core_id) ((core_id) < 2 ? (1 << ((core_id) * 2 + 9)) : (1 << ((core_id) * 2 + 21))) |
| 25 | #define SLTx_CFG(n) ((SLT0_CFG + ((n) * 4))) |
| 26 | #define SLT_COREx_PUP(core_id) (0x2 << ((core_id) * 2)) |
Jacky Bai | 4e44165 | 2020-01-10 17:46:31 +0800 | [diff] [blame] | 27 | #define SLT_COREx_PUP_ACK(core_id) ((core_id) < 2 ? (1 << ((core_id) + 16)) : (1 << ((core_id) + 27))) |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 28 | |
Jacky Bai | f7dc401 | 2019-03-06 16:58:18 +0800 | [diff] [blame] | 29 | #define IMR_MASK_ALL 0xffffffff |
| 30 | |
Jacky Bai | 07ed02c | 2020-06-03 14:28:45 +0800 | [diff] [blame] | 31 | #define IMX_PD_DOMAIN(name, on) \ |
| 32 | { \ |
| 33 | .pwr_req = name##_PWR_REQ, \ |
| 34 | .pgc_offset = name##_PGC, \ |
| 35 | .need_sync = false, \ |
Jacky Bai | e71da9f | 2020-08-11 15:56:29 +0800 | [diff] [blame] | 36 | .always_on = (on), \ |
Jacky Bai | 07ed02c | 2020-06-03 14:28:45 +0800 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | #define IMX_MIX_DOMAIN(name, on) \ |
| 40 | { \ |
| 41 | .pwr_req = name##_PWR_REQ, \ |
| 42 | .pgc_offset = name##_PGC, \ |
| 43 | .adb400_sync = name##_ADB400_SYNC, \ |
| 44 | .adb400_ack = name##_ADB400_ACK, \ |
| 45 | .need_sync = true, \ |
Jacky Bai | e71da9f | 2020-08-11 15:56:29 +0800 | [diff] [blame] | 46 | .always_on = (on), \ |
Jacky Bai | 07ed02c | 2020-06-03 14:28:45 +0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | struct imx_pwr_domain { |
| 50 | uint32_t pwr_req; |
| 51 | uint32_t adb400_sync; |
| 52 | uint32_t adb400_ack; |
| 53 | uint32_t pgc_offset; |
| 54 | bool need_sync; |
| 55 | bool always_on; |
| 56 | }; |
| 57 | |
Jacky Bai | 48c9dcd | 2020-01-10 15:31:52 +0800 | [diff] [blame] | 58 | struct pll_override { |
| 59 | uint32_t reg; |
| 60 | uint32_t override_mask; |
| 61 | }; |
| 62 | |
Jacky Bai | 3710fc7 | 2020-01-07 11:05:22 +0800 | [diff] [blame] | 63 | DECLARE_BAKERY_LOCK(gpc_lock); |
| 64 | |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 65 | /* function declare */ |
| 66 | void imx_gpc_init(void); |
| 67 | void imx_set_cpu_secure_entry(unsigned int core_index, uintptr_t sec_entrypoint); |
| 68 | void imx_set_cpu_pwr_off(unsigned int core_index); |
| 69 | void imx_set_cpu_pwr_on(unsigned int core_index); |
| 70 | void imx_set_cpu_lpm(unsigned int core_index, bool pdn); |
| 71 | void imx_set_cluster_standby(bool retention); |
| 72 | void imx_set_cluster_powerdown(unsigned int last_core, uint8_t power_state); |
Jacky Bai | f7dc401 | 2019-03-06 16:58:18 +0800 | [diff] [blame] | 73 | void imx_noc_slot_config(bool pdn); |
| 74 | void imx_set_sys_wakeup(unsigned int last_core, bool pdn); |
| 75 | void imx_set_sys_lpm(unsigned last_core, bool retention); |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 76 | void imx_set_rbc_count(void); |
| 77 | void imx_clear_rbc_count(void); |
Jacky Bai | 11261fa | 2019-12-09 13:27:39 +0800 | [diff] [blame] | 78 | void imx_anamix_override(bool enter); |
Jacky Bai | 31f0232 | 2019-12-11 16:26:59 +0800 | [diff] [blame] | 79 | void imx_gpc_pm_domain_enable(uint32_t domain_id, bool on); |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 80 | |
Jacky Bai | a940799 | 2020-01-08 16:56:01 +0800 | [diff] [blame] | 81 | #if defined(PLAT_imx8mq) |
| 82 | void imx_gpc_set_a53_core_awake(uint32_t core_id); |
Jacky Bai | a51b11a | 2020-01-14 14:19:05 +0800 | [diff] [blame] | 83 | void imx_gpc_core_wake(uint32_t cpumask); |
Jacky Bai | a940799 | 2020-01-08 16:56:01 +0800 | [diff] [blame] | 84 | #endif |
| 85 | |
Bai Ping | 06e325e | 2018-10-28 00:12:34 +0800 | [diff] [blame] | 86 | #endif /*IMX8M_GPC_H */ |