* [PATCH 0/2] Add fwnode helper functions to MDIO bus driver
@ 2020-07-22 11:32 Vikas Singh
2020-07-22 11:32 ` [PATCH 1/2] net: phy: Add fwnode helper functions Vikas Singh
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Vikas Singh @ 2020-07-22 11:32 UTC (permalink / raw)
To: andrew, f.fainelli, hkallweit1, linux, netdev
Cc: calvin.johnson, kuldip.dwivedi, madalin.bucur, vikas.singh, Vikas Singh
This patch add helper functions to handle fwnodes on MDIO bus in case of
ACPI probing. These helper functions will be used in DPAA MAC driver.
The patches are in below logical order:
1. Add helper function to attach MAC with PHY
2. Associate device node with fixed PHY by extending "fixed_phy_status"
Vikas Singh (2):
net: phy: Add fwnode helper functions
net: phy: Associate device node with fixed PHY
drivers/net/phy/fixed_phy.c | 2 ++
drivers/net/phy/mdio_bus.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
include/linux/mdio.h | 4 +++
include/linux/phy_fixed.h | 2 ++
4 files changed, 74 insertions(+)
--
2.7.4
--
*Disclaimer* -The information transmitted is intended solely for the
individual
or entity to which it is addressed and may contain confidential
and/or
privileged material. Any review, re-transmission, dissemination or
other use of
or taking action in reliance upon this information by persons
or entities other
than the intended recipient is prohibited. If you have
received this email in
error please contact the sender and delete the
material from any computer. In
such instances you are further prohibited
from reproducing, disclosing,
distributing or taking any action in reliance
on it.As a recipient of this email,
you are responsible for screening its
contents and the contents of any
attachments for the presence of viruses.
No liability is accepted for any
damages caused by any virus transmitted by
this email.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] net: phy: Add fwnode helper functions
2020-07-22 11:32 [PATCH 0/2] Add fwnode helper functions to MDIO bus driver Vikas Singh
@ 2020-07-22 11:32 ` Vikas Singh
2020-07-22 11:32 ` [PATCH 2/2] net: phy: Associate device node with fixed PHY Vikas Singh
2020-07-22 12:55 ` [PATCH 0/2] Add fwnode helper functions to MDIO bus driver Andrew Lunn
2 siblings, 0 replies; 5+ messages in thread
From: Vikas Singh @ 2020-07-22 11:32 UTC (permalink / raw)
To: andrew, f.fainelli, hkallweit1, linux, netdev
Cc: calvin.johnson, kuldip.dwivedi, madalin.bucur, vikas.singh, Vikas Singh
Add support of fwnode helper functions to MDIO bus driver.
1. fwnode_phy_find_device() to find phy_device associated to a fwnod
2. fwnode_phy_connect() to attach the mac to the phy
Signed-off-by: Vikas Singh <vikas.singh@puresoftware.com>
---
drivers/net/phy/mdio_bus.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
include/linux/mdio.h | 4 +++
2 files changed, 70 insertions(+)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 7275eff..9457ff5 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -40,6 +40,72 @@
#include "mdio-boardinfo.h"
+/* Helper function for fwnode_phy_find_device */
+static int fwnode_phy_match(struct device *dev, const void *phy_fwnode)
+{
+ return dev->fwnode == phy_fwnode;
+}
+
+/**
+ * fwnode_phy_find_device - find the phy_device associated to fwnode
+ * @phy_fwnode: Pointer to the PHY's fwnode
+ *
+ * If successful, returns a pointer to the phy_device with the
+ * embedded struct device refcount incremented by one, NULL on
+ * failure.
+ */
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode)
+{
+ struct device *d;
+ struct mdio_device *mdiodev;
+
+ if (!phy_fwnode)
+ return NULL;
+
+ d = bus_find_device(&mdio_bus_type, NULL, phy_fwnode, fwnode_phy_match);
+ if (d) {
+ mdiodev = to_mdio_device(d);
+ if (mdiodev->flags & MDIO_DEVICE_FLAG_PHY)
+ return to_phy_device(d);
+ put_device(d);
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL(fwnode_phy_find_device);
+
+/**
+ * fwnode_phy_connect - Connect to the phy described in the device tree
+ * @dev: pointer to net_device claiming the phy
+ * @phy_fwnode: Pointer to fwnode for the PHY
+ * @hndlr: Link state callback for the network device
+ * @flags: flags to pass to the PHY
+ * @iface: PHY data interface type
+ *
+ * If successful, returns a pointer to the phy_device with the embedded
+ * struct device refcount incremented by one, or NULL on failure. The
+ * refcount must be dropped by calling phy_disconnect() or phy_detach().
+ */
+struct phy_device *fwnode_phy_connect(
+ struct net_device *dev, struct fwnode_handle *phy_fwnode,
+ void (*hndlr)(struct net_device *), u32 flags, u32 iface)
+{
+ struct phy_device *phy_dev;
+
+ phy_dev = fwnode_phy_find_device(phy_fwnode);
+ if (!phy_dev)
+ return NULL;
+
+ phy_dev->dev_flags = flags;
+
+ /* If in case we fail to attach to PHY,then phy_dev must be NULL */
+ if (phy_connect_direct(dev, phy_dev, hndlr, iface))
+ return NULL;
+
+ return phy_dev;
+}
+EXPORT_SYMBOL(fwnode_phy_connect);
+
static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
{
/* Deassert the optional reset signal */
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 898cbf0..501da6a 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -362,6 +362,10 @@ int mdiobus_register_device(struct mdio_device *mdiodev);
int mdiobus_unregister_device(struct mdio_device *mdiodev);
bool mdiobus_is_registered_device(struct mii_bus *bus, int addr);
struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr);
+struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode);
+struct phy_device *fwnode_phy_connect(
+ struct net_device *dev, struct fwnode_handle *phy_fwnode,
+ void (*hndlr)(struct net_device *), u32 flags, u32 iface);
/**
* mdio_module_driver() - Helper macro for registering mdio drivers
--
2.7.4
--
*Disclaimer* -The information transmitted is intended solely for the
individual
or entity to which it is addressed and may contain confidential
and/or
privileged material. Any review, re-transmission, dissemination or
other use of
or taking action in reliance upon this information by persons
or entities other
than the intended recipient is prohibited. If you have
received this email in
error please contact the sender and delete the
material from any computer. In
such instances you are further prohibited
from reproducing, disclosing,
distributing or taking any action in reliance
on it.As a recipient of this email,
you are responsible for screening its
contents and the contents of any
attachments for the presence of viruses.
No liability is accepted for any
damages caused by any virus transmitted by
this email.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] net: phy: Associate device node with fixed PHY
2020-07-22 11:32 [PATCH 0/2] Add fwnode helper functions to MDIO bus driver Vikas Singh
2020-07-22 11:32 ` [PATCH 1/2] net: phy: Add fwnode helper functions Vikas Singh
@ 2020-07-22 11:32 ` Vikas Singh
2020-07-22 12:55 ` [PATCH 0/2] Add fwnode helper functions to MDIO bus driver Andrew Lunn
2 siblings, 0 replies; 5+ messages in thread
From: Vikas Singh @ 2020-07-22 11:32 UTC (permalink / raw)
To: andrew, f.fainelli, hkallweit1, linux, netdev
Cc: calvin.johnson, kuldip.dwivedi, madalin.bucur, vikas.singh, Vikas Singh
This patch will extend "struct fixed_phy_status" by adding new
"struct device *dev" member entry in it.
This change will help to handle the fixed phy registration in
ACPI probe case for fwnodes.
Signed-off-by: Vikas Singh <vikas.singh@puresoftware.com>
---
drivers/net/phy/fixed_phy.c | 2 ++
include/linux/phy_fixed.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index c4641b1..011c033 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -267,6 +267,8 @@ static struct phy_device *__fixed_phy_register(unsigned int irq,
phy->duplex = status->duplex;
phy->pause = status->pause;
phy->asym_pause = status->asym_pause;
+ if (!np)
+ phy->mdio.dev.fwnode = status->dev->fwnode;
}
of_node_get(np);
diff --git a/include/linux/phy_fixed.h b/include/linux/phy_fixed.h
index 52bc8e4..155fea6 100644
--- a/include/linux/phy_fixed.h
+++ b/include/linux/phy_fixed.h
@@ -8,6 +8,8 @@ struct fixed_phy_status {
int duplex;
int pause;
int asym_pause;
+ /* Associated device node */
+ struct device *dev;
};
struct device_node;
--
2.7.4
--
*Disclaimer* -The information transmitted is intended solely for the
individual
or entity to which it is addressed and may contain confidential
and/or
privileged material. Any review, re-transmission, dissemination or
other use of
or taking action in reliance upon this information by persons
or entities other
than the intended recipient is prohibited. If you have
received this email in
error please contact the sender and delete the
material from any computer. In
such instances you are further prohibited
from reproducing, disclosing,
distributing or taking any action in reliance
on it.As a recipient of this email,
you are responsible for screening its
contents and the contents of any
attachments for the presence of viruses.
No liability is accepted for any
damages caused by any virus transmitted by
this email.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Add fwnode helper functions to MDIO bus driver
2020-07-22 11:32 [PATCH 0/2] Add fwnode helper functions to MDIO bus driver Vikas Singh
2020-07-22 11:32 ` [PATCH 1/2] net: phy: Add fwnode helper functions Vikas Singh
2020-07-22 11:32 ` [PATCH 2/2] net: phy: Associate device node with fixed PHY Vikas Singh
@ 2020-07-22 12:55 ` Andrew Lunn
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2020-07-22 12:55 UTC (permalink / raw)
To: Vikas Singh
Cc: f.fainelli, hkallweit1, linux, netdev, calvin.johnson,
kuldip.dwivedi, madalin.bucur, vikas.singh
> *Disclaimer* -The information transmitted is intended solely for the
> individual
> or entity to which it is addressed and may contain confidential
> and/or
> privileged material. Any review, re-transmission, dissemination or
> other use of
> or taking action in reliance upon this information by persons
> or entities other
> than the intended recipient is prohibited. If you have
> received this email in
> error please contact the sender and delete the
> material from any computer.
As requested, i deleted this email. If you want to submit patches,
please remove this.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 0/2] Add fwnode helper functions to MDIO bus driver
@ 2020-07-28 12:13 Vikas Singh
0 siblings, 0 replies; 5+ messages in thread
From: Vikas Singh @ 2020-07-28 12:13 UTC (permalink / raw)
To: andrew, f.fainelli, hkallweit1, linux, netdev
Cc: calvin.johnson, kuldip.dwivedi, madalin.bucur, vikas.singh, Vikas Singh
This patch add helper functions to handle fwnodes on MDIO bus in case of
ACPI probing. These helper functions will be used in DPAA MAC driver.
The patches are in below logical order:
1. Add helper function to attach MAC with PHY
2. Associate device node with fixed PHY by extending "fixed_phy_status"
Vikas Singh (2):
net: phy: Add fwnode helper functions
net: phy: Associate device node with fixed PHY
drivers/net/phy/fixed_phy.c | 2 ++
drivers/net/phy/mdio_bus.c | 66 +++++++++++++++++++++++++++++++++++++++++++++
include/linux/mdio.h | 4 +++
include/linux/phy_fixed.h | 2 ++
4 files changed, 74 insertions(+)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-28 12:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 11:32 [PATCH 0/2] Add fwnode helper functions to MDIO bus driver Vikas Singh
2020-07-22 11:32 ` [PATCH 1/2] net: phy: Add fwnode helper functions Vikas Singh
2020-07-22 11:32 ` [PATCH 2/2] net: phy: Associate device node with fixed PHY Vikas Singh
2020-07-22 12:55 ` [PATCH 0/2] Add fwnode helper functions to MDIO bus driver Andrew Lunn
2020-07-28 12:13 Vikas Singh
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).