All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 net-next 0/2] add interface mode select and RMII
@ 2022-08-22  1:59 wei.fang
  2022-08-22  1:59 ` [PATCH V2 net-next 1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property wei.fang
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: wei.fang @ 2022-08-22  1:59 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt,
	andrew, f.fainelli, hkallweit1, linux
  Cc: netdev, devicetree, linux-kernel

From: Wei Fang <wei.fang@nxp.com>

The patches add the below feature support for both TJA1100 and
TJA1101 PHYs cards:
- Add MII and RMII mode support.
- Add REF_CLK input/output support for RMII mode.

Wei Fang (2):
  dt-bindings: net: tja11xx: add nxp,refclk_in property
  net: phy: tja11xx: add interface mode and RMII REF_CLK support

 .../devicetree/bindings/net/nxp,tja11xx.yaml  | 17 ++++
 drivers/net/phy/nxp-tja11xx.c                 | 83 +++++++++++++++++--
 2 files changed, 95 insertions(+), 5 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH V2 net-next 1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property
  2022-08-22  1:59 [PATCH V2 net-next 0/2] add interface mode select and RMII wei.fang
@ 2022-08-22  1:59 ` wei.fang
  2022-08-22 21:36   ` Rob Herring
  2022-08-22  1:59 ` [PATCH V2 net-next 2/2] net: phy: tja11xx: add interface mode and RMII REF_CLK support wei.fang
  2022-08-24  0:50 ` [PATCH V2 net-next 0/2] add interface mode select and RMII patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: wei.fang @ 2022-08-22  1:59 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt,
	andrew, f.fainelli, hkallweit1, linux
  Cc: netdev, devicetree, linux-kernel

From: Wei Fang <wei.fang@nxp.com>

TJA110x REF_CLK can be configured as interface reference clock
intput or output when the RMII mode enabled. This patch add the
property to make the REF_CLK can be configurable.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
V2 change:
Correct the property name and a typo.
---
 .../devicetree/bindings/net/nxp,tja11xx.yaml    | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/nxp,tja11xx.yaml b/Documentation/devicetree/bindings/net/nxp,tja11xx.yaml
index d51da24f3505..ab8867e6939b 100644
--- a/Documentation/devicetree/bindings/net/nxp,tja11xx.yaml
+++ b/Documentation/devicetree/bindings/net/nxp,tja11xx.yaml
@@ -31,6 +31,22 @@ patternProperties:
         description:
           The ID number for the child PHY. Should be +1 of parent PHY.
 
+      nxp,rmii-refclk-in:
+        type: boolean
+        description: |
+          The REF_CLK is provided for both transmitted and received data
+          in RMII mode. This clock signal is provided by the PHY and is
+          typically derived from an external 25MHz crystal. Alternatively,
+          a 50MHz clock signal generated by an external oscillator can be
+          connected to pin REF_CLK. A third option is to connect a 25MHz
+          clock to pin CLK_IN_OUT. So, the REF_CLK should be configured
+          as input or output according to the actual circuit connection.
+          If present, indicates that the REF_CLK will be configured as
+          interface reference clock input when RMII mode enabled.
+          If not present, the REF_CLK will be configured as interface
+          reference clock output when RMII mode enabled.
+          Only supported on TJA1100 and TJA1101.
+
     required:
       - reg
 
@@ -44,6 +60,7 @@ examples:
 
         tja1101_phy0: ethernet-phy@4 {
             reg = <0x4>;
+            nxp,rmii-refclk-in;
         };
     };
   - |
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH V2 net-next 2/2] net: phy: tja11xx: add interface mode and RMII REF_CLK support
  2022-08-22  1:59 [PATCH V2 net-next 0/2] add interface mode select and RMII wei.fang
  2022-08-22  1:59 ` [PATCH V2 net-next 1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property wei.fang
@ 2022-08-22  1:59 ` wei.fang
  2022-08-24  0:50 ` [PATCH V2 net-next 0/2] add interface mode select and RMII patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: wei.fang @ 2022-08-22  1:59 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt,
	andrew, f.fainelli, hkallweit1, linux
  Cc: netdev, devicetree, linux-kernel

From: Wei Fang <wei.fang@nxp.com>

Add below features support for both TJA1100 and TJA1101 cards:
- Add MII and RMII mode support.
- Add REF_CLK input/output support for RMII mode.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
---
V2 change:
1. Correct the property name to "nxp,rmii-refclk-in".
2. Modify the "quirks" of struct tja11xx_priv to "flags".
---
 drivers/net/phy/nxp-tja11xx.c | 83 ++++++++++++++++++++++++++++++++---
 1 file changed, 78 insertions(+), 5 deletions(-)

diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c
index 2a8195c50d14..ec91e671f8aa 100644
--- a/drivers/net/phy/nxp-tja11xx.c
+++ b/drivers/net/phy/nxp-tja11xx.c
@@ -10,6 +10,7 @@
 #include <linux/mdio.h>
 #include <linux/mii.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/phy.h>
 #include <linux/hwmon.h>
 #include <linux/bitfield.h>
@@ -34,6 +35,11 @@
 #define MII_CFG1			18
 #define MII_CFG1_MASTER_SLAVE		BIT(15)
 #define MII_CFG1_AUTO_OP		BIT(14)
+#define MII_CFG1_INTERFACE_MODE_MASK	GENMASK(9, 8)
+#define MII_CFG1_MII_MODE				(0x0 << 8)
+#define MII_CFG1_RMII_MODE_REFCLK_IN	BIT(8)
+#define MII_CFG1_RMII_MODE_REFCLK_OUT	BIT(9)
+#define MII_CFG1_REVMII_MODE			GENMASK(9, 8)
 #define MII_CFG1_SLEEP_CONFIRM		BIT(6)
 #define MII_CFG1_LED_MODE_MASK		GENMASK(5, 4)
 #define MII_CFG1_LED_MODE_LINKUP	0
@@ -72,11 +78,15 @@
 #define MII_COMMCFG			27
 #define MII_COMMCFG_AUTO_OP		BIT(15)
 
+/* Configure REF_CLK as input in RMII mode */
+#define TJA110X_RMII_MODE_REFCLK_IN       BIT(0)
+
 struct tja11xx_priv {
 	char		*hwmon_name;
 	struct device	*hwmon_dev;
 	struct phy_device *phydev;
 	struct work_struct phy_register_work;
+	u32 flags;
 };
 
 struct tja11xx_phy_stats {
@@ -251,8 +261,34 @@ static int tja11xx_config_aneg(struct phy_device *phydev)
 	return __genphy_config_aneg(phydev, changed);
 }
 
+static int tja11xx_get_interface_mode(struct phy_device *phydev)
+{
+	struct tja11xx_priv *priv = phydev->priv;
+	int mii_mode;
+
+	switch (phydev->interface) {
+	case PHY_INTERFACE_MODE_MII:
+		mii_mode = MII_CFG1_MII_MODE;
+		break;
+	case PHY_INTERFACE_MODE_REVMII:
+		mii_mode = MII_CFG1_REVMII_MODE;
+		break;
+	case PHY_INTERFACE_MODE_RMII:
+		if (priv->flags & TJA110X_RMII_MODE_REFCLK_IN)
+			mii_mode = MII_CFG1_RMII_MODE_REFCLK_IN;
+		else
+			mii_mode = MII_CFG1_RMII_MODE_REFCLK_OUT;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return mii_mode;
+}
+
 static int tja11xx_config_init(struct phy_device *phydev)
 {
+	u16 reg_mask, reg_val;
 	int ret;
 
 	ret = tja11xx_enable_reg_write(phydev);
@@ -265,15 +301,32 @@ static int tja11xx_config_init(struct phy_device *phydev)
 
 	switch (phydev->phy_id & PHY_ID_MASK) {
 	case PHY_ID_TJA1100:
-		ret = phy_modify(phydev, MII_CFG1,
-				 MII_CFG1_AUTO_OP | MII_CFG1_LED_MODE_MASK |
-				 MII_CFG1_LED_ENABLE,
-				 MII_CFG1_AUTO_OP | MII_CFG1_LED_MODE_LINKUP |
-				 MII_CFG1_LED_ENABLE);
+		reg_mask = MII_CFG1_AUTO_OP | MII_CFG1_LED_MODE_MASK |
+			   MII_CFG1_LED_ENABLE;
+		reg_val = MII_CFG1_AUTO_OP | MII_CFG1_LED_MODE_LINKUP |
+			  MII_CFG1_LED_ENABLE;
+
+		reg_mask |= MII_CFG1_INTERFACE_MODE_MASK;
+		ret = tja11xx_get_interface_mode(phydev);
+		if (ret < 0)
+			return ret;
+
+		reg_val |= (ret & 0xffff);
+		ret = phy_modify(phydev, MII_CFG1, reg_mask, reg_val);
 		if (ret)
 			return ret;
 		break;
 	case PHY_ID_TJA1101:
+		reg_mask = MII_CFG1_INTERFACE_MODE_MASK;
+		ret = tja11xx_get_interface_mode(phydev);
+		if (ret < 0)
+			return ret;
+
+		reg_val = ret & 0xffff;
+		ret = phy_modify(phydev, MII_CFG1, reg_mask, reg_val);
+		if (ret)
+			return ret;
+		fallthrough;
 	case PHY_ID_TJA1102:
 		ret = phy_set_bits(phydev, MII_COMMCFG, MII_COMMCFG_AUTO_OP);
 		if (ret)
@@ -458,16 +511,36 @@ static int tja11xx_hwmon_register(struct phy_device *phydev,
 	return PTR_ERR_OR_ZERO(priv->hwmon_dev);
 }
 
+static int tja11xx_parse_dt(struct phy_device *phydev)
+{
+	struct device_node *node = phydev->mdio.dev.of_node;
+	struct tja11xx_priv *priv = phydev->priv;
+
+	if (!IS_ENABLED(CONFIG_OF_MDIO))
+		return 0;
+
+	if (of_property_read_bool(node, "nxp,rmii-refclk-in"))
+		priv->flags |= TJA110X_RMII_MODE_REFCLK_IN;
+
+	return 0;
+}
+
 static int tja11xx_probe(struct phy_device *phydev)
 {
 	struct device *dev = &phydev->mdio.dev;
 	struct tja11xx_priv *priv;
+	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
 	priv->phydev = phydev;
+	phydev->priv = priv;
+
+	ret = tja11xx_parse_dt(phydev);
+	if (ret)
+		return ret;
 
 	return tja11xx_hwmon_register(phydev, priv);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2 net-next 1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property
  2022-08-22  1:59 ` [PATCH V2 net-next 1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property wei.fang
@ 2022-08-22 21:36   ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2022-08-22 21:36 UTC (permalink / raw)
  To: wei.fang
  Cc: netdev, krzysztof.kozlowski+dt, f.fainelli, edumazet, andrew,
	davem, pabeni, linux-kernel, kuba, devicetree, robh+dt,
	hkallweit1, linux

On Mon, 22 Aug 2022 09:59:48 +0800, wei.fang@nxp.com wrote:
> From: Wei Fang <wei.fang@nxp.com>
> 
> TJA110x REF_CLK can be configured as interface reference clock
> intput or output when the RMII mode enabled. This patch add the
> property to make the REF_CLK can be configurable.
> 
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> ---
> V2 change:
> Correct the property name and a typo.
> ---
>  .../devicetree/bindings/net/nxp,tja11xx.yaml    | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2 net-next 0/2] add interface mode select and RMII
  2022-08-22  1:59 [PATCH V2 net-next 0/2] add interface mode select and RMII wei.fang
  2022-08-22  1:59 ` [PATCH V2 net-next 1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property wei.fang
  2022-08-22  1:59 ` [PATCH V2 net-next 2/2] net: phy: tja11xx: add interface mode and RMII REF_CLK support wei.fang
@ 2022-08-24  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-24  0:50 UTC (permalink / raw)
  To: Wei Fang
  Cc: davem, edumazet, kuba, pabeni, robh+dt, krzysztof.kozlowski+dt,
	andrew, f.fainelli, hkallweit1, linux, netdev, devicetree,
	linux-kernel

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 22 Aug 2022 09:59:47 +0800 you wrote:
> From: Wei Fang <wei.fang@nxp.com>
> 
> The patches add the below feature support for both TJA1100 and
> TJA1101 PHYs cards:
> - Add MII and RMII mode support.
> - Add REF_CLK input/output support for RMII mode.
> 
> [...]

Here is the summary with links:
  - [V2,net-next,1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property
    https://git.kernel.org/netdev/net-next/c/52b2fe4535ad
  - [V2,net-next,2/2] net: phy: tja11xx: add interface mode and RMII REF_CLK support
    https://git.kernel.org/netdev/net-next/c/60ddc78d1636

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-24  0:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-22  1:59 [PATCH V2 net-next 0/2] add interface mode select and RMII wei.fang
2022-08-22  1:59 ` [PATCH V2 net-next 1/2] dt-bindings: net: tja11xx: add nxp,refclk_in property wei.fang
2022-08-22 21:36   ` Rob Herring
2022-08-22  1:59 ` [PATCH V2 net-next 2/2] net: phy: tja11xx: add interface mode and RMII REF_CLK support wei.fang
2022-08-24  0:50 ` [PATCH V2 net-next 0/2] add interface mode select and RMII patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.