1 /*******************************************************************************
2  * Copyright 2019-2021 Microchip FPGA Embedded Systems Solutions.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * MPFS HAL Embedded Software
7  *
8  */
9 /*******************************************************************************
10  * @file mss_peripherals.h
11  * @author Microchip-FPGA Embedded Systems Solutions
12  * @brief PolarFire SoC MSS fumnctions related to MSS peripherals.
13  *
14  */
15 /*=========================================================================*//**
16 
17  *//*=========================================================================*/
18 #ifndef MSS_PERIPHERALS_H
19 #define MSS_PERIPHERALS_H
20 
21 #include <stdint.h>
22 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #if !defined (LIBERO_SETTING_CONTEXT_A_EN)
29 #define LIBERO_SETTING_CONTEXT_A_EN         0x00000000UL
30 #endif
31 #if !defined (LIBERO_SETTING_CONTEXT_B_EN)
32 #define LIBERO_SETTING_CONTEXT_B_EN         0x00000000UL
33 #endif
34 #if !defined (LIBERO_SETTING_CONTEXT_A_EN_FIC)
35 #define LIBERO_SETTING_CONTEXT_A_EN_FIC     0x0000000FUL
36 #endif
37 #if !defined (LIBERO_SETTING_CONTEXT_B_EN_FIC)
38 #define LIBERO_SETTING_CONTEXT_B_EN_FIC     0x0000000FUL
39 #endif
40 
41 /***************************************************************************//**
42 
43  */
44 typedef enum PERIPH_RESET_STATE_
45 {
46 
47     PERIPHERAL_ON                       = 0x00,        /*!< 0 RST and clk ON  */
48     PERIPHERAL_OFF                      = 0x01,        /*!< 1 RST and clk OFF */
49 } PERIPH_RESET_STATE;
50 
51 #define CONTEXT_EN_INDEX                 0x00U
52 #define CONTEXT_EN_INDEX_FIC             0x01U
53 #define SUBBLK_CLOCK_NA_MASK             0x00U
54 
55 typedef enum mss_peripherals_ {
56     MSS_PERIPH_MMUART0      = 0U,
57     MSS_PERIPH_MMUART1      = 1U,
58     MSS_PERIPH_MMUART2      = 2U,
59     MSS_PERIPH_MMUART3      = 3U,
60     MSS_PERIPH_MMUART4      = 4U,
61     MSS_PERIPH_WDOG0        = 5U,
62     MSS_PERIPH_WDOG1        = 6U,
63     MSS_PERIPH_WDOG2        = 7U,
64     MSS_PERIPH_WDOG3        = 8U,
65     MSS_PERIPH_WDOG4        = 9U,
66     MSS_PERIPH_SPI0         = 10U,
67     MSS_PERIPH_SPI1         = 11U,
68     MSS_PERIPH_I2C0         = 12U,
69     MSS_PERIPH_I2C1         = 13U,
70     MSS_PERIPH_CAN0         = 14U,
71     MSS_PERIPH_CAN1         = 15U,
72     MSS_PERIPH_MAC0         = 16U,
73     MSS_PERIPH_MAC1         = 17U,
74     MSS_PERIPH_TIMER        = 18U,
75     MSS_PERIPH_GPIO0        = 19U,
76     MSS_PERIPH_GPIO1        = 20U,
77     MSS_PERIPH_GPIO2        = 21U,
78     MSS_PERIPH_RTC          = 22U,
79     MSS_PERIPH_H2FINT       = 23U,
80     MSS_PERIPH_CRYPTO       = 24U,
81     MSS_PERIPH_USB          = 25U,
82     MSS_PERIPH_QSPIXIP      = 26U,
83     MSS_PERIPH_ATHENA       = 27U,
84     MSS_PERIPH_TRACE        = 28U,
85     MSS_PERIPH_MAILBOX_SC   = 29U,
86     MSS_PERIPH_EMMC         = 30U,
87     MSS_PERIPH_CFM          = 31U,
88     MSS_PERIPH_FIC0         = 32U,
89     MSS_PERIPH_FIC1         = 33U,
90     MSS_PERIPH_FIC2         = 34U,
91     MSS_PERIPH_FIC3         = 35U
92 } mss_peripherals;
93 
94 
95 /***************************************************************************//**
96   This function is used to turn on or off a peripheral. If contexts have been
97   configured, these will be checked to see if peripheral should be controlled
98   from a particular context.
99 
100   @param peripheral
101     See enum mss_peripherals for list of peripherals
102 
103   @param hart
104     Origin hart of this request
105 
106   @req_state
107     Turn peripheral on or off:
108         - PERIPHERAL_ON
109         - PERIPHERAL_OFF
110   Example:
111   @code
112     uint8_t err_status;
113     err_status = mss_config_clk_rst(MSS_PERIPH_MMUART0, (uint8_t) origin_hart_ID, PERIPHERAL_ON);
114 
115     if(0U != err_status)
116     {
117        print_uart0("\n\r Context not allowed to access UART0 from hart:%d\n\nr", origin_hart_ID);
118     }
119   @endcode
120  */
121 uint8_t mss_config_clk_rst(mss_peripherals peripheral, uint8_t hart, PERIPH_RESET_STATE req_state);
122 
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 
129 #endif /* MSS_PERIPHERALS_H */
130