summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2021-04-15 20:11:19 +0300
committerTom Rini <trini@konsulko.com>2021-04-15 20:11:19 +0300
commit45b3cf88da24206a6cb847efe837fddc120af3e8 (patch)
tree0c2054e1af2af9dc752205ec8ee003e4399045b5 /drivers
parentb86772eda6033ea795e42f5463d436057919b6be (diff)
parent20830d0c01b5d82c916010b5dfdbe099ca1f0444 (diff)
downloadu-boot-45b3cf88da24206a6cb847efe837fddc120af3e8.tar.xz
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq
update ls1028aqds networking protocol, config in ls1021atwr, env in ls1012a Add seli3 board support, booke watchdog, update eTSEC support in ppc-qemu Add DM_SERIAL and lpuart in sl28, add DM_ETH support for some of powerpc platforms Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/core/Kconfig14
-rw-r--r--drivers/core/of_extra.c23
-rw-r--r--drivers/core/simple-bus.c32
-rw-r--r--drivers/net/Kconfig9
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/dsa_sandbox.c179
-rw-r--r--drivers/net/phy/Kconfig1
-rw-r--r--drivers/net/phy/fixed.c54
-rw-r--r--drivers/net/phy/phy.c63
-rw-r--r--drivers/net/phy/xilinx_gmii2rgmii.c61
-rw-r--r--drivers/net/tsec.c36
-rw-r--r--drivers/watchdog/Kconfig7
-rw-r--r--drivers/watchdog/Makefile1
-rw-r--r--drivers/watchdog/booke_wdt.c106
14 files changed, 490 insertions, 97 deletions
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
index 1eccac28c6..a7c3120860 100644
--- a/drivers/core/Kconfig
+++ b/drivers/core/Kconfig
@@ -235,6 +235,20 @@ config SPL_SIMPLE_BUS
Supports the 'simple-bus' driver, which is used on some systems
in SPL.
+config SIMPLE_BUS_CORRECT_RANGE
+ bool "Decode the 'simple-bus' <range> by honoring the #address-cells and #size-cells"
+ depends on SIMPLE_BUS
+ default y if SANDBOX
+ help
+ Decoding the 'simple-bus' <range> by honoring the #address-cells
+ and #size-cells of parent/child bus. If unset, #address-cells of
+ parent bus is assumed to be 1, #address-cells and #size-cells of
+ child bus is also assumed to be 1, to save some spaces of using
+ an advanced API to decode the <range>, which benefits SPL image
+ builds that have size limits.
+
+ If you are unsure about this, Say N here.
+
config SIMPLE_PM_BUS
bool "Support simple-pm-bus driver"
depends on DM && OF_CONTROL && CLK && POWER_DOMAIN
diff --git a/drivers/core/of_extra.c b/drivers/core/of_extra.c
index 653344529e..7702beff97 100644
--- a/drivers/core/of_extra.c
+++ b/drivers/core/of_extra.c
@@ -130,3 +130,26 @@ int ofnode_decode_memory_region(ofnode config_node, const char *mem_type,
return 0;
}
+
+bool ofnode_phy_is_fixed_link(ofnode eth_node, ofnode *phy_node)
+{
+ ofnode node, subnode;
+ int len;
+
+ subnode = ofnode_find_subnode(eth_node, "fixed-link");
+ if (ofnode_valid(subnode)) {
+ /* new binding */
+ node = subnode;
+ } else if (ofnode_get_property(eth_node, "fixed-link", &len) &&
+ len == (5 * sizeof(__be32))) {
+ /* old binding */
+ node = eth_node;
+ } else {
+ return false;
+ }
+
+ if (phy_node)
+ *phy_node = node;
+
+ return true;
+}
diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
index b0c2c20958..18f52d26df 100644
--- a/drivers/core/simple-bus.c
+++ b/drivers/core/simple-bus.c
@@ -4,8 +4,12 @@
*/
#include <common.h>
+#include <asm/global_data.h>
#include <dm.h>
#include <dm/simple_bus.h>
+#include <fdt_support.h>
+
+DECLARE_GLOBAL_DATA_PTR;
fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr)
{
@@ -22,16 +26,30 @@ static int simple_bus_post_bind(struct udevice *dev)
#if CONFIG_IS_ENABLED(OF_PLATDATA)
return 0;
#else
- u32 cell[3];
+ struct simple_bus_plat *plat = dev_get_uclass_plat(dev);
int ret;
- ret = dev_read_u32_array(dev, "ranges", cell, ARRAY_SIZE(cell));
- if (!ret) {
- struct simple_bus_plat *plat = dev_get_uclass_plat(dev);
+ if (CONFIG_IS_ENABLED(SIMPLE_BUS_CORRECT_RANGE)) {
+ uint64_t caddr, paddr, len;
+
+ /* only read range index 0 */
+ ret = fdt_read_range((void *)gd->fdt_blob, dev_of_offset(dev),
+ 0, &caddr, &paddr, &len);
+ if (!ret) {
+ plat->base = caddr;
+ plat->target = paddr;
+ plat->size = len;
+ }
+ } else {
+ u32 cell[3];
- plat->base = cell[0];
- plat->target = cell[1];
- plat->size = cell[2];
+ ret = dev_read_u32_array(dev, "ranges", cell,
+ ARRAY_SIZE(cell));
+ if (!ret) {
+ plat->base = cell[0];
+ plat->target = cell[1];
+ plat->size = cell[2];
+ }
}
return dm_scan_fdt_dev(dev);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 54f7b81624..72822eaec4 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -78,6 +78,15 @@ config DM_ETH_PHY
help
Enable driver model for Ethernet Generic PHY .
+config DSA_SANDBOX
+ depends on DM_DSA && SANDBOX
+ default y
+ bool "Sandbox: Mocked DSA driver"
+ help
+ This driver implements a dummy DSA switch connected to a dummy sandbox
+ Ethernet device used as DSA master, to test DSA class code, including
+ exported DSA API and datapath processing of Ethernet traffic.
+
menuconfig NETDEVICES
bool "Network device support"
depends on NET
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index ce7b9e3478..2ce89f7e3c 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
obj-$(CONFIG_ETH_DESIGNWARE_S700) += dwmac_s700.o
obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o
obj-$(CONFIG_DNET) += dnet.o
+obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o
obj-$(CONFIG_DM_ETH_PHY) += eth-phy-uclass.o
obj-$(CONFIG_E1000) += e1000.o
obj-$(CONFIG_E1000_SPI) += e1000_spi.o
diff --git a/drivers/net/dsa_sandbox.c b/drivers/net/dsa_sandbox.c
new file mode 100644
index 0000000000..4b62670e5d
--- /dev/null
+++ b/drivers/net/dsa_sandbox.c
@@ -0,0 +1,179 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2019-2021 NXP Semiconductors
+ */
+
+#include <asm/eth.h>
+#include <net/dsa.h>
+#include <net.h>
+
+#define DSA_SANDBOX_MAGIC 0x00415344
+#define DSA_SANDBOX_TAG_LEN sizeof(struct dsa_sandbox_tag)
+
+struct dsa_sandbox_priv {
+ struct eth_sandbox_priv *master_priv;
+ int port_en_mask;
+};
+
+struct dsa_sandbox_tag {
+ u32 magic;
+ u32 port;
+};
+
+static bool sb_dsa_port_enabled(struct udevice *dev, int port)
+{
+ struct dsa_sandbox_priv *priv = dev_get_priv(dev);
+
+ return priv->port_en_mask & BIT(port);
+}
+
+static bool sb_dsa_master_enabled(struct udevice *dev)
+{
+ struct dsa_sandbox_priv *priv = dev_get_priv(dev);
+
+ return !priv->master_priv->disabled;
+}
+
+static int dsa_sandbox_port_enable(struct udevice *dev, int port,
+ struct phy_device *phy)
+{
+ struct dsa_sandbox_priv *priv = dev_get_priv(dev);
+
+ if (!sb_dsa_master_enabled(dev))
+ return -EFAULT;
+
+ priv->port_en_mask |= BIT(port);
+
+ return 0;
+}
+
+static void dsa_sandbox_port_disable(struct udevice *dev, int port,
+ struct phy_device *phy)
+{
+ struct dsa_sandbox_priv *priv = dev_get_priv(dev);
+
+ priv->port_en_mask &= ~BIT(port);
+}
+
+static int dsa_sandbox_xmit(struct udevice *dev, int port, void *packet,
+ int length)
+{
+ struct dsa_sandbox_tag *tag = packet;
+
+ if (!sb_dsa_master_enabled(dev))
+ return -EFAULT;
+
+ if (!sb_dsa_port_enabled(dev, port))
+ return -EFAULT;
+
+ tag->magic = DSA_SANDBOX_MAGIC;
+ tag->port = port;
+
+ return 0;
+}
+
+static int dsa_sandbox_rcv(struct udevice *dev, int *port, void *packet,
+ int length)
+{
+ struct dsa_sandbox_tag *tag = packet;
+
+ if (!sb_dsa_master_enabled(dev))
+ return -EFAULT;
+
+ if (tag->magic != DSA_SANDBOX_MAGIC)
+ return -EFAULT;
+
+ *port = tag->port;
+ if (!sb_dsa_port_enabled(dev, tag->port))
+ return -EFAULT;
+
+ return 0;
+}
+
+static const struct dsa_ops dsa_sandbox_ops = {
+ .port_enable = dsa_sandbox_port_enable,
+ .port_disable = dsa_sandbox_port_disable,
+ .xmit = dsa_sandbox_xmit,
+ .rcv = dsa_sandbox_rcv,
+};
+
+static int sb_dsa_handler(struct udevice *dev, void *packet,
+ unsigned int len)
+{
+ struct eth_sandbox_priv *master_priv;
+ struct dsa_sandbox_tag *tag = packet;
+ struct udevice *dsa_dev;
+ u32 port_index;
+ void *rx_buf;
+ int i;
+
+ /* this emulates the switch hw and the network side */
+ if (tag->magic != DSA_SANDBOX_MAGIC)
+ return -EFAULT;
+
+ port_index = tag->port;
+ master_priv = dev_get_priv(dev);
+ dsa_dev = master_priv->priv;
+ if (!sb_dsa_port_enabled(dsa_dev, port_index))
+ return -EFAULT;
+
+ packet += DSA_SANDBOX_TAG_LEN;
+ len -= DSA_SANDBOX_TAG_LEN;
+
+ if (!sandbox_eth_arp_req_to_reply(dev, packet, len))
+ goto dsa_tagging;
+ if (!sandbox_eth_ping_req_to_reply(dev, packet, len))
+ goto dsa_tagging;
+
+ return 0;
+
+dsa_tagging:
+ master_priv->recv_packets--;
+ i = master_priv->recv_packets;
+ rx_buf = master_priv->recv_packet_buffer[i];
+ len = master_priv->recv_packet_length[i];
+ memmove(rx_buf + DSA_SANDBOX_TAG_LEN, rx_buf, len);
+
+ tag = rx_buf;
+ tag->magic = DSA_SANDBOX_MAGIC;
+ tag->port = port_index;
+ len += DSA_SANDBOX_TAG_LEN;
+ master_priv->recv_packet_length[i] = len;
+ master_priv->recv_packets++;
+
+ return 0;
+}
+
+static int dsa_sandbox_probe(struct udevice *dev)
+{
+ struct dsa_sandbox_priv *priv = dev_get_priv(dev);
+ struct udevice *master = dsa_get_master(dev);
+ struct eth_sandbox_priv *master_priv;
+
+ if (!master)
+ return -ENODEV;
+
+ dsa_set_tagging(dev, DSA_SANDBOX_TAG_LEN, 0);
+
+ master_priv = dev_get_priv(master);
+ master_priv->priv = dev;
+ master_priv->tx_handler = sb_dsa_handler;
+
+ priv->master_priv = master_priv;
+
+ return 0;
+}
+
+static const struct udevice_id dsa_sandbox_ids[] = {
+ { .compatible = "sandbox,dsa" },
+ { }
+};
+
+U_BOOT_DRIVER(dsa_sandbox) = {
+ .name = "dsa_sandbox",
+ .id = UCLASS_DSA,
+ .of_match = dsa_sandbox_ids,
+ .probe = dsa_sandbox_probe,
+ .ops = &dsa_sandbox_ops,
+ .priv_auto = sizeof(struct dsa_sandbox_priv),
+};
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d69503067d..070ffa82cb 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -292,6 +292,7 @@ config PHY_XILINX
config PHY_XILINX_GMII2RGMII
bool "Xilinx GMII to RGMII Ethernet PHYs support"
+ depends on DM_ETH
help
This adds support for Xilinx GMII to RGMII IP core. This IP acts
as bridge between MAC connected over GMII and external phy that
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 1a38c29469..1192915ee5 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -15,18 +15,42 @@
DECLARE_GLOBAL_DATA_PTR;
-int fixedphy_probe(struct phy_device *phydev)
+static int fixedphy_probe(struct phy_device *phydev)
{
+ /* fixed-link phy must not be reset by core phy code */
+ phydev->flags |= PHY_FLAG_BROKEN_RESET;
+
+ return 0;
+}
+
+static int fixedphy_config(struct phy_device *phydev)
+{
+ ofnode node = phy_get_ofnode(phydev);
struct fixed_link *priv;
- int ofnode = phydev->addr;
+ bool old_binding = false;
+ u32 old_val[5];
u32 val;
+ if (!ofnode_valid(node))
+ return -EINVAL;
+
/* check for mandatory properties within fixed-link node */
- val = fdt_getprop_u32_default_node(gd->fdt_blob,
- ofnode, 0, "speed", 0);
+ val = ofnode_read_u32_default(node, "speed", 0);
+
+ if (!val) {
+ /* try old binding */
+ old_binding = true;
+ if (ofnode_read_u32_array(node, "fixed-link", old_val,
+ ARRAY_SIZE(old_val))) {
+ printf("ERROR: no/invalid <fixed-link> property!\n");
+ return -ENOENT;
+ }
+ val = old_val[2];
+ }
+
if (val != SPEED_10 && val != SPEED_100 && val != SPEED_1000 &&
val != SPEED_2500 && val != SPEED_10000) {
- printf("ERROR: no/invalid speed given in fixed-link node!");
+ printf("ERROR: no/invalid speed given in fixed-link node!\n");
return -EINVAL;
}
@@ -38,17 +62,20 @@ int fixedphy_probe(struct phy_device *phydev)
phydev->priv = priv;
priv->link_speed = val;
- priv->duplex = fdtdec_get_bool(gd->fdt_blob, ofnode, "full-duplex");
- priv->pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "pause");
- priv->asym_pause = fdtdec_get_bool(gd->fdt_blob, ofnode, "asym-pause");
-
- /* fixed-link phy must not be reset by core phy code */
- phydev->flags |= PHY_FLAG_BROKEN_RESET;
+ if (!old_binding) {
+ priv->duplex = ofnode_read_bool(node, "full-duplex");
+ priv->pause = ofnode_read_bool(node, "pause");
+ priv->asym_pause = ofnode_read_bool(node, "asym-pause");
+ } else {
+ priv->duplex = old_val[1];
+ priv->pause = old_val[3];
+ priv->asym_pause = old_val[4];
+ }
return 0;
}
-int fixedphy_startup(struct phy_device *phydev)
+static int fixedphy_startup(struct phy_device *phydev)
{
struct fixed_link *priv = phydev->priv;
@@ -61,7 +88,7 @@ int fixedphy_startup(struct phy_device *phydev)
return 0;
}
-int fixedphy_shutdown(struct phy_device *phydev)
+static int fixedphy_shutdown(struct phy_device *phydev)
{
return 0;
}
@@ -72,6 +99,7 @@ static struct phy_driver fixedphy_driver = {
.name = "Fixed PHY",
.features = PHY_GBIT_FEATURES | SUPPORTED_MII,
.probe = fixedphy_probe,
+ .config = fixedphy_config,
.startup = fixedphy_startup,
.shutdown = fixedphy_shutdown,
};
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 89e3076bfd..dcdef9e661 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -18,6 +18,7 @@
#include <phy.h>
#include <errno.h>
#include <asm/global_data.h>
+#include <dm/of_extra.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/err.h>
@@ -942,34 +943,25 @@ void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev)
}
#ifdef CONFIG_PHY_XILINX_GMII2RGMII
-#ifdef CONFIG_DM_ETH
static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
struct udevice *dev,
phy_interface_t interface)
-#else
-static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
- struct eth_device *dev,
- phy_interface_t interface)
-#endif
{
struct phy_device *phydev = NULL;
- int sn = dev_of_offset(dev);
- int off;
-
- while (sn > 0) {
- off = fdt_node_offset_by_compatible(gd->fdt_blob, sn,
- "xlnx,gmii-to-rgmii-1.0");
- if (off > 0) {
- phydev = phy_device_create(bus, off,
+ ofnode node = dev_ofnode(dev);
+
+ while (ofnode_valid(node)) {
+ node = ofnode_by_compatible(node, "xlnx,gmii-to-rgmii-1.0");
+ if (ofnode_valid(node)) {
+ phydev = phy_device_create(bus, 0,
PHY_GMII2RGMII_ID, false,
interface);
+ if (phydev)
+ phydev->node = node;
break;
}
- if (off == -FDT_ERR_NOTFOUND)
- sn = fdt_first_subnode(gd->fdt_blob, sn);
- else
- printf("%s: Error finding compat string:%d\n",
- __func__, off);
+
+ node = ofnode_first_subnode(node);
}
return phydev;
@@ -988,6 +980,7 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus,
struct phy_device *fixed_phy_create(ofnode node)
{
phy_interface_t interface = PHY_INTERFACE_MODE_NONE;
+ struct phy_device *phydev;
const char *if_str;
ofnode subnode;
@@ -1004,33 +997,25 @@ struct phy_device *fixed_phy_create(ofnode node)
return NULL;
}
- return phy_device_create(NULL, ofnode_to_offset(subnode), PHY_FIXED_ID,
- false, interface);
+ phydev = phy_device_create(NULL, 0, PHY_FIXED_ID, false, interface);
+ if (phydev)
+ phydev->node = subnode;
+
+ return phydev;
}
-#ifdef CONFIG_DM_ETH
static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
struct udevice *dev,
phy_interface_t interface)
-#else
-static struct phy_device *phy_connect_fixed(struct mii_dev *bus,
- struct eth_device *dev,
- phy_interface_t interface)
-#endif
{
+ ofnode node = dev_ofnode(dev), subnode;
struct phy_device *phydev = NULL;
- int sn;
- const char *name;
-
- sn = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
- while (sn > 0) {
- name = fdt_get_name(gd->fdt_blob, sn, NULL);
- if (name && strcmp(name, "fixed-link") == 0) {
- phydev = phy_device_create(bus, sn, PHY_FIXED_ID, false,
- interface);
- break;
- }
- sn = fdt_next_subnode(gd->fdt_blob, sn);
+
+ if (ofnode_phy_is_fixed_link(node, &subnode)) {
+ phydev = phy_device_create(bus, 0, PHY_FIXED_ID,
+ false, interface);
+ if (phydev)
+ phydev->node = subnode;
}
return phydev;
diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index 74105c0b7d..635c0570ef 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -18,9 +18,38 @@ DECLARE_GLOBAL_DATA_PTR;
static int xilinxgmiitorgmii_config(struct phy_device *phydev)
{
- struct phy_device *ext_phydev = phydev->priv;
+ ofnode node = phy_get_ofnode(phydev);
+ struct phy_device *ext_phydev;
+ struct ofnode_phandle_args phandle;
+ int ext_phyaddr = -1;
+ int ret;
debug("%s\n", __func__);
+
+ if (!ofnode_valid(node))
+ return -EINVAL;
+
+ phydev->addr = ofnode_read_u32_default(node, "reg", -1);
+ ret = ofnode_parse_phandle_with_args(node, "phy-handle",
+ NULL, 0, 0, &phandle);
+ if (ret)
+ return ret;
+
+ ext_phyaddr = ofnode_read_u32_default(phandle.node, "reg", -1);
+ ext_phydev = phy_find_by_mask(phydev->bus,
+ 1 << ext_phyaddr,
+ PHY_INTERFACE_MODE_RGMII);
+ if (!ext_phydev) {
+ printf("%s, No external phy device found\n", __func__);
+ return -EINVAL;
+ }
+
+ ext_phydev->node = phandle.node;
+ phydev->priv = ext_phydev;
+
+ debug("%s, gmii2rgmmi:0x%x, extphy:0x%x\n", __func__, phydev->addr,
+ ext_phyaddr);
+
if (ext_phydev->drv->config)
ext_phydev->drv->config(ext_phydev);
@@ -83,11 +112,6 @@ static int xilinxgmiitorgmii_startup(struct phy_device *phydev)
static int xilinxgmiitorgmii_probe(struct phy_device *phydev)
{
- int ofnode = phydev->addr;
- u32 phy_of_handle;
- int ext_phyaddr = -1;
- struct phy_device *ext_phydev;
-
debug("%s\n", __func__);
if (phydev->interface != PHY_INTERFACE_MODE_GMII) {
@@ -95,31 +119,6 @@ static int xilinxgmiitorgmii_probe(struct phy_device *phydev)
return -EINVAL;
}
- /*
- * Read the phy address again as the one we read in ethernet driver
- * was overwritten for the purpose of storing the ofnode
- */
- phydev->addr = fdtdec_get_int(gd->fdt_blob, ofnode, "reg", -1);
- phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, ofnode,
- "phy-handle");
- if (phy_of_handle > 0)
- ext_phyaddr = fdtdec_get_int(gd->fdt_blob,
- phy_of_handle,
- "reg", -1);
- ext_phydev = phy_find_by_mask(phydev->bus,
- 1 << ext_phyaddr,
- PHY_INTERFACE_MODE_RGMII);
- if (!ext_phydev) {
- printf("%s, No external phy device found\n", __func__);
- return -EINVAL;
- }
-
- ext_phydev->node = offset_to_ofnode(phy_of_handle);
- phydev->priv = ext_phydev;
-
- debug("%s, gmii2rgmmi:0x%x, extphy:0x%x\n", __func__, phydev->addr,
- ext_phyaddr);
-
phydev->flags |= PHY_FLAG_BROKEN_RESET;
return 0;
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index ec48689372..c68e4b7fb5 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -707,11 +707,7 @@ static int init_phy(struct tsec_private *priv)
tsec_configure_serdes(priv);
#if defined(CONFIG_DM_ETH) && defined(CONFIG_DM_MDIO)
- if (ofnode_valid(ofnode_find_subnode(dev_ofnode(priv->dev),
- "fixed-link")))
- phydev = phy_connect(NULL, 0, priv->dev, priv->interface);
- else
- phydev = dm_eth_phy_connect(priv->dev);
+ phydev = dm_eth_phy_connect(priv->dev);
#else
phydev = phy_connect(priv->bus, priv->phyaddr, priv->dev,
priv->interface);
@@ -830,14 +826,40 @@ int tsec_probe(struct udevice *dev)
u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE;
struct tsec_data *data;
const char *phy_mode;
+ ofnode parent, child;
fdt_addr_t reg;
- ofnode parent;
int ret;
data = (struct tsec_data *)dev_get_driver_data(dev);
pdata->iobase = (phys_addr_t)dev_read_addr(dev);
- priv->regs = dev_remap_addr(dev);
+ if (pdata->iobase == FDT_ADDR_T_NONE) {
+ ofnode_for_each_subnode(child, dev_ofnode(dev)) {
+ if (strncmp(ofnode_get_name(child), "queue-group",
+ strlen("queue-group")))
+ continue;
+
+ reg = ofnode_get_addr(child);
+ if (reg == FDT_ADDR_T_NONE) {
+ printf("No 'reg' property of <queue-group>\n");
+ return -ENOENT;
+ }
+ pdata->iobase = reg;
+
+ /*
+ * if there are multiple queue groups,
+ * only the first one is used.
+ */
+ break;
+ }
+
+ if (!ofnode_valid(child)) {
+ printf("No child node for <queue-group>?\n");
+ return -ENOENT;
+ }
+ }
+
+ priv->regs = map_physmem(pdata->iobase, 0, MAP_NOCACHE);
ret = dev_read_phandle_with_args(dev, "tbi-handle", NULL, 0, 0,
&phandle_args);
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index aa76a8f2d2..f0ff2612a6 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -124,6 +124,13 @@ config WDT_BCM6345
The watchdog timer is stopped when initialized.
It performs full SoC reset.
+config WDT_BOOKE
+ bool "PowerPC Book-E watchdog driver"
+ depends on WDT && MPC85xx
+ help
+ Watchdog driver for PowerPC Book-E chips, such as the Freescale
+ MPC85xx SOCs and the IBM PowerPC 440.
+
config WDT_CDNS
bool "Cadence watchdog timer support"
depends on WDT
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 6e70c7ae19..5c7ef593fe 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_WDT_ARMADA_37XX) += armada-37xx-wdt.o
obj-$(CONFIG_WDT_ASPEED) += ast_wdt.o
obj-$(CONFIG_WDT_AST2600) += ast2600_wdt.o
obj-$(CONFIG_WDT_BCM6345) += bcm6345_wdt.o
+obj-$(CONFIG_WDT_BOOKE) += booke_wdt.o
obj-$(CONFIG_WDT_CORTINA) += cortina_wdt.o
obj-$(CONFIG_WDT_ORION) += orion_wdt.o
obj-$(CONFIG_WDT_CDNS) += cdns_wdt.o
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
new file mode 100644
index 0000000000..50c091956e
--- /dev/null
+++ b/drivers/watchdog/booke_wdt.c
@@ -0,0 +1,106 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Watchdog timer for PowerPC Book-E systems
+ */
+
+#include <div64.h>
+#include <dm.h>
+#include <wdt.h>
+#include <asm/processor.h>
+
+#define WDTP_MASK TCR_WP(0x3f)
+
+/* For the specified period, determine the number of seconds
+ * corresponding to the reset time. There will be a watchdog
+ * exception at approximately 3/5 of this time.
+ *
+ * The formula to calculate this is given by:
+ * 2.5 * (2^(63-period+1)) / timebase_freq
+ *
+ * In order to simplify things, we assume that period is
+ * at least 1. This will still result in a very long timeout.
+ */
+static unsigned long long period_to_sec(unsigned int period)
+{
+ unsigned long long tmp = 1ULL << (64 - period);
+ unsigned long tmp2 = get_tbclk();
+
+ /* tmp may be a very large number and we don't want to overflow,
+ * so divide the timebase freq instead of multiplying tmp
+ */
+ tmp2 = tmp2 / 5 * 2;
+
+ do_div(tmp, tmp2);
+ return tmp;
+}
+
+/*
+ * This procedure will find the highest period which will give a timeout
+ * greater than the one required. e.g. for a bus speed of 66666666 and
+ * and a parameter of 2 secs, then this procedure will return a value of 38.
+ */
+static unsigned int sec_to_period(unsigned int secs)
+{
+ unsigned int period;
+
+ for (period = 63; period > 0; period--) {
+ if (period_to_sec(period) >= secs)
+ return period;
+ }
+ return 0;
+}
+
+static int booke_wdt_reset(struct udevice *dev)
+{
+ mtspr(SPRN_TSR, TSR_ENW | TSR_WIS);
+
+ return 0;
+}
+
+static int booke_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)
+{
+ u32 val;
+ unsigned int timeout = DIV_ROUND_UP(timeout_ms, 1000);
+
+ /* clear status before enabling watchdog */
+ booke_wdt_reset(dev);
+ val = mfspr(SPRN_TCR);
+ val &= ~WDTP_MASK;
+ val |= (TCR_WIE | TCR_WRC(WRC_CHIP) | TCR_WP(sec_to_period(timeout)));
+
+ mtspr(SPRN_TCR, val);
+
+ return 0;
+}
+
+static int booke_wdt_stop(struct udevice *dev)
+{
+ u32 val;
+
+ val = mfspr(SPRN_TCR);
+ val &= ~(TCR_WIE | WDTP_MASK);
+ mtspr(SPRN_TCR, val);
+
+ /* clear status to make sure nothing is pending */
+ booke_wdt_reset(dev);
+
+ return 0;
+}
+
+static const struct wdt_ops booke_wdt_ops = {
+ .start = booke_wdt_start,
+ .stop = booke_wdt_stop,
+ .reset = booke_wdt_reset,
+};
+
+static const struct udevice_id booke_wdt_ids[] = {
+ { .compatible = "fsl,booke-wdt" },
+ {}
+};
+
+U_BOOT_DRIVER(booke_wdt) = {
+ .name = "booke_wdt",
+ .id = UCLASS_WDT,
+ .of_match = booke_wdt_ids,
+ .ops = &booke_wdt_ops,
+};