Changeset 9d09f497 in rtems
- Timestamp:
- 06/20/16 16:55:49 (7 years ago)
- Branches:
- 4.11
- Children:
- d830414e
- Parents:
- 529d0751
- git-author:
- Pavel Pisa <pisa@…> (06/20/16 16:55:49)
- git-committer:
- Pavel Pisa <pisa@…> (10/02/16 09:31:18)
- Location:
- c/src/lib/libbsp/arm/tms570
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/arm/tms570/Makefile.am
r529d0751 r9d09f497 43 43 include_bsp_HEADERS += include/system-clocks.h 44 44 include_bsp_HEADERS += include/tms570-pinmux.h 45 46 include_bsp_HEADERS += include/tms570-pins.h 47 include_bsp_HEADERS += include/tms570ls3137zwt-pins.h 45 48 46 49 include_bsp_ti_hercules_HEADERS = include/ti_herc/reg_adc.h -
c/src/lib/libbsp/arm/tms570/include/tms570-pinmux.h
r529d0751 r9d09f497 32 32 33 33 34 #define TMS570_PIN_NUM_SHIFT 035 #define TMS570_PIN_NUM_MASK 0x0fff34 #define TMS570_PIN_NUM_SHIFT 0 35 #define TMS570_PIN_NUM_MASK 0x000007ff 36 36 37 #define TMS570_PIN_FNC_SHIFT 12 38 #define TMS570_PIN_FNC_MASK 0xf000 37 /* 38 * Request clear of interconnection in setup 39 * to ensure that previous peripheral to pin 40 * connection is not enabled in parallel to other one. 41 * Mask is ored with pin number in such list. 42 */ 43 #define TMS570_PIN_CLEAR_RQ_MASK 0x00000800 44 45 #define TMS570_PIN_FNC_SHIFT 12 46 #define TMS570_PIN_FNC_MASK 0x0000f000 47 48 #define TMS570_PIN_NUM_FNC_MASK 0x0000ffff 49 50 #define TMS570_PIN_IN_ALT_SHIFT 16 51 #define TMS570_PIN_IN_ALT_MASK 0xffff0000 39 52 40 53 #define TMS570_PIN_FNC_AUTO (-1) 41 54 42 55 #define TMS570_PIN_AND_FNC(pin, fnc) \ 43 ((pin) | ((fnc)<<TMS570_PIN_FNC_SHIFT)) 56 ((pin) | ((fnc) << TMS570_PIN_FNC_SHIFT)) 57 58 #define TMS570_PIN_WITH_IN_ALT(pin_num_and_fnc, pin_in_alt_num_and_fnc) \ 59 ((pin_num_and_fnc) | ((pin_in_alt_num_and_fnc) << TMS570_PIN_IN_ALT_SHIFT)) 44 60 45 61 #define TMS570_BALL_WITH_MMR(mmrx, pos) \ 46 ((pos) | ((mmrx)<<2)) 47 48 /* Definition for pins/balls which has to be set for Ethernet MII */ 49 50 #define TMS570_BALL_C3 TMS570_BALL_WITH_MMR(0, 2) 51 #define TMS570_BALL_C3_MIBSPI3NCS_3 TMS570_PIN_AND_FNC(TMS570_BALL_C3, 0) 52 #define TMS570_BALL_C3_I2C_SCL TMS570_PIN_AND_FNC(TMS570_BALL_C3, 1) 53 54 #define TMS570_BALL_F3 TMS570_BALL_WITH_MMR(20, 2) 55 #define TMS570_BALL_F3_MII_COL TMS570_PIN_AND_FNC(TMS570_BALL_F3, 2) 56 57 #define TMS570_BALL_B4 TMS570_BALL_WITH_MMR(17, 2) 58 #define TMS570_BALL_B4_MII_CRS TMS570_PIN_AND_FNC(TMS570_BALL_B4, 1) 59 60 #define TMS570_BALL_B11 TMS570_BALL_WITH_MMR(19, 1) 61 #define TMS570_BALL_B11_MII_RX_DV TMS570_PIN_AND_FNC(TMS570_BALL_B11, 1) 62 63 #define TMS570_BALL_N19 TMS570_BALL_WITH_MMR(10, 0) 64 #define TMS570_BALL_N19_MII_RX_ER TMS570_PIN_AND_FNC(TMS570_BALL_N19, 1) 65 66 #define TMS570_BALL_K19 TMS570_BALL_WITH_MMR(14, 1) 67 #define TMS570_BALL_K19_MII_RX_CLK TMS570_PIN_AND_FNC(TMS570_BALL_K19, 1) 68 69 #define TMS570_BALL_P1 TMS570_BALL_WITH_MMR(11, 3) 70 #define TMS570_BALL_P1_MII_RXD_0 TMS570_PIN_AND_FNC(TMS570_BALL_P1, 2) 71 72 #define TMS570_BALL_A14 TMS570_BALL_WITH_MMR(12, 0) 73 #define TMS570_BALL_A14_MII_RXD_1 TMS570_PIN_AND_FNC(TMS570_BALL_A14, 1) 74 75 #define TMS570_BALL_G19 TMS570_BALL_WITH_MMR(12, 2) 76 #define TMS570_BALL_G19_MII_RXD_2 TMS570_PIN_AND_FNC(TMS570_BALL_G19, 2) 77 78 #define TMS570_BALL_H18 TMS570_BALL_WITH_MMR(12, 3) 79 #define TMS570_BALL_H18_MII_RXD_3 TMS570_PIN_AND_FNC(TMS570_BALL_H18, 2) 80 81 #define TMS570_BALL_D19 TMS570_BALL_WITH_MMR(17, 0) 82 #define TMS570_BALL_D19_MII_TX_CLK TMS570_PIN_AND_FNC(TMS570_BALL_D19, 1) 83 84 #define TMS570_BALL_J18 TMS570_BALL_WITH_MMR(13, 0) 85 #define TMS570_BALL_J18_MII_TXD_0 TMS570_PIN_AND_FNC(TMS570_BALL_J18, 2) 86 87 #define TMS570_BALL_J19 TMS570_BALL_WITH_MMR(13, 1) 88 #define TMS570_BALL_J19_MII_TXD_1 TMS570_PIN_AND_FNC(TMS570_BALL_J19, 2) 89 90 #define TMS570_BALL_R2 TMS570_BALL_WITH_MMR(13, 3) 91 #define TMS570_BALL_R2_MII_TXD_2 TMS570_PIN_AND_FNC(TMS570_BALL_R2, 2) 92 93 #define TMS570_BALL_E18 TMS570_BALL_WITH_MMR(14, 0) 94 #define TMS570_BALL_E18_MII_TXD_3 TMS570_PIN_AND_FNC(TMS570_BALL_E18, 2) 95 96 #define TMS570_BALL_H19 TMS570_BALL_WITH_MMR(13, 2) 97 #define TMS570_BALL_H19_MII_TXEN TMS570_PIN_AND_FNC(TMS570_BALL_H19, 2) 98 99 #define TMS570_BALL_V5 TMS570_BALL_WITH_MMR(7, 1) 100 #define TMS570_BALL_V5_MDCLK TMS570_PIN_AND_FNC(TMS570_BALL_V5, 2) 101 102 #define TMS570_BALL_G3 TMS570_BALL_WITH_MMR(8, 1) 103 #define TMS570_BALL_G3_MDIO TMS570_PIN_AND_FNC(TMS570_BALL_G3, 2) 104 105 #define TMS570_BALL_XX TMS570_BALL_WITH_MMR(29, 3) 106 #define TMS570_BALL_XX_GMII_SEL TMS570_PIN_AND_FNC(TMS570_BALL_XX, 0) 62 ((pos) | ((mmrx) << 2)) 107 63 108 64 /* Generic functions select pin to peripheral connection */ … … 111 67 112 68 void tms570_bsp_pin_clear_function(int pin_num, int pin_fnc); 69 70 void tms570_bsp_pin_config_one(uint32_t pin_num_and_fnc); 71 72 void tms570_bsp_pinmmr_config(const uint32_t *pinmmr_values, int reg_start, int reg_count); 113 73 114 74 static inline void … … 121 81 } 122 82 83 #define TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) \ 84 (((((pin) & TMS570_PIN_NUM_MASK) >> 2 != (reg)) || ((pin) & TMS570_PIN_CLEAR_RQ_MASK))? 0: \ 85 1 << ((((pin) & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT) + \ 86 ((pin) & 3) * 8) \ 87 ) 88 89 #define TMS570_PINMMR_REG_VAL_ACTION(reg, pin) \ 90 TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) | \ 91 ((pin) & TMS570_PIN_IN_ALT_MASK? \ 92 TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, (pin) >> TMS570_PIN_IN_ALT_SHIFT ): \ 93 0) | 94 95 /** 96 * Macro which computes value for PINMMRx register from pin list 97 * which is defined as macro calling action macro for each pin 98 * 99 * @param reg PINMMR register number (0 .. 30 for TMS570LS3137) 100 * @param pin_list declared as macro with parameters 101 * \c per_pin_action and \c common_arg which expands 102 * to list of \c per_pin_action(\c common_arg, \c TMS570_BALL_xx_function) 103 * 104 * @retval number which represents connections which should be enabled 105 * in given PINMMR register. Pin setup for other registers than specified 106 * are ignored 107 */ 108 #define TMS570_PINMMR_REG_VAL(reg, pin_list) \ 109 pin_list(TMS570_PINMMR_REG_VAL_ACTION, reg) 0 110 111 #define TMS570_PINMMR_COMA_LIST_ACTION(reg, pin) \ 112 (pin), 113 114 /** 115 * Macro which generates list of pin and function specification from 116 * from pin list which is defined as macro calling action macro for each pin 117 * 118 * @param pin_list declared as macro with parameters 119 * \c per_pin_action and \c common_arg which expands 120 * to list of \c per_pin_action(\c common_arg, \c TMS570_BALL_xx_function) 121 * 122 * @retval list of coma separated pin+function combined values which is terminated by coma 123 * at the end 124 */ 125 #define TMS570_PINMMR_COMA_LIST(pin_list) \ 126 pin_list(TMS570_PINMMR_COMA_LIST_ACTION, 0) 127 128 123 129 #endif 124 130 -
c/src/lib/libbsp/arm/tms570/include/tms570.h
r529d0751 r9d09f497 39 39 #ifndef LIBBSP_ARM_TMS570 40 40 #define LIBBSP_ARM_TMS570 41 42 #include <bsp/tms570-pins.h> 43 41 44 #include <bsp/ti_herc/reg_adc.h> 42 45 #include <bsp/ti_herc/reg_ccmsr.h> -
c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c
r529d0751 r9d09f497 23 23 #include <bsp/tms570.h> 24 24 #include <bsp/tms570-pinmux.h> 25 #include <bsp/irq.h> 26 27 uint32_t tms570_bsp_pinmmr_kick_key0 = 0x83E70B13U; 28 uint32_t tms570_bsp_pinmmr_kick_key1 = 0x95A4F1E0U; 25 29 26 30 /** … … 30 34 * specified function/peripheral. Pin number is index into pinmux 31 35 * entries array. Predefined values for pins are in a format 32 * TMS570_BALL_ <column><row> (for exampleTMS570_BALL_N19).36 * TMS570_BALL_ \c column \c row (for example \c TMS570_BALL_N19). 33 37 * The multiplexer allows to interconnect one pin to multiple 34 38 * signal sources/sinks in the theory but it is usually bad choice. … … 36 40 * connections. 37 41 * 38 * @param[in] pin_num pin/ball identifier (index into pinmux array) 39 * @param[in] pin_fnc function number 0 .. 7, if value TMS570_PIN_FNC_AUTO42 * @param[in] pin_num pin/ball identifier (index into pinmux array), 43 * @param[in] pin_fnc function number 0 .. 7, if value \c TMS570_PIN_FNC_AUTO 40 44 * is specified then pin function is extracted from 41 45 * pin_num argument … … 62 66 * 63 67 * @param[in] pin_num pin/ball identifier (index into pinmux array) 64 * @param[in] pin_fnc function number 0 .. 7, if value TMS570_PIN_FNC_AUTO68 * @param[in] pin_fnc function number 0 .. 7, if value \c TMS570_PIN_FNC_AUTO 65 69 * is specified then pin function is extracted from 66 70 * pin_num argument … … 79 83 *pinmmrx = *pinmmrx & ~(1 << (pin_fnc+pin_shift)); 80 84 } 85 86 /** 87 * @brief configure one pin according to its function specification 88 * 89 * The function setups multiplexer to interconnect pin with 90 * specified function/peripheral. Predefined values for pins combined with 91 * function are in a format TMS570_BALL_ \c column \c row \c function 92 * (for example \c TMS570_BALL_W3_SCIRX). 93 * If the function can be connected to more pins then specification 94 * includes infomation which allows to disconnect alternative pin to peripheral 95 * input connection or switch input multiplexer to right pin. 96 * 97 * @param[in] pin_num_and_fnc pin function descriptor is build by macro 98 * \c TMS570_PIN_AND_FNC which takes pin/pinmmr specification 99 * build by \c TMS570_BALL_WITH_MMR and function index in output 100 * multiplexer. If the peripheral can be connected to other input 101 * alternative then actual pin description and alternative to 102 * disconnected/reconnect are combined together by 103 * \c TMS570_PIN_WITH_IN_ALT macro. If clear of alternative 104 * connection is required then flag \c TMS570_PIN_CLEAR_RQ_MASK 105 * is ored to alternative description. 106 * 107 * @retval Void 108 */ 109 void 110 tms570_bsp_pin_config_one(uint32_t pin_num_and_fnc) 111 { 112 rtems_interrupt_level intlev; 113 uint32_t pin_in_alt; 114 115 rtems_interrupt_disable(intlev); 116 117 TMS570_IOMM.KICK_REG0 = tms570_bsp_pinmmr_kick_key0; 118 TMS570_IOMM.KICK_REG1 = tms570_bsp_pinmmr_kick_key1; 119 120 pin_in_alt = pin_num_and_fnc & TMS570_PIN_IN_ALT_MASK; 121 if ( pin_in_alt ) { 122 pin_in_alt >>= TMS570_PIN_IN_ALT_SHIFT; 123 if ( pin_in_alt & TMS570_PIN_CLEAR_RQ_MASK ) { 124 tms570_bsp_pin_clear_function(pin_in_alt, TMS570_PIN_FNC_AUTO); 125 } else { 126 tms570_bsp_pin_set_function(pin_in_alt, TMS570_PIN_FNC_AUTO); 127 } 128 } 129 130 pin_num_and_fnc &= TMS570_PIN_NUM_FNC_MASK; 131 if ( pin_num_and_fnc & TMS570_PIN_CLEAR_RQ_MASK ) { 132 tms570_bsp_pin_clear_function(pin_num_and_fnc, TMS570_PIN_FNC_AUTO); 133 } else { 134 tms570_bsp_pin_set_function(pin_num_and_fnc, TMS570_PIN_FNC_AUTO); 135 } 136 137 TMS570_IOMM.KICK_REG0 = 0; 138 TMS570_IOMM.KICK_REG1 = 0; 139 140 rtems_interrupt_enable(intlev); 141 } 142 143 /** 144 * @brief configure block or whole pin multiplexer 145 * 146 * Function change multiplexer content. It is intended for initial 147 * chip setup and does not use locking. If complete reconfiguration 148 * is required at runtime then it is application responsibility 149 * to protect and serialize change with peripherals drivers 150 * and parallel calls 151 * 152 * @param[in] pinmmr_values pointer to array with required multiplexer setup 153 * @param[in] reg_start starting register, this allows to configure non-consecutive 154 * registers groups found on some MCU family members 155 * @param[in] reg_count number of words in initialization array to set 156 * to corresponding registers 157 * 158 * @retval Void 159 */ 160 void 161 tms570_bsp_pinmmr_config(const uint32_t *pinmmr_values, int reg_start, int reg_count) 162 { 163 volatile uint32_t *pinmmrx; 164 const uint32_t *pval; 165 int cnt; 166 167 if ( reg_count <= 0) 168 return; 169 170 TMS570_IOMM.KICK_REG0 = tms570_bsp_pinmmr_kick_key0; 171 TMS570_IOMM.KICK_REG1 = tms570_bsp_pinmmr_kick_key1; 172 173 pinmmrx = (&TMS570_IOMM.PINMUX.PINMMR0) + reg_start; 174 pval = pinmmr_values; 175 cnt = reg_count; 176 177 do { 178 *pinmmrx = *pinmmrx & *pval; 179 pinmmrx++; 180 pval++; 181 } while( --cnt ); 182 183 pinmmrx = (&TMS570_IOMM.PINMUX.PINMMR0) + reg_start; 184 pval = pinmmr_values; 185 cnt = reg_count; 186 187 do { 188 *pinmmrx = *pval; 189 pinmmrx++; 190 pval++; 191 } while( --cnt ); 192 193 TMS570_IOMM.KICK_REG0 = 0; 194 TMS570_IOMM.KICK_REG1 = 0; 195 }
Note: See TracChangeset
for help on using the changeset viewer.