]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - psdk_cust/pdk_k2g_1_0_1_1_eng/packages/ti/board/src/icev2AM335x/icev2AM335x_pinmux.c
PASDK-319:Update PDK eng to 1.0.1.2.
[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_1_eng / packages / ti / board / src / icev2AM335x / icev2AM335x_pinmux.c
1 /**
2  *   @file  icev2am335x_pinmux.c
3  *
4  *   @brief
5  *      This is the pin configuration for ICE V2 AM335x.
6  *
7  *  \par
8  *  ============================================================================
9  *  @n   (C) Copyright 2009-2015, Texas Instruments, Inc.
10  *
11  *  Redistribution and use in source and binary forms, with or without
12  *  modification, are permitted provided that the following conditions
13  *  are met:
14  *
15  *    Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  *
18  *    Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the
21  *    distribution.
22  *
23  *    Neither the name of Texas Instruments Incorporated nor the names of
24  *    its contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39  *  \par
40 */
42 #include <stdint.h>
43 #include <stdlib.h>
44 #include <stdio.h>
45 #include "board_internal.h"
46 #include "types.h"
47 #include "hw_types.h"
48 #include "chipdb.h"
49 #include "pinmux.h"
50 #include "error.h"
51 #include "am335x_pinmux.h"
52 #include "debug.h"
54 extern uint32_t icssPinMuxFlag;
56 Board_STATUS Board_pinmuxConfig (void)
57 {
58     int32_t status;
59     
60     /* UART */
61     status = PINMUXModuleConfig(CHIPDB_MOD_ID_UART, 0U, NULL);
62     if(S_PASS == status)
63     {
64         status = PINMUXModuleConfig(CHIPDB_MOD_ID_UART, 1U, NULL);
65     }
66     if(S_PASS == status)
67     {
68         status = PINMUXModuleConfig(CHIPDB_MOD_ID_UART, 3U, NULL);
69     }
70     if(S_PASS == status)
71     {
72         status = PINMUXModuleConfig(CHIPDB_MOD_ID_UART, 4U, NULL);
73     }
74     
75     /* CPSW */
76     if((S_PASS == status) && (icssPinMuxFlag == 0U))
77     {
78         status = PINMUXModuleConfig(CHIPDB_MOD_ID_CPSW, 0U, NULL);
79     }    
80     
81     /* GPIO */
82     if(S_PASS == status)
83     {
84         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 0U, NULL);
85     }
86     if(S_PASS == status)
87     {
88         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 1U, NULL);
89     }
90     if(S_PASS == status)
91     {
92         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 2U, NULL);
93     }
94     if(S_PASS == status)
95     {
96         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 3U, NULL);
97     }
99     /* I2C */
100     if(S_PASS == status)
101     {
102         status = PINMUXModuleConfig(CHIPDB_MOD_ID_I2C, 0U, NULL);
103     }
105     /* MCSPI */
106     if(S_PASS == status)
107     {
108         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MCSPI, 0U, NULL);
109     }    
110     if(S_PASS == status)
111     {
112         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MCSPI, 1U, NULL);
113     }    
116     /* MMCSD */
117     if(S_PASS == status)
118     {
119         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MMCSD, 0U, NULL);
120     }
122     /*GPMC*/
123     if(S_PASS == status)
124     {
125         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPMC, 0U, NULL);
126     }
128     /*PRU_ICSS*/
129     if((S_PASS == status) && (icssPinMuxFlag == 1U))
130     {
131         status = PINMUXModuleConfig(CHIPDB_MOD_ID_PRU_ICSS, 1U, NULL);
132     }
135     return BOARD_SOK;
139 int32_t PINMUXModuleConfig(chipdbModuleID_t moduleId, uint32_t instNum, 
140                                                               void* pParam1)
142     pinmuxModuleCfg_t* pModuleData = NULL;
143     pinmuxPerCfg_t* pInstanceData = NULL;
144     volatile const pinmuxBoardCfg_t* pPinmuxData  = NULL;
145     uint32_t ctrlModBase = CHIPDBBaseAddress(CHIPDB_MOD_ID_CONTROL_MODULE, 0);
146     int32_t status = E_FAIL;
147     uint32_t index = 0;
148     
149     /* Get module Data */
150 //  pPinmuxData = gGpevmPinmuxData; 
151     pPinmuxData = gIceV2PinmuxData; 
152     ASSERT(NULL != pPinmuxData);
153         
154     status = E_INVALID_MODULE_ID;
155     for(index = 0; ((S_PASS != status) && 
156        (CHIPDB_MOD_ID_INVALID != pPinmuxData[index].moduleId)); index++)
157     {
158         if(pPinmuxData[index].moduleId == moduleId)
159         {
160             pModuleData = pPinmuxData[index].modulePinCfg;
161             ASSERT(NULL != pModuleData);
162             status = S_PASS;
163         }
164     }
166     /* Get instance Data */
167     if(S_PASS == status)
168     {
169         status = E_INST_NOT_SUPP;
170         for(index = 0; ((S_PASS != status) && 
171           (CHIPDB_INVALID_INSTANCE_NUM != pModuleData[index].modInstNum)); index++)
172         {
173             if(pModuleData[index].modInstNum == instNum)
174             {
175                 pInstanceData = pModuleData[index].instPins;
176                 ASSERT(NULL != pInstanceData)
177                 status = S_PASS;
178             }
179         }
180     }
181         
182     /* Configure Pinmux */
183     if(S_PASS == status)
184     {
185                 for(index = 0; ((uint16_t)PINMUX_INVALID_PIN != 
186                                                                           pInstanceData[index].pinOffset); index++)
187                 {
188                         if(NULL != pParam1)
189                         {
190                                 if(pInstanceData[index].optParam == *(uint16_t*)pParam1)
191                                 {
192                                         HW_WR_REG32((ctrlModBase + pInstanceData[index].pinOffset),
193                                                                 pInstanceData[index].pinSettings);
194                     status = S_PASS;
195                                         break;
196                                 }
197                         }
198                         else
199                         {
200                                 HW_WR_REG32((ctrlModBase + pInstanceData[index].pinOffset),
201                                                                 pInstanceData[index].pinSettings);
202                         }
203                 }
204                 if((NULL != pParam1) && ((uint16_t)PINMUX_INVALID_PIN == pInstanceData[index].pinOffset))
205                 {
206                         status = E_FAIL;
207                 }
208     }
209     
210     return status;