From: Tom Rini Date: Sun, 27 Nov 2022 15:25:05 +0000 (-0500) Subject: net: fm: Remove non-DM_ETH code X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=cc2bf624eb7109f793b470660973e4167de8290f;p=u-boot.git net: fm: Remove non-DM_ETH code As DM_ETH is required for all network drivers, it's now safe to remove the non-DM_ETH support code. Signed-off-by: Tom Rini --- diff --git a/drivers/net/fm/Makefile b/drivers/net/fm/Makefile index 5a7d3037af..b34209d2b3 100644 --- a/drivers/net/fm/Makefile +++ b/drivers/net/fm/Makefile @@ -6,7 +6,6 @@ obj-y += dtsec.o obj-y += eth.o obj-y += fdt.o obj-y += fm.o -obj-y += init.o obj-y += tgec.o obj-y += tgec_phy.o diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c index c8381cc713..9fd26de0d7 100644 --- a/drivers/net/fm/eth.c +++ b/drivers/net/fm/eth.c @@ -8,12 +8,10 @@ #include #include #include -#ifdef CONFIG_DM_ETH #include #include #include #include -#endif #include #include #include @@ -28,11 +26,6 @@ #include "fm.h" -#ifndef CONFIG_DM_ETH -static struct eth_device *devlist[NUM_FM_PORTS]; -static int num_controllers; -#endif - #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) && !defined(BITBANGMII) #define TBIANA_SETTINGS (TBIANA_ASYMMETRIC_PAUSE | TBIANA_SYMMETRIC_PAUSE | \ @@ -53,14 +46,10 @@ static void dtsec_configure_serdes(struct fm_eth *priv) PHY_INTERFACE_MODE_2500BASEX) ? true : false; int i = 0, j; -#ifndef CONFIG_DM_ETH - bus.priv = priv->mac->phyregs; -#else bus.priv = priv->pcs_mdio; bus.read = memac_mdio_read; bus.write = memac_mdio_write; bus.reset = memac_mdio_reset; -#endif qsgmii_loop: /* SGMII IF mode + AN enable only for 1G SGMII, not for 2.5G */ @@ -136,19 +125,6 @@ static void dtsec_init_phy(struct fm_eth *fm_eth) fm_eth->enet_if == PHY_INTERFACE_MODE_2500BASEX) dtsec_configure_serdes(fm_eth); } - -#ifndef CONFIG_DM_ETH -#ifdef CONFIG_PHYLIB -static int tgec_is_fibre(struct fm_eth *fm) -{ - char phyopt[20]; - - sprintf(phyopt, "fsl_fm%d_xaui_phy", fm->fm_index + 1); - - return hwconfig_arg_cmp(phyopt, "xfi"); -} -#endif -#endif /* CONFIG_DM_ETH */ #endif static u16 muram_readw(u16 *addr) @@ -465,18 +441,10 @@ static void fmc_tx_port_graceful_stop_disable(struct fm_eth *fm_eth) sync(); } -#ifndef CONFIG_DM_ETH -static int fm_eth_open(struct eth_device *dev, struct bd_info *bd) -#else static int fm_eth_open(struct udevice *dev) -#endif { -#ifndef CONFIG_DM_ETH - struct fm_eth *fm_eth = dev->priv; -#else struct eth_pdata *pdata = dev_get_plat(dev); struct fm_eth *fm_eth = dev_get_priv(dev); -#endif unsigned char *enetaddr; struct fsl_enet_mac *mac; #ifdef CONFIG_PHYLIB @@ -485,11 +453,7 @@ static int fm_eth_open(struct udevice *dev) mac = fm_eth->mac; -#ifndef CONFIG_DM_ETH - enetaddr = &dev->enetaddr[0]; -#else enetaddr = pdata->enetaddr; -#endif /* setup the MAC address */ if (enetaddr[0] & 0x01) { @@ -512,12 +476,7 @@ static int fm_eth_open(struct udevice *dev) if (fm_eth->phydev) { ret = phy_startup(fm_eth->phydev); if (ret) { -#ifndef CONFIG_DM_ETH - printf("%s: Could not initialize\n", - fm_eth->phydev->dev->name); -#else printf("%s: Could not initialize\n", dev->name); -#endif return ret; } } else { @@ -540,20 +499,12 @@ static int fm_eth_open(struct udevice *dev) return fm_eth->phydev->link ? 0 : -1; } -#ifndef CONFIG_DM_ETH -static void fm_eth_halt(struct eth_device *dev) -#else static void fm_eth_halt(struct udevice *dev) -#endif { struct fm_eth *fm_eth; struct fsl_enet_mac *mac; -#ifndef CONFIG_DM_ETH - fm_eth = (struct fm_eth *)dev->priv; -#else fm_eth = dev_get_priv(dev); -#endif mac = fm_eth->mac; /* graceful stop the transmission of frames */ @@ -571,11 +522,7 @@ static void fm_eth_halt(struct udevice *dev) #endif } -#ifndef CONFIG_DM_ETH -static int fm_eth_send(struct eth_device *dev, void *buf, int len) -#else static int fm_eth_send(struct udevice *dev, void *buf, int len) -#endif { struct fm_eth *fm_eth; struct fm_port_global_pram *pram; @@ -583,11 +530,7 @@ static int fm_eth_send(struct udevice *dev, void *buf, int len) u16 offset_in; int i; -#ifndef CONFIG_DM_ETH - fm_eth = (struct fm_eth *)dev->priv; -#else fm_eth = dev_get_priv(dev); -#endif pram = fm_eth->tx_pram; txbd = fm_eth->cur_txbd; @@ -668,11 +611,7 @@ static struct fm_port_bd *fm_eth_free_one(struct fm_eth *fm_eth, return rxbd; } -#ifndef CONFIG_DM_ETH -static int fm_eth_recv(struct eth_device *dev) -#else static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) -#endif { struct fm_eth *fm_eth; struct fm_port_bd *rxbd; @@ -681,11 +620,7 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) int ret = -1; u8 *data; -#ifndef CONFIG_DM_ETH - fm_eth = (struct fm_eth *)dev->priv; -#else fm_eth = dev_get_priv(dev); -#endif rxbd = fm_eth->cur_rxbd; status = muram_readw(&rxbd->status); @@ -695,12 +630,8 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) buf_lo = in_be32(&rxbd->buf_ptr_lo); data = (u8 *)((ulong)(buf_hi << 16) << 16 | buf_lo); len = muram_readw(&rxbd->len); -#ifndef CONFIG_DM_ETH - net_process_received_packet(data, len); -#else *packetp = data; return len; -#endif } else { printf("%s: Rx error\n", dev->name); ret = 0; @@ -717,7 +648,6 @@ static int fm_eth_recv(struct udevice *dev, int flags, uchar **packetp) return ret; } -#ifdef CONFIG_DM_ETH static int fm_eth_free_pkt(struct udevice *dev, uchar *packet, int length) { struct fm_eth *fm_eth = (struct fm_eth *)dev_get_priv(dev); @@ -726,65 +656,7 @@ static int fm_eth_free_pkt(struct udevice *dev, uchar *packet, int length) return 0; } -#endif /* CONFIG_DM_ETH */ - -#ifndef CONFIG_DM_ETH -static int fm_eth_init_mac(struct fm_eth *fm_eth, struct ccsr_fman *reg) -{ - struct fsl_enet_mac *mac; - int num; - void *base, *phyregs = NULL; - - num = fm_eth->num; - -#ifdef CONFIG_SYS_FMAN_V3 -#ifndef CONFIG_FSL_FM_10GEC_REGULAR_NOTATION - if (fm_eth->type == FM_ETH_10G_E) { - /* 10GEC1/10GEC2 use mEMAC9/mEMAC10 on T2080/T4240. - * 10GEC3/10GEC4 use mEMAC1/mEMAC2 on T2080. - * 10GEC1 uses mEMAC1 on T1024. - * so it needs to change the num. - */ - if (fm_eth->num >= 2) - num -= 2; - else - num += 8; - } -#endif - base = ®->memac[num].fm_memac; - phyregs = ®->memac[num].fm_memac_mdio; -#else - /* Get the mac registers base address */ - if (fm_eth->type == FM_ETH_1G_E) { - base = ®->mac_1g[num].fm_dtesc; - phyregs = ®->mac_1g[num].fm_mdio.miimcfg; - } else { - base = ®->mac_10g[num].fm_10gec; - phyregs = ®->mac_10g[num].fm_10gec_mdio; - } -#endif - - /* alloc mac controller */ - mac = malloc(sizeof(struct fsl_enet_mac)); - if (!mac) - return -ENOMEM; - memset(mac, 0, sizeof(struct fsl_enet_mac)); - - /* save the mac to fm_eth struct */ - fm_eth->mac = mac; - -#ifdef CONFIG_SYS_FMAN_V3 - init_memac(mac, base, phyregs, MAX_RXBUF_LEN); -#else - if (fm_eth->type == FM_ETH_1G_E) - init_dtsec(mac, base, phyregs, MAX_RXBUF_LEN); - else - init_tgec(mac, base, phyregs, MAX_RXBUF_LEN); -#endif - return 0; -} -#else /* CONFIG_DM_ETH */ static int fm_eth_init_mac(struct fm_eth *fm_eth, void *reg) { #ifndef CONFIG_SYS_FMAN_V3 @@ -817,15 +689,11 @@ static int fm_eth_init_mac(struct fm_eth *fm_eth, void *reg) return 0; } -#endif /* CONFIG_DM_ETH */ static int init_phy(struct fm_eth *fm_eth) { #ifdef CONFIG_PHYLIB u32 supported = PHY_GBIT_FEATURES; -#ifndef CONFIG_DM_ETH - struct phy_device *phydev = NULL; -#endif if (fm_eth->type == FM_ETH_10G_E) supported = PHY_10G_FEATURES; @@ -836,7 +704,6 @@ static int init_phy(struct fm_eth *fm_eth) if (fm_eth->type == FM_ETH_1G_E) dtsec_init_phy(fm_eth); -#ifdef CONFIG_DM_ETH #ifdef CONFIG_PHYLIB #ifdef CONFIG_DM_MDIO fm_eth->phydev = dm_eth_phy_connect(fm_eth->dev); @@ -848,112 +715,8 @@ static int init_phy(struct fm_eth *fm_eth) phy_config(fm_eth->phydev); #endif -#else /* CONFIG_DM_ETH */ -#ifdef CONFIG_PHYLIB - if (fm_eth->bus) { - phydev = phy_connect(fm_eth->bus, fm_eth->phyaddr, fm_eth->dev, - fm_eth->enet_if); - if (!phydev) { - printf("Failed to connect\n"); - return -1; - } - } else { - return 0; - } - - if (fm_eth->type == FM_ETH_1G_E) { - supported = (SUPPORTED_10baseT_Half | - SUPPORTED_10baseT_Full | - SUPPORTED_100baseT_Half | - SUPPORTED_100baseT_Full | - SUPPORTED_1000baseT_Full); - } else { - supported = SUPPORTED_10000baseT_Full; - - if (tgec_is_fibre(fm_eth)) - phydev->port = PORT_FIBRE; - } - - phydev->supported &= supported; - phydev->advertising = phydev->supported; - - fm_eth->phydev = phydev; - - phy_config(phydev); -#endif -#endif /* CONFIG_DM_ETH */ - return 0; -} - -#ifndef CONFIG_DM_ETH -int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info) -{ - struct eth_device *dev; - struct fm_eth *fm_eth; - int i, num = info->num; - int ret; - - /* alloc eth device */ - dev = (struct eth_device *)malloc(sizeof(struct eth_device)); - if (!dev) - return -ENOMEM; - memset(dev, 0, sizeof(struct eth_device)); - - /* alloc the FMan ethernet private struct */ - fm_eth = (struct fm_eth *)malloc(sizeof(struct fm_eth)); - if (!fm_eth) - return -ENOMEM; - memset(fm_eth, 0, sizeof(struct fm_eth)); - - /* save off some things we need from the info struct */ - fm_eth->fm_index = info->index - 1; /* keep as 0 based for muram */ - fm_eth->num = num; - fm_eth->type = info->type; - - fm_eth->rx_port = (void *)®->port[info->rx_port_id - 1].fm_bmi; - fm_eth->tx_port = (void *)®->port[info->tx_port_id - 1].fm_bmi; - - /* set the ethernet max receive length */ - fm_eth->max_rx_len = MAX_RXBUF_LEN; - - /* init global mac structure */ - ret = fm_eth_init_mac(fm_eth, reg); - if (ret) - return ret; - - /* keep same as the manual, we call FMAN1, FMAN2, DTSEC1, DTSEC2, etc */ - if (fm_eth->type == FM_ETH_1G_E) - sprintf(dev->name, "FM%d@DTSEC%d", info->index, num + 1); - else - sprintf(dev->name, "FM%d@TGEC%d", info->index, num + 1); - - devlist[num_controllers++] = dev; - dev->iobase = 0; - dev->priv = (void *)fm_eth; - dev->init = fm_eth_open; - dev->halt = fm_eth_halt; - dev->send = fm_eth_send; - dev->recv = fm_eth_recv; - fm_eth->dev = dev; - fm_eth->bus = info->bus; - fm_eth->phyaddr = info->phy_addr; - fm_eth->enet_if = info->enet_if; - - /* startup the FM im */ - ret = fm_eth_startup(fm_eth); - if (ret) - return ret; - - init_phy(fm_eth); - - /* clear the ethernet address */ - for (i = 0; i < 6; i++) - dev->enetaddr[i] = 0; - eth_register(dev); - return 0; } -#else /* CONFIG_DM_ETH */ static int fm_eth_bind(struct udevice *dev) { @@ -1139,4 +902,3 @@ U_BOOT_DRIVER(eth_fman) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index c476cb3120..055dd61fbe 100644 --- a/drivers/net/fm/fm.c +++ b/drivers/net/fm/fm.c @@ -10,9 +10,7 @@ #include #include #include -#ifdef CONFIG_DM_ETH #include -#endif #include "fm.h" #include /* For struct qe_firmware */ @@ -551,7 +549,6 @@ int fm_init_common(int index, struct ccsr_fman *reg) } #endif -#ifdef CONFIG_DM_ETH struct fman_priv { struct ccsr_fman *reg; unsigned int fman_id; @@ -626,4 +623,3 @@ U_BOOT_DRIVER(fman) = { .priv_auto = sizeof(struct fman_priv), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/fm.h b/drivers/net/fm/fm.h index 3d9cc5ca06..ba858cc24b 100644 --- a/drivers/net/fm/fm.h +++ b/drivers/net/fm/fm.h @@ -57,7 +57,6 @@ struct fm_port_bd { #define TxBD_READY 0x8000 #define TxBD_LAST BD_LAST -#ifdef CONFIG_DM_ETH enum fm_mac_type { #ifdef CONFIG_SYS_FMAN_V3 FM_MEMAC, @@ -66,7 +65,6 @@ enum fm_mac_type { FM_TGEC, #endif }; -#endif /* Fman ethernet private struct */ /* Rx/Tx queue descriptor */ @@ -115,9 +113,7 @@ void fman_disable_port(enum fm_port port); void fman_enable_port(enum fm_port port); int fman_id(struct udevice *dev); void *fman_port(struct udevice *dev, int num); -#ifdef CONFIG_DM_ETH void *fman_mdio(struct udevice *dev, enum fm_mac_type type, int num); -#endif struct fsl_enet_mac { void *base; /* MAC controller registers base address */ @@ -143,13 +139,9 @@ struct fm_eth { struct mii_dev *bus; struct phy_device *phydev; int phyaddr; -#ifndef CONFIG_DM_ETH - struct eth_device *dev; -#else enum fm_mac_type mac_type; struct udevice *dev; struct udevice *pcs_mdio; -#endif int max_rx_len; struct fm_port_global_pram *rx_pram; /* Rx parameter table */ struct fm_port_global_pram *tx_pram; /* Tx parameter table */ diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c deleted file mode 100644 index 618c1bccbe..0000000000 --- a/drivers/net/fm/init.c +++ /dev/null @@ -1,386 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Copyright 2011-2015 Freescale Semiconductor, Inc. - */ -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_FSL_LAYERSCAPE -#include -#include -#else -#include -#endif - -#include "fm.h" - -#ifndef CONFIG_DM_ETH -struct fm_eth_info fm_info[] = { -#if (CFG_SYS_NUM_FM1_DTSEC >= 1) - FM_DTSEC_INFO_INITIALIZER(1, 1), -#endif -#if (CFG_SYS_NUM_FM1_DTSEC >= 2) - FM_DTSEC_INFO_INITIALIZER(1, 2), -#endif -#if (CFG_SYS_NUM_FM1_DTSEC >= 3) - FM_DTSEC_INFO_INITIALIZER(1, 3), -#endif -#if (CFG_SYS_NUM_FM1_DTSEC >= 4) - FM_DTSEC_INFO_INITIALIZER(1, 4), -#endif -#if (CFG_SYS_NUM_FM1_DTSEC >= 5) - FM_DTSEC_INFO_INITIALIZER(1, 5), -#endif -#if (CFG_SYS_NUM_FM1_DTSEC >= 6) - FM_DTSEC_INFO_INITIALIZER(1, 6), -#endif -#if (CFG_SYS_NUM_FM1_DTSEC >= 7) - FM_DTSEC_INFO_INITIALIZER(1, 9), -#endif -#if (CFG_SYS_NUM_FM1_DTSEC >= 8) - FM_DTSEC_INFO_INITIALIZER(1, 10), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 1) - FM_DTSEC_INFO_INITIALIZER(2, 1), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 2) - FM_DTSEC_INFO_INITIALIZER(2, 2), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 3) - FM_DTSEC_INFO_INITIALIZER(2, 3), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 4) - FM_DTSEC_INFO_INITIALIZER(2, 4), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 5) - FM_DTSEC_INFO_INITIALIZER(2, 5), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 6) - FM_DTSEC_INFO_INITIALIZER(2, 6), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 7) - FM_DTSEC_INFO_INITIALIZER(2, 9), -#endif -#if (CFG_SYS_NUM_FM2_DTSEC >= 8) - FM_DTSEC_INFO_INITIALIZER(2, 10), -#endif -#if (CFG_SYS_NUM_FM1_10GEC >= 1) - FM_TGEC_INFO_INITIALIZER(1, 1), -#endif -#if (CFG_SYS_NUM_FM1_10GEC >= 2) - FM_TGEC_INFO_INITIALIZER(1, 2), -#endif -#if (CFG_SYS_NUM_FM1_10GEC >= 3) - FM_TGEC_INFO_INITIALIZER2(1, 3), -#endif -#if (CFG_SYS_NUM_FM1_10GEC >= 4) - FM_TGEC_INFO_INITIALIZER2(1, 4), -#endif -#if (CFG_SYS_NUM_FM2_10GEC >= 1) - FM_TGEC_INFO_INITIALIZER(2, 1), -#endif -#if (CFG_SYS_NUM_FM2_10GEC >= 2) - FM_TGEC_INFO_INITIALIZER(2, 2), -#endif -}; - -int fm_standard_init(struct bd_info *bis) -{ - int i; - struct ccsr_fman *reg; - - reg = (void *)CFG_SYS_FSL_FM1_ADDR; - if (fm_init_common(0, reg)) - return 0; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - if ((fm_info[i].enabled) && (fm_info[i].index == 1)) - fm_eth_initialize(reg, &fm_info[i]); - } - -#if (CFG_SYS_NUM_FMAN == 2) - reg = (void *)CFG_SYS_FSL_FM2_ADDR; - if (fm_init_common(1, reg)) - return 0; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - if ((fm_info[i].enabled) && (fm_info[i].index == 2)) - fm_eth_initialize(reg, &fm_info[i]); - } -#endif - - return 1; -} - -/* simple linear search to map from port to array index */ -static int fm_port_to_index(enum fm_port port) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - if (fm_info[i].port == port) - return i; - } - - return -1; -} - -/* - * Determine if an interface is actually active based on HW config - * we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NA if - * the interface is not active based on HW cfg of the SoC - */ -void fman_enet_init(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - phy_interface_t enet_if; - - enet_if = fman_port_enet_if(fm_info[i].port); - if (enet_if != PHY_INTERFACE_MODE_NA) { - fm_info[i].enabled = 1; - fm_info[i].enet_if = enet_if; - } else { - fm_info[i].enabled = 0; - } - } - - return; -} - -void fm_disable_port(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].enabled = 0; -#ifndef CONFIG_SYS_FMAN_V3 - fman_disable_port(port); -#endif -} - -void fm_enable_port(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].enabled = 1; - fman_enable_port(port); -} - -void fm_info_set_mdio(enum fm_port port, struct mii_dev *bus) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].bus = bus; -} - -void fm_info_set_phy_address(enum fm_port port, int address) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return; - - fm_info[i].phy_addr = address; -} - -/* - * Returns the PHY address for a given Fman port - * - * The port must be set via a prior call to fm_info_set_phy_address(). - * A negative error code is returned if the port is invalid. - */ -int fm_info_get_phy_address(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return -1; - - return fm_info[i].phy_addr; -} - -/* - * Returns the type of the data interface between the given MAC and its PHY. - * This is typically determined by the RCW. - */ -phy_interface_t fm_info_get_enet_if(enum fm_port port) -{ - int i = fm_port_to_index(port); - - if (i == -1) - return PHY_INTERFACE_MODE_NA; - - if (fm_info[i].enabled) - return fm_info[i].enet_if; - - return PHY_INTERFACE_MODE_NA; -} - -static void -__def_board_ft_fman_fixup_port(void *blob, char * prop, phys_addr_t pa, - enum fm_port port, int offset) -{ - return; -} - -void board_ft_fman_fixup_port(void *blob, char * prop, phys_addr_t pa, - enum fm_port port, int offset) - __attribute__((weak, alias("__def_board_ft_fman_fixup_port"))); - -int ft_fixup_port(void *blob, struct fm_eth_info *info, char *prop) -{ - int off; - uint32_t ph; - phys_addr_t paddr = CFG_SYS_CCSRBAR_PHYS + info->compat_offset; -#ifndef CONFIG_SYS_FMAN_V3 - u64 dtsec1_addr = (u64)CFG_SYS_CCSRBAR_PHYS + - CFG_SYS_FSL_FM1_DTSEC1_OFFSET; -#endif - - off = fdt_node_offset_by_compat_reg(blob, prop, paddr); - if (off == -FDT_ERR_NOTFOUND) - return -EINVAL; - - if (info->enabled) { - fdt_fixup_phy_connection(blob, off, info->enet_if); - board_ft_fman_fixup_port(blob, prop, paddr, info->port, off); - return 0; - } - -#ifdef CONFIG_SYS_FMAN_V3 -#ifndef CONFIG_FSL_FM_10GEC_REGULAR_NOTATION - /* - * On T2/T4 SoCs, physically FM1_DTSEC9 and FM1_10GEC1 use the same - * dual-role MAC, when FM1_10GEC1 is enabled and FM1_DTSEC9 - * is disabled, ensure that the dual-role MAC is not disabled, - * ditto for other dual-role MACs. - */ - if (((info->port == FM1_DTSEC9) && (PORT_IS_ENABLED(FM1_10GEC1))) || - ((info->port == FM1_DTSEC10) && (PORT_IS_ENABLED(FM1_10GEC2))) || - ((info->port == FM1_DTSEC1) && (PORT_IS_ENABLED(FM1_10GEC3))) || - ((info->port == FM1_DTSEC2) && (PORT_IS_ENABLED(FM1_10GEC4))) || - ((info->port == FM1_10GEC1) && (PORT_IS_ENABLED(FM1_DTSEC9))) || - ((info->port == FM1_10GEC2) && (PORT_IS_ENABLED(FM1_DTSEC10))) || - ((info->port == FM1_10GEC3) && (PORT_IS_ENABLED(FM1_DTSEC1))) || - ((info->port == FM1_10GEC4) && (PORT_IS_ENABLED(FM1_DTSEC2))) -#if (CFG_SYS_NUM_FMAN == 2) - || - ((info->port == FM2_DTSEC9) && (PORT_IS_ENABLED(FM2_10GEC1))) || - ((info->port == FM2_DTSEC10) && (PORT_IS_ENABLED(FM2_10GEC2))) || - ((info->port == FM2_10GEC1) && (PORT_IS_ENABLED(FM2_DTSEC9))) || - ((info->port == FM2_10GEC2) && (PORT_IS_ENABLED(FM2_DTSEC10))) -#endif -#else - /* FM1_DTSECx and FM1_10GECx use the same dual-role MAC */ - if (((info->port == FM1_DTSEC1) && (PORT_IS_ENABLED(FM1_10GEC1))) || - ((info->port == FM1_DTSEC2) && (PORT_IS_ENABLED(FM1_10GEC2))) || - ((info->port == FM1_DTSEC3) && (PORT_IS_ENABLED(FM1_10GEC3))) || - ((info->port == FM1_DTSEC4) && (PORT_IS_ENABLED(FM1_10GEC4))) || - ((info->port == FM1_10GEC1) && (PORT_IS_ENABLED(FM1_DTSEC1))) || - ((info->port == FM1_10GEC2) && (PORT_IS_ENABLED(FM1_DTSEC2))) || - ((info->port == FM1_10GEC3) && (PORT_IS_ENABLED(FM1_DTSEC3))) || - ((info->port == FM1_10GEC4) && (PORT_IS_ENABLED(FM1_DTSEC4))) -#endif - ) - return 0; -#endif - /* board code might have caused offset to change */ - off = fdt_node_offset_by_compat_reg(blob, prop, paddr); - -#ifndef CONFIG_SYS_FMAN_V3 - /* Don't disable FM1-DTSEC1 MAC as its used for MDIO */ - if (paddr != dtsec1_addr) -#endif - fdt_status_disabled(blob, off); /* disable the MAC node */ - - /* disable the fsl,dpa-ethernet node that points to the MAC */ - ph = fdt_get_phandle(blob, off); - do_fixup_by_prop(blob, "fsl,fman-mac", &ph, sizeof(ph), - "status", "disabled", strlen("disabled") + 1, 1); - - return 0; -} - -void fdt_fixup_fman_ethernet(void *blob) -{ - int i; - -#ifdef CONFIG_SYS_FMAN_V3 - for (i = 0; i < ARRAY_SIZE(fm_info); i++) - ft_fixup_port(blob, &fm_info[i], "fsl,fman-memac"); -#else - for (i = 0; i < ARRAY_SIZE(fm_info); i++) { - /* Try the new compatible first. - * If the node is missing, try the old. - */ - if (fm_info[i].type == FM_ETH_1G_E) { - if (ft_fixup_port(blob, &fm_info[i], "fsl,fman-dtsec")) - ft_fixup_port(blob, &fm_info[i], - "fsl,fman-1g-mac"); - } else { - if (ft_fixup_port(blob, &fm_info[i], "fsl,fman-xgec") && - ft_fixup_port(blob, &fm_info[i], "fsl,fman-tgec")) - ft_fixup_port(blob, &fm_info[i], - "fsl,fman-10g-mac"); - } - } -#endif -} - -/*QSGMII Riser Card can work in SGMII mode, but the PHY address is different. - *This function scans which Riser Card being used(QSGMII or SGMII Riser Card), - *then set the correct PHY address - */ -void set_sgmii_phy(struct mii_dev *bus, enum fm_port base_port, - unsigned int port_num, int phy_base_addr) -{ - unsigned int regnum = 0; - int qsgmii; - int i; - int phy_real_addr; - - qsgmii = is_qsgmii_riser_card(bus, phy_base_addr, port_num, regnum); - - if (!qsgmii) - return; - - for (i = base_port; i < base_port + port_num; i++) { - if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_SGMII) { - phy_real_addr = phy_base_addr + i - base_port; - fm_info_set_phy_address(i, phy_real_addr); - } - } -} - -/*to check whether qsgmii riser card is used*/ -int is_qsgmii_riser_card(struct mii_dev *bus, int phy_base_addr, - unsigned int port_num, unsigned regnum) -{ - int i; - int val; - - if (!bus) - return 0; - - for (i = phy_base_addr; i < phy_base_addr + port_num; i++) { - val = bus->read(bus, i, MDIO_DEVAD_NONE, regnum); - if (val != MIIM_TIMEOUT) - return 1; - } - - return 0; -} -#endif /* CONFIG_DM_ETH */ diff --git a/drivers/net/fm/memac_phy.c b/drivers/net/fm/memac_phy.c index 3ddae97e09..e0b62b9449 100644 --- a/drivers/net/fm/memac_phy.c +++ b/drivers/net/fm/memac_phy.c @@ -22,11 +22,9 @@ #define memac_setbits_32(a, v) setbits_be32(a, v) #endif -#ifdef CONFIG_DM_ETH struct fm_mdio_priv { struct memac_mdio_controller *regs; }; -#endif #define MAX_NUM_RETRIES 1000 @@ -88,9 +86,6 @@ int memac_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr, u32 c45 = 1; /* Default to 10G interface */ int err; -#ifndef CONFIG_DM_ETH - regs = bus->priv; -#else struct fm_mdio_priv *priv; if (!bus->priv) @@ -99,7 +94,6 @@ int memac_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr, regs = priv->regs; debug("memac_mdio_write(regs %p, port %d, dev %d, reg %d, val %#x)\n", regs, port_addr, dev_addr, regnum, value); -#endif if (dev_addr == MDIO_DEVAD_NONE) { c45 = 0; /* clause 22 */ @@ -147,22 +141,14 @@ int memac_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr, u32 c45 = 1; int err; -#ifndef CONFIG_DM_ETH - regs = bus->priv; -#else struct fm_mdio_priv *priv; if (!bus->priv) return -EINVAL; priv = dev_get_priv(bus->priv); regs = priv->regs; -#endif if (dev_addr == MDIO_DEVAD_NONE) { -#ifndef CONFIG_DM_ETH - if (!strcmp(bus->name, DEFAULT_FM_TGEC_MDIO_NAME)) - return 0xffff; -#endif c45 = 0; /* clause 22 */ dev_addr = regnum & 0x1f; memac_clrbits_32(®s->mdio_stat, MDIO_STAT_ENC); @@ -205,43 +191,6 @@ int memac_mdio_reset(struct mii_dev *bus) return 0; } -#ifndef CONFIG_DM_ETH -int fm_memac_mdio_init(struct bd_info *bis, struct memac_mdio_info *info) -{ - struct mii_dev *bus = mdio_alloc(); - - if (!bus) { - printf("Failed to allocate FM TGEC MDIO bus\n"); - return -1; - } - - bus->read = memac_mdio_read; - bus->write = memac_mdio_write; - bus->reset = memac_mdio_reset; - strcpy(bus->name, info->name); - - bus->priv = info->regs; - - /* - * On some platforms like B4860, default value of MDIO_CLK_DIV bits - * in mdio_stat(mdio_cfg) register generates MDIO clock too high - * (much higher than 2.5MHz), violating the IEEE specs. - * On other platforms like T1040, default value of MDIO_CLK_DIV bits - * is zero, so MDIO clock is disabled. - * So, for proper functioning of MDIO, MDIO_CLK_DIV bits needs to - * be properly initialized. - * NEG bit default should be '1' as per FMAN-v3 RM, but on platform - * like T2080QDS, this bit default is '0', which leads to MDIO failure - * on XAUI PHY, so set this bit definitely. - */ - memac_setbits_32( - &((struct memac_mdio_controller *)info->regs)->mdio_stat, - MDIO_STAT_CLKDIV(258) | MDIO_STAT_NEG); - - return mdio_register(bus); -} - -#else /* CONFIG_DM_ETH */ #if defined(CONFIG_PHYLIB) && defined(CONFIG_DM_MDIO) static int fm_mdio_read(struct udevice *dev, int addr, int devad, int reg) { @@ -341,4 +290,3 @@ U_BOOT_DRIVER(fman_mdio) = { .plat_auto = sizeof(struct mdio_perdev_priv), }; #endif /* CONFIG_PHYLIB && CONFIG_DM_MDIO */ -#endif /* CONFIG_DM_ETH */