From: Biao Huang <biao.huang@mediatek.com>
To: David Miller <davem@davemloft.net>,
Rob Herring <robh+dt@kernel.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Fabien Parent <fparent@baylibre.com>
Cc: Jakub Kicinski <kuba@kernel.org>, Felix Fietkau <nbd@nbd.name>,
John Crispin <john@phrozen.org>,
Sean Wang <sean.wang@mediatek.com>,
Mark Lee <Mark-MC.Lee@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
<netdev@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
Biao Huang <biao.huang@mediatek.com>,
Yinghua Pan <ot_yinghua.pan@mediatek.com>,
<srv_heupstream@mediatek.com>,
Macpaul Lin <macpaul.lin@mediatek.com>
Subject: [PATCH net-next v3 05/10] net: ethernet: mtk-star-emac: add clock pad selection for RMII
Date: Wed, 22 Jun 2022 17:05:40 +0800 [thread overview]
Message-ID: <20220622090545.23612-6-biao.huang@mediatek.com> (raw)
In-Reply-To: <20220622090545.23612-1-biao.huang@mediatek.com>
This patch add a new dts property named "mediatek,rmii-rxc" parsing
in driver, which will configure MAC to select which pin the RMII reference
clock is connected to, TXC or RXC.
TXC pad is the default reference clock pin. If user wants to use RXC pad
instead, add "mediatek,rmii-rxc" to corresponding device node.
Signed-off-by: Biao Huang <biao.huang@mediatek.com>
Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com>
---
drivers/net/ethernet/mediatek/mtk_star_emac.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c
index 3776af9ac1ff..b4d37728be69 100644
--- a/drivers/net/ethernet/mediatek/mtk_star_emac.c
+++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c
@@ -188,6 +188,8 @@ static const char *const mtk_star_clk_names[] = { "core", "reg", "trans" };
#define MTK_PERICFG_REG_NIC_CFG_CON_V2 0x0c10
#define MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF GENMASK(3, 0)
#define MTK_PERICFG_BIT_NIC_CFG_CON_RMII 1
+#define MTK_PERICFG_BIT_NIC_CFG_CON_CLK BIT(0)
+#define MTK_PERICFG_BIT_NIC_CFG_CON_CLK_V2 BIT(8)
/* Represents the actual structure of descriptors used by the MAC. We can
* reuse the same structure for both TX and RX - the layout is the same, only
@@ -264,6 +266,7 @@ struct mtk_star_priv {
int speed;
int duplex;
int pause;
+ bool rmii_rxc;
const struct mtk_star_compat *compat_data;
@@ -1527,6 +1530,8 @@ static int mtk_star_probe(struct platform_device *pdev)
return -ENODEV;
}
+ priv->rmii_rxc = of_property_read_bool(of_node, "mediatek,rmii-rxc");
+
if (priv->compat_data->set_interface_mode) {
ret = priv->compat_data->set_interface_mode(ndev);
if (ret) {
@@ -1571,17 +1576,25 @@ static int mt8516_set_interface_mode(struct net_device *ndev)
{
struct mtk_star_priv *priv = netdev_priv(ndev);
struct device *dev = mtk_star_get_dev(priv);
- unsigned int intf_val;
+ unsigned int intf_val, ret, rmii_rxc;
switch (priv->phy_intf) {
case PHY_INTERFACE_MODE_RMII:
intf_val = MTK_PERICFG_BIT_NIC_CFG_CON_RMII;
+ rmii_rxc = priv->rmii_rxc ? 0 : MTK_PERICFG_BIT_NIC_CFG_CON_CLK;
break;
default:
dev_err(dev, "This interface not supported\n");
return -EINVAL;
}
+ ret = regmap_update_bits(priv->pericfg,
+ MTK_PERICFG_REG_NIC_CFG1_CON,
+ MTK_PERICFG_BIT_NIC_CFG_CON_CLK,
+ rmii_rxc);
+ if (ret)
+ return ret;
+
return regmap_update_bits(priv->pericfg,
MTK_PERICFG_REG_NIC_CFG0_CON,
MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF,
@@ -1597,6 +1610,7 @@ static int mt8365_set_interface_mode(struct net_device *ndev)
switch (priv->phy_intf) {
case PHY_INTERFACE_MODE_RMII:
intf_val = MTK_PERICFG_BIT_NIC_CFG_CON_RMII;
+ intf_val |= priv->rmii_rxc ? 0 : MTK_PERICFG_BIT_NIC_CFG_CON_CLK_V2;
break;
default:
dev_err(dev, "This interface not supported\n");
@@ -1605,7 +1619,8 @@ static int mt8365_set_interface_mode(struct net_device *ndev)
return regmap_update_bits(priv->pericfg,
MTK_PERICFG_REG_NIC_CFG_CON_V2,
- MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF,
+ MTK_PERICFG_REG_NIC_CFG_CON_CFG_INTF |
+ MTK_PERICFG_BIT_NIC_CFG_CON_CLK_V2,
intf_val);
}
--
2.25.1
next prev parent reply other threads:[~2022-06-22 9:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 9:05 [PATCH net-next v3 00/10] add more features for mtk-star-emac Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 01/10] net: ethernet: mtk-star-emac: store bit_clk_div in compat structure Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 02/10] net: ethernet: mtk-star-emac: modify IRQ trigger flags Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 03/10] net: ethernet: mtk-star-emac: add support for MT8365 SoC Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 04/10] dt-bindings: net: mtk-star-emac: add support for MT8365 Biao Huang
2022-06-22 9:05 ` Biao Huang [this message]
2022-06-22 9:05 ` [PATCH net-next v3 06/10] net: ethernet: mtk-star-emac: add timing adjustment support Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 07/10] dt-bindings: net: mtk-star-emac: add description for new properties Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 08/10] net: ethernet: mtk-star-emac: add support for MII interface Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 09/10] net: ethernet: mtk-star-emac: separate tx/rx handling with two NAPIs Biao Huang
2022-06-24 4:34 ` Jakub Kicinski
2022-06-28 5:44 ` Biao Huang
2022-06-22 9:05 ` [PATCH net-next v3 10/10] net: ethernet: mtk-star-emac: enable half duplex hardware support Biao Huang
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=20220622090545.23612-6-biao.huang@mediatek.com \
--to=biao.huang@mediatek.com \
--cc=Mark-MC.Lee@mediatek.com \
--cc=brgl@bgdev.pl \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=fparent@baylibre.com \
--cc=john@phrozen.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=macpaul.lin@mediatek.com \
--cc=matthias.bgg@gmail.com \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=ot_yinghua.pan@mediatek.com \
--cc=robh+dt@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=srv_heupstream@mediatek.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).