imx_gpio: enable only the transport specific gpio
Change-Id: Idb1fabbc1e9385f8c23b643584bf7863ea91ffbf Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/5557 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
ed17994757
commit
a8e483a2bf
|
@ -22,6 +22,7 @@
|
|||
#endif
|
||||
|
||||
#include <jtag/interface.h>
|
||||
#include <transport/transport.h>
|
||||
#include "bitbang.h"
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
@ -478,15 +479,13 @@ static int imx_gpio_init(void)
|
|||
|
||||
LOG_INFO("imx_gpio GPIO JTAG/SWD bitbang driver");
|
||||
|
||||
if (imx_gpio_jtag_mode_possible()) {
|
||||
if (imx_gpio_swd_mode_possible())
|
||||
LOG_INFO("JTAG and SWD modes enabled");
|
||||
else
|
||||
LOG_INFO("JTAG only mode enabled (specify swclk and swdio gpio to add SWD mode)");
|
||||
} else if (imx_gpio_swd_mode_possible()) {
|
||||
LOG_INFO("SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)");
|
||||
} else {
|
||||
LOG_ERROR("Require tck, tms, tdi and tdo gpios for JTAG mode and/or swclk and swdio gpio for SWD mode");
|
||||
if (transport_is_jtag() && !imx_gpio_jtag_mode_possible()) {
|
||||
LOG_ERROR("Require tck, tms, tdi and tdo gpios for JTAG mode");
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
if (transport_is_swd() && !imx_gpio_swd_mode_possible()) {
|
||||
LOG_ERROR("Require swclk and swdio gpio for SWD mode");
|
||||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
|
@ -496,7 +495,6 @@ static int imx_gpio_init(void)
|
|||
return ERROR_JTAG_INIT_FAILED;
|
||||
}
|
||||
|
||||
|
||||
LOG_INFO("imx_gpio mmap: pagesize: %u, regionsize: %u",
|
||||
(unsigned int) sysconf(_SC_PAGE_SIZE), IMX_GPIO_REGS_COUNT * IMX_GPIO_SIZE);
|
||||
pio_base = mmap(NULL, IMX_GPIO_REGS_COUNT * IMX_GPIO_SIZE,
|
||||
|
@ -513,7 +511,7 @@ static int imx_gpio_init(void)
|
|||
* Configure TDO as an input, and TDI, TCK, TMS, TRST, SRST
|
||||
* as outputs. Drive TDI and TCK low, and TMS/TRST/SRST high.
|
||||
*/
|
||||
if (imx_gpio_jtag_mode_possible()) {
|
||||
if (transport_is_jtag()) {
|
||||
tdo_gpio_mode = gpio_mode_get(tdo_gpio);
|
||||
tdi_gpio_mode = gpio_mode_get(tdi_gpio);
|
||||
tck_gpio_mode = gpio_mode_get(tck_gpio);
|
||||
|
@ -527,8 +525,15 @@ static int imx_gpio_init(void)
|
|||
gpio_mode_output_set(tdi_gpio);
|
||||
gpio_mode_output_set(tck_gpio);
|
||||
gpio_mode_output_set(tms_gpio);
|
||||
|
||||
if (trst_gpio != -1) {
|
||||
trst_gpio_mode = gpio_mode_get(trst_gpio);
|
||||
gpio_set(trst_gpio);
|
||||
gpio_mode_output_set(trst_gpio);
|
||||
}
|
||||
}
|
||||
if (imx_gpio_swd_mode_possible()) {
|
||||
|
||||
if (transport_is_swd()) {
|
||||
swclk_gpio_mode = gpio_mode_get(swclk_gpio);
|
||||
swdio_gpio_mode = gpio_mode_get(swdio_gpio);
|
||||
|
||||
|
@ -537,11 +542,7 @@ static int imx_gpio_init(void)
|
|||
gpio_mode_output_set(swclk_gpio);
|
||||
gpio_mode_output_set(swdio_gpio);
|
||||
}
|
||||
if (trst_gpio != -1) {
|
||||
trst_gpio_mode = gpio_mode_get(trst_gpio);
|
||||
gpio_set(trst_gpio);
|
||||
gpio_mode_output_set(trst_gpio);
|
||||
}
|
||||
|
||||
if (srst_gpio != -1) {
|
||||
srst_gpio_mode = gpio_mode_get(srst_gpio);
|
||||
gpio_set(srst_gpio);
|
||||
|
@ -557,18 +558,21 @@ static int imx_gpio_init(void)
|
|||
|
||||
static int imx_gpio_quit(void)
|
||||
{
|
||||
if (imx_gpio_jtag_mode_possible()) {
|
||||
if (transport_is_jtag()) {
|
||||
gpio_mode_set(tdo_gpio, tdo_gpio_mode);
|
||||
gpio_mode_set(tdi_gpio, tdi_gpio_mode);
|
||||
gpio_mode_set(tck_gpio, tck_gpio_mode);
|
||||
gpio_mode_set(tms_gpio, tms_gpio_mode);
|
||||
|
||||
if (trst_gpio != -1)
|
||||
gpio_mode_set(trst_gpio, trst_gpio_mode);
|
||||
}
|
||||
if (imx_gpio_swd_mode_possible()) {
|
||||
|
||||
if (transport_is_swd()) {
|
||||
gpio_mode_set(swclk_gpio, swclk_gpio_mode);
|
||||
gpio_mode_set(swdio_gpio, swdio_gpio_mode);
|
||||
}
|
||||
if (trst_gpio != -1)
|
||||
gpio_mode_set(trst_gpio, trst_gpio_mode);
|
||||
|
||||
if (srst_gpio != -1)
|
||||
gpio_mode_set(srst_gpio, srst_gpio_mode);
|
||||
|
||||
|
|
Loading…
Reference in New Issue