linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option
@ 2020-11-28 22:54 Adrien Grassein
  2020-11-28 22:54 ` [PATCH 2/3] net: fsl: fec: " Adrien Grassein
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Adrien Grassein @ 2020-11-28 22:54 UTC (permalink / raw)
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree,
	linux-kernel, Adrien Grassein

Add dt-bindings explanation for the two new gpios
(mdio and mdc) used for bitbanging.

Signed-off-by: Adrien Grassein <adrien.grassein@gmail.com>
---
 Documentation/devicetree/bindings/net/fsl-fec.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
index 9b543789cd52..e9fa992354b7 100644
--- a/Documentation/devicetree/bindings/net/fsl-fec.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
@@ -22,6 +22,10 @@ Optional properties:
 - fsl,err006687-workaround-present: If present indicates that the system has
   the hardware workaround for ERR006687 applied and does not need a software
   workaround.
+- mdc-gpios: Bitbanged MDIO Management Data Clock GPIO. If specified,
+mdio-gpios should be specified too.
+- mdio-gpios: Bitbanged MDIO Management Data I/O GPIO. If specified,
+mdc-gpios should be specified too.
 - fsl,stop-mode: register bits of stop mode control, the format is
 		 <&gpr req_gpr req_bit>.
 		 gpr is the phandle to general purpose register node.
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/3] net: fsl: fec: add mdc/mdio bitbang option
  2020-11-28 22:54 [PATCH 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
@ 2020-11-28 22:54 ` Adrien Grassein
  2020-11-28 22:54 ` [PATCH 3/3] net: fsl: fec: add imx8mq support Adrien Grassein
  2020-11-29 21:59 ` [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
  2 siblings, 0 replies; 10+ messages in thread
From: Adrien Grassein @ 2020-11-28 22:54 UTC (permalink / raw)
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree,
	linux-kernel, Adrien Grassein

This patch adds the ability for the fec to use the
mdc/mdio bitbang protocol to communicate with its phy.

It adds two new optional parameters in the
devicetree definition for the two needed GPIO (mdc and mdio).

It uses the mdio-bitbang generic implementation.

Signed-off-by: Adrien Grassein <adrien.grassein@gmail.com>
---
 drivers/net/ethernet/freescale/fec.h      |  5 ++
 drivers/net/ethernet/freescale/fec_main.c | 91 ++++++++++++++++++++---
 2 files changed, 87 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index c527f4ee1d3a..84bf9be4c6f5 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -15,6 +15,7 @@
 /****************************************************************************/
 
 #include <linux/clocksource.h>
+#include <linux/mdio-bitbang.h>
 #include <linux/net_tstamp.h>
 #include <linux/ptp_clock_kernel.h>
 #include <linux/timecounter.h>
@@ -590,6 +591,10 @@ struct fec_enet_private {
 	int pps_enable;
 	unsigned int next_counter;
 
+	struct mdiobb_ctrl fec_main_bb_ctrl;
+	struct gpio_desc *gd_mdc;
+	struct gpio_desc *gd_mdio;
+
 	u64 ethtool_stats[];
 };
 
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 04f24c66cf36..e5c0a5da9965 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2050,6 +2050,48 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 	return 0;
 }
 
