mmc-util: add the method to enable the bkops
PATCH RESEND 1/1 mmc-util: add the method to enable the bkops
This patch added the method to enable the bkops. In ext_csd register, BKOPS_EN bit is one-time programable. So if you want to use the bkops, use the this command.
<usage>
#mmc bkops enable /dev/mmcblk0
--- mmc.c | 5 +++++ mmc.h | 7 +++++++ mmc_cmds.c | 39 +++++++++++++++++++++++++++++++++++++++ mmc_cmds.h | 1 + 4 files changed, 52 insertions(+), 0 deletions(-)
mmc.c +5 -0
@@ -75,6 +75,11 @@ static struct Command commands[] = { "Enable the boot partition for the <device>.\nTo receive acknowledgment of boot from the card set <send_ack>\nto 1, else set it to 0.", NULL }, + { do_write_bkops_en,-1 , +"bkops enable" ,"<device>\n" +"Enable the eMMC BKOPS feature on <device>." , +NULL + }, { 0, 0, 0, 0 } };
mmc.h +7 -0
@@ -31,12 +31,14 @@*/ #define EXT_CSD_S_CMD_SET 504#define EXT_CSD_HPI_FEATURE 503 +#define EXT_CSD_BKOPS_SUPPORT 502/* RO */ #define EXT_CSD_BOOT_INFO 228/* R/W */ #define EXT_CSD_PART_SWITCH_TIME 199#define EXT_CSD_BOOT_CFG 179#define EXT_CSD_PART_CONFIG 179#define EXT_CSD_BOOT_WP 173#define EXT_CSD_WR_REL_PARAM 166 +#define EXT_CSD_BKOPS_EN 163/* R/W */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63/* R */ #define EXT_CSD_USE_NATIVE_SECTOR 62/* R/W */ #define EXT_CSD_DATA_SECTOR_SIZE 61/* R */
@@ -48,6 +50,11 @@#define EN_REL_WR (1<<2)/* +* BKOPS_EN field definition +*/ +#define BKOPS_ENABLE (1<<0) + +/* * EXT_CSD field definitions */ #define EXT_CSD_HPI_SUPP (1<<0)
mmc_cmds.c +39 -0
@@ -280,6 +280,45 @@ int do_write_boot_en(int nargs, char **argv)return ret; } +int do_write_bkops_en (int nargs,char **argv) +{ +__u8 ext_csd[512 ], value =0 ; +int fd, ret; +char *device; + +CHECK (nargs !=2 ,"Usage: mmc bkops enable </path/to/mmcblkX>\n" , +exit (1 )); + + device = argv[1 ]; + + fd =open (device,O_RDWR ); +if (fd <0 ) { +perror ("open" ); +exit (1 ); + } + + ret =read_extcsd (fd, ext_csd); +if (ret) { +fprintf (stderr,"Could not read EXT_CSD from %s\n" , device); +exit (1 ); + } + +if (!(ext_csd[EXT_CSD_BKOPS_SUPPORT ] &0x1 )) { +fprintf (stderr,"%s dosen't support BKOPS\n" , device); +exit (1 ); + } + + ret =write_extcsd_value (fd,EXT_CSD_BKOPS_EN ,BKOPS_ENABLE ); +if (ret) { +fprintf (stderr,"Could not write 0x%02x to " +"EXT_CSD[%d] in %s\n" , + value,EXT_CSD_BKOPS_EN , device); +exit (1 ); + } + +return ret; +} +int do_read_extcsd (int nargs,char **argv) {__u8 ext_csd[512 ], ext_csd_rev, reg;
mmc_cmds.h +1 -0
@@ -21,3 +21,4 @@ int do_writeprotect_get(int nargs, char **argv);int do_writeprotect_set (int nargs,char **argv);int do_disable_512B_emulation (int nargs,char **argv);int do_write_boot_en (int nargs,char **argv); +int do_write_bkops_en (int nargs,char **argv);
Signature · 1 line
1.7.4.1
Dear Chris,
Could you merge the this at mmc-utils?
If you have any other opinion, plz let me know.
Best Regards,
Jaehoon Chung
Quoted 124 lines · Jaehoon Chung
This patch added the method to enable the bkops. In
ext_csdregister,BKOPS_ENbit is one-time programable. So if you want to use the bkops, use the this command.<usage>
#mmc bkops enable/dev/mmcblk0Signed-off-by Jaehoon Chung <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Reviewd-by Venkatraman S <[email protected]>--- mmc.c | 5 +++++ mmc.h | 7 +++++++ mmc_cmds.c | 39 +++++++++++++++++++++++++++++++++++++++ mmc_cmds.h | 1 + 4 files changed, 52 insertions(+), 0 deletions(-)mmc.c +5
-0@@ -75,6 +75,11 @@ static struct Command commands[] = { "Enable the boot partition for the <device>.\nTo receive acknowledgment of boot from the card set <send_ack>\nto 1, else set it to 0.", NULL }, + { do_write_bkops_en,-1 , +"bkops enable" ,"<device>\n" +"Enable the eMMC BKOPS feature on <device>." , +NULL + }, { 0, 0, 0, 0 } };mmc.h +7
-0@@ -31,12 +31,14 @@*/ #define EXT_CSD_S_CMD_SET 504#define EXT_CSD_HPI_FEATURE 503 +#define EXT_CSD_BKOPS_SUPPORT 502/* RO */ #define EXT_CSD_BOOT_INFO 228/* R/W */ #define EXT_CSD_PART_SWITCH_TIME 199#define EXT_CSD_BOOT_CFG 179#define EXT_CSD_PART_CONFIG 179#define EXT_CSD_BOOT_WP 173#define EXT_CSD_WR_REL_PARAM 166 +#define EXT_CSD_BKOPS_EN 163/* R/W */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63/* R */ #define EXT_CSD_USE_NATIVE_SECTOR 62/* R/W */ #define EXT_CSD_DATA_SECTOR_SIZE 61/* R */ @@ -48,6 +50,11 @@#define EN_REL_WR (1<<2)/* +* BKOPS_EN field definition +*/ +#define BKOPS_ENABLE (1<<0) + +/* * EXT_CSD field definitions */ #define EXT_CSD_HPI_SUPP (1<<0)mmc_cmds.c +39
-0@@ -280,6 +280,45 @@ int do_write_boot_en(int nargs, char **argv)return ret; } +int do_write_bkops_en (int nargs,char **argv) +{ +__u8 ext_csd[512 ], value =0 ; +int fd, ret; +char *device; + +CHECK (nargs !=2 ,"Usage: mmc bkops enable </path/to/mmcblkX>\n" , +exit (1 )); + + device = argv[1 ]; + + fd =open (device,O_RDWR ); +if (fd <0 ) { +perror ("open" ); +exit (1 ); + } + + ret =read_extcsd (fd, ext_csd); +if (ret) { +fprintf (stderr,"Could not read EXT_CSD from %s\n" , device); +exit (1 ); + } + +if (!(ext_csd[EXT_CSD_BKOPS_SUPPORT ] &0x1 )) { +fprintf (stderr,"%s dosen't support BKOPS\n" , device); +exit (1 ); + } + + ret =write_extcsd_value (fd,EXT_CSD_BKOPS_EN ,BKOPS_ENABLE ); +if (ret) { +fprintf (stderr,"Could not write 0x%02x to " +"EXT_CSD[%d] in %s\n" , + value,EXT_CSD_BKOPS_EN , device); +exit (1 ); + } + +return ret; +} +int do_read_extcsd (int nargs,char **argv) {__u8 ext_csd[512 ], ext_csd_rev, reg;mmc_cmds.h +1
-0@@ -21,3 +21,4 @@ int do_writeprotect_get(int nargs, char **argv);int do_writeprotect_set (int nargs,char **argv);int do_disable_512B_emulation (int nargs,char **argv);int do_write_boot_en (int nargs,char **argv); +int do_write_bkops_en (int nargs,char **argv);
Hi,
Quoted 4 lines · Jaehoon Chung
Dear Chris,
Could you merge the this at mmc-utils?
If you have any other opinion, plz let me know.
Looks good, but I was planning to merge it at the same time as merging the kernel patch -- I think we're waiting on another revision of that?
Thanks,
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Quoted 10 lines · Chris Ball
Hi,
Quoted 4 lines · Jaehoon Chung
Dear Chris,
Could you merge the this at mmc-utils?
If you have any other opinion, plz let me know.Looks good, but I was planning to merge it at the same time as merging the kernel patch -- I think we're waiting on another revision of that?
Ok, i agree your planning.
Thanks for reply.
Best Regards,
Jaehoon Chung
Quoted 5 lines
Thanks,
- Chris.