* [PATCH] commands: mmc_extcsd: Add support to write multibyte registers
@ 2018-06-04 12:47 Teresa Remmet
2018-06-07 8:11 ` Bastian Stender
0 siblings, 1 reply; 3+ messages in thread
From: Teresa Remmet @ 2018-06-04 12:47 UTC (permalink / raw)
To: barebox
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>
---
commands/mmc_extcsd.c | 44 +++++++++++++++++++++++++++-----------------
1 file changed, 27 insertions(+), 17 deletions(-)
diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c
index acd23a466bcb..a5af97fbbaf1 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)
+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
--
2.7.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] commands: mmc_extcsd: Add support to write multibyte registers
2018-06-04 12:47 [PATCH] commands: mmc_extcsd: Add support to write multibyte registers Teresa Remmet
@ 2018-06-07 8:11 ` Bastian Stender
2018-06-07 8:16 ` Teresa Remmet
0 siblings, 1 reply; 3+ messages in thread
From: Bastian Stender @ 2018-06-07 8:11 UTC (permalink / raw)
To: Teresa Remmet; +Cc: barebox
Hi Teresa,
On 06/04/2018 02:47 PM, Teresa Remmet wrote:
> 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>
> ---
> commands/mmc_extcsd.c | 44 +++++++++++++++++++++++++++-----------------
> 1 file changed, 27 insertions(+), 17 deletions(-)
>
> diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c
> index acd23a466bcb..a5af97fbbaf1 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)
> +int request_one_time_programmable(u16 index)
Why do you remove "static" here?
> {
> -
> 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
>
Everything else looks good to me.
Regards,
Bastian
--
Pengutronix e.K.
Industrial Linux Solutions
http://www.pengutronix.de/
Peiner Str. 6-8, 31137 Hildesheim, Germany
Amtsgericht Hildesheim, HRA 2686
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] commands: mmc_extcsd: Add support to write multibyte registers
2018-06-07 8:11 ` Bastian Stender
@ 2018-06-07 8:16 ` Teresa Remmet
0 siblings, 0 replies; 3+ messages in thread
From: Teresa Remmet @ 2018-06-07 8:16 UTC (permalink / raw)
To: Bastian Stender; +Cc: barebox
Hello Bastian,
Am Donnerstag, den 07.06.2018, 10:11 +0200 schrieb Bastian Stender:
> Hi Teresa,
>
> On 06/04/2018 02:47 PM, Teresa Remmet wrote:
> >
> > 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>
> > ---
> > commands/mmc_extcsd.c | 44 +++++++++++++++++++++++++++-----------
> > ------
> > 1 file changed, 27 insertions(+), 17 deletions(-)
> >
> > diff --git a/commands/mmc_extcsd.c b/commands/mmc_extcsd.c
> > index acd23a466bcb..a5af97fbbaf1 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)
> > +int request_one_time_programmable(u16 index)
> Why do you remove "static" here?
this was not on purpose. I will send an v2.
Thank you.
Teresa
>
> >
> > {
> > -
> > 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
> >
> Everything else looks good to me.
>
> Regards,
> Bastian
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-07 8:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-04 12:47 [PATCH] commands: mmc_extcsd: Add support to write multibyte registers Teresa Remmet
2018-06-07 8:11 ` Bastian Stender
2018-06-07 8:16 ` Teresa Remmet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox