From: Hou Zhiqiang <b48286@freescale.com>
To: <linux-spi@vger.kernel.org>, <linuxppc-dev@ozlabs.org>
Cc: scottwood@freescale.com, Mingkai.Hu@freescale.com,
broonie@kernel.org, Hou Zhiqiang <b48286@freescale.com>
Subject: [PATCH] spi/fsl-espi: Add Power Management support for eSPI controller
Date: Wed, 11 Dec 2013 16:11:51 +0800 [thread overview]
Message-ID: <1386749511-21904-1-git-send-email-b48286@freescale.com> (raw)
Add PM support for eSPI controller using callback function suspend
and resume in .driver of platform_driver.
Signed-off-by: Hou Zhiqiang <b48286@freescale.com>
---
drivers/spi/spi-fsl-espi.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c
index 8106006..9c3fe70 100644
--- a/drivers/spi/spi-fsl-espi.c
+++ b/drivers/spi/spi-fsl-espi.c
@@ -727,6 +727,59 @@ static int of_fsl_espi_remove(struct platform_device *dev)
return mpc8xxx_spi_remove(&dev->dev);
}
+#ifdef CONFIG_PM
+static int of_fsl_espi_suspend(struct device *dev, pm_message_t state)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct spi_master *master = platform_get_drvdata(pdev);
+ struct mpc8xxx_spi *mpc8xxx_spi;
+ struct fsl_espi_reg *reg_base;
+ u32 regval;
+
+ mpc8xxx_spi = spi_master_get_devdata(master);
+ reg_base = mpc8xxx_spi->reg_base;
+
+ regval = mpc8xxx_spi_read_reg(®_base->mode);
+ regval &= ~(SPMODE_ENABLE);
+ mpc8xxx_spi_write_reg(®_base->mode, regval);
+
+ regval = mpc8xxx_spi_read_reg(®_base->mode);
+
+ return 0;
+}
+
+static int of_fsl_espi_resume(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
+ struct spi_master *master = platform_get_drvdata(pdev);
+ struct mpc8xxx_spi *mpc8xxx_spi;
+ struct fsl_espi_reg *reg_base;
+ u32 regval;
+ int i;
+
+ mpc8xxx_spi = spi_master_get_devdata(master);
+ reg_base = mpc8xxx_spi->reg_base;
+
+ /* SPI controller initializations */
+ mpc8xxx_spi_write_reg(®_base->mode, 0);
+ mpc8xxx_spi_write_reg(®_base->mask, 0);
+ mpc8xxx_spi_write_reg(®_base->command, 0);
+ mpc8xxx_spi_write_reg(®_base->event, 0xffffffff);
+
+ /* Init eSPI CS mode register */
+ for (i = 0; i < pdata->max_chipselect; i++)
+ mpc8xxx_spi_write_reg(®_base->csmode[i], CSMODE_INIT_VAL);
+
+ /* Enable SPI interface */
+ regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE;
+
+ mpc8xxx_spi_write_reg(®_base->mode, regval);
+
+ return 0;
+}
+#endif /* CONFIG_PM */
+
static const struct of_device_id of_fsl_espi_match[] = {
{ .compatible = "fsl,mpc8536-espi" },
{}
@@ -738,6 +791,10 @@ static struct platform_driver fsl_espi_driver = {
.name = "fsl_espi",
.owner = THIS_MODULE,
.of_match_table = of_fsl_espi_match,
+#ifdef CONFIG_PM
+ .suspend = of_fsl_espi_suspend,
+ .resume = of_fsl_espi_resume,
+#endif
},
.probe = of_fsl_espi_probe,
.remove = of_fsl_espi_remove,
--
1.8.4.1
next reply other threads:[~2013-12-11 9:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 8:11 Hou Zhiqiang [this message]
2013-12-11 13:39 ` [PATCH] spi/fsl-espi: Add Power Management support for eSPI controller Mark Brown
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=1386749511-21904-1-git-send-email-b48286@freescale.com \
--to=b48286@freescale.com \
--cc=Mingkai.Hu@freescale.com \
--cc=broonie@kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=scottwood@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).