EVB-335x-II
以下内容为具体步骤说明。
一、u-boot里如何修改phy1、引脚初始化打开 board/eac/com335x/mux.c文件,增加以下内容:
static struct module_pin_muxrmii1_pin_mux[] = {
{OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* RMII1_CRS */
{OFFSET(mii1_rxerr), MODE(1) | RXACTIVE}, /* RMII1_RXERR */
{OFFSET(mii1_txen), MODE(1)}, /* RMII1_TXEN */
{OFFSET(mii1_txd1), MODE(1)}, /* RMII1_TXD1 */
{OFFSET(mii1_txd0), MODE(1)}, /* RMII1_TXD0 */
{OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* RMII1_RXD1 */
{OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* RMII1_RXD0 */
{OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
{OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
{OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REFCLK */
{-1},
};
在enable_board_pin_mux(void)函数中,做以下修改:
void enable_board_pin_mux(void)
{
......
// configure_module_pin_mux(rgmii1_pin_mux);
configure_module_pin_mux(rmii1_pin_mux);
......
}
2、驱动初始化打开board/eac/com335x/board.c,在cpsw_slaves[]结构体中,修改phy_addr(由LAN8720的硬件连接决定,本文以0为例):
static struct cpsw_slave_datacpsw_slaves[] = {
{
.slave_reg_ofs = 0x208,
.sliver_reg_ofs = 0xd80,
.phy_addr = 0x00,
},
......
};
在 board_eth_init(bd_t *bis)函数中,修改cpsw的通信模式为RMII:
int board_eth_init(bd_t *bis)
{
.......
writel((RMII_MODE_ENABLE| RMII_CHIPCKL_ENABLE), &cdev->miisel);
........
}
注:RMII_CHIPCKL_ENABLE为rmii_refclk输入使能,即rmii_refclk信号由phy芯片提供而不是由CPU提供,该参数由硬件设计决定。在底板设计指导手册中,使用的是LAN8720输出的rmii_refclk信号,因此需要添加改参数,否则会导致rmii_refclk信号出现问题;如果硬件设计为由CPU提供的话,则无需添加该参数。
另外,要确保include/configs/com335x.h文件中有如下宏定义;
#define CONFIG_PHY_SMSC
该定义为phy芯片驱动配置,文件中默认有定义,无需修改。
至此,uboot修改完毕,重新编译即可。
二、kernel里如何修改phy(单网络,rmii1接口)1、内核配置Device Drivers --->
Networkdevice support --->
Ethernetdriver support --->
TexasInstruments (TI) devices
-*- TI DaVinci MDIOSupport
-*- TI DaVinciCPDMA Support
<*> TI CPSWSwitch Support
[] TI CPSW Switchas Dual EMAC
-*- PHY Device support and infrastructure --->
<*> Drivers for SMSC PHYs
2、引脚初始化打开板级初始化文件arch/arm/mach-omap2/board-com335x.c,增加以下内容:
/* Module pin mux for rmii1 */
static struct pinmux_configrmii1_pin_mux[] = {
{"mii1_crs.rmii1_crs_dv",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"mii1_rxerr.mii1_rxerr",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"mii1_txen.mii1_txen",OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
{"mii1_txd1.mii1_txd1",OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
{"mii1_txd0.mii1_txd0",OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
{"mii1_rxd1.mii1_rxd1",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"mii1_rxd0.mii1_rxd0",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"rmii1_refclk.rmii1_refclk",OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
{"mdio_data.mdio_data",OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"mdio_clk.mdio_clk",OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT_PULLUP},
{NULL,0},
};
注意:引脚不要被其它功能复用!
3、驱动初始化在board-com335x.c文件的com335x_eth_init(void)函数中,做以下修改:
static void com335x_eth_init(void)
{
setup_pin_mux(rmii1_pin_mux);
am33xx_cpsw_init(AM33XX_CPSW_MODE_RMII, "0:00", NULL);
// intret = phy_register_fixup_for_uid(COM335X_EVM_PHY_ID, COM335X_PHY_MASK, am33xx_tx_clk_dly_phy_fixup);
}
注:am33xx_cpsw_init(AM33XX_CPSW_MODE_RMII, "0:00", NULL)里的第一个参数为指定RMII模式,第二个参数为rmii1接口上的phy_addr,第三个参数为rmii2接口上的phy_addr。修改完成后,保存文件。
在上一节提到,我们的设计中,rmii_refclk信号由phy芯片提供,因此需要使能rmii1_refclk为输入,打开arch/arm/mach-omap2/devices.c文件,在am33xx_cpsw_init函数中,增加以下内容:
int am33xx_cpsw_init(enumam33xx_cpsw_mac_mode mode, unsigned char *phy_id0,
unsigned char *phy_id1)
{
......
#defineRMII1_IO_CLK_EN 1 << 6
gmii_sel |=(RMII1_IO_CLK_EN);
writel(gmii_sel,AM33XX_CTRL_REGADDR(AM33XX_CONTROL_GMII_SEL_OFFSET));
......
}
修改完成后,保存退出。重新编译系统即可。
三、kernel里如何修改phy(双网络,rmii1、rmii2接口)1、内核配置Device Drivers --->
Networkdevice support --->
Ethernetdriver support --->
TexasInstruments (TI) devices
-*- TI DaVinci MDIOSupport
-*- TI DaVinciCPDMA Support
<*> TI CPSWSwitch Support
TI CPSW Switchas Dual EMAC
-*- PHY Device support and infrastructure --->
<*> Drivers for SMSC PHYs
2、引脚初始化打开板级初始化文件arch/arm/mach-omap2/board-com335x.c,增加以下内容:
/* Module pin mux for rmii1 */
static struct pinmux_configrmii1_pin_mux[] = {
{"mii1_crs.rmii1_crs_dv",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"mii1_rxerr.mii1_rxerr",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"mii1_txen.mii1_txen",OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
{"mii1_txd1.mii1_txd1",OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
{"mii1_txd0.mii1_txd0",OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
{"mii1_rxd1.mii1_rxd1",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"mii1_rxd0.mii1_rxd0",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"rmii1_refclk.rmii1_refclk",OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
{"mdio_data.mdio_data",OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"mdio_clk.mdio_clk",OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT_PULLUP},
{NULL,0},
};
/* Module pin mux for rmii2 */
static struct pinmux_configrmii2_pin_mux[] = {
{"gpmc_csn3.rmii2_crs_dv",OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
// {"gpmc_wpn.rmii2_rxerr",OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLDOWN},
{"gpmc_a0.rmii2_txen",OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},
{"gpmc_a4.rmii2_txd1",OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},
{"gpmc_a5.rmii2_txd0",OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},
{"gpmc_a10.rmii2_rxd1",OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLDOWN},
{"gpmc_a11.rmii2_rxd0",OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLDOWN},
{"mii1_col.rmii2_refclk",OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
{"mdio_data.mdio_data",OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
{"mdio_clk.mdio_clk",OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT_PULLUP},
{NULL,0},
};
注意:引脚不要被其它功能复用!另外,根据底板设计手册,在rmii2接口中,由于rmii2_rxerr脚已经被gpmc使用,因此rmii2_rxerr未与LAN8720连接,经测试,未发现此情况下对网络有影响。
3、驱动初始化在board-com335x.c文件的com335x_eth_init(void)函数中,做以下修改:
static void com335x_eth_init(void)
{
setup_pin_mux(rmii1_pin_mux);
setup_pin_mux(rmii2_pin_mux);
am33xx_cpsw_init(AM33XX_CPSW_MODE_RMII, "0:00", "0:01");
// intret = phy_register_fixup_for_uid(COM335X_EVM_PHY_ID, COM335X_PHY_MASK, am33xx_tx_clk_dly_phy_fixup);
}
注:详细说明请参考上一节。修改完成后,保存文件。
使能rmii1_refclk、rmii2_refclk为输入(参考上一节),打开arch/arm/mach-omap2/devices.c文件,在am33xx_cpsw_init函数中,增加以下内容:
int am33xx_cpsw_init(enumam33xx_cpsw_mac_mode mode, unsigned char *phy_id0,
unsigned char *phy_id1)
{
......
#defineRMII1_IO_CLK_EN 1 << 6
#defineRMII2_IO_CLK_EN 1 << 7
gmii_sel |=(RMII1_IO_CLK_EN);
writel(gmii_sel,AM33XX_CTRL_REGADDR(AM33XX_CONTROL_GMII_SEL_OFFSET));
......
}
修改完成后,保存退出。重新编译系统即可。
4、双网络使用说明将上述步骤编译的内核烧录到COM335X,系统启动后,在终端输入ifconfig -a命令可以查看到eth0和eth1两个设备。如需同时使用eth0和eth1,必须注意两者不能在同一网段!