From f8a117258a7f8df85a37b64ea687fa3dfdc48f1c Mon Sep 17 00:00:00 2001
From: ntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Date: Wed, 30 Apr 2008 18:33:21 +0000
Subject: [PATCH] - added new device to luminary flash driver - only use
 SYSRESETREQ on affected luminary parts

git-svn-id: svn://svn.berlios.de/openocd/trunk@630 b42882b7-edfa-0310-969c-e2dbd0fdcd60
---
 src/flash/stellaris.c  | 37 +++++++++++++++++++++++++++++++++++--
 src/target/cortex_m3.c | 36 ++++++++++++++++++++++++++++++++----
 2 files changed, 67 insertions(+), 6 deletions(-)

diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c
index efcd7818c..ecdf686d5 100644
--- a/src/flash/stellaris.c
+++ b/src/flash/stellaris.c
@@ -81,6 +81,11 @@ struct {
 {
 	{0x01,"LM3S101"},
 	{0x02,"LM3S102"},
+	{0x03,"LM3S1625"},
+	{0x04,"LM3S1626"},
+	{0x05,"LM3S1627"},
+	{0x06,"LM3S1607"},
+	{0x10,"LM3S1776"},
 	{0x19,"LM3S300"},
 	{0x11,"LM3S301"},
 	{0x12,"LM3S310"},
@@ -106,10 +111,20 @@ struct {
 	{0x39,"LM3S808"},
 	{0x32,"LM3S811"},
 	{0x33,"LM3S812"},
+	/*{0x33,"LM3S2616"},*/
 	{0x34,"LM3S815"},
 	{0x36,"LM3S817"},
 	{0x37,"LM3S818"},
 	{0x35,"LM3S828"},
+	{0x39,"LM3S2276"},
+	{0x3A,"LM3S2776"},
+	{0x43,"LM3S3651"},
+	{0x44,"LM3S3739"},
+	{0x45,"LM3S3749"},
+	{0x46,"LM3S3759"},
+	{0x48,"LM3S3768"},
+	{0x49,"LM3S3748"},
+	{0x50,"LM3S2678"},
 	{0x51,"LM3S2110"},
 	{0x52,"LM3S2739"},
 	{0x53,"LM3S2651"},
@@ -133,6 +148,8 @@ struct {
 	{0x76,"LM3S6537"},
 	{0x77,"LM3S6753"},
 	{0x78,"LM3S6952"},
+	{0x80,"LM3S2671"},
+	{0x81,"LM3S5632"},
 	{0x82,"LM3S6422"},
 	{0x83,"LM3S6633"},
 	{0x84,"LM3S2139"},
@@ -140,17 +157,30 @@ struct {
 	{0x86,"LM3S8738"},
 	{0x88,"LM3S8938"},
 	{0x89,"LM3S6938"},
+	{0x8A,"LM3S5652"},
 	{0x8B,"LM3S6637"},
 	{0x8C,"LM3S8933"},
 	{0x8D,"LM3S8733"},
 	{0x8E,"LM3S8538"},
 	{0x8F,"LM3S2948"},
+	{0x91,"LM3S5662"},
+	{0x96,"LM3S5732"},
+	{0x97,"LM3S5737"},
+	{0x99,"LM3S5747"},
+	{0x9A,"LM3S5752"},
+	{0x9B,"LM3S5757"},
+	{0x9C,"LM3S5762"},
+	{0x9D,"LM3S5767"},
+	{0xA0,"LM3S5739"},
 	{0xA1,"LM3S6100"},
 	{0xA2,"LM3S2410"},
 	{0xA3,"LM3S6730"},
 	{0xA4,"LM3S2730"},
 	{0xA5,"LM3S6420"},
 	{0xA6,"LM3S8962"},
+	{0xA7,"LM3S5749"},
+	{0xA8,"LM3S5769"},
+	{0xA9,"LM3S5768"},
 	{0xB3,"LM3S1635"},
 	{0xB4,"LM3S1850"},
 	{0xB5,"LM3S1960"},
@@ -200,10 +230,13 @@ struct {
 	{0,"Unknown part"}
 };
 
-char * StellarisClassname[2] =
+char * StellarisClassname[5] =
 {
 	"Sandstorm",
-	"Fury"
+	"Fury",
+	"Unknown",
+	"DustDevil",
+	"Tempest"
 };
 
 /***************************************************************************
diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c
index ec3851667..fb3b36b46 100644
--- a/src/target/cortex_m3.c
+++ b/src/target/cortex_m3.c
@@ -673,6 +673,7 @@ int cortex_m3_assert_reset(target_t *target)
 	armv7m_common_t *armv7m = target->arch_info;
 	cortex_m3_common_t *cortex_m3 = armv7m->arch_info;
 	swjdp_common_t *swjdp = &cortex_m3->swjdp_info;
+	int assert_srst = TRUE;
 	
 	LOG_DEBUG("target->state: %s", target_state_strings[target->state]);
 	
@@ -712,12 +713,33 @@ int cortex_m3_assert_reset(target_t *target)
 		
 	if (strcmp(cortex_m3->variant, "lm3s") == 0)
 	{
-		/* this causes the luminary device to reset using the watchdog */
-		ahbap_write_system_atomic_u32(swjdp, NVIC_AIRCR, AIRCR_VECTKEY | AIRCR_SYSRESETREQ );
-		LOG_DEBUG("Using Luminary Reset: SYSRESETREQ");
+		/* get revision of lm3s target, only early silicon has this issue
+		 * Fury Rev B, DustDevil Rev B, Tempest all ok */
+		
+		u32 did0;
+		
+		if (target_read_u32(target, 0x400fe000, &did0) == ERROR_OK)
+		{
+			switch ((did0 >> 16) & 0xff)
+			{
+				case 0:
+					/* all Sandstorm suffer issue */
+					assert_srst = FALSE;
+					break;
+				
+				case 1:
+				case 3:
+					/* only Fury/DustDevil rev A suffer reset problems */
+					if (((did0 >> 8) & 0xff) == 0)
+						assert_srst = FALSE;
+					break;
+			}
+		}
 	}
-	else
+	
+	if (assert_srst == TRUE)
 	{
+		/* default to asserting srst */
 		if (jtag_reset_config & RESET_SRST_PULLS_TRST)
 		{
 			jtag_add_reset(1, 1);
@@ -727,6 +749,12 @@ int cortex_m3_assert_reset(target_t *target)
 			jtag_add_reset(0, 1);
 		}
 	}
+	else
+	{
+		/* this causes the luminary device to reset using the watchdog */
+		ahbap_write_system_atomic_u32(swjdp, NVIC_AIRCR, AIRCR_VECTKEY | AIRCR_SYSRESETREQ );
+		LOG_DEBUG("Using Luminary Reset: SYSRESETREQ");
+	}
 	
 	target->state = TARGET_RESET;
 	jtag_add_sleep(50000);
-- 
GitLab