From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>,
Samuel Holland <samuel.holland@sifive.com>,
Richard Cochran <richardcochran@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>,
Gregory CLEMENT <gregory.clement@bootlin.com>,
Cyrille Pitchen <cyrille.pitchen@atmel.com>,
Harini Katakam <harini.katakam@xilinx.com>,
Rafal Ozieblo <rafalo@cadence.com>,
Haavard Skinnemoen <hskinnemoen@atmel.com>,
Jeff Garzik <jeff@garzik.org>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-mips@vger.kernel.org,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Tawfik Bayouk" <tawfik.bayouk@mobileye.com>,
"Théo Lebrun" <theo.lebrun@bootlin.com>
Subject: [PATCH net-next v2 15/18] net: macb: Add "mobileye,eyeq5-gem" compatible
Date: Fri, 27 Jun 2025 11:09:01 +0200 [thread overview]
Message-ID: <20250627-macb-v2-15-ff8207d0bb77@bootlin.com> (raw)
In-Reply-To: <20250627-macb-v2-0-ff8207d0bb77@bootlin.com>
Add support for the two GEM instances inside Mobileye EyeQ5 SoCs, using
compatible "mobileye,eyeq5-gem". With it, add a custom init sequence
that accesses two system-controller registers.
Noteworthy: NET_IP_ALIGN=2 on MIPS but the hardware does not align and
low bits aren't configurable, so we cannot respect the requested IP
header alignment.
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
---
drivers/net/ethernet/cadence/macb_main.c | 80 ++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index f9a3a5caebcafe3d9197a3bc7681b64734d7ac93..ed394e5d1ec9b1748282f1448628d5006f3b0971 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -20,6 +20,7 @@
#include <linux/iopoll.h>
#include <linux/ip.h>
#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/netdevice.h>
@@ -31,6 +32,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/ptp_classify.h>
+#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/slab.h>
#include <linux/tcp.h>
@@ -4957,6 +4959,72 @@ static int init_reset_optional(struct platform_device *pdev)
return ret;
}
+#define EYEQ5_OLB_GP_TX_SWRST_DIS BIT(0) // Tx SW reset
+#define EYEQ5_OLB_GP_TX_M_CLKE BIT(1) // Tx M clock enable
+#define EYEQ5_OLB_GP_SYS_SWRST_DIS BIT(2) // Sys SW reset
+#define EYEQ5_OLB_GP_SYS_M_CLKE BIT(3) // Sys clock enable
+#define EYEQ5_OLB_GP_SGMII_MODE BIT(4) // SGMII mode
+#define EYEQ5_OLB_GP_RGMII_DRV GENMASK(8, 5) // RGMII mode
+
+#define EYEQ5_OLB_SGMII_PWR_EN BIT(0)
+#define EYEQ5_OLB_SGMII_RST_DIS BIT(1)
+#define EYEQ5_OLB_SGMII_PLL_EN BIT(2)
+#define EYEQ5_OLB_SGMII_SIG_DET_SW BIT(3)
+#define EYEQ5_OLB_SGMII_PWR_STATE BIT(4)
+#define EYEQ5_OLB_SGMII_PLL_ACK BIT(18)
+
+static int eyeq5_init(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct net_device *netdev = platform_get_drvdata(pdev);
+ struct macb *bp = netdev_priv(netdev);
+ struct device_node *np = dev->of_node;
+ unsigned int gp, sgmii;
+ struct regmap *regmap;
+ unsigned int args[2];
+ unsigned int reg;
+ int ret;
+
+ regmap = syscon_regmap_lookup_by_phandle_args(np, "mobileye,olb", 2, args);
+ if (IS_ERR(regmap))
+ return PTR_ERR(regmap);
+
+ gp = args[0];
+ sgmii = args[1];
+
+ /* Forced reset */
+ regmap_write(regmap, gp, 0);
+ regmap_write(regmap, sgmii, 0);
+ usleep_range(5, 20);
+
+ if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII) {
+ regmap_write(regmap, gp, EYEQ5_OLB_GP_SGMII_MODE);
+
+ reg = EYEQ5_OLB_SGMII_PWR_EN | EYEQ5_OLB_SGMII_RST_DIS |
+ EYEQ5_OLB_SGMII_PLL_EN;
+ regmap_write(regmap, sgmii, reg);
+
+ ret = regmap_read_poll_timeout(regmap, sgmii, reg,
+ reg & EYEQ5_OLB_SGMII_PLL_ACK,
+ 1, 100);
+ if (ret)
+ return dev_err_probe(dev, ret, "PLL timeout");
+
+ reg = EYEQ5_OLB_SGMII_PWR_STATE | EYEQ5_OLB_SGMII_SIG_DET_SW;
+ regmap_update_bits(regmap, sgmii, reg, reg);
+ }
+
+ reg = phy_interface_mode_is_rgmii(bp->phy_interface) ? 0x9 : 0x0;
+ regmap_update_bits(regmap, gp, EYEQ5_OLB_GP_RGMII_DRV,
+ FIELD_PREP(EYEQ5_OLB_GP_RGMII_DRV, reg));
+
+ reg = EYEQ5_OLB_GP_TX_SWRST_DIS | EYEQ5_OLB_GP_TX_M_CLKE |
+ EYEQ5_OLB_GP_SYS_SWRST_DIS | EYEQ5_OLB_GP_SYS_M_CLKE;
+ regmap_update_bits(regmap, gp, reg, reg);
+
+ return macb_init(pdev);
+}
+
static const struct macb_usrio_config sama7g5_usrio = {
.mii = 0,
.rmii = 1,
@@ -5109,6 +5177,17 @@ static const struct macb_config versal_config = {
.usrio = &macb_default_usrio,
};
+static const struct macb_config eyeq5_config = {
+ .caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |
+ MACB_CAPS_GEM_HAS_PTP | MACB_CAPS_QUEUE_DISABLE |
+ MACB_CAPS_NO_LSO,
+ .dma_burst_length = 16,
+ .clk_init = macb_clk_init,
+ .init = eyeq5_init,
+ .jumbo_max_len = 10240,
+ .usrio = &macb_default_usrio,
+};
+
static const struct of_device_id macb_dt_ids[] = {
{ .compatible = "cdns,at91sam9260-macb", .data = &at91sam9260_config },
{ .compatible = "cdns,macb" },
@@ -5129,6 +5208,7 @@ static const struct of_device_id macb_dt_ids[] = {
{ .compatible = "microchip,mpfs-macb", .data = &mpfs_config },
{ .compatible = "microchip,sama7g5-gem", .data = &sama7g5_gem_config },
{ .compatible = "microchip,sama7g5-emac", .data = &sama7g5_emac_config },
+ { .compatible = "mobileye,eyeq5-gem", .data = &eyeq5_config },
{ .compatible = "xlnx,zynqmp-gem", .data = &zynqmp_config},
{ .compatible = "xlnx,zynq-gem", .data = &zynq_config },
{ .compatible = "xlnx,versal-gem", .data = &versal_config},
--
2.50.0
next prev parent reply other threads:[~2025-06-27 9:09 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 9:08 [PATCH net-next v2 00/18] Support the Cadence MACB/GEM instances on Mobileye EyeQ5 SoCs Théo Lebrun
2025-06-27 9:08 ` [PATCH net-next v2 01/18] dt-bindings: net: cdns,macb: sort compatibles Théo Lebrun
2025-07-01 8:16 ` Krzysztof Kozlowski
2025-06-27 9:08 ` [PATCH net-next v2 02/18] dt-bindings: net: cdns,macb: add Mobileye EyeQ5 ethernet interface Théo Lebrun
2025-07-01 8:18 ` Krzysztof Kozlowski
2025-06-27 9:08 ` [PATCH net-next v2 03/18] dt-bindings: net: cdns,macb: allow tsu_clk without tx_clk Théo Lebrun
2025-07-01 8:19 ` Krzysztof Kozlowski
2025-06-27 9:08 ` [PATCH net-next v2 04/18] dt-bindings: net: cdns,macb: allow dma-coherent Théo Lebrun
2025-06-27 9:08 ` [PATCH net-next v2 05/18] net: macb: use BIT() macro for capability definitions Théo Lebrun
2025-07-01 15:35 ` Sean Anderson
2025-06-27 9:08 ` [PATCH net-next v2 06/18] net: macb: Remove local variables clk_init and init in macb_probe() Théo Lebrun
2025-07-01 15:35 ` Sean Anderson
2025-06-27 9:08 ` [PATCH net-next v2 07/18] net: macb: drop macb_config NULL checking Théo Lebrun
2025-07-01 15:37 ` Sean Anderson
2025-06-27 9:08 ` [PATCH net-next v2 08/18] net: macb: introduce DMA descriptor helpers (is 64bit? is PTP?) Théo Lebrun
2025-07-01 15:56 ` Sean Anderson
2025-06-27 9:08 ` [PATCH net-next v2 09/18] net: macb: sort #includes Théo Lebrun
2025-07-01 15:58 ` Sean Anderson
2025-06-27 9:08 ` [PATCH net-next v2 10/18] net: macb: remove illusion about TBQPH/RBQPH being per-queue Théo Lebrun
2025-07-01 16:15 ` Sean Anderson
2025-07-01 16:20 ` Sean Anderson
2025-06-27 9:08 ` [PATCH net-next v2 11/18] net: macb: single dma_alloc_coherent() for DMA descriptors Théo Lebrun
2025-07-01 16:32 ` Sean Anderson
2025-08-07 14:48 ` Théo Lebrun
2025-06-27 9:08 ` [PATCH net-next v2 12/18] net: macb: match skb_reserve(skb, NET_IP_ALIGN) with HW alignment Théo Lebrun
2025-07-01 16:40 ` Sean Anderson
2025-08-07 15:24 ` Théo Lebrun
2025-08-11 18:53 ` Sean Anderson
2025-06-27 9:08 ` [PATCH net-next v2 13/18] net: macb: avoid double endianness swap in macb_set_hwaddr() Théo Lebrun
2025-07-01 16:44 ` Sean Anderson
2025-06-27 9:09 ` [PATCH net-next v2 14/18] net: macb: add no LSO capability (MACB_CAPS_NO_LSO) Théo Lebrun
2025-07-01 16:51 ` Sean Anderson
2025-06-27 9:09 ` Théo Lebrun [this message]
2025-07-01 16:51 ` [PATCH net-next v2 15/18] net: macb: Add "mobileye,eyeq5-gem" compatible Sean Anderson
2025-06-27 9:09 ` [PATCH net-next v2 16/18] MIPS: mobileye: add EyeQ5 DMA IOCU support Théo Lebrun
2025-06-27 19:15 ` Simon Horman
2025-06-30 13:35 ` Jiaxun Yang
2025-08-07 16:11 ` Théo Lebrun
2025-06-27 9:09 ` [PATCH net-next v2 17/18] MIPS: mobileye: eyeq5: add two Cadence GEM Ethernet controllers Théo Lebrun
2025-06-27 9:09 ` [PATCH net-next v2 18/18] MIPS: mobileye: eyeq5-epm: add two Cadence GEM Ethernet PHYs Théo Lebrun
2025-06-27 9:41 ` [PATCH net-next v2 00/18] Support the Cadence MACB/GEM instances on Mobileye EyeQ5 SoCs Maxime Chevallier
2025-07-01 16:53 ` Sean Anderson
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=20250627-macb-v2-15-ff8207d0bb77@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=alex@ghiti.fr \
--cc=andrew+netdev@lunn.ch \
--cc=aou@eecs.berkeley.edu \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=cyrille.pitchen@atmel.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=gregory.clement@bootlin.com \
--cc=harini.katakam@xilinx.com \
--cc=hskinnemoen@atmel.com \
--cc=jeff@garzik.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rafalo@cadence.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=tawfik.bayouk@mobileye.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=tsbogend@alpha.franken.de \
--cc=vladimir.kondratiev@mobileye.com \
/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;
as well as URLs for NNTP newsgroup(s).