Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Always ON (AON) register interface between bootloader and Linux
0004  *
0005  * Copyright © 2014-2017 Broadcom
0006  */
0007 
0008 #ifndef __BRCMSTB_AON_DEFS_H__
0009 #define __BRCMSTB_AON_DEFS_H__
0010 
0011 #include <linux/compiler.h>
0012 
0013 /* Magic number in upper 16-bits */
0014 #define BRCMSTB_S3_MAGIC_MASK                   0xffff0000
0015 #define BRCMSTB_S3_MAGIC_SHORT                  0x5AFE0000
0016 
0017 enum {
0018     /* Restore random key for AES memory verification (off = fixed key) */
0019     S3_FLAG_LOAD_RANDKEY        = (1 << 0),
0020 
0021     /* Scratch buffer page table is present */
0022     S3_FLAG_SCRATCH_BUFFER_TABLE    = (1 << 1),
0023 
0024     /* Skip all memory verification */
0025     S3_FLAG_NO_MEM_VERIFY       = (1 << 2),
0026 
0027     /*
0028      * Modification of this bit reserved for bootloader only.
0029      * 1=PSCI started Linux, 0=Direct jump to Linux.
0030      */
0031     S3_FLAG_PSCI_BOOT       = (1 << 3),
0032 
0033     /*
0034      * Modification of this bit reserved for bootloader only.
0035      * 1=64 bit boot, 0=32 bit boot.
0036      */
0037     S3_FLAG_BOOTED64        = (1 << 4),
0038 };
0039 
0040 #define BRCMSTB_HASH_LEN            (128 / 8) /* 128-bit hash */
0041 
0042 #define AON_REG_MAGIC_FLAGS         0x00
0043 #define AON_REG_CONTROL_LOW         0x04
0044 #define AON_REG_CONTROL_HIGH            0x08
0045 #define AON_REG_S3_HASH             0x0c /* hash of S3 params */
0046 #define AON_REG_CONTROL_HASH_LEN        0x1c
0047 #define AON_REG_PANIC               0x20
0048 
0049 #define BRCMSTB_S3_MAGIC        0x5AFEB007
0050 #define BRCMSTB_PANIC_MAGIC     0x512E115E
0051 #define BOOTLOADER_SCRATCH_SIZE     64
0052 #define BRCMSTB_DTU_STATE_MAP_ENTRIES   (8*1024)
0053 #define BRCMSTB_DTU_CONFIG_ENTRIES  (512)
0054 #define BRCMSTB_DTU_COUNT       (2)
0055 
0056 #define IMAGE_DESCRIPTORS_BUFSIZE   (2 * 1024)
0057 #define S3_BOOTLOADER_RESERVED      (S3_FLAG_PSCI_BOOT | S3_FLAG_BOOTED64)
0058 
0059 struct brcmstb_bootloader_dtu_table {
0060     uint32_t    dtu_state_map[BRCMSTB_DTU_STATE_MAP_ENTRIES];
0061     uint32_t    dtu_config[BRCMSTB_DTU_CONFIG_ENTRIES];
0062 };
0063 
0064 /*
0065  * Bootloader utilizes a custom parameter block left in DRAM for handling S3
0066  * warm resume
0067  */
0068 struct brcmstb_s3_params {
0069     /* scratch memory for bootloader */
0070     uint8_t scratch[BOOTLOADER_SCRATCH_SIZE];
0071 
0072     uint32_t magic; /* BRCMSTB_S3_MAGIC */
0073     uint64_t reentry; /* PA */
0074 
0075     /* descriptors */
0076     uint32_t hash[BRCMSTB_HASH_LEN / 4];
0077 
0078     /*
0079      * If 0, then ignore this parameter (there is only one set of
0080      *   descriptors)
0081      *
0082      * If non-0, then a second set of descriptors is stored at:
0083      *
0084      *   descriptors + desc_offset_2
0085      *
0086      * The MAC result of both descriptors is XOR'd and stored in @hash
0087      */
0088     uint32_t desc_offset_2;
0089 
0090     /*
0091      * (Physical) address of a brcmstb_bootloader_scratch_table, for
0092      * providing a large DRAM buffer to the bootloader
0093      */
0094     uint64_t buffer_table;
0095 
0096     uint32_t spare[70];
0097 
0098     uint8_t descriptors[IMAGE_DESCRIPTORS_BUFSIZE];
0099     /*
0100      * Must be last member of struct. See brcmstb_pm_s3_finish() for reason.
0101      */
0102     struct brcmstb_bootloader_dtu_table dtu[BRCMSTB_DTU_COUNT];
0103 } __packed;
0104 
0105 #endif /* __BRCMSTB_AON_DEFS_H__ */