Re: [U-Boot] [PATCH v3 2/2] mdio: add marvell MDIO driver
On 13.06.2018 06:37, m...@marvell.com wrote: From: Ken Ma 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. Signed-off-by: Ken Ma Reviewed-by: Chris Packham --- 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 | 234 ++ 6 files changed, 265 insertions(+) create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt create mode 100644 drivers/net/mdio/mvmdio.c diff --git a/MAINTAINERS b/MAINTAINERS index 9e1fc83..d8584f9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index dde422b..e52b164 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -432,6 +432,7 @@ config ARCH_MVEBU select DM_SPI select DM_SPI_FLASH select SPI + select MDIO config TARGET_DEVKIT3250 bool "Support devkit3250" diff --git a/doc/device-tree-bindings/net/marvell-mdio.txt b/doc/device-tree-bindings/net/marvell-mdio.txt new file mode 100644 index 000..55db435 --- /dev/null +++ b/doc/device-tree-bindings/net/marvell-mdio.txt @@ -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". diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig index 533cc4a..d1a31e6 100644 --- a/drivers/net/mdio/Kconfig +++ b/drivers/net/mdio/Kconfig @@ -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 diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile index 45ae502..8b2e5a4 100644 --- a/drivers/net/mdio/Makefile +++ b/drivers/net/mdio/Makefile @@ -4,3 +4,4 @@ # Author: Ken Ma obj-$(CONFIG_MDIO) += mdio-uclass.o +obj-$(CONFIG_MVMDIO) += mvmdio.o diff --git a/drivers/net/mdio/mvmdio.c b/drivers/net/mdio/mvmdio.c new file mode 100644 index 000..0fb45ce --- /dev/null +++ b/drivers/net/mdio/mvmdio.c @@ -0,0 +1,234 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Marvell International Ltd. + * Author: Ken Ma + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MVMDIO_SMI_DATA_SHIFT 0 +#define MVMDIO_SMI_PHY_ADDR_SHIFT 16 +#define MVMDIO_SMI_PHY_REG_SHIFT 21 +#define MVMDIO_SMI_READ_OPERATION BIT(26) +#define MVMDIO_SMI_WRITE_OPERATION 0 +#define
[U-Boot] [PATCH v3 2/2] mdio: add marvell MDIO driver
From: Ken Ma 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. Signed-off-by: Ken Ma Reviewed-by: Chris Packham --- 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 | 234 ++ 6 files changed, 265 insertions(+) create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt create mode 100644 drivers/net/mdio/mvmdio.c diff --git a/MAINTAINERS b/MAINTAINERS index 9e1fc83..d8584f9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index dde422b..e52b164 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -432,6 +432,7 @@ config ARCH_MVEBU select DM_SPI select DM_SPI_FLASH select SPI + select MDIO config TARGET_DEVKIT3250 bool "Support devkit3250" diff --git a/doc/device-tree-bindings/net/marvell-mdio.txt b/doc/device-tree-bindings/net/marvell-mdio.txt new file mode 100644 index 000..55db435 --- /dev/null +++ b/doc/device-tree-bindings/net/marvell-mdio.txt @@ -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". diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig index 533cc4a..d1a31e6 100644 --- a/drivers/net/mdio/Kconfig +++ b/drivers/net/mdio/Kconfig @@ -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 diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile index 45ae502..8b2e5a4 100644 --- a/drivers/net/mdio/Makefile +++ b/drivers/net/mdio/Makefile @@ -4,3 +4,4 @@ # Author: Ken Ma obj-$(CONFIG_MDIO) += mdio-uclass.o +obj-$(CONFIG_MVMDIO) += mvmdio.o diff --git a/drivers/net/mdio/mvmdio.c b/drivers/net/mdio/mvmdio.c new file mode 100644 index 000..0fb45ce --- /dev/null +++ b/drivers/net/mdio/mvmdio.c @@ -0,0 +1,234 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Marvell International Ltd. + * Author: Ken Ma + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MVMDIO_SMI_DATA_SHIFT 0 +#define MVMDIO_SMI_PHY_ADDR_SHIFT 16 +#define MVMDIO_SMI_PHY_REG_SHIFT 21 +#define MVMDIO_SMI_READ_OPERATION BIT(26) +#define MVMDIO_SMI_WRITE_OPERATION 0 +#define MVMDIO_SMI_READ_VALID BIT(27) +#define MVMDIO_SMI_BUSYBIT(28) +
[U-Boot] [PATCH v3 2/2] mdio: add marvell MDIO driver
From: Ken Ma 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. Signed-off-by: Ken Ma Reviewed-by: Chris Packham --- 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 | 234 ++ 6 files changed, 265 insertions(+) create mode 100644 doc/device-tree-bindings/net/marvell-mdio.txt create mode 100644 drivers/net/mdio/mvmdio.c diff --git a/MAINTAINERS b/MAINTAINERS index 9e1fc83..d8584f9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index dde422b..e52b164 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -432,6 +432,7 @@ config ARCH_MVEBU select DM_SPI select DM_SPI_FLASH select SPI + select MDIO config TARGET_DEVKIT3250 bool "Support devkit3250" diff --git a/doc/device-tree-bindings/net/marvell-mdio.txt b/doc/device-tree-bindings/net/marvell-mdio.txt new file mode 100644 index 000..55db435 --- /dev/null +++ b/doc/device-tree-bindings/net/marvell-mdio.txt @@ -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". diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig index 533cc4a..d1a31e6 100644 --- a/drivers/net/mdio/Kconfig +++ b/drivers/net/mdio/Kconfig @@ -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 diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile index 45ae502..8b2e5a4 100644 --- a/drivers/net/mdio/Makefile +++ b/drivers/net/mdio/Makefile @@ -4,3 +4,4 @@ # Author: Ken Ma obj-$(CONFIG_MDIO) += mdio-uclass.o +obj-$(CONFIG_MVMDIO) += mvmdio.o diff --git a/drivers/net/mdio/mvmdio.c b/drivers/net/mdio/mvmdio.c new file mode 100644 index 000..0fb45ce --- /dev/null +++ b/drivers/net/mdio/mvmdio.c @@ -0,0 +1,234 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Marvell International Ltd. + * Author: Ken Ma + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MVMDIO_SMI_DATA_SHIFT 0 +#define MVMDIO_SMI_PHY_ADDR_SHIFT 16 +#define MVMDIO_SMI_PHY_REG_SHIFT 21 +#define MVMDIO_SMI_READ_OPERATION BIT(26) +#define MVMDIO_SMI_WRITE_OPERATION 0 +#define MVMDIO_SMI_READ_VALID BIT(27) +#define MVMDIO_SMI_BUSYBIT(28) +