From 21c209fd8fa04fe8b312fa357ae0aa5bf38e3ecd Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Wed, 1 Apr 2015 20:21:22 -0700 Subject: [PATCH] sam3x: simplify probe function. --- src/sam3x.c | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/sam3x.c b/src/sam3x.c index 05667183..05db4208 100644 --- a/src/sam3x.c +++ b/src/sam3x.c @@ -122,10 +122,7 @@ static const char sam4s_xml_memory_map[] = "" #define EEFC_FSR_ERROR (EEFC_FSR_FCMDE | EEFC_FSR_FLOCKE) #define SAM3X_CHIPID_CIDR 0x400E0940 -#define SAM3N_CHIPID_CIDR 0x400E0740 -#define SAM3S_CHIPID_CIDR 0x400E0740 -#define SAM3U_CHIPID_CIDR 0x400E0740 -#define SAM4S_CHIPID_CIDR 0x400E0740 +#define SAM34NSU_CHIPID_CIDR 0x400E0740 #define CHIPID_CIDR_VERSION_MASK (0x1F << 0) #define CHIPID_CIDR_EPROC_CM3 (0x03 << 5) @@ -166,7 +163,6 @@ bool sam3x_probe(target *t) { t->idcode = target_mem_read32(t, SAM3X_CHIPID_CIDR); - /* FIXME: Check for all variants with similar flash interface */ switch (t->idcode & (CHIPID_CIDR_ARCH_MASK | CHIPID_CIDR_EPROC_MASK)) { case CHIPID_CIDR_ARCH_SAM3XxC | CHIPID_CIDR_EPROC_CM3: case CHIPID_CIDR_ARCH_SAM3XxE | CHIPID_CIDR_EPROC_CM3: @@ -179,34 +175,20 @@ bool sam3x_probe(target *t) return true; } - t->idcode = target_mem_read32(t, SAM3N_CHIPID_CIDR); + t->idcode = target_mem_read32(t, SAM34NSU_CHIPID_CIDR); switch (t->idcode & (CHIPID_CIDR_ARCH_MASK | CHIPID_CIDR_EPROC_MASK)) { case CHIPID_CIDR_ARCH_SAM3NxA | CHIPID_CIDR_EPROC_CM3: case CHIPID_CIDR_ARCH_SAM3NxB | CHIPID_CIDR_EPROC_CM3: case CHIPID_CIDR_ARCH_SAM3NxC | CHIPID_CIDR_EPROC_CM3: - t->driver = "Atmel SAM3N"; - t->xml_mem_map = sam3n_xml_memory_map; - t->flash_erase = sam3x_flash_erase; - t->flash_write = sam3x_flash_write; - target_add_commands(t, sam3x_cmd_list, "SAM3N"); - return true; - } - - t->idcode = target_mem_read32(t, SAM3S_CHIPID_CIDR); - switch (t->idcode & (CHIPID_CIDR_ARCH_MASK | CHIPID_CIDR_EPROC_MASK)) { case CHIPID_CIDR_ARCH_SAM3SxA | CHIPID_CIDR_EPROC_CM3: case CHIPID_CIDR_ARCH_SAM3SxB | CHIPID_CIDR_EPROC_CM3: case CHIPID_CIDR_ARCH_SAM3SxC | CHIPID_CIDR_EPROC_CM3: - t->driver = "Atmel SAM3S"; + t->driver = "Atmel SAM3N/S"; t->xml_mem_map = sam3n_xml_memory_map; t->flash_erase = sam3x_flash_erase; t->flash_write = sam3x_flash_write; - target_add_commands(t, sam3x_cmd_list, "SAM3S"); + target_add_commands(t, sam3x_cmd_list, "SAM3N"); return true; - } - - t->idcode = target_mem_read32(t, SAM3U_CHIPID_CIDR); - switch (t->idcode & (CHIPID_CIDR_ARCH_MASK | CHIPID_CIDR_EPROC_MASK)) { case CHIPID_CIDR_ARCH_SAM3UxC | CHIPID_CIDR_EPROC_CM3: case CHIPID_CIDR_ARCH_SAM3UxE | CHIPID_CIDR_EPROC_CM3: t->driver = "Atmel SAM3U"; @@ -215,10 +197,6 @@ bool sam3x_probe(target *t) t->flash_write = sam3x_flash_write; target_add_commands(t, sam3x_cmd_list, "SAM3U"); return true; - } - - t->idcode = target_mem_read32(t, SAM4S_CHIPID_CIDR); - switch (t->idcode & (CHIPID_CIDR_ARCH_MASK | CHIPID_CIDR_EPROC_MASK)) { case CHIPID_CIDR_ARCH_SAM4SxA | CHIPID_CIDR_EPROC_CM4: case CHIPID_CIDR_ARCH_SAM4SxB | CHIPID_CIDR_EPROC_CM4: case CHIPID_CIDR_ARCH_SAM4SxC | CHIPID_CIDR_EPROC_CM4: