1 /*
2 * Copyright (c) 2016 - 2020, Broadcom
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #ifndef SR_CHIMP_H
8 #define SR_CHIMP_H
9
10 #include <common/bl_common.h>
11 #include <common/debug.h>
12 #include <lib/mmio.h>
13
14 #include <platform_def.h>
15
16 #define CHIMP_WINDOW_SIZE 0x400000
17 #define CHIMP_ERROR_OFFSET 28
18 #define CHIMP_ERROR_MASK 0xf0000000
19
20 #ifndef EMULATION_SETUP
21 #define CHIMP_HANDSHAKE_TIMEOUT_MS 10000
22 #else
23 /*
24 * 1hr timeout for test in emulator
25 * By doing this ChiMP is given a chance to boot
26 * fully from the QSPI
27 * (on Palladium this takes upto 50 min depending on QSPI clk)
28 */
29
30 #define CHIMP_HANDSHAKE_TIMEOUT_MS 3600000
31 #endif
32
33 #define CHIMP_BPE_MODE_ID_PATTERN (0x25000000)
34 #define CHIMP_BPE_MODE_ID_MASK (0x7f000000)
35 #define NIC_RESET_RELEASE_TIMEOUT_US (10)
36
37 /* written by M0, used by ChiMP ROM */
38 #define SR_IN_SMARTNIC_MODE_BIT 0
39 /* written by M0, used by ChiMP ROM */
40 #define SR_CHIMP_SECURE_BOOT_BIT 1
41 /* cleared by AP, set by ChiMP BC2 code */
42 #define SR_FLASH_ACCESS_DONE_BIT 2
43
44 #ifdef USE_CHIMP
45 void bcm_chimp_write(uintptr_t addr, uint32_t value);
46 uint32_t bcm_chimp_read(uintptr_t addr);
47 uint32_t bcm_chimp_read_ctrl(uint32_t offset);
48 void bcm_chimp_clrbits(uintptr_t addr, uint32_t bits);
49 void bcm_chimp_setbits(uintptr_t addr, uint32_t bits);
50 int bcm_chimp_is_nic_mode(void);
51 void bcm_chimp_fru_prog_done(bool status);
52 int bcm_chimp_handshake_done(void);
53 int bcm_chimp_wait_handshake(void);
54 /* Fastboot-related*/
55 int bcm_chimp_initiate_fastboot(int fastboot_type);
56 #else
bcm_chimp_write(uintptr_t addr,uint32_t value)57 static inline void bcm_chimp_write(uintptr_t addr, uint32_t value)
58 {
59 }
bcm_chimp_read(uintptr_t addr)60 static inline uint32_t bcm_chimp_read(uintptr_t addr)
61 {
62 return 0;
63 }
bcm_chimp_read_ctrl(uint32_t offset)64 static inline uint32_t bcm_chimp_read_ctrl(uint32_t offset)
65 {
66 return 0;
67 }
bcm_chimp_clrbits(uintptr_t addr,uint32_t bits)68 static inline void bcm_chimp_clrbits(uintptr_t addr, uint32_t bits)
69 {
70 }
bcm_chimp_setbits(uintptr_t addr,uint32_t bits)71 static inline void bcm_chimp_setbits(uintptr_t addr, uint32_t bits)
72 {
73 }
bcm_chimp_is_nic_mode(void)74 static inline int bcm_chimp_is_nic_mode(void)
75 {
76 return 0;
77 }
bcm_chimp_fru_prog_done(bool status)78 static inline void bcm_chimp_fru_prog_done(bool status)
79 {
80 }
bcm_chimp_handshake_done(void)81 static inline int bcm_chimp_handshake_done(void)
82 {
83 return 0;
84 }
bcm_chimp_wait_handshake(void)85 static inline int bcm_chimp_wait_handshake(void)
86 {
87 return 0;
88 }
bcm_chimp_initiate_fastboot(int fastboot_type)89 static inline int bcm_chimp_initiate_fastboot(int fastboot_type)
90 {
91 return 0;
92 }
93 #endif /* USE_CHIMP */
94 #endif
95