diff --git a/board/embedian/smarcfimx6/smarcfimx6.c b/board/embedian/smarcfimx6/smarcfimx6.c index c6e9a55..dcc2c00 100644 --- a/board/embedian/smarcfimx6/smarcfimx6.c +++ b/board/embedian/smarcfimx6/smarcfimx6.c @@ -1261,6 +1261,18 @@ static const struct boot_mode board_boot_modes[] = { }; #endif +static int check_mmc_autodetect(void) +{ + char *autodetect_str = getenv("mmcautodetect"); + + if ((autodetect_str != NULL) && + (strcmp(autodetect_str, "yes") == 0)) { + return 1; + } + + return 0; +} + void board_late_mmc_env_init(void) { char cmd[32]; @@ -1346,6 +1358,8 @@ int board_late_init(void) sizeof(header.serial), header.serial); puts("-----------------------------------------\n"); +/* Lock Up SPI NOR First to Free ECSPI2 Bus */ + gpio_direction_output(IMX_GPIO_NR(4,20), 0); /* SMARC BOOT_SEL*/ gpio_request(IMX_GPIO_NR(1, 4), "BOOT_SEL_1"); gpio_request(IMX_GPIO_NR(1, 5), "BOOT_SEL_2"); diff --git a/cmd/sf.c b/cmd/sf.c index 65b117f..12506ec 100644 --- a/cmd/sf.c +++ b/cmd/sf.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -557,7 +558,12 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int argc, ++argv; if (strcmp(cmd, "probe") == 0) { + gpio_request(IMX_GPIO_NR(4, 20), "SPI_LOCK_PIN"); + /*Unlock SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_probe(argc, argv); + /*Lock Up SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 0); goto done; } @@ -568,15 +574,34 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int argc, } if (strcmp(cmd, "read") == 0 || strcmp(cmd, "write") == 0 || - strcmp(cmd, "update") == 0) + strcmp(cmd, "update") == 0) { + /*Unlock SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_read_write(argc, argv); - else if (strcmp(cmd, "erase") == 0) + /*Lock Up SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 0); + } + else if (strcmp(cmd, "erase") == 0) { + /*Unlock SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_erase(argc, argv); - else if (strcmp(cmd, "protect") == 0) + /*Lock Up SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 0); + } + else if (strcmp(cmd, "protect") == 0) { + /*Unlock SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_protect(argc, argv); + /*Lock Up SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 0); + } #ifdef CONFIG_CMD_SF_TEST else if (!strcmp(cmd, "test")) + /*Unlock SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_test(argc, argv); + /*Lock Up SPI Flash*/ + gpio_direction_output(IMX_GPIO_NR(4,20), 0); #endif else ret = -1;