From: Erik Ahlén Date: Tue, 13 Dec 2011 10:47:49 +0000 (+0100) Subject: Added command to enable/disable/query BI-swap for MXC NAND X-Git-Tag: v0.6.0-rc1~351 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a57d547dd728fc97f2f905a2e36e9e636e1758b3;p=openocd Added command to enable/disable/query BI-swap for MXC NAND Change-Id: Ifa3eb739afe0760a974b57c5a17cc3bf7704ba79 Signed-off-by: Erik Ahlén Reviewed-on: http://openocd.zylin.com/270 Tested-by: jenkins Reviewed-by: Mathias Küster Reviewed-by: Spencer Oliver --- diff --git a/src/flash/nand/mx2.c b/src/flash/nand/mx2.c index e3647385..4393e2dd 100644 --- a/src/flash/nand/mx2.c +++ b/src/flash/nand/mx2.c @@ -135,6 +135,56 @@ NAND_DEVICE_COMMAND_HANDLER(mxc_nand_device_command) return ERROR_OK; } +COMMAND_HANDLER(handle_mxc_biswap_command) +{ + struct nand_device *nand = NULL; + struct mxc_nf_controller *mxc_nf_info = NULL; + + if (CMD_ARGC < 1 || CMD_ARGC > 2) + return ERROR_COMMAND_SYNTAX_ERROR; + + int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &nand); + if (retval != ERROR_OK) { + command_print(CMD_CTX, "invalid nand device number or name: %s", CMD_ARGV[0]); + return ERROR_COMMAND_ARGUMENT_INVALID; + } + + mxc_nf_info = nand->controller_priv; + if (CMD_ARGC == 2) { + if (strcmp(CMD_ARGV[1], "enable") == 0) + mxc_nf_info->flags.biswap_enabled = true; + else + mxc_nf_info->flags.biswap_enabled = false; + } + if (mxc_nf_info->flags.biswap_enabled) + command_print(CMD_CTX, "BI-swapping enabled on %s", nand->name); + else + command_print(CMD_CTX, "BI-swapping disabled on %s", nand->name); + + return ERROR_OK; +} + +static const struct command_registration mxc_sub_command_handlers[] = { + { + .name = "biswap", + .handler = handle_mxc_biswap_command , + .help = "Turns on/off bad block information swaping from main area, " + "without parameter query status.", + .usage = "bank_id ['enable'|'disable']", + }, + COMMAND_REGISTRATION_DONE +}; + +static const struct command_registration mxc_nand_command_handler[] = { + { + .name = "mxc", + .mode = COMMAND_ANY, + .help = "MXC NAND flash controller commands", + .chain = mxc_sub_command_handlers + }, + COMMAND_REGISTRATION_DONE +}; + static int mxc_init(struct nand_device *nand) { struct mxc_nf_controller *mxc_nf_info = nand->controller_priv; @@ -785,6 +835,7 @@ static int do_data_output(struct nand_device *nand) struct nand_flash_controller mxc_nand_flash_controller = { .name = "mxc", .nand_device_command = &mxc_nand_device_command, + .commands = mxc_nand_command_handler, .init = &mxc_init, .reset = &mxc_reset, .command = &mxc_command,