From: Joakim Zhang <qiangqing.zhang@nxp.com>
To: peppe.cavallaro@st.com, alexandre.torgue@st.com,
joabreu@synopsys.com, davem@davemloft.net, kuba@kernel.org
Cc: linux-imx@nxp.com, netdev@vger.kernel.org
Subject: [PATCH] net: stmmac: implement .set_intf_mode() callback for imx8dxl
Date: Thu, 3 Dec 2020 12:10:38 +0800 [thread overview]
Message-ID: <20201203041038.32440-1-qiangqing.zhang@nxp.com> (raw)
From: Fugang Duan <fugang.duan@nxp.com>
Implement .set_intf_mode() callback for imx8dxl.
Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-imx.c | 34 ++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index 223f69da7e95..1d0a4d73add6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -6,7 +6,9 @@
*
*/
+#include <dt-bindings/firmware/imx/rsrc.h>
#include <linux/clk.h>
+#include <linux/firmware/imx/sci.h>
#include <linux/gpio/consumer.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
@@ -86,7 +88,37 @@ imx8dxl_set_intf_mode(struct plat_stmmacenet_data *plat_dat)
{
int ret = 0;
- /* TBD: depends on imx8dxl scu interfaces to be upstreamed */
+ struct imx_sc_ipc *ipc_handle;
+ int val;
+
+ ret = imx_scu_get_handle(&ipc_handle);
+ if (ret)
+ return ret;
+
+ switch (plat_dat->interface) {
+ case PHY_INTERFACE_MODE_MII:
+ val = GPR_ENET_QOS_INTF_SEL_MII;
+ break;
+ case PHY_INTERFACE_MODE_RMII:
+ val = GPR_ENET_QOS_INTF_SEL_RMII;
+ break;
+ case PHY_INTERFACE_MODE_RGMII:
+ case PHY_INTERFACE_MODE_RGMII_ID:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ val = GPR_ENET_QOS_INTF_SEL_RGMII;
+ break;
+ default:
+ pr_debug("imx dwmac doesn't support %d interface\n",
+ plat_dat->interface);
+ return -EINVAL;
+ }
+
+ ret = imx_sc_misc_set_control(ipc_handle, IMX_SC_R_ENET_1,
+ IMX_SC_C_INTF_SEL, val >> 16);
+ ret |= imx_sc_misc_set_control(ipc_handle, IMX_SC_R_ENET_1,
+ IMX_SC_C_CLK_GEN_EN, 0x1);
+
return ret;
}
--
2.17.1
next reply other threads:[~2020-12-03 4:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 4:10 Joakim Zhang [this message]
2020-12-05 19:58 ` [PATCH] net: stmmac: implement .set_intf_mode() callback for imx8dxl Jakub Kicinski
2020-12-07 8:15 ` Joakim Zhang
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=20201203041038.32440-1-qiangqing.zhang@nxp.com \
--to=qiangqing.zhang@nxp.com \
--cc=alexandre.torgue@st.com \
--cc=davem@davemloft.net \
--cc=joabreu@synopsys.com \
--cc=kuba@kernel.org \
--cc=linux-imx@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.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;
as well as URLs for NNTP newsgroup(s).