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 51E85C61DA4 for ; Sat, 11 Feb 2023 21:49:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id ABA2885726; Sat, 11 Feb 2023 22:48:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1676152116; bh=fMYYkXrCcPUqNpdqe1e8LAgssbB4poNs/xzB6DA714A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=wp/qte+vXgZqLaRMFMZ6oTrhDMOfr2EDs+iPaD2FmLYlQq5HXzK1YeBItbdyhZKaf PHd9WfpqBkYEpKrg89nLtNvvzifMkobBAFNcrC4SLJKPz2WL/wbI3SY9V8ywjvlG3h /R7Ayj6QYz991iCjrYhN9IrmreCPKI6zAouSI6peCBjzA0krC3moh8KDX63i2MBLVo CKI6t92US0JojPR3tQCC6vAn8ZZ5gwPndCjlgwRN3EKbb0W6GTQ2FVznaL10uS2nyK znaKlVjfvQZIMOYFT9Z6vXkxStx/x/hbmLWc4wXyv98Sv1KXTgcDbk9nutblNpkzS8 hv3R/6HAKNseg== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 78BD08564B; Sat, 11 Feb 2023 22:47:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1676152076; bh=fMYYkXrCcPUqNpdqe1e8LAgssbB4poNs/xzB6DA714A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z7h4DZMRv6gZp08rXdSyv6xpYy8tED+qe2EPPuIiHGXbhWHB3ChBORZzbGzsE9LL/ IsZb66Y/UaD3q2rRvX8iPuommKhKanRE3sThtDUaUzeNo6gdYW/AekIrHn8oLFyPLd hk8CrtR3mqSdjQJy748ZabrrohPn7386FpHdSx6Tcg5+eIGz9U19aD+e+6Z4s+jyVm VlFMBjzsvvCGaShODrLxPxQVzFAAyKKxvdQyp7phKckaX047m7ixZfRvcutU8fwb4M 5LAmZR1cedx4eg/gfCF5DaZIViYxi7K83ExebanPbNcWUfSeWZI2iSNG3D/hk2W9fW 6JWXTHzvulwyw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Ramon Fried , "Ariel D'Alessandro" , "NXP i.MX U-Boot Team" , Andrey Zhizhikin , Fabio Estevam , Joe Hershberger , Lukasz Majewski , Marcel Ziswiler , Michael Trimarchi , Peng Fan , Sean Anderson , Stefano Babic , Tim Harvey , Tommaso Merciai Subject: [PATCH v3 08/14] net: dwc_eth_qos: Add i.MX8M Plus RMII support Date: Sat, 11 Feb 2023 22:47:23 +0100 Message-Id: <20230211214729.478566-8-marex@denx.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230211214729.478566-1-marex@denx.de> References: <20230211214729.478566-1-marex@denx.de> MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean With DM clock support in place, it is easy to add RMII support into the MAC driver. The RMII cannot operate at 1000 Mbps and at 100 and 10 Mbps the clock frequency is 50 MHz and 5 MHz instead of 25 MHz and 2.5 MHz. The board DT requires the following adjustments to EQoS node: phy-mode = "rmii"; assigned-clock-parents = <&clk IMX8MP_SYS_PLL1_266M>, <&clk IMX8MP_SYS_PLL2_100M>, <&clk IMX8MP_SYS_PLL2_50M>; assigned-clock-rates = <0>, <100000000>, <50000000>; Reviewed-by: Ramon Fried Signed-off-by: Marek Vasut --- Cc: "Ariel D'Alessandro" Cc: "NXP i.MX U-Boot Team" Cc: Andrey Zhizhikin Cc: Fabio Estevam Cc: Joe Hershberger Cc: Lukasz Majewski Cc: Marcel Ziswiler Cc: Marek Vasut Cc: Michael Trimarchi Cc: Peng Fan Cc: Ramon Fried Cc: Sean Anderson Cc: Stefano Babic Cc: Tim Harvey Cc: Tommaso Merciai Cc: u-boot@lists.denx.de --- V2: Add RB from Ramon V3: Handle RGMII_*ID variants --- drivers/net/dwc_eth_qos_imx.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/net/dwc_eth_qos_imx.c b/drivers/net/dwc_eth_qos_imx.c index f5f3f2099f0..962c5373243 100644 --- a/drivers/net/dwc_eth_qos_imx.c +++ b/drivers/net/dwc_eth_qos_imx.c @@ -179,21 +179,28 @@ static int eqos_set_tx_clk_speed_imx(struct udevice *dev) debug("%s(dev=%p):\n", __func__, dev); - switch (eqos->phy->speed) { - case SPEED_1000: - rate = 125 * 1000 * 1000; - break; - case SPEED_100: - rate = 25 * 1000 * 1000; - break; - case SPEED_10: - rate = 2.5 * 1000 * 1000; - break; - default: + if (eqos->phy->interface == PHY_INTERFACE_MODE_RMII) + rate = 5000; /* 5000 kHz = 5 MHz */ + else + rate = 2500; /* 2500 kHz = 2.5 MHz */ + + if (eqos->phy->speed == SPEED_1000 && + (eqos->phy->interface == PHY_INTERFACE_MODE_RGMII || + eqos->phy->interface == PHY_INTERFACE_MODE_RGMII_ID || + eqos->phy->interface == PHY_INTERFACE_MODE_RGMII_RXID || + eqos->phy->interface == PHY_INTERFACE_MODE_RGMII_TXID)) { + rate *= 50; /* Use 50x base rate i.e. 125 MHz */ + } else if (eqos->phy->speed == SPEED_100) { + rate *= 10; /* Use 10x base rate */ + } else if (eqos->phy->speed == SPEED_10) { + rate *= 1; /* Use base rate */ + } else { pr_err("invalid speed %d", eqos->phy->speed); return -EINVAL; } + rate *= 1000; /* clk_set_rate() operates in Hz */ + ret = clk_set_rate(&eqos->clk_tx, rate); if (ret < 0) { pr_err("imx (tx_clk, %lu) failed: %d", rate, ret); -- 2.39.1