source: rtems/c/src/lib/libbsp/arm/tms570/hwinit/init_pinmux.c @ b2ed712

Last change on this file since b2ed712 was 29430a3, checked in by Pavel Pisa <pisa@…>, on Sep 22, 2016 at 7:50:59 AM

arm/tms570: include hardware initialization and selftest based on Ti HalCoGen? generated files.

The configuration is specific for TMS570LS3137 based HDK.
Pins configuration can be easily changed in

rtems/c/src/lib/libbsp/arm/tms570/hwinit/init_pinmux.c

file.

The list tms570_selftest_par_list in the file

rtems/c/src/lib/libbsp/arm/tms570/hwinit/bspstarthooks-hwinit.c

specifies peripherals which health status is examined
by parity self-test at BSP start-up. It can be easily
modified for other TMS570 family members variants same
as the selection of other tests in bspstarthooks-hwinit.c.

  • Property mode set to 100644
File size: 11.4 KB
Line 
1/**
2 * @file init_pinmux.c
3 *
4 * @ingroup tms570
5 *
6 * @brief Initialize pin multiplexers.
7 */
8/*
9 * Copyright (c) 2016 Pavel Pisa <pisa@cmp.felk.cvut.cz>
10 *
11 * Czech Technical University in Prague
12 * Zikova 1903/4
13 * 166 36 Praha 6
14 * Czech Republic
15 *
16 * The license and distribution terms for this file may be
17 * found in the file LICENSE in this distribution or at
18 * http://www.rtems.org/license/LICENSE.
19 */
20
21#include <stdint.h>
22#include <bsp/tms570.h>
23#include <bsp/tms570-pinmux.h>
24#include <rtems.h>
25#include "tms570_hwinit.h"
26
27/*
28 * To check that content is right generated use
29 *
30 * objdump --section=.rodata -s init_pinmux.o
31 */
32#if 0
33
34/*
35 * Test of use of the default pins configuration with one line added.
36 * This can be used to concatenate partial lists but care has to
37 * be taken to not attempt to override already defined pin.
38 * This would not work and result in two PINMMR bits set
39 * for given pine.
40 */
41
42#ifndef TMS570_PINMMR_INIT_LIST
43  #define TMS570_PINMMR_INIT_LIST(per_pin_action, common_arg) \
44     TMS570_PINMMR_DEFAULT_INIT_LIST(per_pin_action, common_arg) \
45     per_pin_action(common_arg, TMS570_BALL_E3_HET2_18)
46#endif
47
48#else
49
50/*
51 * Definition of fuctions for all pins of TMS570LS3137.
52 * This setup correctponds to TMS570LS31x HDK Kit
53 */
54
55#define TMS570_PINMMR_INIT_LIST( per_pin_action, common_arg ) \
56  per_pin_action( common_arg, TMS570_BALL_W10_GIOB_3 ) \
57  per_pin_action( common_arg, TMS570_BALL_A5_GIOA_0 ) \
58  per_pin_action( common_arg, TMS570_BALL_C3_MIBSPI3NCS_3 ) \
59  per_pin_action( common_arg, TMS570_BALL_B2_MIBSPI3NCS_2 ) \
60  per_pin_action( common_arg, TMS570_BALL_C2_GIOA_1 ) \
61  per_pin_action( common_arg, TMS570_BALL_E3_HET1_11 ) \
62  per_pin_action( common_arg, TMS570_BALL_E5_EMIF_DATA_4 ) \
63  per_pin_action( common_arg, TMS570_BALL_F5_EMIF_DATA_5 ) \
64  per_pin_action( common_arg, TMS570_BALL_C1_GIOA_2 ) \
65  per_pin_action( common_arg, TMS570_BALL_G5_EMIF_DATA_6 ) \
66  per_pin_action( common_arg, TMS570_BALL_E1_GIOA_3 ) \
67  per_pin_action( common_arg, TMS570_BALL_B5_GIOA_5 ) \
68  per_pin_action( common_arg, TMS570_BALL_K5_EMIF_DATA_7 ) \
69  per_pin_action( common_arg, TMS570_BALL_B3_HET1_22 ) \
70  per_pin_action( common_arg, TMS570_BALL_H3_GIOA_6 ) \
71  per_pin_action( common_arg, TMS570_BALL_L5_EMIF_DATA_8 ) \
72  per_pin_action( common_arg, TMS570_BALL_M1_GIOA_7 ) \
73  per_pin_action( common_arg, TMS570_BALL_M5_EMIF_DATA_9 ) \
74  per_pin_action( common_arg, TMS570_BALL_V2_HET1_01 ) \
75  per_pin_action( common_arg, TMS570_BALL_U1_HET1_03 ) \
76  per_pin_action( common_arg, TMS570_BALL_K18_HET1_00 ) \
77  per_pin_action( common_arg, TMS570_BALL_W5_HET1_02 ) \
78  per_pin_action( common_arg, TMS570_BALL_V6_HET1_05 ) \
79  per_pin_action( common_arg, TMS570_BALL_N5_EMIF_DATA_10 ) \
80  per_pin_action( common_arg, TMS570_BALL_T1_HET1_07 ) \
81  per_pin_action( common_arg, TMS570_BALL_P5_EMIF_DATA_11 ) \
82  per_pin_action( common_arg, TMS570_BALL_V7_HET1_09 ) \
83  per_pin_action( common_arg, TMS570_BALL_R5_EMIF_DATA_12 ) \
84  per_pin_action( common_arg, TMS570_BALL_R6_EMIF_DATA_13 ) \
85  per_pin_action( common_arg, TMS570_BALL_V5_MIBSPI3NCS_1 ) \
86  per_pin_action( common_arg, TMS570_BALL_W3_SCIRX ) \
87  per_pin_action( common_arg, TMS570_BALL_R7_EMIF_DATA_14 ) \
88  per_pin_action( common_arg, TMS570_BALL_N2_SCITX ) \
89  per_pin_action( common_arg, TMS570_BALL_G3_MIBSPI1NCS_2 ) \
90  per_pin_action( common_arg, TMS570_BALL_N1_HET1_15 ) \
91  per_pin_action( common_arg, TMS570_BALL_R8_EMIF_DATA_15 ) \
92  per_pin_action( common_arg, TMS570_BALL_R9_ETMTRACECLKIN ) \
93  per_pin_action( common_arg, TMS570_BALL_W9_MIBSPI3NENA ) \
94  per_pin_action( common_arg, TMS570_BALL_V10_MIBSPI3NCS_0 ) \
95  per_pin_action( common_arg, TMS570_BALL_J3_MIBSPI1NCS_3 ) \
96  per_pin_action( common_arg, TMS570_BALL_N19_AD1EVT ) \
97  per_pin_action( common_arg, TMS570_BALL_N15_EMIF_DATA_3 ) \
98  per_pin_action( common_arg, TMS570_BALL_N17_EMIF_nCS_0 ) \
99  per_pin_action( common_arg, TMS570_BALL_M15_EMIF_DATA_2 ) \
100  per_pin_action( common_arg, TMS570_BALL_K17_EMIF_nCS_3 ) \
101  per_pin_action( common_arg, TMS570_BALL_M17_EMIF_nCS_4 ) \
102  per_pin_action( common_arg, TMS570_BALL_L15_EMIF_DATA_1 ) \
103  per_pin_action( common_arg, TMS570_BALL_P1_HET1_24 ) \
104  per_pin_action( common_arg, TMS570_BALL_A14_HET1_26 ) \
105  per_pin_action( common_arg, TMS570_BALL_K15_EMIF_DATA_0 ) \
106  per_pin_action( common_arg, TMS570_BALL_G19_MIBSPI1NENA ) \
107  per_pin_action( common_arg, TMS570_BALL_H18_MIBSPI5NENA ) \
108  per_pin_action( common_arg, TMS570_BALL_J18_MIBSPI5SOMI_0 ) \
109  per_pin_action( common_arg, TMS570_BALL_J19_MIBSPI5SIMO_0 ) \
110  per_pin_action( common_arg, TMS570_BALL_H19_MIBSPI5CLK ) \
111  per_pin_action( common_arg, TMS570_BALL_R2_MIBSPI1NCS_0 ) \
112  per_pin_action( common_arg, TMS570_BALL_E18_HET1_08 ) \
113  per_pin_action( common_arg, TMS570_BALL_K19_HET1_28 ) \
114  per_pin_action( common_arg, TMS570_BALL_D17_EMIF_nWE ) \
115  per_pin_action( common_arg, TMS570_BALL_D16_EMIF_BA_1 ) \
116  per_pin_action( common_arg, TMS570_BALL_C17_EMIF_ADDR_21 ) \
117  per_pin_action( common_arg, TMS570_BALL_C16_EMIF_ADDR_20 ) \
118  per_pin_action( common_arg, TMS570_BALL_C15_EMIF_ADDR_19 ) \
119  per_pin_action( common_arg, TMS570_BALL_D15_EMIF_ADDR_18 ) \
120  per_pin_action( common_arg, TMS570_BALL_E13_EMIF_BA_0 ) \
121  per_pin_action( common_arg, TMS570_BALL_C14_EMIF_ADDR_17 ) \
122  per_pin_action( common_arg, TMS570_BALL_D14_EMIF_ADDR_16 ) \
123  per_pin_action( common_arg, TMS570_BALL_E12_EMIF_nOE ) \
124  per_pin_action( common_arg, TMS570_BALL_D19_HET1_10 ) \
125  per_pin_action( common_arg, TMS570_BALL_E11_EMIF_nDQM_1 ) \
126  per_pin_action( common_arg, TMS570_BALL_B4_HET1_12 ) \
127  per_pin_action( common_arg, TMS570_BALL_E9_EMIF_ADDR_5 ) \
128  per_pin_action( common_arg, TMS570_BALL_C13_EMIF_ADDR_15 ) \
129  per_pin_action( common_arg, TMS570_BALL_A11_HET1_14 ) \
130  per_pin_action( common_arg, TMS570_BALL_C12_EMIF_ADDR_14 ) \
131  per_pin_action( common_arg, TMS570_BALL_M2_GIOB_0 ) \
132  per_pin_action( common_arg, TMS570_BALL_E8_EMIF_ADDR_4 ) \
133  per_pin_action( common_arg, TMS570_BALL_B11_HET1_30 ) \
134  per_pin_action( common_arg, TMS570_BALL_E10_EMIF_nDQM_0 ) \
135  per_pin_action( common_arg, TMS570_BALL_E7_EMIF_ADDR_3 ) \
136  per_pin_action( common_arg, TMS570_BALL_C11_EMIF_ADDR_13 ) \
137  per_pin_action( common_arg, TMS570_BALL_C10_EMIF_ADDR_12 ) \
138  per_pin_action( common_arg, TMS570_BALL_F3_MIBSPI1NCS_1 ) \
139  per_pin_action( common_arg, TMS570_BALL_C9_EMIF_ADDR_11 ) \
140  per_pin_action( common_arg, TMS570_BALL_D5_EMIF_ADDR_1 ) \
141  per_pin_action( common_arg, TMS570_BALL_K2_GIOB_1 ) \
142  per_pin_action( common_arg, TMS570_BALL_C8_EMIF_ADDR_10 ) \
143  per_pin_action( common_arg, TMS570_BALL_C7_EMIF_ADDR_9 ) \
144  per_pin_action( common_arg, TMS570_BALL_D4_EMIF_ADDR_0 ) \
145  per_pin_action( common_arg, TMS570_BALL_C5_EMIF_ADDR_7 ) \
146  per_pin_action( common_arg, TMS570_BALL_C4_EMIF_ADDR_6 ) \
147  per_pin_action( common_arg, TMS570_BALL_E6_EMIF_ADDR_2 ) \
148  per_pin_action( common_arg, TMS570_BALL_C6_EMIF_ADDR_8 ) \
149  per_pin_action( common_arg, TMS570_MMR_SELECT_SPI4CLK ) \
150  per_pin_action( common_arg, TMS570_MMR_SELECT_SPI4SIMO ) \
151  per_pin_action( common_arg, TMS570_MMR_SELECT_SPI4SOMI ) \
152  per_pin_action( common_arg, TMS570_MMR_SELECT_SPI4NENA ) \
153  per_pin_action( common_arg, TMS570_MMR_SELECT_SPI4NCS_0 ) \
154  per_pin_action( common_arg, TMS570_BALL_A13_HET1_17 ) \
155  per_pin_action( common_arg, TMS570_BALL_B13_HET1_19 ) \
156  per_pin_action( common_arg, TMS570_BALL_H4_HET1_21 ) \
157  per_pin_action( common_arg, TMS570_BALL_J4_HET1_23 ) \
158  per_pin_action( common_arg, TMS570_BALL_M3_HET1_25 ) \
159  per_pin_action( common_arg, TMS570_BALL_A9_HET1_27 ) \
160  per_pin_action( common_arg, TMS570_BALL_A3_HET1_29 ) \
161  per_pin_action( common_arg, TMS570_BALL_J17_HET1_31 ) \
162  per_pin_action( common_arg, TMS570_BALL_W6_MIBSPI5NCS_2 ) \
163  per_pin_action( common_arg, TMS570_BALL_T12_MIBSPI5NCS_3 ) \
164  per_pin_action( common_arg, TMS570_BALL_E19_MIBSPI5NCS_0 ) \
165  per_pin_action( common_arg, TMS570_BALL_B6_MIBSPI5NCS_1 ) \
166  per_pin_action( common_arg, TMS570_BALL_E16_MIBSPI5SIMO_1 ) \
167  per_pin_action( common_arg, TMS570_BALL_H17_MIBSPI5SIMO_2 ) \
168  per_pin_action( common_arg, TMS570_BALL_G17_MIBSPI5SIMO_3 ) \
169  per_pin_action( common_arg, TMS570_BALL_E17_MIBSPI5SOMI_1 ) \
170  per_pin_action( common_arg, TMS570_BALL_H16_MIBSPI5SOMI_2 ) \
171  per_pin_action( common_arg, TMS570_BALL_G16_MIBSPI5SOMI_3 ) \
172  per_pin_action( common_arg, TMS570_BALL_D3_SPI2NENA ) \
173  per_pin_action( common_arg, \
174  TMS570_MMR_SELECT_EMIF_CLK_SEL | TMS570_PIN_CLEAR_RQ_MASK ) \
175  per_pin_action( common_arg, \
176  TMS570_BALL_F2_GIOB_2 | TMS570_PIN_CLEAR_RQ_MASK ) \
177  per_pin_action( common_arg, \
178  TMS570_MMR_SELECT_GMII_SEL | TMS570_PIN_CLEAR_RQ_MASK ) \
179  per_pin_action( common_arg, TMS570_MMR_SELECT_ADC_TRG1 ) \
180
181
182#endif
183
184/*
185 * The next construct allows to compute values for individual
186 * PINMMR registers based on the multiple processing
187 * complete pin functions list at compile time.
188 * Each line computes 32-bit value which selects function
189 * of consecutive four pins. Each pin function is defined
190 * by single byte.
191 */
192const uint32_t tms570_pinmmr_init_data[] = {
193  TMS570_PINMMR_REG_VAL( 0, TMS570_PINMMR_INIT_LIST ),
194  TMS570_PINMMR_REG_VAL( 1, TMS570_PINMMR_INIT_LIST ),
195  TMS570_PINMMR_REG_VAL( 2, TMS570_PINMMR_INIT_LIST ),
196  TMS570_PINMMR_REG_VAL( 3, TMS570_PINMMR_INIT_LIST ),
197  TMS570_PINMMR_REG_VAL( 4, TMS570_PINMMR_INIT_LIST ),
198  TMS570_PINMMR_REG_VAL( 5, TMS570_PINMMR_INIT_LIST ),
199  TMS570_PINMMR_REG_VAL( 6, TMS570_PINMMR_INIT_LIST ),
200  TMS570_PINMMR_REG_VAL( 7, TMS570_PINMMR_INIT_LIST ),
201  TMS570_PINMMR_REG_VAL( 8, TMS570_PINMMR_INIT_LIST ),
202  TMS570_PINMMR_REG_VAL( 9, TMS570_PINMMR_INIT_LIST ),
203  TMS570_PINMMR_REG_VAL( 10, TMS570_PINMMR_INIT_LIST ),
204  TMS570_PINMMR_REG_VAL( 11, TMS570_PINMMR_INIT_LIST ),
205  TMS570_PINMMR_REG_VAL( 12, TMS570_PINMMR_INIT_LIST ),
206  TMS570_PINMMR_REG_VAL( 13, TMS570_PINMMR_INIT_LIST ),
207  TMS570_PINMMR_REG_VAL( 14, TMS570_PINMMR_INIT_LIST ),
208  TMS570_PINMMR_REG_VAL( 15, TMS570_PINMMR_INIT_LIST ),
209  TMS570_PINMMR_REG_VAL( 16, TMS570_PINMMR_INIT_LIST ),
210  TMS570_PINMMR_REG_VAL( 17, TMS570_PINMMR_INIT_LIST ),
211  TMS570_PINMMR_REG_VAL( 18, TMS570_PINMMR_INIT_LIST ),
212  TMS570_PINMMR_REG_VAL( 19, TMS570_PINMMR_INIT_LIST ),
213  TMS570_PINMMR_REG_VAL( 20, TMS570_PINMMR_INIT_LIST ),
214  TMS570_PINMMR_REG_VAL( 21, TMS570_PINMMR_INIT_LIST ),
215  TMS570_PINMMR_REG_VAL( 22, TMS570_PINMMR_INIT_LIST ),
216  TMS570_PINMMR_REG_VAL( 23, TMS570_PINMMR_INIT_LIST ),
217  TMS570_PINMMR_REG_VAL( 24, TMS570_PINMMR_INIT_LIST ),
218  TMS570_PINMMR_REG_VAL( 25, TMS570_PINMMR_INIT_LIST ),
219  TMS570_PINMMR_REG_VAL( 26, TMS570_PINMMR_INIT_LIST ),
220  TMS570_PINMMR_REG_VAL( 27, TMS570_PINMMR_INIT_LIST ),
221  TMS570_PINMMR_REG_VAL( 28, TMS570_PINMMR_INIT_LIST ),
222  TMS570_PINMMR_REG_VAL( 29, TMS570_PINMMR_INIT_LIST ),
223  TMS570_PINMMR_REG_VAL( 30, TMS570_PINMMR_INIT_LIST ),
224};
225
226/**
227 * @brief setups pin multiplexer according to precomputed registers values (HCG:muxInit)
228 */
229void tms570_pinmux_init( void )
230{
231  tms570_bsp_pinmmr_config( tms570_pinmmr_init_data, 0,
232    RTEMS_ARRAY_SIZE( tms570_pinmmr_init_data ) );
233}
234
235#if 0
236
237/*
238 * Alternative option how to set function of individual pins
239 * or use list for one by one setting. This is much slower
240 * and consumes more memory to hold complete list.
241 *
242 * On the other hand this solution can be used for configuration
243 * or reconfiguration of some shorter groups of pins at runtime.
244 *
245 */
246
247const uint32_t tms570_pinmmr_init_list[] = {
248  TMS570_PINMMR_COMA_LIST( TMS570_PINMMR_INIT_LIST )
249};
250
251void tms570_pinmux_init_by_list( void )
252{
253  int pincnt = RTEMS_ARRAY_SIZE( tms570_pinmmr_init_list );
254  const uint32_t *pinfnc = tms570_pinmmr_init_list;
255
256  while ( pincnt-- )
257    tms570_bsp_pin_config_one( *(pinfnc++) );
258}
259#endif
Note: See TracBrowser for help on using the repository browser.