[PATCH 3/3] net: qcom/emac: add support for emulation systems

2017-06-23 Thread Timur Tabi
On emulation systems, the EMAC's internal PHY ("SGMII") is not present,
but is not needed for network functionality.  So just display a warning
message and ignore the SGMII.

Tested-by: Philip Elcan 
Tested-by: Adam Wallis 
Signed-off-by: Timur Tabi 
---
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c 
b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index 18c184e..29ba37a 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -297,6 +297,14 @@ static int emac_sgmii_acpi_match(struct device *dev, void 
*data)
{}
 };
 
+/* Dummy function for systems without an internal PHY. This avoids having
+ * to check for NULL pointers before calling the functions.
+ */
+static int emac_sgmii_dummy(struct emac_adapter *adpt)
+{
+   return 0;
+}
+
 int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
 {
struct platform_device *sgmii_pdev = NULL;
@@ -311,8 +319,19 @@ int emac_sgmii_config(struct platform_device *pdev, struct 
emac_adapter *adpt)
emac_sgmii_acpi_match);
 
if (!dev) {
-   dev_err(>dev, "cannot find internal phy node\n");
-   return -ENODEV;
+   dev_warn(>dev, "cannot find internal phy node\n");
+   /* There is typically no internal PHY on emulation
+* systems, so if we can't find the node, assume
+* we are on an emulation system and stub-out
+* support for the internal PHY.  These systems only
+* use ACPI.
+*/
+   phy->open = emac_sgmii_dummy;
+   phy->close = emac_sgmii_dummy;
+   phy->link_up = emac_sgmii_dummy;
+   phy->link_down = emac_sgmii_dummy;
+
+   return 0;
}
 
sgmii_pdev = to_platform_device(dev);
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



[PATCH 3/3] net: qcom/emac: add support for emulation systems

2017-06-22 Thread Timur Tabi
On emulation systems, the EMAC's internal PHY ("SGMII") is not present,
but is not needed for network functionality.  So just display a warning
message and ignore the SGMII.

Tested-by: Philip Elcan 
Tested-by: Adam Wallis 
Signed-off-by: Timur Tabi 
---
 drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c 
b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index 18c184e..29ba37a 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -297,6 +297,14 @@ static int emac_sgmii_acpi_match(struct device *dev, void 
*data)
{}
 };
 
+/* Dummy function for systems without an internal PHY. This avoids having
+ * to check for NULL pointers before calling the functions.
+ */
+static int emac_sgmii_dummy(struct emac_adapter *adpt)
+{
+   return 0;
+}
+
 int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
 {
struct platform_device *sgmii_pdev = NULL;
@@ -311,8 +319,19 @@ int emac_sgmii_config(struct platform_device *pdev, struct 
emac_adapter *adpt)
emac_sgmii_acpi_match);
 
if (!dev) {
-   dev_err(>dev, "cannot find internal phy node\n");
-   return -ENODEV;
+   dev_warn(>dev, "cannot find internal phy node\n");
+   /* There is typically no internal PHY on emulation
+* systems, so if we can't find the node, assume
+* we are on an emulation system and stub-out
+* support for the internal PHY.  These systems only
+* use ACPI.
+*/
+   phy->open = emac_sgmii_dummy;
+   phy->close = emac_sgmii_dummy;
+   phy->link_up = emac_sgmii_dummy;
+   phy->link_down = emac_sgmii_dummy;
+
+   return 0;
}
 
sgmii_pdev = to_platform_device(dev);
-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.