net: dwc_eth_qos: Add glue driver for Intel MAC
Subsystems (5)
v4 cover net: dwc_eth_qos: Add glue driver for Intel MAC
This patch series implements the dwc_eth_qos glue driver for Intel SOCs. Before doing that, a few general adaptions to the dwc_eth_qos.c main driver are required. Most notably, the preparation for PCI based driver instances, which do not necessarily use a device tree.
Changes in V4:
- Fix printf format string
Changes in V3:
- Replace mfence() with mb()
- Clean-up eqos_get_base_addr()
- Several style fixes for dwc_eth_qos_intel
Philip Oberfichtner (5):
x86: provide mb() macro
net: dwc_eth_qos: Fix header to be self-contained
net: dwc_eth_qos: Adapt probe() for PCI devices
net: dwc_eth_qos: Implement bind() for PCI devices
net: dwc_eth_qos: Add glue driver for Intel MAC
arch/x86/cpu/mp_init.c | 10 +- arch/x86/include/asm/cpu.h | 5 - arch/x86/include/asm/io.h | 1 + drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/dwc_eth_qos.c | 83 +++++- drivers/net/dwc_eth_qos.h | 8 +- drivers/net/dwc_eth_qos_imx.c | 6 + drivers/net/dwc_eth_qos_intel.c | 449 +++++++++++++++++++++++++++++ drivers/net/dwc_eth_qos_intel.h | 57 ++++ drivers/net/dwc_eth_qos_qcom.c | 6 + drivers/net/dwc_eth_qos_rockchip.c | 6 + drivers/net/dwc_eth_qos_starfive.c | 6 + drivers/net/dwc_eth_qos_stm32.c | 6 + include/pci_ids.h | 9 + 15 files changed, 641 insertions(+), 19 deletions(-) create mode 100644 drivers/net/dwc_eth_qos_intel.c create mode 100644 drivers/net/dwc_eth_qos_intel.h
Signature · 1 line
2.39.2
PATCH v4 1/5 x86: provide mb() macro
Implement a x86 memory barrier mb(). Furthermore, remove the previously used mfence() function, which does the same thing.
The mb() macro is now equivalent to Linux (v6.9):linux/arch/x86/include/asm/barrier.h
---
Notes:
Changes in V4: None
Changes in V3:
- Remove mfence() function
arch/x86/cpu/mp_init.c | 10 +++++----- arch/x86/include/asm/cpu.h | 5 ----- arch/x86/include/asm/io.h | 1 + 3 files changed, 6 insertions(+), 10 deletions(-)
arch/x86/cpu/mp_init.c +5 -5
@@ -164,12 +164,12 @@ static inline void barrier_wait(atomic_t *b) {while (atomic_read (b) ==0 ) asm("pause" ); -mfence (); +mb (); }static inline void release_barrier (atomic_t *b) { -mfence (); +mb ();atomic_set (b,1 ); }
@@ -631,7 +631,7 @@ static int run_ap_work(struct mp_callback *callback, struct udevice *bsp,if (cur_cpu != i)store_callback (&ap_callbacks[i], callback); } -mfence (); +mb ();/* Wait for all the APs to signal back that call has been accepted. */ start =get_timer (0 );
@@ -656,7 +656,7 @@ static int run_ap_work(struct mp_callback *callback, struct udevice *bsp, }while (cpus_accepted != num_aps);/* Make sure we can see any data written by the APs */ -mfence (); +mb ();return 0 ; }
@@ -692,7 +692,7 @@ static int ap_wait_for_instruction(struct udevice *cpu, void *unused)/* Copy to local variable before using the value */ memcpy (&lcb, cb,sizeof (lcb)); -mfence (); +mb ();if (lcb.logical_cpu_number ==MP_SELECT_ALL || lcb.logical_cpu_number ==MP_SELECT_APS ||dev_seq (cpu) == lcb.logical_cpu_number)
arch/x86/include/asm/cpu.h +0 -5
@@ -185,11 +185,6 @@ static inline int flag_is_changeable_p(uint32_t flag) }#endif -static inline void mfence (void ) -{ - __asm__ __volatile__("mfence" : : :"memory" ); -} -/** * cpu_enable_paging_pae() - Enable PAE-paging *
arch/x86/include/asm/io.h +1 -0
@@ -240,6 +240,7 @@ static inline void sync(void)* have some advantages to use them instead of the simple one here. */ #define dmb () __asm__ __volatile__ ("" : : : "memory") +#define mb () __asm__ __volatile__ ("mfence" : : : "memory")#define __iormb () dmb()#define __iowmb () dmb()
Signature · 1 line
2.39.2
Re: [PATCH v4 1/5] x86: provide mb() macro
Quoted 13 lines · Philip Oberfichtner
Implement a x86 memory barrier
mb(). Furthermore, remove the previously usedmfence()function, which does the same thing.The
mb()macro is now equivalent to Linux (v6.9):linux/arch/x86/include/asm/barrier.hSigned-off-by Philip Oberfichtner <[email protected]>---
Notes:
Changes in V4: None
Quoted 7 lines
Changes in V3:
- Removemfence()functionarch/x86/cpu/mp_init.c | 10 +++++----- arch/x86/include/asm/cpu.h | 5 ----- arch/x86/include/asm/io.h | 1 + 3 files changed, 6 insertions(+), 10 deletions(-)
PATCH v4 2/5 net: dwc_eth_qos: Fix header to be self-contained
In reply to Philip OberfichtnerBefore this commit, usage of this header relied on a specific include order. Fix it by including all dependencies.
---
Notes:
Changes in V4: None
Changes in V3: None
drivers/net/dwc_eth_qos.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/dwc_eth_qos.h +4 -1
@@ -3,8 +3,11 @@* Copyright 2022 NXP */ -#include <phy_interface.h> +#include <asm/gpio.h> +#include <clk.h> #include <linux/bitops.h> +#include <phy_interface.h> +#include <reset.h> /* Core registers */
Signature · 1 line
2.39.2
PATCH v4 3/5 net: dwc_eth_qos: Adapt probe() for PCI devices
In reply to Philip OberfichtnerPCI devices do not necessarily use a device tree. In that case, the driver currently fails to find eqos->config and eqos->regs.
This commit factors out the respective functionality. Device tree usage remains default, but board specific implementations will be possible as well.
---
Notes:
Changes in V4:
- Fix printf format string to account for 32-bit fdt_addr_t
Changes in V3:
Factor out eqos_get_base_addr_common() in order to avoid introducing a new callback function.
drivers/net/dwc_eth_qos.c | 55 +++++++++++++++++++++++++----- drivers/net/dwc_eth_qos.h | 2 ++ drivers/net/dwc_eth_qos_imx.c | 6 ++++ drivers/net/dwc_eth_qos_qcom.c | 6 ++++ drivers/net/dwc_eth_qos_rockchip.c | 6 ++++ drivers/net/dwc_eth_qos_starfive.c | 6 ++++ drivers/net/dwc_eth_qos_stm32.c | 6 ++++ 7 files changed, 79 insertions(+), 8 deletions(-)
drivers/net/dwc_eth_qos.c +47 -8
@@ -32,6 +32,7 @@#include <clk.h> #include <cpu_func.h> #include <dm.h> +#include <dm/device_compat.h> #include <errno.h> #include <eth_phy.h> #include <log.h>
@@ -1301,6 +1302,13 @@ static int eqos_probe_resources_tegra186(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev); + ret =eqos_get_base_addr_dt (dev); +if (ret) { +pr_err ("eqos_get_base_addr_dt failed: %d\n" , ret); +return ret; + } + eqos->tegra186_regs = (void *)(eqos->regs +EQOS_TEGRA186_REGS_BASE ); + ret =reset_get_by_name (dev,"eqos" , &eqos->reset_ctl);if (ret) {pr_err ("reset_get_by_name(rst) failed: %d\n" , ret);
@@ -1375,6 +1383,42 @@ static int eqos_remove_resources_tegra186(struct udevice *dev)return 0 ; } +/* +* Get driver data based on the device tree. Boards not using a device tree can +* overwrite this function. +*/ +__weak void *eqos_get_driver_data (struct udevice *dev) +{ +return (void *)dev_get_driver_data (dev); +} + +static fdt_addr_t eqos_get_base_addr_common (struct udevice *dev,fdt_addr_t addr) +{ +struct eqos_priv *eqos =dev_get_priv (dev); + +if (addr ==FDT_ADDR_T_NONE ) { +#if CONFIG_IS_ENABLED (FDT_64BIT ) +dev_err (dev,"addr=0x%llx is invalid.\n" , addr); +#else +dev_err (dev,"addr=0x%x is invalid.\n" , addr); +#endif +return -EINVAL ; + } + + eqos->regs = addr; + eqos->mac_regs = (void *)(addr +EQOS_MAC_REGS_BASE ); + eqos->mtl_regs = (void *)(addr +EQOS_MTL_REGS_BASE ); + eqos->dma_regs = (void *)(addr +EQOS_DMA_REGS_BASE ); + +return 0 ; +} + +int eqos_get_base_addr_dt (struct udevice *dev) +{ +fdt_addr_t addr =dev_read_addr (dev); +return eqos_get_base_addr_common (dev, addr); +} +static int eqos_probe (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
@@ -1383,17 +1427,12 @@ static int eqos_probe(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev); eqos->dev = dev; - eqos->config = (void *)dev_get_driver_data (dev); - eqos->regs =dev_read_addr (dev); -if (eqos->regs ==FDT_ADDR_T_NONE ) { -pr_err ("dev_read_addr() failed\n" ); + eqos->config =eqos_get_driver_data (dev); +if (!eqos->config) { +pr_err ("Failed to get driver data.\n" );return -ENODEV ; } - eqos->mac_regs = (void *)(eqos->regs +EQOS_MAC_REGS_BASE ); - eqos->mtl_regs = (void *)(eqos->regs +EQOS_MTL_REGS_BASE ); - eqos->dma_regs = (void *)(eqos->regs +EQOS_DMA_REGS_BASE ); - eqos->tegra186_regs = (void *)(eqos->regs +EQOS_TEGRA186_REGS_BASE ); eqos->max_speed =dev_read_u32_default (dev,"max-speed" ,0 );
drivers/net/dwc_eth_qos.h +2 -0
@@ -289,7 +289,9 @@ void eqos_inval_desc_generic(void *desc);void eqos_flush_desc_generic (void *desc);void eqos_inval_buffer_generic (void *buf,size_t size);void eqos_flush_buffer_generic (void *buf,size_t size); +int eqos_get_base_addr_dt (struct udevice *dev);int eqos_null_ops (struct udevice *dev); +void *eqos_get_driver_data (struct udevice *dev);extern struct eqos_config eqos_imx_config;extern struct eqos_config eqos_rockchip_config;
drivers/net/dwc_eth_qos_imx.c +6 -0
@@ -47,6 +47,12 @@ static int eqos_probe_resources_imx(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev); + ret =eqos_get_base_addr_dt (dev); +if (ret) { +dev_dbg (dev,"eqos_get_base_addr_dt failed: %d" , ret); + goto err_probe; + } + interface = eqos->config->interface (dev);if (interface ==PHY_INTERFACE_MODE_NA ) {
drivers/net/dwc_eth_qos_qcom.c +6 -0
@@ -522,6 +522,12 @@ static int eqos_probe_resources_qcom(struct udevice *dev)debug ("%s(dev=%p):\n" , __func__, dev); + ret =eqos_get_base_addr_dt (dev); +if (ret) { +pr_err ("eqos_get_base_addr_dt failed: %d\n" , ret); +return ret; + } + interface = eqos->config->interface (dev);if (interface ==PHY_INTERFACE_MODE_NA ) {
drivers/net/dwc_eth_qos_rockchip.c +6 -0
@@ -311,6 +311,12 @@ static int eqos_probe_resources_rk(struct udevice *dev)int reset_flags =GPIOD_IS_OUT |GPIOD_IS_OUT_ACTIVE ;int ret; + ret =eqos_get_base_addr_dt (dev); +if (ret) { +dev_err (dev,"eqos_get_base_addr_dt failed: %d\n" , ret); +return ret; + } + data =calloc (1 ,sizeof (struct rockchip_platform_data ));if (!data)return -ENOMEM ;
drivers/net/dwc_eth_qos_starfive.c +6 -0
@@ -183,6 +183,12 @@ static int eqos_probe_resources_jh7110(struct udevice *dev)struct starfive_platform_data *data;int ret; + ret =eqos_get_base_addr_dt (dev); +if (ret) { +pr_err ("eqos_get_base_addr_dt failed: %d\n" , ret); +return ret; + } + data =calloc (1 ,sizeof (struct starfive_platform_data ));if (!data)return -ENOMEM ;
drivers/net/dwc_eth_qos_stm32.c +6 -0
@@ -234,6 +234,12 @@ static int eqos_probe_resources_stm32(struct udevice *dev) interface = eqos->config->interface (dev); + ret =eqos_get_base_addr_dt (dev); +if (ret) { +dev_err (dev,"eqos_get_base_addr_dt failed: %d\n" , ret); +return ret; + } +if (interface ==PHY_INTERFACE_MODE_NA ) {dev_err (dev,"Invalid PHY interface\n" );return -EINVAL ;
Signature · 1 line
2.39.2
PATCH v4 4/5 net: dwc_eth_qos: Implement bind() for PCI devices
In reply to Philip OberfichtnerPCI devices do not necessarily use a device tree. Implement a bind() function to assign unique device names in that case.
---
Notes:
Changes in V4: None
Changes in V3: None
drivers/net/dwc_eth_qos.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/net/dwc_eth_qos.c +16 -0
@@ -1383,6 +1383,21 @@ static int eqos_remove_resources_tegra186(struct udevice *dev)return 0 ; } +static int eqos_bind (struct udevice *dev) +{ +static int dev_num; +const size_t name_sz =16 ; +char name[name_sz]; + +/* Device name defaults to DT node name. */ +if (ofnode_valid (dev_ofnode (dev))) +return 0 ; + +/* Assign unique names in case there is no DT node. */ +snprintf (name, name_sz,"eth_eqos#%d" , dev_num++); +return device_set_name (dev, name); +} +/* * Get driver data based on the device tree. Boards not using a device tree can * overwrite this function.
@@ -1613,6 +1628,7 @@ U_BOOT_DRIVER(eth_eqos) = { .name = "eth_eqos", .id = UCLASS_ETH, .of_match = of_match_ptr(eqos_ids), + .bind = eqos_bind, .probe = eqos_probe, .remove = eqos_remove, .ops = &eqos_ops,
Signature · 1 line
2.39.2
PATCH v4 5/5 net: dwc_eth_qos: Add glue driver for Intel MAC
In reply to Philip OberfichtnerAdd dwc_eth_qos glue driver for the Intel Elkhart-Lake SOC.
---
Notes:
Changes in V4: None
Changes in V3:
- update linux reference to current stable
- replace pr_err by dev_err
- drop __prefix from local function names
- use FIELD_PREP to simplify bitfield extraction
drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/dwc_eth_qos.c | 12 + drivers/net/dwc_eth_qos.h | 1 + drivers/net/dwc_eth_qos_intel.c | 449 ++++++++++++++++++++++++++++++++ drivers/net/dwc_eth_qos_intel.h | 57 ++++ include/pci_ids.h | 9 + 7 files changed, 536 insertions(+) create mode 100644 drivers/net/dwc_eth_qos_intel.c create mode 100644 drivers/net/dwc_eth_qos_intel.h
drivers/net/Kconfig +7 -0
@@ -243,6 +243,13 @@ config DWC_ETH_QOS_IMX The Synopsys Designware Ethernet QOS IP block with the specific configuration used in IMX soc. +config DWC_ETH_QOS_INTEL + bool "Synopsys DWC Ethernet QOS device support for Intel" + depends on DWC_ETH_QOS + help + The Synopsys Designware Ethernet QOS IP block with the specific + configuration used in the Intel Elkhart-Lake soc. + config DWC_ETH_QOS_ROCKCHIP bool "Synopsys DWC Ethernet QOS device support for Rockchip SoCs" depends on DWC_ETH_QOS
drivers/net/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o obj-$(CONFIG_DSA_SANDBOX) += dsa_sandbox.o obj-$(CONFIG_DWC_ETH_QOS) += dwc_eth_qos.o obj-$(CONFIG_DWC_ETH_QOS_IMX) += dwc_eth_qos_imx.o +obj-$(CONFIG_DWC_ETH_QOS_INTEL) += dwc_eth_qos_intel.o obj-$(CONFIG_DWC_ETH_QOS_ROCKCHIP) += dwc_eth_qos_rockchip.o obj-$(CONFIG_DWC_ETH_QOS_QCOM) += dwc_eth_qos_qcom.o obj-$(CONFIG_DWC_ETH_XGMAC) += dwc_eth_xgmac.o
drivers/net/dwc_eth_qos.c +12 -0
@@ -1434,6 +1434,18 @@ int eqos_get_base_addr_dt(struct udevice *dev)return eqos_get_base_addr_common (dev, addr); } +int eqos_get_base_addr_pci (struct udevice *dev) +{ +fdt_addr_t addr; +void *paddr; + + paddr =dm_pci_map_bar (dev,PCI_BASE_ADDRESS_0 ,0 ,0 ,PCI_REGION_TYPE , +PCI_REGION_MEM ); + addr = paddr ? (fdt_addr_t )paddr :FDT_ADDR_T_NONE ; + +return eqos_get_base_addr_common (dev, addr); +} +static int eqos_probe (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
drivers/net/dwc_eth_qos.h +1 -0
@@ -290,6 +290,7 @@ void eqos_flush_desc_generic(void *desc);void eqos_inval_buffer_generic (void *buf,size_t size);void eqos_flush_buffer_generic (void *buf,size_t size);int eqos_get_base_addr_dt (struct udevice *dev); +int eqos_get_base_addr_pci (struct udevice *dev);int eqos_null_ops (struct udevice *dev);void *eqos_get_driver_data (struct udevice *dev);
drivers/net/dwc_eth_qos_intel.c new file +449 -0
449 lines not on this page · raw message
drivers/net/dwc_eth_qos_intel.h new file +57 -0
57 lines not on this page · raw message
include/pci_ids.h +9 -0
@@ -2600,6 +2600,15 @@#define PCI_DEVICE_ID_DCI_PCCOM2 0x0004#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_EHL_RGMII1G 0x4b30 +#define PCI_DEVICE_ID_INTEL_EHL_SGMII1 0x4b31 +#define PCI_DEVICE_ID_INTEL_EHL_SGMII2G5 0x4b32 +#define PCI_DEVICE_ID_INTEL_EHL_PSE0_RGMII1G 0x4ba0 +#define PCI_DEVICE_ID_INTEL_EHL_PSE0_SGMII1G 0x4ba1 +#define PCI_DEVICE_ID_INTEL_EHL_PSE0_SGMII2G5 0x4ba2 +#define PCI_DEVICE_ID_INTEL_EHL_PSE1_RGMII1G 0x4bb0 +#define PCI_DEVICE_ID_INTEL_EHL_PSE1_SGMII1G 0x4bb1 +#define PCI_DEVICE_ID_INTEL_EHL_PSE1_SGMII2G5 0x4bb2#define PCI_DEVICE_ID_INTEL_EESSC 0x0008#define PCI_DEVICE_ID_INTEL_SNB_IMC 0x0100#define PCI_DEVICE_ID_INTEL_IVB_IMC 0x0154
Signature · 1 line
2.39.2
Hi all,
Seems there is no more comments to the series. Can we get it merged then?
Best regards,
Philip
Quoted 42 lines · Philip Oberfichtner
This patch series implements the
dwc_eth_qosglue driver for Intel SOCs. Before doing that, a few general adaptions to thedwc_eth_qos.cmain driver are required. Most notably, the preparation for PCI based driver instances, which do not necessarily use a device tree.Changes in V4:
- Fix printf format stringChanges in V3:
- Replacemfence()withmb()
- Clean-upeqos_get_base_addr()
- Several style fixes fordwc_eth_qos_intelPhilip Oberfichtner (5):
x86: providemb()macro
net:dwc_eth_qos: Fix header to be self-contained
net:dwc_eth_qos: Adaptprobe()for PCI devices
net:dwc_eth_qos: Implementbind()for PCI devices
net:dwc_eth_qos: Add glue driver for Intel MACarch/x86/cpu/mp_init.c | 10 +- arch/x86/include/asm/cpu.h | 5 - arch/x86/include/asm/io.h | 1 + drivers/net/Kconfig | 7 + drivers/net/Makefile | 1 + drivers/net/dwc_eth_qos.c | 83 +++++- drivers/net/dwc_eth_qos.h | 8 +- drivers/net/dwc_eth_qos_imx.c | 6 + drivers/net/dwc_eth_qos_intel.c | 449 +++++++++++++++++++++++++++++ drivers/net/dwc_eth_qos_intel.h | 57 ++++ drivers/net/dwc_eth_qos_qcom.c | 6 + drivers/net/dwc_eth_qos_rockchip.c | 6 + drivers/net/dwc_eth_qos_starfive.c | 6 + drivers/net/dwc_eth_qos_stm32.c | 6 + include/pci_ids.h | 9 + 15 files changed, 641 insertions(+), 19 deletions(-) create mode 100644 drivers/net/dwc_eth_qos_intel.c create mode 100644 drivers/net/dwc_eth_qos_intel.hSignature · 1 line
2.39.2
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-22 Fax: +49-8142-66989-80 Email: [email protected] =====================================================================
Quoted 9 lines · Philip Oberfichtner
This patch series implements the
dwc_eth_qosglue driver for Intel SOCs. Before doing that, a few general adaptions to thedwc_eth_qos.cmain driver are required. Most notably, the preparation for PCI based driver instances, which do not necessarily use a device tree.Changes in V4:
- Fix printf format string[...]
Applied to u-boot/next, thanks!
Signature · 1 line
Tom