Commit d9c0eb0c authored by David S. Miller's avatar David S. Miller

Merge branch 'bgmac-cleanups-PM-support'

Jon Mason says:

====================
net: ethernet: bgmac: PM support and clean-ups

Changes in v3:
* Corrected a bug Florian found and added his Reviewed-by

Changes in v2:
* Reworked the PM patch with Florian's suggestions

Add code to support Power Management (only tested on NS2), and add some
code clean-ups
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 452349c3 f3537b34
...@@ -192,36 +192,50 @@ static int bgmac_probe(struct bcma_device *core) ...@@ -192,36 +192,50 @@ static int bgmac_probe(struct bcma_device *core)
goto err1; goto err1;
} }
bgmac->has_robosw = !!(core->bus->sprom.boardflags_lo & bgmac->has_robosw = !!(sprom->boardflags_lo & BGMAC_BFL_ENETROBO);
BGMAC_BFL_ENETROBO);
if (bgmac->has_robosw) if (bgmac->has_robosw)
dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n"); dev_warn(bgmac->dev, "Support for Roboswitch not implemented\n");
if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM) if (sprom->boardflags_lo & BGMAC_BFL_ENETADM)
dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n"); dev_warn(bgmac->dev, "Support for ADMtek ethernet switch not implemented\n");
/* Feature Flags */ /* Feature Flags */
switch (core->bus->chipinfo.id) { switch (ci->id) {
/* BCM 471X/535X family */
case BCMA_CHIP_ID_BCM4716:
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
/* fallthrough */
case BCMA_CHIP_ID_BCM47162:
bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
break;
case BCMA_CHIP_ID_BCM5357: case BCMA_CHIP_ID_BCM5357:
case BCMA_CHIP_ID_BCM53572:
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK; bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1; bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY; bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47186) { if (ci->pkg == BCMA_PKG_ID_BCM47188 ||
bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED; ci->pkg == BCMA_PKG_ID_BCM47186) {
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII; bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
} }
if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM5358) if (ci->pkg == BCMA_PKG_ID_BCM5358)
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII; bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_EPHYRMII;
break; break;
case BCMA_CHIP_ID_BCM53572: case BCMA_CHIP_ID_BCM53573:
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1; bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY; if (ci->pkg == BCMA_PKG_ID_BCM47189)
if (core->bus->chipinfo.pkg == BCMA_PKG_ID_BCM47188) {
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED; bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
if (core->core_unit == 0) {
bgmac->feature_flags |= BGMAC_FEAT_CC4_IF_SW_TYPE;
if (ci->pkg == BCMA_PKG_ID_BCM47189)
bgmac->feature_flags |=
BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII;
} else if (core->core_unit == 1) {
bgmac->feature_flags |= BGMAC_FEAT_IRQ_ID_OOB_6;
bgmac->feature_flags |= BGMAC_FEAT_CC7_IF_TYPE_RGMII;
} }
break; break;
case BCMA_CHIP_ID_BCM4749: case BCMA_CHIP_ID_BCM4749:
...@@ -229,18 +243,11 @@ static int bgmac_probe(struct bcma_device *core) ...@@ -229,18 +243,11 @@ static int bgmac_probe(struct bcma_device *core)
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1; bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL1;
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY; bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_PHY;
if (core->bus->chipinfo.pkg == 10) { if (ci->pkg == 10) {
bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII; bgmac->feature_flags |= BGMAC_FEAT_SW_TYPE_RGMII;
bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED; bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
} }
break; break;
case BCMA_CHIP_ID_BCM4716:
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
/* fallthrough */
case BCMA_CHIP_ID_BCM47162:
bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
break;
/* bcm4707_family */ /* bcm4707_family */
case BCMA_CHIP_ID_BCM4707: case BCMA_CHIP_ID_BCM4707:
case BCMA_CHIP_ID_BCM47094: case BCMA_CHIP_ID_BCM47094:
...@@ -249,21 +256,6 @@ static int bgmac_probe(struct bcma_device *core) ...@@ -249,21 +256,6 @@ static int bgmac_probe(struct bcma_device *core)
bgmac->feature_flags |= BGMAC_FEAT_NO_RESET; bgmac->feature_flags |= BGMAC_FEAT_NO_RESET;
bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500; bgmac->feature_flags |= BGMAC_FEAT_FORCE_SPEED_2500;
break; break;
case BCMA_CHIP_ID_BCM53573:
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
if (ci->pkg == BCMA_PKG_ID_BCM47189)
bgmac->feature_flags |= BGMAC_FEAT_IOST_ATTACHED;
if (core->core_unit == 0) {
bgmac->feature_flags |= BGMAC_FEAT_CC4_IF_SW_TYPE;
if (ci->pkg == BCMA_PKG_ID_BCM47189)
bgmac->feature_flags |=
BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII;
} else if (core->core_unit == 1) {
bgmac->feature_flags |= BGMAC_FEAT_IRQ_ID_OOB_6;
bgmac->feature_flags |= BGMAC_FEAT_CC7_IF_TYPE_RGMII;
}
break;
default: default:
bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST; bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK; bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
......
...@@ -21,8 +21,12 @@ ...@@ -21,8 +21,12 @@
#include <linux/of_net.h> #include <linux/of_net.h>
#include "bgmac.h" #include "bgmac.h"
#define NICPM_PADRING_CFG 0x00000004
#define NICPM_IOMUX_CTRL 0x00000008 #define NICPM_IOMUX_CTRL 0x00000008
#define NICPM_PADRING_CFG_INIT_VAL 0x74000000
#define NICPM_IOMUX_CTRL_INIT_VAL_AX 0x21880000
#define NICPM_IOMUX_CTRL_INIT_VAL 0x3196e000 #define NICPM_IOMUX_CTRL_INIT_VAL 0x3196e000
#define NICPM_IOMUX_CTRL_SPD_SHIFT 10 #define NICPM_IOMUX_CTRL_SPD_SHIFT 10
#define NICPM_IOMUX_CTRL_SPD_10M 0 #define NICPM_IOMUX_CTRL_SPD_10M 0
...@@ -113,6 +117,10 @@ static void bgmac_nicpm_speed_set(struct net_device *net_dev) ...@@ -113,6 +117,10 @@ static void bgmac_nicpm_speed_set(struct net_device *net_dev)
if (!bgmac->plat.nicpm_base) if (!bgmac->plat.nicpm_base)
return; return;
/* SET RGMII IO CONFIG */
writel(NICPM_PADRING_CFG_INIT_VAL,
bgmac->plat.nicpm_base + NICPM_PADRING_CFG);
val = NICPM_IOMUX_CTRL_INIT_VAL; val = NICPM_IOMUX_CTRL_INIT_VAL;
switch (bgmac->net_dev->phydev->speed) { switch (bgmac->net_dev->phydev->speed) {
default: default:
...@@ -244,6 +252,31 @@ static int bgmac_remove(struct platform_device *pdev) ...@@ -244,6 +252,31 @@ static int bgmac_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM
static int bgmac_suspend(struct device *dev)
{
struct bgmac *bgmac = dev_get_drvdata(dev);
return bgmac_enet_suspend(bgmac);
}
static int bgmac_resume(struct device *dev)
{
struct bgmac *bgmac = dev_get_drvdata(dev);
return bgmac_enet_resume(bgmac);
}
static const struct dev_pm_ops bgmac_pm_ops = {
.suspend = bgmac_suspend,
.resume = bgmac_resume
};
#define BGMAC_PM_OPS (&bgmac_pm_ops)
#else
#define BGMAC_PM_OPS NULL
#endif /* CONFIG_PM */
static const struct of_device_id bgmac_of_enet_match[] = { static const struct of_device_id bgmac_of_enet_match[] = {
{.compatible = "brcm,amac",}, {.compatible = "brcm,amac",},
{.compatible = "brcm,nsp-amac",}, {.compatible = "brcm,nsp-amac",},
...@@ -257,6 +290,7 @@ static struct platform_driver bgmac_enet_driver = { ...@@ -257,6 +290,7 @@ static struct platform_driver bgmac_enet_driver = {
.driver = { .driver = {
.name = "bgmac-enet", .name = "bgmac-enet",
.of_match_table = bgmac_of_enet_match, .of_match_table = bgmac_of_enet_match,
.pm = BGMAC_PM_OPS
}, },
.probe = bgmac_probe, .probe = bgmac_probe,
.remove = bgmac_remove, .remove = bgmac_remove,
......
...@@ -1480,6 +1480,7 @@ int bgmac_enet_probe(struct bgmac *bgmac) ...@@ -1480,6 +1480,7 @@ int bgmac_enet_probe(struct bgmac *bgmac)
net_dev->irq = bgmac->irq; net_dev->irq = bgmac->irq;
SET_NETDEV_DEV(net_dev, bgmac->dev); SET_NETDEV_DEV(net_dev, bgmac->dev);
dev_set_drvdata(bgmac->dev, bgmac);
if (!is_valid_ether_addr(net_dev->dev_addr)) { if (!is_valid_ether_addr(net_dev->dev_addr)) {
dev_err(bgmac->dev, "Invalid MAC addr: %pM\n", dev_err(bgmac->dev, "Invalid MAC addr: %pM\n",
...@@ -1552,5 +1553,55 @@ void bgmac_enet_remove(struct bgmac *bgmac) ...@@ -1552,5 +1553,55 @@ void bgmac_enet_remove(struct bgmac *bgmac)
} }
EXPORT_SYMBOL_GPL(bgmac_enet_remove); EXPORT_SYMBOL_GPL(bgmac_enet_remove);
int bgmac_enet_suspend(struct bgmac *bgmac)
{
if (!netif_running(bgmac->net_dev))
return 0;
phy_stop(bgmac->net_dev->phydev);
netif_stop_queue(bgmac->net_dev);
napi_disable(&bgmac->napi);
netif_tx_lock(bgmac->net_dev);
netif_device_detach(bgmac->net_dev);
netif_tx_unlock(bgmac->net_dev);
bgmac_chip_intrs_off(bgmac);
bgmac_chip_reset(bgmac);
bgmac_dma_cleanup(bgmac);
return 0;
}
EXPORT_SYMBOL_GPL(bgmac_enet_suspend);
int bgmac_enet_resume(struct bgmac *bgmac)
{
int rc;
if (!netif_running(bgmac->net_dev))
return 0;
rc = bgmac_dma_init(bgmac);
if (rc)
return rc;
bgmac_chip_init(bgmac);
napi_enable(&bgmac->napi);
netif_tx_lock(bgmac->net_dev);
netif_device_attach(bgmac->net_dev);
netif_tx_unlock(bgmac->net_dev);
netif_start_queue(bgmac->net_dev);
phy_start(bgmac->net_dev->phydev);
return 0;
}
EXPORT_SYMBOL_GPL(bgmac_enet_resume);
MODULE_AUTHOR("Rafał Miłecki"); MODULE_AUTHOR("Rafał Miłecki");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -402,7 +402,7 @@ ...@@ -402,7 +402,7 @@
#define BGMAC_WEIGHT 64 #define BGMAC_WEIGHT 64
#define ETHER_MAX_LEN 1518 #define ETHER_MAX_LEN (ETH_FRAME_LEN + ETH_FCS_LEN)
/* Feature Flags */ /* Feature Flags */
#define BGMAC_FEAT_TX_MASK_SETUP BIT(0) #define BGMAC_FEAT_TX_MASK_SETUP BIT(0)
...@@ -537,6 +537,8 @@ int bgmac_enet_probe(struct bgmac *bgmac); ...@@ -537,6 +537,8 @@ int bgmac_enet_probe(struct bgmac *bgmac);
void bgmac_enet_remove(struct bgmac *bgmac); void bgmac_enet_remove(struct bgmac *bgmac);
void bgmac_adjust_link(struct net_device *net_dev); void bgmac_adjust_link(struct net_device *net_dev);
int bgmac_phy_connect_direct(struct bgmac *bgmac); int bgmac_phy_connect_direct(struct bgmac *bgmac);
int bgmac_enet_suspend(struct bgmac *bgmac);
int bgmac_enet_resume(struct bgmac *bgmac);
struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac); struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac);
void bcma_mdio_mii_unregister(struct mii_bus *mii_bus); void bcma_mdio_mii_unregister(struct mii_bus *mii_bus);
......
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