mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 12:34:45 +00:00
bsp/tms570: update pinmux to provide support for initialization lists and clear of alt outputs.
This commit is contained in:
@@ -43,6 +43,9 @@ include_bsp_HEADERS += include/tms570-sci-driver.h
|
||||
include_bsp_HEADERS += include/system-clocks.h
|
||||
include_bsp_HEADERS += include/tms570-pinmux.h
|
||||
|
||||
include_bsp_HEADERS += include/tms570-pins.h
|
||||
include_bsp_HEADERS += include/tms570ls3137zwt-pins.h
|
||||
|
||||
include_bsp_ti_hercules_HEADERS = include/ti_herc/reg_adc.h
|
||||
include_bsp_ti_hercules_HEADERS += include/ti_herc/reg_ccmsr.h
|
||||
include_bsp_ti_hercules_HEADERS += include/ti_herc/reg_crc.h
|
||||
|
||||
@@ -31,79 +31,35 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#define TMS570_PIN_NUM_SHIFT 0
|
||||
#define TMS570_PIN_NUM_MASK 0x0fff
|
||||
#define TMS570_PIN_NUM_SHIFT 0
|
||||
#define TMS570_PIN_NUM_MASK 0x000007ff
|
||||
|
||||
#define TMS570_PIN_FNC_SHIFT 12
|
||||
#define TMS570_PIN_FNC_MASK 0xf000
|
||||
/*
|
||||
* Request clear of interconnection in setup
|
||||
* to ensure that previous peripheral to pin
|
||||
* connection is not enabled in parallel to other one.
|
||||
* Mask is ored with pin number in such list.
|
||||
*/
|
||||
#define TMS570_PIN_CLEAR_RQ_MASK 0x00000800
|
||||
|
||||
#define TMS570_PIN_FNC_SHIFT 12
|
||||
#define TMS570_PIN_FNC_MASK 0x0000f000
|
||||
|
||||
#define TMS570_PIN_NUM_FNC_MASK 0x0000ffff
|
||||
|
||||
#define TMS570_PIN_IN_ALT_SHIFT 16
|
||||
#define TMS570_PIN_IN_ALT_MASK 0xffff0000
|
||||
|
||||
#define TMS570_PIN_FNC_AUTO (-1)
|
||||
|
||||
#define TMS570_PIN_AND_FNC(pin, fnc) \
|
||||
((pin) | ((fnc)<<TMS570_PIN_FNC_SHIFT))
|
||||
((pin) | ((fnc) << TMS570_PIN_FNC_SHIFT))
|
||||
|
||||
#define TMS570_PIN_WITH_IN_ALT(pin_num_and_fnc, pin_in_alt_num_and_fnc) \
|
||||
((pin_num_and_fnc) | ((pin_in_alt_num_and_fnc) << TMS570_PIN_IN_ALT_SHIFT))
|
||||
|
||||
#define TMS570_BALL_WITH_MMR(mmrx, pos) \
|
||||
((pos) | ((mmrx)<<2))
|
||||
|
||||
/* Definition for pins/balls which has to be set for Ethernet MII */
|
||||
|
||||
#define TMS570_BALL_C3 TMS570_BALL_WITH_MMR(0, 2)
|
||||
#define TMS570_BALL_C3_MIBSPI3NCS_3 TMS570_PIN_AND_FNC(TMS570_BALL_C3, 0)
|
||||
#define TMS570_BALL_C3_I2C_SCL TMS570_PIN_AND_FNC(TMS570_BALL_C3, 1)
|
||||
|
||||
#define TMS570_BALL_F3 TMS570_BALL_WITH_MMR(20, 2)
|
||||
#define TMS570_BALL_F3_MII_COL TMS570_PIN_AND_FNC(TMS570_BALL_F3, 2)
|
||||
|
||||
#define TMS570_BALL_B4 TMS570_BALL_WITH_MMR(17, 2)
|
||||
#define TMS570_BALL_B4_MII_CRS TMS570_PIN_AND_FNC(TMS570_BALL_B4, 1)
|
||||
|
||||
#define TMS570_BALL_B11 TMS570_BALL_WITH_MMR(19, 1)
|
||||
#define TMS570_BALL_B11_MII_RX_DV TMS570_PIN_AND_FNC(TMS570_BALL_B11, 1)
|
||||
|
||||
#define TMS570_BALL_N19 TMS570_BALL_WITH_MMR(10, 0)
|
||||
#define TMS570_BALL_N19_MII_RX_ER TMS570_PIN_AND_FNC(TMS570_BALL_N19, 1)
|
||||
|
||||
#define TMS570_BALL_K19 TMS570_BALL_WITH_MMR(14, 1)
|
||||
#define TMS570_BALL_K19_MII_RX_CLK TMS570_PIN_AND_FNC(TMS570_BALL_K19, 1)
|
||||
|
||||
#define TMS570_BALL_P1 TMS570_BALL_WITH_MMR(11, 3)
|
||||
#define TMS570_BALL_P1_MII_RXD_0 TMS570_PIN_AND_FNC(TMS570_BALL_P1, 2)
|
||||
|
||||
#define TMS570_BALL_A14 TMS570_BALL_WITH_MMR(12, 0)
|
||||
#define TMS570_BALL_A14_MII_RXD_1 TMS570_PIN_AND_FNC(TMS570_BALL_A14, 1)
|
||||
|
||||
#define TMS570_BALL_G19 TMS570_BALL_WITH_MMR(12, 2)
|
||||
#define TMS570_BALL_G19_MII_RXD_2 TMS570_PIN_AND_FNC(TMS570_BALL_G19, 2)
|
||||
|
||||
#define TMS570_BALL_H18 TMS570_BALL_WITH_MMR(12, 3)
|
||||
#define TMS570_BALL_H18_MII_RXD_3 TMS570_PIN_AND_FNC(TMS570_BALL_H18, 2)
|
||||
|
||||
#define TMS570_BALL_D19 TMS570_BALL_WITH_MMR(17, 0)
|
||||
#define TMS570_BALL_D19_MII_TX_CLK TMS570_PIN_AND_FNC(TMS570_BALL_D19, 1)
|
||||
|
||||
#define TMS570_BALL_J18 TMS570_BALL_WITH_MMR(13, 0)
|
||||
#define TMS570_BALL_J18_MII_TXD_0 TMS570_PIN_AND_FNC(TMS570_BALL_J18, 2)
|
||||
|
||||
#define TMS570_BALL_J19 TMS570_BALL_WITH_MMR(13, 1)
|
||||
#define TMS570_BALL_J19_MII_TXD_1 TMS570_PIN_AND_FNC(TMS570_BALL_J19, 2)
|
||||
|
||||
#define TMS570_BALL_R2 TMS570_BALL_WITH_MMR(13, 3)
|
||||
#define TMS570_BALL_R2_MII_TXD_2 TMS570_PIN_AND_FNC(TMS570_BALL_R2, 2)
|
||||
|
||||
#define TMS570_BALL_E18 TMS570_BALL_WITH_MMR(14, 0)
|
||||
#define TMS570_BALL_E18_MII_TXD_3 TMS570_PIN_AND_FNC(TMS570_BALL_E18, 2)
|
||||
|
||||
#define TMS570_BALL_H19 TMS570_BALL_WITH_MMR(13, 2)
|
||||
#define TMS570_BALL_H19_MII_TXEN TMS570_PIN_AND_FNC(TMS570_BALL_H19, 2)
|
||||
|
||||
#define TMS570_BALL_V5 TMS570_BALL_WITH_MMR(7, 1)
|
||||
#define TMS570_BALL_V5_MDCLK TMS570_PIN_AND_FNC(TMS570_BALL_V5, 2)
|
||||
|
||||
#define TMS570_BALL_G3 TMS570_BALL_WITH_MMR(8, 1)
|
||||
#define TMS570_BALL_G3_MDIO TMS570_PIN_AND_FNC(TMS570_BALL_G3, 2)
|
||||
|
||||
#define TMS570_BALL_XX TMS570_BALL_WITH_MMR(29, 3)
|
||||
#define TMS570_BALL_XX_GMII_SEL TMS570_PIN_AND_FNC(TMS570_BALL_XX, 0)
|
||||
((pos) | ((mmrx) << 2))
|
||||
|
||||
/* Generic functions select pin to peripheral connection */
|
||||
|
||||
@@ -111,6 +67,10 @@ void tms570_bsp_pin_set_function(int pin_num, int pin_fnc);
|
||||
|
||||
void tms570_bsp_pin_clear_function(int pin_num, int pin_fnc);
|
||||
|
||||
void tms570_bsp_pin_config_one(uint32_t pin_num_and_fnc);
|
||||
|
||||
void tms570_bsp_pinmmr_config(const uint32_t *pinmmr_values, int reg_start, int reg_count);
|
||||
|
||||
static inline void
|
||||
tms570_bsp_pin_to_pinmmrx(volatile uint32_t **pinmmrx, unsigned int *pin_shift,
|
||||
int pin_num)
|
||||
@@ -120,6 +80,52 @@ tms570_bsp_pin_to_pinmmrx(volatile uint32_t **pinmmrx, unsigned int *pin_shift,
|
||||
*pin_shift = (pin_num & 0x3)*8;
|
||||
}
|
||||
|
||||
#define TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) \
|
||||
(((((pin) & TMS570_PIN_NUM_MASK) >> 2 != (reg)) || ((pin) & TMS570_PIN_CLEAR_RQ_MASK))? 0: \
|
||||
1 << ((((pin) & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT) + \
|
||||
((pin) & 3) * 8) \
|
||||
)
|
||||
|
||||
#define TMS570_PINMMR_REG_VAL_ACTION(reg, pin) \
|
||||
TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, pin) | \
|
||||
((pin) & TMS570_PIN_IN_ALT_MASK? \
|
||||
TMS570_PINMMR_REG_SINGLE_VAL_ACTION(reg, (pin) >> TMS570_PIN_IN_ALT_SHIFT ): \
|
||||
0) |
|
||||
|
||||
/**
|
||||
* Macro which computes value for PINMMRx register from pin list
|
||||
* which is defined as macro calling action macro for each pin
|
||||
*
|
||||
* @param reg PINMMR register number (0 .. 30 for TMS570LS3137)
|
||||
* @param pin_list declared as macro with parameters
|
||||
* \c per_pin_action and \c common_arg which expands
|
||||
* to list of \c per_pin_action(\c common_arg, \c TMS570_BALL_xx_function)
|
||||
*
|
||||
* @retval number which represents connections which should be enabled
|
||||
* in given PINMMR register. Pin setup for other registers than specified
|
||||
* are ignored
|
||||
*/
|
||||
#define TMS570_PINMMR_REG_VAL(reg, pin_list) \
|
||||
pin_list(TMS570_PINMMR_REG_VAL_ACTION, reg) 0
|
||||
|
||||
#define TMS570_PINMMR_COMA_LIST_ACTION(reg, pin) \
|
||||
(pin),
|
||||
|
||||
/**
|
||||
* Macro which generates list of pin and function specification from
|
||||
* from pin list which is defined as macro calling action macro for each pin
|
||||
*
|
||||
* @param pin_list declared as macro with parameters
|
||||
* \c per_pin_action and \c common_arg which expands
|
||||
* to list of \c per_pin_action(\c common_arg, \c TMS570_BALL_xx_function)
|
||||
*
|
||||
* @retval list of coma separated pin+function combined values which is terminated by coma
|
||||
* at the end
|
||||
*/
|
||||
#define TMS570_PINMMR_COMA_LIST(pin_list) \
|
||||
pin_list(TMS570_PINMMR_COMA_LIST_ACTION, 0)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
*/
|
||||
#ifndef LIBBSP_ARM_TMS570
|
||||
#define LIBBSP_ARM_TMS570
|
||||
|
||||
#include <bsp/tms570-pins.h>
|
||||
|
||||
#include <bsp/ti_herc/reg_adc.h>
|
||||
#include <bsp/ti_herc/reg_ccmsr.h>
|
||||
#include <bsp/ti_herc/reg_crc.h>
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
|
||||
#include <bsp/tms570.h>
|
||||
#include <bsp/tms570-pinmux.h>
|
||||
#include <bsp/irq.h>
|
||||
|
||||
uint32_t tms570_bsp_pinmmr_kick_key0 = 0x83E70B13U;
|
||||
uint32_t tms570_bsp_pinmmr_kick_key1 = 0x95A4F1E0U;
|
||||
|
||||
/**
|
||||
* @brief select desired function of pin/ball
|
||||
@@ -29,14 +33,14 @@
|
||||
* The function setups multiplexer to interconnect pin with
|
||||
* specified function/peripheral. Pin number is index into pinmux
|
||||
* entries array. Predefined values for pins are in a format
|
||||
* TMS570_BALL_<column><row> (for example TMS570_BALL_N19).
|
||||
* TMS570_BALL_ \c column \c row (for example \c TMS570_BALL_N19).
|
||||
* The multiplexer allows to interconnect one pin to multiple
|
||||
* signal sources/sinks in the theory but it is usually bad choice.
|
||||
* The function sets only specified function and clears all other
|
||||
* connections.
|
||||
*
|
||||
* @param[in] pin_num pin/ball identifier (index into pinmux array)
|
||||
* @param[in] pin_fnc function number 0 .. 7, if value TMS570_PIN_FNC_AUTO
|
||||
* @param[in] pin_num pin/ball identifier (index into pinmux array),
|
||||
* @param[in] pin_fnc function number 0 .. 7, if value \c TMS570_PIN_FNC_AUTO
|
||||
* is specified then pin function is extracted from
|
||||
* pin_num argument
|
||||
* @retval Void
|
||||
@@ -61,7 +65,7 @@ tms570_bsp_pin_set_function(int pin_num, int pin_fnc)
|
||||
* of multiplexer setup intact.
|
||||
*
|
||||
* @param[in] pin_num pin/ball identifier (index into pinmux array)
|
||||
* @param[in] pin_fnc function number 0 .. 7, if value TMS570_PIN_FNC_AUTO
|
||||
* @param[in] pin_fnc function number 0 .. 7, if value \c TMS570_PIN_FNC_AUTO
|
||||
* is specified then pin function is extracted from
|
||||
* pin_num argument
|
||||
* @retval Void
|
||||
@@ -78,3 +82,114 @@ tms570_bsp_pin_clear_function(int pin_num, int pin_fnc)
|
||||
tms570_bsp_pin_to_pinmmrx(&pinmmrx, &pin_shift, pin_num);
|
||||
*pinmmrx = *pinmmrx & ~(1 << (pin_fnc+pin_shift));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief configure one pin according to its function specification
|
||||
*
|
||||
* The function setups multiplexer to interconnect pin with
|
||||
* specified function/peripheral. Predefined values for pins combined with
|
||||
* function are in a format TMS570_BALL_ \c column \c row \c function
|
||||
* (for example \c TMS570_BALL_W3_SCIRX).
|
||||
* If the function can be connected to more pins then specification
|
||||
* includes infomation which allows to disconnect alternative pin to peripheral
|
||||
* input connection or switch input multiplexer to right pin.
|
||||
*
|
||||
* @param[in] pin_num_and_fnc pin function descriptor is build by macro
|
||||
* \c TMS570_PIN_AND_FNC which takes pin/pinmmr specification
|
||||
* build by \c TMS570_BALL_WITH_MMR and function index in output
|
||||
* multiplexer. If the peripheral can be connected to other input
|
||||
* alternative then actual pin description and alternative to
|
||||
* disconnected/reconnect are combined together by
|
||||
* \c TMS570_PIN_WITH_IN_ALT macro. If clear of alternative
|
||||
* connection is required then flag \c TMS570_PIN_CLEAR_RQ_MASK
|
||||
* is ored to alternative description.
|
||||
*
|
||||
* @retval Void
|
||||
*/
|
||||
void
|
||||
tms570_bsp_pin_config_one(uint32_t pin_num_and_fnc)
|
||||
{
|
||||
rtems_interrupt_level intlev;
|
||||
uint32_t pin_in_alt;
|
||||
|
||||
rtems_interrupt_disable(intlev);
|
||||
|
||||
TMS570_IOMM.KICK_REG0 = tms570_bsp_pinmmr_kick_key0;
|
||||
TMS570_IOMM.KICK_REG1 = tms570_bsp_pinmmr_kick_key1;
|
||||
|
||||
pin_in_alt = pin_num_and_fnc & TMS570_PIN_IN_ALT_MASK;
|
||||
if ( pin_in_alt ) {
|
||||
pin_in_alt >>= TMS570_PIN_IN_ALT_SHIFT;
|
||||
if ( pin_in_alt & TMS570_PIN_CLEAR_RQ_MASK ) {
|
||||
tms570_bsp_pin_clear_function(pin_in_alt, TMS570_PIN_FNC_AUTO);
|
||||
} else {
|
||||
tms570_bsp_pin_set_function(pin_in_alt, TMS570_PIN_FNC_AUTO);
|
||||
}
|
||||
}
|
||||
|
||||
pin_num_and_fnc &= TMS570_PIN_NUM_FNC_MASK;
|
||||
if ( pin_num_and_fnc & TMS570_PIN_CLEAR_RQ_MASK ) {
|
||||
tms570_bsp_pin_clear_function(pin_num_and_fnc, TMS570_PIN_FNC_AUTO);
|
||||
} else {
|
||||
tms570_bsp_pin_set_function(pin_num_and_fnc, TMS570_PIN_FNC_AUTO);
|
||||
}
|
||||
|
||||
TMS570_IOMM.KICK_REG0 = 0;
|
||||
TMS570_IOMM.KICK_REG1 = 0;
|
||||
|
||||
rtems_interrupt_enable(intlev);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief configure block or whole pin multiplexer
|
||||
*
|
||||
* Function change multiplexer content. It is intended for initial
|
||||
* chip setup and does not use locking. If complete reconfiguration
|
||||
* is required at runtime then it is application responsibility
|
||||
* to protect and serialize change with peripherals drivers
|
||||
* and parallel calls
|
||||
*
|
||||
* @param[in] pinmmr_values pointer to array with required multiplexer setup
|
||||
* @param[in] reg_start starting register, this allows to configure non-consecutive
|
||||
* registers groups found on some MCU family members
|
||||
* @param[in] reg_count number of words in initialization array to set
|
||||
* to corresponding registers
|
||||
*
|
||||
* @retval Void
|
||||
*/
|
||||
void
|
||||
tms570_bsp_pinmmr_config(const uint32_t *pinmmr_values, int reg_start, int reg_count)
|
||||
{
|
||||
volatile uint32_t *pinmmrx;
|
||||
const uint32_t *pval;
|
||||
int cnt;
|
||||
|
||||
if ( reg_count <= 0)
|
||||
return;
|
||||
|
||||
TMS570_IOMM.KICK_REG0 = tms570_bsp_pinmmr_kick_key0;
|
||||
TMS570_IOMM.KICK_REG1 = tms570_bsp_pinmmr_kick_key1;
|
||||
|
||||
pinmmrx = (&TMS570_IOMM.PINMUX.PINMMR0) + reg_start;
|
||||
pval = pinmmr_values;
|
||||
cnt = reg_count;
|
||||
|
||||
do {
|
||||
*pinmmrx = *pinmmrx & *pval;
|
||||
pinmmrx++;
|
||||
pval++;
|
||||
} while( --cnt );
|
||||
|
||||
pinmmrx = (&TMS570_IOMM.PINMUX.PINMMR0) + reg_start;
|
||||
pval = pinmmr_values;
|
||||
cnt = reg_count;
|
||||
|
||||
do {
|
||||
*pinmmrx = *pval;
|
||||
pinmmrx++;
|
||||
pval++;
|
||||
} while( --cnt );
|
||||
|
||||
TMS570_IOMM.KICK_REG0 = 0;
|
||||
TMS570_IOMM.KICK_REG1 = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user