From e73d93247e019f74356588c3af1d72ce0e925077 Mon Sep 17 00:00:00 2001 From: Premysl Houdek Date: Thu, 12 Nov 2015 23:11:28 +0100 Subject: bsp/tms570: Pinmux support and EMAC pin definition added Signed-off-by: Premysl Houdek --- c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c (limited to 'c/src/lib/libbsp/arm/tms570/pinmux') 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 + * + * 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 +#include + +/** + * @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_ (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)); +} -- cgit v1.2.3