+static void fec_main_bb_ctrl_set_mdc(struct mdiobb_ctrl *ctrl, int level)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	if (level)
+		gpiod_direction_input(fep->gd_mdc);
+	else
+		gpiod_direction_output(fep->gd_mdc, 0);
+}
+
+static void fec_main_bb_ctrl_set_mdio_dir(struct mdiobb_ctrl *ctrl, int output)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	if (output)
+		gpiod_direction_output(fep->gd_mdio, 0);
+	else
+		gpiod_direction_input(fep->gd_mdio);
+}
+
+static void fec_main_bb_ctrl_set_mdio_data(struct mdiobb_ctrl *ctrl, int value)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	gpiod_direction_output(fep->gd_mdio, value);
+}
+
+static int fec_main_bb_ctrl_get_mdio_data(struct mdiobb_ctrl *ctrl)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	return gpiod_get_value(fep->gd_mdio);
+}
+
+static const struct mdiobb_ops fec_main_bb_ops = {
+	.owner = THIS_MODULE,
+	.set_mdc = fec_main_bb_ctrl_set_mdc,
+	.set_mdio_dir = fec_main_bb_ctrl_set_mdio_dir,
+	.set_mdio_data = fec_main_bb_ctrl_set_mdio_data,
+	.get_mdio_data = fec_main_bb_ctrl_get_mdio_data,
+};
+
 static int fec_enet_mii_init(struct platform_device *pdev)
 {
 	static struct mii_bus *fec0_mii_bus;
@@ -2150,18 +2192,27 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	/* Clear any pending transaction complete indication */
 	writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
 
-	fep->mii_bus = mdiobus_alloc();
-	if (fep->mii_bus == NULL) {
-		err = -ENOMEM;
-		goto err_out;
-	}
+	if (fep->gd_mdc && fep->gd_mdio) {
+		fep->fec_main_bb_ctrl.ops = &fec_main_bb_ops;
+		fep->mii_bus = alloc_mdio_bitbang(&fep->fec_main_bb_ctrl);
+		if (!fep->mii_bus) {
+			err = -ENOMEM;
+			goto err_out;
+		}
+	} else {
+		fep->mii_bus = mdiobus_alloc();
+		if (!fep->mii_bus) {
+			err = -ENOMEM;
+			goto err_out;
+		}
+		fep->mii_bus->read = fec_enet_mdio_read;
+		fep->mii_bus->write = fec_enet_mdio_write;
 
-	fep->mii_bus->name = "fec_enet_mii_bus";
-	fep->mii_bus->read = fec_enet_mdio_read;
-	fep->mii_bus->write = fec_enet_mdio_write;
+		fep->mii_bus->priv = fep;
+	}
 	snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
 		pdev->name, fep->dev_id + 1);
-	fep->mii_bus->priv = fep;
+	fep->mii_bus->name = "fec_enet_mii_bus";
 	fep->mii_bus->parent = &pdev->dev;
 
 	err = of_mdiobus_register(fep->mii_bus, node);
@@ -3525,6 +3576,8 @@ fec_probe(struct platform_device *pdev)
 	char irq_name[8];
 	int irq_cnt;
 	struct fec_devinfo *dev_info;
+	struct gpio_desc *gd;
+
 
 	fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
 
@@ -3575,6 +3628,26 @@ fec_probe(struct platform_device *pdev)
 	    !of_property_read_bool(np, "fsl,err006687-workaround-present"))
 		fep->quirks |= FEC_QUIRK_ERR006687;
 
