]> 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/evmAM335x/evmAM335x_pinmux.c
Merge pull request #1 in PASDK/pasdk_sr from PASDK-318-input-task-code-repetition...
[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_2_eng / packages / ti / board / src / evmAM335x / evmAM335x_pinmux.c
1 /**
2  *   @file  evmam335x_pinmux.c
3  *
4  *   @brief
5  *      This is the pin configuration for GP EVM 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 Board_STATUS Board_pinmuxConfig (void)
55 {
56     int32_t status;
57     
58     status = PINMUXModuleConfig(CHIPDB_MOD_ID_UART, 0U, NULL);
60     /* GPIO */
61     if(S_PASS == status)
62     {
63         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 0U, NULL);
64     }
65     if(S_PASS == status)
66     {
67         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPIO, 1U, NULL);
68     }
70     /* MMCSD */
71     if(S_PASS == status)
72     {
73         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MMCSD, 0U, NULL);
74     }
75     
76     /* I2C */
77     if(S_PASS == status)
78     {
79         status = PINMUXModuleConfig(CHIPDB_MOD_ID_I2C, 0U, NULL);
80     }
81     
82     /* PWMSS */
83     if(S_PASS == status)
84     {
85         status = PINMUXModuleConfig(CHIPDB_MOD_ID_PWMSS, 2U, NULL);
86     }
87     
88     /* MCSPI */
89     if(S_PASS == status)
90     {
91         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MCSPI, 0U, NULL);
92     }
93     
94     /* DCAN */
95     if(S_PASS == status)
96     {
97         status = PINMUXModuleConfig(CHIPDB_MOD_ID_DCAN, 1U, NULL);
98     }
99     
100     /* CPSW */
101     if(S_PASS == status)
102     {
103         status = PINMUXModuleConfig(CHIPDB_MOD_ID_CPSW, 0U, NULL);
104     }
105     
106     /* GPMC */
107     if(S_PASS == status)
108     {
109         status = PINMUXModuleConfig(CHIPDB_MOD_ID_GPMC, 0U, NULL);
110     }
112     /* LCDC */
113     if(S_PASS == status)
114     {
115         status = PINMUXModuleConfig(CHIPDB_MOD_ID_LCDC, 0U, NULL);
116     }
118     /* USB */
119     if(S_PASS == status)
120     {
121         status = PINMUXModuleConfig(CHIPDB_MOD_ID_USB, 0U, NULL);
122     }
124     /* MCASP */
125     if(S_PASS == status)
126     {
127         status = PINMUXModuleConfig(CHIPDB_MOD_ID_MCASP, 0U, NULL);
128     }
130     return BOARD_SOK;
134 int32_t PINMUXModuleConfig(chipdbModuleID_t moduleId, uint32_t instNum, 
135                                                               void* pParam1)
137     pinmuxModuleCfg_t* pModuleData = NULL;
138     pinmuxPerCfg_t* pInstanceData = NULL;
139     volatile const pinmuxBoardCfg_t* pPinmuxData  = NULL;
140     uint32_t ctrlModBase = CHIPDBBaseAddress(CHIPDB_MOD_ID_CONTROL_MODULE, 0);
141     int32_t status = E_FAIL;
142     uint32_t index = 0;
143     
144     /* Get module Data */
145     pPinmuxData = gGpevmPinmuxData; 
146 //  pPinmuxData = gIceV2PinmuxData; 
147     ASSERT(NULL != pPinmuxData);
148         
149     status = E_INVALID_MODULE_ID;
150     for(index = 0; ((S_PASS != status) && 
151        (CHIPDB_MOD_ID_INVALID != pPinmuxData[index].moduleId)); index++)
152     {
153         if(pPinmuxData[index].moduleId == moduleId)
154         {
155             pModuleData = pPinmuxData[index].modulePinCfg;
156             ASSERT(NULL != pModuleData);
157             status = S_PASS;
158         }
159     }
161     /* Get instance Data */
162     if(S_PASS == status)
163     {
164         status = E_INST_NOT_SUPP;
165         for(index = 0; ((S_PASS != status) && 
166           (CHIPDB_INVALID_INSTANCE_NUM != pModuleData[index].modInstNum)); index++)
167         {
168             if(pModuleData[index].modInstNum == instNum)
169             {
170                 pInstanceData = pModuleData[index].instPins;
171                 ASSERT(NULL != pInstanceData)
172                 status = S_PASS;
173             }
174         }
175     }
176         
177     /* Configure Pinmux */
178     if(S_PASS == status)
179     {
180                 for(index = 0; ((uint16_t)PINMUX_INVALID_PIN != 
181                                                                           pInstanceData[index].pinOffset); index++)
182                 {
183                         if(NULL != pParam1)
184                         {
185                                 if(pInstanceData[index].optParam == *(uint16_t*)pParam1)
186                                 {
187                                         HW_WR_REG32((ctrlModBase + pInstanceData[index].pinOffset),
188                                                                 pInstanceData[index].pinSettings);
189                     status = S_PASS;
190                                         break;
191                                 }
192                         }
193                         else
194                         {
195                                 HW_WR_REG32((ctrlModBase + pInstanceData[index].pinOffset),
196                                                                 pInstanceData[index].pinSettings);
197                         }
198                 }
199                 if((NULL != pParam1) && ((uint16_t)PINMUX_INVALID_PIN == pInstanceData[index].pinOffset))
200                 {
201                         status = E_FAIL;
202                 }
203     }
204     
205     return status;