各位好。
有没有相关的资料介绍如何在4.x的内核设备树中配置双百兆(rmii模式)网口的?
Shine:
请参考下面的CPSW user guide.
processors.wiki.ti.com/…/Linux_Core_CPSW_User's_Guide
LONGFEI LI1:
回复 Shine:
你好 Shine Zhang。
配置单网口为RMII模式,遇到下面的问题,请帮忙看看是哪里配置的有问题,谢谢。
cpu是am3352,phy芯片是dp83620,需要配置成百兆的RMII模式,片外晶振提供时钟,硬件配置phy地址位5,我配置的设备树如下:
cpsw_default: cpsw_default { pinctrl-single,pins = < /* Slave 1 */ AM33XX_IOPAD(0x90C, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_crs.rmii1_crs_dv */ AM33XX_IOPAD(0x910, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxerr.rmii1_rxerr */ AM33XX_IOPAD(0x914, PIN_OUTPUT | MUX_MODE1) /* mii1_txen.rmii1_txen */ AM33XX_IOPAD(0x924, PIN_OUTPUT | MUX_MODE1) /* mii1_txd1.rmii1_txd1 */ AM33XX_IOPAD(0x928, PIN_OUTPUT | MUX_MODE1) /* mii1_txd0.rmii1_txd0 */ AM33XX_IOPAD(0x944, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mii1_refclk.rmii1_refclk */ AM33XX_IOPAD(0x93c, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxd1.rmii1_rxd1 */ AM33XX_IOPAD(0x940, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxd0.rmii1_rxd0 */ >; };
cpsw_sleep: cpsw_sleep { pinctrl-single,pins = < /* Slave 1 reset value */ AM33XX_IOPAD(0x90C, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x910, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x914, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x924, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x928, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x944, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x93c, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x940, PIN_INPUT_PULLDOWN | MUX_MODE7) >; }; davinci_mdio_default: davinci_mdio_default { pinctrl-single,pins = < /* MDIO */ AM33XX_IOPAD(0x948, PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE0) /* mdio_data.mdio_data */ AM33XX_IOPAD(0x94c, PIN_OUTPUT_PULLUP | MUX_MODE0) /* mdio_clk.mdio_clk */ >; };
davinci_mdio_sleep: davinci_mdio_sleep { pinctrl-single,pins = < /* MDIO reset value */ AM33XX_IOPAD(0x948, PIN_INPUT_PULLDOWN | MUX_MODE7) AM33XX_IOPAD(0x94c, PIN_INPUT_PULLDOWN | MUX_MODE7) >; };
&mac { pinctrl-names = "default", "sleep"; pinctrl-0 = <&cpsw_default>; pinctrl-1 = <&cpsw_sleep>; status = "okay";};
&davinci_mdio { pinctrl-names = "default", "sleep"; pinctrl-0 = <&davinci_mdio_default>; pinctrl-1 = <&davinci_mdio_sleep>; status = "okay";};
&cpsw_emac0 { phy_id = <&davinci_mdio>, <5>; phy-mode = "rmii";};&phy_sel { rmii-clock-ext;};
目前我的单板启动过程中会提示没有找到phy:
[ 1.401063] omap_rng 48310000.rng: OMAP Random Number Generator ver. 20[ 1.408472] [drm] Initialized[ 1.446133] brd: module loaded[ 1.466036] loop: module loaded[ 1.475613] libphy: Fixed MDIO Bus: probed[ 1.556382] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6[ 1.562893] davinci_mdio 4a101000.mdio: no live phy, scanning all[ 1.569968] davinci_mdio: probe of 4a101000.mdio failed with error -5[ 1.578211] cpsw 4a100000.ethernet: No slave[1] phy_id, phy-handle, or fixed-link property[ 1.587126] cpsw 4a100000.ethernet: Detected MACID = 98:5d:ad:b6:29:04[ 1.594314] cpsw 4a100000.ethernet: cpts: overflow check period 500 (jiffies)[ 1.606503] mousedev: PS/2 mouse device common for all mice[ 1.613590] i2c /dev entries driver
……
[ 8.642974] net eth0: initializing cpsw version 1.12 (0)[ 8.648628] net eth0: initialized cpsw ale version 1.4[ 8.654023] net eth0: ALE Table size 1024[ 8.661486] libphy: PHY 4a101000.mdio:05 not found[ 8.666535] net eth0: phy "4a101000.mdio:05" not found on slave 0, err -19[ 8.673760] libphy: PHY not found[ 8.677344] net eth0: phy "" not found on slave 1, err -19[ 8.694482] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
烦请帮忙看看是否哪里配置有问题,谢谢。
Steven Liu1:
回复 LONGFEI LI1:
参考这个:
e2echina.ti.com/…/45981
确认一下GMII_SEL, 相关的PINMUX,PHY_ID都该正确是你要的配置了吗?特别是GMII_SEL和PINMUX,用寄存器回读的方法看一下生效值是不是正确的。
LONGFEI LI1:
回复 Steven Liu1:
你好,经过添加打印信息发现driver/net/ethernet/ti/cpsw-phy-sel.c文件中的cpsw_gmii_sel_am3352函数没有执行到:
static const struct of_device_id cpsw_phy_sel_id_table[] = {{.compatible = "ti,am3352-cpsw-phy-sel",.data= &cpsw_gmii_sel_am3352,},{.compatible = "ti,dra7xx-cpsw-phy-sel",.data= &cpsw_gmii_sel_dra7xx,},{.compatible = "ti,am43xx-cpsw-phy-sel",.data= &cpsw_gmii_sel_am3352,},{}
};
请问 struct of_device_id结构的data成员在内核代码的什么地方会被调用?
LONGFEI LI1:
回复 Steven Liu1:
更新一下:
按照提供的连接检查,读取并打印gmii-sel寄存器的值为0xC5(片外晶振模式),此配置应该没问题,pinmux的配置我检查过了应该也不存在问题才对,管脚配置如下:
cpsw_default: cpsw_default {
pinctrl-single,pins = <
/* Slave 1 */
AM33XX_IOPAD(0x90C, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_crs.rmii1_crs_dv */
AM33XX_IOPAD(0x910, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxerr.rmii1_rxerr */
AM33XX_IOPAD(0x914, PIN_OUTPUT | MUX_MODE1) /* mii1_txen.rmii1_txen */
AM33XX_IOPAD(0x924, PIN_OUTPUT | MUX_MODE1) /* mii1_txd1.rmii1_txd1 */
AM33XX_IOPAD(0x928, PIN_OUTPUT | MUX_MODE1) /* mii1_txd0.rmii1_txd0 */
AM33XX_IOPAD(0x944, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mii1_refclk.rmii1_refclk */
AM33XX_IOPAD(0x93c, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxd1.rmii1_rxd1 */
AM33XX_IOPAD(0x940, PIN_INPUT_PULLDOWN | MUX_MODE1) /* mii1_rxd0.rmii1_rxd0 */
>;
};
还有一项是硬件连接的phy_id,我们的硬件工程师分配的phy_id是5,在设备树中配置如下(phy_id属性的第二个参数配置成5):
&cpsw_emac0 {
phy_id = <&davinci_mdio>, <5>;
phy-mode = "rmii";
};
如此对比的话,哪里存在问题吗?请指教。
Shine:
回复 LONGFEI LI1:
感谢分享解决方法!