+	gd = devm_gpiod_get_optional(&pdev->dev, "mdc", GPIOD_IN);
+	if (IS_ERR(gd)) {
+		if (PTR_ERR(gd) != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get mdc gpio: %ld\n",
+				PTR_ERR(gd));
+		ret = PTR_ERR(gd);
+		goto failed_ioremap;
+	}
+	fep->gd_mdc = gd;
+
+	gd = devm_gpiod_get_optional(&pdev->dev, "mdio", GPIOD_IN);
+	if (IS_ERR(gd)) {
+		if (PTR_ERR(gd) != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get mdio gpio: %ld\n",
+				PTR_ERR(gd));
+		ret = PTR_ERR(gd);
+		goto failed_ioremap;
+	}
+	fep->gd_mdio = gd;
+
 	if (of_get_property(np, "fsl,magic-packet", NULL))
 		fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 3/3] net: fsl: fec: add imx8mq support.
  2020-11-28 22:54 [PATCH 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
  2020-11-28 22:54 ` [PATCH 2/3] net: fsl: fec: " Adrien Grassein
@ 2020-11-28 22:54 ` Adrien Grassein
  2020-11-29 21:59 ` [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
  2 siblings, 0 replies; 10+ messages in thread
From: Adrien Grassein @ 2020-11-28 22:54 UTC (permalink / raw)
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree,
	linux-kernel, Adrien Grassein

This patch adds the imx8mq support to the
fsl fec driver.
Quirks are extracted from the NXP driver (5.4).

Signed-off-by: Adrien Grassein <adrien.grassein@gmail.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index e5c0a5da9965..92ad5b86d31c 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -131,6 +131,14 @@ static const struct fec_devinfo fec_imx6ul_info = {
 		  FEC_QUIRK_HAS_COALESCE | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
+static const struct fec_devinfo fec_imx8mq_info = {
+	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
+		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
+		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
+		  FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
+		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE
+};
+
 static struct platform_device_id fec_devtype[] = {
 	{
 		/* keep it for coldfire */
@@ -158,6 +166,11 @@ static struct platform_device_id fec_devtype[] = {
 		.name = "imx6ul-fec",
 		.driver_data = (kernel_ulong_t)&fec_imx6ul_info,
 	}, {
+		.name = "imx8mq-fec",
+		.driver_data = (kernel_ulong_t)&fec_imx8mq_info,
+	},
+
+	{
 		/* sentinel */
 	}
 };
@@ -171,6 +184,7 @@ enum imx_fec_type {
 	MVF600_FEC,
 	IMX6SX_FEC,
 	IMX6UL_FEC,
+	IMX8MQ_FEC,
 };
 
 static const struct of_device_id fec_dt_ids[] = {
@@ -181,6 +195,8 @@ static const struct of_device_id fec_dt_ids[] = {
 	{ .compatible = "fsl,mvf600-fec", .data = &fec_devtype[MVF600_FEC], },
 	{ .compatible = "fsl,imx6sx-fec", .data = &fec_devtype[IMX6SX_FEC], },
 	{ .compatible = "fsl,imx6ul-fec", .data = &fec_devtype[IMX6UL_FEC], },
+	{ .compatible = "fsl,imx8mq-fec", .data = &fec_devtype[IMX8MQ_FEC], },
+
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, fec_dt_ids);
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option
  2020-11-28 22:54 [PATCH 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
  2020-11-28 22:54 ` [PATCH 2/3] net: fsl: fec: " Adrien Grassein
  2020-11-28 22:54 ` [PATCH 3/3] net: fsl: fec: add imx8mq support Adrien Grassein
@ 2020-11-29 21:59 ` Adrien Grassein
  2020-11-29 21:59   ` [PATCH v2 2/3] net: fsl: fec: " Adrien Grassein
                     ` (2 more replies)
  2 siblings, 3 replies; 10+ messages in thread
From: Adrien Grassein @ 2020-11-29 21:59 UTC (permalink / raw)
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree,
	linux-kernel, Adrien Grassein

Add dt-bindings explanation for the two new gpios
(mdio and mdc) used for bitbanging.

Signed-off-by: Adrien Grassein <adrien.grassein@gmail.com>
---
 Documentation/devicetree/bindings/net/fsl-fec.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
index 9b543789cd52..e9fa992354b7 100644
--- a/Documentation/devicetree/bindings/net/fsl-fec.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
@@ -22,6 +22,10 @@ Optional properties:
 - fsl,err006687-workaround-present: If present indicates that the system has
   the hardware workaround for ERR006687 applied and does not need a software
   workaround.
+- mdc-gpios: Bitbanged MDIO Management Data Clock GPIO. If specified,
+mdio-gpios should be specified too.
+- mdio-gpios: Bitbanged MDIO Management Data I/O GPIO. If specified,
+mdc-gpios should be specified too.
 - fsl,stop-mode: register bits of stop mode control, the format is
 		 <&gpr req_gpr req_bit>.
 		 gpr is the phandle to general purpose register node.
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 2/3] net: fsl: fec: add mdc/mdio bitbang option
  2020-11-29 21:59 ` [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
@ 2020-11-29 21:59   ` Adrien Grassein
  2020-11-29 22:00   ` [PATCH v2 3/3] net: fsl: fec: add imx8mq support Adrien Grassein
       [not found]   ` <20201129224113.GS2234159@lunn.ch>
  2 siblings, 0 replies; 10+ messages in thread
From: Adrien Grassein @ 2020-11-29 21:59 UTC (permalink / raw)
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree,
	linux-kernel, Adrien Grassein

This patch adds the ability for the fec to use the
mdc/mdio bitbang protocol to communicate with its phy.

It adds two new optional parameters in the
devicetree definition for the two needed GPIO (mdc and mdio).

It uses the mdio-bitbang generic implementation.

