* [PATCH net-next 1/2] Altera TSE: Move PHY get addr and MDIO create
2014-10-03 18:08 [PATCH net-next 0/2] Altera TSE with no PHY Walter Lozano
@ 2014-10-03 18:09 ` Walter Lozano
2014-10-03 18:09 ` [PATCH net-next 2/2] Altera TSE: Add support for no PHY Walter Lozano
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Walter Lozano @ 2014-10-03 18:09 UTC (permalink / raw)
To: netdev
Cc: davem, tobias.klauser, vbridgers2013, f.fainelli, nios2-dev,
ezequiel, guido, Walter Lozano
Move PHY get addr and MDIO create to a new function to improve readability
and make it easier to avoid its usage. This will be useful for example in
the case where there is no PHY chip.
Signed-off-by: Walter Lozano <walter@vanguardiasur.com.ar>
---
drivers/net/ethernet/altera/altera_tse_main.c | 57 ++++++++++++++++---------
1 file changed, 36 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index 7330681..c85d029 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -728,6 +728,40 @@ static struct phy_device *connect_local_phy(struct net_device *dev)
return phydev;
}
+static int altera_tse_phy_get_addr_mdio_create(struct net_device *dev)
+{
+ struct altera_tse_private *priv = netdev_priv(dev);
+ struct device_node *np = priv->device->of_node;
+ int ret = 0;
+
+ priv->phy_iface = of_get_phy_mode(np);
+
+ /* try to get PHY address from device tree, use PHY autodetection if
+ * no valid address is given
+ */
+
+ if (of_property_read_u32(priv->device->of_node, "phy-addr",
+ &priv->phy_addr)) {
+ priv->phy_addr = POLL_PHY;
+ }
+
+ if (!((priv->phy_addr == POLL_PHY) ||
+ ((priv->phy_addr >= 0) && (priv->phy_addr < PHY_MAX_ADDR)))) {
+ netdev_err(dev, "invalid phy-addr specified %d\n",
+ priv->phy_addr);
+ return -ENODEV;
+ }
+
+ /* Create/attach to MDIO bus */
+ ret = altera_tse_mdio_create(dev,
+ atomic_add_return(1, &instance_count));
+
+ if (ret)
+ return -ENODEV;
+
+ return 0;
+}
+
/* Initialize driver's PHY state, and attach to the PHY
*/
static int init_phy(struct net_device *dev)
@@ -1231,7 +1265,6 @@ static int altera_tse_probe(struct platform_device *pdev)
struct resource *dma_res;
struct altera_tse_private *priv;
const unsigned char *macaddr;
- struct device_node *np = pdev->dev.of_node;
void __iomem *descmap;
const struct of_device_id *of_id = NULL;
@@ -1408,26 +1441,8 @@ static int altera_tse_probe(struct platform_device *pdev)
else
eth_hw_addr_random(ndev);
- priv->phy_iface = of_get_phy_mode(np);
-
- /* try to get PHY address from device tree, use PHY autodetection if
- * no valid address is given
- */
- if (of_property_read_u32(pdev->dev.of_node, "phy-addr",
- &priv->phy_addr)) {
- priv->phy_addr = POLL_PHY;
- }
-
- if (!((priv->phy_addr == POLL_PHY) ||
- ((priv->phy_addr >= 0) && (priv->phy_addr < PHY_MAX_ADDR)))) {
- dev_err(&pdev->dev, "invalid phy-addr specified %d\n",
- priv->phy_addr);
- goto err_free_netdev;
- }
-
- /* Create/attach to MDIO bus */
- ret = altera_tse_mdio_create(ndev,
- atomic_add_return(1, &instance_count));
+ /* get phy addr and create mdio */
+ ret = altera_tse_phy_get_addr_mdio_create(ndev);
if (ret)
goto err_free_netdev;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH net-next 2/2] Altera TSE: Add support for no PHY
2014-10-03 18:08 [PATCH net-next 0/2] Altera TSE with no PHY Walter Lozano
2014-10-03 18:09 ` [PATCH net-next 1/2] Altera TSE: Move PHY get addr and MDIO create Walter Lozano
@ 2014-10-03 18:09 ` Walter Lozano
2014-10-06 1:40 ` [PATCH net-next 0/2] Altera TSE with " David Miller
2014-10-10 20:46 ` [Nios2-dev] " Matthew Gerlach
3 siblings, 0 replies; 6+ messages in thread
From: Walter Lozano @ 2014-10-03 18:09 UTC (permalink / raw)
To: netdev
Cc: davem, tobias.klauser, vbridgers2013, f.fainelli, nios2-dev,
ezequiel, guido, Walter Lozano
This patch avoids PHY and MDIO probing if no PHY chip is present.
This is the case mainly in optical links where there is no need for
PHY chip, and therefore no need of MDIO. In this scenario Ethernet
MAC is directly connected to an optical module through an external
SFP transceiver.
Signed-off-by: Walter Lozano <walter@vanguardiasur.com.ar>
---
drivers/net/ethernet/altera/altera_tse_main.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index c85d029..b44a5f7 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -736,6 +736,10 @@ static int altera_tse_phy_get_addr_mdio_create(struct net_device *dev)
priv->phy_iface = of_get_phy_mode(np);
+ /* Avoid get phy addr and create mdio if no phy is present */
+ if (!priv->phy_iface)
+ return 0;
+
/* try to get PHY address from device tree, use PHY autodetection if
* no valid address is given
*/
@@ -770,6 +774,10 @@ static int init_phy(struct net_device *dev)
struct phy_device *phydev;
struct device_node *phynode;
+ /* Avoid init phy in case of no phy present */
+ if (!priv->phy_iface)
+ return 0;
+
priv->oldlink = 0;
priv->oldspeed = 0;
priv->oldduplex = -1;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next 0/2] Altera TSE with no PHY
2014-10-03 18:08 [PATCH net-next 0/2] Altera TSE with no PHY Walter Lozano
2014-10-03 18:09 ` [PATCH net-next 1/2] Altera TSE: Move PHY get addr and MDIO create Walter Lozano
2014-10-03 18:09 ` [PATCH net-next 2/2] Altera TSE: Add support for no PHY Walter Lozano
@ 2014-10-06 1:40 ` David Miller
2014-10-10 20:46 ` [Nios2-dev] " Matthew Gerlach
3 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-10-06 1:40 UTC (permalink / raw)
To: walter
Cc: netdev, tobias.klauser, vbridgers2013, f.fainelli, nios2-dev,
ezequiel, guido
From: Walter Lozano <walter@vanguardiasur.com.ar>
Date: Fri, 3 Oct 2014 15:08:59 -0300
> In some scenarios there is no PHY chip present, for example in optical links.
> This serie of patches moves PHY get addr and MDIO create to a new function and
> avoids PHY and MDIO probing in these cases.
Series applied, thanks Walter.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Nios2-dev] [PATCH net-next 0/2] Altera TSE with no PHY
2014-10-03 18:08 [PATCH net-next 0/2] Altera TSE with no PHY Walter Lozano
` (2 preceding siblings ...)
2014-10-06 1:40 ` [PATCH net-next 0/2] Altera TSE with " David Miller
@ 2014-10-10 20:46 ` Matthew Gerlach
2014-10-11 22:24 ` Walter Lozano
3 siblings, 1 reply; 6+ messages in thread
From: Matthew Gerlach @ 2014-10-10 20:46 UTC (permalink / raw)
To: Walter Lozano, netdev@vger.kernel.org
Cc: f.fainelli@gmail.com, tobias.klauser@gmail.com,
vbridgers2013@gmail.com, nios2-dev@lists.rocketboards.org,
davem@davemloft.net, guido@vanguardiasur.com.ar
Hi Walter,
I've examined your patch, and it makes sense to me. I tested your patch again the TSE example design, and it did not break anything.
Thanks,
Matthew Gerlach
________________________________________
From: nios2-dev-bounces@lists.rocketboards.org <nios2-dev-bounces@lists.rocketboards.org> on behalf of Walter Lozano <walter@vanguardiasur.com.ar>
Sent: Friday, October 3, 2014 11:08 AM
To: netdev@vger.kernel.org
Cc: f.fainelli@gmail.com; tobias.klauser@gmail.com; vbridgers2013@gmail.com; nios2-dev@lists.rocketboards.org; davem@davemloft.net; guido@vanguardiasur.com.ar
Subject: [Nios2-dev] [PATCH net-next 0/2] Altera TSE with no PHY
In some scenarios there is no PHY chip present, for example in optical links.
This serie of patches moves PHY get addr and MDIO create to a new function and
avoids PHY and MDIO probing in these cases.
Walter Lozano (2):
Altera TSE: Move PHY get addr and MDIO create
Altera TSE: Add support for no PHY
drivers/net/ethernet/altera/altera_tse_main.c | 65 +++++++++++++++++--------
1 file changed, 44 insertions(+), 21 deletions(-)
--
1.7.10.4
_______________________________________________
Nios2-dev mailing list
Nios2-dev@lists.rocketboards.org
http://lists.rocketboards.org/cgi-bin/mailman/listinfo/nios2-dev
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Nios2-dev] [PATCH net-next 0/2] Altera TSE with no PHY
2014-10-10 20:46 ` [Nios2-dev] " Matthew Gerlach
@ 2014-10-11 22:24 ` Walter Lozano
0 siblings, 0 replies; 6+ messages in thread
From: Walter Lozano @ 2014-10-11 22:24 UTC (permalink / raw)
To: Matthew Gerlach
Cc: netdev@vger.kernel.org, f.fainelli@gmail.com,
tobias.klauser@gmail.com, vbridgers2013@gmail.com,
nios2-dev@lists.rocketboards.org, davem@davemloft.net,
guido@vanguardiasur.com.ar
Hi Matthew,
Thanks for your testing. I'm glad to hear that I didn't break
anything. Most of my testing
was done with a custom board with a SFP transceiver.
Regards,
Walter
On Fri, Oct 10, 2014 at 5:46 PM, Matthew Gerlach
<mgerlach@opensource.altera.com> wrote:
> Hi Walter,
>
> I've examined your patch, and it makes sense to me. I tested your patch again the TSE example design, and it did not break anything.
>
> Thanks,
> Matthew Gerlach
> ________________________________________
> From: nios2-dev-bounces@lists.rocketboards.org <nios2-dev-bounces@lists.rocketboards.org> on behalf of Walter Lozano <walter@vanguardiasur.com.ar>
> Sent: Friday, October 3, 2014 11:08 AM
> To: netdev@vger.kernel.org
> Cc: f.fainelli@gmail.com; tobias.klauser@gmail.com; vbridgers2013@gmail.com; nios2-dev@lists.rocketboards.org; davem@davemloft.net; guido@vanguardiasur.com.ar
> Subject: [Nios2-dev] [PATCH net-next 0/2] Altera TSE with no PHY
>
> In some scenarios there is no PHY chip present, for example in optical links.
> This serie of patches moves PHY get addr and MDIO create to a new function and
> avoids PHY and MDIO probing in these cases.
>
> Walter Lozano (2):
> Altera TSE: Move PHY get addr and MDIO create
> Altera TSE: Add support for no PHY
>
> drivers/net/ethernet/altera/altera_tse_main.c | 65 +++++++++++++++++--------
> 1 file changed, 44 insertions(+), 21 deletions(-)
>
> --
> 1.7.10.4
>
> _______________________________________________
> Nios2-dev mailing list
> Nios2-dev@lists.rocketboards.org
> http://lists.rocketboards.org/cgi-bin/mailman/listinfo/nios2-dev
--
Walter Lozano, VanguardiaSur
www.vanguardiasur.com.ar
^ permalink raw reply [flat|nested] 6+ messages in thread