【OpenWrt筆記】MT76x8 reboot命令後系統死機

現象

將固件燒寫到系統後,執行reboot命令重啓時,開發板卡死,無法進入重啓流程。

解決

修改m25p80.c文件

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 8548270..9b186b1 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -259,6 +259,21 @@ static int m25p_remove(struct spi_device *spi)
         return mtd_device_unregister(&flash->spi_nor.mtd);
}

+static void m25p_shutdown(struct spi_device *spi)
+{
+        struct m25p        *flash = spi_get_drvdata(spi);
+
+        if ((&flash->spi_nor)->addr_width > 3) {
+                printk(KERN_INFO "m25p80: exit 4-byte address mode\n");
+                flash->command[0] = SPINOR_OP_EX4B;  // exit 4-byte address mode: 0xe9
+                spi_write(flash->spi, flash->command, 1);
+                flash->command[0] = 0x66;  // enable reset
+                spi_write(flash->spi, flash->command, 1);
+                flash->command[0] = 0x99;  // reset
+                spi_write(flash->spi, flash->command, 1);
+        }
+}
+
/*
  * Do NOT add to this array without reading the following:
  *
@@ -329,6 +344,7 @@ static struct spi_driver m25p80_driver = {
         .id_table        = m25p_ids,
         .probe        = m25p_probe,
         .remove        = m25p_remove,
+        .shutdown = m25p_shutdown,

         /* REVISIT: many of these chips have deep power-down modes, which
          * should clearly be entered on suspend() to minimize power use.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章