diff options
author | Premysl Houdek <kom541000@gmail.com> | 2015-11-12 23:11:28 +0100 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2015-11-18 10:19:00 -0500 |
commit | e73d93247e019f74356588c3af1d72ce0e925077 (patch) | |
tree | e4df716f5ab7d728c29bba2db24880ff19d74231 /c/src/lib/libbsp/arm/tms570/pinmux | |
parent | bsp/tms570: EMAC control header file corrected and EMAC interrupt vector added (diff) | |
download | rtems-e73d93247e019f74356588c3af1d72ce0e925077.tar.bz2 |
bsp/tms570: Pinmux support and EMAC pin definition added
Signed-off-by: Premysl Houdek <kom541000@gmail.com>
Diffstat (limited to 'c/src/lib/libbsp/arm/tms570/pinmux')
-rw-r--r-- | c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c b/c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c new file mode 100644 index 0000000000..79d6b1e504 --- /dev/null +++ b/c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c @@ -0,0 +1,88 @@ +/** + * @file pinmux.c + * + * @ingroup tms570 + * + * @brief I/O Multiplexing Module (IOMM) basic support + */ + +/* + * Copyright (c) 2015 Premysl Houdek <kom541000@gmail.com> + * + * Google Summer of Code 2014 at + * Czech Technical University in Prague + * Zikova 1903/4 + * 166 36 Praha 6 + * Czech Republic + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include <bsp/tms570.h> +#include <bsp/tms570-pinmux.h> + +/** + * @brief select desired function of pin/ball + * + * 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). + * The multiplexer allows to interconnect one pin to multiple + * signal sources/sings 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 + * is specified then pin function is extracted from + * pin_num argument + * @retval Void + */ +void +tms570_bsp_pin_set_function(int pin_num, int pin_fnc) +{ + unsigned int pin_shift; + typeof(TMS570_IOMM.PINMUX.PINMMR0) *pinmmrx; + + if ( pin_fnc == TMS570_PIN_FNC_AUTO ) { + pin_fnc = (pin_num & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT; + } + pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT; + + pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0; + pinmmrx += (pin_num >> 2); + pin_shift = (pin_num & 0x3)*8; + *pinmmrx = (*pinmmrx & ~(0xff << pin_shift)) | (1 << (pin_fnc + pin_shift)); +} + +/** + * @brief clear connection between pin and specified peripherals/function + * + * This function switches off given connection and leaves rest + * 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 + * is specified then pin function is extracted from + * pin_num argument + * @retval Void + */ +void +tms570_bsp_pin_clear_function(int pin_num, int pin_fnc) +{ + unsigned int pin_shift; + typeof(TMS570_IOMM.PINMUX.PINMMR0) *pinmmrx; + + if ( pin_fnc == TMS570_PIN_FNC_AUTO ) { + pin_fnc = (pin_num & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT; + } + pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT; + + pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0; + pinmmrx += (pin_num >> 2); + pin_shift = (pin_num & 0x3)*8; + *pinmmrx = *pinmmrx & ~(1 << (pin_fnc+pin_shift)); +} |