1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Always ON (AON) register interface between bootloader and Linux 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright © 2014-2017 Broadcom 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef __BRCMSTB_AON_DEFS_H__ 9*4882a593Smuzhiyun #define __BRCMSTB_AON_DEFS_H__ 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/compiler.h> 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun /* Magic number in upper 16-bits */ 14*4882a593Smuzhiyun #define BRCMSTB_S3_MAGIC_MASK 0xffff0000 15*4882a593Smuzhiyun #define BRCMSTB_S3_MAGIC_SHORT 0x5AFE0000 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun enum { 18*4882a593Smuzhiyun /* Restore random key for AES memory verification (off = fixed key) */ 19*4882a593Smuzhiyun S3_FLAG_LOAD_RANDKEY = (1 << 0), 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun /* Scratch buffer page table is present */ 22*4882a593Smuzhiyun S3_FLAG_SCRATCH_BUFFER_TABLE = (1 << 1), 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun /* Skip all memory verification */ 25*4882a593Smuzhiyun S3_FLAG_NO_MEM_VERIFY = (1 << 2), 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun /* 28*4882a593Smuzhiyun * Modification of this bit reserved for bootloader only. 29*4882a593Smuzhiyun * 1=PSCI started Linux, 0=Direct jump to Linux. 30*4882a593Smuzhiyun */ 31*4882a593Smuzhiyun S3_FLAG_PSCI_BOOT = (1 << 3), 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* 34*4882a593Smuzhiyun * Modification of this bit reserved for bootloader only. 35*4882a593Smuzhiyun * 1=64 bit boot, 0=32 bit boot. 36*4882a593Smuzhiyun */ 37*4882a593Smuzhiyun S3_FLAG_BOOTED64 = (1 << 4), 38*4882a593Smuzhiyun }; 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun #define BRCMSTB_HASH_LEN (128 / 8) /* 128-bit hash */ 41*4882a593Smuzhiyun 42*4882a593Smuzhiyun #define AON_REG_MAGIC_FLAGS 0x00 43*4882a593Smuzhiyun #define AON_REG_CONTROL_LOW 0x04 44*4882a593Smuzhiyun #define AON_REG_CONTROL_HIGH 0x08 45*4882a593Smuzhiyun #define AON_REG_S3_HASH 0x0c /* hash of S3 params */ 46*4882a593Smuzhiyun #define AON_REG_CONTROL_HASH_LEN 0x1c 47*4882a593Smuzhiyun #define AON_REG_PANIC 0x20 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun #define BRCMSTB_S3_MAGIC 0x5AFEB007 50*4882a593Smuzhiyun #define BRCMSTB_PANIC_MAGIC 0x512E115E 51*4882a593Smuzhiyun #define BOOTLOADER_SCRATCH_SIZE 64 52*4882a593Smuzhiyun #define BRCMSTB_DTU_STATE_MAP_ENTRIES (8*1024) 53*4882a593Smuzhiyun #define BRCMSTB_DTU_CONFIG_ENTRIES (512) 54*4882a593Smuzhiyun #define BRCMSTB_DTU_COUNT (2) 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun #define IMAGE_DESCRIPTORS_BUFSIZE (2 * 1024) 57*4882a593Smuzhiyun #define S3_BOOTLOADER_RESERVED (S3_FLAG_PSCI_BOOT | S3_FLAG_BOOTED64) 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun struct brcmstb_bootloader_dtu_table { 60*4882a593Smuzhiyun uint32_t dtu_state_map[BRCMSTB_DTU_STATE_MAP_ENTRIES]; 61*4882a593Smuzhiyun uint32_t dtu_config[BRCMSTB_DTU_CONFIG_ENTRIES]; 62*4882a593Smuzhiyun }; 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun /* 65*4882a593Smuzhiyun * Bootloader utilizes a custom parameter block left in DRAM for handling S3 66*4882a593Smuzhiyun * warm resume 67*4882a593Smuzhiyun */ 68*4882a593Smuzhiyun struct brcmstb_s3_params { 69*4882a593Smuzhiyun /* scratch memory for bootloader */ 70*4882a593Smuzhiyun uint8_t scratch[BOOTLOADER_SCRATCH_SIZE]; 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun uint32_t magic; /* BRCMSTB_S3_MAGIC */ 73*4882a593Smuzhiyun uint64_t reentry; /* PA */ 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* descriptors */ 76*4882a593Smuzhiyun uint32_t hash[BRCMSTB_HASH_LEN / 4]; 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun /* 79*4882a593Smuzhiyun * If 0, then ignore this parameter (there is only one set of 80*4882a593Smuzhiyun * descriptors) 81*4882a593Smuzhiyun * 82*4882a593Smuzhiyun * If non-0, then a second set of descriptors is stored at: 83*4882a593Smuzhiyun * 84*4882a593Smuzhiyun * descriptors + desc_offset_2 85*4882a593Smuzhiyun * 86*4882a593Smuzhiyun * The MAC result of both descriptors is XOR'd and stored in @hash 87*4882a593Smuzhiyun */ 88*4882a593Smuzhiyun uint32_t desc_offset_2; 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun /* 91*4882a593Smuzhiyun * (Physical) address of a brcmstb_bootloader_scratch_table, for 92*4882a593Smuzhiyun * providing a large DRAM buffer to the bootloader 93*4882a593Smuzhiyun */ 94*4882a593Smuzhiyun uint64_t buffer_table; 95*4882a593Smuzhiyun 96*4882a593Smuzhiyun uint32_t spare[70]; 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun uint8_t descriptors[IMAGE_DESCRIPTORS_BUFSIZE]; 99*4882a593Smuzhiyun /* 100*4882a593Smuzhiyun * Must be last member of struct. See brcmstb_pm_s3_finish() for reason. 101*4882a593Smuzhiyun */ 102*4882a593Smuzhiyun struct brcmstb_bootloader_dtu_table dtu[BRCMSTB_DTU_COUNT]; 103*4882a593Smuzhiyun } __packed; 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun #endif /* __BRCMSTB_AON_DEFS_H__ */ 106