am335x system upgrade uboot ethernet(二)
系统可以通过SD卡引道之后,为了之后了调试方便
通过查看网卡的硬件设计
正常来说需要注意的有如下几点:
1) 网口 的接线方式: RMII
2) 网口的PHY地址两张网口,这里我们只需先初始化一张网卡,通过查看PHY的数据手册,可以发现其代码PHY地址是0.
3) 将对应的网卡驱动在include/configs/am335x_evm.h 添加对应的网卡驱动选项,以支持对应的PHY.
Index: board.c
===================================================================
--- board.c (revision 7)
+++ board.c (revision 8)
@@ -816,7 +816,7 @@
{
.slave_reg_ofs = 0x308,
.sliver_reg_ofs = 0xdc0,
- .phy_addr = 1,
+ .phy_addr = 3,
},
};
@@ -889,6 +889,7 @@
}
#ifdef CONFIG_DRIVER_TI_CPSW
+#if 0
if (board_is_bone() || board_is_bone_lt() ||
board_is_idk()) {
writel(MII_MODE_ENABLE, &cdev->miisel);
@@ -895,17 +896,19 @@
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
PHY_INTERFACE_MODE_MII;
} else if (board_is_icev2()) {
+#endif
writel(RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE, &cdev->miisel);
cpsw_slaves[0].phy_if = PHY_INTERFACE_MODE_RMII;
cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RMII;
- cpsw_slaves[0].phy_addr = 1;
+ cpsw_slaves[0].phy_addr = 0;
cpsw_slaves[1].phy_addr = 3;
+#if 0
} else {
writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel);
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
PHY_INTERFACE_MODE_RGMII;
}
-
+#endif
rv = cpsw_register(&cpsw_data);
if (rv < 0)
printf("Error %d registering CPSW switch\n", rv);
@@ -924,7 +927,7 @@
#define AR8051_PHY_DEBUG_DATA_REG 0x1e
#define AR8051_DEBUG_RGMII_CLK_DLY_REG 0x5
#define AR8051_RGMII_TX_CLK_DLY 0x100
网口引脚初始化:
Index: mux.c
===================================================================
--- mux.c (revision 7)
+++ mux.c (revision 8)
@@ -176,7 +176,7 @@
{OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
{-1},
};
-
+#if 1
static struct module_pin_mux rmii1_pin_mux[] = {
{OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
{OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
@@ -190,7 +190,23 @@
{OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REFCLK */
{-1},
};
+#endif
+#if 0
+static struct module_pin_mux rmii1_pin_mux[] = {
+ {OFFSET(mii1_txen), MODE(1)}, /* RMII1_Txen */
+ {OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* RMII1_CRS */
+ {OFFSET(mii1_txd1), MODE(1)}, /* RMII1_TD1 */
+ {OFFSET(mii1_txd0), MODE(1)}, /* RMII1_TD0 */
+ {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* RMII1_RD1 */
+ {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* RMII1_RD0 */
+ {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REF */
+ {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */
+ {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
+ {-1},
+};
+#endif
+
#ifdef CONFIG_NAND
static struct module_pin_mux nand_pin_mux[] = {
{OFFSET(gpmc_ad0), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD0 */
@@ -404,6 +420,6 @@
#endif
configure_module_pin_mux(i2c1_pin_mux);
configure_module_pin_mux(gpio0_7_pin_mux);
- configure_module_pin_mux(rgmii1_pin_mux);
+ configure_module_pin_mux(rmii1_pin_mux);
configure_module_pin_mux(mmc0_pin_mux_sk_evm);
}
网口对应的驱动配置选项:
Index: am335x_evm.h
===================================================================
--- am335x_evm.h (revision 7)
+++ am335x_evm.h (revision 8)
@@ -18,6 +18,8 @@
#include <configs/ti_am335x_common.h>
#define CONFIG_SD_BOOT
+#define CONFIG_PHY_MICREL
+#define CONFIG_PHY_MICREL_KSZ8XXX
上述修改之后,可以PING通本地的PC机
boot log:
U-Boot SPL 2018.01-svn16 (Nov 22 2018 - 15:56:43)
Trying to boot from NAND
U-Boot 2018.01-svn16 (Nov 22 2018 - 15:56:43 +0800)
CPU : AM335X-GP rev 2.1
Model: TI AM335x EVM
DRAM: 256 MiB
NAND: 256 MiB
MMC: OMAP SD/MMC: 0
Net: cpsw
Hit any key to stop autoboot: 0
=> ping 192.168.3.144
link up on port 0, speed 100, full duplex
Using cpsw device
host 192.168.3.144 is alive