本文主要是關(guān)于MT7621和QCA9558的相關(guān)介紹,并著重對(duì)MT7621和QCA9558進(jìn)行詳盡的對(duì)比分析。
MT7621和QCA9558的差距
MT7621 比9558 強(qiáng)多了。不是一個(gè)檔次的。你可以上openwrt官網(wǎng)看看,我給你截了個(gè)圖。你就很明了了。最后一欄越高越好。9558比MT7620A好一點(diǎn)。MT7621應(yīng)該面對(duì)的競爭對(duì)手是BCM4708/4709或者高通的IPQ8064。但這只是MTK的愿望,7621的表現(xiàn)離這兩款的差距還是有點(diǎn)大,所以后來出了個(gè)MT7623,但是芯片發(fā)布了一年多了,到現(xiàn)在市場還沒出現(xiàn)一款消費(fèi)級(jí)別的路由用此芯片,我估計(jì)還是MTK的老問題。
淺談MT7621應(yīng)用
OpenWrt的最新kernel(3.18.23)已經(jīng)能夠支持32M SPI Flash的讀寫以及擦除操作。然而,可能是系統(tǒng)考慮不周,亦或是MT7621系統(tǒng)的BUG,在配置了W25Q256的MT7621開發(fā)板系統(tǒng)上,無法soft reset!經(jīng)過查閱相關(guān)資料,發(fā)現(xiàn),MT7621默認(rèn)支持24bit(3byte)的spi地址模式,而要支持32M以上的spi flash,則必須切換到32bit(4byte)地址模式。在soft reset的時(shí)候,spi停留在了32bit模式,沒有切換回默認(rèn)的24bit模式,導(dǎo)致reset后,MT7621在默認(rèn)的24bit模式,無法和32bit模式的spi通訊,系統(tǒng)死機(jī)。
在linux源代碼kernel目錄下,有一個(gè)reboot.c文件,里面暴露了一個(gè)register_reboot_notifier方法,可以讓kernel中的代碼有機(jī)會(huì)獲得reboot的通知,當(dāng)我們繼續(xù)分析reboot.c的代碼時(shí),會(huì)發(fā)現(xiàn)更有意思的東西:
/**
* kernel_restart - reboot the system
* @cmd: pointer to buffer containing command to execute for restart
* or %NULL
*
* Shutdown everything and perform a clean reboot.
* This is not safe to call in interrupt context.
*/
void kernel_restart(char *cmd)
{
kernel_restart_prepare(cmd);
migrate_to_reboot_cpu();
syscore_shutdown();
if (!cmd)
pr_emerg(“Restarting system\n”);
else
pr_emerg(“Restarting system with command ‘%s’\n”, cmd);
kmsg_dump(KMSG_DUMP_RESTART);
machine_restart(cmd);
}
在kernel_restart中,又調(diào)用了kernel_restart_prepare方法:
void kernel_restart_prepare(char *cmd)
{
blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
system_state = SYSTEM_RESTART;
usermodehelper_disable();
device_shutdown();
}
device_shutdown在drivers/base/core.c中實(shí)現(xiàn):
/**
* device_shutdown - call -》shutdown() on each device to shutdown.
*/
void device_shutdown(void)
{
struct device *dev, *parent;
spin_lock(&devices_kset-》list_lock);
/*
* Walk the devices list backward, shutting down each in turn.
* Beware that device unplug events may also start pulling
* devices offline, even as the system is shutting down.
*/
while (!list_empty(&devices_kset-》list)) {
dev = list_entry(devices_kset-》list.prev, struct device,
kobj.entry);
/*
* hold reference count of device‘s parent to
* prevent it from being freed because parent’s
* lock is to be held
*/
parent = get_device(dev-》parent);
get_device(dev);
/*
* Make sure the device is off the kset list, in the
* event that dev-》*-》shutdown() doesn‘t remove it.
*/
list_del_init(&dev-》kobj.entry);
spin_unlock(&devices_kset-》list_lock);
/* hold lock to avoid race with probe/release */
if (parent)
device_lock(parent);
device_lock(dev);
/* Don’t allow any more runtime suspends */
pm_runtime_get_noresume(dev);
pm_runtime_barrier(dev);
// manfeel, add debug info
//dev_info(dev,“search shutdown method.。.\n”);
if (dev-》bus && dev-》bus-》shutdown) {
//if (initcall_debug) manfeel
dev_info(dev, “shutdown\n”);
dev-》bus-》shutdown(dev);
} else if (dev-》driver && dev-》driver-》shutdown) {
//if (initcall_debug) manfeel
dev_info(dev, “shutdown\n”);
dev-》driver-》shutdown(dev);
}
device_unlock(dev);
if (parent)
device_unlock(parent);
put_device(dev);
put_device(parent);
spin_lock(&devices_kset-》list_lock);
}
spin_unlock(&devices_kset-》list_lock);
async_synchronize_full();
}
通過閱讀代碼,我們不難發(fā)現(xiàn),在device_shutdown中,枚舉了設(shè)備的shutdown方法,如果存在該方法,則會(huì)調(diào)用之。
于是,32M spi flash的reset方法噴薄而出。
解決辦法
轉(zhuǎn)到drivers/mtd/devices/m25p80.c
修改如下代碼:
static int m25p_remove(struct spi_device *spi)
{
struct m25p *flash = spi_get_drvdata(spi);
// manfeel note: add spi flash reset code
flash-》command[0] = 0x66;
spi_write(flash-》spi, flash-》command, 1);
flash-》command[0] = 0x99;
spi_write(flash-》spi, flash-》command, 1);
/* Clean up MTD stuff. */
return mtd_device_unregister(&flash-》mtd);
}
static struct spi_driver m25p80_driver = {
.driver = {
.name = “m25p80”,
.owner = THIS_MODULE,
},
.id_table = m25p_ids,
.probe = m25p_probe,
.remove = m25p_remove,
// manfeel, add shutdown method to reset spi flash
.shutdown = m25p_remove,
/* REVISIT: many of these chips have deep power-down modes, which
* should clearly be entered on suspend() to minimize power use.
* And also when they‘re otherwise idle.。.
*/
};
結(jié)語
關(guān)于MT7621和QCA9558的相關(guān)介紹就到這了,如有不足之處歡迎指正。
評(píng)論
查看更多