From 029e728fc247bff680d202316071af64ca376aea Mon Sep 17 00:00:00 2001 From: Eric Lee Date: Sun, 1 Nov 2015 21:17:56 +0800 Subject: [PATCH] Unlock SPI NOR in sf utility. --- common/cmd_sf.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/common/cmd_sf.c b/common/cmd_sf.c index b4ceb71..246448f 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -502,7 +503,9 @@ static int do_spi_flash(cmd_tbl_t *cmdtp, int flag, int argc, ++argv; if (strcmp(cmd, "probe") == 0) { + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_probe(argc, argv); + gpio_direction_output(IMX_GPIO_NR(4,20), 0); goto done; } @@ -513,13 +516,22 @@ 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){ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_read_write(argc, argv); - else if (strcmp(cmd, "erase") == 0) + gpio_direction_output(IMX_GPIO_NR(4,20), 0); + } + else if (strcmp(cmd, "erase") == 0){ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_erase(argc, argv); + gpio_direction_output(IMX_GPIO_NR(4,20), 0); + } #ifdef CONFIG_CMD_SF_TEST - else if (!strcmp(cmd, "test")) + else if (!strcmp(cmd, "test")){ + gpio_direction_output(IMX_GPIO_NR(4,20), 1); ret = do_spi_flash_test(argc, argv); + gpio_direction_output(IMX_GPIO_NR(4,20), 0); + } #endif else ret = -1; -- 1.9.1