Signed-off-by: Adrien Grassein <adrien.grassein@gmail.com>
---
 drivers/net/ethernet/freescale/fec.h      |   5 ++
 drivers/net/ethernet/freescale/fec_main.c | 101 +++++++++++++++++++---
 2 files changed, 95 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index c527f4ee1d3a..84bf9be4c6f5 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -15,6 +15,7 @@
 /****************************************************************************/
 
 #include <linux/clocksource.h>
+#include <linux/mdio-bitbang.h>
 #include <linux/net_tstamp.h>
 #include <linux/ptp_clock_kernel.h>
 #include <linux/timecounter.h>
@@ -590,6 +591,10 @@ struct fec_enet_private {
 	int pps_enable;
 	unsigned int next_counter;
 
+	struct mdiobb_ctrl fec_main_bb_ctrl;
+	struct gpio_desc *gd_mdc;
+	struct gpio_desc *gd_mdio;
+
 	u64 ethtool_stats[];
 };
 
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 04f24c66cf36..4f22c8e3fe7e 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2050,6 +2050,48 @@ static int fec_enet_mii_probe(struct net_device *ndev)
 	return 0;
 }
 
+static void fec_main_bb_ctrl_set_mdc(struct mdiobb_ctrl *ctrl, int level)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	if (level)
+		gpiod_direction_input(fep->gd_mdc);
+	else
+		gpiod_direction_output(fep->gd_mdc, 0);
+}
+
+static void fec_main_bb_ctrl_set_mdio_dir(struct mdiobb_ctrl *ctrl, int output)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	if (output)
+		gpiod_direction_output(fep->gd_mdio, 0);
+	else
+		gpiod_direction_input(fep->gd_mdio);
+}
+
+static void fec_main_bb_ctrl_set_mdio_data(struct mdiobb_ctrl *ctrl, int value)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	gpiod_direction_output(fep->gd_mdio, value);
+}
+
+static int fec_main_bb_ctrl_get_mdio_data(struct mdiobb_ctrl *ctrl)
+{
+	struct fec_enet_private *fep = container_of(ctrl,
+							struct fec_enet_private, fec_main_bb_ctrl);
+	return gpiod_get_value(fep->gd_mdio);
+}
+
+static const struct mdiobb_ops fec_main_bb_ops = {
+	.owner = THIS_MODULE,
+	.set_mdc = fec_main_bb_ctrl_set_mdc,
+	.set_mdio_dir = fec_main_bb_ctrl_set_mdio_dir,
+	.set_mdio_data = fec_main_bb_ctrl_set_mdio_data,
+	.get_mdio_data = fec_main_bb_ctrl_get_mdio_data,
+};
+
 static int fec_enet_mii_init(struct platform_device *pdev)
 {
 	static struct mii_bus *fec0_mii_bus;
@@ -2150,18 +2192,27 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	/* Clear any pending transaction complete indication */
 	writel(FEC_ENET_MII, fep->hwp + FEC_IEVENT);
 
-	fep->mii_bus = mdiobus_alloc();
-	if (fep->mii_bus == NULL) {
-		err = -ENOMEM;
-		goto err_out;
-	}
+	if (fep->gd_mdc && fep->gd_mdio) {
+		fep->fec_main_bb_ctrl.ops = &fec_main_bb_ops;
+		fep->mii_bus = alloc_mdio_bitbang(&fep->fec_main_bb_ctrl);
+		if (!fep->mii_bus) {
+			err = -ENOMEM;
+			goto err_out;
+		}
+	} else {
+		fep->mii_bus = mdiobus_alloc();
+		if (!fep->mii_bus) {
+			err = -ENOMEM;
+			goto err_out;
+		}
+		fep->mii_bus->read = fec_enet_mdio_read;
+		fep->mii_bus->write = fec_enet_mdio_write;
 
-	fep->mii_bus->name = "fec_enet_mii_bus";
-	fep->mii_bus->read = fec_enet_mdio_read;
-	fep->mii_bus->write = fec_enet_mdio_write;
+		fep->mii_bus->priv = fep;
+	}
 	snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
 		pdev->name, fep->dev_id + 1);
-	fep->mii_bus->priv = fep;
+	fep->mii_bus->name = "fec_enet_mii_bus";
 	fep->mii_bus->parent = &pdev->dev;
 
 	err = of_mdiobus_register(fep->mii_bus, node);
