dm: net: Use existing Ethernet init for driver model
At present even with driver model is used there is still much manual init of related devices: PHY, environment and board init. Until these requirements are dealt with in another way we need to keep them around. Break out the init portion of the legacy eth_initialize() into a separate function and call it from both the legacy and driver model eth_initialize() functions. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
7b9cf84031
commit
3bc427006a
79
net/eth.c
79
net/eth.c
|
@ -82,6 +82,45 @@ static int eth_mac_skip(int index)
|
||||||
|
|
||||||
static void eth_current_changed(void);
|
static void eth_current_changed(void);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CPU and board-specific Ethernet initializations. Aliased function
|
||||||
|
* signals caller to move on
|
||||||
|
*/
|
||||||
|
static int __def_eth_init(bd_t *bis)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
|
||||||
|
int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
|
||||||
|
|
||||||
|
static void eth_common_init(void)
|
||||||
|
{
|
||||||
|
bootstage_mark(BOOTSTAGE_ID_NET_ETH_START);
|
||||||
|
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
|
||||||
|
miiphy_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PHYLIB
|
||||||
|
phy_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
eth_env_init();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If board-specific initialization exists, call it.
|
||||||
|
* If not, call a CPU-specific one
|
||||||
|
*/
|
||||||
|
if (board_eth_init != __def_eth_init) {
|
||||||
|
if (board_eth_init(gd->bd) < 0)
|
||||||
|
printf("Board Net Initialization Failed\n");
|
||||||
|
} else if (cpu_eth_init != __def_eth_init) {
|
||||||
|
if (cpu_eth_init(gd->bd) < 0)
|
||||||
|
printf("CPU Net Initialization Failed\n");
|
||||||
|
} else {
|
||||||
|
printf("Net Initialization Skipped\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DM_ETH
|
#ifdef CONFIG_DM_ETH
|
||||||
/**
|
/**
|
||||||
* struct eth_device_priv - private structure for each Ethernet device
|
* struct eth_device_priv - private structure for each Ethernet device
|
||||||
|
@ -392,8 +431,7 @@ int eth_initialize(void)
|
||||||
int num_devices = 0;
|
int num_devices = 0;
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
|
|
||||||
bootstage_mark(BOOTSTAGE_ID_NET_ETH_START);
|
eth_common_init();
|
||||||
eth_env_init();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Devices need to write the hwaddr even if not started so that Linux
|
* Devices need to write the hwaddr even if not started so that Linux
|
||||||
|
@ -520,16 +558,6 @@ UCLASS_DRIVER(eth) = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_DM_ETH
|
#ifndef CONFIG_DM_ETH
|
||||||
/*
|
|
||||||
* CPU and board-specific Ethernet initializations. Aliased function
|
|
||||||
* signals caller to move on
|
|
||||||
*/
|
|
||||||
static int __def_eth_init(bd_t *bis)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
|
|
||||||
int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
|
|
||||||
|
|
||||||
#ifdef CONFIG_API
|
#ifdef CONFIG_API
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -706,33 +734,10 @@ int eth_unregister(struct eth_device *dev)
|
||||||
int eth_initialize(void)
|
int eth_initialize(void)
|
||||||
{
|
{
|
||||||
int num_devices = 0;
|
int num_devices = 0;
|
||||||
|
|
||||||
eth_devices = NULL;
|
eth_devices = NULL;
|
||||||
eth_current = NULL;
|
eth_current = NULL;
|
||||||
|
eth_common_init();
|
||||||
bootstage_mark(BOOTSTAGE_ID_NET_ETH_START);
|
|
||||||
#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB)
|
|
||||||
miiphy_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_PHYLIB
|
|
||||||
phy_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
eth_env_init();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If board-specific initialization exists, call it.
|
|
||||||
* If not, call a CPU-specific one
|
|
||||||
*/
|
|
||||||
if (board_eth_init != __def_eth_init) {
|
|
||||||
if (board_eth_init(gd->bd) < 0)
|
|
||||||
printf("Board Net Initialization Failed\n");
|
|
||||||
} else if (cpu_eth_init != __def_eth_init) {
|
|
||||||
if (cpu_eth_init(gd->bd) < 0)
|
|
||||||
printf("CPU Net Initialization Failed\n");
|
|
||||||
} else {
|
|
||||||
printf("Net Initialization Skipped\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!eth_devices) {
|
if (!eth_devices) {
|
||||||
puts("No ethernet found.\n");
|
puts("No ethernet found.\n");
|
||||||
|
|
Loading…
Reference in New Issue