summaryrefslogtreecommitdiff
path: root/src/flash
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-17 14:11:24 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-19 13:39:41 -0800
commit664ba309d5dac2532c83fed441d14f93c7381d62 (patch)
treedef919a7d9e741e4f214f13ddd3698b1ac2de87d /src/flash
parent59d4466b551e89077e41b0dba21c7a95db9c7b0a (diff)
downloadopenocd+libswd-664ba309d5dac2532c83fed441d14f93c7381d62.tar.gz
openocd+libswd-664ba309d5dac2532c83fed441d14f93c7381d62.tar.bz2
openocd+libswd-664ba309d5dac2532c83fed441d14f93c7381d62.tar.xz
openocd+libswd-664ba309d5dac2532c83fed441d14f93c7381d62.zip
add support for naming NAND banks
Requires users to name their nand banks, allowing them to be used instead of bank numbers in script commands.
Diffstat (limited to 'src/flash')
-rw-r--r--src/flash/nand.c13
-rw-r--r--src/flash/nand.h1
2 files changed, 11 insertions, 3 deletions
diff --git a/src/flash/nand.c b/src/flash/nand.c
index 70b14b02..2085028c 100644
--- a/src/flash/nand.c
+++ b/src/flash/nand.c
@@ -212,7 +212,7 @@ COMMAND_HANDLER(handle_nand_list_drivers)
return ERROR_OK;
}
-static COMMAND_HELPER(create_nand_device,
+static COMMAND_HELPER(create_nand_device, const char *bank_name,
struct nand_flash_controller *controller)
{
int retval = controller->register_commands(CMD_CTX);
@@ -221,9 +221,9 @@ static COMMAND_HELPER(create_nand_device,
LOG_ERROR("couldn't register '%s' commands", controller->name);
return retval;
}
-
struct nand_device *c = malloc(sizeof(struct nand_device));
+ c->name = strdup(bank_name);
c->controller = controller;
c->controller_priv = NULL;
c->manufacturer = NULL;
@@ -260,6 +260,10 @@ COMMAND_HANDLER(handle_nand_device_command)
return ERROR_FLASH_BANK_INVALID;
}
+ // save name and increment (for compatibility) with drivers
+ const char *bank_name = *CMD_ARGV++;
+ CMD_ARGC--;
+
const char *driver_name = CMD_ARGV[0];
for (unsigned i = 0; nand_flash_controllers[i]; i++)
{
@@ -267,7 +271,8 @@ COMMAND_HANDLER(handle_nand_device_command)
if (strcmp(driver_name, controller->name) != 0)
continue;
- return CALL_COMMAND_HANDLER(create_nand_device, controller);
+ return CALL_COMMAND_HANDLER(create_nand_device,
+ bank_name, controller);
}
LOG_ERROR("No valid NAND flash driver found (%s)", driver_name);
@@ -297,6 +302,8 @@ struct nand_device *get_nand_device_by_name(const char *name)
struct nand_device *nand;
for (nand = nand_devices; NULL != nand; nand = nand->next)
{
+ if (strcmp(nand->name, name) == 0)
+ return nand;
if (!flash_driver_name_matches(nand->controller->name, name))
continue;
if (++found < requested)
diff --git a/src/flash/nand.h b/src/flash/nand.h
index d38ed67e..af52c770 100644
--- a/src/flash/nand.h
+++ b/src/flash/nand.h
@@ -75,6 +75,7 @@ struct nand_ecclayout {
struct nand_device
{
+ char *name;
struct nand_flash_controller *controller;
void *controller_priv;
struct nand_manufacturer *manufacturer;