@@ -2178,7 +2229,10 @@ static int fec_enet_mii_init(struct platform_device *pdev)
 	return 0;
 
 err_out_free_mdiobus:
-	mdiobus_free(fep->mii_bus);
+	if (fep->gd_mdc && fep->gd_mdio)
+		free_mdio_bitbang(fep->mii_bus);
+	else
+		mdiobus_free(fep->mii_bus);
 err_out:
 	return err;
 }
@@ -2187,7 +2241,10 @@ static void fec_enet_mii_remove(struct fec_enet_private *fep)
 {
 	if (--mii_cnt == 0) {
 		mdiobus_unregister(fep->mii_bus);
-		mdiobus_free(fep->mii_bus);
+		if (fep->gd_mdc && fep->gd_mdio)
+			free_mdio_bitbang(fep->mii_bus);
+		else
+			mdiobus_free(fep->mii_bus);
 	}
 }
 
@@ -3525,6 +3582,8 @@ fec_probe(struct platform_device *pdev)
 	char irq_name[8];
 	int irq_cnt;
 	struct fec_devinfo *dev_info;
+	struct gpio_desc *gd;
+
 
 	fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs);
 
@@ -3575,6 +3634,26 @@ fec_probe(struct platform_device *pdev)
 	    !of_property_read_bool(np, "fsl,err006687-workaround-present"))
 		fep->quirks |= FEC_QUIRK_ERR006687;
 
+	gd = devm_gpiod_get_optional(&pdev->dev, "mdc", GPIOD_IN);
+	if (IS_ERR(gd)) {
+		if (PTR_ERR(gd) != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get mdc gpio: %ld\n",
+				PTR_ERR(gd));
+		ret = PTR_ERR(gd);
+		goto failed_ioremap;
+	}
+	fep->gd_mdc = gd;
+
+	gd = devm_gpiod_get_optional(&pdev->dev, "mdio", GPIOD_IN);
+	if (IS_ERR(gd)) {
+		if (PTR_ERR(gd) != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "Failed to get mdio gpio: %ld\n",
+				PTR_ERR(gd));
+		ret = PTR_ERR(gd);
+		goto failed_ioremap;
+	}
+	fep->gd_mdio = gd;
+
 	if (of_get_property(np, "fsl,magic-packet", NULL))
 		fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 3/3] net: fsl: fec: add imx8mq support.
  2020-11-29 21:59 ` [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
  2020-11-29 21:59   ` [PATCH v2 2/3] net: fsl: fec: " Adrien Grassein
@ 2020-11-29 22:00   ` Adrien Grassein
       [not found]   ` <20201129224113.GS2234159@lunn.ch>
  2 siblings, 0 replies; 10+ messages in thread
From: Adrien Grassein @ 2020-11-29 22:00 UTC (permalink / raw)
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree,
	linux-kernel, Adrien Grassein

This patch adds the imx8mq support to the
fsl fec driver.
Quirks are extracted from the NXP driver (5.4).

