mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-19 05:31:32 +00:00
Merge branch 'network_master' of https://source.denx.de/u-boot/custodians/u-boot-net
This commit is contained in:
commit
4906d698d3
9 changed files with 112 additions and 148 deletions
|
@ -206,6 +206,7 @@ config DWC_ETH_QOS_IMX
|
|||
config DWC_ETH_QOS_STM32
|
||||
bool "Synopsys DWC Ethernet QOS device support for STM32"
|
||||
depends on DWC_ETH_QOS
|
||||
select DM_ETH_PHY
|
||||
default y if ARCH_STM32MP
|
||||
help
|
||||
The Synopsys Designware Ethernet QOS IP block with the specific
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
* all clock and reset signals to the HW block.
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_ETH
|
||||
|
||||
#include <common.h>
|
||||
#include <clk.h>
|
||||
#include <cpu_func.h>
|
||||
|
@ -281,7 +283,7 @@ struct eqos_ops {
|
|||
int (*eqos_remove_resources)(struct udevice *dev);
|
||||
int (*eqos_stop_resets)(struct udevice *dev);
|
||||
int (*eqos_start_resets)(struct udevice *dev);
|
||||
void (*eqos_stop_clks)(struct udevice *dev);
|
||||
int (*eqos_stop_clks)(struct udevice *dev);
|
||||
int (*eqos_start_clks)(struct udevice *dev);
|
||||
int (*eqos_calibrate_pads)(struct udevice *dev);
|
||||
int (*eqos_disable_calibration)(struct udevice *dev);
|
||||
|
@ -307,7 +309,6 @@ struct eqos_priv {
|
|||
struct clk clk_slave_bus;
|
||||
struct mii_dev *mii;
|
||||
struct phy_device *phy;
|
||||
int phyaddr;
|
||||
u32 max_speed;
|
||||
void *descs;
|
||||
int tx_desc_idx, rx_desc_idx;
|
||||
|
@ -614,12 +615,7 @@ err:
|
|||
#endif
|
||||
}
|
||||
|
||||
static int eqos_start_clks_imx(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void eqos_stop_clks_tegra186(struct udevice *dev)
|
||||
static int eqos_stop_clks_tegra186(struct udevice *dev)
|
||||
{
|
||||
#ifdef CONFIG_CLK
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
|
@ -634,9 +630,10 @@ static void eqos_stop_clks_tegra186(struct udevice *dev)
|
|||
#endif
|
||||
|
||||
debug("%s: OK\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void eqos_stop_clks_stm32(struct udevice *dev)
|
||||
static int eqos_stop_clks_stm32(struct udevice *dev)
|
||||
{
|
||||
#ifdef CONFIG_CLK
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
|
@ -649,11 +646,7 @@ static void eqos_stop_clks_stm32(struct udevice *dev)
|
|||
#endif
|
||||
|
||||
debug("%s: OK\n", __func__);
|
||||
}
|
||||
|
||||
static void eqos_stop_clks_imx(struct udevice *dev)
|
||||
{
|
||||
/* empty */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_start_resets_tegra186(struct udevice *dev)
|
||||
|
@ -695,39 +688,6 @@ static int eqos_start_resets_tegra186(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_start_resets_stm32(struct udevice *dev)
|
||||
{
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
debug("%s(dev=%p):\n", __func__, dev);
|
||||
if (dm_gpio_is_valid(&eqos->phy_reset_gpio)) {
|
||||
ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 1);
|
||||
if (ret < 0) {
|
||||
pr_err("dm_gpio_set_value(phy_reset, assert) failed: %d",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
udelay(2);
|
||||
|
||||
ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0);
|
||||
if (ret < 0) {
|
||||
pr_err("dm_gpio_set_value(phy_reset, deassert) failed: %d",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
debug("%s: OK\n", __func__);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_start_resets_imx(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_stop_resets_tegra186(struct udevice *dev)
|
||||
{
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
|
@ -738,28 +698,6 @@ static int eqos_stop_resets_tegra186(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_stop_resets_stm32(struct udevice *dev)
|
||||
{
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
if (dm_gpio_is_valid(&eqos->phy_reset_gpio)) {
|
||||
ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 1);
|
||||
if (ret < 0) {
|
||||
pr_err("dm_gpio_set_value(phy_reset, assert) failed: %d",
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_stop_resets_imx(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_calibrate_pads_tegra186(struct udevice *dev)
|
||||
{
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
|
@ -848,26 +786,6 @@ static ulong eqos_get_tick_clk_rate_imx(struct udevice *dev)
|
|||
return imx_get_eqos_csr_clk();
|
||||
}
|
||||
|
||||
static int eqos_calibrate_pads_stm32(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_calibrate_pads_imx(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_disable_calibration_stm32(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_disable_calibration_imx(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_set_full_duplex(struct udevice *dev)
|
||||
{
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
|
@ -964,11 +882,6 @@ static int eqos_set_tx_clk_speed_tegra186(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_set_tx_clk_speed_stm32(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_set_tx_clk_speed_imx(struct udevice *dev)
|
||||
{
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
|
@ -1773,7 +1686,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)
|
|||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
int ret;
|
||||
phy_interface_t interface;
|
||||
struct ofnode_phandle_args phandle_args;
|
||||
|
||||
debug("%s(dev=%p):\n", __func__, dev);
|
||||
|
||||
|
@ -1813,24 +1725,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)
|
|||
if (ret)
|
||||
pr_warn("No phy clock provided %d", ret);
|
||||
|
||||
eqos->phyaddr = -1;
|
||||
ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
|
||||
&phandle_args);
|
||||
if (!ret) {
|
||||
/* search "reset-gpios" in phy node */
|
||||
ret = gpio_request_by_name_nodev(phandle_args.node,
|
||||
"reset-gpios", 0,
|
||||
&eqos->phy_reset_gpio,
|
||||
GPIOD_IS_OUT |
|
||||
GPIOD_IS_OUT_ACTIVE);
|
||||
if (ret)
|
||||
pr_warn("gpio_request_by_name(phy reset) not provided %d",
|
||||
ret);
|
||||
|
||||
eqos->phyaddr = ofnode_read_u32_default(phandle_args.node,
|
||||
"reg", -1);
|
||||
}
|
||||
|
||||
debug("%s: OK\n", __func__);
|
||||
return 0;
|
||||
|
||||
|
@ -1936,11 +1830,6 @@ static int eqos_remove_resources_stm32(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_remove_resources_imx(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_probe(struct udevice *dev)
|
||||
{
|
||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||
|
@ -2029,6 +1918,11 @@ static int eqos_remove(struct udevice *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int eqos_null_ops(struct udevice *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct eth_ops eqos_ops = {
|
||||
.start = eqos_start,
|
||||
.stop = eqos_stop,
|
||||
|
@ -2074,13 +1968,13 @@ static struct eqos_ops eqos_stm32_ops = {
|
|||
.eqos_flush_buffer = eqos_flush_buffer_generic,
|
||||
.eqos_probe_resources = eqos_probe_resources_stm32,
|
||||
.eqos_remove_resources = eqos_remove_resources_stm32,
|
||||
.eqos_stop_resets = eqos_stop_resets_stm32,
|
||||
.eqos_start_resets = eqos_start_resets_stm32,
|
||||
.eqos_stop_resets = eqos_null_ops,
|
||||
.eqos_start_resets = eqos_null_ops,
|
||||
.eqos_stop_clks = eqos_stop_clks_stm32,
|
||||
.eqos_start_clks = eqos_start_clks_stm32,
|
||||
.eqos_calibrate_pads = eqos_calibrate_pads_stm32,
|
||||
.eqos_disable_calibration = eqos_disable_calibration_stm32,
|
||||
.eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_stm32,
|
||||
.eqos_calibrate_pads = eqos_null_ops,
|
||||
.eqos_disable_calibration = eqos_null_ops,
|
||||
.eqos_set_tx_clk_speed = eqos_null_ops,
|
||||
.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32
|
||||
};
|
||||
|
||||
|
@ -2101,13 +1995,13 @@ static struct eqos_ops eqos_imx_ops = {
|
|||
.eqos_inval_buffer = eqos_inval_buffer_generic,
|
||||
.eqos_flush_buffer = eqos_flush_buffer_generic,
|
||||
.eqos_probe_resources = eqos_probe_resources_imx,
|
||||
.eqos_remove_resources = eqos_remove_resources_imx,
|
||||
.eqos_stop_resets = eqos_stop_resets_imx,
|
||||
.eqos_start_resets = eqos_start_resets_imx,
|
||||
.eqos_stop_clks = eqos_stop_clks_imx,
|
||||
.eqos_start_clks = eqos_start_clks_imx,
|
||||
.eqos_calibrate_pads = eqos_calibrate_pads_imx,
|
||||
.eqos_disable_calibration = eqos_disable_calibration_imx,
|
||||
.eqos_remove_resources = eqos_null_ops,
|
||||
.eqos_stop_resets = eqos_null_ops,
|
||||
.eqos_start_resets = eqos_null_ops,
|
||||
.eqos_stop_clks = eqos_null_ops,
|
||||
.eqos_start_clks = eqos_null_ops,
|
||||
.eqos_calibrate_pads = eqos_null_ops,
|
||||
.eqos_disable_calibration = eqos_null_ops,
|
||||
.eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_imx,
|
||||
.eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_imx
|
||||
};
|
||||
|
|
|
@ -3,15 +3,24 @@
|
|||
* Copyright 2020 NXP
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_ETH_PHY
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <log.h>
|
||||
#include <net.h>
|
||||
#include <asm-generic/gpio.h>
|
||||
#include <dm/device_compat.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
#include <dm/lists.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
struct eth_phy_device_priv {
|
||||
struct mii_dev *mdio_bus;
|
||||
struct gpio_desc reset_gpio;
|
||||
u32 reset_assert_delay;
|
||||
u32 reset_deassert_delay;
|
||||
};
|
||||
|
||||
int eth_phy_binds_nodes(struct udevice *eth_dev)
|
||||
|
@ -20,27 +29,33 @@ int eth_phy_binds_nodes(struct udevice *eth_dev)
|
|||
const char *node_name;
|
||||
int ret;
|
||||
|
||||
mdio_node = dev_read_subnode(eth_dev, "mdio");
|
||||
/* search a subnode named "mdio.*" */
|
||||
dev_for_each_subnode(mdio_node, eth_dev) {
|
||||
node_name = ofnode_get_name(mdio_node);
|
||||
if (!strncmp(node_name, "mdio", 4))
|
||||
break;
|
||||
}
|
||||
if (!ofnode_valid(mdio_node)) {
|
||||
debug("%s: %s mdio subnode not found!", __func__,
|
||||
dev_dbg(eth_dev, "%s: %s mdio subnode not found!\n", __func__,
|
||||
eth_dev->name);
|
||||
return -ENXIO;
|
||||
}
|
||||
dev_dbg(eth_dev, "%s: %s subnode found!\n", __func__, node_name);
|
||||
|
||||
ofnode_for_each_subnode(phy_node, mdio_node) {
|
||||
node_name = ofnode_get_name(phy_node);
|
||||
|
||||
debug("* Found child node: '%s'\n", node_name);
|
||||
dev_dbg(eth_dev, "* Found child node: '%s'\n", node_name);
|
||||
|
||||
ret = device_bind_driver_to_node(eth_dev,
|
||||
"eth_phy_generic_drv",
|
||||
node_name, phy_node, NULL);
|
||||
if (ret) {
|
||||
debug(" - Eth phy binding error: %d\n", ret);
|
||||
dev_dbg(eth_dev, " - Eth phy binding error: %d\n", ret);
|
||||
continue;
|
||||
}
|
||||
|
||||
debug(" - bound phy device: '%s'\n", node_name);
|
||||
dev_dbg(eth_dev, " - bound phy device: '%s'\n", node_name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -81,14 +96,14 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)
|
|||
*/
|
||||
uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv(phy_dev));
|
||||
if (uc_priv->mdio_bus)
|
||||
printf("Get shared mii bus on %s\n", eth_dev->name);
|
||||
log_notice("Get shared mii bus on %s\n", eth_dev->name);
|
||||
else
|
||||
printf("Can't get shared mii bus on %s\n", eth_dev->name);
|
||||
log_notice("Can't get shared mii bus on %s\n", eth_dev->name);
|
||||
|
||||
return uc_priv->mdio_bus;
|
||||
}
|
||||
} else {
|
||||
printf("FEC: can't find phy-handle\n");
|
||||
log_notice("FEC: can't find phy-handle\n");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -101,7 +116,7 @@ int eth_phy_get_addr(struct udevice *dev)
|
|||
|
||||
if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
|
||||
&phandle_args)) {
|
||||
debug("Failed to find phy-handle");
|
||||
dev_dbg(dev, "Failed to find phy-handle");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
@ -110,13 +125,64 @@ int eth_phy_get_addr(struct udevice *dev)
|
|||
return reg;
|
||||
}
|
||||
|
||||
/* parsing generic properties of devicetree/bindings/net/ethernet-phy.yaml */
|
||||
static int eth_phy_of_to_plat(struct udevice *dev)
|
||||
{
|
||||
struct eth_phy_device_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
int ret;
|
||||
|
||||
if (!CONFIG_IS_ENABLED(DM_GPIO))
|
||||
return 0;
|
||||
|
||||
/* search "reset-gpios" in phy node */
|
||||
ret = gpio_request_by_name(dev, "reset-gpios", 0,
|
||||
&uc_priv->reset_gpio,
|
||||
GPIOD_IS_OUT);
|
||||
if (ret != -ENOENT)
|
||||
return ret;
|
||||
|
||||
uc_priv->reset_assert_delay = dev_read_u32_default(dev, "reset-assert-us", 0);
|
||||
uc_priv->reset_deassert_delay = dev_read_u32_default(dev, "reset-deassert-us", 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void eth_phy_reset(struct udevice *dev, int value)
|
||||
{
|
||||
struct eth_phy_device_priv *uc_priv = dev_get_uclass_priv(dev);
|
||||
u32 delay;
|
||||
|
||||
if (!CONFIG_IS_ENABLED(DM_GPIO))
|
||||
return;
|
||||
|
||||
if (!dm_gpio_is_valid(&uc_priv->reset_gpio))
|
||||
return;
|
||||
|
||||
dm_gpio_set_value(&uc_priv->reset_gpio, value);
|
||||
|
||||
delay = value ? uc_priv->reset_assert_delay : uc_priv->reset_deassert_delay;
|
||||
if (delay)
|
||||
udelay(delay);
|
||||
}
|
||||
|
||||
static int eth_phy_pre_probe(struct udevice *dev)
|
||||
{
|
||||
/* Assert and deassert the reset signal */
|
||||
eth_phy_reset(dev, 1);
|
||||
eth_phy_reset(dev, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(eth_phy_generic) = {
|
||||
.id = UCLASS_ETH_PHY,
|
||||
.name = "eth_phy_generic",
|
||||
.per_device_auto = sizeof(struct eth_phy_device_priv),
|
||||
.pre_probe = eth_phy_pre_probe,
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(eth_phy_generic_drv) = {
|
||||
.name = "eth_phy_generic_drv",
|
||||
.id = UCLASS_ETH_PHY,
|
||||
.of_to_plat = eth_phy_of_to_plat,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2014 Freescale Semiconductor, Inc.
|
||||
* Copyright 2017-2018, 2020 NXP
|
||||
* Copyright 2017-2018, 2020-2021 NXP
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
|
@ -1126,7 +1126,7 @@ static int dpio_exit(void)
|
|||
goto err;
|
||||
}
|
||||
|
||||
dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
|
||||
err = dpio_close(dflt_mc_io, MC_CMD_NO_FLAGS, dflt_dpio->dpio_handle);
|
||||
if (err < 0) {
|
||||
printf("dpio_close() failed: %d\n", err);
|
||||
goto err;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Aquantia PHY drivers
|
||||
*
|
||||
* Copyright 2014 Freescale Semiconductor, Inc.
|
||||
* Copyright 2018 NXP
|
||||
* Copyright 2018, 2021 NXP
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <common.h>
|
||||
|
@ -554,8 +554,9 @@ int aquantia_config(struct phy_device *phydev)
|
|||
|
||||
int aquantia_startup(struct phy_device *phydev)
|
||||
{
|
||||
u32 reg, speed;
|
||||
u32 speed;
|
||||
int i = 0;
|
||||
int reg;
|
||||
|
||||
phydev->duplex = DUPLEX_FULL;
|
||||
|
||||
|
|
|
@ -1269,7 +1269,7 @@ static void print_packet( byte * buf, int length )
|
|||
}
|
||||
#endif
|
||||
|
||||
int smc91111_initialize(u8 dev_num, int base_addr)
|
||||
int smc91111_initialize(u8 dev_num, phys_addr_t base_addr)
|
||||
{
|
||||
struct smc91111_priv *priv;
|
||||
struct eth_device *dev;
|
||||
|
|
|
@ -478,7 +478,7 @@ static int smc911x_recv(struct eth_device *dev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int smc911x_initialize(u8 dev_num, int base_addr)
|
||||
int smc911x_initialize(u8 dev_num, phys_addr_t base_addr)
|
||||
{
|
||||
struct smc911x_priv *priv;
|
||||
int ret;
|
||||
|
|
|
@ -70,8 +70,8 @@ int rtl8169_initialize(struct bd_info *bis);
|
|||
int scc_initialize(struct bd_info *bis);
|
||||
int sh_eth_initialize(struct bd_info *bis);
|
||||
int skge_initialize(struct bd_info *bis);
|
||||
int smc91111_initialize(u8 dev_num, int base_addr);
|
||||
int smc911x_initialize(u8 dev_num, int base_addr);
|
||||
int smc91111_initialize(u8 dev_num, phys_addr_t base_addr);
|
||||
int smc911x_initialize(u8 dev_num, phys_addr_t base_addr);
|
||||
int uec_standard_init(struct bd_info *bis);
|
||||
int uli526x_initialize(struct bd_info *bis);
|
||||
int armada100_fec_register(unsigned long base_addr);
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Joe Hershberger, National Instruments
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY UCLASS_ETH
|
||||
|
||||
#include <common.h>
|
||||
#include <bootstage.h>
|
||||
#include <dm.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue