From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE555C433EF for ; Wed, 27 Apr 2022 10:46:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6339883E9B; Wed, 27 Apr 2022 12:45:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="p/h6TMUZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB84683D3D; Wed, 27 Apr 2022 12:43:15 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D09F383EEC for ; Wed, 27 Apr 2022 12:42:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kabel@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4D43F61D41; Wed, 27 Apr 2022 10:42:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23541C385AF; Wed, 27 Apr 2022 10:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651056161; bh=o3pSrISZnBeagEMsdKXsNmddgsuDadx2ZA1k2z1MtUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p/h6TMUZQDl9ynAN+CJ6Wx3VCpnpB9oY/qOrOIQUFxmjV0KItIsVYdJHrXQLdOWUc ZoTP2Ae+fnD7nMAADnF3hWtbKNlBbPIqOgRSOcgM4sNz2RzellOeZIcd42Q5gDCV1a j5vTKgdDMYyUr5AtWL2WngijhSD6LqCk+xpSlZb+ORGsFmqXzP9amDrd9PVz4mU9WN aSF8b1aM5AaQtqr/QZH6Zx5x2GRcC5gijZlImAXst5PjeNDtkX0dbVi1NEhSU/XmNG 9mezR8mu9rfjT5lGS4VpHaPOxY/fL7Yi7z7zMJen7Mv7L8qCAm+bEucFCCDlAG6J45 UpQGfNBoU/y1A== From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: Stefan Roese Cc: Robert Marko , =?UTF-8?q?Pali=20Roh=C3=A1r?= , U-Boot-Denx , Ramon Fried , Joe Hershberger , =?UTF-8?q?Marek=20Beh=C3=BAn?= Subject: [PATCH u-boot-marvell 15/19] net: mvneta: Convert to use PHY_FIXED for fixed-link Date: Wed, 27 Apr 2022 12:41:58 +0200 Message-Id: <20220427104202.1205-16-kabel@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220427104202.1205-1-kabel@kernel.org> References: <20220427104202.1205-1-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: Marek BehĂșn Stop parsing fixed-link in the MAC driver. Instead support only PHY mode and let the fixed PHY driver handle the fixed-link case. Enable CONFIG_PHY_FIXED for mvneta boards that need it: Turris Omnia and ESPRESSObin. Signed-off-by: Marek BehĂșn --- configs/mvebu_espressobin-88f3720_defconfig | 1 + configs/turris_omnia_defconfig | 1 + drivers/net/mvneta.c | 98 ++++++++------------- 3 files changed, 39 insertions(+), 61 deletions(-) diff --git a/configs/mvebu_espressobin-88f3720_defconfig b/configs/mvebu_espressobin-88f3720_defconfig index 37e4fdc41e..8d7d57ff1b 100644 --- a/configs/mvebu_espressobin-88f3720_defconfig +++ b/configs/mvebu_espressobin-88f3720_defconfig @@ -74,6 +74,7 @@ CONFIG_SPI_FLASH_STMICRO=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_SPI_FLASH_MTD=y CONFIG_PHY_MARVELL=y +CONFIG_PHY_FIXED=y CONFIG_PHY_GIGE=y CONFIG_E1000=y CONFIG_MVNETA=y diff --git a/configs/turris_omnia_defconfig b/configs/turris_omnia_defconfig index 6b218bd7a7..bdd70f2ba7 100644 --- a/configs/turris_omnia_defconfig +++ b/configs/turris_omnia_defconfig @@ -79,6 +79,7 @@ CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_MTD=y CONFIG_PHY_MARVELL=y +CONFIG_PHY_FIXED=y CONFIG_PHY_GIGE=y CONFIG_MVNETA=y CONFIG_MII=y diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index 519e06ff01..5b1c4fe5fc 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -1152,11 +1152,6 @@ static void mvneta_adjust_link(struct udevice *dev) struct phy_device *phydev = pp->phydev; bool status_change = false; - if (pp->fixed_link) { - debug("Using fixed link, skip link adjust\n"); - return; - } - if (phydev->link && (pp->speed != phydev->speed || pp->duplex != phydev->duplex)) { u32 val; @@ -1168,6 +1163,21 @@ static void mvneta_adjust_link(struct udevice *dev) MVNETA_GMAC_AN_SPEED_EN | MVNETA_GMAC_AN_DUPLEX_EN); + /* FIXME: For fixed-link case, these were the initial settings + * used before the code was converted to use PHY_FIXED. Some of + * these may look nonsensical (for example BYPASS_AN makes sense + * for 1000base-x and 2500base-x modes, AFAIK), and in fact this + * may be changed in the future (when support for inband AN will + * be added). Also, why is ADVERT_FC enabled if we don't enable + * inband AN at all? + */ + if (pp->fixed_link) + val = MVNETA_GMAC_FORCE_LINK_UP | + MVNETA_GMAC_IB_BYPASS_AN_EN | + MVNETA_GMAC_SET_FC_EN | + MVNETA_GMAC_ADVERT_FC_EN | + MVNETA_GMAC_SAMPLE_TX_CFG_EN; + if (phydev->duplex) val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX; @@ -1413,56 +1423,34 @@ static int mvneta_start(struct udevice *dev) mvneta_port_power_up(pp, pp->phy_interface); if (!pp->init || pp->link == 0) { - if (pp->fixed_link) { - u32 val; - - pp->init = 1; - pp->link = 1; - mvneta_init(dev); - - val = MVNETA_GMAC_FORCE_LINK_UP | - MVNETA_GMAC_IB_BYPASS_AN_EN | - MVNETA_GMAC_SET_FC_EN | - MVNETA_GMAC_ADVERT_FC_EN | - MVNETA_GMAC_SAMPLE_TX_CFG_EN; - - if (pp->duplex) - val |= MVNETA_GMAC_CONFIG_FULL_DUPLEX; - - if (pp->speed == SPEED_1000) - val |= MVNETA_GMAC_CONFIG_GMII_SPEED; - else if (pp->speed == SPEED_100) - val |= MVNETA_GMAC_CONFIG_MII_SPEED; + phydev = dm_eth_phy_connect(dev); + if (!phydev) { + printf("dm_eth_phy_connect failed\n"); + return -ENODEV; + } - mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val); - } else { - phydev = dm_eth_phy_connect(dev); - if (!phydev) { - printf("dm_eth_phy_connect failed\n"); - return -ENODEV; - } + pp->fixed_link = phydev->phy_id == PHY_FIXED_ID; - /* Set PHY address in case we will enable HW polling */ + /* Set PHY address in case we will enable HW polling */ + if (!pp->fixed_link) mvreg_write(pp, MVNETA_PHY_ADDR, phydev->addr); - pp->phydev = phydev; - phy_config(phydev); - phy_startup(phydev); - if (!phydev->link) { - printf("%s: No link.\n", phydev->dev->name); - return -1; - } - - /* Full init on first call */ - mvneta_init(dev); - pp->init = 1; - return 0; + pp->phydev = phydev; + phy_config(phydev); + phy_startup(phydev); + if (!phydev->link) { + printf("%s: No link.\n", phydev->dev->name); + return -1; } - } - /* Upon all following calls, this is enough */ - mvneta_port_up(pp); - mvneta_port_enable(pp); + /* Full init on first call */ + mvneta_init(dev); + pp->init = 1; + } else { + /* Upon all following calls, this is enough */ + mvneta_port_up(pp); + mvneta_port_enable(pp); + } return 0; } @@ -1560,10 +1548,7 @@ static int mvneta_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(DM_GPIO) struct ofnode_phandle_args sfp_args; #endif - void *blob = (void *)gd->fdt_blob; - int node = dev_of_offset(dev); void *bd_space; - int fl_node; /* * Allocate buffer area for descs and rx_buffers. This is only @@ -1600,15 +1585,6 @@ static int mvneta_probe(struct udevice *dev) else mvneta_conf_mbus_windows(pp); - /* fetch 'fixed-link' property from 'neta' node */ - fl_node = fdt_subnode_offset(blob, node, "fixed-link"); - if (fl_node != -FDT_ERR_NOTFOUND) { - /* set phy_addr to invalid value for fixed link */ - pp->duplex = fdtdec_get_bool(blob, fl_node, "full-duplex"); - pp->speed = fdtdec_get_int(blob, fl_node, "speed", 0); - pp->fixed_link = true; - } - #if CONFIG_IS_ENABLED(DM_GPIO) if (!dev_read_phandle_with_args(dev, "sfp", NULL, 0, 0, &sfp_args) && ofnode_is_enabled(sfp_args.node)) -- 2.35.1