Received: from mail.onstor.com (66.201.51.107) by exch1.onstor.net
 (10.0.0.225) with Microsoft SMTP Server id 8.1.311.2; Sun, 21 Dec 2008
 00:31:09 -0800
Received: from chiesmta2-3.messageone.com ([216.203.30.55]) by mail.onstor.com
 with Microsoft SMTPSVC(6.0.3790.3959);	 Sun, 21 Dec 2008 00:31:09 -0800
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])	by
 chiesmta2-3.messageone.com (8.13.8/8.13.8) with ESMTP id mBL8V7vj027394	for
 <andy.sharp@onstor.com>; Sun, 21 Dec 2008 02:31:08 -0600
Received: from localhost.localdomain ([127.0.0.1]:53166 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP	id S24162966AbYLUIbE
 (ORCPT <rfc822;andy.sharp@onstor.com>);	Sun, 21 Dec 2008 08:31:04 +0000
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 21 Dec 2008 08:30:48
 +0000 (GMT)
Received: from fnoeppeil48.netpark.at ([217.175.205.176]:13755 "EHLO
	roarinelk.homelinux.net") by ftp.linux-mips.org with ESMTP	id
 S24162857AbYLUI0c (ORCPT <rfc822;linux-mips@linux-mips.org>);	Sun, 21 Dec
 2008 08:26:32 +0000
Received: (qmail 3984 invoked from network); 21 Dec 2008 09:25:00 +0100
Received: from scarran.roarinelk.net (HELO localhost.localdomain)
 (192.168.0.242)  by 192.168.0.1 with SMTP; 21 Dec 2008 09:25:00 +0100
From: Manuel Lauss <mano@roarinelk.homelinux.net>
To: Linux-MIPS <linux-mips@linux-mips.org>
CC: Manuel Lauss <mano@roarinelk.homelinux.net>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Sun, 21 Dec 2008 00:26:26 -0800
Subject: [PATCH 13/14] Alchemy: dbdma suspend/resume support.
Thread-Topic: [PATCH 13/14] Alchemy: dbdma suspend/resume support.
Thread-Index: AcljRnnU906ZjDaTScqkgHwCxvvE3w==
Message-ID:
 <502995eadd40552a890abdf15ee194807b190096.1229846415.git.mano@roarinelk.homelinux.net>
References: <cover.1229846410.git.mano@roarinelk.homelinux.net>
In-Reply-To: <cover.1229846410.git.mano@roarinelk.homelinux.net>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 0b
X-MS-Exchange-Organization-AuthSource: exch1.onstor.net
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-originalarrivaltime: 21 Dec 2008 08:31:09.0402 (UTC)
 FILETIME=[797F5BA0:01C96346]
errors-to: linux-mips-bounce@linux-mips.org
x-ems-proccessed: 2K3Xl1OQTInXD6xxuA8z3Q==
x-ems-stamp: XgbICBmiLL/w+i4fOJEO0w==
x-messageone-virus-version: vendor=fsecure
 engine=4.65.7400:2.4.4,1.2.40,4.0.164
 definitions=2008-12-21_01:2008-12-18,2008-12-21,2008-12-20 signatures=0
x-messageone-virus-scanned: Clean
x-messageone-envelope-sender: linux-mips-bounce@linux-mips.org
x-messageone-spam-details: rule=m773emszm_notspam policy=m773emszm score=0
 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam
 adjust=0 reason=mlx engine=3.1.0-0810130000 definitions=main-0812200189
x-messageone-spam-score: 0
x-messageone-spam-bar:
x-list: linux-mips
x-archive-position: 21647
x-ecartis-version: Ecartis v1.0.0
x-original-sender: mano@roarinelk.homelinux.net
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

Implement suspend/resume for DBDMA controller and its channels.

Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
---
 arch/mips/alchemy/common/dbdma.c                 |   65 ++++++++++++++++++=
++++
 arch/mips/alchemy/common/power.c                 |   11 ++++
 arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h |    5 ++
 3 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/arch/mips/alchemy/common/dbdma.c b/arch/mips/alchemy/common/db=
dma.c
index 601ee91..3ab6d80 100644
--- a/arch/mips/alchemy/common/dbdma.c
+++ b/arch/mips/alchemy/common/dbdma.c
@@ -174,6 +174,11 @@ static dbdev_tab_t dbdev_tab[] =3D {
=20
 #define DBDEV_TAB_SIZE	ARRAY_SIZE(dbdev_tab)
=20
+#ifdef CONFIG_PM
+static u32 au1xxx_dbdma_pm_regs[NUM_DBDMA_CHANS + 1][8];
+#endif
+
+
 static chan_tab_t *chan_tab_ptr[NUM_DBDMA_CHANS];
=20
 static dbdev_tab_t *find_dbdev_id(u32 id)
@@ -975,4 +980,64 @@ u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t=
 *dscr)
 	return nbytes;
 }
=20
+#ifdef CONFIG_PM
+void au1xxx_dbdma_suspend(void)
+{
+	int i;
+	u32 addr;
+
+	addr =3D DDMA_GLOBAL_BASE;
+	au1xxx_dbdma_pm_regs[0][0] =3D au_readl(addr + 0x00);
+	au1xxx_dbdma_pm_regs[0][1] =3D au_readl(addr + 0x04);
+	au1xxx_dbdma_pm_regs[0][2] =3D au_readl(addr + 0x08);
+	au1xxx_dbdma_pm_regs[0][3] =3D au_readl(addr + 0x0c);
+
+	/* save channel configurations */
+	for (i =3D 1, addr =3D DDMA_CHANNEL_BASE; i < NUM_DBDMA_CHANS; i++) {
+		au1xxx_dbdma_pm_regs[i][0] =3D au_readl(addr + 0x00);
+		au1xxx_dbdma_pm_regs[i][1] =3D au_readl(addr + 0x04);
+		au1xxx_dbdma_pm_regs[i][2] =3D au_readl(addr + 0x08);
+		au1xxx_dbdma_pm_regs[i][3] =3D au_readl(addr + 0x0c);
+		au1xxx_dbdma_pm_regs[i][4] =3D au_readl(addr + 0x10);
+		au1xxx_dbdma_pm_regs[i][5] =3D au_readl(addr + 0x14);
+		au1xxx_dbdma_pm_regs[i][6] =3D au_readl(addr + 0x18);
+
+		/* halt channel */
+		au_writel(au1xxx_dbdma_pm_regs[i][0] & ~1, addr + 0x00);
+		au_sync();
+		while (!(au_readl(addr + 0x14) & 1))
+			au_sync();
+
+		addr +=3D 0x100;	/* next channel base */
+	}
+	/* disable channel interrupts */
+	au_writel(0, DDMA_GLOBAL_BASE + 0x0c);
+	au_sync();
+}
+
+void au1xxx_dbdma_resume(void)
+{
+	int i;
+	u32 addr;
+
+	addr =3D DDMA_GLOBAL_BASE;
+	au_writel(au1xxx_dbdma_pm_regs[0][0], addr + 0x00);
+	au_writel(au1xxx_dbdma_pm_regs[0][1], addr + 0x04);
+	au_writel(au1xxx_dbdma_pm_regs[0][2], addr + 0x08);
+	au_writel(au1xxx_dbdma_pm_regs[0][3], addr + 0x0c);
+
+	/* restore channel configurations */
+	for (i =3D 1, addr =3D DDMA_CHANNEL_BASE; i < NUM_DBDMA_CHANS; i++) {
+		au_writel(au1xxx_dbdma_pm_regs[i][0], addr + 0x00);
+		au_writel(au1xxx_dbdma_pm_regs[i][1], addr + 0x04);
+		au_writel(au1xxx_dbdma_pm_regs[i][2], addr + 0x08);
+		au_writel(au1xxx_dbdma_pm_regs[i][3], addr + 0x0c);
+		au_writel(au1xxx_dbdma_pm_regs[i][4], addr + 0x10);
+		au_writel(au1xxx_dbdma_pm_regs[i][5], addr + 0x14);
+		au_writel(au1xxx_dbdma_pm_regs[i][6], addr + 0x18);
+		au_sync();
+		addr +=3D 0x100;	/* next channel base */
+	}
+}
+#endif	/* CONFIG_PM */
 #endif /* defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) */
diff --git a/arch/mips/alchemy/common/power.c b/arch/mips/alchemy/common/po=
wer.c
index f08312b..f58e151 100644
--- a/arch/mips/alchemy/common/power.c
+++ b/arch/mips/alchemy/common/power.c
@@ -36,6 +36,9 @@
=20
 #include <asm/uaccess.h>
 #include <asm/mach-au1x00/au1000.h>
+#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
+#include <asm/mach-au1x00/au1xxx_dbdma.h>
+#endif
=20
 #ifdef CONFIG_PM
=20
@@ -156,6 +159,10 @@ static void save_core_regs(void)
 	sleep_static_memctlr[3][0] =3D au_readl(MEM_STCFG3);
 	sleep_static_memctlr[3][1] =3D au_readl(MEM_STTIME3);
 	sleep_static_memctlr[3][2] =3D au_readl(MEM_STADDR3);
+
+#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
+	au1xxx_dbdma_suspend();
+#endif
 }
=20
 static void restore_core_regs(void)
@@ -221,6 +228,10 @@ static void restore_core_regs(void)
 	}
=20
 	restore_au1xxx_intctl();
+
+#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
+	au1xxx_dbdma_resume();
+#endif
 }
=20
 unsigned long suspend_mode;
diff --git a/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h b/arch/mips/i=
nclude/asm/mach-au1x00/au1xxx_dbdma.h
index 44a67bf..06f68f4 100644
--- a/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h
+++ b/arch/mips/include/asm/mach-au1x00/au1xxx_dbdma.h
@@ -357,6 +357,11 @@ u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t=
 *dscr);
 u32 au1xxx_ddma_add_device(dbdev_tab_t *dev);
 extern void au1xxx_ddma_del_device(u32 devid);
 void *au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp);
+#ifdef CONFIG_PM
+void au1xxx_dbdma_suspend(void);
+void au1xxx_dbdma_resume(void);
+#endif
+
=20
 /*
  * Some compatibilty macros -- needed to make changes to API
--=20
1.6.0.4


