![]() |
|
|||
File indexing completed on 2025-05-11 08:23:39
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSBSPsARMTMS570 0007 * 0008 * @brief This header file provides interfaces of the I/O Multiplexing Module 0009 * (IOMM) support. 0010 */ 0011 0012 /* 0013 * Copyright (C) 2015 Premysl Houdek <kom541000@gmail.com> 0014 * 0015 * Google Summer of Code 2014 at 0016 * Czech Technical University in Prague 0017 * Zikova 1903/4 0018 * 166 36 Praha 6 0019 * Czech Republic 0020 * 0021 * Redistribution and use in source and binary forms, with or without 0022 * modification, are permitted provided that the following conditions 0023 * are met: 0024 * 1. Redistributions of source code must retain the above copyright 0025 * notice, this list of conditions and the following disclaimer. 0026 * 2. Redistributions in binary form must reproduce the above copyright 0027 * notice, this list of conditions and the following disclaimer in the 0028 * documentation and/or other materials provided with the distribution. 0029 * 0030 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0031 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0032 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0033 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0034 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0035 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0036 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0037 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0038 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0039 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0040 * POSSIBILITY OF SUCH DAMAGE. 0041 */ 0042 0043 #ifndef LIBBSP_ARM_TMS570_PINMUX_H 0044 #define LIBBSP_ARM_TMS570_PINMUX_H 0045 0046 #include <stddef.h> 0047 #include <stdint.h> 0048 0049 #ifdef __cplusplus 0050 extern "C" { 0051 #endif /* __cplusplus */ 0052 0053 0054 #define TMS570_PIN_NUM_SHIFT 0 0055 #define TMS570_PIN_NUM_MASK 0x000007ff 0056 0057 /* 0058 * Request clear of interconnection in setup 0059 * to ensure that previous peripheral to pin 0060 * connection is not enabled in parallel to other one. 0061 * Mask is ored with pin number in such list. 0062 */ 0063 #define TMS570_PIN_CLEAR_RQ_MASK 0x00008000 0064 0065 #define TMS570_PIN_FNC_SHIFT 11 0066 #define TMS570_PIN_FNC_MASK 0x00007800 0067 0068 /** 0069 * @brief This constant indicates that all eight function bits associated with 0070 * the pin shall be cleared. 0071 * 0072 * Use it as a special value for the pin function in TMS570_PIN_AND_FNC(). 0073 */ 0074 #define TMS570_PIN_FNC_CLEAR 0x10U 0075 0076 #define TMS570_PIN_NUM_FNC_MASK 0x0000ffff 0077 0078 #define TMS570_PIN_IN_ALT_SHIFT 16 0079 #define TMS570_PIN_IN_ALT_MASK 0xffff0000 0080 0081 #define TMS570_PIN_FNC_AUTO (-1) 0082 0083 /** 0084 * @brief Defines the function of the pin. 0085 * 0086 * @param pin is the pin identifier. Use TMS570_BALL_WITH_MMR() to define the 0087 * pin identifier. 0088 * 0089 * param fnc is the pin function. The pin function shall be the function bit 0090 * index or TMS570_PIN_FNC_CLEAR. 0091 */ 0092 #define TMS570_PIN_AND_FNC(pin, fnc) \ 0093 ((pin) | ((fnc) << TMS570_PIN_FNC_SHIFT)) 0094 0095 #define TMS570_PIN_WITH_IN_ALT(pin_num_and_fnc, pin_in_alt_num_and_fnc) \ 0096 ((pin_num_and_fnc) | ((pin_in_alt_num_and_fnc) << TMS570_PIN_IN_ALT_SHIFT)) 0097 0098 #define TMS570_BALL_WITH_MMR(mmrx, pos) \ 0099 ((pos) | ((mmrx) << 2)) 0100 0101 /** 0102 * @brief Prepares a pin configuration sequence. 0103 * 0104 * Use tms570_pin_config_apply() to apply pin configurations. Use 0105 * tms570_pin_config_complete() to complete the pin configuration sequence. 0106 */ 0107 void tms570_pin_config_prepare(void); 0108 0109 /** 0110 * @brief Applies a pin configuration. 0111 * 0112 * This function can only be used if the pin configuration was prepared by 0113 * tms570_pin_config_prepare(). 0114 * 0115 * @param config is the pin configuration defined by TMS570_PIN_AND_FNC() or 0116 * TMS570_PIN_WITH_IN_ALT(). 0117 */ 0118 void tms570_pin_config_apply(uint32_t config); 0119 0120 /** 0121 * @brief Applies a pin configuration array. 0122 * 0123 * This function can only be used if the pin configuration was prepared by 0124 * tms570_pin_config_prepare(). 0125 * 0126 * @param config is the pin configuration array. Calls 0127 * tms570_pin_config_apply() for each pin configuration in the array. 0128 * 0129 * @param count is the element count of the pin configuration array. 0130 */ 0131 void tms570_pin_config_array_apply(const uint32_t *config, size_t count); 0132 0133 /** 0134 * @brief Completes a pin configuration sequence. 0135 */ 0136 void tms570_pin_config_complete(void); 0137 0138 /* Generic functions select pin to peripheral connection */ 0139 0140 void tms570_bsp_pin_set_function(int pin_num, int pin_fnc); 0141 0142 void tms570_bsp_pin_clear_function(int pin_num, int pin_fnc); 0143 0144 void tms570_bsp_pin_config_one(uint32_t pin_num_and_fnc); 0145 0146 void tms570_bsp_pinmmr_config(const uint32_t *pinmmr_values, int reg_start, int reg_count); 0147 0148 #define TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) \ 0149 (((((pin) & TMS570_PIN_NUM_MASK) >> 2 != (reg)) || ((pin) & TMS570_PIN_CLEAR_RQ_MASK))? 0: \ 0150 1 << ((((pin) & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT) + \ 0151 ((pin) & 3) * 8) \ 0152 ) 0153 0154 #define TMS570_PINMMR_REG_VAL_ACTION(reg, pin) \ 0155 TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) | \ 0156 ((pin) & TMS570_PIN_IN_ALT_MASK? \ 0157 TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, (pin) >> TMS570_PIN_IN_ALT_SHIFT ): \ 0158 0) | 0159 0160 /** 0161 * Macro which computes value for PINMMRx register from pin list 0162 * which is defined as macro calling action macro for each pin 0163 * 0164 * @param reg PINMMR register number (0 .. 30 for TMS570LS3137) 0165 * @param pin_list declared as macro with parameters 0166 * \c per_pin_action and \c common_arg which expands 0167 * to list of \c per_pin_action(\c common_arg, \c TMS570_BALL_xx_function) 0168 * 0169 * @retval number which represents connections which should be enabled 0170 * in given PINMMR register. Pin setup for other registers than specified 0171 * are ignored 0172 */ 0173 #define TMS570_PINMMR_REG_VAL(reg, pin_list) \ 0174 pin_list(TMS570_PINMMR_REG_VAL_ACTION, reg) 0 0175 0176 #define TMS570_PINMMR_COMA_LIST_ACTION(reg, pin) \ 0177 (pin), 0178 0179 /** 0180 * Macro which generates list of pin and function specification from 0181 * from pin list which is defined as macro calling action macro for each pin 0182 * 0183 * @param pin_list declared as macro with parameters 0184 * \c per_pin_action and \c common_arg which expands 0185 * to list of \c per_pin_action(\c common_arg, \c TMS570_BALL_xx_function) 0186 * 0187 * @retval list of coma separated pin+function combined values which is terminated by coma 0188 * at the end 0189 */ 0190 #define TMS570_PINMMR_COMA_LIST(pin_list) \ 0191 pin_list(TMS570_PINMMR_COMA_LIST_ACTION, 0) 0192 0193 /** @} */ 0194 0195 #ifdef __cplusplus 0196 } 0197 #endif /* __cplusplus */ 0198 0199 #endif /* LIBBSP_ARM_TMS570_IRQ_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |