* [PATCH] mmc-utils: Support enable/disable of eMMC H/W Reset function
@ 2012-10-19 21:29 Chris Ball
2012-10-22 7:11 ` Johan Rudholm
0 siblings, 1 reply; 2+ messages in thread
From: Chris Ball @ 2012-10-19 21:29 UTC (permalink / raw)
To: linux-mmc
(Note: one-time programmable fuse.)
$ mmc hwreset enable /dev/mmcblk0
$ mmc hwreset disable /dev/mmcblk0
---
mmc.c | 10 ++++++++++
mmc.h | 4 ++++
mmc_cmds.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
mmc_cmds.h | 2 ++
4 files changed, 75 insertions(+)
diff --git a/mmc.c b/mmc.c
index 56f621c..a2de863 100644
--- a/mmc.c
+++ b/mmc.c
@@ -80,6 +80,16 @@ static struct Command commands[] = {
"Enable the eMMC BKOPS feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.",
NULL
},
+ { do_hwreset_en, -1,
+ "hwreset enable", "<device>\n"
+ "Permanently enable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.",
+ NULL
+ },
+ { do_hwreset_dis, -1,
+ "hwreset disable", "<device>\n"
+ "Permanently disable the eMMC H/W Reset feature on <device>.\nNOTE! This is a one-time programmable (unreversible) change.",
+ NULL
+ },
{ 0, 0, 0, 0 }
};
diff --git a/mmc.h b/mmc.h
index 3d77b38..c863751 100644
--- a/mmc.h
+++ b/mmc.h
@@ -39,6 +39,7 @@
#define EXT_CSD_BOOT_WP 173
#define EXT_CSD_WR_REL_PARAM 166
#define EXT_CSD_BKOPS_EN 163 /* R/W */
+#define EXT_CSD_RST_N_FUNCTION 162 /* 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 */
@@ -70,6 +71,9 @@
#define EXT_CSD_BOOT_CFG_ACK (1<<6)
#define EXT_CSD_BOOT_CFG_EN (0x38)
#define EXT_CSD_BOOT_CFG_ACC (0x03)
+#define EXT_CSD_RST_N_EN_MASK (0x03)
+#define EXT_CSD_HW_RESET_EN (0x01)
+#define EXT_CSD_HW_RESET_DIS (0x02)
#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7)
#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1)
#define EXT_CSD_PART_CONFIG_ACC_BOOT1 (0x2)
diff --git a/mmc_cmds.c b/mmc_cmds.c
index 05d7e13..b407f65 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -280,6 +280,65 @@ int do_write_boot_en(int nargs, char **argv)
return ret;
}
+int do_hwreset(int value, int nargs, char **argv)
+{
+ __u8 ext_csd[512];
+ int fd, ret;
+ char *device;
+
+ CHECK(nargs != 2, "Usage: mmc hwreset 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_RST_N_FUNCTION] & EXT_CSD_RST_N_EN_MASK) ==
+ EXT_CSD_HW_RESET_EN) {
+ fprintf(stderr,
+ "H/W Reset is already permanently enabled on %s\n",
+ device);
+ exit(1);
+ }
+ if ((ext_csd[EXT_CSD_RST_N_FUNCTION] & EXT_CSD_RST_N_EN_MASK) ==
+ EXT_CSD_HW_RESET_DIS) {
+ fprintf(stderr,
+ "H/W Reset is already permanently disabled on %s\n",
+ device);
+ exit(1);
+ }
+
+ ret = write_extcsd_value(fd, EXT_CSD_RST_N_FUNCTION, value);
+ if (ret) {
+ fprintf(stderr,
+ "Could not write 0x%02x to EXT_CSD[%d] in %s\n",
+ value, EXT_CSD_RST_N_FUNCTION, device);
+ exit(1);
+ }
+
+ return ret;
+}
+
+int do_hwreset_en(int nargs, char **argv)
+{
+ return do_hwreset(EXT_CSD_HW_RESET_EN, nargs, argv);
+}
+
+int do_hwreset_dis(int nargs, char **argv)
+{
+ return do_hwreset(EXT_CSD_HW_RESET_DIS, nargs, argv);
+}
+
int do_write_bkops_en(int nargs, char **argv)
{
__u8 ext_csd[512], value = 0;
diff --git a/mmc_cmds.h b/mmc_cmds.h
index 1dd4324..e52d622 100644
--- a/mmc_cmds.h
+++ b/mmc_cmds.h
@@ -22,3 +22,5 @@ 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);
+int do_hwreset_en(int nargs, char **argv);
+int do_hwreset_dis(int nargs, char **argv);
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc-utils: Support enable/disable of eMMC H/W Reset function
2012-10-19 21:29 [PATCH] mmc-utils: Support enable/disable of eMMC H/W Reset function Chris Ball
@ 2012-10-22 7:11 ` Johan Rudholm
0 siblings, 0 replies; 2+ messages in thread
From: Johan Rudholm @ 2012-10-22 7:11 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc
Hi,
2012/10/19 Chris Ball <cjb@laptop.org>:
> (Note: one-time programmable fuse.)
>
> $ mmc hwreset enable /dev/mmcblk0
> $ mmc hwreset disable /dev/mmcblk0
> ---
> mmc.c | 10 ++++++++++
> mmc.h | 4 ++++
> mmc_cmds.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> mmc_cmds.h | 2 ++
> 4 files changed, 75 insertions(+)
we've played around with this feature a bit, and if the reset pin is
not connected to for instance a GPIO, enabling the reset can give
really interesting results :) But if it's connected on the other hand,
it works fine...
Acked-By: Johan Rudholm <johan.rudholm@stericsson.com>
Kind regards, Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-22 7:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-19 21:29 [PATCH] mmc-utils: Support enable/disable of eMMC H/W Reset function Chris Ball
2012-10-22 7:11 ` Johan Rudholm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).