* [[PATCH linux dev-5.10] net: npcm: Support for fixed PHYs
@ 2021-03-27 0:49 William A. Kennington III
2021-03-29 22:36 ` Joel Stanley
0 siblings, 1 reply; 3+ messages in thread
From: William A. Kennington III @ 2021-03-27 0:49 UTC (permalink / raw)
To: openbmc; +Cc: William A. Kennington III
Most of our machines don't have PHYs between the NIC and the BMC over
their NC-SI port. We don't want to use the kernel NC-SI machinery, but
we do want phyless support.
Signed-off-by: William A. Kennington III <wak@google.com>
---
drivers/net/ethernet/nuvoton/npcm7xx_emc.c | 31 +++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
index f07449e2f68d..1dc871a72180 100644
--- a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
+++ b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
@@ -26,6 +26,7 @@
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/of_device.h>
+#include <linux/of_mdio.h>
#include <linux/dma-mapping.h>
#include <linux/regmap.h>
@@ -242,6 +243,7 @@ struct npcm7xx_ether {
struct net_device *ndev;
struct resource *res;
unsigned int msg_enable;
+ struct device_node *phy_dn;
struct mii_bus *mii_bus;
struct phy_device *phy_dev;
struct napi_struct napi;
@@ -1774,6 +1776,17 @@ static int npcm7xx_mii_setup(struct net_device *dev)
pdev = ether->pdev;
+ if (ether->phy_dn) {
+ ether->phy_dev = of_phy_connect(dev, ether->phy_dn,
+ &adjust_link, 0, 0);
+ if (!ether->phy_dn) {
+ dev_err(&dev->dev, "could not connect to phy %pOF\n",
+ ether->phy_dn);
+ return -ENODEV;
+ }
+ return 0;
+ }
+
ether->mii_bus = mdiobus_alloc();
if (!ether->mii_bus) {
err = -ENOMEM;
@@ -2011,6 +2024,15 @@ static int npcm7xx_ether_probe(struct platform_device *pdev)
}
} else {
ether->use_ncsi = false;
+
+ ether->phy_dn = of_parse_phandle(np, "phy-handle", 0);
+ if (!ether->phy_dn && of_phy_is_fixed_link(np)) {
+ error = of_phy_register_fixed_link(np);
+ if (error < 0)
+ goto failed_free_napi;
+ ether->phy_dn = of_node_get(np);
+ }
+
error = npcm7xx_mii_setup(dev);
if (error < 0) {
dev_err(&pdev->dev, "npcm7xx_mii_setup err\n");
@@ -2032,6 +2054,9 @@ static int npcm7xx_ether_probe(struct platform_device *pdev)
return 0;
failed_free_napi:
+ of_node_put(ether->phy_dn);
+ if (of_phy_is_fixed_link(np))
+ of_phy_deregister_fixed_link(np);
netif_napi_del(ðer->napi);
platform_set_drvdata(pdev, NULL);
failed_free_io:
@@ -2048,13 +2073,17 @@ static int npcm7xx_ether_remove(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct npcm7xx_ether *ether = netdev_priv(dev);
+ struct device_node *np = pdev->dev.of_node;
#ifdef CONFIG_DEBUG_FS
debugfs_remove_recursive(ether->dbgfs_dir);
#endif
-
unregister_netdev(dev);
+ of_node_put(ether->phy_dn);
+ if (of_phy_is_fixed_link(np))
+ of_phy_deregister_fixed_link(np);
+
free_irq(ether->txirq, dev);
free_irq(ether->rxirq, dev);
--
2.31.0.291.g576ba9dcdaf-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [[PATCH linux dev-5.10] net: npcm: Support for fixed PHYs
2021-03-27 0:49 [[PATCH linux dev-5.10] net: npcm: Support for fixed PHYs William A. Kennington III
@ 2021-03-29 22:36 ` Joel Stanley
2021-03-31 16:06 ` Tomer Maimon
0 siblings, 1 reply; 3+ messages in thread
From: Joel Stanley @ 2021-03-29 22:36 UTC (permalink / raw)
To: William A. Kennington III, Tomer Maimon, Avi Fishman; +Cc: OpenBMC Maillist
On Sat, 27 Mar 2021 at 00:49, William A. Kennington III <wak@google.com> wrote:
>
> Most of our machines don't have PHYs between the NIC and the BMC over
> their NC-SI port. We don't want to use the kernel NC-SI machinery, but
> we do want phyless support.
>
> Signed-off-by: William A. Kennington III <wak@google.com>
This looks fine to me. Tomer, Avi, can I please get a review from
someone at Nuvoton?
Reviewed-by: Joel Stanley <joel@jms.id.au>
It would be great to see this driver submitted upstream too!
> ---
> drivers/net/ethernet/nuvoton/npcm7xx_emc.c | 31 +++++++++++++++++++++-
> 1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> index f07449e2f68d..1dc871a72180 100644
> --- a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> +++ b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> @@ -26,6 +26,7 @@
> #include <linux/of.h>
> #include <linux/of_net.h>
> #include <linux/of_device.h>
> +#include <linux/of_mdio.h>
> #include <linux/dma-mapping.h>
>
> #include <linux/regmap.h>
> @@ -242,6 +243,7 @@ struct npcm7xx_ether {
> struct net_device *ndev;
> struct resource *res;
> unsigned int msg_enable;
> + struct device_node *phy_dn;
> struct mii_bus *mii_bus;
> struct phy_device *phy_dev;
> struct napi_struct napi;
> @@ -1774,6 +1776,17 @@ static int npcm7xx_mii_setup(struct net_device *dev)
>
> pdev = ether->pdev;
>
> + if (ether->phy_dn) {
> + ether->phy_dev = of_phy_connect(dev, ether->phy_dn,
> + &adjust_link, 0, 0);
> + if (!ether->phy_dn) {
> + dev_err(&dev->dev, "could not connect to phy %pOF\n",
> + ether->phy_dn);
> + return -ENODEV;
> + }
> + return 0;
> + }
> +
> ether->mii_bus = mdiobus_alloc();
> if (!ether->mii_bus) {
> err = -ENOMEM;
> @@ -2011,6 +2024,15 @@ static int npcm7xx_ether_probe(struct platform_device *pdev)
> }
> } else {
> ether->use_ncsi = false;
> +
> + ether->phy_dn = of_parse_phandle(np, "phy-handle", 0);
> + if (!ether->phy_dn && of_phy_is_fixed_link(np)) {
> + error = of_phy_register_fixed_link(np);
> + if (error < 0)
> + goto failed_free_napi;
> + ether->phy_dn = of_node_get(np);
> + }
> +
> error = npcm7xx_mii_setup(dev);
> if (error < 0) {
> dev_err(&pdev->dev, "npcm7xx_mii_setup err\n");
> @@ -2032,6 +2054,9 @@ static int npcm7xx_ether_probe(struct platform_device *pdev)
> return 0;
>
> failed_free_napi:
> + of_node_put(ether->phy_dn);
> + if (of_phy_is_fixed_link(np))
> + of_phy_deregister_fixed_link(np);
> netif_napi_del(ðer->napi);
> platform_set_drvdata(pdev, NULL);
> failed_free_io:
> @@ -2048,13 +2073,17 @@ static int npcm7xx_ether_remove(struct platform_device *pdev)
> {
> struct net_device *dev = platform_get_drvdata(pdev);
> struct npcm7xx_ether *ether = netdev_priv(dev);
> + struct device_node *np = pdev->dev.of_node;
>
> #ifdef CONFIG_DEBUG_FS
> debugfs_remove_recursive(ether->dbgfs_dir);
> #endif
> -
> unregister_netdev(dev);
>
> + of_node_put(ether->phy_dn);
> + if (of_phy_is_fixed_link(np))
> + of_phy_deregister_fixed_link(np);
> +
> free_irq(ether->txirq, dev);
> free_irq(ether->rxirq, dev);
>
> --
> 2.31.0.291.g576ba9dcdaf-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [[PATCH linux dev-5.10] net: npcm: Support for fixed PHYs
2021-03-29 22:36 ` Joel Stanley
@ 2021-03-31 16:06 ` Tomer Maimon
0 siblings, 0 replies; 3+ messages in thread
From: Tomer Maimon @ 2021-03-31 16:06 UTC (permalink / raw)
To: Joel Stanley; +Cc: Avi Fishman, OpenBMC Maillist, William A. Kennington III
[-- Attachment #1: Type: text/plain, Size: 4132 bytes --]
Looks fine to me,
Reviewed-by : Tomer Maimon <tmaimon77@gmail.com>
cheers,
Tomer
On Tue, 30 Mar 2021 at 01:37, Joel Stanley <joel@jms.id.au> wrote:
> On Sat, 27 Mar 2021 at 00:49, William A. Kennington III <wak@google.com>
> wrote:
> >
> > Most of our machines don't have PHYs between the NIC and the BMC over
> > their NC-SI port. We don't want to use the kernel NC-SI machinery, but
> > we do want phyless support.
> >
> > Signed-off-by: William A. Kennington III <wak@google.com>
>
> This looks fine to me. Tomer, Avi, can I please get a review from
> someone at Nuvoton?
>
> Reviewed-by: Joel Stanley <joel@jms.id.au>
>
> It would be great to see this driver submitted upstream too!
>
> ---
> > drivers/net/ethernet/nuvoton/npcm7xx_emc.c | 31 +++++++++++++++++++++-
> > 1 file changed, 30 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> > index f07449e2f68d..1dc871a72180 100644
> > --- a/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> > +++ b/drivers/net/ethernet/nuvoton/npcm7xx_emc.c
> > @@ -26,6 +26,7 @@
> > #include <linux/of.h>
> > #include <linux/of_net.h>
> > #include <linux/of_device.h>
> > +#include <linux/of_mdio.h>
> > #include <linux/dma-mapping.h>
> >
> > #include <linux/regmap.h>
> > @@ -242,6 +243,7 @@ struct npcm7xx_ether {
> > struct net_device *ndev;
> > struct resource *res;
> > unsigned int msg_enable;
> > + struct device_node *phy_dn;
> > struct mii_bus *mii_bus;
> > struct phy_device *phy_dev;
> > struct napi_struct napi;
> > @@ -1774,6 +1776,17 @@ static int npcm7xx_mii_setup(struct net_device
> *dev)
> >
> > pdev = ether->pdev;
> >
> > + if (ether->phy_dn) {
> > + ether->phy_dev = of_phy_connect(dev, ether->phy_dn,
> > + &adjust_link, 0, 0);
> > + if (!ether->phy_dn) {
> > + dev_err(&dev->dev, "could not connect to phy
> %pOF\n",
> > + ether->phy_dn);
> > + return -ENODEV;
> > + }
> > + return 0;
> > + }
> > +
> > ether->mii_bus = mdiobus_alloc();
> > if (!ether->mii_bus) {
> > err = -ENOMEM;
> > @@ -2011,6 +2024,15 @@ static int npcm7xx_ether_probe(struct
> platform_device *pdev)
> > }
> > } else {
> > ether->use_ncsi = false;
> > +
> > + ether->phy_dn = of_parse_phandle(np, "phy-handle", 0);
> > + if (!ether->phy_dn && of_phy_is_fixed_link(np)) {
> > + error = of_phy_register_fixed_link(np);
> > + if (error < 0)
> > + goto failed_free_napi;
> > + ether->phy_dn = of_node_get(np);
> > + }
> > +
> > error = npcm7xx_mii_setup(dev);
> > if (error < 0) {
> > dev_err(&pdev->dev, "npcm7xx_mii_setup err\n");
> > @@ -2032,6 +2054,9 @@ static int npcm7xx_ether_probe(struct
> platform_device *pdev)
> > return 0;
> >
> > failed_free_napi:
> > + of_node_put(ether->phy_dn);
> > + if (of_phy_is_fixed_link(np))
> > + of_phy_deregister_fixed_link(np);
> > netif_napi_del(ðer->napi);
> > platform_set_drvdata(pdev, NULL);
> > failed_free_io:
> > @@ -2048,13 +2073,17 @@ static int npcm7xx_ether_remove(struct
> platform_device *pdev)
> > {
> > struct net_device *dev = platform_get_drvdata(pdev);
> > struct npcm7xx_ether *ether = netdev_priv(dev);
> > + struct device_node *np = pdev->dev.of_node;
> >
> > #ifdef CONFIG_DEBUG_FS
> > debugfs_remove_recursive(ether->dbgfs_dir);
> > #endif
> > -
> > unregister_netdev(dev);
> >
> > + of_node_put(ether->phy_dn);
> > + if (of_phy_is_fixed_link(np))
> > + of_phy_deregister_fixed_link(np);
> > +
> > free_irq(ether->txirq, dev);
> > free_irq(ether->rxirq, dev);
> >
> > --
> > 2.31.0.291.g576ba9dcdaf-goog
> >
>
[-- Attachment #2: Type: text/html, Size: 6119 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-31 16:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-27 0:49 [[PATCH linux dev-5.10] net: npcm: Support for fixed PHYs William A. Kennington III
2021-03-29 22:36 ` Joel Stanley
2021-03-31 16:06 ` Tomer Maimon
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).