1#!/usr/bin/env python3
2#
3# Copyright (c) 2019 Intel Corporation
4#
5# SPDX-License-Identifier: Apache-2.0
6from enum import Enum
7
8# BXT
9
10# CORE ID MASK
11CORE_0 = 0x1
12CORE_1 = 0x2
13CORE_MASK = 0x3
14
15# Number of Input Streams Supported (GCAP[11:8])
16NUM_ISS = 6
17# Number of Output Streams Supported (GCAP[15:12])
18NUM_OSS = 7
19# Total Number of Streams supported
20NUM_STREAMS = NUM_ISS + NUM_OSS
21
22# DMA Index for FW download
23DMA_ID = 7
24
25# DMA Page Size
26DMA_PAGE_SIZE = 0x1000
27
28# FW Registers in SRAM
29FW_SRAM = 0x80000
30FW_REGS = FW_SRAM + 0x00
31FW_MBOX_UPLINK = FW_SRAM + 0x1000
32FW_MBOX_DWLINK = FW_SRAM + 0x20000
33FW_MBOX_SIZE   = 0x1000
34
35# FW Status Register
36FW_STATUS                   = FW_REGS + 0x0000
37FW_STATUS_BOOT_STATE        = 0x00FFFFFF
38FW_STATUS_BOOT_STATE_OFFSET = 0
39FW_STATUS_WAIT_STATE        = 0x0F000000
40FW_STATUS_WAIT_STATE_OFFSET = 24
41FW_STATUS_MODULE            = 0x70000000
42FW_STATUS_MODULE_OFFSET     = 28
43FW_STATUS_ERROR             = 0x80000000
44FW_STATUS_ERROR_OFFSET      = 31
45
46
47class BOOT_STATUS(Enum):
48    INIT        = 0
49    INIT_DONE   = 1
50    FW_ENTERED  = 5
51
52
53def BOOT_STATUS_STR(status):
54    try:
55        e = BOOT_STATUS(status)
56    except Exception:
57        return "UNKNOWN"
58
59    return e.name
60
61
62# Boot Status
63BOOT_STATUS_INIT        = 0x00
64BOOT_STATUS_INIT_DONE   = 0x01
65BOOT_STATUS_FW_ENTERED  = 0x05
66
67
68class WAIT_STATUS(Enum):
69    DMA_BUFFER_FULL = 5
70
71
72def WAIT_STATUS_STR(status):
73    try:
74        e = WAIT_STATUS(status)
75    except Exception:
76        return "UNKNOWN"
77
78    return e.name
79
80
81# Wait Status
82WAIT_STATUS_DMA_BUFFER_FULL = 0x05
83
84# FW Error Status
85FW_ERR_CODE = FW_SRAM + 0x0004
86
87# IPC Purge FW message
88FW_IPC_PURGE = 0x01004000
89
90# IPC GLOBAL LENGTH register
91IPC_GLOBAL_LEN = 0x00
92IPC_GLOBAL_CMD = 0x04
93