Commit 6fbf36ea19ccc0eae7ebc59a7be6fc55ed9ef50f

Authored by Eric Lee
1 parent 164058671f

Lock Up SPI NOR to free ECSPI2 bus

Showing 2 changed files with 42 additions and 3 deletions Side-by-side Diff

board/embedian/smarcfimx6/smarcfimx6.c
... ... @@ -1261,6 +1261,18 @@
1261 1261 };
1262 1262 #endif
1263 1263  
  1264 +static int check_mmc_autodetect(void)
  1265 +{
  1266 + char *autodetect_str = getenv("mmcautodetect");
  1267 +
  1268 + if ((autodetect_str != NULL) &&
  1269 + (strcmp(autodetect_str, "yes") == 0)) {
  1270 + return 1;
  1271 + }
  1272 +
  1273 + return 0;
  1274 +}
  1275 +
1264 1276 void board_late_mmc_env_init(void)
1265 1277 {
1266 1278 char cmd[32];
... ... @@ -1346,6 +1358,8 @@
1346 1358 sizeof(header.serial), header.serial);
1347 1359 puts("-----------------------------------------\n");
1348 1360  
  1361 +/* Lock Up SPI NOR First to Free ECSPI2 Bus */
  1362 + gpio_direction_output(IMX_GPIO_NR(4,20), 0);
1349 1363 /* SMARC BOOT_SEL*/
1350 1364 gpio_request(IMX_GPIO_NR(1, 4), "BOOT_SEL_1");
1351 1365 gpio_request(IMX_GPIO_NR(1, 5), "BOOT_SEL_2");
... ... @@ -13,6 +13,7 @@
13 13 #include <mapmem.h>
14 14 #include <spi.h>
15 15 #include <spi_flash.h>
  16 +#include <asm/gpio.h>
16 17 #include <jffs2/jffs2.h>
17 18 #include <linux/mtd/mtd.h>
18 19  
19 20  
... ... @@ -557,7 +558,12 @@
557 558 ++argv;
558 559  
559 560 if (strcmp(cmd, "probe") == 0) {
  561 + gpio_request(IMX_GPIO_NR(4, 20), "SPI_LOCK_PIN");
  562 + /*Unlock SPI Flash*/
  563 + gpio_direction_output(IMX_GPIO_NR(4,20), 1);
560 564 ret = do_spi_flash_probe(argc, argv);
  565 + /*Lock Up SPI Flash*/
  566 + gpio_direction_output(IMX_GPIO_NR(4,20), 0);
561 567 goto done;
562 568 }
563 569  
564 570  
565 571  
566 572  
567 573  
568 574  
... ... @@ -568,15 +574,34 @@
568 574 }
569 575  
570 576 if (strcmp(cmd, "read") == 0 || strcmp(cmd, "write") == 0 ||
571   - strcmp(cmd, "update") == 0)
  577 + strcmp(cmd, "update") == 0) {
  578 + /*Unlock SPI Flash*/
  579 + gpio_direction_output(IMX_GPIO_NR(4,20), 1);
572 580 ret = do_spi_flash_read_write(argc, argv);
573   - else if (strcmp(cmd, "erase") == 0)
  581 + /*Lock Up SPI Flash*/
  582 + gpio_direction_output(IMX_GPIO_NR(4,20), 0);
  583 + }
  584 + else if (strcmp(cmd, "erase") == 0) {
  585 + /*Unlock SPI Flash*/
  586 + gpio_direction_output(IMX_GPIO_NR(4,20), 1);
574 587 ret = do_spi_flash_erase(argc, argv);
575   - else if (strcmp(cmd, "protect") == 0)
  588 + /*Lock Up SPI Flash*/
  589 + gpio_direction_output(IMX_GPIO_NR(4,20), 0);
  590 + }
  591 + else if (strcmp(cmd, "protect") == 0) {
  592 + /*Unlock SPI Flash*/
  593 + gpio_direction_output(IMX_GPIO_NR(4,20), 1);
576 594 ret = do_spi_protect(argc, argv);
  595 + /*Lock Up SPI Flash*/
  596 + gpio_direction_output(IMX_GPIO_NR(4,20), 0);
  597 + }
577 598 #ifdef CONFIG_CMD_SF_TEST
578 599 else if (!strcmp(cmd, "test"))
  600 + /*Unlock SPI Flash*/
  601 + gpio_direction_output(IMX_GPIO_NR(4,20), 1);
579 602 ret = do_spi_flash_test(argc, argv);
  603 + /*Lock Up SPI Flash*/
  604 + gpio_direction_output(IMX_GPIO_NR(4,20), 0);
580 605 #endif
581 606 else
582 607 ret = -1;