Commit 0a51f76e authored by David S. Miller's avatar David S. Miller

Merge branch 'xgene-next'

Suman Tripathi says:

====================
drivers: net: xgene: Fix the ACPI support for RGMII/SGMII0/XFI ethernet interfaces of APM X-Gene SoC.
====================
Signed-off-by: default avatarIyappan Subramanian <isubramanian@apm.com>
Signed-off-by: default avatarSuman Tripathi <stripathi@apm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0dd07709 c2d33bdc
...@@ -610,7 +610,7 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata) ...@@ -610,7 +610,7 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
if (!xgene_ring_mgr_init(pdata)) if (!xgene_ring_mgr_init(pdata))
return -ENODEV; return -ENODEV;
if (pdata->clk) { if (!IS_ERR(pdata->clk)) {
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
clk_disable_unprepare(pdata->clk); clk_disable_unprepare(pdata->clk);
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
...@@ -629,6 +629,7 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata) ...@@ -629,6 +629,7 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata) static void xgene_gport_shutdown(struct xgene_enet_pdata *pdata)
{ {
if (!IS_ERR(pdata->clk))
clk_disable_unprepare(pdata->clk); clk_disable_unprepare(pdata->clk);
} }
...@@ -751,7 +752,7 @@ static int xgene_mdiobus_register(struct xgene_enet_pdata *pdata, ...@@ -751,7 +752,7 @@ static int xgene_mdiobus_register(struct xgene_enet_pdata *pdata,
if (ret) if (ret)
return -EINVAL; return -EINVAL;
phy = get_phy_device(mdio, phy_id, true); phy = get_phy_device(mdio, phy_id, false);
if (!phy || IS_ERR(phy)) if (!phy || IS_ERR(phy))
return -EIO; return -EIO;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#define RES_RING_CMD 2 #define RES_RING_CMD 2
static const struct of_device_id xgene_enet_of_match[]; 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) 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 = { ...@@ -870,24 +871,33 @@ static const struct net_device_ops xgene_ndev_ops = {
.ndo_set_mac_address = xgene_enet_set_mac_address, .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; u32 id = 0;
int ret; int ret;
ret = device_property_read_u32(dev, "port-id", &id); ret = of_property_read_u32(dev->of_node, "port-id", &id);
if (ret) {
switch (ret) {
case -EINVAL:
pdata->port_id = 0; pdata->port_id = 0;
ret = 0; ret = 0;
break; } else {
case 0:
pdata->port_id = id & BIT(0); pdata->port_id = id & BIT(0);
break;
default:
dev_err(dev, "Incorrect port-id specified: errno: %d\n", ret);
break;
} }
return ret; return ret;
...@@ -977,7 +987,12 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) ...@@ -977,7 +987,12 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
return -ENOMEM; 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) if (ret)
return ret; return ret;
...@@ -1009,17 +1024,19 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) ...@@ -1009,17 +1024,19 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
if (pdata->phy_mode != PHY_INTERFACE_MODE_RGMII) { if (pdata->phy_mode != PHY_INTERFACE_MODE_RGMII) {
ret = platform_get_irq(pdev, 1); ret = platform_get_irq(pdev, 1);
if (ret <= 0) { if (ret <= 0) {
dev_err(dev, "Unable to get ENET Tx completion IRQ\n"); pdata->cq_cnt = 0;
ret = ret ? : -ENXIO; dev_info(dev, "Unable to get Tx completion IRQ,"
return ret; "using Rx IRQ instead\n");
} } else {
pdata->cq_cnt = XGENE_MAX_TXC_RINGS;
pdata->txc_irq = ret; pdata->txc_irq = ret;
} }
}
pdata->clk = devm_clk_get(&pdev->dev, NULL); pdata->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(pdata->clk)) { if (IS_ERR(pdata->clk)) {
/* Firmware may have set up the clock already. */ /* Firmware may have set up the clock already. */
pdata->clk = NULL; dev_info(dev, "clocks have been setup already\n");
} }
if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII)
...@@ -1090,13 +1107,11 @@ static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata) ...@@ -1090,13 +1107,11 @@ static void xgene_enet_setup_ops(struct xgene_enet_pdata *pdata)
pdata->mac_ops = &xgene_sgmac_ops; pdata->mac_ops = &xgene_sgmac_ops;
pdata->port_ops = &xgene_sgport_ops; pdata->port_ops = &xgene_sgport_ops;
pdata->rm = RM1; pdata->rm = RM1;
pdata->cq_cnt = XGENE_MAX_TXC_RINGS;
break; break;
default: default:
pdata->mac_ops = &xgene_xgmac_ops; pdata->mac_ops = &xgene_xgmac_ops;
pdata->port_ops = &xgene_xgport_ops; pdata->port_ops = &xgene_xgport_ops;
pdata->rm = RM0; pdata->rm = RM0;
pdata->cq_cnt = XGENE_MAX_TXC_RINGS;
break; break;
} }
...@@ -1173,9 +1188,7 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -1173,9 +1188,7 @@ static int xgene_enet_probe(struct platform_device *pdev)
struct xgene_enet_pdata *pdata; struct xgene_enet_pdata *pdata;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct xgene_mac_ops *mac_ops; struct xgene_mac_ops *mac_ops;
#ifdef CONFIG_OF
const struct of_device_id *of_id; const struct of_device_id *of_id;
#endif
int ret; int ret;
ndev = alloc_etherdev(sizeof(struct xgene_enet_pdata)); ndev = alloc_etherdev(sizeof(struct xgene_enet_pdata));
...@@ -1194,16 +1207,23 @@ static int xgene_enet_probe(struct platform_device *pdev) ...@@ -1194,16 +1207,23 @@ static int xgene_enet_probe(struct platform_device *pdev)
NETIF_F_GSO | NETIF_F_GSO |
NETIF_F_GRO; NETIF_F_GRO;
#ifdef CONFIG_OF
of_id = of_match_device(xgene_enet_of_match, &pdev->dev); of_id = of_match_device(xgene_enet_of_match, &pdev->dev);
if (of_id) { if (of_id) {
pdata->enet_id = (enum xgene_enet_id)of_id->data; pdata->enet_id = (enum xgene_enet_id)of_id->data;
}
#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) { if (!pdata->enet_id) {
free_netdev(ndev); free_netdev(ndev);
return -ENODEV; return -ENODEV;
} }
}
#endif
ret = xgene_enet_get_resources(pdata); ret = xgene_enet_get_resources(pdata);
if (ret) if (ret)
...@@ -1266,9 +1286,11 @@ static int xgene_enet_remove(struct platform_device *pdev) ...@@ -1266,9 +1286,11 @@ static int xgene_enet_remove(struct platform_device *pdev)
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static const struct acpi_device_id xgene_enet_acpi_match[] = { static const struct acpi_device_id xgene_enet_acpi_match[] = {
{ "APMC0D05", }, { "APMC0D05", XGENE_ENET1},
{ "APMC0D30", }, { "APMC0D30", XGENE_ENET1},
{ "APMC0D31", }, { "APMC0D31", XGENE_ENET1},
{ "APMC0D26", XGENE_ENET2},
{ "APMC0D25", XGENE_ENET2},
{ } { }
}; };
MODULE_DEVICE_TABLE(acpi, xgene_enet_acpi_match); MODULE_DEVICE_TABLE(acpi, xgene_enet_acpi_match);
......
...@@ -334,9 +334,11 @@ static int xgene_enet_reset(struct xgene_enet_pdata *p) ...@@ -334,9 +334,11 @@ static int xgene_enet_reset(struct xgene_enet_pdata *p)
if (!xgene_ring_mgr_init(p)) if (!xgene_ring_mgr_init(p))
return -ENODEV; return -ENODEV;
if (!IS_ERR(p->clk)) {
clk_prepare_enable(p->clk); clk_prepare_enable(p->clk);
clk_disable_unprepare(p->clk); clk_disable_unprepare(p->clk);
clk_prepare_enable(p->clk); clk_prepare_enable(p->clk);
}
xgene_enet_ecc_init(p); xgene_enet_ecc_init(p);
xgene_enet_config_ring_if_assoc(p); xgene_enet_config_ring_if_assoc(p);
...@@ -369,6 +371,7 @@ static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p, ...@@ -369,6 +371,7 @@ static void xgene_enet_cle_bypass(struct xgene_enet_pdata *p,
static void xgene_enet_shutdown(struct xgene_enet_pdata *p) static void xgene_enet_shutdown(struct xgene_enet_pdata *p)
{ {
if (!IS_ERR(p->clk))
clk_disable_unprepare(p->clk); clk_disable_unprepare(p->clk);
} }
......
...@@ -256,9 +256,11 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata) ...@@ -256,9 +256,11 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
if (!xgene_ring_mgr_init(pdata)) if (!xgene_ring_mgr_init(pdata))
return -ENODEV; return -ENODEV;
if (!IS_ERR(pdata->clk)) {
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
clk_disable_unprepare(pdata->clk); clk_disable_unprepare(pdata->clk);
clk_prepare_enable(pdata->clk); clk_prepare_enable(pdata->clk);
}
xgene_enet_ecc_init(pdata); xgene_enet_ecc_init(pdata);
xgene_enet_config_ring_if_assoc(pdata); xgene_enet_config_ring_if_assoc(pdata);
...@@ -285,6 +287,7 @@ static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata, ...@@ -285,6 +287,7 @@ static void xgene_enet_xgcle_bypass(struct xgene_enet_pdata *pdata,
static void xgene_enet_shutdown(struct xgene_enet_pdata *pdata) static void xgene_enet_shutdown(struct xgene_enet_pdata *pdata)
{ {
if (!IS_ERR(pdata->clk))
clk_disable_unprepare(pdata->clk); clk_disable_unprepare(pdata->clk);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment