diff options
author | Teresa Remmet <t.remmet@phytec.de> | 2018-06-07 10:25:10 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-06-08 08:01:52 +0200 |
commit | 82abcdfc63a7b1d2f6cbeda28a9a8299287818d1 (patch) | |
tree | 6b52ec02223128e72dc86bf585308804e91aaa3f /commands/mmc_extcsd.c | |
parent | 2b8c3fe861019a0ea67db23bfde82a22400c2b61 (diff) | |
download | barebox-82abcdfc63a7b1d2f6cbeda28a9a8299287818d1.tar.gz barebox-82abcdfc63a7b1d2f6cbeda28a9a8299287818d1.tar.xz |
commands: mmc_extcsd: Add support to write multibyte registers
It has been possible to write only the first byte of a multibyte register.
Updated the command to write the complete value of a multibyte register at once.
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Reviewed-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/mmc_extcsd.c')
-rw-r--r-- | commands/mmc_extcsd.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c index acd23a466b..82e0600eaf 100644 --- a/commands/mmc_extcsd.c +++ b/commands/mmc_extcsd.c @@ -2306,10 +2306,8 @@ static int request_write_operation(void) return 0; } -static void write_field(struct mci *mci, u8 *reg, u16 index, u8 value, - int always_write) +static int request_one_time_programmable(u16 index) { - switch (index) { case EXT_CSD_BOOT_CONFIG_PROT: case EXT_CSD_BOOT_WP: @@ -2349,18 +2347,15 @@ static void write_field(struct mci *mci, u8 *reg, u16 index, u8 value, case 52: case EXT_CSD_BARRIER_CTRL: case EXT_CSD_SECURE_REMOVAL_TYPE: - if (!always_write) - if (request_write_operation() == 0) { - printf("Abort write operation!\n"); - goto out; - } - break; + if (request_write_operation() == 0) { + printf("Abort write operation!\n"); + return 1; + } else { + return 0; + } } - mci_switch(mci, index, value); - -out: - return; + return 0; } static int do_mmc_extcsd(int argc, char *argv[]) @@ -2430,11 +2425,26 @@ static int do_mmc_extcsd(int argc, char *argv[]) if (!print_field(dst, index)) { printf("No field with this index found. Abort write operation!\n"); } else { - write_field(mci, dst, index, value, always_write); + struct extcsd_reg *ext; + int i; + int val = 0; + + if (!always_write) { + retval = request_one_time_programmable(index); + if (retval) + goto error_with_mem; + } + + ext = &extcsd[index]; + for (i = 0; i < ext->width; i++) { + val = (value >> (i * 8)) & 0xFF; + + mci_switch(mci, index + i, val); + retval = mci_send_ext_csd(mci, dst); + if (retval != 0) + goto error_with_mem; + } printf("\nValue written!\n\n"); - retval = mci_send_ext_csd(mci, dst); - if (retval != 0) - goto error_with_mem; print_field(dst, index); } else |