mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v2 3/6] drivers: net: fec_imx: add promiscuous mode configuration support
Date: Thu,  3 Nov 2022 14:13:48 +0100	[thread overview]
Message-ID: <20221103131351.2059683-3-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20221103131351.2059683-1-o.rempel@pengutronix.de>

Add promiscuous mode configuration support to allow using multiple MAC address
on same FEC interfaces.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/fec_imx.c | 24 +++++++++++++++++++++++-
 drivers/net/fec_imx.h |  1 +
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 673555a48a..a5ff764e28 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -25,6 +25,22 @@
 
 #include "fec_imx.h"
 
+static int fec_set_promiscuous_mode(struct eth_device *edev, bool enable)
+{
+	struct fec_priv *fec = (struct fec_priv *)edev->priv;
+	u32 rcntl;
+
+	rcntl = readl(fec->regs + FEC_R_CNTRL);
+
+	if (enable)
+		rcntl |= FEC_R_CNTRL_PROMISC;
+	else
+		rcntl &= ~FEC_R_CNTRL_PROMISC;
+
+	writel(rcntl, fec->regs + FEC_R_CNTRL);
+
+	return 0;
+}
 
 /*
  * MII-interface related functions
@@ -257,10 +273,13 @@ static int fec_init(struct eth_device *dev)
 	 */
 	writel(0x00000000, fec->regs + FEC_IMASK);
 
+	rcntl = readl(fec->regs + FEC_R_CNTRL);
+	rcntl &= FEC_R_CNTRL_PROMISC;
+
 	/*
 	 * Set FEC-Lite receive control register(R_CNTRL):
 	 */
-	rcntl = FEC_R_CNTRL_MAX_FL(1518);
+	rcntl |= FEC_R_CNTRL_MAX_FL(1518);
 
 	rcntl |= FEC_R_CNTRL_MII_MODE;
 	/*
@@ -768,6 +787,7 @@ static int fec_probe(struct device_d *dev)
 	edev->halt = fec_halt;
 	edev->get_ethaddr = fec_get_hwaddr;
 	edev->set_ethaddr = fec_set_hwaddr;
+	edev->set_promiscuous_mode = fec_set_promiscuous_mode;
 	edev->parent = dev;
 
 	dma_set_mask(dev, DMA_BIT_MASK(32));
@@ -834,6 +854,8 @@ static int fec_probe(struct device_d *dev)
 	if (ret)
 		goto free_gpio;
 
+	fec_set_promiscuous_mode(edev, false);
+
 	/*
 	 * reserve memory for both buffer descriptor chains at once
 	 * Datasheet forces the startaddress of each chain is 16 byte aligned
diff --git a/drivers/net/fec_imx.h b/drivers/net/fec_imx.h
index 316eefe48f..9bb1c64b55 100644
--- a/drivers/net/fec_imx.h
+++ b/drivers/net/fec_imx.h
@@ -58,6 +58,7 @@
 #define FEC_R_CNTRL_RMII_10T		(1 << 9) /* i.MX28 specific */
 #define FEC_R_CNTRL_RMII_MODE		(1 << 8) /* i.MX28 specific */
 #define FEC_R_CNTRL_FCE			(1 << 5)
+#define FEC_R_CNTRL_PROMISC		(1 << 3)
 #define FEC_R_CNTRL_MII_MODE		(1 << 2)
 
 #define FEC_IEVENT_HBERR                0x80000000 /* Note: Not on i.MX28 */
-- 
2.30.2




  parent reply	other threads:[~2022-11-03 13:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 13:13 [PATCH v2 1/6] net: " Oleksij Rempel
2022-11-03 13:13 ` [PATCH v2 2/6] net: dsa: enable promiscuous mode for switch master edev Oleksij Rempel
2022-11-04  8:26   ` Sascha Hauer
2022-11-04  8:34     ` Ahmad Fatoum
2022-11-03 13:13 ` Oleksij Rempel [this message]
2022-11-04  8:29   ` [PATCH v2 3/6] drivers: net: fec_imx: add promiscuous mode configuration support Sascha Hauer
2022-11-04  8:52     ` Sascha Hauer
2022-11-03 13:13 ` [PATCH v2 4/6] net: dsa: fix of_device_ensure_probed*() for switch ports Oleksij Rempel
2022-11-03 13:13 ` [PATCH v2 5/6] ARM: boards: skov-imx6: convert all pr_ to dev_ prints Oleksij Rempel
2022-11-03 13:13 ` [PATCH v2 6/6] ARM: boards: skov-imx6: assigned separate MAC address to LAN2 Oleksij Rempel
2022-11-04  8:25 ` [PATCH v2 1/6] net: add promiscuous mode configuration support Sascha Hauer
2022-11-04  8:37 ` Ahmad Fatoum

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=20221103131351.2059683-3-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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