From: Domen Puncer <domen.puncer@telargo•com>
To: linuxppc-embedded@ozlabs•org
Subject: [PATCH 2/5] mpc52xx suspend: FEC (ethernet)
Date: Thu, 15 Mar 2007 11:41:58 +0100 [thread overview]
Message-ID: <20070315104158.GC22215@moe.telargo.com> (raw)
In-Reply-To: <20070315103959.GA22215@moe.telargo.com>
Suspend and resume for FEC on MPC52xx.
Note that resume is a bit different for lite5200b low-power mode.
Signed-off-by: Domen Puncer <domen.puncer@telargo•com>
---
drivers/net/fec_mpc52xx/fec.c | 60 ++++++++++++++++++++++++++++++++++++--
drivers/net/fec_mpc52xx/fec_phy.c | 17 ++++++++++
drivers/net/fec_mpc52xx/fec_phy.h | 5 +++
3 files changed, 80 insertions(+), 2 deletions(-)
Index: grant.git/drivers/net/fec_mpc52xx/fec.c
===================================================================
--- grant.git.orig/drivers/net/fec_mpc52xx/fec.c
+++ grant.git/drivers/net/fec_mpc52xx/fec.c
@@ -801,6 +801,62 @@ mpc52xx_fec_remove(struct device *dev)
return 0;
}
+#ifdef CONFIG_PM
+static int mpc52xx_fec_suspend(struct of_device *op, pm_message_t state)
+{
+ struct net_device *ndev = dev_get_drvdata(&op->dev);
+ struct fec_priv *priv = ndev->priv;
+ struct mpc52xx_fec *fec = priv->fec;
+
+ netif_device_detach(ndev);
+
+ /* Disable the rx and tx tasks. */
+ sdma_disable(priv->rx_sdma);
+ sdma_disable(priv->tx_sdma);
+
+ fec_free_rx_buffers(priv->rx_sdma);
+
+ /* Stop FEC */
+ out_be32(&fec->ecntrl, in_be32(&fec->ecntrl) & ~0x2);
+
+ fec_mii_suspend(ndev);
+
+ return 0;
+}
+
+int mpc52xx_fec_resume(struct of_device *op)
+{
+ struct net_device *ndev = dev_get_drvdata(&op->dev);
+ struct fec_priv *priv = ndev->priv;
+ struct mpc52xx_fec *fec = priv->fec;
+
+ /* XXX ugly hack */
+ /* not deep-sleep (but low-power), so re-init hw */
+ if (*(unsigned long *)CONFIG_KERNEL_START != 0x60000000) {
+ *(unsigned long *)CONFIG_KERNEL_START = 0x60000000; // restore
+ fec_mii_init(ndev);
+ fec_hw_init(ndev);
+ } else
+ fec_mii_resume(ndev);
+
+ /* Restart the DMA tasks */
+ sdma_fec_rx_init(priv->rx_sdma, priv->rx_fifo, FEC_RX_BUFFER_SIZE);
+ sdma_fec_tx_init(priv->tx_sdma, priv->tx_fifo);
+
+ /* Start FEC */
+ out_be32(&fec->ecntrl, in_be32(&fec->ecntrl) | 0x2);
+
+ netif_device_attach(ndev);
+
+ if (priv->sequence_done) { /* redo the fec_open() */
+ fec_free_rx_buffers(priv->rx_sdma);
+ fec_open(ndev);
+ }
+
+ return 0;
+}
+#endif
+
#if defined(CONFIG_PPC_MERGE)
static struct of_device_id mpc52xx_fec_of_match[] = {
{ .compatible = "mpc5200-ethernet", },
@@ -815,8 +871,8 @@ static struct of_platform_driver mpc52xx
.probe = mpc52xx_fec_probe,
.remove = mpc52xx_fec_remove,
#ifdef CONFIG_PM
-/* .suspend = mpc52xx_fec_suspend, TODO */
-/* .resume = mpc52xx_fec_resume, TODO */
+ .suspend = mpc52xx_fec_suspend,
+ .resume = mpc52xx_fec_resume,
#endif
.driver = {
.name = DRIVER_NAME,
Index: grant.git/drivers/net/fec_mpc52xx/fec_phy.c
===================================================================
--- grant.git.orig/drivers/net/fec_mpc52xx/fec_phy.c
+++ grant.git/drivers/net/fec_mpc52xx/fec_phy.c
@@ -527,6 +527,23 @@ int fec_mii_wait(struct net_device *dev)
return 0;
}
+#ifdef CONFIG_PM
+phy_cmd_t phy_cmd_off[] = { { mk_mii_write(MII_BMCR, BMCR_PDOWN), NULL },
+ { mk_mii_end, } };
+phy_cmd_t phy_cmd_on[] = { { mk_mii_write(MII_BMCR, 0), NULL },
+ { mk_mii_end, } };
+
+void fec_mii_suspend(struct net_device *dev)
+{
+ mii_do_cmd(dev, phy_cmd_off);
+}
+
+void fec_mii_resume(struct net_device *dev)
+{
+ mii_do_cmd(dev, phy_cmd_on);
+}
+#endif
+
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Dale Farnsworth");
MODULE_DESCRIPTION("PHY driver for Motorola MPC52xx FEC");
Index: grant.git/drivers/net/fec_mpc52xx/fec_phy.h
===================================================================
--- grant.git.orig/drivers/net/fec_mpc52xx/fec_phy.h
+++ grant.git/drivers/net/fec_mpc52xx/fec_phy.h
@@ -71,3 +71,8 @@ extern int fec_mii_wait(struct net_devic
extern void fec_mii(struct net_device *dev);
extern int fec_ioctl(struct net_device *, struct ifreq *rq, int cmd);
+
+#ifdef CONFIG_PM
+extern void fec_mii_suspend(struct net_device *dev);
+extern void fec_mii_resume(struct net_device *dev);
+#endif
next prev parent reply other threads:[~2007-03-15 10:42 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-15 10:39 [PATCH 0/5 v2] MPC5200 and Lite5200b low power modes Domen Puncer
2007-03-15 10:41 ` [PATCH 1/5] mpc52xx suspend: UART Domen Puncer
2007-03-15 10:41 ` Domen Puncer [this message]
2007-03-15 13:35 ` [PATCH 2/5] mpc52xx suspend: FEC (ethernet) Grant Likely
2007-03-15 10:42 ` [PATCH 3/5] mpc52xx suspend: USB Domen Puncer
2007-03-15 13:24 ` Grant Likely
2007-03-15 14:37 ` Wrong board info for ML403 Leonid
2007-03-16 8:15 ` Andrei Konovalov
2007-03-22 7:44 ` [PATCH 3/5 v2] mpc52xx suspend: USB Domen Puncer
2007-03-23 11:56 ` Sylvain Munaut
2007-03-23 16:00 ` Grant Likely
2007-03-15 10:43 ` [PATCH 4/5] mpc52xx suspend: deep-sleep Domen Puncer
2007-03-23 15:58 ` Grant Likely
2007-04-04 7:37 ` Domen Puncer
2007-04-16 5:40 ` Grant Likely
2007-04-17 7:05 ` Domen Puncer
2007-04-17 7:10 ` Grant Likely
2007-03-15 10:44 ` [PATCH] icecube/lite5200b: wakeup from low-power support Domen Puncer
2007-03-26 16:08 ` Grant Likely
2007-04-03 8:46 ` Domen Puncer
2007-04-16 4:45 ` Grant Likely
2007-04-16 6:25 ` Domen Puncer
2007-03-31 17:20 ` Rafal Jaworowski
2007-03-31 18:38 ` Domen Puncer
2007-03-15 10:44 ` [PATCH 5/5] lite5200b suspend: low-power mode Domen Puncer
2007-03-15 14:09 ` Grant Likely
2007-03-15 16:36 ` Domen Puncer
2007-03-22 7:41 ` Domen Puncer
2007-03-26 13:23 ` Domen Puncer
2007-03-26 15:54 ` Grant Likely
2007-04-17 7:11 ` Domen Puncer
2007-04-17 7:25 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070315104158.GC22215@moe.telargo.com \
--to=domen.puncer@telargo$(echo .)com \
--cc=linuxppc-embedded@ozlabs$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox