From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>, Ramon Fried <rfried.dev@gmail.com>,
"Ariel D'Alessandro" <ariel.dalessandro@collabora.com>,
"NXP i.MX U-Boot Team" <uboot-imx@nxp.com>,
Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>,
Fabio Estevam <festevam@gmail.com>,
Joe Hershberger <joe.hershberger@ni.com>,
Lukasz Majewski <lukma@denx.de>,
Marcel Ziswiler <marcel.ziswiler@toradex.com>,
Michael Trimarchi <michael@amarulasolutions.com>,
Peng Fan <peng.fan@nxp.com>, Sean Anderson <seanga2@gmail.com>,
Stefano Babic <sbabic@denx.de>,
Tim Harvey <tharvey@gateworks.com>,
Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Subject: [PATCH v2 07/10] net: dwc_eth_qos: Add i.MX8M Plus RMII support
Date: Thu, 9 Feb 2023 22:50:45 +0100 [thread overview]
Message-ID: <20230209215048.259223-7-marex@denx.de> (raw)
In-Reply-To: <20230209215048.259223-1-marex@denx.de>
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 <rfried.dev@gmail.com>
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: "Ariel D'Alessandro" <ariel.dalessandro@collabora.com>
Cc: "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
Cc: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Lukasz Majewski <lukma@denx.de>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Michael Trimarchi <michael@amarulasolutions.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Cc: u-boot@lists.denx.de
---
V2: Add RB from Ramon
---
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 f5f3f2099f0..fb4e6d38e24 100644
--- a/drivers/net/dwc_eth_qos_imx.c
+++ b/drivers/net/dwc_eth_qos_imx.c
@@ -179,21 +179,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.1
next prev parent reply other threads:[~2023-02-09 21:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 21:50 [PATCH v2 01/10] clk: imx8mp: Add EQoS MAC clock Marek Vasut
2023-02-09 21:50 ` [PATCH v2 02/10] net: dwc_eth_qos: Drop bogus return after goto Marek Vasut
2023-02-09 21:50 ` [PATCH v2 03/10] net: dwc_eth_qos: Drop unused dm_gpio_free() on STM32 Marek Vasut
2023-02-09 21:50 ` [PATCH v2 04/10] net: dwc_eth_qos: Staticize eqos_inval_buffer_tegra186() Marek Vasut
2023-02-09 21:50 ` [PATCH v2 05/10] net: dwc_eth_qos: Set DMA_MODE SWR bit to reset the MAC Marek Vasut
2023-02-09 21:50 ` [PATCH v2 06/10] net: dwc_eth_qos: Add DM CLK support for i.MX8M Plus Marek Vasut
2023-02-12 17:57 ` Sean Anderson
2023-02-09 21:50 ` Marek Vasut [this message]
2023-02-09 21:50 ` [PATCH v2 08/10] net: dwc_eth_qos: Add board_interface_eth_init() " Marek Vasut
2023-02-09 21:50 ` [PATCH v2 09/10] arm64: dts: imx8mp: Drop EQoS clock workaround Marek Vasut
2023-02-09 21:50 ` [PATCH v2 10/10] arm64: imx8mp: Drop EQoS GPR[1] board workaround Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230209215048.259223-7-marex@denx.de \
--to=marex@denx.de \
--cc=andrey.zhizhikin@leica-geosystems.com \
--cc=ariel.dalessandro@collabora.com \
--cc=festevam@gmail.com \
--cc=joe.hershberger@ni.com \
--cc=lukma@denx.de \
--cc=marcel.ziswiler@toradex.com \
--cc=michael@amarulasolutions.com \
--cc=peng.fan@nxp.com \
--cc=rfried.dev@gmail.com \
--cc=sbabic@denx.de \
--cc=seanga2@gmail.com \
--cc=tharvey@gateworks.com \
--cc=tommaso.merciai@amarulasolutions.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-imx@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox