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 9FC7EC46467 for ; Thu, 19 Jan 2023 21:47:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9CA01856AD; Thu, 19 Jan 2023 22:45:53 +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=1674164754; bh=KrKbCjrce0qcfm18sLZpJeUjNoV6UIO4AfnDSHks3J8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uO5foHNgSagMvgvDH9Vz/KxRmf7yqzQFXFhEk8MqLKksqr8DVd/reg5k7CVdWhLbg 0302516sO0V2jFvqaExJ4DJCUMzTkVnQaHXP/zWWpzuolLFfm4cBuITBL6wRcbmJ7v exqG+MYY4SA6YXbaIHq0+QQ4CYOiSJ4A9GbqaVALD60fJvS8IehBGmXYTk9ffnacK1 fGWS4t/5oZ8lrCIFEcsIdDAOjvauwOAtQwomSr6LUou6P1kEPwdaahJb+LPO1BoDFH cikJBi3q9lbCm/T7FWxN0ZfDg09ovJoJg7amIXUvrrj7f75eglVRq+WdlQTVAdUCNt PkoabX+Q8b/Hg== 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 E226785678; Thu, 19 Jan 2023 22:45:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1674164711; bh=KrKbCjrce0qcfm18sLZpJeUjNoV6UIO4AfnDSHks3J8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GRLDWlztAQgzb3ja5DUYjr/kBum/qUNevH+y7qFwNSDHYTQPV7MZio9ths7rFY1vO 7gg2UjotLfs3OMZa/XTFbZqRu/Xan3s7hLCt9BXYMGyVYmKibIqhCqbmH//ouOIkzG 0cuRFHwM9hKcrKWdV3G7Avh4xb+AAFa5E+RZnvPqgdjW7Akzsyq66jX7yOe6arjTpi JhT7AVA2xuvUbs416OhOjwZCoTBmtywAoU3S5JrRS6s1eR8/hqRq+wx8XkEs5POaE6 wW5Fn7mlrtx1/HBibK5q1FxUINbnkAxLY0W5SEmG2UwPxTinWOmvbp9oKAVoKjGfBA ny+x7v8vCstXw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , "Ariel D'Alessandro" , "NXP i.MX U-Boot Team" , Andrey Zhizhikin , Fabio Estevam , Joe Hershberger , Lukasz Majewski , Marcel Ziswiler , Michael Trimarchi , Peng Fan , Ramon Fried , Sean Anderson , Stefano Babic , Tim Harvey , Tommaso Merciai Subject: [PATCH 6/9] net: dwc_eth_qos: Add i.MX8M Plus RMII support Date: Thu, 19 Jan 2023 22:44:50 +0100 Message-Id: <20230119214453.174991-6-marex@denx.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119214453.174991-1-marex@denx.de> References: <20230119214453.174991-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>; 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 --- drivers/net/dwc_eth_qos_imx.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/dwc_eth_qos_imx.c b/drivers/net/dwc_eth_qos_imx.c index d0b7ef75c26..55080257623 100644 --- a/drivers/net/dwc_eth_qos_imx.c +++ b/drivers/net/dwc_eth_qos_imx.c @@ -178,21 +178,25 @@ 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) { + 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.0