[DSS APP][PDK-9214]DSS Display Examples is not working on eDP
[processor-sdk/pdk.git] / packages / ti / drv / dss / examples / utils / app_utils_j721e.c
1 /*
2  *  Copyright (c) Texas Instruments Incorporated 2018
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions
7  *  are met:
8  *
9  *    Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *    Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *    Neither the name of Texas Instruments Incorporated nor the names of
18  *    its contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
34 /**
35  *  \file app_utils.c
36  *
37  *  \brief DSS example utility APIs for J7
38  */
40 /* ========================================================================== */
41 /*                             Include Files                                  */
42 /* ========================================================================== */
44 #include <ti/board/src/j721e_evm/include/board_control.h>
45 #include <ti/csl/soc/cslr_soc_ctrl_mmr.h>
46 #include <ti/drv/sciclient/sciclient.h>
47 #include <ti/drv/pm/pmlib.h>
48 #include "app_utils.h"
50 /* ========================================================================== */
51 /*                           Macros & Typedefs                                */
52 /* ========================================================================== */
55 /* ========================================================================== */
56 /*                         Structure Declarations                             */
57 /* ========================================================================== */
59 /* None */
61 /* ========================================================================== */
62 /*                          Function Declarations                             */
63 /* ========================================================================== */
65 /* None */
67 /* ========================================================================== */
68 /*                            Global Variables                                */
69 /* ========================================================================== */
71 /* None */
73 /* ========================================================================== */
74 /*                          Function Definitions                              */
75 /* ========================================================================== */
77 void App_configureSoC(void)
78 {
79     /* Set drive strength */
80     CSL_REG32_WR(CSL_WKUP_CTRL_MMR0_CFG0_BASE +
81                  CSL_WKUP_CTRL_MMR_CFG0_H_IO_DRVSTRNGTH0_PROXY, 0xFU);
83     CSL_REG32_WR(CSL_WKUP_CTRL_MMR0_CFG0_BASE +
84                  CSL_WKUP_CTRL_MMR_CFG0_V_IO_DRVSTRNGTH0_PROXY, 0xFU);
85 }
87 void App_configureLCD(uint32_t app_output)
88 {
89     int32_t status = PM_SUCCESS;
91     if(APP_OUTPUT_HDMI == app_output)
92     {
93         if(PM_SUCCESS == status)
94         {
95             status = Sciclient_pmSetModuleClkParent(TISCI_DEV_DSS0,
96                     TISCI_DEV_DSS0_DSS_INST0_DPI_1_IN_2X_CLK,
97                     TISCI_DEV_DSS0_DSS_INST0_DPI_1_IN_2X_CLK_PARENT_DPI0_EXT_CLKSEL_OUT0,
98                     SCICLIENT_SERVICE_WAIT_FOREVER);
99         }
101         if(PM_SUCCESS == status)
102         {
103             status = Sciclient_pmSetModuleState(TISCI_DEV_DSS0,
104                     TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
105                     TISCI_MSG_FLAG_AOP,
106                     SCICLIENT_SERVICE_WAIT_FOREVER);
107         }
109         if(PM_SUCCESS == status)
110         {
111             status = Sciclient_pmModuleClkRequest(TISCI_DEV_DSS0,
112                     TISCI_DEV_DSS0_DSS_FUNC_CLK,
113                     TISCI_MSG_VALUE_CLOCK_SW_STATE_REQ,
114                     0,
115                     SCICLIENT_SERVICE_WAIT_FOREVER);
116         }
118         if(PM_SUCCESS == status)
119         {
120             status = Sciclient_pmSetModuleClkFreq(TISCI_DEV_DSS0,
121                     TISCI_DEV_DSS0_DSS_INST0_DPI_1_IN_2X_CLK,
122                     148500000ULL,
123                     0,
124                     SCICLIENT_SERVICE_WAIT_FOREVER);
125         }
127         if(PM_SUCCESS == status)
128         {
129             status = Sciclient_pmModuleClkRequest(TISCI_DEV_DSS0,
130                     TISCI_DEV_DSS0_DSS_INST0_DPI_1_IN_2X_CLK,
131                     TISCI_MSG_VALUE_CLOCK_SW_STATE_REQ,
132                     0,
133                     SCICLIENT_SERVICE_WAIT_FOREVER);
134         }
135         if(PM_SUCCESS == status)
136         {
137             Board_control(BOARD_CTRL_CMD_SET_HDMI_MUX, (void*) 0U);
138             Board_control(BOARD_CTRL_CMD_SET_HDMI_PD_HIGH, (void*) 0U);
139         }
140     }
141     else if (APP_OUTPUT_DSI == app_output)
142     {
143         if(PM_SUCCESS == status)
144         {
145             status = Sciclient_pmSetModuleState(
146                 TISCI_DEV_DSS_DSI0, TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
147                 TISCI_MSG_FLAG_AOP, SCICLIENT_SERVICE_WAIT_FOREVER);
148         }
149         if(PM_SUCCESS == status)
150         {
151             status = Sciclient_pmSetModuleState(
152                 TISCI_DEV_DPHY_TX0, TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
153                 TISCI_MSG_FLAG_AOP, SCICLIENT_SERVICE_WAIT_FOREVER);
154         }
155         if(PM_SUCCESS == status)
156         {
157             status = Sciclient_pmSetModuleState(TISCI_DEV_DSS0,
158                     TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
159                     TISCI_MSG_FLAG_AOP,
160                     SCICLIENT_SERVICE_WAIT_FOREVER);
161         }
162         if(PM_SUCCESS == status)
163         {
164             status = Sciclient_pmModuleClkRequest(TISCI_DEV_DSS0,
165                     TISCI_DEV_DSS0_DSS_FUNC_CLK,
166                     TISCI_MSG_VALUE_CLOCK_SW_STATE_REQ,
167                     0,
168                     SCICLIENT_SERVICE_WAIT_FOREVER);
169         }
170         if (PM_SUCCESS == status)
171         {
172             status = Sciclient_pmSetModuleClkParent(TISCI_DEV_DSS0,
173                 TISCI_DEV_DSS0_DSS_INST0_DPI_2_IN_2X_CLK,
174                 TISCI_DEV_DSS0_DSS_INST0_DPI_2_IN_2X_CLK_PARENT_HSDIV1_16FFT_MAIN_18_HSDIVOUT0_CLK,
175                 SCICLIENT_SERVICE_WAIT_FOREVER);
176         }
177         if (PM_SUCCESS == status)
178         {
179             /* Set the clock at the desirable frequency*/
180             status = Sciclient_pmSetModuleClkFreq(TISCI_DEV_DSS0,
181                 TISCI_DEV_DSS0_DSS_INST0_DPI_2_IN_2X_CLK, 74250000u,
182                 TISCI_MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE,
183                 SCICLIENT_SERVICE_WAIT_FOREVER);
184         }
185     }
186     else
187     {
188         if(PM_SUCCESS == status)
189         {
190             status = Sciclient_pmSetModuleState(TISCI_DEV_SERDES_10G0,
191                 TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
192                 TISCI_MSG_FLAG_AOP,
193                 SCICLIENT_SERVICE_WAIT_FOREVER);
194         }
196         if(PM_SUCCESS == status)
197         {
198             status = Sciclient_pmSetModuleState(TISCI_DEV_DSS_EDP0,
199                 TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
200                 TISCI_MSG_FLAG_AOP,
201                 SCICLIENT_SERVICE_WAIT_FOREVER);
202         }
204         if(PM_SUCCESS == status)
205         {
206             status = Sciclient_pmSetModuleState(TISCI_DEV_DSS0,
207                 TISCI_MSG_VALUE_DEVICE_SW_STATE_ON,
208                 TISCI_MSG_FLAG_AOP,
209                 SCICLIENT_SERVICE_WAIT_FOREVER);
210         }
212         if(PM_SUCCESS == status)
213         {
214             status = Sciclient_pmSetModuleClkParent(TISCI_DEV_DSS0,
215                 TISCI_DEV_DSS0_DSS_INST0_DPI_2_IN_2X_CLK,
216                 TISCI_DEV_DSS0_DSS_INST0_DPI_2_IN_2X_CLK_PARENT_HSDIV1_16FFT_MAIN_18_HSDIVOUT0_CLK,
217                 SCICLIENT_SERVICE_WAIT_FOREVER);
218         }
220         if(PM_SUCCESS == status)
221         {
222             status = Sciclient_pmSetModuleClkParent(TISCI_DEV_DSS0,
223                 TISCI_DEV_DSS0_DSS_INST0_DPI_3_IN_2X_CLK,
224                 TISCI_DEV_DSS0_DSS_INST0_DPI_3_IN_2X_CLK_PARENT_DPI1_EXT_CLKSEL_OUT0,
225                 SCICLIENT_SERVICE_WAIT_FOREVER);
226         }
228         if(PM_SUCCESS == status)
229         {
230             status = Sciclient_pmSetModuleClkParent(TISCI_DEV_DSS0,
231                 TISCI_DEV_DSS0_DSS_INST0_DPI_0_IN_2X_CLK,
232                 TISCI_DEV_DSS0_DSS_INST0_DPI_0_IN_2X_CLK_PARENT_HSDIV1_16FFT_MAIN_16_HSDIVOUT0_CLK,
233                 SCICLIENT_SERVICE_WAIT_FOREVER);
234         }
236         if(PM_SUCCESS == status)
237         {
238             status = Sciclient_pmSetModuleClkFreq(TISCI_DEV_DSS0,
239                 TISCI_DEV_DSS0_DSS_INST0_DPI_0_IN_2X_CLK,
240                 148500000ULL,
241                 0U,
242                 SCICLIENT_SERVICE_WAIT_FOREVER);
243         }
245         if(PM_SUCCESS == status)
246         {
247             status = Sciclient_pmModuleClkRequest(TISCI_DEV_DSS0,
248                 TISCI_DEV_DSS0_DSS_INST0_DPI_0_IN_2X_CLK,
249                 TISCI_MSG_VALUE_CLOCK_SW_STATE_REQ,
250                 0U,
251                 SCICLIENT_SERVICE_WAIT_FOREVER);
252         }
253     }