From fcc48204d2ea1e555e72d2cc6d22b59b1ec0e618 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 9 Feb 2025 16:52:51 -0800 Subject: [PATCH] ltq-ptm: add NVMEM MAC support This will be used in the following commit to move MAC assignment of the DSL interface to NVMEM. Signed-off-by: Rosen Penev Link: https://github.com/openwrt/openwrt/pull/17289 Signed-off-by: Robert Marko --- package/kernel/lantiq/ltq-ptm/Makefile | 2 +- .../lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c | 32 +++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/package/kernel/lantiq/ltq-ptm/Makefile b/package/kernel/lantiq/ltq-ptm/Makefile index c3ab47c1b3e..f4d5f766c7e 100644 --- a/package/kernel/lantiq/ltq-ptm/Makefile +++ b/package/kernel/lantiq/ltq-ptm/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-ptm -PKG_RELEASE:=4 +PKG_RELEASE:=5 PKG_MAINTAINER:=John Crispin PKG_LICENSE:=GPL-2.0+ diff --git a/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c b/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c index 65c9833a0a5..f580105505f 100644 --- a/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c +++ b/package/kernel/lantiq/ltq-ptm/src/ifxmips_ptm_vdsl.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "ifxmips_ptm_vdsl.h" #include @@ -69,7 +70,7 @@ unsigned long cgu_get_pp32_clock(void) return rate; } -static void ptm_setup(struct net_device *, int); +static int ptm_setup(struct device_node* np, struct net_device *, int); static struct net_device_stats *ptm_get_stats(struct net_device *); static int ptm_open(struct net_device *); static int ptm_stop(struct net_device *); @@ -144,9 +145,10 @@ unsigned int ifx_ptm_dbg_enable = DBG_ENABLE_MASK_ERR; * #################################### */ -static void ptm_setup(struct net_device *dev, int ndev) +static int ptm_setup(struct device_node *np, struct net_device *dev, int ndev) { u8 addr[ETH_ALEN]; + int err; netif_carrier_off(dev); @@ -160,13 +162,20 @@ static void ptm_setup(struct net_device *dev, int ndev) #endif dev->watchdog_timeo = ETH_WATCHDOG_TIMEOUT; - addr[0] = 0x00; - addr[1] = 0x20; - addr[2] = 0xda; - addr[3] = 0x86; - addr[4] = 0x23; - addr[5] = 0x75 + ndev; - eth_hw_addr_set(dev, addr); + err = of_get_ethdev_address(np, dev); + if (err == -EPROBE_DEFER) + return err; + if (err) { + addr[0] = 0x00; + addr[1] = 0x20; + addr[2] = 0xda; + addr[3] = 0x86; + addr[4] = 0x23; + addr[5] = 0x75 + ndev; + eth_hw_addr_set(dev, addr); + } + + return 0; } static struct net_device_stats *ptm_get_stats(struct net_device *dev) @@ -986,6 +995,7 @@ static int ltq_ptm_probe(struct platform_device *pdev) int i; char ver_str[256]; struct port_cell_info port_cell = {0}; + struct device_node *np = pdev->dev.of_node; ret = init_priv_data(); if ( ret != 0 ) { @@ -1006,7 +1016,9 @@ static int ltq_ptm_probe(struct platform_device *pdev) g_net_dev[i] = alloc_netdev(0, g_net_dev_name[i], NET_NAME_UNKNOWN, ether_setup); if ( g_net_dev[i] == NULL ) goto ALLOC_NETDEV_FAIL; - ptm_setup(g_net_dev[i], i); + ret = ptm_setup(np, g_net_dev[i], i); + if (ret == -EPROBE_DEFER) + goto INIT_TABLES_FAIL; } for ( i = 0; i < ARRAY_SIZE(g_net_dev); i++ ) { -- 2.47.2