1*91f16700Schasinglulu /* 2*91f16700Schasinglulu * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. 3*91f16700Schasinglulu * 4*91f16700Schasinglulu * SPDX-License-Identifier: BSD-3-Clause 5*91f16700Schasinglulu */ 6*91f16700Schasinglulu 7*91f16700Schasinglulu #ifndef BPMP_H 8*91f16700Schasinglulu #define BPMP_H 9*91f16700Schasinglulu 10*91f16700Schasinglulu #include <stdint.h> 11*91f16700Schasinglulu 12*91f16700Schasinglulu /* macro to enable clock to the Atomics block */ 13*91f16700Schasinglulu #define CAR_ENABLE_ATOMICS (1U << 16) 14*91f16700Schasinglulu 15*91f16700Schasinglulu /* command to get the channel base addresses from bpmp */ 16*91f16700Schasinglulu #define ATOMIC_CMD_GET 4U 17*91f16700Schasinglulu 18*91f16700Schasinglulu /* Hardware IRQ # used to signal bpmp of an incoming command */ 19*91f16700Schasinglulu #define INT_SHR_SEM_OUTBOX_FULL 6U 20*91f16700Schasinglulu 21*91f16700Schasinglulu /* macros to decode the bpmp's state */ 22*91f16700Schasinglulu #define CH_MASK(ch) ((uint32_t)0x3 << ((ch) * 2U)) 23*91f16700Schasinglulu #define MA_FREE(ch) ((uint32_t)0x2 << ((ch) * 2U)) 24*91f16700Schasinglulu #define MA_ACKD(ch) ((uint32_t)0x3 << ((ch) * 2U)) 25*91f16700Schasinglulu 26*91f16700Schasinglulu /* response from bpmp to indicate it has powered up */ 27*91f16700Schasinglulu #define SIGN_OF_LIFE 0xAAAAAAAAU 28*91f16700Schasinglulu 29*91f16700Schasinglulu /* flags to indicate bpmp driver's state */ 30*91f16700Schasinglulu #define BPMP_NOT_PRESENT 0xF00DBEEFU 31*91f16700Schasinglulu #define BPMP_INIT_COMPLETE 0xBEEFF00DU 32*91f16700Schasinglulu #define BPMP_INIT_PENDING 0xDEADBEEFU 33*91f16700Schasinglulu #define BPMP_SUSPEND_ENTRY 0xF00DCAFEU 34*91f16700Schasinglulu 35*91f16700Schasinglulu /* requests serviced by the bpmp */ 36*91f16700Schasinglulu #define MRQ_PING 0 37*91f16700Schasinglulu #define MRQ_QUERY_TAG 1 38*91f16700Schasinglulu #define MRQ_DO_IDLE 2 39*91f16700Schasinglulu #define MRQ_TOLERATE_IDLE 3 40*91f16700Schasinglulu #define MRQ_MODULE_LOAD 4 41*91f16700Schasinglulu #define MRQ_MODULE_UNLOAD 5 42*91f16700Schasinglulu #define MRQ_SWITCH_CLUSTER 6 43*91f16700Schasinglulu #define MRQ_TRACE_MODIFY 7 44*91f16700Schasinglulu #define MRQ_WRITE_TRACE 8 45*91f16700Schasinglulu #define MRQ_THREADED_PING 9 46*91f16700Schasinglulu #define MRQ_CPUIDLE_USAGE 10 47*91f16700Schasinglulu #define MRQ_MODULE_MAIL 11 48*91f16700Schasinglulu #define MRQ_SCX_ENABLE 12 49*91f16700Schasinglulu #define MRQ_BPMPIDLE_USAGE 14 50*91f16700Schasinglulu #define MRQ_HEAP_USAGE 15 51*91f16700Schasinglulu #define MRQ_SCLK_SKIP_SET_RATE 16 52*91f16700Schasinglulu #define MRQ_ENABLE_SUSPEND 17 53*91f16700Schasinglulu #define MRQ_PASR_MASK 18 54*91f16700Schasinglulu #define MRQ_DEBUGFS 19 55*91f16700Schasinglulu #define MRQ_THERMAL 27 56*91f16700Schasinglulu 57*91f16700Schasinglulu /* Tegra PM states as known to BPMP */ 58*91f16700Schasinglulu #define TEGRA_PM_CC1 9 59*91f16700Schasinglulu #define TEGRA_PM_CC4 12 60*91f16700Schasinglulu #define TEGRA_PM_CC6 14 61*91f16700Schasinglulu #define TEGRA_PM_CC7 15 62*91f16700Schasinglulu #define TEGRA_PM_SC1 17 63*91f16700Schasinglulu #define TEGRA_PM_SC2 18 64*91f16700Schasinglulu #define TEGRA_PM_SC3 19 65*91f16700Schasinglulu #define TEGRA_PM_SC4 20 66*91f16700Schasinglulu #define TEGRA_PM_SC7 23 67*91f16700Schasinglulu 68*91f16700Schasinglulu /* flag to indicate if entry into a CCx power state is allowed */ 69*91f16700Schasinglulu #define BPMP_CCx_ALLOWED 0U 70*91f16700Schasinglulu 71*91f16700Schasinglulu /* number of communication channels to interact with the bpmp */ 72*91f16700Schasinglulu #define NR_CHANNELS 4U 73*91f16700Schasinglulu 74*91f16700Schasinglulu /* flag to ask bpmp to acknowledge command packet */ 75*91f16700Schasinglulu #define NO_ACK (0U << 0U) 76*91f16700Schasinglulu #define DO_ACK (1U << 0U) 77*91f16700Schasinglulu 78*91f16700Schasinglulu /* size of the command/response data */ 79*91f16700Schasinglulu #define MSG_DATA_MAX_SZ 120U 80*91f16700Schasinglulu 81*91f16700Schasinglulu /** 82*91f16700Schasinglulu * command/response packet to/from the bpmp 83*91f16700Schasinglulu * 84*91f16700Schasinglulu * command 85*91f16700Schasinglulu * ------- 86*91f16700Schasinglulu * code: MRQ_* command 87*91f16700Schasinglulu * flags: DO_ACK or NO_ACK 88*91f16700Schasinglulu * data: 89*91f16700Schasinglulu * [0] = cpu # 90*91f16700Schasinglulu * [1] = cluster power state (TEGRA_PM_CCx) 91*91f16700Schasinglulu * [2] = system power state (TEGRA_PM_SCx) 92*91f16700Schasinglulu * 93*91f16700Schasinglulu * response 94*91f16700Schasinglulu * --------- 95*91f16700Schasinglulu * code: error code 96*91f16700Schasinglulu * flags: not used 97*91f16700Schasinglulu * data: 98*91f16700Schasinglulu * [0-3] = response value 99*91f16700Schasinglulu */ 100*91f16700Schasinglulu typedef struct mb_data { 101*91f16700Schasinglulu int32_t code; 102*91f16700Schasinglulu uint32_t flags; 103*91f16700Schasinglulu uint8_t data[MSG_DATA_MAX_SZ]; 104*91f16700Schasinglulu } mb_data_t; 105*91f16700Schasinglulu 106*91f16700Schasinglulu /** 107*91f16700Schasinglulu * Function to initialise the interface with the bpmp 108*91f16700Schasinglulu */ 109*91f16700Schasinglulu int tegra_bpmp_init(void); 110*91f16700Schasinglulu 111*91f16700Schasinglulu /** 112*91f16700Schasinglulu * Function to suspend the interface with the bpmp 113*91f16700Schasinglulu */ 114*91f16700Schasinglulu void tegra_bpmp_suspend(void); 115*91f16700Schasinglulu 116*91f16700Schasinglulu /** 117*91f16700Schasinglulu * Function to resume the interface with the bpmp 118*91f16700Schasinglulu */ 119*91f16700Schasinglulu void tegra_bpmp_resume(void); 120*91f16700Schasinglulu 121*91f16700Schasinglulu /** 122*91f16700Schasinglulu * Handler to send a MRQ_* command to the bpmp 123*91f16700Schasinglulu */ 124*91f16700Schasinglulu int32_t tegra_bpmp_send_receive_atomic(int mrq, const void *ob_data, int ob_sz, 125*91f16700Schasinglulu void *ib_data, int ib_sz); 126*91f16700Schasinglulu 127*91f16700Schasinglulu #endif /* BPMP_H */ 128