summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xboard/samsung/common/board.c11
-rwxr-xr-xdrivers/mmc/mmc.c29
-rwxr-xr-x[-rw-r--r--]drivers/mmc/mmc_boot.c10
3 files changed, 36 insertions, 14 deletions
diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index ebedde01f6..fe5b5339ee 100755
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -360,17 +360,6 @@ void reset_misc(void)
if (node < 0)
return;
-#if defined(CONFIG_TARGET_ODROID_XU3) || defined(CONFIG_TARGET_ODROID_XU4)
- /* eMMC hardware reset enable */
- {
- struct mmc *mmc = find_mmc_device(0);
- if (mmc) {
- if (!mmc_init(mmc) && !IS_SD(mmc))
- mmc_set_rst_n_function(mmc, 1);
- }
- }
-#endif
-
gpio_request_by_name_nodev(gd->fdt_blob, node, "reset-gpio", 0, &gpio,
GPIOD_IS_OUT);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c7c56c8c6e..6311c32667 100755
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -499,7 +499,6 @@ static int mmc_complete_op_cond(struct mmc *mmc)
return 0;
}
-
static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
{
struct mmc_cmd cmd;
@@ -521,6 +520,30 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)
return err;
}
+#if defined(CONFIG_TARGET_ODROID_XU3) || defined(CONFIG_TARGET_ODROID_XU4)
+int mmc_rst_n_func_status(struct mmc *mmc)
+{
+ int err;
+ ALLOC_CACHE_ALIGN_BUFFER(unsigned char, ext_csd, MMC_MAX_BLOCK_LEN);
+
+ err = mmc_send_ext_csd(mmc, ext_csd);
+ if (err) {
+ puts("Could not get ext_csd register values\n");
+ return err;
+ }
+
+ printf("%s : %d\n", __func__, ext_csd[EXT_CSD_RST_N_FUNCTION]);
+ printf("%s : EXT_CSD_RST_N_FUNCTION enable!\n", __func__);
+
+ return ext_csd[EXT_CSD_RST_N_FUNCTION];
+}
+#else
+int mmc_rst_n_func_status(struct mmc *mmc)
+{
+ return 0;
+}
+#endif
+
int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
{
struct mmc_cmd cmd;
@@ -1867,6 +1890,10 @@ int mmc_initialize(bd_t *bis)
return err;
printf("MMC Device %d (%s): ", dev, IS_SD(mmc) ? " SD " : "eMMC");
print_size(mmc->capacity, "\n");
+
+ /* enable EXT_CSD_RST_N_FUNCTION command for hardware reset */
+ if (!IS_SD(mmc))
+ mmc_set_rst_n_function(mmc, 1);
}
#endif
mmc_do_preinit();
diff --git a/drivers/mmc/mmc_boot.c b/drivers/mmc/mmc_boot.c
index ac6f56f157..b0a4b2b318 100644..100755
--- a/drivers/mmc/mmc_boot.c
+++ b/drivers/mmc/mmc_boot.c
@@ -112,8 +112,14 @@ int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
*
* Returns 0 on success.
*/
+#include <malloc.h>
+#include <memalign.h>
+
int mmc_set_rst_n_function(struct mmc *mmc, u8 enable)
{
- return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_RST_N_FUNCTION,
- enable);
+ if(!mmc_rst_n_func_status(mmc)) {
+ return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_RST_N_FUNCTION,
+ enable);
+ }
+ return 0;
}