From: Aaro Koskinen <aaro.koskinen@nokia.com>
To: ext Kevin Hilman <khilman@deeprootsystems.com>
Cc: "linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
Hemanth V <hemanthv@ti.com>,
"Hogander Jouni (Nokia-D/Tampere)" <jouni.hogander@nokia.com>
Subject: Re: [PATCH 3/4] OMAP3 McSPI: Adds context save/restore
Date: Mon, 29 Jun 2009 17:25:05 +0300 [thread overview]
Message-ID: <4A48CEC1.10203@nokia.com> (raw)
In-Reply-To: <4A44B8D7.8020508@nokia.com>
[-- Attachment #1: Type: text/plain, Size: 990 bytes --]
Hello,
Koskinen Aaro (Nokia-D/Helsinki) wrote:
> I'm afraid this patch needs more work. The optimized restoration of
> chconf can cause occasionally errors with off mode if multiple chip
> selects are in use. In practice it is needed to restore all CHxCONF
> registers, not just the one by a specific chip select.
>
> ext Kevin Hilman wrote:
>> From: Hemanth V <hemanthv@ti.com>
>>
>> This patch adds context save/restore feature to McSPI driver.
>> This includes fixes by Aaro Koskinen
>>
>> Signed-off-by: Hemanth V <hemanthv@ti.com>
>> Reviewed-by: Aaro Koskinen <Aaro.Koskinen@nokia.com>
>> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
>> ---
>> drivers/spi/omap2_mcspi.c | 134 +++++++++++++++++++++++++++++++++-----------
>> 1 files changed, 100 insertions(+), 34 deletions(-)
Here's a patch on top of PM branch that restores all the registers. This
is basically the same what Jouni originally suggested
(http://marc.info/?l=linux-omap&m=123366825525879&w=2).
A.
[-- Attachment #2: 0001-PM-OMAP-SPI-Restore-all-CHxCONF-registers.patch --]
[-- Type: text/x-diff, Size: 2940 bytes --]
>From 92ee5d91385e96a358d44b0e59ae3484d4191786 Mon Sep 17 00:00:00 2001
From: Aaro Koskinen <aaro.koskinen@nokia.com>
Date: Mon, 29 Jun 2009 14:20:49 +0300
Subject: [PATCH] PM: OMAP: SPI: Restore all CHxCONF registers
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
---
drivers/spi/omap2_mcspi.c | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index a75c546..264bd21 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -43,6 +43,7 @@
/* OMAP2 has 3 SPI controllers, while OMAP3 has 4 */
#define OMAP2_MCSPI_MAX_CTRL 4
+#define OMAP2_MCSPI_MAX_CS 4
#define OMAP2_MCSPI_REVISION 0x00
#define OMAP2_MCSPI_SYSCONFIG 0x10
@@ -134,8 +135,6 @@ struct omap2_mcspi_cs {
void __iomem *base;
unsigned long phys;
int word_len;
- /* Context save and restore shadow register */
- u32 chconf0;
};
/* used for context save and restore, structure members to be updated whenever
@@ -145,6 +144,8 @@ struct omap2_mcspi_regs {
u32 sysconfig;
u32 modulctrl;
u32 wakeupenable;
+ /* Context save and restore shadow register for each chipselect */
+ u32 chconf0[OMAP2_MCSPI_MAX_CS];
};
static struct omap2_mcspi_regs omap2_mcspi_ctx[OMAP2_MCSPI_MAX_CTRL];
@@ -190,16 +191,16 @@ static inline u32 mcspi_read_cs_reg(const struct spi_device *spi, int idx)
static inline u32 mcspi_cached_chconf0(const struct spi_device *spi)
{
- struct omap2_mcspi_cs *cs = spi->controller_state;
+ int cs = spi->chip_select;
- return cs->chconf0;
+ return omap2_mcspi_ctx[spi->master->bus_num - 1].chconf0[cs];
}
static inline void mcspi_write_chconf0(const struct spi_device *spi, u32 val)
{
- struct omap2_mcspi_cs *cs = spi->controller_state;
+ int cs = spi->chip_select;
- cs->chconf0 = val;
+ omap2_mcspi_ctx[spi->master->bus_num - 1].chconf0[cs] = val;
mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, val);
}
@@ -255,6 +256,8 @@ static void omap2_mcspi_set_master_mode(struct spi_master *master)
static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
{
struct spi_master *spi_cntrl;
+ int cs;
+
spi_cntrl = mcspi->master;
/* McSPI: context restore */
@@ -266,6 +269,11 @@ static void omap2_mcspi_restore_ctx(struct omap2_mcspi *mcspi)
mcspi_write_reg(spi_cntrl, OMAP2_MCSPI_WAKEUPENABLE,
omap2_mcspi_ctx[spi_cntrl->bus_num - 1].wakeupenable);
+
+ for (cs = 0; cs < spi_cntrl->num_chipselect; cs++)
+ mcspi_write_reg(spi_cntrl,
+ cs * 0x14 + OMAP2_MCSPI_CHCONF0,
+ omap2_mcspi_ctx[spi_cntrl->bus_num - 1].chconf0[cs]);
}
static void omap2_mcspi_disable_clocks(struct omap2_mcspi *mcspi)
{
@@ -704,7 +712,6 @@ static int omap2_mcspi_setup(struct spi_device *spi)
return -ENOMEM;
cs->base = mcspi->base + spi->chip_select * 0x14;
cs->phys = mcspi->phys + spi->chip_select * 0x14;
- cs->chconf0 = 0;
spi->controller_state = cs;
}
--
1.5.4.3
prev parent reply other threads:[~2009-06-29 14:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-25 21:34 [PATCH 0/4] driver updates from PM branch for upstream Kevin Hilman
2009-06-25 21:34 ` [PATCH 1/4] OMAP: McSPI: enable wake-ups and smart-idle Kevin Hilman
2009-06-25 21:34 ` [PATCH 2/4] OMAP: McSPI: Convert bit shifted values into BIT format Kevin Hilman
2009-06-25 21:34 ` [PATCH 3/4] OMAP3 McSPI: Adds context save/restore Kevin Hilman
2009-06-25 21:34 ` [PATCH 4/4] I2C: OMAP3: PM: (re)init for every transfer to support off-mode Kevin Hilman
2009-06-26 11:13 ` Aaro Koskinen
2009-06-26 14:19 ` Kevin Hilman
2009-06-29 8:51 ` HU TAO-TGHK48
2009-06-29 17:04 ` Kevin Hilman
2009-06-29 19:28 ` Hunter, Jon
2009-06-29 21:15 ` Kevin Hilman
2009-06-30 16:49 ` Hunter, Jon
2009-07-01 9:43 ` HU TAO-TGHK48
2009-06-26 12:02 ` [PATCH 3/4] OMAP3 McSPI: Adds context save/restore Aaro Koskinen
2009-06-29 14:25 ` Aaro Koskinen [this message]
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=4A48CEC1.10203@nokia.com \
--to=aaro.koskinen@nokia.com \
--cc=hemanthv@ti.com \
--cc=jouni.hogander@nokia.com \
--cc=khilman@deeprootsystems.com \
--cc=linux-omap@vger.kernel.org \
/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