]> 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_2_eng/packages/ti/board/src/evmAM437x/evmAM437x_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_2_eng / packages / ti / board / src / evmAM437x / evmAM437x_pinmux.c
1 /**
2  *   @file  evmam437xx_pinmux.c
3  *
4  *   @brief
5  *      This is the pin configuration for GP EVM AM437x.
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 "am43xx_pinmux.h"
52 #include "debug.h"
54 Board_STATUS Board_pinmuxConfig (void)
55 {
56     int32_t status;
57     
58     /* UART */
59     status = PINMUXModuleConfig(CHIPDB_MOD_ID_UART, 0U, NULL);
60     
61     /* PWMSS */
62     if(S_PASS == status)
63     {
64         status = PINMUXModuleConfig(CHIPDB_MOD_ID_PWMSS, 0U, NULL);
65     }
66     
67     /* DSS */
68     if(S_PASS == status)
69     {
70         status = PINMUXModuleConfig(CHIPDB_MOD_ID_DSS, 0U, NULL);
71     }
72     
73     /* USB */
74     if(S_PASS == status)
75     {
76         status = PINMUXModuleConfig(CHIPDB_MOD_ID_USB, 0U, NULL);
77     }
78     if(S_PASS == status)
79     {
80         status = PINMUXModuleConfig(CHIPDB_MOD_ID_USB, 1U, NULL);
81     }  
83     /* GPMC */
84     if(S_PASS == status)
85     {
86         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPMC, 0U, NULL);
87     } 
89     /* DCAN */
90     if(S_PASS == status)
91     {
92         status = PINMUXModuleConfig(CHIPDB_MOD_ID_DCAN, 0U, NULL);
93     } 
95     /* CPSW */
96     if(S_PASS == status)
97     {
98         status = PINMUXModuleConfig(CHIPDB_MOD_ID_CPSW, 0U, NULL);
99     }
101     /* MCASP */
102     if(S_PASS == status)
103     {
104         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MCASP, 0U, NULL);
105     } 
107     /* I2C */
108     if(S_PASS == status)
109     {
110         status = PINMUXModuleConfig(CHIPDB_MOD_ID_I2C, 0U, NULL);
111     } 
113     /* MMCSD */
114     if(S_PASS == status)
115     {
116         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MMCSD, 0U, NULL);
117     }
118     if(S_PASS == status)
119     {
120         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MMCSD, 1U, NULL);
121     }
123     /* VPFE */
124     if(S_PASS == status)
125     {
126         status = PINMUXModuleConfig(CHIPDB_MOD_ID_VPFE, 0U, NULL);
127     }
128     if(S_PASS == status)
129     {
130         status = PINMUXModuleConfig(CHIPDB_MOD_ID_VPFE, 1U, NULL);
131     }    
132     
133     /* GPIO */
134     if(S_PASS == status)
135     {
136         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 4U, NULL);
137     }
138     if(S_PASS == status)
139     {
140         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 3U, NULL);
141     }
142     if(S_PASS == status)
143     {
144         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 0U, NULL);
145     }
146     if(S_PASS == status)
147     {
148         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 5U, NULL);
149     }
150     return BOARD_SOK;
154 int32_t PINMUXModuleConfig(chipdbModuleID_t moduleId, uint32_t instNum, 
155                                                               void* pParam1)
157     pinmuxModuleCfg_t* pModuleData = NULL;
158     pinmuxPerCfg_t* pInstanceData = NULL;
159     volatile const pinmuxBoardCfg_t* pPinmuxData  = NULL;
160     uint32_t ctrlModBase = CHIPDBBaseAddress(CHIPDB_MOD_ID_CONTROL_MODULE, 0);
161     int32_t status = E_FAIL;
162     uint32_t index = 0;
163     
164     /* Get module Data */
165     pPinmuxData = gGpevmPinmuxData; 
166  
167     ASSERT(NULL != pPinmuxData);
168         
169     status = E_INVALID_MODULE_ID;
170     for(index = 0; ((S_PASS != status) && 
171        (CHIPDB_MOD_ID_INVALID != pPinmuxData[index].moduleId)); index++)
172     {
173         if(pPinmuxData[index].moduleId == moduleId)
174         {
175             pModuleData = pPinmuxData[index].modulePinCfg;
176             ASSERT(NULL != pModuleData);
177             status = S_PASS;
178         }
179     }
181     /* Get instance Data */
182     if(S_PASS == status)
183     {
184         status = E_INST_NOT_SUPP;
185         for(index = 0; ((S_PASS != status) && 
186           (CHIPDB_INVALID_INSTANCE_NUM != pModuleData[index].modInstNum)); index++)
187         {
188             if(pModuleData[index].modInstNum == instNum)
189             {
190                 pInstanceData = pModuleData[index].instPins;
191                 ASSERT(NULL != pInstanceData)
192                 status = S_PASS;
193             }
194         }
195     }
196         
197     /* Configure Pinmux */
198     if(S_PASS == status)
199     {
200                 for(index = 0; ((uint16_t)PINMUX_INVALID_PIN != 
201                                                                           pInstanceData[index].pinOffset); index++)
202                 {
203                         if(NULL != pParam1)
204                         {
205                                 if(pInstanceData[index].optParam == *(uint16_t*)pParam1)
206                                 {
207                                         HW_WR_REG32((ctrlModBase + pInstanceData[index].pinOffset),
208                                                                 pInstanceData[index].pinSettings);
209                     status = S_PASS;
210                                         break;
211                                 }
212                         }
213                         else
214                         {
215                                 HW_WR_REG32((ctrlModBase + pInstanceData[index].pinOffset),
216                                                                 pInstanceData[index].pinSettings);
217                         }
218                 }
219                 if((NULL != pParam1) && ((uint16_t)PINMUX_INVALID_PIN == pInstanceData[index].pinOffset))
220                 {
221                         status = E_FAIL;
222                 }
223     }
224     
225     return status;