Signed-off-by: Adrien Grassein <adrien.grassein@gmail.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 4f22c8e3fe7e..a4bb1adbf9ed 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -131,6 +131,14 @@ static const struct fec_devinfo fec_imx6ul_info = {
 		  FEC_QUIRK_HAS_COALESCE | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
+static const struct fec_devinfo fec_imx8mq_info = {
+	.quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
+		  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
+		  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
+		  FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
+		  FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE
+};
+
 static struct platform_device_id fec_devtype[] = {
 	{
 		/* keep it for coldfire */
@@ -158,6 +166,11 @@ static struct platform_device_id fec_devtype[] = {
 		.name = "imx6ul-fec",
 		.driver_data = (kernel_ulong_t)&fec_imx6ul_info,
 	}, {
+		.name = "imx8mq-fec",
+		.driver_data = (kernel_ulong_t)&fec_imx8mq_info,
+	},
+
+	{
 		/* sentinel */
 	}
 };
@@ -171,6 +184,7 @@ enum imx_fec_type {
 	MVF600_FEC,
 	IMX6SX_FEC,
 	IMX6UL_FEC,
+	IMX8MQ_FEC,
 };
 
 static const struct of_device_id fec_dt_ids[] = {
@@ -181,6 +195,8 @@ static const struct of_device_id fec_dt_ids[] = {
 	{ .compatible = "fsl,mvf600-fec", .data = &fec_devtype[MVF600_FEC], },
 	{ .compatible = "fsl,imx6sx-fec", .data = &fec_devtype[IMX6SX_FEC], },
 	{ .compatible = "fsl,imx6ul-fec", .data = &fec_devtype[IMX6UL_FEC], },
+	{ .compatible = "fsl,imx8mq-fec", .data = &fec_devtype[IMX8MQ_FEC], },
+
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, fec_dt_ids);
-- 
2.20.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option
       [not found]     ` <CABkfQAFcSNMeYEepsx0Z6tuaif-dQhE2YBMK54t1hikAvzdASg@mail.gmail.com>
@ 2020-11-29 23:04       ` Andrew Lunn
  2020-11-30 22:08         ` Florian Fainelli
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2020-11-29 23:04 UTC (permalink / raw)
  To: Adrien Grassein
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree, linux-kernel

On Sun, Nov 29, 2020 at 11:51:43PM +0100, Adrien Grassein wrote:
> Hi Andrew,
> 
> Please find my answers below.
> 
> Le dim. 29 nov. 2020 à 23:41, Andrew Lunn <andrew@lunn.ch> a écrit :
> 
>     On Sun, Nov 29, 2020 at 10:59:58PM +0100, Adrien Grassein wrote:
>     > Add dt-bindings explanation for the two new gpios
>     > (mdio and mdc) used for bitbanging.
> 
>     Hi Adrien
> 
>     What is missing is an explanation of why!
> 
> I'm sorry, it's my first upstreaming attempt.

Hi Adrien

Please take a look at

https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html

It is normal to have a patch 0/X which explains the big picture.

Then the commit message for each patch should explain why you are
doing something. That is much more important than what you are doing,
i can see that from the patch itself.

> I am currently upstreaming the "Nitrogen 8m Mini board" that seems to not use a
> "normal" mdio bus but a "bitbanged" one with the fsl fec driver.

Any idea why?

Anyway, you should not replicate code, don't copy bitbanging code into
the FEC. Just use the existing bit-banger MDIO bus master driver.

	   Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option
  2020-11-29 23:04       ` [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Andrew Lunn
@ 2020-11-30 22:08         ` Florian Fainelli
  2020-11-30 22:26           ` Andrew Lunn
  0 siblings, 1 reply; 10+ messages in thread
From: Florian Fainelli @ 2020-11-30 22:08 UTC (permalink / raw)
  To: Andrew Lunn, Adrien Grassein
  Cc: fugang.duan, davem, kuba, robh+dt, netdev, devicetree, linux-kernel



On 11/29/2020 3:04 PM, Andrew Lunn wrote:
> On Sun, Nov 29, 2020 at 11:51:43PM +0100, Adrien Grassein wrote:
>> Hi Andrew,
>>
>> Please find my answers below.
>>
>> Le dim. 29 nov. 2020 à 23:41, Andrew Lunn <andrew@lunn.ch> a écrit :
>>
>>     On Sun, Nov 29, 2020 at 10:59:58PM +0100, Adrien Grassein wrote:
>>     > Add dt-bindings explanation for the two new gpios
>>     > (mdio and mdc) used for bitbanging.
>>
>>     Hi Adrien
>>
>>     What is missing is an explanation of why!
>>
>> I'm sorry, it's my first upstreaming attempt.
> 
> Hi Adrien
> 
> Please take a look at
> 
> https://www.kernel.org/doc/html/latest/networking/netdev-FAQ.html
> 
> It is normal to have a patch 0/X which explains the big picture.
> 
> Then the commit message for each patch should explain why you are
> doing something. That is much more important than what you are doing,
> i can see that from the patch itself.
> 
>> I am currently upstreaming the "Nitrogen 8m Mini board" that seems to not use a
>> "normal" mdio bus but a "bitbanged" one with the fsl fec driver.
> 
> Any idea why?
> 
> Anyway, you should not replicate code, don't copy bitbanging code into
> the FEC. Just use the existing bit-banger MDIO bus master driver.

Right there should be no need for you to modify the FEC driver at all,
there is an existing generic bitbanged MDIO bus driver here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/mdio/mdio-gpio.c

with its binding here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/net/mdio-gpio.txt

so all you should need to do is make sure that you place a
"virtual,mdio-gpio" node, declare the PHY devices that are present on
that bus, and have your FEC nodes point to those PHY devices with an
appropriate 'phy-handle' property.
-- 
Florian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option
  2020-11-30 22:08         ` Florian Fainelli
@ 2020-11-30 22:26           ` Andrew Lunn
  2020-12-04 20:09             ` Adrien Grassein
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2020-11-30 22:26 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Adrien Grassein, fugang.duan, davem, kuba, robh+dt, netdev,
	devicetree, linux-kernel

> >> I am currently upstreaming the "Nitrogen 8m Mini board" that seems to not use a
> >> "normal" mdio bus but a "bitbanged" one with the fsl fec driver.
> > 
> > Any idea why?
> > 
> > Anyway, you should not replicate code, don't copy bitbanging code into
> > the FEC. Just use the existing bit-banger MDIO bus master driver.
> 
> Right there should be no need for you to modify the FEC driver at all,
> there is an existing generic bitbanged MDIO bus driver here:

Hi Florian

Speculation on my part, until i hear back on the Why? question, but
i'm guessing the board has a wrong pullup on the MDIO line. It takes
too long for the PHY/FEC to pull the line low at the default
2.5MHz. bit-banging is much slower, so it works.

If i'm right, there is a much simpler fix for this. Use the
clock-frequency property for the MDIO bus to slow the clock down.

	Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option
  2020-11-30 22:26           ` Andrew Lunn
@ 2020-12-04 20:09             ` Adrien Grassein
  0 siblings, 0 replies; 10+ messages in thread
From: Adrien Grassein @ 2020-12-04 20:09 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Florian Fainelli, fugang.duan, davem, kuba, Rob Herring, netdev,
	DTML, linux-kernel

Hi all,

I'm not a kernel expert, but I try to find why these patches were
needed in the FSL/Boundary kernel.

I found that the pin muxing in the original kernel was not good for FEC.
It's now working well with the mainline code.

You can delete these patches.

Thanks a lot,
Regards,

Adrien

Le lun. 30 nov. 2020 à 23:26, Andrew Lunn <andrew@lunn.ch> a écrit :
>
> > >> I am currently upstreaming the "Nitrogen 8m Mini board" that seems to not use a
> > >> "normal" mdio bus but a "bitbanged" one with the fsl fec driver.
> > >
> > > Any idea why?
> > >
> > > Anyway, you should not replicate code, don't copy bitbanging code into
> > > the FEC. Just use the existing bit-banger MDIO bus master driver.
> >
> > Right there should be no need for you to modify the FEC driver at all,
> > there is an existing generic bitbanged MDIO bus driver here:
>
> Hi Florian
>
> Speculation on my part, until i hear back on the Why? question, but
> i'm guessing the board has a wrong pullup on the MDIO line. It takes
> too long for the PHY/FEC to pull the line low at the default
> 2.5MHz. bit-banging is much slower, so it works.
>
> If i'm right, there is a much simpler fix for this. Use the
> clock-frequency property for the MDIO bus to slow the clock down.
>
>         Andrew

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-12-04 20:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-28 22:54 [PATCH 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
2020-11-28 22:54 ` [PATCH 2/3] net: fsl: fec: " Adrien Grassein
2020-11-28 22:54 ` [PATCH 3/3] net: fsl: fec: add imx8mq support Adrien Grassein
2020-11-29 21:59 ` [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Adrien Grassein
2020-11-29 21:59   ` [PATCH v2 2/3] net: fsl: fec: " Adrien Grassein
2020-11-29 22:00   ` [PATCH v2 3/3] net: fsl: fec: add imx8mq support Adrien Grassein
     [not found]   ` <20201129224113.GS2234159@lunn.ch>
     [not found]     ` <CABkfQAFcSNMeYEepsx0Z6tuaif-dQhE2YBMK54t1hikAvzdASg@mail.gmail.com>
2020-11-29 23:04       ` [PATCH v2 1/3] dt-bindings: net: fsl-fec add mdc/mdio bitbang option Andrew Lunn
2020-11-30 22:08         ` Florian Fainelli
2020-11-30 22:26           ` Andrew Lunn
2020-12-04 20:09             ` Adrien Grassein

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).