From patchwork Mon Jun 29 14:25:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Koskinen, Aaro (Nokia - FI/Espoo)" X-Patchwork-Id: 32960 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5TEPQDH014114 for ; Mon, 29 Jun 2009 14:25:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369AbZF2OZV (ORCPT ); Mon, 29 Jun 2009 10:25:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752746AbZF2OZV (ORCPT ); Mon, 29 Jun 2009 10:25:21 -0400 Received: from smtp.nokia.com ([192.100.122.233]:30840 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751369AbZF2OZU (ORCPT ); Mon, 29 Jun 2009 10:25:20 -0400 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx06.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n5TEOoMh016334; Mon, 29 Jun 2009 17:25:13 +0300 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 29 Jun 2009 17:25:07 +0300 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 29 Jun 2009 17:25:06 +0300 Received: from [172.21.43.221] (esdhcp043221.research.nokia.com [172.21.43.221]) by mgw-sa02.ext.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n5TEP5Ix008163; Mon, 29 Jun 2009 17:25:05 +0300 Message-ID: <4A48CEC1.10203@nokia.com> Date: Mon, 29 Jun 2009 17:25:05 +0300 From: Aaro Koskinen User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: ext Kevin Hilman CC: "linux-omap@vger.kernel.org" , Hemanth V , "Hogander Jouni (Nokia-D/Tampere)" Subject: Re: [PATCH 3/4] OMAP3 McSPI: Adds context save/restore References: <1245965646-20070-1-git-send-email-khilman@deeprootsystems.com> <1245965646-20070-2-git-send-email-khilman@deeprootsystems.com> <1245965646-20070-3-git-send-email-khilman@deeprootsystems.com> <1245965646-20070-4-git-send-email-khilman@deeprootsystems.com> <4A44B8D7.8020508@nokia.com> In-Reply-To: <4A44B8D7.8020508@nokia.com> X-OriginalArrivalTime: 29 Jun 2009 14:25:06.0865 (UTC) FILETIME=[667F8A10:01C9F8C5] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 >> >> This patch adds context save/restore feature to McSPI driver. >> This includes fixes by Aaro Koskinen >> >> Signed-off-by: Hemanth V >> Reviewed-by: Aaro Koskinen >> Signed-off-by: Kevin Hilman >> --- >> 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. From 92ee5d91385e96a358d44b0e59ae3484d4191786 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jun 2009 14:20:49 +0300 Subject: [PATCH] PM: OMAP: SPI: Restore all CHxCONF registers Signed-off-by: Aaro Koskinen --- 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