[prev in list] [next in list] [prev in thread] [next in thread]
List: openocd-development
Subject: [OpenOCD-devel] [PATCH]: de95c30 ftdi: Add deinit hook in ftdi_quit()
From: gerrit () openocd ! org (gerrit)
Date: 2015-08-30 22:33:40
Message-ID: 20150830223340.AE3CC19807D5 () mail ! openocd ! org
[Download RAW message or body]
This is an automated email from Gerrit.
Stephan Linz (linz@li-pro.net) just uploaded a new patch set to Gerrit, which you can \
find at http://openocd.zylin.com/2949
-- gerrit
commit de95c30c734849f9c548e2fc8a07eb6b0ff0558f
Author: Stephan Linz <linz@li-pro.net>
Date: Tue Aug 27 18:22:58 2013 +0200
ftdi: Add deinit hook in ftdi_quit()
Some layouts maybe need a proper hardware deinitialization on
shutdown, for example to disable gates, drivers, buffers, or
switch off blinking LEDs.
The current implementation of ftdi_quit() will only close the
USB interface and cleanup all related buffers in memory. There
is no call to cleanup all the changes that the ftdi_initialize()
has done on hardware side.
Based on the configuration command 'ftdi_layout_init' we add the
new command 'ftdi_layout_shutdown' for setup a separated value
pair (data output and direction word) that can be used to reset
the FTDI GPIO register (high and low byte).
Change-Id: I00164dda6ffd1c5a82da947782f2c77435a7878a
Signed-off-by: Stephan Linz <linz@li-pro.net>
diff --git a/doc/openocd.texi b/doc/openocd.texi
index 63ab5de..7f554d1 100644
--- a/doc/openocd.texi
+++ b/doc/openocd.texi
@@ -2567,6 +2567,17 @@ minimal impact on the target system. Avoid floating inputs, \
conflicting outputs and initially asserted reset signals.
@end deffn
+@deffn {Config Command} {ftdi_layout_shutdown} data direction
+Specifies the deinitialization values of the FTDI GPIO data and direction
+registers for adapter shutdown. The command syntax is the same as for initial
+values (see @command{ftdi_layout_init}). Some layouts maybe need a proper
+hardware deinitialization on shutdown, for example to disable gates, drivers,
+buffers, or switch off blinking LEDs. The values should be selected based
+on the schematics of the adapter, such that all signals are set to safe
+levels without impact on the target system on adapter shutdown. Avoid floating
+inputs, conflicting outputs and asserted reset signals.
+@end deffn
+
@deffn {Config Command} {ftdi_layout_signal} name [@option{-data}|@option{-ndata} \
data_mask] [@option{-oe}|@option{-noe} oe_mask] [@option{-alias}|@option{-nalias} \
name] Creates a signal with the specified @var{name}, controlled by one or more FTDI
GPIO pins via a range of possible buffer connections. The masks are FTDI GPIO
diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c
index 14c5908..6247177 100644
--- a/src/jtag/drivers/ftdi.c
+++ b/src/jtag/drivers/ftdi.c
@@ -124,7 +124,9 @@ static int queued_retval;
static int freq;
static uint16_t output;
+static uint16_t output_shd;
static uint16_t direction;
+static uint16_t direction_shd;
static uint16_t jtag_output_init;
static uint16_t jtag_direction_init;
@@ -660,11 +662,20 @@ static int ftdi_initialize(void)
static int ftdi_quit(void)
{
+ LOG_DEBUG("ftdi interface deinitialization on shutdown");
+
+ mpsse_set_data_bits_low_byte(mpsse_ctx, output_shd & 0xff, direction_shd & 0xff);
+ mpsse_set_data_bits_high_byte(mpsse_ctx, output_shd >> 8, direction_shd >> 8);
+
+ int retval = mpsse_flush(mpsse_ctx);
+ if (retval != ERROR_OK)
+ LOG_ERROR("error while flushing MPSSE queue: %d", retval);
+
mpsse_close(mpsse_ctx);
free(swd_cmd_queue);
- return ERROR_OK;
+ return retval;
}
COMMAND_HANDLER(ftdi_handle_device_desc_command)
@@ -714,6 +725,17 @@ COMMAND_HANDLER(ftdi_handle_layout_init_command)
return ERROR_OK;
}
+COMMAND_HANDLER(ftdi_handle_layout_shutdown_command)
+{
+ if (CMD_ARGC != 2)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+
+ COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], output_shd);
+ COMMAND_PARSE_NUMBER(u16, CMD_ARGV[1], direction_shd);
+
+ return ERROR_OK;
+}
+
COMMAND_HANDLER(ftdi_handle_layout_signal_command)
{
if (CMD_ARGC < 1)
@@ -863,6 +885,15 @@ static const struct command_registration ftdi_command_handlers[] \
= {
.usage = "data direction",
},
{
+ .name = "ftdi_layout_shutdown",
+ .handler = &ftdi_handle_layout_shutdown_command,
+ .mode = COMMAND_CONFIG,
+ .help = "(de-)initialize the FTDI GPIO signals used "
+ "to control output-enables and reset signals "
+ "on adapter shutdown",
+ .usage = "data direction",
+ },
+ {
.name = "ftdi_layout_signal",
.handler = &ftdi_handle_layout_signal_command,
.mode = COMMAND_ANY,
--
------------------------------------------------------------------------------
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic