RE: Ping is not working on MitySOM-335x Processor Card ยป u-boot-som.diff
| som_updated.c 2019-11-22 07:59:23.000000000 -0500 | ||
|---|---|---|
|
#include <asm/arch/mmc_host_def.h>
|
||
|
#include <asm/arch/sys_proto.h>
|
||
|
#include <asm/arch/mem.h>
|
||
|
#include <asm/omap_common.h>
|
||
|
#include <asm/io.h>
|
||
|
#include <asm/emif.h>
|
||
|
#include <asm/gpio.h>
|
||
| ... | ... | |
|
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
||
|
gpmc_init();
|
||
|
//gpmc_init();
|
||
|
return 0;
|
||
|
}
|
||
| ... | ... | |
|
///////////
|
||
|
/// Don't change this. Just change phy_addr from 2 to 3 for 2nd slave
|
||
|
static struct cpsw_slave_data cpsw_slaves[] = {
|
||
|
{
|
||
|
.slave_reg_ofs = 0x208,
|
||
|
.sliver_reg_ofs = 0xd80,
|
||
|
#ifdef CONFIG_SPL_USBETH_SUPPORT
|
||
|
.phy_addr = 1,
|
||
|
#else
|
||
|
.phy_addr = 2,
|
||
|
#endif
|
||
|
},
|
||
|
.slave_reg_ofs = 0x200,
|
||
|
.sliver_reg_ofs = 0xd80,
|
||
|
.phy_addr = 3,
|
||
|
},
|
||
|
{
|
||
|
.slave_reg_ofs = 0x308,
|
||
|
.sliver_reg_ofs = 0xdc0,
|
||
|
#ifdef CONFIG_SPL_USBETH_SUPPORT
|
||
|
.phy_addr = 2,
|
||
|
#else
|
||
|
.phy_addr = 1,
|
||
|
#endif
|
||
|
},
|
||
|
.slave_reg_ofs = 0x308,
|
||
|
.sliver_reg_ofs = 0xdc0,
|
||
|
.phy_addr = 1,
|
||
|
},
|
||
|
};
|
||
|
///////////
|
||
|
/// Don't change this, just make sure CONFIG_ETH_PORT is set to 2
|
||
|
static struct cpsw_platform_data cpsw_data = {
|
||
|
.mdio_base = CPSW_MDIO_BASE,
|
||
|
.cpsw_base = CPSW_BASE,
|
||
|
.mdio_div = 0xff,
|
||
|
.channels = 8,
|
||
|
.cpdma_reg_ofs = 0x800,
|
||
|
.slaves = 2,
|
||
|
.slave_data = cpsw_slaves,
|
||
|
.ale_reg_ofs = 0xd00,
|
||
|
.ale_entries = 1024,
|
||
|
.host_port_reg_ofs = 0x108,
|
||
|
.hw_stats_reg_ofs = 0x900,
|
||
|
.bd_ram_ofs = 0x2000,
|
||
|
.mac_control = (1 << 5) /* MIIEN */ ,
|
||
|
.control = cpsw_control,
|
||
|
.host_port_num = 0,
|
||
|
.version = CPSW_CTRL_VERSION_2,
|
||
|
.active_slave = CONFIG_ETH_PORT - 1,
|
||
|
.mdio_base = CPSW_MDIO_BASE,
|
||
|
.cpsw_base = CPSW_BASE,
|
||
|
.mdio_div = 0xff,
|
||
|
.channels = 8,
|
||
|
.cpdma_reg_ofs = 0x800,
|
||
|
.slaves = 1,
|
||
|
.slave_data = cpsw_slaves,
|
||
|
.ale_reg_ofs = 0xd00,
|
||
|
.ale_entries = 1024,
|
||
|
.host_port_reg_ofs = 0x108,
|
||
|
.hw_stats_reg_ofs = 0x900,
|
||
|
.bd_ram_ofs = 0x2000,
|
||
|
.mac_control = (1 << 5),
|
||
|
.control = cpsw_control,
|
||
|
.host_port_num = 0,
|
||
|
.version = CPSW_CTRL_VERSION_2,
|
||
|
};
|
||
|
#endif /* !CONFIG_SPL_BUILD */
|
||
| ... | ... | |
|
#ifdef CONFIG_MITYSOM_MAKER
|
||
|
env_set("disable_giga", "1");
|
||
|
#endif
|
||
|
|
||
|
printf("Resetting PHY\n");
|
||
|
gpio_request(GPIO_PHY_RESET_N, "gpio3_10");
|
||
|
// Pull into reset
|
||
|
gpio_direction_output(GPIO_PHY_RESET_N, 0);
|
||
| ... | ... | |
|
debug("<ethaddr> not set. Reading from E-fuse\n");
|
||
|
/* try reading mac address from efuse */
|
||
|
///////////
|
||
|
/// Don't change this, just make sure CONFIG_ETH_PORT is set to 2
|
||
|
#if (CONFIG_ETH_PORT == 1)
|
||
|
mac_lo = readl(&cdev->macid0l);
|
||
|
mac_hi = readl(&cdev->macid0h);
|
||
|
#else
|
||
|
mac_lo = readl(&cdev->macid1l);
|
||
|
mac_hi = readl(&cdev->macid1h);
|
||
|
#endif
|
||
|
/* try reading mac address from efuse */
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
mac_lo = readl(&cdev->macid0l);
|
||
|
mac_hi = readl(&cdev->macid0h);
|
||
|
mac_addr[0] = mac_hi & 0xFF;
|
||
|
mac_addr[1] = (mac_hi & 0xFF00) >> 8;
|
||
|
mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
|
||
| ... | ... | |
|
///////////
|
||
|
/// Whether RGMII_INT_DELAY needs to be set or not will need to be played with. This is the same as going between "rgmii" and "rgmii-id" in the dts.
|
||
|
#if !defined(CONFIG_SPL_BUILD)
|
||
|
if (valid_mac)
|
||
|
{
|
||
|
writel(RGMII_MODE_ENABLE, &cdev->miisel);
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel);
|
||
|
cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if =
|
||
|
PHY_INTERFACE_MODE_RGMII;
|
||
|
}
|
||
| ... | ... | |
|
printf("Error %d registering CPSW switch\n", rv);
|
||
|
else
|
||
|
n += rv;
|
||
|
///////////
|
||
|
/// I assume this is trying to set the skew delays in the phy? These may need to be played with.
|
||
|
/// Note you can play with these registers directly using "mdio write" from u-boot shell
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
const char *devname;
|
||
|
int i,data;
|
||
|
devname = miiphy_get_current_dev();
|
||
|
printf("\r\nHARDIK->: get current dev name device:%s ", devname);
|
||
|
miiphy_write(devname, 0x3,11, 0x8104);
|
||
|
miiphy_write(devname, 0x3, 12, 0xf0f0);
|
||
|
|
||
|
miiphy_write(devname, 0x3,11, 0x8105);
|
||
|
miiphy_write(devname, 0x3, 12, 0x0000);
|
||
|
/*miiphy_write(devname, 0x3,11, 0x8106);*/
|
||
|
/*miiphy_write(devname, 0x3, 12, 0x0000);*/
|
||
|
miiphy_write(devname, 0x3, 9, 0x0100);
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
#endif
|
||
|
#endif /* !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT) */
|
||
|
return n;
|
||
| ... | ... | |
|
}
|
||
|
#endif /* CONFIG_OF_LIBFDT && CONFIG_OF_SYSTEM_SETUP */
|
||
|
///////////
|
||
|
/// I'm not sure this is a good idea. Should probably be left alone.
|
||
|
#ifndef CONFIG_SPL_BUILD
|
||
|
//#ifndef CONFIG_SPL_BUILD
|
||
|
#if 0
|
||
|
#ifdef CONFIG_BOARD_LATE_INIT
|
||
|
int board_late_init(void)
|
||
|
{
|
||
| ... | ... | |
|
return 0;
|
||
|
}
|
||
|
#endif /* CONFIG_BOARD_LATE_INIT */
|
||
|
#endif
|
||
|
#ifdef CONFIG_BOARD_LATE_INIT
|
||
|
int board_late_init(void)
|
||
|
{
|
||
|
static bool prueth_is_mii = true;
|
||
|
#if !defined(CONFIG_SPL_BUILD)
|
||
|
uint8_t mac_addr[6];
|
||
|
uint32_t mac_hi, mac_lo;
|
||
|
#endif
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
||
|
char *name = NULL;
|
||
|
#if 0
|
||
|
if (board_is_bone_lt()) {
|
||
|
/* BeagleBoard.org BeagleBone Black Wireless: */
|
||
|
if (!strncmp(board_ti_get_rev(), "BWA", 3)) {
|
||
|
name = "BBBW";
|
||
|
}
|
||
|
/* SeeedStudio BeagleBone Green Wireless */
|
||
|
if (!strncmp(board_ti_get_rev(), "GW1", 3)) {
|
||
|
name = "BBGW";
|
||
|
}
|
||
|
/* BeagleBoard.org BeagleBone Blue */
|
||
|
if (!strncmp(board_ti_get_rev(), "BLA", 3)) {
|
||
|
name = "BBBL";
|
||
|
}
|
||
|
}
|
||
|
if (board_is_bbg1())
|
||
|
name = "BBG1";
|
||
|
#endif
|
||
|
// name = "A335X_SK";
|
||
|
//set_board_info_env(name);
|
||
|
env_set("board_name", "MitySOM335x");
|
||
|
/*
|
||
|
* Default FIT boot on HS devices. Non FIT images are not allowed
|
||
|
* on HS devices.
|
||
|
*/
|
||
|
if (get_device_type() == HS_DEVICE)
|
||
|
env_set("boot_fit", "1");
|
||
|
#endif
|
||
|
#if !defined(CONFIG_SPL_BUILD)
|
||
|
/* try reading mac address from efuse */
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
mac_lo = readl(&cdev->macid0l);
|
||
|
mac_hi = readl(&cdev->macid0h);
|
||
|
mac_addr[0] = mac_hi & 0xFF;
|
||
|
mac_addr[1] = (mac_hi & 0xFF00) >> 8;
|
||
|
mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
|
||
|
mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
|
||
|
mac_addr[4] = mac_lo & 0xFF;
|
||
|
mac_addr[5] = (mac_lo & 0xFF00) >> 8;
|
||
|
if (!env_get("ethaddr")) {
|
||
|
printf("<ethaddr> not set. Validating first E-fuse MAC\n");
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
if (is_valid_ethaddr(mac_addr))
|
||
|
eth_env_set_enetaddr("ethaddr", mac_addr);
|
||
|
}
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
mac_lo = readl(&cdev->macid1l);
|
||
|
mac_hi = readl(&cdev->macid1h);
|
||
|
mac_addr[0] = mac_hi & 0xFF;
|
||
|
mac_addr[1] = (mac_hi & 0xFF00) >> 8;
|
||
|
mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
|
||
|
mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
|
||
|
mac_addr[4] = mac_lo & 0xFF;
|
||
|
mac_addr[5] = (mac_lo & 0xFF00) >> 8;
|
||
|
if (!env_get("eth1addr")) {
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
if (is_valid_ethaddr(mac_addr))
|
||
|
{
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
eth_env_set_enetaddr("eth1addr", mac_addr);
|
||
|
}
|
||
|
}
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
env_set("ice_mii", prueth_is_mii ? "mii" : "rmii");
|
||
|
#endif
|
||
|
printf("\r\nHARDIK->: func:%s : file: %s line:%d ", __func__ ,__FILE__, __LINE__);
|
||
|
return 0;
|
||
|
}
|
||
|
//#endif
|
||
|
//#endif
|
||
|
#endif /* CONFIG_SPL_BUILD */
|
||