RTEMS 6.1-rc4
Loading...
Searching...
No Matches
tms570-pinmux.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
12/*
13 * Copyright (C) 2015 Premysl Houdek <kom541000@gmail.com>
14 *
15 * Google Summer of Code 2014 at
16 * Czech Technical University in Prague
17 * Zikova 1903/4
18 * 166 36 Praha 6
19 * Czech Republic
20 *
21 * Redistribution and use in source and binary forms, with or without
22 * modification, are permitted provided that the following conditions
23 * are met:
24 * 1. Redistributions of source code must retain the above copyright
25 * notice, this list of conditions and the following disclaimer.
26 * 2. Redistributions in binary form must reproduce the above copyright
27 * notice, this list of conditions and the following disclaimer in the
28 * documentation and/or other materials provided with the distribution.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
41 */
42
43#ifndef LIBBSP_ARM_TMS570_PINMUX_H
44#define LIBBSP_ARM_TMS570_PINMUX_H
45
46#include <stddef.h>
47#include <stdint.h>
48
49#ifdef __cplusplus
50extern "C" {
51#endif /* __cplusplus */
52
53
54#define TMS570_PIN_NUM_SHIFT 0
55#define TMS570_PIN_NUM_MASK 0x000007ff
56
57/*
58 * Request clear of interconnection in setup
59 * to ensure that previous peripheral to pin
60 * connection is not enabled in parallel to other one.
61 * Mask is ored with pin number in such list.
62 */
63#define TMS570_PIN_CLEAR_RQ_MASK 0x00008000
64
65#define TMS570_PIN_FNC_SHIFT 11
66#define TMS570_PIN_FNC_MASK 0x00007800
67
74#define TMS570_PIN_FNC_CLEAR 0x10U
75
76#define TMS570_PIN_NUM_FNC_MASK 0x0000ffff
77
78#define TMS570_PIN_IN_ALT_SHIFT 16
79#define TMS570_PIN_IN_ALT_MASK 0xffff0000
80
81#define TMS570_PIN_FNC_AUTO (-1)
82
92#define TMS570_PIN_AND_FNC(pin, fnc) \
93 ((pin) | ((fnc) << TMS570_PIN_FNC_SHIFT))
94
95#define TMS570_PIN_WITH_IN_ALT(pin_num_and_fnc, pin_in_alt_num_and_fnc) \
96 ((pin_num_and_fnc) | ((pin_in_alt_num_and_fnc) << TMS570_PIN_IN_ALT_SHIFT))
97
98#define TMS570_BALL_WITH_MMR(mmrx, pos) \
99 ((pos) | ((mmrx) << 2))
100
108
118void tms570_pin_config_apply(uint32_t config);
119
131void tms570_pin_config_array_apply(const uint32_t *config, size_t count);
132
137
138/* Generic functions select pin to peripheral connection */
139
140void tms570_bsp_pin_set_function(int pin_num, int pin_fnc);
141
142void tms570_bsp_pin_clear_function(int pin_num, int pin_fnc);
143
144void tms570_bsp_pin_config_one(uint32_t pin_num_and_fnc);
145
146void tms570_bsp_pinmmr_config(const uint32_t *pinmmr_values, int reg_start, int reg_count);
147
148#define TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) \
149 (((((pin) & TMS570_PIN_NUM_MASK) >> 2 != (reg)) || ((pin) & TMS570_PIN_CLEAR_RQ_MASK))? 0: \
150 1 << ((((pin) & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT) + \
151 ((pin) & 3) * 8) \
152 )
153
154#define TMS570_PINMMR_REG_VAL_ACTION(reg, pin) \
155 TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) | \
156 ((pin) & TMS570_PIN_IN_ALT_MASK? \
157 TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, (pin) >> TMS570_PIN_IN_ALT_SHIFT ): \
158 0) |
159
173#define TMS570_PINMMR_REG_VAL(reg, pin_list) \
174 pin_list(TMS570_PINMMR_REG_VAL_ACTION, reg) 0
175
176#define TMS570_PINMMR_COMA_LIST_ACTION(reg, pin) \
177 (pin),
178
190#define TMS570_PINMMR_COMA_LIST(pin_list) \
191 pin_list(TMS570_PINMMR_COMA_LIST_ACTION, 0)
192
195#ifdef __cplusplus
196}
197#endif /* __cplusplus */
198
199#endif /* LIBBSP_ARM_TMS570_IRQ_H */
Definition: deflate.c:114
void tms570_bsp_pinmmr_config(const uint32_t *pinmmr_values, int reg_start, int reg_count)
configure block or whole pin multiplexer
Definition: pinmux.c:170
void tms570_bsp_pin_set_function(int pin_num, int pin_fnc)
select desired function of pin/ball
Definition: pinmux.c:80
void tms570_pin_config_array_apply(const uint32_t *config, size_t count)
Applies a pin configuration array.
Definition: pinmux.c:237
void tms570_bsp_pin_config_one(uint32_t pin_num_and_fnc)
configure one pin according to its function specification
Definition: pinmux.c:141
void tms570_pin_config_apply(uint32_t config)
Applies a pin configuration.
Definition: pinmux.c:222
void tms570_pin_config_complete(void)
Completes a pin configuration sequence.
Definition: pinmux.c:246
void tms570_pin_config_prepare(void)
Prepares a pin configuration sequence.
Definition: pinmux.c:194
void tms570_bsp_pin_clear_function(int pin_num, int pin_fnc)
clear connection between pin and specified peripherals/function
Definition: pinmux.c:105