summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSuman Tripathi <stripathi@apm.com>2015-06-23 12:17:14 +0300
committerDavid S. Miller <davem@davemloft.net>2015-06-23 17:19:18 +0300
commit0738c54d63249bd4a51aa2e899877c8316f19957 (patch)
tree216502bacd393cb2dd169006ebfd4bbfee2d87cc /drivers
parent0dd0770936363ecd4d49192782bceccb882d3a24 (diff)
downloadlinux-0738c54d63249bd4a51aa2e899877c8316f19957.tar.xz
drivers: net: xgene: Fix the ACPI support for RGMII/SGMII0/XFI interface of APM X-Gene SoC ethernet controller.
This patch implements couple of fixes to support ACPI for RGMII/SGMII0/XFI interface of APM X-Gene SoC ethernet controller driver. This patch uses the _SUN acpi object to fetch the port-id information whereas the FDT uses port-id binding for port-id information. Signed-off-by: Iyappan Subramanian <isubramanian@apm.com> Signed-off-by: Suman Tripathi <stripathi@apm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.c2
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_main.c64
2 files changed, 43 insertions, 23 deletions
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 25873d142b95..8ff736d5971c 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -751,7 +751,7 @@ static int xgene_mdiobus_register(struct xgene_enet_pdata *pdata,
if (ret)
return -EINVAL;
- phy = get_phy_device(mdio, phy_id, true);
+ phy = get_phy_device(mdio, phy_id, false);
if (!phy || IS_ERR(phy))
return -EIO;
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
index 1bb317532f75..17f0df508f72 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -29,6 +29,7 @@
#define RES_RING_CMD 2
static const struct of_device_id xgene_enet_of_match[];
+static const struct acpi_device_id xgene_enet_acpi_match[];
static void xgene_enet_init_bufpool(struct xgene_enet_desc_ring *buf_pool)
{
@@ -870,24 +871,33 @@ static const struct net_device_ops xgene_ndev_ops = {
.ndo_set_mac_address = xgene_enet_set_mac_address,
};
-static int xgene_get_port_id(struct device *dev, struct xgene_enet_pdata *pdata)
+static int xgene_get_port_id_acpi(struct device *dev,
+ struct xgene_enet_pdata *pdata)
+{
+ acpi_status status;
+ u64 temp;
+
+ status = acpi_evaluate_integer(ACPI_HANDLE(dev), "_SUN", NULL, &temp);
+ if (ACPI_FAILURE(status)) {
+ pdata->port_id = 0;
+ } else {
+ pdata->port_id = temp;
+ }
+
+ return 0;
+}
+
+static int xgene_get_port_id_dt(struct device *dev, struct xgene_enet_pdata *pdata)
{
u32 id = 0;
int ret;
- ret = device_property_read_u32(dev, "port-id", &id);
-
- switch (ret) {
- case -EINVAL:
+ ret = of_property_read_u32(dev->of_node, "port-id", &id);
+ if (ret) {
pdata->port_id = 0;
ret = 0;
- break;
- case 0:
+ } else {
pdata->port_id = id & BIT(0);
- break;
- default:
- dev_err(dev, "Incorrect port-id specified: errno: %d\n", ret);
- break;
}
return ret;
@@ -977,7 +987,12 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
return -ENOMEM;
}
- ret = xgene_get_port_id(dev, pdata);
+ if (dev->of_node)
+ ret = xgene_get_port_id_dt(dev, pdata);
+#ifdef CONFIG_ACPI
+ else
+ ret = xgene_get_port_id_acpi(dev, pdata);
+#endif
if (ret)
return ret;
@@ -1173,9 +1188,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
struct xgene_enet_pdata *pdata;
struct device *dev = &pdev->dev;
struct xgene_mac_ops *mac_ops;
-#ifdef CONFIG_OF
const struct of_device_id *of_id;
-#endif
int ret;
ndev = alloc_etherdev(sizeof(struct xgene_enet_pdata));
@@ -1194,16 +1207,23 @@ static int xgene_enet_probe(struct platform_device *pdev)
NETIF_F_GSO |
NETIF_F_GRO;
-#ifdef CONFIG_OF
of_id = of_match_device(xgene_enet_of_match, &pdev->dev);
if (of_id) {
pdata->enet_id = (enum xgene_enet_id)of_id->data;
- if (!pdata->enet_id) {
- free_netdev(ndev);
- return -ENODEV;
- }
+ }
+#ifdef CONFIG_ACPI
+ else {
+ const struct acpi_device_id *acpi_id;
+
+ acpi_id = acpi_match_device(xgene_enet_acpi_match, &pdev->dev);
+ if (acpi_id)
+ pdata->enet_id = (enum xgene_enet_id) acpi_id->driver_data;
}
#endif
+ if (!pdata->enet_id) {
+ free_netdev(ndev);
+ return -ENODEV;
+ }
ret = xgene_enet_get_resources(pdata);
if (ret)
@@ -1266,9 +1286,9 @@ static int xgene_enet_remove(struct platform_device *pdev)
#ifdef CONFIG_ACPI
static const struct acpi_device_id xgene_enet_acpi_match[] = {
- { "APMC0D05", },
- { "APMC0D30", },
- { "APMC0D31", },
+ { "APMC0D05", XGENE_ENET1},
+ { "APMC0D30", XGENE_ENET1},
+ { "APMC0D31", XGENE_ENET1},
{ }
};
MODULE_DEVICE_TABLE(acpi, xgene_enet_acpi_match);