1 /* SPDX-License-Identifier: GPL-2.0
3 * Copyright 2018-2020 HabanaLabs, Ltd.
11 #define LKD_HARD_RESET_MAGIC 0xED7BD694 /* deprecated - do not use */
12 #define HL_POWER9_HOST_MAGIC 0x1DA30009
14 #define BOOT_FIT_SRAM_OFFSET 0x200000
16 #define VERSION_MAX_LEN 128
19 * CPU error bits in BOOT_ERROR registers
21 * CPU_BOOT_ERR0_DRAM_INIT_FAIL DRAM initialization failed.
22 * DRAM is not reliable to use.
24 * CPU_BOOT_ERR0_FIT_CORRUPTED FIT data integrity verification of the
25 * image provided by the host has failed.
27 * CPU_BOOT_ERR0_TS_INIT_FAIL Thermal Sensor initialization failed.
28 * Boot continues as usual, but keep in
29 * mind this is a warning.
31 * CPU_BOOT_ERR0_DRAM_SKIPPED DRAM initialization has been skipped.
32 * Skipping DRAM initialization has been
33 * requested (e.g. strap, command, etc.)
34 * and FW skipped the DRAM initialization.
35 * Host can initialize the DRAM.
37 * CPU_BOOT_ERR0_BMC_WAIT_SKIPPED Waiting for BMC data will be skipped.
38 * Meaning the BMC data might not be
39 * available until reset.
41 * CPU_BOOT_ERR0_NIC_DATA_NOT_RDY NIC data from BMC is not ready.
42 * BMC has not provided the NIC data yet.
43 * Once provided this bit will be cleared.
45 * CPU_BOOT_ERR0_NIC_FW_FAIL NIC FW loading failed.
46 * The NIC FW loading and initialization
47 * failed. This means NICs are not usable.
49 * CPU_BOOT_ERR0_SECURITY_NOT_RDY Chip security initialization has been
50 * started, but is not ready yet - chip
53 * CPU_BOOT_ERR0_SECURITY_FAIL Security related tasks have failed.
54 * The tasks are security init (root of
55 * trust), boot authentication (chain of
56 * trust), data packets authentication.
58 * CPU_BOOT_ERR0_EFUSE_FAIL Reading from eFuse failed.
59 * The PCI device ID might be wrong.
61 * CPU_BOOT_ERR0_PRI_IMG_VER_FAIL Verification of primary image failed.
62 * It mean that ppboot checksum
63 * verification for the preboot primary
64 * image has failed to match expected
65 * checksum. Trying to program image again
68 * CPU_BOOT_ERR0_SEC_IMG_VER_FAIL Verification of secondary image failed.
69 * It mean that ppboot checksum
70 * verification for the preboot secondary
71 * image has failed to match expected
72 * checksum. Trying to program image again
75 * CPU_BOOT_ERR0_PLL_FAIL PLL settings failed, meaning that one
76 * of the PLLs remains in REF_CLK
78 * CPU_BOOT_ERR0_DEVICE_UNUSABLE_FAIL Device is unusable and customer support
79 * should be contacted.
81 * CPU_BOOT_ERR0_ENABLED Error registers enabled.
82 * This is a main indication that the
83 * running FW populates the error
84 * registers. Meaning the error bits are
85 * not garbage, but actual error statuses.
87 #define CPU_BOOT_ERR0_DRAM_INIT_FAIL (1 << 0)
88 #define CPU_BOOT_ERR0_FIT_CORRUPTED (1 << 1)
89 #define CPU_BOOT_ERR0_TS_INIT_FAIL (1 << 2)
90 #define CPU_BOOT_ERR0_DRAM_SKIPPED (1 << 3)
91 #define CPU_BOOT_ERR0_BMC_WAIT_SKIPPED (1 << 4)
92 #define CPU_BOOT_ERR0_NIC_DATA_NOT_RDY (1 << 5)
93 #define CPU_BOOT_ERR0_NIC_FW_FAIL (1 << 6)
94 #define CPU_BOOT_ERR0_SECURITY_NOT_RDY (1 << 7)
95 #define CPU_BOOT_ERR0_SECURITY_FAIL (1 << 8)
96 #define CPU_BOOT_ERR0_EFUSE_FAIL (1 << 9)
97 #define CPU_BOOT_ERR0_PRI_IMG_VER_FAIL (1 << 10)
98 #define CPU_BOOT_ERR0_SEC_IMG_VER_FAIL (1 << 11)
99 #define CPU_BOOT_ERR0_PLL_FAIL (1 << 12)
100 #define CPU_BOOT_ERR0_DEVICE_UNUSABLE_FAIL (1 << 13)
101 #define CPU_BOOT_ERR0_ENABLED (1 << 31)
102 #define CPU_BOOT_ERR1_ENABLED (1 << 31)
105 * BOOT DEVICE STATUS bits in BOOT_DEVICE_STS registers
107 * CPU_BOOT_DEV_STS0_SECURITY_EN Security is Enabled.
108 * This is an indication for security
109 * enabled in FW, which means that
110 * all conditions for security are met:
111 * device is indicated as security enabled,
112 * registers are protected, and device
113 * uses keys for image verification.
114 * Initialized in: preboot
116 * CPU_BOOT_DEV_STS0_DEBUG_EN Debug is enabled.
117 * Enabled when JTAG or DEBUG is enabled
119 * Initialized in: preboot
121 * CPU_BOOT_DEV_STS0_WATCHDOG_EN Watchdog is enabled.
122 * Watchdog is enabled in FW.
123 * Initialized in: preboot
125 * CPU_BOOT_DEV_STS0_DRAM_INIT_EN DRAM initialization is enabled.
126 * DRAM initialization has been done in FW.
127 * Initialized in: u-boot
129 * CPU_BOOT_DEV_STS0_BMC_WAIT_EN Waiting for BMC data enabled.
130 * If set, it means that during boot,
131 * FW waited for BMC data.
132 * Initialized in: u-boot
134 * CPU_BOOT_DEV_STS0_E2E_CRED_EN E2E credits initialized.
135 * FW initialized E2E credits.
136 * Initialized in: u-boot
138 * CPU_BOOT_DEV_STS0_HBM_CRED_EN HBM credits initialized.
139 * FW initialized HBM credits.
140 * Initialized in: u-boot
142 * CPU_BOOT_DEV_STS0_RL_EN Rate limiter initialized.
143 * FW initialized rate limiter.
144 * Initialized in: u-boot
146 * CPU_BOOT_DEV_STS0_SRAM_SCR_EN SRAM scrambler enabled.
147 * FW initialized SRAM scrambler.
148 * Initialized in: linux
150 * CPU_BOOT_DEV_STS0_DRAM_SCR_EN DRAM scrambler enabled.
151 * FW initialized DRAM scrambler.
152 * Initialized in: u-boot
154 * CPU_BOOT_DEV_STS0_FW_HARD_RST_EN FW hard reset procedure is enabled.
155 * FW has the hard reset procedure
156 * implemented. This means that FW will
157 * perform hard reset procedure on
158 * receiving the halt-machine event.
159 * Initialized in: preboot, u-boot, linux
161 * CPU_BOOT_DEV_STS0_PLL_INFO_EN FW retrieval of PLL info is enabled.
162 * Initialized in: linux
164 * CPU_BOOT_DEV_STS0_SP_SRAM_EN SP SRAM is initialized and available
166 * Initialized in: preboot
168 * CPU_BOOT_DEV_STS0_CLK_GATE_EN Clock Gating enabled.
169 * FW initialized Clock Gating.
170 * Initialized in: preboot
172 * CPU_BOOT_DEV_STS0_HBM_ECC_EN HBM ECC handling Enabled.
173 * FW handles HBM ECC indications.
174 * Initialized in: linux
176 * CPU_BOOT_DEV_STS0_PKT_PI_ACK_EN Packets ack value used in the armcpd
177 * is set to the PI counter.
178 * Initialized in: linux
180 * CPU_BOOT_DEV_STS0_FW_LD_COM_EN Flexible FW loading communication
181 * protocol is enabled.
182 * Initialized in: preboot
184 * CPU_BOOT_DEV_STS0_FW_IATU_CONF_EN FW iATU configuration is enabled.
185 * This bit if set, means the iATU has been
186 * configured and is ready for use.
187 * Initialized in: ppboot
189 * CPU_BOOT_DEV_STS0_DYN_PLL_EN Dynamic PLL configuration is enabled.
190 * FW sends to host a bitmap of supported
192 * Initialized in: linux
194 * CPU_BOOT_DEV_STS0_GIC_PRIVILEGED_EN GIC access permission only from
195 * previleged entity. FW sets this status
196 * bit for host. If this bit is set then
197 * GIC can not be accessed from host.
198 * Initialized in: linux
200 * CPU_BOOT_DEV_STS0_EQ_INDEX_EN Event Queue (EQ) index is a running
201 * index for each new event sent to host.
202 * This is used as a method in host to
203 * identify that the waiting event in
204 * queue is actually a new event which
205 * was not served before.
206 * Initialized in: linux
208 * CPU_BOOT_DEV_STS0_MULTI_IRQ_POLL_EN Use multiple scratchpad interfaces to
209 * prevent IRQs overriding each other.
210 * Initialized in: linux
212 * CPU_BOOT_DEV_STS0_ENABLED Device status register enabled.
213 * This is a main indication that the
214 * running FW populates the device status
215 * register. Meaning the device status
216 * bits are not garbage, but actual
218 * Initialized in: preboot
221 #define CPU_BOOT_DEV_STS0_SECURITY_EN (1 << 0)
222 #define CPU_BOOT_DEV_STS0_DEBUG_EN (1 << 1)
223 #define CPU_BOOT_DEV_STS0_WATCHDOG_EN (1 << 2)
224 #define CPU_BOOT_DEV_STS0_DRAM_INIT_EN (1 << 3)
225 #define CPU_BOOT_DEV_STS0_BMC_WAIT_EN (1 << 4)
226 #define CPU_BOOT_DEV_STS0_E2E_CRED_EN (1 << 5)
227 #define CPU_BOOT_DEV_STS0_HBM_CRED_EN (1 << 6)
228 #define CPU_BOOT_DEV_STS0_RL_EN (1 << 7)
229 #define CPU_BOOT_DEV_STS0_SRAM_SCR_EN (1 << 8)
230 #define CPU_BOOT_DEV_STS0_DRAM_SCR_EN (1 << 9)
231 #define CPU_BOOT_DEV_STS0_FW_HARD_RST_EN (1 << 10)
232 #define CPU_BOOT_DEV_STS0_PLL_INFO_EN (1 << 11)
233 #define CPU_BOOT_DEV_STS0_SP_SRAM_EN (1 << 12)
234 #define CPU_BOOT_DEV_STS0_CLK_GATE_EN (1 << 13)
235 #define CPU_BOOT_DEV_STS0_HBM_ECC_EN (1 << 14)
236 #define CPU_BOOT_DEV_STS0_PKT_PI_ACK_EN (1 << 15)
237 #define CPU_BOOT_DEV_STS0_FW_LD_COM_EN (1 << 16)
238 #define CPU_BOOT_DEV_STS0_FW_IATU_CONF_EN (1 << 17)
239 #define CPU_BOOT_DEV_STS0_DYN_PLL_EN (1 << 19)
240 #define CPU_BOOT_DEV_STS0_GIC_PRIVILEGED_EN (1 << 20)
241 #define CPU_BOOT_DEV_STS0_EQ_INDEX_EN (1 << 21)
242 #define CPU_BOOT_DEV_STS0_MULTI_IRQ_POLL_EN (1 << 22)
243 #define CPU_BOOT_DEV_STS0_ENABLED (1 << 31)
244 #define CPU_BOOT_DEV_STS1_ENABLED (1 << 31)
246 enum cpu_boot_status {
247 CPU_BOOT_STATUS_NA = 0, /* Default value after reset of chip */
248 CPU_BOOT_STATUS_IN_WFE = 1,
249 CPU_BOOT_STATUS_DRAM_RDY = 2,
250 CPU_BOOT_STATUS_SRAM_AVAIL = 3,
251 CPU_BOOT_STATUS_IN_BTL = 4, /* BTL is H/W FSM */
252 CPU_BOOT_STATUS_IN_PREBOOT = 5,
253 CPU_BOOT_STATUS_IN_SPL, /* deprecated - not reported */
254 CPU_BOOT_STATUS_IN_UBOOT = 7,
255 CPU_BOOT_STATUS_DRAM_INIT_FAIL, /* deprecated - will be removed */
256 CPU_BOOT_STATUS_FIT_CORRUPTED, /* deprecated - will be removed */
257 /* U-Boot console prompt activated, commands are not processed */
258 CPU_BOOT_STATUS_UBOOT_NOT_READY = 10,
259 /* Finished NICs init, reported after DRAM and NICs */
260 CPU_BOOT_STATUS_NIC_FW_RDY = 11,
261 CPU_BOOT_STATUS_TS_INIT_FAIL, /* deprecated - will be removed */
262 CPU_BOOT_STATUS_DRAM_SKIPPED, /* deprecated - will be removed */
263 CPU_BOOT_STATUS_BMC_WAITING_SKIPPED, /* deprecated - will be removed */
264 /* Last boot loader progress status, ready to receive commands */
265 CPU_BOOT_STATUS_READY_TO_BOOT = 15,
266 /* Internal Boot finished, ready for boot-fit */
267 CPU_BOOT_STATUS_WAITING_FOR_BOOT_FIT = 16,
268 /* Internal Security has been initialized, device can be accessed */
269 CPU_BOOT_STATUS_SECURITY_READY = 17,
282 enum cpu_msg_status {
288 /* communication registers mapping - consider ABI when changing */
289 struct cpu_dyn_regs {
290 __le32 cpu_pq_base_addr_low;
291 __le32 cpu_pq_base_addr_high;
292 __le32 cpu_pq_length;
293 __le32 cpu_pq_init_status;
294 __le32 cpu_eq_base_addr_low;
295 __le32 cpu_eq_base_addr_high;
296 __le32 cpu_eq_length;
298 __le32 cpu_cq_base_addr_low;
299 __le32 cpu_cq_base_addr_high;
300 __le32 cpu_cq_length;
302 __le32 cpu_boot_dev_sts0;
303 __le32 cpu_boot_dev_sts1;
304 __le32 cpu_boot_err0;
305 __le32 cpu_boot_err1;
306 __le32 cpu_boot_status;
309 __le32 fw_upd_pending_sts;
310 __le32 fuse_ver_offset;
311 __le32 preboot_ver_offset;
312 __le32 uboot_ver_offset;
314 __le32 kmd_msg_to_cpu;
315 __le32 cpu_cmd_status_to_host;
317 __le32 gic_host_irq_ctrl;
318 __le32 gic_host_pi_upd_irq;
320 __le32 gic_tpc_qm_irq_ctrl;
321 __le32 gic_mme_qm_irq_ctrl;
322 __le32 gic_dma_qm_irq_ctrl;
323 __le32 gic_nic_qm_irq_ctrl;
324 __le32 gic_dma_core_irq_ctrl;
325 __le32 gic_host_halt_irq;
326 __le32 gic_host_ints_irq;
327 __le32 reserved1[24]; /* reserve for future use */
330 /* TODO: remove the desc magic after the code is updated to use message */
331 /* HCDM - Habana Communications Descriptor Magic */
332 #define HL_COMMS_DESC_MAGIC 0x4843444D
333 #define HL_COMMS_DESC_VER 1
335 /* HCMv - Habana Communications Message + header version */
336 #define HL_COMMS_MSG_MAGIC_VALUE 0x48434D00
337 #define HL_COMMS_MSG_MAGIC_MASK 0xFFFFFF00
338 #define HL_COMMS_MSG_MAGIC_VER_MASK 0xFF
340 #define HL_COMMS_MSG_MAGIC_VER(ver) (HL_COMMS_MSG_MAGIC_VALUE | \
341 ((ver) & HL_COMMS_MSG_MAGIC_VER_MASK))
342 #define HL_COMMS_MSG_MAGIC_V0 HL_COMMS_DESC_MAGIC
343 #define HL_COMMS_MSG_MAGIC_V1 HL_COMMS_MSG_MAGIC_VER(1)
345 #define HL_COMMS_MSG_MAGIC HL_COMMS_MSG_MAGIC_V1
347 #define HL_COMMS_MSG_MAGIC_VALIDATE_MAGIC(magic) \
348 (((magic) & HL_COMMS_MSG_MAGIC_MASK) == \
349 HL_COMMS_MSG_MAGIC_VALUE)
351 #define HL_COMMS_MSG_MAGIC_VALIDATE_VERSION(magic, ver) \
352 (((magic) & HL_COMMS_MSG_MAGIC_VER_MASK) >= \
353 ((ver) & HL_COMMS_MSG_MAGIC_VER_MASK))
355 #define HL_COMMS_MSG_MAGIC_VALIDATE(magic, ver) \
356 (HL_COMMS_MSG_MAGIC_VALIDATE_MAGIC((magic)) && \
357 HL_COMMS_MSG_MAGIC_VALIDATE_VERSION((magic), (ver)))
359 enum comms_msg_type {
360 HL_COMMS_DESC_TYPE = 0,
361 HL_COMMS_RESET_CAUSE_TYPE = 1,
364 /* TODO: remove this struct after the code is updated to use message */
365 /* this is the comms descriptor header - meta data */
366 struct comms_desc_header {
367 __le32 magic; /* magic for validation */
368 __le32 crc32; /* CRC32 of the descriptor w/o header */
369 __le16 size; /* size of the descriptor w/o header */
370 __u8 version; /* descriptor version */
371 __u8 reserved[5]; /* pad to 64 bit */
374 /* this is the comms message header - meta data */
375 struct comms_msg_header {
376 __le32 magic; /* magic for validation */
377 __le32 crc32; /* CRC32 of the message w/o header */
378 __le16 size; /* size of the message w/o header */
379 __u8 version; /* message payload version */
380 __u8 type; /* message type */
381 __u8 reserved[4]; /* pad to 64 bit */
384 /* this is the main FW descriptor - consider ABI when changing */
385 struct lkd_fw_comms_desc {
386 struct comms_desc_header header;
387 struct cpu_dyn_regs cpu_dyn_regs;
388 char fuse_ver[VERSION_MAX_LEN];
389 char cur_fw_ver[VERSION_MAX_LEN];
390 /* can be used for 1 more version w/o ABI change */
391 char reserved0[VERSION_MAX_LEN];
392 __le64 img_addr; /* address for next FW component load */
395 enum comms_reset_cause {
396 HL_RESET_CAUSE_UNKNOWN = 0,
397 HL_RESET_CAUSE_HEARTBEAT = 1,
398 HL_RESET_CAUSE_TDR = 2,
401 /* TODO: remove define after struct name is aligned on all projects */
402 #define lkd_msg_comms lkd_fw_comms_msg
404 /* this is the comms message descriptor */
405 struct lkd_fw_comms_msg {
406 struct comms_msg_header header;
407 /* union for future expantions of new messages */
410 struct cpu_dyn_regs cpu_dyn_regs;
411 char fuse_ver[VERSION_MAX_LEN];
412 char cur_fw_ver[VERSION_MAX_LEN];
413 /* can be used for 1 more version w/o ABI change */
414 char reserved0[VERSION_MAX_LEN];
415 /* address for next FW component load */
427 * COMMS_NOOP Used to clear the command register and no actual
430 * COMMS_CLR_STS Clear status command - FW should clear the
431 * status register. Used for synchronization
432 * between the commands as part of the race free
435 * COMMS_RST_STATE Reset the current communication state which is
436 * kept by FW for proper responses.
437 * Should be used in the beginning of the
438 * communication cycle to clean any leftovers from
439 * previous communication attempts.
441 * COMMS_PREP_DESC Prepare descriptor for setting up the
442 * communication and other dynamic data:
443 * struct lkd_fw_comms_desc.
444 * This command has a parameter stating the next FW
445 * component size, so the FW can actually prepare a
446 * space for it and in the status response provide
447 * the descriptor offset. The Offset of the next FW
448 * data component is a part of the descriptor
451 * COMMS_DATA_RDY The FW data has been uploaded and is ready for
454 * COMMS_EXEC Execute the next FW component.
456 * COMMS_RST_DEV Reset the device.
458 * COMMS_GOTO_WFE Execute WFE command. Allowed only on non-secure
461 * COMMS_SKIP_BMC Perform actions required for BMC-less servers.
462 * Do not wait for BMC response.
464 * COMMS_LOW_PLL_OPP Initialize PLLs for low OPP.
476 COMMS_LOW_PLL_OPP = 9,
480 #define COMMS_COMMAND_SIZE_SHIFT 0
481 #define COMMS_COMMAND_SIZE_MASK 0x1FFFFFF
482 #define COMMS_COMMAND_CMD_SHIFT 27
483 #define COMMS_COMMAND_CMD_MASK 0xF8000000
486 * LKD command to FW register structure
487 * @size - FW component size
488 * @cmd - command from enum comms_cmd
490 struct comms_command {
491 union { /* bit fields are only for FW use */
493 u32 size :25; /* 32MB max. */
495 enum comms_cmd cmd :5; /* 32 commands */
504 * COMMS_STS_NOOP Used to clear the status register and no actual
505 * status is provided.
507 * COMMS_STS_ACK Command has been received and recognized.
509 * COMMS_STS_OK Command execution has finished successfully.
511 * COMMS_STS_ERR Command execution was unsuccessful and resulted
514 * COMMS_STS_VALID_ERR FW validation has failed.
516 * COMMS_STS_TIMEOUT_ERR Command execution has timed out.
523 COMMS_STS_VALID_ERR = 4,
524 COMMS_STS_TIMEOUT_ERR = 5,
528 /* RAM types for FW components loading - defines the base address */
529 enum comms_ram_types {
534 #define COMMS_STATUS_OFFSET_SHIFT 0
535 #define COMMS_STATUS_OFFSET_MASK 0x03FFFFFF
536 #define COMMS_STATUS_OFFSET_ALIGN_SHIFT 2
537 #define COMMS_STATUS_RAM_TYPE_SHIFT 26
538 #define COMMS_STATUS_RAM_TYPE_MASK 0x0C000000
539 #define COMMS_STATUS_STATUS_SHIFT 28
540 #define COMMS_STATUS_STATUS_MASK 0xF0000000
543 * FW status to LKD register structure
544 * @offset - an offset from the base of the ram_type shifted right by
545 * 2 bits (always aligned to 32 bits).
546 * Allows a maximum addressable offset of 256MB from RAM base.
547 * Example: for real offset in RAM of 0x800000 (8MB), the value
548 * in offset field is (0x800000 >> 2) = 0x200000.
549 * @ram_type - the RAM type that should be used for offset from
550 * enum comms_ram_types
551 * @status - status from enum comms_sts
553 struct comms_status {
554 union { /* bit fields are only for FW use */
557 enum comms_ram_types ram_type :2;
558 enum comms_sts status :4; /* 16 statuses */
564 #endif /* HL_BOOT_IF_H */