2020-04-22 09:29:03

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v5 0/4] add TJA1102 support

changes v5:
- rename __of_mdiobus_register_phy() to of_mdiobus_phy_device_register()

changes v4:
- remove unused phy_id variable

changes v3:
- export part of of_mdiobus_register_phy() and reuse it in tja11xx
driver
- coding style fixes

changes v2:
- use .match_phy_device
- add irq support
- add add delayed registration for PHY1

Oleksij Rempel (4):
dt-bindings: net: phy: Add support for NXP TJA11xx
net: phy: tja11xx: add initial TJA1102 support
net: mdio: of: export part of of_mdiobus_register_phy()
net: phy: tja11xx: add delayed registration of TJA1102 PHY1

.../devicetree/bindings/net/nxp,tja11xx.yaml | 61 ++++++
drivers/net/phy/nxp-tja11xx.c | 201 +++++++++++++++++-
drivers/of/of_mdio.c | 73 ++++---
include/linux/of_mdio.h | 11 +-
4 files changed, 308 insertions(+), 38 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/nxp,tja11xx.yaml

--
2.26.1


2020-04-22 09:29:24

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH net-next v5 3/4] net: mdio: of: export part of of_mdiobus_register_phy()

This function will be needed in tja11xx driver for secondary PHY
support.

Signed-off-by: Oleksij Rempel <[email protected]>
---
drivers/of/of_mdio.c | 73 ++++++++++++++++++++++++-----------------
include/linux/of_mdio.h | 11 ++++++-
2 files changed, 52 insertions(+), 32 deletions(-)

diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 9f982c0627a0d..a04afe79529ca 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -60,39 +60,15 @@ static struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
return register_mii_timestamper(arg.np, arg.args[0]);
}

-static int of_mdiobus_register_phy(struct mii_bus *mdio,
- struct device_node *child, u32 addr)
+int of_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy,
+ struct device_node *child, u32 addr)
{
- struct mii_timestamper *mii_ts;
- struct phy_device *phy;
- bool is_c45;
int rc;
- u32 phy_id;
-
- mii_ts = of_find_mii_timestamper(child);
- if (IS_ERR(mii_ts))
- return PTR_ERR(mii_ts);
-
- is_c45 = of_device_is_compatible(child,
- "ethernet-phy-ieee802.3-c45");
-
- if (!is_c45 && !of_get_phy_id(child, &phy_id))
- phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
- else
- phy = get_phy_device(mdio, addr, is_c45);
- if (IS_ERR(phy)) {
- if (mii_ts)
- unregister_mii_timestamper(mii_ts);
- return PTR_ERR(phy);
- }

rc = of_irq_get(child, 0);
- if (rc == -EPROBE_DEFER) {
- if (mii_ts)
- unregister_mii_timestamper(mii_ts);
- phy_device_free(phy);
+ if (rc == -EPROBE_DEFER)
return rc;
- }
+
if (rc > 0) {
phy->irq = rc;
mdio->irq[addr] = rc;
@@ -117,11 +93,48 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
/* All data is now stored in the phy struct;
* register it */
rc = phy_device_register(phy);
+ if (rc) {
+ of_node_put(child);
+ return rc;
+ }
+
+ dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n",
+ child, addr);
+ return 0;
+}
+EXPORT_SYMBOL(of_mdiobus_phy_device_register);
+
+static int of_mdiobus_register_phy(struct mii_bus *mdio,
+ struct device_node *child, u32 addr)
+{
+ struct mii_timestamper *mii_ts;
+ struct phy_device *phy;
+ bool is_c45;
+ int rc;
+ u32 phy_id;
+
+ mii_ts = of_find_mii_timestamper(child);
+ if (IS_ERR(mii_ts))
+ return PTR_ERR(mii_ts);
+
+ is_c45 = of_device_is_compatible(child,
+ "ethernet-phy-ieee802.3-c45");
+
+ if (!is_c45 && !of_get_phy_id(child, &phy_id))
+ phy = phy_device_create(mdio, addr, phy_id, 0, NULL);
+ else
+ phy = get_phy_device(mdio, addr, is_c45);
+ if (IS_ERR(phy)) {
+ if (mii_ts)
+ unregister_mii_timestamper(mii_ts);
+ return PTR_ERR(phy);
+ }
+
+ rc = of_mdiobus_phy_device_register(mdio, phy, child, addr);
if (rc) {
if (mii_ts)
unregister_mii_timestamper(mii_ts);
phy_device_free(phy);
- of_node_put(child);
return rc;
}

@@ -132,8 +145,6 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
if (mii_ts)
phy->mii_ts = mii_ts;

- dev_dbg(&mdio->dev, "registered phy %pOFn at address %i\n",
- child, addr);
return 0;
}

diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h
index 491a2b7e77c1e..0f61a4ac6bcfb 100644
--- a/include/linux/of_mdio.h
+++ b/include/linux/of_mdio.h
@@ -30,7 +30,9 @@ extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np);
extern int of_phy_register_fixed_link(struct device_node *np);
extern void of_phy_deregister_fixed_link(struct device_node *np);
extern bool of_phy_is_fixed_link(struct device_node *np);
-
+extern int of_mdiobus_phy_device_register(struct mii_bus *mdio,
+ struct phy_device *phy,
+ struct device_node *child, u32 addr);

static inline int of_mdio_parse_addr(struct device *dev,
const struct device_node *np)
@@ -118,6 +120,13 @@ static inline bool of_phy_is_fixed_link(struct device_node *np)
{
return false;
}
+
+static inline int of_mdiobus_phy_device_register(struct mii_bus *mdio,
+ struct phy_device *phy,
+ struct device_node *child, u32 addr)
+{
+ return -ENOSYS;
+}
#endif


--
2.26.1

2020-04-22 13:47:49

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH net-next v5 3/4] net: mdio: of: export part of of_mdiobus_register_phy()

On Wed, Apr 22, 2020 at 11:24:55AM +0200, Oleksij Rempel wrote:
> This function will be needed in tja11xx driver for secondary PHY
> support.
>
> Signed-off-by: Oleksij Rempel <[email protected]>

Reviewed-by: Andrew Lunn <[email protected]>

Andrew

2020-04-23 02:44:39

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net-next v5 0/4] add TJA1102 support

From: Oleksij Rempel <[email protected]>
Date: Wed, 22 Apr 2020 11:24:52 +0200

> changes v5:
> - rename __of_mdiobus_register_phy() to of_mdiobus_phy_device_register()
>
> changes v4:
> - remove unused phy_id variable
>
> changes v3:
> - export part of of_mdiobus_register_phy() and reuse it in tja11xx
> driver
> - coding style fixes
>
> changes v2:
> - use .match_phy_device
> - add irq support
> - add add delayed registration for PHY1

Series applied, thanks.

2020-04-23 03:22:32

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH net-next v5 3/4] net: mdio: of: export part of of_mdiobus_register_phy()



On 4/22/2020 2:24 AM, Oleksij Rempel wrote:
> This function will be needed in tja11xx driver for secondary PHY
> support.
>
> Signed-off-by: Oleksij Rempel <[email protected]>

Reviewed-by: Florian Fainelli <[email protected]>
--
Florian