MT76x8的多网口与GPIO复用配置
生活随笔
收集整理的這篇文章主要介紹了
MT76x8的多网口与GPIO复用配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?MT7628與MT7688除了WIFI之外,其他幾乎一樣,沒有區別;至少在網口方面是一樣的;本文將介紹Openwrt中多網口與其復用為GPIO的方式
關于模式:
只有單網口以及5網口的兩種,沒有中間方案;這一點需要留意;
首先看datasheet配置
關于寄存器配置,可以在兩個地方進行:
其一Uboot中設定
drivers/rt2880_eth.c, 宏定義CONFIG_ETH_ONE_PORT_ONLY部分即是;
menuconfig的配置除了ONE_PORT_ONLY 之外還有WLLL,LLLW等配置,自行根據板子所用到的網口進行選擇;
x x [ ] ETH One Port Only x x [*] Partition LAN/WAN x x (LLLL/W) LAN/WAN Board Layout x x --- x x Load an Alternate Configuration File x x Save Configuration to an Alternate File
內核的配置,主要在DTS中:
ethernet@10100000 {mtd-mac-address = <&factory 0x4>;ralink,port-map = "llllw";};"ralink,port-map"將被 drivres/net/ethernet/ralink/esw_rt3052.c 解析 #define RT305X_ESW_PMAP_LLLLLL?? ??? ?0x3f #define RT305X_ESW_PMAP_LLLLWL?? ??? ?0x2f #define RT305X_ESW_PMAP_WLLLLL?? ??? ?0x3estatic int esw_probe(struct platform_device *pdev) { ... port_map = of_get_property(np, "ralink,portmap", NULL);if (port_map)esw->port_map = be32_to_cpu(*port_map);... esw_hw_init(esw); }static void esw_hw_init(struct rt305x_esw *esw) {int i;u8 port_disable = 0;u8 port_map = RT305X_ESW_PMAP_LLLLLL; ...if (esw->port_map)port_map = esw->port_map;elseport_map = RT305X_ESW_PMAP_LLLLLL;/** Unused HW feature, but still nice to be consistent here...* This is also exported to userspace ('lan' attribute) so it's* conveniently usable to decide which ports go into the wan vlan by* default.*/esw_rmw(esw, RT305X_ESW_REG_SGC2,RT305X_ESW_SGC2_LAN_PMAP_M << RT305X_ESW_SGC2_LAN_PMAP_S,port_map << RT305X_ESW_SGC2_LAN_PMAP_S); } 因此無論uboot和dts中如何配置,PORT0 一定是作為網口并且是使能可用的;需要注意的地方
Uboot中針對網口寄存器進行了設定之后,Kernel中 解析dts配置,然后驅動初始化,并沒有設定全部,最終加載后,還是只有一個網口;
即如果使用的是單網口配置的uboot,openwrt系統起來后,還需在對寄存器進行一次設定;
在此,我們可以參考mtk-openwrt-sdk中的reg工具進行,在openwrt系統加載完后,在應用空間進行寄存器修改
start() {reg w 10000064 0x0reg w 1000003c 0xe001ff }關于LAN和WAN的設定,在文件 target/linux/ramips/base-files/etc/board.d/02_network
ramips_setup_rt3x5x_vlans() {if [ ! -x /sbin/swconfig ]; then# legacy defaultucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"returnfilocal wanports=""local lanports=""for port in 5 4 3 2 1 0; doif [ `swconfig dev rt305x port $port get disable` = "1" ]; thencontinuefiif [ `swconfig dev rt305x port $port get lan` = "0" ]; thenwanports="$port $wanports"elselanports="$port $lanports"fidoneucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"ucidef_add_switch "rt305x" "1" "1"ucidef_add_switch_vlan "rt305x" "1" "$lanports 6t"ucidef_add_switch_vlan "rt305x" "2" "$wanports 6t" } ... zbt-wg2626)|\ your-borad-name)ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"ucidef_add_switch "switch0" "1" "1"ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 6t"ucidef_add_switch_vlan "switch0" "2" "4 6t";;需要注意的是 02_network僅僅只是將配置寫入配置文件,然后有系統加載執行,前提是reg 先設定好相關寄存器,否則只改變02_network是無效的;
總結
以上是生活随笔為你收集整理的MT76x8的多网口与GPIO复用配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用Buildroot为Nxp i.mx
- 下一篇: nodogsplash的内部机制分析