From: Greg Malysa <malysagreg@gmail.com>
To: u-boot@lists.denx.de
Cc: adsp-linux@analog.com, Greg Malysa <malysagreg@gmail.com>,
Ian Roberts <ian.roberts@timesys.com>,
Nathan Barrett-Morrison <nathan.morrison@timesys.com>,
Vasileios Bimpikas <vasileios.bimpikas@analog.com>,
Utsav Agarwal <utsav.agarwal@analog.com>,
Arturs Artamonovs <arturs.artamonovs@analog.com>,
Oliver Gaskell <Oliver.Gaskell@analog.com>,
Boon Khai Ng <boon.khai.ng@intel.com>,
Caleb Connolly <caleb.connolly@linaro.org>,
Christophe ROULLIER <christophe.roullier@foss.st.com>,
Erik Schumacher <erik.schumacher@iris-sensing.com>,
Gabor Juhos <j4g8y7@gmail.com>,
Greg Malysa <greg.malysa@timesys.com>,
Hanyuan Zhao <hanyuan-z@qq.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Jerome Forissier <jerome.forissier@linaro.org>,
Joe Hershberger <joe.hershberger@ni.com>,
Marek Vasut <marex@denx.de>,
Markus Gothe <markus.gothe@genexis.eu>,
Mattijs Korpershoek <mkorpershoek@baylibre.com>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Philip Oberfichtner <pro@denx.de>,
Ramon Fried <rfried.dev@gmail.com>,
Robert Marko <robert.marko@sartura.hr>,
Romain Naour <romain.naour@smile.fr>,
Sam Protsenko <semen.protsenko@linaro.org>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
Weijie Gao <weijie.gao@mediatek.com>
Subject: [PATCH v3 07/12] net: Add support for ADI SC5xx SoCs with DWC QoS ethernet
Date: Wed, 26 Feb 2025 12:30:29 -0500 [thread overview]
Message-ID: <20250226173150.13198-8-malysagreg@gmail.com> (raw)
In-Reply-To: <20250226173150.13198-1-malysagreg@gmail.com>
The ADI SC598 includes a Designware QoS 5.20a IP block. This
commit adds support for using the existing ethernet QoS driver
with the SC598 SoC.
Co-developed-by: Ian Roberts <ian.roberts@timesys.com>
Signed-off-by: Ian Roberts <ian.roberts@timesys.com>
Co-developed-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
Signed-off-by: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
Signed-off-by: Vasileios Bimpikas <vasileios.bimpikas@analog.com>
Signed-off-by: Utsav Agarwal <utsav.agarwal@analog.com>
Signed-off-by: Arturs Artamonovs <arturs.artamonovs@analog.com>
Signed-off-by: Oliver Gaskell <Oliver.Gaskell@analog.com>
Signed-off-by: Greg Malysa <malysagreg@gmail.com>
---
Changes in v3:
- replace readl/writel with ioread32 and iowrite32 and friends
- update for compatibility with changes to dwc qos driver between 2024.04 and 2025.01
MAINTAINERS | 1 +
drivers/net/Kconfig | 7 +++
drivers/net/Makefile | 1 +
drivers/net/dwc_eth_qos.c | 6 ++
drivers/net/dwc_eth_qos.h | 2 +
drivers/net/dwc_eth_qos_adi.c | 103 ++++++++++++++++++++++++++++++++++
6 files changed, 120 insertions(+)
create mode 100644 drivers/net/dwc_eth_qos_adi.c
diff --git a/MAINTAINERS b/MAINTAINERS
index f2638becc32..2c4dc8b14c1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -635,6 +635,7 @@ F: drivers/clk/adi/
F: drivers/gpio/adp5588_gpio.c
F: drivers/gpio/gpio-adi-adsp.c
F: drivers/i2c/adi_i2c.c
+F: drivers/net/dwc_eth_qos_adi.c
F: drivers/pinctrl/pinctrl-adi-adsp.c
F: drivers/serial/serial_adi_uart4.c
F: drivers/timer/adi_sc5xx_timer.c
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 1563404ca17..8dc5f4810e9 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -237,6 +237,13 @@ config DWC_ETH_QOS
Of Service) IP block. The IP supports many options for bus type,
clocking/reset structure, and feature list.
+config DWC_ETH_QOS_ADI
+ bool "Synopsys DWC Ethernet QOS device support for ADI SC59x-64 parts"
+ depends on DWC_ETH_QOS
+ help
+ The Synopsis Designware Ethernet QoS IP block with the specific
+ configuration used in the ADI ADSP-SC59X 64 bit SoCs
+
config DWC_ETH_QOS_IMX
bool "Synopsys DWC Ethernet QOS device support for IMX"
depends on DWC_ETH_QOS
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 80d70212971..d919d437c08 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_DM_ETH_PHY) += eth-phy-uclass.o
obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o
obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o
obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o
+obj-$(CONFIG_DWC_ETH_QOS_ADI) += dwc_eth_qos_adi.o
obj-$(CONFIG_DWC_ETH_QOS_IMX) += dwc_eth_qos_imx.o
obj-$(CONFIG_DWC_ETH_QOS_INTEL) += dwc_eth_qos_intel.o
obj-$(CONFIG_DWC_ETH_QOS_ROCKCHIP) += dwc_eth_qos_rockchip.o
diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
index 2279481d935..b4ec3614696 100644
--- a/drivers/net/dwc_eth_qos.c
+++ b/drivers/net/dwc_eth_qos.c
@@ -1631,6 +1631,12 @@ static const struct udevice_id eqos_ids[] = {
.compatible = "starfive,jh7110-dwmac",
.data = (ulong)&eqos_jh7110_config
},
+#endif
+#if IS_ENABLED(CONFIG_DWC_ETH_QOS_ADI)
+ {
+ .compatible = "adi,sc59x-dwmac-eqos",
+ .data = (ulong)&eqos_adi_config
+ },
#endif
{ }
};
diff --git a/drivers/net/dwc_eth_qos.h b/drivers/net/dwc_eth_qos.h
index 123f98d5d53..403e8203974 100644
--- a/drivers/net/dwc_eth_qos.h
+++ b/drivers/net/dwc_eth_qos.h
@@ -87,6 +87,7 @@ struct eqos_mac_regs {
#define EQOS_MAC_MDIO_ADDRESS_CR_MASK GENMASK(11, 8)
#define EQOS_MAC_MDIO_ADDRESS_CR_100_150 1
#define EQOS_MAC_MDIO_ADDRESS_CR_20_35 2
+#define EQOS_MAC_MDIO_ADDRESS_CR_150_250 4
#define EQOS_MAC_MDIO_ADDRESS_CR_250_300 5
#define EQOS_MAC_MDIO_ADDRESS_SKAP BIT(4)
#define EQOS_MAC_MDIO_ADDRESS_GOC_MASK GENMASK(3, 2)
@@ -301,3 +302,4 @@ extern struct eqos_config eqos_qcom_config;
extern struct eqos_config eqos_stm32mp13_config;
extern struct eqos_config eqos_stm32mp15_config;
extern struct eqos_config eqos_jh7110_config;
+extern struct eqos_config eqos_adi_config;
diff --git a/drivers/net/dwc_eth_qos_adi.c b/drivers/net/dwc_eth_qos_adi.c
new file mode 100644
index 00000000000..0e6a901e303
--- /dev/null
+++ b/drivers/net/dwc_eth_qos_adi.c
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/**
+ * (C) Copyright 2024 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Author: Greg Malysa <greg.malysa@timesys.com>
+ * Additional Contact: Nathan Barrett-Morrison <nathan.morrison@timesys.com>
+ */
+
+#include <clk.h>
+#include <dm.h>
+#include <net.h>
+#include <phy.h>
+#include <reset.h>
+#include <linux/io.h>
+
+#include <asm/arch-adi/sc5xx/sc5xx.h>
+
+#include "dwc_eth_qos.h"
+
+static int eqos_start_resets_adi(struct udevice *dev)
+{
+ struct eqos_priv *eqos = dev_get_priv(dev);
+
+ /*
+ * Settings need to latch with the DMA reset below. Currently only
+ * rgmii is supported but other phy interfaces may be supported in
+ * the future
+ */
+ sc5xx_enable_rgmii();
+ setbits_32(&eqos->dma_regs->mode, EQOS_DMA_MODE_SWR);
+
+ return 0;
+}
+
+static int eqos_probe_resources_adi(struct udevice *dev)
+{
+ struct eqos_priv *eqos = dev_get_priv(dev);
+ phy_interface_t interface;
+ int ret;
+
+ ret = eqos_get_base_addr_dt(dev);
+ if (ret) {
+ pr_err("eqos_get_base_addr_dt failed: %d\n", ret);
+ return ret;
+ }
+
+ interface = eqos->config->interface(dev);
+ if (interface == PHY_INTERFACE_MODE_NA) {
+ pr_err("Invalid PHY interface\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+/**
+ * rgmii tx clock rate is set to 125 MHz regardless of phy mode, and
+ * by default the internal clock is always connected to 125 MHz. According
+ * to the HRM it is invalid for this clock to have any other speed, so
+ * the hardware won't work anyway if this is wrong.
+ */
+static ulong eqos_get_tick_clk_rate_adi(struct udevice *dev)
+{
+ return 125 * 1000000;
+}
+
+static int eqos_get_enetaddr_adi(struct udevice *dev)
+{
+ struct eth_pdata *pdata = dev_get_plat(dev);
+
+ return eth_env_get_enetaddr("ethaddr", pdata->enetaddr);
+}
+
+static struct eqos_ops eqos_adi_ops = {
+ .eqos_inval_desc = eqos_inval_desc_generic,
+ .eqos_flush_desc = eqos_flush_desc_generic,
+ .eqos_inval_buffer = eqos_inval_buffer_generic,
+ .eqos_flush_buffer = eqos_flush_buffer_generic,
+ .eqos_probe_resources = eqos_probe_resources_adi,
+ .eqos_remove_resources = eqos_null_ops,
+ .eqos_start_resets = eqos_start_resets_adi,
+ .eqos_stop_resets = eqos_null_ops,
+ .eqos_start_clks = eqos_null_ops,
+ .eqos_stop_clks = eqos_null_ops,
+ .eqos_calibrate_pads = eqos_null_ops,
+ .eqos_disable_calibration = eqos_null_ops,
+ .eqos_set_tx_clk_speed = eqos_null_ops,
+ .eqos_get_enetaddr = eqos_get_enetaddr_adi,
+ .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_adi,
+};
+
+struct eqos_config __maybe_unused eqos_adi_config = {
+ .reg_access_always_ok = true,
+ .mdio_wait = 20,
+ .swr_wait = 50,
+ .config_mac = EQOS_MAC_RXQ_CTRL0_RXQ0EN_ENABLED_DCB,
+ .config_mac_mdio = EQOS_MAC_MDIO_ADDRESS_CR_150_250,
+ .axi_bus_width = EQOS_AXI_WIDTH_32,
+ .interface = dev_read_phy_mode,
+ .ops = &eqos_adi_ops,
+};
--
2.45.2
next prev parent reply other threads:[~2025-02-26 18:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 17:30 [PATCH v3 00/12] drivers: Driver support for ADI SC5xx SoCs Greg Malysa
2025-02-26 17:30 ` [PATCH v3 01/12] pinctrl: Add support for ADI SC5XX-family pinctrl Greg Malysa
2025-02-26 17:30 ` [PATCH v3 02/12] doc: Add dt-bindings and descriptions for ADI SC5xx-family pinctrl Greg Malysa
2025-02-26 17:30 ` [PATCH v3 03/12] gpio: Add support for SC5XX-family processor GPIO driver Greg Malysa
2025-02-26 17:30 ` [PATCH v3 04/12] gpio: Add support for ADI ADP5588 GPIO expander chips Greg Malysa
2025-02-26 17:30 ` [PATCH v3 05/12] usb: musb-new: Add support for Analog Devices SC5xx SoCs Greg Malysa
2025-02-26 17:30 ` [PATCH v3 06/12] i2c: Add support for ADI SC5XX-family I2C peripheral Greg Malysa
2025-03-06 5:56 ` Heiko Schocher
2025-02-26 17:30 ` Greg Malysa [this message]
2025-02-26 17:30 ` [PATCH v3 08/12] watchdog: Add support for ADI SC5XX-family watchdog peripheral Greg Malysa
2025-02-27 8:44 ` Stefan Roese
2025-02-26 17:30 ` [PATCH v3 09/12] dma: Add driver for ADI SC5xx-family SoC MDMA functionality Greg Malysa
2025-02-26 17:30 ` [PATCH v3 10/12] remoteproc: Add in SHARC loading for ADI SC5XX-family processors Greg Malysa
2025-02-26 17:30 ` [PATCH v3 11/12] spi: Add support for ADI SC5XX-family processor SPI peripherals Greg Malysa
2025-02-26 17:30 ` [PATCH v3 12/12] mmc: Add support for ADI SC5XX-family processor SDHCI peripherals Greg Malysa
2025-03-12 19:43 ` [PATCH v3 00/12] drivers: Driver support for ADI SC5xx SoCs Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250226173150.13198-8-malysagreg@gmail.com \
--to=malysagreg@gmail.com \
--cc=Oliver.Gaskell@analog.com \
--cc=adsp-linux@analog.com \
--cc=arturs.artamonovs@analog.com \
--cc=boon.khai.ng@intel.com \
--cc=caleb.connolly@linaro.org \
--cc=christophe.roullier@foss.st.com \
--cc=erik.schumacher@iris-sensing.com \
--cc=greg.malysa@timesys.com \
--cc=hanyuan-z@qq.com \
--cc=ian.roberts@timesys.com \
--cc=ilias.apalodimas@linaro.org \
--cc=j4g8y7@gmail.com \
--cc=jerome.forissier@linaro.org \
--cc=joe.hershberger@ni.com \
--cc=marex@denx.de \
--cc=markus.gothe@genexis.eu \
--cc=mkorpershoek@baylibre.com \
--cc=nathan.morrison@timesys.com \
--cc=patrice.chotard@foss.st.com \
--cc=pro@denx.de \
--cc=rfried.dev@gmail.com \
--cc=robert.marko@sartura.hr \
--cc=romain.naour@smile.fr \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=utsav.agarwal@analog.com \
--cc=vasileios.bimpikas@analog.com \
--cc=weijie.gao@mediatek.com \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox