Skip to contentSkip to conversation

dt-bindings: net: fsl-fec add mdc/mdio bitbang option

PATCH Superseded Adrien Grassein 3 participants 10 messages Nov 28, 2020 – Dec 4, 2020 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 dt-bindings: net: fsl-fec add mdc/mdio bitbang option

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

---
 Documentation/devicetree/bindings/net/fsl-fec.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/fsl-fec.txt +4 -0
index 9b543789cd52..e9fa992354b7 100644
@@ -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.
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/3 net: fsl: fec: add mdc/mdio bitbang option

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.

---
 drivers/net/ethernet/freescale/fec.h      |  5 ++
 drivers/net/ethernet/freescale/fec_main.c | 91 ++++++++++++++++++++---
 2 files changed, 87 insertions(+), 9 deletions(-)
drivers/net/ethernet/freescale/fec.h +5 -0
index c527f4ee1d3a..84bf9be4c6f5 100644
@@ -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[];
 };
 
drivers/net/ethernet/freescale/fec_main.c +82 -9

118 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

PATCH 3/3 net: fsl: fec: add imx8mq support.

In reply to Adrien Grassein

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

---
 drivers/net/ethernet/freescale/fec_main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +16 -0
index e5c0a5da9965..92ad5b86d31c 100644
@@ -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);
Signature · 1 line
2.20.1
#3 lore raw

PATCH v2 1/3 dt-bindings: net: fsl-fec add mdc/mdio bitbang option

In reply to Adrien Grassein

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

---
 Documentation/devicetree/bindings/net/fsl-fec.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/fsl-fec.txt +4 -0
index 9b543789cd52..e9fa992354b7 100644
@@ -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.
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 2/3 net: fsl: fec: add mdc/mdio bitbang option

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.

---
 drivers/net/ethernet/freescale/fec.h      |   5 ++
 drivers/net/ethernet/freescale/fec_main.c | 101 +++++++++++++++++++---
 2 files changed, 95 insertions(+), 11 deletions(-)
drivers/net/ethernet/freescale/fec.h +5 -0
index c527f4ee1d3a..84bf9be4c6f5 100644
@@ -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[];
 };
 
drivers/net/ethernet/freescale/fec_main.c +90 -11

140 lines not on this page · raw message

Signature · 1 line
2.20.1
#5 lore raw

PATCH v2 3/3 net: fsl: fec: add imx8mq support.

In reply to Adrien Grassein

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

---
 drivers/net/ethernet/freescale/fec_main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/net/ethernet/freescale/fec_main.c +16 -0
index 4f22c8e3fe7e..a4bb1adbf9ed 100644
@@ -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);
Signature · 1 line
2.20.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CABkfQAFcSNMeYEepsx0Z6tuaif-dQhE2YBMK54t1hikAvzdASg@mail.gmail.com

#8 lore raw
Quoted 10 lines · Adrien Grassein

Hi Andrew,

Please find my answers below.

Le dim. 29 nov. 2020 à 23:41, Andrew Lunn <[email protected]> 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.

Quoted 5 lines

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.

Quoted 2 lines

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

#9 lore raw
Quoted 29 lines · Andrew Lunn
Quoted 10 lines · Adrien Grassein

Hi Andrew,

Please find my answers below.

Le dim. 29 nov. 2020 à 23:41, Andrew Lunn <[email protected]> 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.

Quoted 5 lines

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.

Quoted 7 lines
Quoted 2 lines

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.

Signature · 1 line
Florian
#10 lore raw
Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

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

#11 lore raw

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

Quoted 23 lines · Andrew Lunn
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

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