作者
QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118
参考
QCA switch芯片配置说明
移植OpenWRT下的ART驱动程序
(20191011)QCA9563(同K2T)石像鬼openwrt 固件
有art相关移植到openwrt
atheros无线驱动之:系统初始化
Atheros开源驱动发展历史的介绍
高通atheros ar93xx AP软件体系结构
AR/QCA/MTK Breed,功能强大的多线程 Bootloader
Marvell 98DX51xx / 98DX81xx 系列交换芯片 内部初始化
Linux 4.0+内核对硬件交换模块的支持(HW Switch Offload)
芯片手册下载
了解与MDIO/MDC接口相关的22号、45号条款
QCA9886降低功耗指令
极具战略性的核武器—网件夜鹰X10 R9000评测
高通AP152_QCA9563+QCA9882+QCA8337N官方HDK开发资料(datasheet,bom,原理图,pcb等)
Marvell 交换芯片DSA(分布式交换架构)功能介绍
QCA8337
芯片结构图,
支持如下几种配置方式,有一个方式比较有意思,有一个独立的PHY,相当于一个AR8033,
Mode的切换通过下面3个pad寄存器来实现,
#define QCA8K_REG_PORT0_PAD_CTRL 0x004
#define QCA8K_REG_PORT5_PAD_CTRL 0x008
#define QCA8K_REG_PORT6_PAD_CTRL 0x00c
寄存器访问通过MDIO来实现,和普通的phy有区别,IEEE802.3 clause22对应的格式为,
qca8337的mdio时序如下图,PHYADR是5bit,在写高地址时,PHYADR是0x18即24,在读写数据的时候PHYADR是(0x10 | A[8:6]),
协议栈可利用atheros header
控制包转发,The QCA8337N support proprietary Qualcomm Atheros header that can indicate the packet information and allow CPU to control the packet forwarding. The header can be 2 bytes or 4 bytes with additional 2 bytes identifier. For 2 bytes header, each packet sent out or received must include header. For 4 bytes header, header can exist only in the management frame and there is no header in the normal frame. The Atheros header also supports read/write register through the CPU port.
u-boot
先ping,初始化网卡寄存器,然后可以读写寄存器。
zynq-uboot> ping 192.168.6.6
Gem.e000b000: link UP, phyaddr: 1, speed: 100.
Using Gem.e000b000 device
host 192.168.6.6 is alive
zynq-uboot> qca8337read 0
0x0: 0x1302
linux驱动
我用的petalinux2015.2.1,内核版本3.19,没有qca8337的驱动,所以需要全新移植,
//*\net\dsa\dsa.c line869 添加对qca8337的支持
static const struct of_device_id dsa_of_match_table[] = {
{ .compatible = "brcm,bcm7445-switch-v4.0" },
{ .compatible = "marvell,dsa", },
{ .compatible = "qca,qca8337" },
{}
};
MODULE_DEVICE_TABLE(of, dsa_of_match_table);
设备树参考marvell的,其中reg字段标识了switch的mdio地址,这在QCA8337里不使用,参考上面所述,PHYADR在读写数据时是变化的,直接在QCA8337的驱动里写死了,但是如果访问的switch寄存器地址在0~31范围内,可以认为switch的mdio地址是16。QCA8337不能允许在一个mdio总线上挂多个芯片,但是marvell的是可以的。参考内核文档qca8k.txt
,每一个port节点都需要指定phy-handle
,因为QCA8K switches do not have a N:N mapping of port and PHY id
,所以,无法使用slave MII bus created by DSA
。
dsa@0 {
compatible = "marvell,dsa";
#address-cells = <2>;
#size-cells = <0>;
interrupts = <10>;
dsa,ethernet = <ðernet0>;
dsa,mii-bus = <&mii_bus0>;
switch@0 {
#address-cells = <1>;
#size-cells = <0>;
reg = <16 0>; /* MDIO address 16, switch 0 in tree */
port@0 {
reg = <0>;
label = "lan1";
phy-handle = <&phy0>;
};
port@1 {
reg = <1>;
label = "lan2";
};
port@5 {
reg = <5>;
label = "cpu";
};
switch0uplink: port@6 {
reg = <6>;
label = "dsa";
link = <&switch1uplink>;
};
};
switch@1 {
#address-cells = <1>;
#size-cells = <0>;
reg = <17 1>; /* MDIO address 17, switch 1 in tree */
switch1uplink: port@0 {
reg = <0>;
label = "dsa";
link = <&switch0uplink>;
};
};
};