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