Add MDIO driver model support
Subsystems (4)
v4 cover Add MDIO driver model support
From: Ken Ma <[email protected]>
Changes in v4:
- Minor updates for comments and Maintainer.
- Use wait_for_bit_le32() instead of implementing private busy wait polling function.
Changes in v3:
- Move mdio uclass implementation to driver/net folder;
- Replace flat-tree functions with livetree functions and update codes and comments to be consistent with driver-model codes style;
- Put struct mii_dev to uclass platdata to avoid the mdio alloc and let driver model framework to alloc the memroy automatically, meanwhile the mii bus link initialization is added.
- Move marvell mdio driver to driver/net/mdio folder;
- Update codes according to mdio uclass implementation updates.
Changes in v2:
- Fix error printing:
- Change some debug to pr_err;
- mii bus has no parent member and it is not a udevice, so dev_err is changed to pr_err for mii bus error printings.
- Fix error printing:
- Change some debug to pr_err;
- mii bus has no parent member and it is not a udevice, so dev_err is changed to pr_err for mii bus error printings.
Ken Ma (2):
dm: mdio: add a uclass for MDIO
mdio: add marvell MDIO driver
MAINTAINERS | 2 + arch/arm/Kconfig | 1 + doc/device-tree-bindings/net/marvell-mdio.txt | 18 +++ doc/device-tree-bindings/net/mdio-bus.txt | 54 +++++++ drivers/Kconfig | 2 + drivers/net/Makefile | 1 + drivers/net/mdio/Kconfig | 28 ++++ drivers/net/mdio/Makefile | 7 + drivers/net/mdio/mdio-uclass.c | 112 +++++++++++++++ drivers/net/mdio/mvmdio.c | 200 ++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/net/mdio.h | 62 ++++++++ 12 files changed, 488 insertions(+) create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt create mode 100644 doc/device-tree-bindings/net/mdio-bus.txt create mode 100644 drivers/net/mdio/Kconfig create mode 100644 drivers/net/mdio/Makefile create mode 100644 drivers/net/mdio/mdio-uclass.c create mode 100644 drivers/net/mdio/mvmdio.c create mode 100644 include/net/mdio.h
Signature · 1 line
1.9.1
PATCH v4 1/2 dm: mdio: add a uclass for MDIO
From: Ken Ma <[email protected]>
Add a uclass which provides access to MDIO busses and includes operations required by MDIO.
The implementation is based on the existing mii/phy/mdio data structures and APIs.
This patch also adds device tree binding for MDIO bus.
---
Changes in v4:
- Minor updates for comments and Maintainer.
Changes in v3:
- Move mdio uclass implementation to driver/net folder;
- Replace flat-tree functions with livetree functions and update codes and comments to be consistent with driver-model codes style;
- Put struct mii_dev to uclass platdata to avoid the mdio alloc and let driver model framework to alloc the memroy automatically, meanwhile the mii bus link initialization is added.
Changes in v2:
- Fix error printing:
- Change some debug to pr_err;
- mii bus has no parent member and it is not a udevice, so dev_err is changed to pr_err for mii bus error printings.
MAINTAINERS | 1 + doc/device-tree-bindings/net/mdio-bus.txt | 54 ++++++++++++++ drivers/Kconfig | 2 + drivers/net/Makefile | 1 + drivers/net/mdio/Kconfig | 18 +++++ drivers/net/mdio/Makefile | 6 ++ drivers/net/mdio/mdio-uclass.c | 112 ++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/net/mdio.h | 62 +++++++++++++++++ 9 files changed, 257 insertions(+) create mode 100644 doc/device-tree-bindings/net/mdio-bus.txt create mode 100644 drivers/net/mdio/Kconfig create mode 100644 drivers/net/mdio/Makefile create mode 100644 drivers/net/mdio/mdio-uclass.c create mode 100644 include/net/mdio.h
MAINTAINERS +1 -0
@@ -432,6 +432,7 @@ M: Joe Hershberger <[email protected]> S: Maintained T: git git://git.denx.de/u-boot-net.git F: drivers/net/ +F: drivers/net/mdio/ F: net/ NIOS
doc/device-tree-bindings/net/mdio-bus.txt new file +54 -0
54 lines not on this page · raw message
drivers/Kconfig +2 -0
@@ -54,6 +54,8 @@ source "drivers/mtd/Kconfig" source "drivers/net/Kconfig" +source "drivers/net/mdio/Kconfig" + source "drivers/nvme/Kconfig" source "drivers/pci/Kconfig"
drivers/net/Makefile +1 -0
@@ -70,3 +70,4 @@ obj-$(CONFIG_VSC9953) += vsc9953.o obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o obj-$(CONFIG_FSL_PFE) += pfe_eth/ +obj-$(CONFIG_MDIO) += mdio/
drivers/net/mdio/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# +# MDIO infrastructure and drivers +# + +menu "MDIO Support" + +config MDIO + bool "Enable MDIO (Management Data Input/Output) drivers" + depends on DM + help + Enable driver model for MDIO access. + Drivers provide methods to management data + Input/Output. + MDIO uclass provides interfaces to get mdio + udevice or mii bus from its child phy node or + an ethernet udevice which the phy belongs to. + +endmenu
drivers/net/mdio/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018 Marvell International Ltd. +# Author: Ken Ma<[email protected]> + +obj-$(CONFIG_MDIO) += mdio-uclass.o
drivers/net/mdio/mdio-uclass.c new file +112 -0
112 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -49,6 +49,7 @@ enum uclass_id {UCLASS_LPC ,/* x86 'low pin count' interface */ UCLASS_MAILBOX ,/* Mailbox controller */ UCLASS_MASS_STORAGE ,/* Mass storage device */ +UCLASS_MDIO ,/* Management Data Input/Output (MDIO) device */ UCLASS_MISC ,/* Miscellaneous device */ UCLASS_MMC ,/* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */
include/net/mdio.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 1/2 dm: mdio: add a uclass for MDIO
Quoted 39 lines · make at marvell.com
From: Ken Ma <[email protected]>
Add a uclass which provides access to MDIO busses and includes operations required by MDIO.
The implementation is based on the existing mii/phy/mdio data structures and APIs.
This patch also adds device tree binding for MDIO bus.Signed-off-by Ken Ma <[email protected]>Reviewed-by sjg at chromium.org, joe.hershberger at ni.com---
Changes in v4:
- Minor updates for comments and Maintainer.Changes in v3:
- Move mdio uclass implementation to driver/net folder;
- Replace flat-tree functions with livetree functions and update codes and comments to be consistent with driver-model codes style;
- Put structmii_devto uclass platdata to avoid the mdio alloc and let driver model framework to alloc the memroy automatically, meanwhile the mii bus link initialization is added.Changes in v2:
- Fix error printing:
- Change some debug topr_err;
- mii bus has no parent member and it is not a udevice, sodev_erris changed topr_errfor mii bus error printings.MAINTAINERS | 1 + doc/device-tree-bindings/net/mdio-bus.txt | 54 ++++++++++++++ drivers/Kconfig | 2 + drivers/net/Makefile | 1 + drivers/net/mdio/Kconfig | 18 +++++ drivers/net/mdio/Makefile | 6 ++ drivers/net/mdio/mdio-uclass.c | 112 ++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/net/mdio.h | 62 +++++++++++++++++ 9 files changed, 257 insertions(+)
Quoted 5 lines
create mode 100644
doc/device-tree-bindings/net/mdio-bus.txtcreate mode 100644drivers/net/mdio/Kconfig
create mode 100644drivers/net/mdio/Makefilecreate mode 100644drivers/net/mdio/mdio-uclass.ccreate mode 100644include/net/mdio.h
Thanks,
Stefan
PATCH v4 1/2 dm: mdio: add a uclass for MDIO
In reply to make at marvell.comQuoted 107 lines · make at marvell.com
From: Ken Ma <[email protected]>
Add a uclass which provides access to MDIO busses and includes operations required by MDIO.
The implementation is based on the existing mii/phy/mdio data structures and APIs.
This patch also adds device tree binding for MDIO bus.Signed-off-by Ken Ma <[email protected]>Reviewed-by sjg at chromium.org, joe.hershberger at ni.com---
Changes in v4:
- Minor updates for comments and Maintainer.Changes in v3:
- Move mdio uclass implementation to driver/net folder;
- Replace flat-tree functions with livetree functions and update codes and comments to be consistent with driver-model codes style;
- Put structmii_devto uclass platdata to avoid the mdio alloc and let driver model framework to alloc the memroy automatically, meanwhile the mii bus link initialization is added.Changes in v2:
- Fix error printing:
- Change some debug topr_err;
- mii bus has no parent member and it is not a udevice, sodev_erris changed topr_errfor mii bus error printings.MAINTAINERS | 1 + doc/device-tree-bindings/net/mdio-bus.txt | 54 ++++++++++++++ drivers/Kconfig | 2 + drivers/net/Makefile | 1 + drivers/net/mdio/Kconfig | 18 +++++ drivers/net/mdio/Makefile | 6 ++ drivers/net/mdio/mdio-uclass.c | 112 ++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/net/mdio.h | 62 +++++++++++++++++ 9 files changed, 257 insertions(+) create mode 100644 doc/device-tree-bindings/net/mdio-bus.txt create mode 100644 drivers/net/mdio/Kconfig create mode 100644 drivers/net/mdio/Makefile create mode 100644 drivers/net/mdio/mdio-uclass.c create mode 100644 include/net/mdio.hMAINTAINERS +1
-0@@ -432,6 +432,7 @@ M: Joe Hershberger <[email protected]> S: Maintained T: git git://git.denx.de/u-boot-net.git F: drivers/net/ +F: drivers/net/mdio/ F: net/ NIOSdoc/device-tree-bindings/net/mdio-bus.txt new file +44
-0@@ -0,0 +1,54 @@ +MDIO (Management Data Input/Output) busses + +MDIO busses can be described with a node for the MDIO master device +and a set of child nodes for each phy on the bus. + +The MDIO node requires the following properties: +- #address-cells - number of cells required to define phy address on + the MDIO bus. +- #size-cells - should be zero. +- compatible - name of MDIO bus controller following generic names + recommended practice. +- reg - address and length of the MDIO register. + +Optional property: +- mdio-name - MDIO bus name + +The child nodes of the MDIO driver are the individual PHY devices +connected to this MDIO bus. They must have a "reg" property given the +PHY address on the MDIO bus. +- reg - (required) phy address in MDIO bus. + +Example for cp110 MDIO node at the SoC level: + cp0_mdio: mdio at 12a200 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "marvell,orion-mdio"; + reg = <0x12a200 0x10>; + mdio-name = "cp0-mdio"; + }; + + cp0_xmdio: mdio at 12a600 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "marvell,xmdio"; + reg = <0x12a600 0x200>; + mdio-name = "cp0-xmdio"; + }; + +And at the board level, example for armada-8040-mcbin board: + &cp0_mdio { + ge_phy: ethernet-phy at 0 { + reg = <0>; + }; + };
doc/device-tree-bindings/net/mdio-bus.txt line 54
Quoted 10 lines
doc/device-tree-bindings/net/mdio-bus.txt new file +10
-0+ + &cp0_xmdio { + phy0: ethernet-phy at 0 { + reg = <0>; + }; + + phy8: ethernet-phy at 8 { + reg = <8>; + }; + };
this binding should be in separate patch and it is not align with what it is in the kernel. mdio-name is not there. You should send a patch to kernel.
Thanks,
Michal
PATCH v4 1/2 dm: mdio: add a uclass for MDIO
In reply to make at marvell.comQuoted 122 lines · On Thu, Jul 5, 2018 at 2:34 AM, <[email protected]> wrote:
From: Ken Ma <[email protected]>
Add a uclass which provides access to MDIO busses and includes operations required by MDIO.
The implementation is based on the existing mii/phy/mdio data structures and APIs.
This patch also adds device tree binding for MDIO bus.Signed-off-by Ken Ma <[email protected]>Reviewed-by sjg at chromium.org, joe.hershberger at ni.com---
Changes in v4:
- Minor updates for comments and Maintainer.Changes in v3:
- Move mdio uclass implementation to driver/net folder;
- Replace flat-tree functions with livetree functions and update codes and comments to be consistent with driver-model codes style;
- Put structmii_devto uclass platdata to avoid the mdio alloc and let driver model framework to alloc the memroy automatically, meanwhile the mii bus link initialization is added.Changes in v2:
- Fix error printing:
- Change some debug topr_err;
- mii bus has no parent member and it is not a udevice, sodev_erris changed topr_errfor mii bus error printings.MAINTAINERS | 1 + doc/device-tree-bindings/net/mdio-bus.txt | 54 ++++++++++++++ drivers/Kconfig | 2 + drivers/net/Makefile | 1 + drivers/net/mdio/Kconfig | 18 +++++ drivers/net/mdio/Makefile | 6 ++ drivers/net/mdio/mdio-uclass.c | 112 ++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/net/mdio.h | 62 +++++++++++++++++ 9 files changed, 257 insertions(+) create mode 100644 doc/device-tree-bindings/net/mdio-bus.txt create mode 100644 drivers/net/mdio/Kconfig create mode 100644 drivers/net/mdio/Makefile create mode 100644 drivers/net/mdio/mdio-uclass.c create mode 100644 include/net/mdio.hMAINTAINERS +1
-0@@ -432,6 +432,7 @@ M: Joe Hershberger <[email protected]> S: Maintained T: git git://git.denx.de/u-boot-net.git F: drivers/net/ +F: drivers/net/mdio/ F: net/ NIOSdoc/device-tree-bindings/net/mdio-bus.txt new file +54
-0@@ -0,0 +1,54 @@ +MDIO (Management Data Input/Output) busses + +MDIO busses can be described with a node for the MDIO master device +and a set of child nodes for each phy on the bus. + +The MDIO node requires the following properties: +- #address-cells - number of cells required to define phy address on + the MDIO bus. +- #size-cells - should be zero. +- compatible - name of MDIO bus controller following generic names + recommended practice. +- reg - address and length of the MDIO register. + +Optional property: +- mdio-name - MDIO bus name + +The child nodes of the MDIO driver are the individual PHY devices +connected to this MDIO bus. They must have a "reg" property given the +PHY address on the MDIO bus. +- reg - (required) phy address in MDIO bus. + +Example for cp110 MDIO node at the SoC level: + cp0_mdio: mdio at 12a200 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "marvell,orion-mdio"; + reg = <0x12a200 0x10>; + mdio-name = "cp0-mdio"; + }; + + cp0_xmdio: mdio at 12a600 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "marvell,xmdio"; + reg = <0x12a600 0x200>; + mdio-name = "cp0-xmdio"; + }; + +And at the board level, example for armada-8040-mcbin board: + &cp0_mdio { + ge_phy: ethernet-phy at 0 { + reg = <0>; + }; + }; + + &cp0_xmdio { + phy0: ethernet-phy at 0 { + reg = <0>; + }; + + phy8: ethernet-phy at 8 { + reg = <8>; + }; + };drivers/Kconfig +0
-0
drivers/Kconfig source "drivers/mtd/Kconfig" · line 57
Quoted 4 lines
drivers/Kconfig +1
-0@@ -54,6 +54,8 @@ source "drivers/mtd/Kconfig" source "drivers/net/Kconfig" +source "drivers/net/mdio/Kconfig"
Please put 'source "drivers/net/mdio/Kconfig"' in drivers/net/Kconfig.
Quoted 18 lines
drivers/Kconfig +0
-0source "drivers/nvme/Kconfig" source "drivers/pci/Kconfig"drivers/net/Makefile +1
-0@@ -70,3 +70,4 @@ obj-$(CONFIG_VSC9953) += vsc9953.o obj-$(CONFIG_PIC32_ETH) += pic32_mdio.o pic32_eth.o obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o obj-$(CONFIG_FSL_PFE) += pfe_eth/ +obj-$(CONFIG_MDIO) += mdio/drivers/net/mdio/Kconfig new file +0
-0
drivers/net/mdio/Kconfig line 8
Quoted 8 lines
drivers/net/mdio/Kconfig new file +8
-0@@ -0,0 +1,18 @@ +# +# MDIO infrastructure and drivers +# + +menu "MDIO Support" + +config MDIO + bool "Enable MDIO (Management Data Input/Output) drivers"
I think it would be smart to mention driver model for now, since many other drivers have MDIO support enabled without this. We can later remove that from the text.
Quoted 28 lines
drivers/net/mdio/Kconfig new file +10
-0+ depends on DM + help + Enable driver model for MDIO access. + Drivers provide methods to management data + Input/Output. + MDIO uclass provides interfaces to get mdio + udevice or mii bus from its child phy node or + an ethernet udevice which the phy belongs to. + +endmenudrivers/net/mdio/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018 Marvell International Ltd. +# Author: Ken Ma<[email protected]> + +obj-$(CONFIG_MDIO) += mdio-uclass.odrivers/net/mdio/mdio-uclass.c new file +0
-0
drivers/net/mdio/mdio-uclass.c line 8
Quoted 8 lines
drivers/net/mdio/mdio-uclass.c new file +8
-0@@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2018 Marvell International Ltd. +* Author: Ken Ma<[email protected]> +*/ + +#include <common.h> +#include <fdtdec.h>
You shouldn't need this.
Quoted 74 lines
drivers/net/mdio/mdio-uclass.c new file +74
-0+#include <errno.h> +#include <dm.h> +#include <dm/uclass.h> +#include <dm/uclass-internal.h> +#include <miiphy.h> +#include <net/mdio.h> + +DECLARE_GLOBAL_DATA_PTR ; + +int mdio_mii_bus_get (struct udevice *mdio_dev,struct mii_dev **busp) +{ + *busp = (struct mii_dev *)dev_get_uclass_platdata (mdio_dev); + +return 0 ; +} + +int mdio_device_get_from_phy (ofnode phy_node,struct udevice **devp) +{ +ofnode mdio_node; + + mdio_node =ofnode_get_parent (phy_node); +return uclass_get_device_by_ofnode (UCLASS_MDIO , mdio_node, devp); +} + +int mdio_mii_bus_get_from_phy (ofnode phy_node,struct mii_dev **busp) +{ +struct udevice *mdio_dev; +int ret; + + ret =mdio_device_get_from_phy (phy_node, &mdio_dev); +if (ret) +return ret; + + *busp = (struct mii_dev *)dev_get_uclass_platdata (mdio_dev); + +return 0 ; +} + +int mdio_device_get_from_eth (struct udevice *eth,struct udevice **devp) +{ +struct ofnode_phandle_args phy_args; +int ret; + + ret =dev_read_phandle_with_args (eth,"phy" ,NULL ,0 ,0 , &phy_args); +if (!ret) +return mdio_device_get_from_phy (phy_args.node, devp); + +/* +* If there is no phy reference under the ethernet fdt node, +* it is not an error since the ethernet device may do not use +* mode; so in this case, the output mdio device pointer is set +* as NULL. +*/ + *devp =NULL ; +return 0 ; +} + +int mdio_mii_bus_get_from_eth (struct udevice *eth,struct mii_dev **busp) +{ +struct udevice *mdio_dev; +int ret; + + ret =mdio_device_get_from_eth (eth, &mdio_dev); +if (ret) +return ret; + +if (mdio_dev) + *busp = (struct mii_dev *)dev_get_uclass_platdata (mdio_dev); +else + *busp =NULL ; + +return 0 ; +} +
drivers/net/mdio/mdio-uclass.c line 92
Quoted 10 lines
drivers/net/mdio/mdio-uclass.c new file +10
-0+static int mdio_uclass_pre_probe (struct udevice *dev) +{ +struct mii_dev *bus = (struct mii_dev *)dev_get_uclass_platdata (dev); +const char *name; + +/* initialize mii_dev struct fields, implement mdio_alloc() setup */ +INIT_LIST_HEAD (&bus->link); + + name =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), +"mdio-name" ,NULL );
Please use dev_read_string() here.
Quoted 20 lines
drivers/net/mdio/mdio-uclass.c new file +20
-0+if (name) +strncpy (bus->name, name,MDIO_NAME_LEN ); + +return 0 ; +} + +static int mdio_uclass_post_probe (struct udevice *dev) +{ +struct mii_dev *bus = (struct mii_dev *)dev_get_uclass_platdata (dev); + +return mdio_register (bus); +} + +UCLASS_DRIVER (mdio) = { + .id =UCLASS_MDIO , + .name ="mdio" , + .pre_probe = mdio_uclass_pre_probe, + .post_probe = mdio_uclass_post_probe, + .per_device_platdata_auto_alloc_size =sizeof (struct mii_dev ), +};
<snip>
PATCH v4 1/2 dm: mdio: add a uclass for MDIO
Hello,
Quoted 30 lines · Joe Hershberger
Quoted 29 lines · On Thu, Jul 5, 2018 at 2:34 AM, <[email protected]> wrote:
From: Ken Ma <[email protected]>
Add a uclass which provides access to MDIO busses and includes operations required by MDIO.
The implementation is based on the existing mii/phy/mdio data structures and APIs.
This patch also adds device tree binding for MDIO bus.Signed-off-by Ken Ma <[email protected]>Reviewed-by sjg at chromium.org, joe.hershberger at ni.com---
Changes in v4:
- Minor updates for comments and Maintainer.Changes in v3:
- Move mdio uclass implementation to driver/net folder;
- Replace flat-tree functions with livetree functions and update codes and comments to be consistent with driver-model codes style;
- Put structmii_devto uclass platdata to avoid the mdio alloc and let driver model framework to alloc the memroy automatically, meanwhile the mii bus link initialization is added.Changes in v2:
- Fix error printing:
- Change some debug topr_err;
- mii bus has no parent member and it is not a udevice, sodev_erris changed topr_errfor mii bus error printings.
Quoted 16 lines
Quoted 7 lines
MAINTAINERS | 1 + doc/device-tree-bindings/net/mdio-bus.txt | 54 ++++++++++++++ drivers/Kconfig | 2 + drivers/net/Makefile | 1 + drivers/net/mdio/Kconfig | 18 +++++ drivers/net/mdio/Makefile | 6 ++ drivers/net/mdio/mdio-uclass.c | 112 ++++++++++++++++++++++++++++++Quoted 9 lines
include/dm/uclass-id.h | 1 + include/net/mdio.h | 62 +++++++++++++++++ 9 files changed, 257 insertions(+) create mode 100644 doc/device-tree-bindings/net/mdio-bus.txt create mode 100644 drivers/net/mdio/Kconfig create mode 100644 drivers/net/mdio/Makefile create mode 100644 drivers/net/mdio/mdio-uclass.c create mode 100644 include/net/mdio.h
It looks this only supports mdio device via device tree. How about PCI NICs?
Regards,
Bin
PATCH v4 2/2 mdio: add marvell MDIO driver
In reply to make at marvell.comFrom: Ken Ma <[email protected]>
This patch adds a separate driver for the MDIO interface of the Marvell Ethernet controllers based on driver model. There are two reasons to have a separate driver rather than including it inside the MAC driver itself:
*) The MDIO interface is shared by all Ethernet ports, so a driver
must guarantee non-concurrent accesses to this MDIO interface. The most logical way is to have a separate driver that handles this single MDIO interface, used by all Ethernet ports.
*) The MDIO interface is the same between the existing mv643xx_eth
driver and the new mvneta/mvpp2 driver. Even though it is for now only used by the mvneta/mvpp2 driver, it will in the future be used by the mv643xx_eth driver as well.
This driver supports SMI IEEE for 802.3 Clause 22 and XSMI for IEEE 802.3 Clause 45.
This patch also adds device tree binding for marvell MDIO driver.
---
Changes in v4:
- Use wait_for_bit_le32() instead of implementing private busy wait polling function.
Changes in v3:
- Move marvell mdio driver to driver/net/mdio folder;
- Update codes according to mdio uclass implementation updates.
Changes in v2:
- Fix error printing:
- Change some debug to pr_err;
- mii bus has no parent member and it is not a udevice, so dev_err is changed to pr_err for mii bus error printings.
MAINTAINERS | 1 + arch/arm/Kconfig | 1 + doc/device-tree-bindings/net/marvell-mdio.txt | 18 +++ drivers/net/mdio/Kconfig | 10 ++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mvmdio.c | 200 ++++++++++++++++++++++++++ 6 files changed, 231 insertions(+) create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt create mode 100644 drivers/net/mdio/mvmdio.c
MAINTAINERS +1 -0
@@ -137,6 +137,7 @@ T: git git://git.denx.de/u-boot-marvell.git F: arch/arm/mach-kirkwood/ F: arch/arm/mach-mvebu/ F: drivers/ata/ahci_mvebu.c +F: drivers/net/mdio/mvmdio.c ARM MARVELL PXA M: Marek Vasut <[email protected]>
arch/arm/Kconfig +1 -0
@@ -432,6 +432,7 @@ config ARCH_MVEBU select DM_SPI select DM_SPI_FLASH select SPI + select MDIO config TARGET_DEVKIT3250 bool "Support devkit3250"
doc/device-tree-bindings/net/marvell-mdio.txt new file +18 -0
@@ -0,0 +1,18 @@ +* Marvell MDIO Ethernet Controller interface + +The Ethernet controllers of the Marvel Armada 3700 and Armada 7k/8k +have an identical unit that provides an interface with the MDIO bus. +This driver handles this MDIO interface. + +Mandatory properties: +SoC specific: + - #address-cells: Must be <1>. + - #size-cells: Must be <0>. + - compatible: Should be "marvell,orion-mdio" (for SMI) + "marvell,xmdio" (for XSMI) + - reg: Base address and size SMI/XMSI bus. + +Optional properties: + - mdio-name - MDIO bus name + +For example, please refer to "mdio-bus.txt".
drivers/net/mdio/Kconfig +10 -0
@@ -15,4 +15,14 @@ config MDIO udevice or mii bus from its child phy node or an ethernet udevice which the phy belongs to. +config MVMDIO + bool "Marvell MDIO interface support" + depends on MDIO + select PHYLIB + help + This driver supports the MDIO interface found in the network + interface units of the Marvell EBU SoCs (Kirkwood, Orion5x, + Dove, Armada 370, Armada XP, Armada 37xx and Armada7K/8K/8KP). + + This driver is used by the MVPP2 and MVNETA drivers. endmenu
drivers/net/mdio/Makefile +1 -0
@@ -4,3 +4,4 @@ # Author: Ken Ma<[email protected]> obj-$(CONFIG_MDIO) += mdio-uclass.o +obj-$(CONFIG_MVMDIO) += mvmdio.o
drivers/net/mdio/mvmdio.c new file +200 -0
200 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v4 2/2 mdio: add marvell MDIO driver
Quoted 45 lines · make at marvell.com
From: Ken Ma <[email protected]>
This patch adds a separate driver for the MDIO interface of the Marvell Ethernet controllers based on driver model. There are two reasons to have a separate driver rather than including it inside the MAC driver itself:
*) The MDIO interface is shared by all Ethernet ports, so a driver
must guarantee non-concurrent accesses to this MDIO interface. The most logical way is to have a separate driver that handles this single MDIO interface, used by all Ethernet ports.
*) The MDIO interface is the same between the existingmv643xx_eth
driver and the new mvneta/mvpp2 driver. Even though it is for now only used by the mvneta/mvpp2 driver, it will in the future be used by themv643xx_ethdriver as well.This driver supports SMI IEEE for 802.3 Clause 22 and XSMI for IEEE 802.3 Clause 45.
This patch also adds device tree binding for marvell MDIO driver.
Signed-off-by Ken Ma <[email protected]>Reviewed-by Chris Packham <[email protected]>---
Changes in v4:
- Usewait_for_bit_le32()instead of implementing private busy wait polling function.Changes in v3:
- Move marvell mdio driver to driver/net/mdio folder;
- Update codes according to mdio uclass implementation updates.Changes in v2:
- Fix error printing:
- Change some debug topr_err;
- mii bus has no parent member and it is not a udevice, sodev_erris changed topr_errfor mii bus error printings.MAINTAINERS | 1 + arch/arm/Kconfig | 1 + doc/device-tree-bindings/net/marvell-mdio.txt | 18 +++ drivers/net/mdio/Kconfig | 10 ++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mvmdio.c | 200 ++++++++++++++++++++++++++ 6 files changed, 231 insertions(+)
Quoted 2 lines
create mode 100644
doc/device-tree-bindings/net/marvell-mdio.txtcreate mode 100644drivers/net/mdio/mvmdio.c
Thanks,
Stefan
PATCH v4 2/2 mdio: add marvell MDIO driver
In reply to make at marvell.comQuoted 15 lines · On Thu, Jul 5, 2018 at 2:34 AM, <[email protected]> wrote:
From: Ken Ma <[email protected]>
This patch adds a separate driver for the MDIO interface of the Marvell Ethernet controllers based on driver model. There are two reasons to have a separate driver rather than including it inside the MAC driver itself:
*) The MDIO interface is shared by all Ethernet ports, so a driver
must guarantee non-concurrent accesses to this MDIO interface. The most logical way is to have a separate driver that handles this single MDIO interface, used by all Ethernet ports.
*) The MDIO interface is the same between the existingmv643xx_eth
driver and the new mvneta/mvpp2 driver. Even though it is for now only used by the mvneta/mvpp2 driver, it will in the future be used by themv643xx_ethdriver as well.
Quoted 7 lines
This driver supports SMI IEEE for 802.3 Clause 22 and XSMI for IEEE 802.3 Clause 45.
This patch also adds device tree binding for marvell MDIO driver.
Signed-off-by Ken Ma <[email protected]>Reviewed-by Chris Packham <[email protected]>