From roel.kluin@gmail.com Tue Sep  1 20:26:31 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 01 Sep 2009 20:26:38 +0200 (CEST)
Received: from mail-fx0-f220.google.com ([209.85.220.220]:44235 "EHLO
	mail-fx0-f220.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1494241AbZIAS0b (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 1 Sep 2009 20:26:31 +0200
Received: by fxm20 with SMTP id 20so277381fxm.0
        for <multiple recipients>; Tue, 01 Sep 2009 11:26:24 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from
         :user-agent:mime-version:to:subject:content-type
         :content-transfer-encoding;
        bh=TLtbBscmrNt5Kj+Q8MTHiMcYuBMg3m84JPERBIhSPxY=;
        b=k6bAl9QZoRKK4y3Kc9qOe1AvXgldSgxXhXN25Q/iU4hj5bmTRqR3TGFoobtsMsATrr
         GHg5OYWRyCU0QdXyOtHY/kUwcaS454roqzZwU5UU1CFWxRk2DBJFbIlMtOoQ+1bp1MxQ
         A3splH1HYbOB5a1FnsQHJ1GtzLnm+3OqERVFE=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:user-agent:mime-version:to:subject
         :content-type:content-transfer-encoding;
        b=GUG2Zt/dE1Rqcer8s79fS016eIYjYDHSuU4om5v4JYDu39tKMhtvffPhY0S9nHFPoq
         5nzFH0vkZ0Gy4hEtnWN5zkdo1CRRFHQPRYXM06LwWTq2ekwf/m35hWmQYzS/kP35VUyR
         nqlRyUKlvaMMwejnHaI84LRGWpGgnOOQnfkj8=
Received: by 10.204.163.5 with SMTP id y5mr5810288bkx.37.1251829583779;
        Tue, 01 Sep 2009 11:26:23 -0700 (PDT)
Received: from zoinx.mars (d133062.upc-d.chello.nl [213.46.133.62])
        by mx.google.com with ESMTPS id 10sm91491eyd.15.2009.09.01.11.26.22
        (version=SSLv3 cipher=RC4-MD5);
        Tue, 01 Sep 2009 11:26:23 -0700 (PDT)
Message-ID: <4A9D68A7.9000902@gmail.com>
Date:	Tue, 01 Sep 2009 20:32:07 +0200
From:	Roel Kluin <roel.kluin@gmail.com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] MSP71xx: request_irq() failure ignored in msp_pcibios_config_access()
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Return-Path: <roel.kluin@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23973
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: roel.kluin@gmail.com
Precedence: bulk
X-list: linux-mips

Produce an error if request_irq() fails.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/arch/mips/pci/ops-pmcmsp.c b/arch/mips/pci/ops-pmcmsp.c
index 109c95c..223d822 100644
--- a/arch/mips/pci/ops-pmcmsp.c
+++ b/arch/mips/pci/ops-pmcmsp.c
@@ -402,11 +402,12 @@ int msp_pcibios_config_access(unsigned char access_type,
 	 * allocation assigns an interrupt handler to the interrupt.
 	 */
 	if (pciirqflag == 0) {
-		request_irq(MSP_INT_PCI,/* Hardcoded internal MSP7120 wiring */
+		if ((request_irq(MSP_INT_PCI,/* Hardcoded internal MSP7120 wiring */
 				bpci_interrupt,
 				IRQF_SHARED | IRQF_DISABLED,
 				"PMC MSP PCI Host",
-				preg);
+				preg)) != 0)
+			return -1;
 		pciirqflag = ~0;
 	}
 

From roel.kluin@gmail.com Tue Sep  1 22:17:54 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 01 Sep 2009 22:18:01 +0200 (CEST)
Received: from mail-ew0-f225.google.com ([209.85.219.225]:54761 "EHLO
	mail-ew0-f225.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1494355AbZIAURy (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 1 Sep 2009 22:17:54 +0200
Received: by ewy25 with SMTP id 25so217506ewy.33
        for <multiple recipients>; Tue, 01 Sep 2009 13:17:44 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from
         :user-agent:mime-version:to:cc:subject:references:in-reply-to
         :content-type:content-transfer-encoding;
        bh=6gAZe4DCuHdeHhPTuE1u511ES02hQXs5ODPcmSauaFg=;
        b=Uq56xg4N9y+6BTt5GMNhsIhH9khZ4bTw+iDh+sO+blfAQr3L5rS0KEWtaFAUv3a0Z2
         +v210lMMo/jhxjQKIEVmm36lTKUYaLbrjTMW+pQFofHPoJcfuATGxDLKv5ryU9cC0waH
         4jHRbvp4P/2YmlYCXfWXe0P35HSOEEsDxRGC8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:user-agent:mime-version:to:cc:subject
         :references:in-reply-to:content-type:content-transfer-encoding;
        b=cz7QEOa8E4GiMAAfWXetEO+KdAxeSIpLQSoSquM98TAJxuSmGvZ9zgWq6eCnj/miEB
         fToB8rV4in5jBCumRGET7808+rmqJWvJHbVrOMC8YIGlGWQw4e1GHIIBEPej5p3IVYSg
         czfh9ii2UcVTfXw7xu6RRWAs2R5yZJ1CD6dIw=
Received: by 10.210.127.13 with SMTP id z13mr6694280ebc.85.1251836264908;
        Tue, 01 Sep 2009 13:17:44 -0700 (PDT)
Received: from zoinx.mars (d133062.upc-d.chello.nl [213.46.133.62])
        by mx.google.com with ESMTPS id 28sm82019eye.0.2009.09.01.13.17.43
        (version=SSLv3 cipher=RC4-MD5);
        Tue, 01 Sep 2009 13:17:44 -0700 (PDT)
Message-ID: <4A9D82C0.7070408@gmail.com>
Date:	Tue, 01 Sep 2009 22:23:28 +0200
From:	Roel Kluin <roel.kluin@gmail.com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3
MIME-Version: 1.0
To:	"Ithamar R. Adema" <ithamar.adema@team-embedded.nl>
CC:	Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] MSP71xx: request_irq() failure ignored in msp_pcibios_config_access()
References: <4A9D68A7.9000902@gmail.com> <4A9D6E37.1030704@team-embedded.nl>
In-Reply-To: <4A9D6E37.1030704@team-embedded.nl>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Return-Path: <roel.kluin@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23974
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: roel.kluin@gmail.com
Precedence: bulk
X-list: linux-mips

Produce an error if request_irq() fails.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---

>> +            return -1;

> I'd personally suggest to return the actual value returned by
> request_irq, instead of returning -EPERM..... ;)
> 
> Ithamar.

The comments at the header states that it returns -1 on failure,
and so do the callers as well, but if preferred, below is as you
suggest.

Thanks,

diff --git a/arch/mips/pci/ops-pmcmsp.c b/arch/mips/pci/ops-pmcmsp.c
index 109c95c..32548b5 100644
--- a/arch/mips/pci/ops-pmcmsp.c
+++ b/arch/mips/pci/ops-pmcmsp.c
@@ -385,6 +385,7 @@ int msp_pcibios_config_access(unsigned char access_type,
 	unsigned long intr;
 	unsigned long value;
 	static char pciirqflag;
+	int ret;
 #if defined(CONFIG_PMC_MSP7120_GW) || defined(CONFIG_PMC_MSP7120_EVAL)
 	unsigned int	vpe_status;
 #endif
@@ -402,11 +403,13 @@ int msp_pcibios_config_access(unsigned char access_type,
 	 * allocation assigns an interrupt handler to the interrupt.
 	 */
 	if (pciirqflag == 0) {
-		request_irq(MSP_INT_PCI,/* Hardcoded internal MSP7120 wiring */
+		ret = request_irq(MSP_INT_PCI,/* Hardcoded internal MSP7120 wiring */
 				bpci_interrupt,
 				IRQF_SHARED | IRQF_DISABLED,
 				"PMC MSP PCI Host",
 				preg);
+		if (ret != 0)
+			return ret;
 		pciirqflag = ~0;
 	}
 

From David.Daney@caviumnetworks.com Thu Sep  3 00:48:11 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 00:48:18 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:13126 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492317AbZIBWsL (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 3 Sep 2009 00:48:11 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,2,2,3503)
	id <B4a9ef60a0000>; Wed, 02 Sep 2009 18:47:40 -0400
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 2 Sep 2009 15:47:41 -0700
Received: from dd1.caveonetworks.com ([64.169.86.201]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 2 Sep 2009 15:47:41 -0700
Received: from dd1.caveonetworks.com (localhost.localdomain [127.0.0.1])
	by dd1.caveonetworks.com (8.14.2/8.14.2) with ESMTP id n82MlaoI021293;
	Wed, 2 Sep 2009 15:47:36 -0700
Received: (from ddaney@localhost)
	by dd1.caveonetworks.com (8.14.2/8.14.2/Submit) id n82MlZ0J021292;
	Wed, 2 Sep 2009 15:47:35 -0700
From:	David Daney <ddaney@caviumnetworks.com>
To:	linux-mips@linux-mips.org, ralf@linux-mips.org
Cc:	David Daney <ddaney@caviumnetworks.com>
Subject: [PATCH] MIPS: Don't corrupt page tables on vmalloc fault.
Date:	Wed,  2 Sep 2009 15:47:34 -0700
Message-Id: <1251931654-21268-1-git-send-email-ddaney@caviumnetworks.com>
X-Mailer: git-send-email 1.6.0.6
X-OriginalArrivalTime: 02 Sep 2009 22:47:41.0243 (UTC) FILETIME=[60C238B0:01CA2C1F]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23975
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

The code after the vmalloc_fault: label in do_page_fault() modifies
user page tables, this is not correct for 64-bit kernels.

For 64-bit kernels we should go straight to the no_context handler
skipping vmalloc_fault.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 arch/mips/mm/fault.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index f956ecb..e97a7a2 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -58,11 +58,17 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
 	 * only copy the information from the master page table,
 	 * nothing more.
 	 */
+#ifdef CONFIG_64BIT
+# define VMALLOC_FAULT_TARGET no_context
+#else
+# define VMALLOC_FAULT_TARGET vmalloc_fault
+#endif
+
 	if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END))
-		goto vmalloc_fault;
+		goto VMALLOC_FAULT_TARGET;
 #ifdef MODULE_START
 	if (unlikely(address >= MODULE_START && address < MODULE_END))
-		goto vmalloc_fault;
+		goto VMALLOC_FAULT_TARGET;
 #endif
 
 	/*
@@ -203,6 +209,7 @@ do_sigbus:
 	force_sig_info(SIGBUS, &info, tsk);
 
 	return;
+#ifndef CONFIG_64BIT
 vmalloc_fault:
 	{
 		/*
@@ -241,4 +248,5 @@ vmalloc_fault:
 			goto no_context;
 		return;
 	}
+#endif
 }
-- 
1.6.0.6


From crquan@gmail.com Thu Sep  3 05:49:06 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 05:49:14 +0200 (CEST)
Received: from mail-px0-f180.google.com ([209.85.216.180]:41891 "EHLO
	mail-px0-f180.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1491870AbZICDtG (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 3 Sep 2009 05:49:06 +0200
Received: by pxi10 with SMTP id 10so1259434pxi.24
        for <linux-mips@linux-mips.org>; Wed, 02 Sep 2009 20:48:59 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:date:message-id:subject
         :from:to:content-type;
        bh=dDJFC9y6nTBskvboK2b2JNiC2P1h49rjgto6tohHado=;
        b=A36yBJBshKqqQl+Q9zS9ZKzAmVFULn0nm6ewfYgZDiPvfV4DcTko0vmYqqTrxR5HSZ
         7b1VlJ6n0LSa3L4lqnWGSzwRcilRjQ5nNrjD7e3jEZjcOyXcrUPYFau4JuerHP0smILj
         u4gA7KUeMikO84bobqqXyKo+QCFdT4b6T8MII=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:date:message-id:subject:from:to:content-type;
        b=cdSLC+MfnOb3pBBoDmDS3RTy3JKIhy+dQgz8D0Go4DT7w9Xt1VmT1hXSeMeGDqqo4J
         ck9P/2nlqwPl4+Vorr9iTLoKbvzRhOTHYNNZDd/cCwyXyaNqA0CJeJqfRwSkuiERUPTZ
         +EMMFATTeItTMa2kwy/XS4j35iIvEXYstV2h4=
MIME-Version: 1.0
Received: by 10.142.75.16 with SMTP id x16mr204125wfa.155.1251949739619; Wed, 
	02 Sep 2009 20:48:59 -0700 (PDT)
Date:	Thu, 3 Sep 2009 11:48:59 +0800
Message-ID: <91b13c310909022048q467dff7cl90284b57132f4f14@mail.gmail.com>
Subject: How to debug glibc-2.10.1 mips on linux multilib o32 ld or libc 
	Segmentation fault?
From:	Cheng Renquan <crquan@gmail.com>
To:	libc-help@sourceware.org, linux-mips@linux-mips.org,
	issues@eglibc.org
Content-Type: text/plain; charset=UTF-8
Return-Path: <crquan@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23976
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: crquan@gmail.com
Precedence: bulk
X-list: linux-mips

Hello, all,
  Recently I have cross compiled GCC-4.4.1 with eglibc-2.10.1,
with a multilib configuration, o32/n32/n64, the result is that n32/n64
can work well, while o32 libs always Segmentation fault,

I have read this but still have no good idea on how to debug,

http://sources.redhat.com/glibc/wiki/Debugging/Development_Debugging

then I run it like this,

$ LD_DEBUG=all eglibc-install-root-o32/lib/ld.so.1 --library-path
$PWD/eglibc-install-root-o32/lib
eglibc-install-root-o32/usr/bin/locale

it ends with:

     30257:	symbol=__stack_chk_guard;  lookup in
file=eglibc-install-root-o32/usr/bin/locale [0]
     30257:	symbol=__stack_chk_guard;  lookup in
file=/mnt/nas/yutech/homes/user/eglibc-install-root-o32/lib/libc.so.6
[0]
     30257:	symbol=__stack_chk_guard;  lookup in
file=eglibc-install-root-o32/lib/ld.so.1 [0]
     30257:	binding file eglibc-install-root-o32/lib/ld.so.1 [0] to
eglibc-install-root-o32/lib/ld.so.1 [0]: normal symbol
`__stack_chk_guard' [GLIBC_2.4]
     30257:	
     30257:	calling init:
/mnt/nas/yutech/homes/user/eglibc-install-root-o32/lib/libc.so.6
     30257:	
Segmentation fault

So please give some inputs on how to resolve this? Thanks,

-- 
Cheng Renquan

From anemo@mba.ocn.ne.jp Thu Sep  3 15:59:10 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 15:59:18 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:55869 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1492715AbZICN7K (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 3 Sep 2009 15:59:10 +0200
Received: from localhost.localdomain (p2046-ipad301funabasi.chiba.ocn.ne.jp [122.17.252.46])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id BA4AA6AE9; Thu,  3 Sep 2009 22:59:02 +0900 (JST)
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org, spi-devel-general@lists.sourceforge.net,
	david-b@pacbell.net
Subject: [PATCH 1/2] txx9: Fix spi-baseclk value
Date:	Thu,  3 Sep 2009 22:59:00 +0900
Message-Id: <1251986341-16938-1-git-send-email-anemo@mba.ocn.ne.jp>
X-Mailer: git-send-email 1.5.6.5
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23977
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

TXx9 SPI bit rate is calculated by:
	fBR = fSPI / 2 / (n + 1)
	(fSPI is SPI master clock freq, i.e. imbusclk freq.)
So use imbus_clk / 2 as a spi-baseclk.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 arch/mips/txx9/generic/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index a205e2b..b2613c1 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -85,7 +85,7 @@ int txx9_ccfg_toeon __initdata = 1;
 struct clk *clk_get(struct device *dev, const char *id)
 {
 	if (!strcmp(id, "spi-baseclk"))
-		return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 4);
+		return (struct clk *)((unsigned long)txx9_gbus_clock / 2 / 2);
 	if (!strcmp(id, "imbus_clk"))
 		return (struct clk *)((unsigned long)txx9_gbus_clock / 2);
 	return ERR_PTR(-ENOENT);
-- 
1.5.6.5


From anemo@mba.ocn.ne.jp Thu Sep  3 15:59:35 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 15:59:42 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:55870 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1492724AbZICN7L (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 3 Sep 2009 15:59:11 +0200
Received: from localhost.localdomain (p2046-ipad301funabasi.chiba.ocn.ne.jp [122.17.252.46])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 24EE46A7E; Thu,  3 Sep 2009 22:59:03 +0900 (JST)
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org, spi-devel-general@lists.sourceforge.net,
	david-b@pacbell.net
Subject: [PATCH 2/2] spi_txx9: Fix bit rate calculation
Date:	Thu,  3 Sep 2009 22:59:01 +0900
Message-Id: <1251986341-16938-2-git-send-email-anemo@mba.ocn.ne.jp>
X-Mailer: git-send-email 1.5.6.5
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23978
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

TXx9 SPI bit rate is calculated by:
        fBR = (spi-baseclk) / (n + 1)
Fix calculation of min_speed_hz, max_speed_hz and n.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 drivers/spi/spi_txx9.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/spi_txx9.c b/drivers/spi/spi_txx9.c
index 96057de..19f7562 100644
--- a/drivers/spi/spi_txx9.c
+++ b/drivers/spi/spi_txx9.c
@@ -29,6 +29,8 @@
 
 
 #define SPI_FIFO_SIZE 4
+#define SPI_MAX_DIVIDER 0xff	/* Max. value for SPCR1.SER */
+#define SPI_MIN_DIVIDER 1	/* Min. value for SPCR1.SER */
 
 #define TXx9_SPMCR		0x00
 #define TXx9_SPCR0		0x04
@@ -193,11 +195,8 @@ static void txx9spi_work_one(struct txx9spi *c, struct spi_message *m)
 
 		if (prev_speed_hz != speed_hz
 				|| prev_bits_per_word != bits_per_word) {
-			u32 n = (c->baseclk + speed_hz - 1) / speed_hz;
-			if (n < 1)
-				n = 1;
-			else if (n > 0xff)
-				n = 0xff;
+			int n = DIV_ROUND_UP(c->baseclk, speed_hz) - 1;
+			n = clamp(n, SPI_MIN_DIVIDER, SPI_MAX_DIVIDER);
 			/* enter config mode */
 			txx9spi_wr(c, mcr | TXx9_SPMCR_CONFIG | TXx9_SPMCR_BCLR,
 					TXx9_SPMCR);
@@ -370,8 +369,8 @@ static int __init txx9spi_probe(struct platform_device *dev)
 		goto exit;
 	}
 	c->baseclk = clk_get_rate(c->clk);
-	c->min_speed_hz = (c->baseclk + 0xff - 1) / 0xff;
-	c->max_speed_hz = c->baseclk;
+	c->min_speed_hz = DIV_ROUND_UP(c->baseclk, SPI_MAX_DIVIDER + 1);
+	c->max_speed_hz = c->baseclk / (SPI_MIN_DIVIDER + 1);
 
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!res)
-- 
1.5.6.5


From at.wufei@gmail.com Thu Sep  3 16:28:05 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 16:28:11 +0200 (CEST)
Received: from fg-out-1718.google.com ([72.14.220.159]:31867 "EHLO
	fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1492730AbZICO2F (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 3 Sep 2009 16:28:05 +0200
Received: by fg-out-1718.google.com with SMTP id d23so713112fga.6
        for <multiple recipients>; Thu, 03 Sep 2009 07:28:04 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:date:from:to:subject
         :message-id:mime-version:content-type:content-disposition:user-agent;
        bh=2Mz1fNpKyOuCkvuXUpWr7MH4bQw4fBnydVsXOvmRxKE=;
        b=lF+ZVOkSf/l4coaJq2y2xU7P9bUCSnQ42ODZK14WTua3JAVew4aIGdAE2k4F+EWRM6
         HCDBMPYBhxDlXY0p852cEt8nUsU0dbl76qFpp3VvKyHLKz0q0wDv0jJ/PJJPgYy5Y4xI
         sStgSd0CIyPbKYIXYIOJ8C5wdP/J45krn8qbo=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=date:from:to:subject:message-id:mime-version:content-type
         :content-disposition:user-agent;
        b=KqD4P4dC3SlUEkaRHFQbgLYaAOkf9QaE5wkhWSQiFOsqPnyIJVEPbMI9DXWGgMDBBR
         O4y2bXCTx6V9zRP+GpZuK8RvEJ2erJ+M4Ac8NmdKK+/Akg7/xlCU+nnED95/3snXs8RD
         fxQaVq7GmcUrE59ZsKGMGKrDMzLSTNiox9szg=
Received: by 10.87.42.14 with SMTP id u14mr3949776fgj.28.1251988084206;
        Thu, 03 Sep 2009 07:28:04 -0700 (PDT)
Received: from desktop ([58.31.9.46])
        by mx.google.com with ESMTPS id l19sm62248fgb.1.2009.09.03.07.27.58
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Thu, 03 Sep 2009 07:27:59 -0700 (PDT)
Date:	Thu, 3 Sep 2009 22:27:53 +0800
From:	Wu Fei <at.wufei@gmail.com>
To:	linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: Shrink the size of tlb handler and fix vmalloc()
Message-ID: <20090903142753.GA6482@desktop>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <at.wufei@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23979
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: at.wufei@gmail.com
Precedence: bulk
X-list: linux-mips

This patch tries to shrink the size of the 64bit tlb handler and also fix
an vmalloc bug at the same time.

By combining the swapper_pg_dir and module_pg_dir, several checks in tlb
handler, particularly build_get_pgd_vmalloc64, are not necessary. The reason
they can be combined is that, the effective virtual address of vmalloc returned
is at the bottom, and of module_alloc returned is at the top.

In the normal case of 4KB page size:
  VMALLOC_START, VMALLOC_END	0xc0000000 00000000 - 0xc0000100 00000000
  MODULE_START,  MODULE_END	0xffffffff c0000000 - 0xffffffff +xxxxxxx
Change it to:
  VMALLOC_START, VMALLOC_END	0xc0000000 00000000 - 0xc00000ff 00000000
  MODULE_START,  MODULE_END	0xffffffff c0000000 - 0xffffffff +xxxxxxx
We use the least 40 bits to traverse the page table, the change makes it still
one-to-one mapping without more checking. "+" is in the range of [c,d,e,f], 
so there even are big holes bewteen them.

With this patch, the tlb refill handler only contains about 28 instructions,
instead of the original 38.


And this patch also fix a bug in vmalloc, which happens when its returned
address is not covered by the first pgd. e.g. if we do two vmallocs, the first
returned address is 0xc0000000 00000000, and the 2nd is 0xc0000000 40000000,

  vmalloc -> __vmalloc_node -> __vmalloc_area_node -> __vmalloc_area_node
  -> map_vm_area -> pgd_offset_k

pgd_offset_k doesn't use the address to index the pgd, just return the first one:

  #define pgd_offset_k(address) \ 
        ((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))     

This is wrong, then the 2 addresses are mapped to the same pte. This bug doesn't
happen because even in the 4KB page case, one pgd can cover 1GB size, and it looks
like the system won't vmalloc so much area.

From at.wufei@gmail.com Thu Sep  3 16:30:06 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 16:30:12 +0200 (CEST)
Received: from mail-fx0-f220.google.com ([209.85.220.220]:37375 "EHLO
	mail-fx0-f220.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492730AbZICOaG (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 3 Sep 2009 16:30:06 +0200
Received: by fxm20 with SMTP id 20so1680982fxm.0
        for <multiple recipients>; Thu, 03 Sep 2009 07:30:00 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:date:from:to:subject
         :message-id:references:mime-version:content-type:content-disposition
         :in-reply-to:user-agent;
        bh=FCl7MH4hu+t6mfKBCOeI1dQAVfEiLK79DD/hGM1IEoo=;
        b=ltogB3mtwoK0jES3WTmeG7qfXtBu89DSSsDdofJd/1Z/9d9ArFGZFXD9/gsjnFn25J
         g9HqnPDDyqAsQ7JMpG5FxQdenYxekEjbLBf4UujQwc66OZih42XBODYxa2jXUs9Ra+FT
         vqYEIh/yEc01+PZ5mOi/d9xbA3xO3lwGA8WIM=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=date:from:to:subject:message-id:references:mime-version
         :content-type:content-disposition:in-reply-to:user-agent;
        b=PHM+ik3Xa54uFMRISvBRSFPibyFNBRgbzouwN6NwGiuy3zVI+HXdSP9uIlhy3DtqOx
         rF5atX6bTkl8aLYNeDf8/3pBvVKwK49WMNS30pbdVKldylRjplElExDT1OaJRKNSNv9c
         uRnHsrvEjDLyp2Cnk02A4LVkoj9ZSTaQ++9jc=
Received: by 10.204.34.71 with SMTP id k7mr7908986bkd.206.1251988199927;
        Thu, 03 Sep 2009 07:29:59 -0700 (PDT)
Received: from desktop ([58.31.9.46])
        by mx.google.com with ESMTPS id y15sm1997182fkd.47.2009.09.03.07.29.57
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Thu, 03 Sep 2009 07:29:59 -0700 (PDT)
Date:	Thu, 3 Sep 2009 22:29:53 +0800
From:	Wu Fei <at.wufei@gmail.com>
To:	linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH] Shrink the size of tlb handler
Message-ID: <20090903142953.GB6482@desktop>
References: <20090903142753.GA6482@desktop>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20090903142753.GA6482@desktop>
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <at.wufei@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23980
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: at.wufei@gmail.com
Precedence: bulk
X-list: linux-mips

By combining swapper_pg_dir and module_pg_dir, several if conditions
can be eliminated from the tlb exception handler. The reason they
can be combined is that, the effective virtual address of vmalloc
returned is at the bottom, and of module_alloc returned is at the
top. It also fixes the bug in vmalloc(), which happens when its
return address is not covered by the first pgd.

Signed-off-by: Wu Fei <at.wufei@gmail.com>
---
 arch/mips/include/asm/pgtable-64.h |   11 ++------
 arch/mips/mm/init.c                |    3 --
 arch/mips/mm/pgtable-64.c          |    3 --
 arch/mips/mm/tlbex.c               |   49 ------------------------------------
 4 files changed, 3 insertions(+), 63 deletions(-)

diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index 4ed9d1b..9cd5089 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -109,13 +109,13 @@
 
 #define VMALLOC_START		MAP_BASE
 #define VMALLOC_END	\
-	(VMALLOC_START + PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE)
+	(VMALLOC_START + \
+	 PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE - (1UL << 32))
 #if defined(CONFIG_MODULES) && defined(KBUILD_64BIT_SYM32) && \
 	VMALLOC_START != CKSSEG
 /* Load modules into 32bit-compatible segment. */
 #define MODULE_START	CKSSEG
 #define MODULE_END	(FIXADDR_START-2*PAGE_SIZE)
-extern pgd_t module_pg_dir[PTRS_PER_PGD];
 #endif
 
 #define pte_ERROR(e) \
@@ -188,12 +188,7 @@ static inline void pud_clear(pud_t *pudp)
 #define __pmd_offset(address)	pmd_index(address)
 
 /* to find an entry in a kernel page-table-directory */
-#ifdef MODULE_START
-#define pgd_offset_k(address) \
-	((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))
-#else
-#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL)
-#endif
+#define pgd_offset_k(address) pgd_offset(&init_mm, address)
 
 #define pgd_index(address)	(((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 #define pmd_index(address)	(((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 0e82050..38c79c5 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -475,9 +475,6 @@ unsigned long pgd_current[NR_CPUS];
  */
 pgd_t swapper_pg_dir[_PTRS_PER_PGD] __page_aligned(_PGD_ORDER);
 #ifdef CONFIG_64BIT
-#ifdef MODULE_START
-pgd_t module_pg_dir[PTRS_PER_PGD] __page_aligned(PGD_ORDER);
-#endif
 pmd_t invalid_pmd_table[PTRS_PER_PMD] __page_aligned(PMD_ORDER);
 #endif
 pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned(PTE_ORDER);
diff --git a/arch/mips/mm/pgtable-64.c b/arch/mips/mm/pgtable-64.c
index e4b565a..1121019 100644
--- a/arch/mips/mm/pgtable-64.c
+++ b/arch/mips/mm/pgtable-64.c
@@ -59,9 +59,6 @@ void __init pagetable_init(void)
 
 	/* Initialize the entire pgd.  */
 	pgd_init((unsigned long)swapper_pg_dir);
-#ifdef MODULE_START
-	pgd_init((unsigned long)module_pg_dir);
-#endif
 	pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
 
 	pgd_base = swapper_pg_dir;
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 9a17bf8..bc66f57 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -499,11 +499,7 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
 	 * The vmalloc handling is not in the hotpath.
 	 */
 	uasm_i_dmfc0(p, tmp, C0_BADVADDR);
-#ifdef MODULE_START
-	uasm_il_bltz(p, r, tmp, label_module_alloc);
-#else
 	uasm_il_bltz(p, r, tmp, label_vmalloc);
-#endif
 	/* No uasm_i_nop needed here, since the next insn doesn't touch TMP. */
 
 #ifdef CONFIG_SMP
@@ -556,52 +552,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
 {
 	long swpd = (long)swapper_pg_dir;
 
-#ifdef MODULE_START
-	long modd = (long)module_pg_dir;
-
-	uasm_l_module_alloc(l, *p);
-	/*
-	 * Assumption:
-	 * VMALLOC_START >= 0xc000000000000000UL
-	 * MODULE_START >= 0xe000000000000000UL
-	 */
-	UASM_i_SLL(p, ptr, bvaddr, 2);
-	uasm_il_bgez(p, r, ptr, label_vmalloc);
-
-	if (uasm_in_compat_space_p(MODULE_START) &&
-	    !uasm_rel_lo(MODULE_START)) {
-		uasm_i_lui(p, ptr, uasm_rel_hi(MODULE_START)); /* delay slot */
-	} else {
-		/* unlikely configuration */
-		uasm_i_nop(p); /* delay slot */
-		UASM_i_LA(p, ptr, MODULE_START);
-	}
-	uasm_i_dsubu(p, bvaddr, bvaddr, ptr);
-
-	if (uasm_in_compat_space_p(modd) && !uasm_rel_lo(modd)) {
-		uasm_il_b(p, r, label_vmalloc_done);
-		uasm_i_lui(p, ptr, uasm_rel_hi(modd));
-	} else {
-		UASM_i_LA_mostly(p, ptr, modd);
-		uasm_il_b(p, r, label_vmalloc_done);
-		if (uasm_in_compat_space_p(modd))
-			uasm_i_addiu(p, ptr, ptr, uasm_rel_lo(modd));
-		else
-			uasm_i_daddiu(p, ptr, ptr, uasm_rel_lo(modd));
-	}
-
 	uasm_l_vmalloc(l, *p);
-	if (uasm_in_compat_space_p(MODULE_START) &&
-	    !uasm_rel_lo(MODULE_START) &&
-	    MODULE_START << 32 == VMALLOC_START)
-		uasm_i_dsll32(p, ptr, ptr, 0);	/* typical case */
-	else
-		UASM_i_LA(p, ptr, VMALLOC_START);
-#else
-	uasm_l_vmalloc(l, *p);
-	UASM_i_LA(p, ptr, VMALLOC_START);
-#endif
-	uasm_i_dsubu(p, bvaddr, bvaddr, ptr);
 
 	if (uasm_in_compat_space_p(swpd) && !uasm_rel_lo(swpd)) {
 		uasm_il_b(p, r, label_vmalloc_done);
-- 
1.6.4.rc1


From at.wufei@gmail.com Thu Sep  3 16:32:17 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 16:32:23 +0200 (CEST)
Received: from mail-fx0-f220.google.com ([209.85.220.220]:56477 "EHLO
	mail-fx0-f220.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492761AbZICOcR (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 3 Sep 2009 16:32:17 +0200
Received: by fxm20 with SMTP id 20so1683155fxm.0
        for <multiple recipients>; Thu, 03 Sep 2009 07:32:10 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:date:from:to:subject
         :message-id:references:mime-version:content-type:content-disposition
         :in-reply-to:user-agent;
        bh=by8DackXTq6qUg8fh4aBGS8T7nzGF9vn2QxcMM7c1J0=;
        b=SgvZP8T3jq44GIvDkkJkBohSJWZE6InU+dOhojzdIh1zUX5/KFzV7ZpQeUqXv7hiNG
         bWACWRj4+R1OezZA8DbmxyCrek5+S4RRl3qzNXFfjPHvuiHYFkScK/DQZbeyZPSTtm8t
         Sc20Ao+O/9sUg+xjgAL7rcMmJcK2SEk/n/Bvc=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=date:from:to:subject:message-id:references:mime-version
         :content-type:content-disposition:in-reply-to:user-agent;
        b=NkBommUmKREGVPZSMgdeUzttGpFj9LxIKdAM1MVFC+cV4qJTkCJEvthz+qxbTMvAiK
         QLmWhIkUOOeGCk2/neOrswk2ReKDisuv25h5S88F9ytv5x2wmyhCuTAD0VjDKrlNyfRv
         mkKBmtpxntKfa2OZSfc91n8tVC/ElfRRV6vbw=
Received: by 10.204.29.22 with SMTP id o22mr8017326bkc.78.1251988330055;
        Thu, 03 Sep 2009 07:32:10 -0700 (PDT)
Received: from desktop ([58.31.9.46])
        by mx.google.com with ESMTPS id 22sm2012165fkq.23.2009.09.03.07.32.07
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Thu, 03 Sep 2009 07:32:09 -0700 (PDT)
Date:	Thu, 3 Sep 2009 22:32:02 +0800
From:	Wu Fei <at.wufei@gmail.com>
To:	linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: Re: Shrink the size of tlb handler and fix vmalloc()
Message-ID: <20090903143202.GC6482@desktop>
References: <20090903142753.GA6482@desktop>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20090903142753.GA6482@desktop>
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <at.wufei@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23981
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: at.wufei@gmail.com
Precedence: bulk
X-list: linux-mips

On Thu, Sep 03, 2009 at 10:27:53PM +0800, Wu Fei wrote:
> This patch tries to shrink the size of the 64bit tlb handler and also fix
> an vmalloc bug at the same time.
> 
Forgot to say, it's only tested on 2.6.27, not the master, I can't get
the environment to run the latest kernel currently.

Thanks,
Wufei.

> By combining the swapper_pg_dir and module_pg_dir, several checks in tlb
> handler, particularly build_get_pgd_vmalloc64, are not necessary. The reason
> they can be combined is that, the effective virtual address of vmalloc returned
> is at the bottom, and of module_alloc returned is at the top.
> 
> In the normal case of 4KB page size:
>   VMALLOC_START, VMALLOC_END	0xc0000000 00000000 - 0xc0000100 00000000
>   MODULE_START,  MODULE_END	0xffffffff c0000000 - 0xffffffff +xxxxxxx
> Change it to:
>   VMALLOC_START, VMALLOC_END	0xc0000000 00000000 - 0xc00000ff 00000000
>   MODULE_START,  MODULE_END	0xffffffff c0000000 - 0xffffffff +xxxxxxx
> We use the least 40 bits to traverse the page table, the change makes it still
> one-to-one mapping without more checking. "+" is in the range of [c,d,e,f], 
> so there even are big holes bewteen them.
> 
> With this patch, the tlb refill handler only contains about 28 instructions,
> instead of the original 38.
> 
> 
> And this patch also fix a bug in vmalloc, which happens when its returned
> address is not covered by the first pgd. e.g. if we do two vmallocs, the first
> returned address is 0xc0000000 00000000, and the 2nd is 0xc0000000 40000000,
> 
>   vmalloc -> __vmalloc_node -> __vmalloc_area_node -> __vmalloc_area_node
>   -> map_vm_area -> pgd_offset_k
> 
> pgd_offset_k doesn't use the address to index the pgd, just return the first one:
> 
>   #define pgd_offset_k(address) \ 
>         ((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))     
> 
> This is wrong, then the 2 addresses are mapped to the same pte. This bug doesn't
> happen because even in the 4KB page case, one pgd can cover 1GB size, and it looks
> like the system won't vmalloc so much area.

From f.fainelli@gmail.com Thu Sep  3 21:04:50 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 03 Sep 2009 21:04:56 +0200 (CEST)
Received: from mail-bw0-f208.google.com ([209.85.218.208]:57925 "EHLO
	mail-bw0-f208.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493126AbZICTEu (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 3 Sep 2009 21:04:50 +0200
Received: by bwz4 with SMTP id 4so185267bwz.0
        for <multiple recipients>; Thu, 03 Sep 2009 12:04:44 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:sender:from:date:subject
         :mime-version:x-uid:x-length:to:cc:content-type
         :content-transfer-encoding:content-disposition:message-id;
        bh=ouPSqi+5PIrY53pETgu0BzDvs+nVf+xfdVnxyNesVeM=;
        b=PfQz3cnNQhrgSjI4MJITOJRti4BPlvG9XpY1OznbF5w/V4OlA2cchsYzx1DAuRY+18
         PZwvYl1QGRrrQnajjiWCg/+xZwc9Bdny6ki31XseYo4MSxDTXAxX+3thXOZ/56jD9evW
         RrF5dL+3USkh5KXpYNFKEJ7QPkfQMtnYNJZgY=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=sender:from:date:subject:mime-version:x-uid:x-length:to:cc
         :content-type:content-transfer-encoding:content-disposition
         :message-id;
        b=nI/Xk4vsvC79a2kVYcn1Rp2XLrfruCvsytEiuQNwK4v1dlSdFsmeSl8NqHZ6JLNLZe
         zAFOQaAVl4Bo7utjV9unoOgL853IFMUQxGlB4XtlDvgWWDCwprmIUDPtiuCbjq3SWAdZ
         zol3R4vupAL/GQI5pGt1kFWwbnfarCsGFZSo4=
Received: by 10.103.76.37 with SMTP id d37mr4405030mul.99.1252004684436;
        Thu, 03 Sep 2009 12:04:44 -0700 (PDT)
Received: from lenovo.localnet (39.87.196-77.rev.gaoland.net [77.196.87.39])
        by mx.google.com with ESMTPS id u26sm159704mug.53.2009.09.03.12.04.43
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Thu, 03 Sep 2009 12:04:43 -0700 (PDT)
From:	Florian Fainelli <florian@openwrt.org>
Date:	Thu, 3 Sep 2009 21:04:32 +0200
Subject: [PATCH] bcm63xx: set the correct BCM3302 CPU name when built for BCM47xx or BCM63xx
MIME-Version: 1.0
X-UID:	1374
X-Length: 1694
To:	ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org, Maxime Bizon <mbizon@freebox.fr>
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200909032104.34135.florian@openwrt.org>
Return-Path: <f.fainelli@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23982
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: florian@openwrt.org
Precedence: bulk
X-list: linux-mips

The Broadcom BCM3302 core is present in both the BCM47xx and
the BCM6338 SoC. If people want to report a kernel oops it
might be convenient to know about the real system they are
running Linux on at first glance.
Set the CPU name to be 3302 on BCM47xx and 6338 on BCM63xx.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index 251a268..405e9d4 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -862,7 +862,11 @@ static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
 	case PRID_IMP_BCM3302:
 	 /* same as PRID_IMP_BCM6338 */
 		c->cputype = CPU_BCM3302;
+#ifdef CONFIG_BCM47XX
 		__cpu_name[cpu] = "Broadcom BCM3302";
+#else 
+		__cpu_name[cpu] = "Broadcom BCM6338";
+#endif
 		break;
 	case PRID_IMP_BCM4710:
 		c->cputype = CPU_BCM4710;


From David.Daney@caviumnetworks.com Fri Sep  4 01:11:16 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 04 Sep 2009 01:11:22 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:41292 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493207AbZICXLQ (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 4 Sep 2009 01:11:16 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,2,2,3503)
	id <B4aa04cfb0000>; Thu, 03 Sep 2009 19:10:51 -0400
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 3 Sep 2009 16:10:54 -0700
Received: from dd1.caveonetworks.com ([64.169.86.201]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 3 Sep 2009 16:10:54 -0700
Received: from dd1.caveonetworks.com (localhost.localdomain [127.0.0.1])
	by dd1.caveonetworks.com (8.14.2/8.14.2) with ESMTP id n83NAnp4003116;
	Thu, 3 Sep 2009 16:10:50 -0700
Received: (from ddaney@localhost)
	by dd1.caveonetworks.com (8.14.2/8.14.2/Submit) id n83NAls8003115;
	Thu, 3 Sep 2009 16:10:47 -0700
From:	David Daney <ddaney@caviumnetworks.com>
To:	linux-mips@linux-mips.org, ralf@linux-mips.org, gregkh@suse.de
Cc:	David Daney <ddaney@caviumnetworks.com>
Subject: [PATCH] Staging: Octeon: Use symbolic values for irq numbers.
Date:	Thu,  3 Sep 2009 16:10:47 -0700
Message-Id: <1252019447-3090-1-git-send-email-ddaney@caviumnetworks.com>
X-Mailer: git-send-email 1.6.0.6
X-OriginalArrivalTime: 03 Sep 2009 23:10:54.0871 (UTC) FILETIME=[C9D6BA70:01CA2CEB]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23983
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

In addition to being magic numbers, the irq number passed to free_irq
is incorrect.  We need to use the correct symbolic value instead.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---

Octeon being a member of the mips archecture, this could merge via
Ralf's linux-mips.org tree.

 drivers/staging/octeon/ethernet-spi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c
index 66190b0..00dc0f4 100644
--- a/drivers/staging/octeon/ethernet-spi.c
+++ b/drivers/staging/octeon/ethernet-spi.c
@@ -317,6 +317,6 @@ void cvm_oct_spi_uninit(struct net_device *dev)
 			cvmx_write_csr(CVMX_SPXX_INT_MSK(interface), 0);
 			cvmx_write_csr(CVMX_STXX_INT_MSK(interface), 0);
 		}
-		free_irq(8 + 46, &number_spi_ports);
+		free_irq(OCTEON_IRQ_RML, &number_spi_ports);
 	}
 }
-- 
1.6.0.6


From anemo@mba.ocn.ne.jp Fri Sep  4 15:09:14 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 04 Sep 2009 15:09:21 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:57580 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1492122AbZIDNJO (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 4 Sep 2009 15:09:14 +0200
Received: from localhost.localdomain (p5218-ipad313funabasi.chiba.ocn.ne.jp [123.217.231.218])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 1820E6918; Fri,  4 Sep 2009 22:09:05 +0900 (JST)
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org, davem@davemloft.net
Subject: [PATCH] txx9: Disable PM capability of TX493[89] internal ether
Date:	Fri,  4 Sep 2009 22:09:04 +0900
Message-Id: <1252069744-4553-1-git-send-email-anemo@mba.ocn.ne.jp>
X-Mailer: git-send-email 1.5.6.5
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23984
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

Some tc35815 variants (i.e. TX493[89] internal ether) report existance
of PM registers though they are not supported.  Disable PM features by
clearing pdev->pm_cap.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 arch/mips/txx9/generic/pci.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c
index 7b637a7..707cfa9 100644
--- a/arch/mips/txx9/generic/pci.c
+++ b/arch/mips/txx9/generic/pci.c
@@ -341,6 +341,15 @@ static void quirk_slc90e66_ide(struct pci_dev *dev)
 }
 #endif /* CONFIG_TOSHIBA_FPCIB0 */
 
+static void tc35815_fixup(struct pci_dev *dev)
+{
+	/* This device may have PM registers but not they are not suported. */
+	if (dev->pm_cap) {
+		dev_info(&dev->dev, "PM disabled\n");
+		dev->pm_cap = 0;
+	}
+}
+
 static void final_fixup(struct pci_dev *dev)
 {
 	unsigned char bist;
@@ -374,6 +383,10 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1,
 DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1,
 	quirk_slc90e66_ide);
 #endif
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_TOSHIBA_2,
+			PCI_DEVICE_ID_TOSHIBA_TC35815_NWU, tc35815_fixup);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_TOSHIBA_2,
+			PCI_DEVICE_ID_TOSHIBA_TC35815_TX4939, tc35815_fixup);
 DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, final_fixup);
 DECLARE_PCI_FIXUP_RESUME(PCI_ANY_ID, PCI_ANY_ID, final_fixup);
 
-- 
1.5.6.5


From ralf@linux-mips.org Fri Sep  4 18:11:28 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 04 Sep 2009 18:11:35 +0200 (CEST)
Received: from p549F7BBC.dip.t-dialin.net ([84.159.123.188]:47471 "EHLO
	h5.dl5rb.org.uk" rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org
	with ESMTP id S1492859AbZIDQL2 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 4 Sep 2009 18:11:28 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n84GBmTe006881;
	Fri, 4 Sep 2009 17:11:52 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n84GBYTe006877;
	Fri, 4 Sep 2009 17:11:34 +0100
Date:	Fri, 4 Sep 2009 17:11:34 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	linux-mips@linux-mips.org, davem@davemloft.net
Subject: Re: [PATCH] txx9: Disable PM capability of TX493[89] internal ether
Message-ID: <20090904161134.GA6699@linux-mips.org>
References: <1252069744-4553-1-git-send-email-anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1252069744-4553-1-git-send-email-anemo@mba.ocn.ne.jp>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23985
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Fri, Sep 04, 2009 at 10:09:04PM +0900, Atsushi Nemoto wrote:

> Some tc35815 variants (i.e. TX493[89] internal ether) report existance
> of PM registers though they are not supported.  Disable PM features by
> clearing pdev->pm_cap.

Thanks, applied.

  Ralf

From ralf@linux-mips.org Fri Sep  4 18:31:40 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 04 Sep 2009 18:31:43 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:35999 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1492750AbZIDQbk (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 4 Sep 2009 18:31:40 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n84GWT1h007643;
	Fri, 4 Sep 2009 17:32:30 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n84GWRmK007641;
	Fri, 4 Sep 2009 17:32:27 +0100
Date:	Fri, 4 Sep 2009 17:32:27 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	linux-mips@linux-mips.org, spi-devel-general@lists.sourceforge.net,
	david-b@pacbell.net
Subject: Re: [PATCH 2/2] spi_txx9: Fix bit rate calculation
Message-ID: <20090904163227.GB6699@linux-mips.org>
References: <1251986341-16938-2-git-send-email-anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1251986341-16938-2-git-send-email-anemo@mba.ocn.ne.jp>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23986
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Thu, Sep 03, 2009 at 10:59:01PM +0900, Atsushi Nemoto wrote:

Atsushi's patches should probably be merged together.  I can take care of
that if the SPI bit is acked by a maintainer.

Thanks,

  Ralf

From wuzhangjin@gmail.com Sat Sep  5 08:22:01 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 05 Sep 2009 08:22:08 +0200 (CEST)
Received: from mail-pz0-f175.google.com ([209.85.222.175]:42054 "EHLO
	mail-pz0-f175.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1491851AbZIEGWB (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 5 Sep 2009 08:22:01 +0200
Received: by pzk5 with SMTP id 5so1297646pzk.10
        for <multiple recipients>; Fri, 04 Sep 2009 23:21:52 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=8+9KmVDvJ2rAQPBA4FihJPrCl/XrQKisFG4GgmwVtBQ=;
        b=sm3XkjjBcgSjndic93NxpohN3+UPzNPSreivNL1JkFk3DumE2CDl+RFTdmGVIkRzMz
         QR64bNTdZP4Dn9qI3ay4UyAavuWY14yeitSkc1JsclPD6NHQjwu8eYzVESfL4B2GofIO
         TzifJ/W5FKfiBZ+UF1yknWx2xMbmCOdb2rxqM=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=SfFsu/P4kbqex5+0e07NrkZSaTqfKFttjBKuCGhObFs1DECLqlCHgkULFED0ip1/gM
         wEi7hSJ2ytzQwFlhne+LCyB6g+26zBJr8fwelzsV1pq6oydlQRJmVlILMMsptAflWd5+
         32WnsqKoHihueeY5ff5yUAefkIWwZohh1ZZdw=
Received: by 10.115.113.9 with SMTP id q9mr11215090wam.224.1252131712619;
        Fri, 04 Sep 2009 23:21:52 -0700 (PDT)
Received: from localhost.localdomain ([222.92.8.142])
        by mx.google.com with ESMTPS id 22sm687173pzk.14.2009.09.04.23.21.45
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 04 Sep 2009 23:21:51 -0700 (PDT)
From:	Wu Zhangjin <wuzhangjin@gmail.com>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org, Jason Wessel <jason.wessel@windriver.com>,
	Zhang Le <r0bertz@gentoo.org>,
	Arnaud Patard <apatard@mandriva.com>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	Wu Zhangjin <wuzj@lemote.com>
Subject: [PATCH 1/3] [loongson] eary_printk: Remove existing implementation
Date:	Sat,  5 Sep 2009 14:21:33 +0800
Message-Id: <1252131693-27424-1-git-send-email-wuzhangjin@gmail.com>
X-Mailer: git-send-email 1.6.2.1
Return-Path: <wuzhangjin@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23987
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: wuzhangjin@gmail.com
Precedence: bulk
X-list: linux-mips

From: Wu Zhangjin <wuzj@lemote.com>

This patch will remove the existing implementation of early_printk in
fulong. for this old implementation is based on the board-specific
source code(dbg_io.c), but dbg_io.c is out-of-date:

as the commit: 8d60a903d986ffa26c41f0092320a3b9da20bfaf shows, dbg_io.c
is not needed. it will be removed in the next patch, and the new
implementation of early_printk will be added later.

Signed-off-by: Wu Zhangjin <wuzj@lemote.com>
---
 arch/mips/lemote/lm2e/prom.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/mips/lemote/lm2e/prom.c b/arch/mips/lemote/lm2e/prom.c
index 7edc15d..d78cedf 100644
--- a/arch/mips/lemote/lm2e/prom.c
+++ b/arch/mips/lemote/lm2e/prom.c
@@ -21,7 +21,6 @@
 extern unsigned long bus_clock;
 extern unsigned long cpu_clock_freq;
 extern unsigned int memsize, highmemsize;
-extern int putDebugChar(unsigned char byte);
 
 static int argc;
 /* pmon passes arguments in 32bit pointers */
@@ -90,8 +89,3 @@ do {									\
 void __init prom_free_prom_memory(void)
 {
 }
-
-void prom_putchar(char c)
-{
-	putDebugChar(c);
-}
-- 
1.6.2.1


From wuzhangjin@gmail.com Sat Sep  5 08:23:09 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 05 Sep 2009 08:23:16 +0200 (CEST)
Received: from mail-px0-f174.google.com ([209.85.216.174]:38723 "EHLO
	mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1491851AbZIEGXF (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 5 Sep 2009 08:23:05 +0200
Received: by pxi4 with SMTP id 4so1255344pxi.21
        for <multiple recipients>; Fri, 04 Sep 2009 23:22:58 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=PyW0Z6+IxnNDroMSkxheBj1Iqe8X/Ckmpd1okuMdPys=;
        b=h/0DxgEX4I37Nm78vwnop/MT2UEQAz6xb0Yp9XAQbJ1NoSVBpnyak78MVjQda4DdqI
         jIdPKoMriKOtcTQu9x3S6sExxEIjXMJHG7eIo2O5wvqnW0mSTwRLUnjAq1+LoVN4giEq
         PyO77v+8Mdg4lM5SOe0SFzaZEy49nYBdEXWjg=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=gww4YloPnh/xAht3RlSE36iFuiL3KcklH3cMUr9OHnRZNgr+vKOEuabiej/4kNniF7
         QGL3OymBXqacSugxojZea54JCSZUCcH48w8TXDgwycp4ICBalMGOmK0yJJG0PguU4aeN
         +LLWBiknmL1CuYjTzw9zlV0Or3fIij6Kh8Skk=
Received: by 10.115.144.7 with SMTP id w7mr11217324wan.228.1252131777932;
        Fri, 04 Sep 2009 23:22:57 -0700 (PDT)
Received: from localhost.localdomain ([222.92.8.142])
        by mx.google.com with ESMTPS id 20sm755922pzk.1.2009.09.04.23.22.51
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 04 Sep 2009 23:22:57 -0700 (PDT)
From:	Wu Zhangjin <wuzhangjin@gmail.com>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org, Jason Wessel <jason.wessel@windriver.com>,
	Zhang Le <r0bertz@gentoo.org>,
	Arnaud Patard <apatard@mandriva.com>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	Wu Zhangjin <wuzj@lemote.com>
Subject: [PATCH 2/3] [loongson] kgdb: Remove out-of-date board-specific source code
Date:	Sat,  5 Sep 2009 14:22:45 +0800
Message-Id: <1252131765-30075-1-git-send-email-wuzhangjin@gmail.com>
X-Mailer: git-send-email 1.6.2.1
Return-Path: <wuzhangjin@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23988
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: wuzhangjin@gmail.com
Precedence: bulk
X-list: linux-mips

From: Wu Zhangjin <wuzj@lemote.com>

as the commit: 8854700115ecf8aa6f087aa915b7b6cf18090d39 shows, the new
mips-specific kgdb implementation not need this board-specific source
code, just remove it.

Acked-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Wu Zhangjin <wuzj@lemote.com>
---
 arch/mips/lemote/lm2e/Makefile |    2 +-
 arch/mips/lemote/lm2e/dbg_io.c |  146 ----------------------------------------
 2 files changed, 1 insertions(+), 147 deletions(-)
 delete mode 100644 arch/mips/lemote/lm2e/dbg_io.c

diff --git a/arch/mips/lemote/lm2e/Makefile b/arch/mips/lemote/lm2e/Makefile
index d34671d..b0c0339 100644
--- a/arch/mips/lemote/lm2e/Makefile
+++ b/arch/mips/lemote/lm2e/Makefile
@@ -2,6 +2,6 @@
 # Makefile for Lemote Fulong mini-PC board.
 #
 
-obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o
+obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o mem.o
 
 EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/lemote/lm2e/dbg_io.c b/arch/mips/lemote/lm2e/dbg_io.c
deleted file mode 100644
index 6c95da3..0000000
--- a/arch/mips/lemote/lm2e/dbg_io.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2001 MontaVista Software Inc.
- * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
- * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org)
- *
- * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology
- * Author: Fuxin Zhang, zhangfx@lemote.com
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
- *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
- *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <linux/io.h>
-#include <linux/init.h>
-#include <linux/types.h>
-
-#include <asm/serial.h>
-
-#define         UART16550_BAUD_2400             2400
-#define         UART16550_BAUD_4800             4800
-#define         UART16550_BAUD_9600             9600
-#define         UART16550_BAUD_19200            19200
-#define         UART16550_BAUD_38400            38400
-#define         UART16550_BAUD_57600            57600
-#define         UART16550_BAUD_115200           115200
-
-#define         UART16550_PARITY_NONE           0
-#define         UART16550_PARITY_ODD            0x08
-#define         UART16550_PARITY_EVEN           0x18
-#define         UART16550_PARITY_MARK           0x28
-#define         UART16550_PARITY_SPACE          0x38
-
-#define         UART16550_DATA_5BIT             0x0
-#define         UART16550_DATA_6BIT             0x1
-#define         UART16550_DATA_7BIT             0x2
-#define         UART16550_DATA_8BIT             0x3
-
-#define         UART16550_STOP_1BIT             0x0
-#define         UART16550_STOP_2BIT             0x4
-
-/* ----------------------------------------------------- */
-
-/* === CONFIG === */
-#ifdef CONFIG_64BIT
-#define         BASE                    (0xffffffffbfd003f8)
-#else
-#define         BASE                    (0xbfd003f8)
-#endif
-
-#define         MAX_BAUD                BASE_BAUD
-/* === END OF CONFIG === */
-
-#define         REG_OFFSET              1
-
-/* register offset */
-#define         OFS_RCV_BUFFER          0
-#define         OFS_TRANS_HOLD          0
-#define         OFS_SEND_BUFFER         0
-#define         OFS_INTR_ENABLE         (1*REG_OFFSET)
-#define         OFS_INTR_ID             (2*REG_OFFSET)
-#define         OFS_DATA_FORMAT         (3*REG_OFFSET)
-#define         OFS_LINE_CONTROL        (3*REG_OFFSET)
-#define         OFS_MODEM_CONTROL       (4*REG_OFFSET)
-#define         OFS_RS232_OUTPUT        (4*REG_OFFSET)
-#define         OFS_LINE_STATUS         (5*REG_OFFSET)
-#define         OFS_MODEM_STATUS        (6*REG_OFFSET)
-#define         OFS_RS232_INPUT         (6*REG_OFFSET)
-#define         OFS_SCRATCH_PAD         (7*REG_OFFSET)
-
-#define         OFS_DIVISOR_LSB         (0*REG_OFFSET)
-#define         OFS_DIVISOR_MSB         (1*REG_OFFSET)
-
-/* memory-mapped read/write of the port */
-#define         UART16550_READ(y)	readb((char *)BASE + (y))
-#define         UART16550_WRITE(y, z)	writeb(z, (char *)BASE + (y))
-
-void debugInit(u32 baud, u8 data, u8 parity, u8 stop)
-{
-	u32 divisor;
-
-	/* disable interrupts */
-	UART16550_WRITE(OFS_INTR_ENABLE, 0);
-
-	/* set up buad rate */
-	/* set DIAB bit */
-	UART16550_WRITE(OFS_LINE_CONTROL, 0x80);
-
-	/* set divisor */
-	divisor = MAX_BAUD / baud;
-	UART16550_WRITE(OFS_DIVISOR_LSB, divisor & 0xff);
-	UART16550_WRITE(OFS_DIVISOR_MSB, (divisor & 0xff00) >> 8);
-
-	/* clear DIAB bit */
-	UART16550_WRITE(OFS_LINE_CONTROL, 0x0);
-
-	/* set data format */
-	UART16550_WRITE(OFS_DATA_FORMAT, data | parity | stop);
-}
-
-static int remoteDebugInitialized;
-
-u8 getDebugChar(void)
-{
-	if (!remoteDebugInitialized) {
-		remoteDebugInitialized = 1;
-		debugInit(UART16550_BAUD_115200,
-			  UART16550_DATA_8BIT,
-			  UART16550_PARITY_NONE, UART16550_STOP_1BIT);
-	}
-
-	while ((UART16550_READ(OFS_LINE_STATUS) & 0x1) == 0) ;
-	return UART16550_READ(OFS_RCV_BUFFER);
-}
-
-int putDebugChar(u8 byte)
-{
-	if (!remoteDebugInitialized) {
-		remoteDebugInitialized = 1;
-		/*
-		   debugInit(UART16550_BAUD_115200,
-		   UART16550_DATA_8BIT,
-		   UART16550_PARITY_NONE, UART16550_STOP_1BIT); */
-	}
-
-	while ((UART16550_READ(OFS_LINE_STATUS) & 0x20) == 0) ;
-	UART16550_WRITE(OFS_SEND_BUFFER, byte);
-	return 1;
-}
-- 
1.6.2.1


From wuzhangjin@gmail.com Sat Sep  5 08:23:41 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 05 Sep 2009 08:23:48 +0200 (CEST)
Received: from mail-pz0-f175.google.com ([209.85.222.175]:58907 "EHLO
	mail-pz0-f175.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1491990AbZIEGX3 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 5 Sep 2009 08:23:29 +0200
Received: by pzk5 with SMTP id 5so1298489pzk.10
        for <multiple recipients>; Fri, 04 Sep 2009 23:23:22 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=ZX8Rv22A/CSV0BPT4cs57LWDWRAdZmMNuoRjYsQVJ48=;
        b=XkITSgdqO+NfP4JTQxz/Rm52izIJ7qj71qCXlMnNOQF5w8c2BbxyTvbnVbmm4O6se/
         2ZGhXhuJJODFstbpjdSE7zxBiTGF7HzlMCYS1dooobKHq0vu2gJYYjD8tTlczXrvhx6D
         A5C5dGmgf+69IkGA1E5bwt/iCEA8c5e0nVmt8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=d4fpaoNtkwgBYlIbC2/CL+suRhwdB+k+3Z4pseLKDuBXKBIRzQUa3aAmoD0KF/ZnQY
         wM/OLMkv8mrk3USBLEN8ddbHXkaiY7XXE1Xdc+YCjeWJ8bYfxvjxuPYq4S7PMhUMCd9o
         8V3vdItfTrQvdXBJx7liND3SlsxSDGr81P/fM=
Received: by 10.115.100.38 with SMTP id c38mr11289382wam.110.1252131800268;
        Fri, 04 Sep 2009 23:23:20 -0700 (PDT)
Received: from localhost.localdomain ([222.92.8.142])
        by mx.google.com with ESMTPS id 22sm95112pxi.10.2009.09.04.23.23.13
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 04 Sep 2009 23:23:19 -0700 (PDT)
From:	Wu Zhangjin <wuzhangjin@gmail.com>
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org, Jason Wessel <jason.wessel@windriver.com>,
	Zhang Le <r0bertz@gentoo.org>,
	Arnaud Patard <apatard@mandriva.com>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	Wu Zhangjin <wuzj@lemote.com>
Subject: [PATCH 3/3] [loongson] early_printk: add new implmentation
Date:	Sat,  5 Sep 2009 14:23:05 +0800
Message-Id: <1252131785-30112-1-git-send-email-wuzhangjin@gmail.com>
X-Mailer: git-send-email 1.6.2.1
Return-Path: <wuzhangjin@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23989
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: wuzhangjin@gmail.com
Precedence: bulk
X-list: linux-mips

From: Wu Zhangjin <wuzj@lemote.com>

This patch is based on the implementation in the lm2e-fixes branch of
Philippe's git://git.linux-cisco.org/linux-mips.git and the
malta-specific early_printk implementation.

Signed-off-by: Wu Zhangjin <wuzj@lemote.com>
---
 arch/mips/lemote/lm2e/Makefile       |    5 ++++
 arch/mips/lemote/lm2e/early_printk.c |   41 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 arch/mips/lemote/lm2e/early_printk.c

diff --git a/arch/mips/lemote/lm2e/Makefile b/arch/mips/lemote/lm2e/Makefile
index b0c0339..f191732 100644
--- a/arch/mips/lemote/lm2e/Makefile
+++ b/arch/mips/lemote/lm2e/Makefile
@@ -4,4 +4,9 @@
 
 obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o mem.o
 
+#
+# Early printk support
+#
+obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
+
 EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/lemote/lm2e/early_printk.c b/arch/mips/lemote/lm2e/early_printk.c
new file mode 100644
index 0000000..0644506
--- /dev/null
+++ b/arch/mips/lemote/lm2e/early_printk.c
@@ -0,0 +1,41 @@
+/*  early printk support
+ *
+ *  Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca>
+ *  Copyright (c) 2009 Lemote Inc. & Insititute of Computing Technology
+ *  Author: Wu Zhangjin, wuzj@lemote.com
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ */
+#include <linux/io.h>
+#include <linux/init.h>
+#include <linux/serial_reg.h>
+
+#include <asm/mips-boards/bonito64.h>
+
+#define UART_BASE (BONITO_PCIIO_BASE + 0x3f8)
+
+#define PORT(base, offset) (u8 *)(base + offset)
+
+static inline unsigned int serial_in(unsigned char *base, int offset)
+{
+	return readb(PORT(base, offset));
+}
+
+static inline void serial_out(unsigned char *base, int offset, int value)
+{
+	writeb(value, PORT(base, offset));
+}
+
+void prom_putchar(char c)
+{
+	unsigned char *uart_base =
+		(unsigned char *) ioremap_nocache(UART_BASE, 8);
+
+	while ((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0)
+		;
+
+	serial_out(uart_base, UART_TX, c);
+}
-- 
1.6.2.1


From cernekee@gmail.com Sun Sep  6 00:11:19 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 06 Sep 2009 22:56:33 +0200 (CEST)
Received: from [65.98.92.6] ([65.98.92.6]:4024 "EHLO b32.net"
	rhost-flags-FAIL-FAIL-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492979AbZIEWLT (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 6 Sep 2009 00:11:19 +0200
Received: (qmail 25897 invoked from network); 5 Sep 2009 22:11:13 -0000
Received: from unknown (HELO two) (127.0.0.1)
  by 127.0.0.1 with SMTP; 5 Sep 2009 22:11:13 -0000
Received: by two (sSMTP sendmail emulation); Sat, 05 Sep 2009 15:11:13 -0700
Message-Id: <197625223d8cb6ec3fc3e7da4501dd65@localhost>
From:	Kevin Cernekee <cernekee@gmail.com>
To:	ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Date:	Sat, 5 Sep 2009 14:38:41 -0700
Subject: [PATCH] MIPS: Machine check exception in kmap_coherent()
Return-Path: <cernekee@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23990
X-Approved-By: ralf@linux-mips.org
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: cernekee@gmail.com
Precedence: bulk
X-list: linux-mips

On an SMP MIPS32 2.6.30 system with cache aliases, I am seeing the
following sequence of events:

1) copy_user_highpage() runs on CPU0, invoking kmap_coherent() to create
a temporary mapping in the fixmap region

2) copy_page() starts on CPU0

3) CPU1 sends CPU0 an IPI asking CPU0 to run
local_r4k_flush_cache_page()

4) CPU0 takes the interrupt, interrupting copy_page()

5) local_r4k_flush_cache_page() on CPU0 calls kmap_coherent() again

6) The second invocation of kmap_coherent() on CPU0 tries to use the
same fixmap virtual address that was being used by copy_user_highpage()

7) CPU0 throws a machine check exception for the TLB address conflict

Here is my proposed fix:

a) kmap_coherent() will maintain a flag for each CPU indicating whether
there is an active mapping (kmap_coherent_inuse)

b) kmap_coherent() will return a NULL address in the unlikely case that
it was called while another mapping was already outstanding

c) local_r4k_flush_cache_page() will check for a NULL return value from
kmap_coherent(), and compensate by using indexed cacheops instead of hit
cacheops

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
 arch/mips/mm/c-r4k.c |   25 +++++++++++++++++++------
 arch/mips/mm/init.c  |   17 +++++++++++++++--
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 6721ee2..572fe7e 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -459,7 +459,7 @@ static inline void local_r4k_flush_cache_page(void *args)
 	struct page *page = pfn_to_page(fcp_args->pfn);
 	int exec = vma->vm_flags & VM_EXEC;
 	struct mm_struct *mm = vma->vm_mm;
-	int map_coherent = 0;
+	int map_coherent = 0, use_indexed = 0;
 	pgd_t *pgdp;
 	pud_t *pudp;
 	pmd_t *pmdp;
@@ -499,13 +499,23 @@ static inline void local_r4k_flush_cache_page(void *args)
 			vaddr = kmap_coherent(page, addr);
 		else
 			vaddr = kmap_atomic(page, KM_USER0);
-		addr = (unsigned long)vaddr;
+
+		if (unlikely(vaddr == NULL))
+			use_indexed = 1;
+		else
+			addr = (unsigned long)vaddr;
 	}
 
 	if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
-		r4k_blast_dcache_page(addr);
-		if (exec && !cpu_icache_snoops_remote_store)
-			r4k_blast_scache_page(addr);
+		if (use_indexed) {
+			r4k_blast_dcache_page_indexed(addr);
+			if (exec && !cpu_icache_snoops_remote_store)
+				r4k_blast_scache_page_indexed(addr);
+		} else {
+			r4k_blast_dcache_page(addr);
+			if (exec && !cpu_icache_snoops_remote_store)
+				r4k_blast_scache_page(addr);
+		}
 	}
 	if (exec) {
 		if (vaddr && cpu_has_vtag_icache && mm == current->active_mm) {
@@ -514,7 +524,10 @@ static inline void local_r4k_flush_cache_page(void *args)
 			if (cpu_context(cpu, mm) != 0)
 				drop_mmu_context(mm, cpu);
 		} else
-			r4k_blast_icache_page(addr);
+			if (use_indexed)
+				r4k_blast_icache_page_indexed(addr);
+			else
+				r4k_blast_icache_page(addr);
 	}
 
 	if (vaddr) {
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 0e82050..87967cd 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -31,6 +31,7 @@
 #include <asm/asm-offsets.h>
 #include <asm/bootinfo.h>
 #include <asm/cachectl.h>
+#include <asm/cache.h>
 #include <asm/cpu.h>
 #include <asm/dma.h>
 #include <asm/kmap_types.h>
@@ -105,6 +106,8 @@ unsigned long setup_zero_pages(void)
 	return 1UL << order;
 }
 
+static int kmap_coherent_inuse[NR_CPUS] ____cacheline_aligned_in_smp;
+
 #ifdef CONFIG_MIPS_MT_SMTC
 static pte_t *kmap_coherent_pte;
 static void __init kmap_coherent_init(void)
@@ -125,14 +128,15 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 	unsigned long vaddr, flags, entrylo;
 	unsigned long old_ctx;
 	pte_t pte;
-	int tlbidx;
+	int tlbidx, cpu;
 
 	BUG_ON(Page_dcache_dirty(page));
 
 	inc_preempt_count();
+	cpu = smp_processor_id();
 	idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
 #ifdef CONFIG_MIPS_MT_SMTC
-	idx += FIX_N_COLOURS * smp_processor_id();
+	idx += FIX_N_COLOURS * cpu;
 #endif
 	vaddr = __fix_to_virt(FIX_CMAP_END - idx);
 	pte = mk_pte(page, PAGE_KERNEL);
@@ -143,6 +147,13 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 #endif
 
 	ENTER_CRITICAL(flags);
+	if (unlikely(kmap_coherent_inuse[cpu] != 0)) {
+		vaddr = 0;
+		dec_preempt_count();
+		goto out;
+	}
+	kmap_coherent_inuse[cpu] = 1;
+
 	old_ctx = read_c0_entryhi();
 	write_c0_entryhi(vaddr & (PAGE_MASK << 1));
 	write_c0_entrylo0(entrylo);
@@ -168,6 +179,7 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 #endif
 	tlbw_use_hazard();
 	write_c0_entryhi(old_ctx);
+out:
 	EXIT_CRITICAL(flags);
 
 	return (void*) vaddr;
@@ -195,6 +207,7 @@ void kunmap_coherent(void)
 	write_c0_entryhi(old_ctx);
 	EXIT_CRITICAL(flags);
 #endif
+	kmap_coherent_inuse[smp_processor_id()] = 0;
 	dec_preempt_count();
 	preempt_check_resched();
 }
-- 
1.6.3.1


From ralf@linux-mips.org Mon Sep  7 12:25:22 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 07 Sep 2009 12:25:26 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:59865 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1492648AbZIGKZW (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 7 Sep 2009 12:25:22 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n87AQERK005136;
	Mon, 7 Sep 2009 12:26:15 +0200
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n87AQDBV005134;
	Mon, 7 Sep 2009 12:26:13 +0200
Date:	Mon, 7 Sep 2009 12:26:13 +0200
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Kevin Cernekee <cernekee@gmail.com>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: Machine check exception in kmap_coherent()
Message-ID: <20090907102613.GA25295@linux-mips.org>
References: <197625223d8cb6ec3fc3e7da4501dd65@localhost>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <197625223d8cb6ec3fc3e7da4501dd65@localhost>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23991
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Sat, Sep 05, 2009 at 02:38:41PM -0700, Kevin Cernekee wrote:

> On an SMP MIPS32 2.6.30 system with cache aliases, I am seeing the
> following sequence of events:
> 
> 1) copy_user_highpage() runs on CPU0, invoking kmap_coherent() to create
> a temporary mapping in the fixmap region
> 
> 2) copy_page() starts on CPU0
> 
> 3) CPU1 sends CPU0 an IPI asking CPU0 to run
> local_r4k_flush_cache_page()
> 
> 4) CPU0 takes the interrupt, interrupting copy_page()
> 
> 5) local_r4k_flush_cache_page() on CPU0 calls kmap_coherent() again
> 
> 6) The second invocation of kmap_coherent() on CPU0 tries to use the
> same fixmap virtual address that was being used by copy_user_highpage()
> 
> 7) CPU0 throws a machine check exception for the TLB address conflict

Nice analysis!

> Here is my proposed fix:
> 
> a) kmap_coherent() will maintain a flag for each CPU indicating whether
> there is an active mapping (kmap_coherent_inuse)
> 
> b) kmap_coherent() will return a NULL address in the unlikely case that
> it was called while another mapping was already outstanding
> 
> c) local_r4k_flush_cache_page() will check for a NULL return value from
> kmap_coherent(), and compensate by using indexed cacheops instead of hit
> cacheops

Too complicated.  The fault is happening because the non-SMTC code is trying
to be terribly clever and pre-loading the TLB with a new wired entry.  On
SMTC where multiple processors are sharing a single TLB are more careful
approach is needed so the code does a TLB probe and carefully and re-uses
an existing entry, if any.  Which happens to be just what we need.

So how about below - only compile tested - patch?

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

 arch/mips/mm/init.c |   35 +----------------------------------
 1 files changed, 1 insertions(+), 34 deletions(-)

diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 0e82050..ab11582 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -105,8 +105,8 @@ unsigned long setup_zero_pages(void)
 	return 1UL << order;
 }
 
-#ifdef CONFIG_MIPS_MT_SMTC
 static pte_t *kmap_coherent_pte;
+
 static void __init kmap_coherent_init(void)
 {
 	unsigned long vaddr;
@@ -115,9 +115,6 @@ static void __init kmap_coherent_init(void)
 	vaddr = __fix_to_virt(FIX_CMAP_BEGIN);
 	kmap_coherent_pte = kmap_get_fixmap_pte(vaddr);
 }
-#else
-static inline void kmap_coherent_init(void) {}
-#endif
 
 void *kmap_coherent(struct page *page, unsigned long addr)
 {
@@ -131,9 +128,7 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 
 	inc_preempt_count();
 	idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
-#ifdef CONFIG_MIPS_MT_SMTC
 	idx += FIX_N_COLOURS * smp_processor_id();
-#endif
 	vaddr = __fix_to_virt(FIX_CMAP_END - idx);
 	pte = mk_pte(page, PAGE_KERNEL);
 #if defined(CONFIG_64BIT_PHYS_ADDR) && defined(CONFIG_CPU_MIPS32)
@@ -147,7 +142,6 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 	write_c0_entryhi(vaddr & (PAGE_MASK << 1));
 	write_c0_entrylo0(entrylo);
 	write_c0_entrylo1(entrylo);
-#ifdef CONFIG_MIPS_MT_SMTC
 	set_pte(kmap_coherent_pte - (FIX_CMAP_END - idx), pte);
 	/* preload TLB instead of local_flush_tlb_one() */
 	mtc0_tlbw_hazard();
@@ -159,13 +153,6 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 		tlb_write_random();
 	else
 		tlb_write_indexed();
-#else
-	tlbidx = read_c0_wired();
-	write_c0_wired(tlbidx + 1);
-	write_c0_index(tlbidx);
-	mtc0_tlbw_hazard();
-	tlb_write_indexed();
-#endif
 	tlbw_use_hazard();
 	write_c0_entryhi(old_ctx);
 	EXIT_CRITICAL(flags);
@@ -177,24 +164,6 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 
 void kunmap_coherent(void)
 {
-#ifndef CONFIG_MIPS_MT_SMTC
-	unsigned int wired;
-	unsigned long flags, old_ctx;
-
-	ENTER_CRITICAL(flags);
-	old_ctx = read_c0_entryhi();
-	wired = read_c0_wired() - 1;
-	write_c0_wired(wired);
-	write_c0_index(wired);
-	write_c0_entryhi(UNIQUE_ENTRYHI(wired));
-	write_c0_entrylo0(0);
-	write_c0_entrylo1(0);
-	mtc0_tlbw_hazard();
-	tlb_write_indexed();
-	tlbw_use_hazard();
-	write_c0_entryhi(old_ctx);
-	EXIT_CRITICAL(flags);
-#endif
 	dec_preempt_count();
 	preempt_check_resched();
 }
@@ -260,7 +229,6 @@ void copy_from_user_page(struct vm_area_struct *vma,
 void __init fixrange_init(unsigned long start, unsigned long end,
 	pgd_t *pgd_base)
 {
-#if defined(CONFIG_HIGHMEM) || defined(CONFIG_MIPS_MT_SMTC)
 	pgd_t *pgd;
 	pud_t *pud;
 	pmd_t *pmd;
@@ -290,7 +258,6 @@ void __init fixrange_init(unsigned long start, unsigned long end,
 		}
 		j = 0;
 	}
-#endif
 }
 
 #ifndef CONFIG_NEED_MULTIPLE_NODES

From cernekee@gmail.com Mon Sep  7 20:24:38 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 07 Sep 2009 20:24:46 +0200 (CEST)
Received: from [65.98.92.6] ([65.98.92.6]:4175 "EHLO b32.net"
	rhost-flags-FAIL-FAIL-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493455AbZIGSYi (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 7 Sep 2009 20:24:38 +0200
Received: (qmail 30898 invoked from network); 7 Sep 2009 18:24:35 -0000
Received: from unknown (HELO two) (127.0.0.1)
  by 127.0.0.1 with SMTP; 7 Sep 2009 18:24:35 -0000
Received: by two (sSMTP sendmail emulation); Mon, 07 Sep 2009 11:24:35 -0700
From:	Kevin Cernekee <cernekee@gmail.com>
To:	ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Date:	Mon, 7 Sep 2009 11:11:31 -0700
Subject: [PATCHv2] MIPS: Machine check exception in kmap_coherent()
Message-Id: <2c228c5e48509b7c8296a6c50af3ad73@localhost>
In-Reply-To: <20090907102613.GA25295@linux-mips.org>
References: <20090907102613.GA25295@linux-mips.org>
User-Agent: vim 7.1
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Return-Path: <cernekee@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23992
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: cernekee@gmail.com
Precedence: bulk
X-list: linux-mips

Create an extra set of fixmap entries for use in interrupt handlers.
This prevents fixmap VA conflicts between copy_user_highpage() running
in user context, and local_r4k_flush_cache_page() invoked from an SMP
IPI.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
 arch/mips/include/asm/fixmap.h |    4 ++--
 arch/mips/mm/init.c            |    6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/fixmap.h b/arch/mips/include/asm/fixmap.h
index 0f5caa1..dd924b9 100644
--- a/arch/mips/include/asm/fixmap.h
+++ b/arch/mips/include/asm/fixmap.h
@@ -48,9 +48,9 @@ enum fixed_addresses {
 #define FIX_N_COLOURS 8
 	FIX_CMAP_BEGIN,
 #ifdef CONFIG_MIPS_MT_SMTC
-	FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS),
+	FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * NR_CPUS * 2),
 #else
-	FIX_CMAP_END = FIX_CMAP_BEGIN + FIX_N_COLOURS,
+	FIX_CMAP_END = FIX_CMAP_BEGIN + (FIX_N_COLOURS * 2),
 #endif
 #ifdef CONFIG_HIGHMEM
 	/* reserved pte's for temporary kernel mappings */
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index 0e82050..43ebe65 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -27,6 +27,7 @@
 #include <linux/swap.h>
 #include <linux/proc_fs.h>
 #include <linux/pfn.h>
+#include <linux/hardirq.h>
 
 #include <asm/asm-offsets.h>
 #include <asm/bootinfo.h>
@@ -132,7 +133,10 @@ void *kmap_coherent(struct page *page, unsigned long addr)
 	inc_preempt_count();
 	idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
 #ifdef CONFIG_MIPS_MT_SMTC
-	idx += FIX_N_COLOURS * smp_processor_id();
+	idx += FIX_N_COLOURS * smp_processor_id() +
+		(in_interrupt() ? (FIX_N_COLOURS * NR_CPUS) : 0);
+#else
+	idx += in_interrupt() ? FIX_N_COLOURS : 0;
 #endif
 	vaddr = __fix_to_virt(FIX_CMAP_END - idx);
 	pte = mk_pte(page, PAGE_KERNEL);
-- 
1.6.3.1


From cernekee@gmail.com Mon Sep  7 20:28:16 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 07 Sep 2009 20:28:24 +0200 (CEST)
Received: from mail-yx0-f176.google.com ([209.85.210.176]:58680 "EHLO
	mail-yx0-f176.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493451AbZIGS2Q convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 7 Sep 2009 20:28:16 +0200
Received: by yxe6 with SMTP id 6so3284579yxe.22
        for <multiple recipients>; Mon, 07 Sep 2009 11:28:09 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type
         :content-transfer-encoding;
        bh=sozatdNewOWwECRibP9qaU47jH3DVLRnapILv5bPyv4=;
        b=JMMUxiduwuyIP/xXZWqjj36JXj5j9u4XcFTFxRlFeiqVibjDmOzL+j7vYl8t6Kxtvk
         KQwvmiBYtoFLmWit32XBQemKd+Te78IIBxCnQaStZlJscZspk1vsKdoHffhptwV02RD3
         zpAQBLrJSTAuif6z70p7A8idPcI/40NmRA++0=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type:content-transfer-encoding;
        b=vjXXJMpY7DYcGb4oowmgSY6+bKBfMm2b8oXi8w/QWS+EK4a/8Re99/C5Xy/JC0214r
         q1P3jjxPCvNn16PjDFROluRT0ETnqthRKEDsm0nObSDRhz0RiFZ6xT//lGyPxZr9fXMb
         kO0W7kX+KZXCACC5dMq1zg6mi0iaM3ZCYTqo0=
MIME-Version: 1.0
Received: by 10.150.1.12 with SMTP id 12mr23205352yba.148.1252348088601; Mon, 
	07 Sep 2009 11:28:08 -0700 (PDT)
In-Reply-To: <20090907102613.GA25295@linux-mips.org>
References: <197625223d8cb6ec3fc3e7da4501dd65@localhost>
	 <20090907102613.GA25295@linux-mips.org>
Date:	Mon, 7 Sep 2009 11:28:05 -0700
Message-ID: <347733d50909071128v63b2d8a1hd6a87a361c14017e@mail.gmail.com>
Subject: Re: [PATCH] MIPS: Machine check exception in kmap_coherent()
From:	Kevin Cernekee <cernekee@gmail.com>
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8BIT
Return-Path: <cernekee@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23993
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: cernekee@gmail.com
Precedence: bulk
X-list: linux-mips

On Mon, Sep 7, 2009 at 3:26 AM, Ralf Baechle<ralf@linux-mips.org> wrote:
> Too complicated. Â The fault is happening because the non-SMTC code is trying
> to be terribly clever and pre-loading the TLB with a new wired entry. Â On
> SMTC where multiple processors are sharing a single TLB are more careful
> approach is needed so the code does a TLB probe and carefully and re-uses
> an existing entry, if any. Â Which happens to be just what we need.
>
> So how about below - only compile tested - patch?

That is an interesting idea.  However, I am not sure we want the IPI
ISR to overwrite copy_user_highpage()'s TLB entry.  That means that
when the interrupt returns, our coherent mapping will likely point to
a different page.  It will avoid the machine check exception, but it
will potentially cause silent, intermittent data corruption instead.

Taking another cue from the SMTC implementation, though - my v2 patch
adds an extra set of fixmap addresses for the in_interrupt() case,
avoiding the VA conflict entirely.  What do you think?

I tested this scheme on non-SMTC.  I suspect that the same change is
required for MT + MP cores like the 1004K, but probably not MT only
cores like 34K which don't use cacheop IPIs.

From muvarov@ru.mvista.com Tue Sep  8 18:17:06 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 08 Sep 2009 18:17:14 +0200 (CEST)
Received: from ru.mvista.com ([213.79.90.228]:22052 "EHLO
	buildserver.ru.mvista.com" rhost-flags-OK-FAIL-OK-FAIL)
	by ftp.linux-mips.org with ESMTP id S1492691AbZIHQRG (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 8 Sep 2009 18:17:06 +0200
Received: from [192.168.11.243] (unknown [10.150.0.9])
	by buildserver.ru.mvista.com (Postfix) with ESMTP
	id 11D568814; Tue,  8 Sep 2009 18:06:33 +0500 (SAMST)
Message-ID: <4AA656D8.9040608@ru.mvista.com>
Date:	Tue, 08 Sep 2009 17:06:32 +0400
From:	Maxim Uvarov <muvarov@ru.mvista.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To:	linux-mips@linux-mips.org
Cc:	ralf@linux-mips.org
Subject: [MIPS] TLB  handler fix for vmalloc'ed addresses
Content-Type: multipart/mixed;
 boundary="------------060200050905030006090904"
Return-Path: <muvarov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23994
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: muvarov@ru.mvista.com
Precedence: bulk
X-list: linux-mips

This is a multi-part message in MIME format.
--------------060200050905030006090904
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Patch is attached.

Best regards,
Maxim Uvarov.

--------------060200050905030006090904
Content-Type: text/x-patch;
 name="mips_tlb_fixup.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mips_tlb_fixup.patch"

TLB exception handler incorrecly handles situation
with wrong vmalloc'ed addresses.  This patch adds
verifications for vmalloc'ed addresses (similar to
x86_64 implementation). So the code now traps inside
do_page_fault() on access to the wrong area.

Signed-off-by: Maxim Uvarov <muvarov@ru.mvista.com>

Test case:

#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/delay.h>

static struct task_struct *ts;
static int example_thread(void *dummy)
{
	void *ptr;
	ptr = vmalloc(16*1024*1024);
	for(;;)
	{
		msleep(100);
	}
}

static void run_vmalloc(void *unused)
{
	ts=kthread_run(example_thread,NULL,"vtest");
}
int init_module (void)
{
	run_vmalloc(NULL);
	return 0;
}

void cleanup_module (void)
{ /*Nothing*/}


Originally kernel trapped on BUG() inside exit_mmap() and it was impossible
to see what has happened. After this patch applied, nice back trace will be
generated:

CPU 0 Unable to handle kernel paging request at virtual address c00000000036a148
Oops[#1]:
Cpu 0
$ 0   : 0000000000000000 ffffffff81940000 0000000000000000 00000000ffff05a7
$ 4   : 0000000000000000 ffffffffffffffff ffffffff81a0b7d0 ffffffff811983e4
$ 8   : ffffffff817407b0 0000000000000000 0000000000000000 0000000000000000
$12   : a80000003374bfe0 0000000000008c00 ffffffff811e9df8 0000000000000000
$16   : ffffffff81164a68 a8000000352a3c50 c00000000036a0e8 0000000000000000
$20   : 0000000000000000 0000000000000000 0000000000000000 0000000000000000
$24   : 0000000000000002 a8000000337bb1a0                                  
$28   : a800000033748000 a80000003374bf70 a80000003374bf70 c00000000036a148
Hi    : 0000000000000000
Lo    : 000000000000a311
epc   : c00000000036a148 0xc00000000036a148     Tainted: P      
ra    : c00000000036a148 0xc00000000036a148 <-- dead in kernel module vtest
Status: 10008ce3    KX SX UX KERNEL EXL IE 
Cause : 00000008
BadVA : c00000000036a148
PrId  : 000d0408
Modules linked in:
Process vtest (pid: 723, threadinfo=a800000033748000, task=a800000034530340)
	Stack : 0000000000000000 a80000003374bf90 ffffffff81176530 ffffffff81176488
	ffffffffffffffff ffffffffffffffff 0000000000000000 0000000000000000
	0000000000000000 a80000003374bfd0 ffffffff81125024 0000000000000000
	0000000000000000 0000000000000000 5a5a5a5a5a5a5a5a 5a5a5a5a5a5a5a5a
	5a5a5a5a5a5a5a5a 5a5a5a5a5a5a5aa5
	Call Trace:
	[<ffffffff81176530>] kthread+0x198/0x1f0
	[<ffffffff81176488>] kthread+0xf0/0x1f0
	[<ffffffff81125024>] kernel_thread_helper+0x14/0x20


Code: (Bad address in epc)

Index: linux-2.6.21/arch/mips/mm/fault.c
===================================================================
--- linux-2.6.21.orig/arch/mips/mm/fault.c
+++ linux-2.6.21/arch/mips/mm/fault.c
@@ -282,22 +282,32 @@ vmalloc_fault:
 		pte_t *pte_k;
 
 		pgd = (pgd_t *) pgd_current[raw_smp_processor_id()] + offset;
-		pgd_k = init_mm.pgd + offset;
+		pgd_k = pgd_offset_k(address);
 
 		if (!pgd_present(*pgd_k))
 			goto no_context;
-		set_pgd(pgd, *pgd_k);
+		if (unlikely(!pgd_present(*pgd)))
+			set_pgd(pgd, *pgd_k);
+		else if (pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_k))
+				goto no_context;
 
 		pud = pud_offset(pgd, address);
 		pud_k = pud_offset(pgd_k, address);
 		if (!pud_present(*pud_k))
 			goto no_context;
+		if (pud_none(*pud) ||
+				pud_page_vaddr(*pud) != pud_page_vaddr(*pud_k))
+			goto no_context;
 
 		pmd = pmd_offset(pud, address);
 		pmd_k = pmd_offset(pud_k, address);
 		if (!pmd_present(*pmd_k))
 			goto no_context;
-		set_pmd(pmd, *pmd_k);
+		if (!pmd_present(*pmd))
+			set_pmd(pmd, *pmd_k);
+		else
+			if (pmd_page(*pmd) != pmd_page(*pmd_k))
+				goto no_context;
 
 		pte_k = pte_offset_kernel(pmd_k, address);
 		if (!pte_present(*pte_k))

--------------060200050905030006090904--

From David.Daney@caviumnetworks.com Wed Sep  9 17:36:41 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 09 Sep 2009 17:36:47 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:16297 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493128AbZIIPgl (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 9 Sep 2009 17:36:41 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,2,2,3503)
	id <B4aa7cb3a0001>; Wed, 09 Sep 2009 11:35:25 -0400
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 9 Sep 2009 08:35:26 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 9 Sep 2009 08:35:26 -0700
Message-ID: <4AA7CB3E.1080807@caviumnetworks.com>
Date:	Wed, 09 Sep 2009 08:35:26 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Wu Fei <at.wufei@gmail.com>
CC:	Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
Subject: Re: [PATCH] cleanup vmalloc_fault for 64bit kernel
References: <20090831132811.GA6924@desktop>
In-Reply-To: <20090831132811.GA6924@desktop>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 09 Sep 2009 15:35:26.0743 (UTC) FILETIME=[277BD270:01CA3163]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23995
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Wu Fei wrote:
> 64bit kernel won't arrive vmalloc_fault, it's not necessary or possible
> to copy the page table from init_mm.pgd. swapper_pg_dir, module_pg_dir
> and the process's pgd represent the different virtual address area, and
> the tlb exception handler accesses the suitable one directly.
> 
> Signed-off-by: Wu Fei <at.wufei@gmail.com>
> ---
>  arch/mips/mm/fault.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
> index f956ecb..e769789 100644
> --- a/arch/mips/mm/fault.c
> +++ b/arch/mips/mm/fault.c
> @@ -58,11 +58,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>  	 * only copy the information from the master page table,
>  	 * nothing more.
>  	 */
> +#ifdef CONFIG_32BIT
>  	if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END))
>  		goto vmalloc_fault;
> -#ifdef MODULE_START
> -	if (unlikely(address >= MODULE_START && address < MODULE_END))
> -		goto vmalloc_fault;
>  #endif
>  

That is not correct.  You can still arrive at do_page_fault() from 
faults in the vmalloc range.  We need to go directly to the panic code 
as I did in my patch: Message-Id: 
<1251931654-21268-1-git-send-email-ddaney@caviumnetworks.com>

AKA: [PATCH] MIPS: Don't corrupt page tables on vmalloc fault.



>  	/*
> @@ -203,6 +201,7 @@ do_sigbus:
>  	force_sig_info(SIGBUS, &info, tsk);
>  
>  	return;
> +#ifdef CONFIG_32BIT
>  vmalloc_fault:
>  	{
>  		/*
> @@ -241,4 +240,5 @@ vmalloc_fault:
>  			goto no_context;
>  		return;
>  	}
> +#endif
>  }


From David.Daney@caviumnetworks.com Wed Sep  9 20:18:18 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 09 Sep 2009 20:18:25 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:2857 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492698AbZIISSR (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 9 Sep 2009 20:18:17 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,2,2,3503)
	id <B4aa7f12f0004>; Wed, 09 Sep 2009 14:17:19 -0400
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 9 Sep 2009 11:17:23 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 9 Sep 2009 11:17:23 -0700
Message-ID: <4AA7F133.20104@caviumnetworks.com>
Date:	Wed, 09 Sep 2009 11:17:23 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Dok Sander <doksander@yahoo.com>
CC:	linux-kernel@vger.kernel.org,
	linux-mips <linux-mips@linux-mips.org>
Subject: Re: io.h doesn't get installed by target "headers_install" for mips
References: <806810.23677.qm@web59313.mail.re1.yahoo.com>
In-Reply-To: <806810.23677.qm@web59313.mail.re1.yahoo.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 09 Sep 2009 18:17:23.0636 (UTC) FILETIME=[C7340740:01CA3179]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23996
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Dok Sander wrote:
> Hi,
> 
>  I noticed the absence of the header io.h while trying to build(cross-compile, host i686-pc-linux-gnu) a software(lm-sensors-3.1.1, wants io.h in /sys) for mips. I can find io.h for mips in arch/mips/asm/include/{,sn/} However, io.h doesn't get installed when i do "make ARCH=mips headers_install" on linux 2.6.30.6
> 
>  According to someone on the eglibc mailing list, linux should provide io.h for mips. Is this true?
> 

I don't think so (for two reasons):

1) The things in /usr/include/sys are provided by libc not the kernel.

2) MIPS doesn't have I/O ports, so all the functions in sys/io.h on an 
x86 are undefined for MIPS.

David Daney


From w.sang@pengutronix.de Wed Sep  9 23:23:53 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 09 Sep 2009 23:23:59 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:41251 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493463AbZIIVXx (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 9 Sep 2009 23:23:53 +0200
Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MlUdc-00008N-Bh; Wed, 09 Sep 2009 23:23:41 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	linux-i2c@vger.kernel.org
Cc:	linuxppc-dev@ozlabs.org, linux-arm-kernel@lists.infradead.org,
	linux-mips@linux-mips.org, uclinux-dist-devel@blackfin.uclinux.org
Date:	Wed,  9 Sep 2009 23:22:47 +0200
Message-Id: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
X-Mailer: git-send-email 1.6.3.3
X-SA-Exim-Connect-IP: 92.198.50.58
X-SA-Exim-Mail-From: w.sang@pengutronix.de
Subject: Removing deprecated drivers from drivers/i2c/chips
X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000)
X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de)
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23997
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips

Hi,

continuing the quest to clean up and ultimately remove the drivers/i2c/chips
directory, this patch series removes three drivers for GPIO-expanders which are
obsoleted and marked as deprecated for more than a year. The newer (and better)
drivers can be found in drivers/gpio.

As it is ensured that the newer drivers cover the same i2c_device_ids, all
platform_devices will still match. Some defconfig updates may be necessary
though, but according to [1] this is left to the arch|platform-maintainers
(also as most defconfigs are quite outdated). For that reason, I put the
relevant arch-mailing-lists to Cc. Comments are welcome.

Regards,

   Wolfram

[1] http://lkml.org/lkml/2009/5/7/34


From w.sang@pengutronix.de Wed Sep  9 23:24:17 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 09 Sep 2009 23:24:24 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:41259 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493465AbZIIVX4 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 9 Sep 2009 23:23:56 +0200
Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MlUdj-00008g-3r; Wed, 09 Sep 2009 23:23:46 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	linux-i2c@vger.kernel.org
Cc:	linuxppc-dev@ozlabs.org, linux-arm-kernel@lists.infradead.org,
	linux-mips@linux-mips.org, uclinux-dist-devel@blackfin.uclinux.org,
	Wolfram Sang <w.sang@pengutronix.de>,
	David Brownell <dbrownell@users.sourceforge.net>,
	Jean Delvare <khali@linux-fr.org>
Date:	Wed,  9 Sep 2009 23:22:48 +0200
Message-Id: <1252531371-14866-2-git-send-email-w.sang@pengutronix.de>
X-Mailer: git-send-email 1.6.3.3
In-Reply-To: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
X-SA-Exim-Connect-IP: 92.198.50.58
X-SA-Exim-Mail-From: w.sang@pengutronix.de
Subject: [PATCH 1/4] gpio/pcf857x: copy i2c_device_id from old pcf8574-driver
X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000)
X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de)
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23998
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips

The deprecated pcf8574 driver is going to be removed. Make sure this
replacement-driver inherits all i2c_device_ids for a smooth transition.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Jean Delvare <khali@linux-fr.org>
---
 drivers/gpio/pcf857x.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/pcf857x.c b/drivers/gpio/pcf857x.c
index 9525724..3f1ec1e 100644
--- a/drivers/gpio/pcf857x.c
+++ b/drivers/gpio/pcf857x.c
@@ -28,6 +28,7 @@
 
 static const struct i2c_device_id pcf857x_id[] = {
 	{ "pcf8574", 8 },
+	{ "pcf8574a", 8 },
 	{ "pca8574", 8 },
 	{ "pca9670", 8 },
 	{ "pca9672", 8 },
-- 
1.6.3.3


From w.sang@pengutronix.de Wed Sep  9 23:24:41 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 09 Sep 2009 23:24:47 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:41273 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493470AbZIIVYE (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 9 Sep 2009 23:24:04 +0200
Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MlUdn-00008w-CC; Wed, 09 Sep 2009 23:23:51 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	linux-i2c@vger.kernel.org
Cc:	linuxppc-dev@ozlabs.org, linux-arm-kernel@lists.infradead.org,
	linux-mips@linux-mips.org, uclinux-dist-devel@blackfin.uclinux.org,
	Wolfram Sang <w.sang@pengutronix.de>,
	Bart Van Assche <bart.vanassche@gmail.com>,
	Jean Delvare <khali@linux-fr.org>
Date:	Wed,  9 Sep 2009 23:22:49 +0200
Message-Id: <1252531371-14866-3-git-send-email-w.sang@pengutronix.de>
X-Mailer: git-send-email 1.6.3.3
In-Reply-To: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
X-SA-Exim-Connect-IP: 92.198.50.58
X-SA-Exim-Mail-From: w.sang@pengutronix.de
Subject: [PATCH 2/4] i2c/chips: Remove deprecated pcf8575-driver
X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000)
X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de)
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 23999
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips

The pcf8575-driver in drivers/i2c/chips which just exports its register to
sysfs is superseeded by drivers/gpio/pcf857x.c which properly uses the gpiolib.
As this driver has been deprecated for more than a year, finally remove it.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Bart Van Assche <bart.vanassche@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
---
 Documentation/i2c/chips/pcf8575 |   69 --------------
 drivers/i2c/chips/Kconfig       |   18 ----
 drivers/i2c/chips/Makefile      |    1 -
 drivers/i2c/chips/pcf8575.c     |  198 ---------------------------------------
 4 files changed, 0 insertions(+), 286 deletions(-)
 delete mode 100644 Documentation/i2c/chips/pcf8575
 delete mode 100644 drivers/i2c/chips/pcf8575.c

diff --git a/Documentation/i2c/chips/pcf8575 b/Documentation/i2c/chips/pcf8575
deleted file mode 100644
index 40b268e..0000000
--- a/Documentation/i2c/chips/pcf8575
+++ /dev/null
@@ -1,69 +0,0 @@
-About the PCF8575 chip and the pcf8575 kernel driver
-====================================================
-
-The PCF8575 chip is produced by the following manufacturers:
-
-  * Philips NXP
-    http://www.nxp.com/#/pip/cb=[type=product,path=50807/41735/41850,final=PCF8575_3]|pip=[pip=PCF8575_3][0]
-
-  * Texas Instruments
-    http://focus.ti.com/docs/prod/folders/print/pcf8575.html
-
-
-Some vendors sell small PCB's with the PCF8575 mounted on it. You can connect
-such a board to a Linux host via e.g. an USB to I2C interface. Examples of
-PCB boards with a PCF8575:
-
-  * SFE Breakout Board for PCF8575 I2C Expander by RobotShop
-    http://www.robotshop.ca/home/products/robot-parts/electronics/adapters-converters/sfe-pcf8575-i2c-expander-board.html
-
-  * Breakout Board for PCF8575 I2C Expander by Spark Fun Electronics
-    http://www.sparkfun.com/commerce/product_info.php?products_id=8130
-
-
-Description
------------
-The PCF8575 chip is a 16-bit I/O expander for the I2C bus. Up to eight of
-these chips can be connected to the same I2C bus. You can find this
-chip on some custom designed hardware, but you won't find it on PC
-motherboards.
-
-The PCF8575 chip consists of a 16-bit quasi-bidirectional port and an I2C-bus
-interface. Each of the sixteen I/O's can be independently used as an input or
-an output. To set up an I/O pin as an input, you have to write a 1 to the
-corresponding output.
-
-For more information please see the datasheet.
-
-
-Detection
----------
-
-There is no method known to detect whether a chip on a given I2C address is
-a PCF8575 or whether it is any other I2C device, so you have to pass the I2C
-bus and address of the installed PCF8575 devices explicitly to the driver at
-load time via the force=... parameter.
-
-/sys interface
---------------
-
-For each address on which a PCF8575 chip was found or forced the following
-files will be created under /sys:
-* /sys/bus/i2c/devices/<bus>-<address>/read
-* /sys/bus/i2c/devices/<bus>-<address>/write
-where bus is the I2C bus number (0, 1, ...) and address is the four-digit
-hexadecimal representation of the 7-bit I2C address of the PCF8575
-(0020 .. 0027).
-
-The read file is read-only. Reading it will trigger an I2C read and will hence
-report the current input state for the pins configured as inputs, and the
-current output value for the pins configured as outputs.
-
-The write file is read-write. Writing a value to it will configure all pins
-as output for which the corresponding bit is zero. Reading the write file will
-return the value last written, or -EAGAIN if no value has yet been written to
-the write file.
-
-On module initialization the configuration of the chip is not changed -- the
-chip is left in the state it was already configured in through either power-up
-or through previous I2C write actions.
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 02d746c..1b5455e 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -33,24 +33,6 @@ config SENSORS_PCF8574
 	  These devices are hard to detect and rarely found on mainstream
 	  hardware.  If unsure, say N.
 
-config PCF8575
-	tristate "Philips PCF8575 (DEPRECATED)"
-	default n
-	depends on GPIO_PCF857X = "n"
-	help
-	  If you say yes here you get support for Philips PCF8575 chip.
-	  This chip is a 16-bit I/O expander for the I2C bus.  Several other
-	  chip manufacturers sell equivalent chips, e.g. Texas Instruments.
-
-	  This driver can also be built as a module.  If so, the module
-	  will be called pcf8575.
-
-	  This driver is deprecated and will be dropped soon. Use
-	  drivers/gpio/pcf857x.c instead.
-
-	  This device is hard to detect and is rarely found on mainstream
-	  hardware.  If unsure, say N.
-
 config SENSORS_PCA9539
 	tristate "Philips PCA9539 16-bit I/O port (DEPRECATED)"
 	depends on EXPERIMENTAL && GPIO_PCA953X = "n"
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index f4680d1..fceb377 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -13,7 +13,6 @@
 obj-$(CONFIG_DS1682)		+= ds1682.o
 obj-$(CONFIG_SENSORS_PCA9539)	+= pca9539.o
 obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
-obj-$(CONFIG_PCF8575)		+= pcf8575.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
diff --git a/drivers/i2c/chips/pcf8575.c b/drivers/i2c/chips/pcf8575.c
deleted file mode 100644
index 07fd7cb..0000000
--- a/drivers/i2c/chips/pcf8575.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
-  pcf8575.c
-
-  About the PCF8575 chip: the PCF8575 is a 16-bit I/O expander for the I2C bus
-  produced by a.o. Philips Semiconductors.
-
-  Copyright (C) 2006 Michael Hennerich, Analog Devices Inc.
-  <hennerich@blackfin.uclinux.org>
-  Based on pcf8574.c.
-
-  Copyright (c) 2007 Bart Van Assche <bart.vanassche@gmail.com>.
-  Ported this driver from ucLinux to the mainstream Linux kernel.
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/i2c.h>
-#include <linux/slab.h>  /* kzalloc() */
-#include <linux/sysfs.h> /* sysfs_create_group() */
-
-/* Addresses to scan: none, device can't be detected */
-static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Insmod parameters */
-I2C_CLIENT_INSMOD;
-
-
-/* Each client has this additional data */
-struct pcf8575_data {
-	int write;		/* last written value, or error code */
-};
-
-/* following are the sysfs callback functions */
-static ssize_t show_read(struct device *dev, struct device_attribute *attr,
-			 char *buf)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	u16 val;
-	u8 iopin_state[2];
-
-	i2c_master_recv(client, iopin_state, 2);
-
-	val = iopin_state[0];
-	val |= iopin_state[1] << 8;
-
-	return sprintf(buf, "%u\n", val);
-}
-
-static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
-
-static ssize_t show_write(struct device *dev, struct device_attribute *attr,
-			  char *buf)
-{
-	struct pcf8575_data *data = dev_get_drvdata(dev);
-	if (data->write < 0)
-		return data->write;
-	return sprintf(buf, "%d\n", data->write);
-}
-
-static ssize_t set_write(struct device *dev, struct device_attribute *attr,
-			 const char *buf, size_t count)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct pcf8575_data *data = i2c_get_clientdata(client);
-	unsigned long val = simple_strtoul(buf, NULL, 10);
-	u8 iopin_state[2];
-
-	if (val > 0xffff)
-		return -EINVAL;
-
-	data->write = val;
-
-	iopin_state[0] = val & 0xFF;
-	iopin_state[1] = val >> 8;
-
-	i2c_master_send(client, iopin_state, 2);
-
-	return count;
-}
-
-static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write);
-
-static struct attribute *pcf8575_attributes[] = {
-	&dev_attr_read.attr,
-	&dev_attr_write.attr,
-	NULL
-};
-
-static const struct attribute_group pcf8575_attr_group = {
-	.attrs = pcf8575_attributes,
-};
-
-/*
- * Real code
- */
-
-/* Return 0 if detection is successful, -ENODEV otherwise */
-static int pcf8575_detect(struct i2c_client *client, int kind,
-			  struct i2c_board_info *info)
-{
-	struct i2c_adapter *adapter = client->adapter;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
-		return -ENODEV;
-
-	/* This is the place to detect whether the chip at the specified
-	   address really is a PCF8575 chip. However, there is no method known
-	   to detect whether an I2C chip is a PCF8575 or any other I2C chip. */
-
-	strlcpy(info->type, "pcf8575", I2C_NAME_SIZE);
-
-	return 0;
-}
-
-static int pcf8575_probe(struct i2c_client *client,
-			 const struct i2c_device_id *id)
-{
-	struct pcf8575_data *data;
-	int err;
-
-	data = kzalloc(sizeof(struct pcf8575_data), GFP_KERNEL);
-	if (!data) {
-		err = -ENOMEM;
-		goto exit;
-	}
-
-	i2c_set_clientdata(client, data);
-	data->write = -EAGAIN;
-
-	/* Register sysfs hooks */
-	err = sysfs_create_group(&client->dev.kobj, &pcf8575_attr_group);
-	if (err)
-		goto exit_free;
-
-	return 0;
-
-exit_free:
-	kfree(data);
-exit:
-	return err;
-}
-
-static int pcf8575_remove(struct i2c_client *client)
-{
-	sysfs_remove_group(&client->dev.kobj, &pcf8575_attr_group);
-	kfree(i2c_get_clientdata(client));
-	return 0;
-}
-
-static const struct i2c_device_id pcf8575_id[] = {
-	{ "pcf8575", 0 },
-	{ }
-};
-
-static struct i2c_driver pcf8575_driver = {
-	.driver = {
-		.owner	= THIS_MODULE,
-		.name	= "pcf8575",
-	},
-	.probe		= pcf8575_probe,
-	.remove		= pcf8575_remove,
-	.id_table	= pcf8575_id,
-
-	.detect		= pcf8575_detect,
-	.address_data	= &addr_data,
-};
-
-static int __init pcf8575_init(void)
-{
-	return i2c_add_driver(&pcf8575_driver);
-}
-
-static void __exit pcf8575_exit(void)
-{
-	i2c_del_driver(&pcf8575_driver);
-}
-
-MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>, "
-	      "Bart Van Assche <bart.vanassche@gmail.com>");
-MODULE_DESCRIPTION("pcf8575 driver");
-MODULE_LICENSE("GPL");
-
-module_init(pcf8575_init);
-module_exit(pcf8575_exit);
-- 
1.6.3.3


From w.sang@pengutronix.de Wed Sep  9 23:25:05 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 09 Sep 2009 23:25:11 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:41293 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493471AbZIIVYK (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 9 Sep 2009 23:24:10 +0200
Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MlUds-00009L-Gw; Wed, 09 Sep 2009 23:23:58 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	linux-i2c@vger.kernel.org
Cc:	linuxppc-dev@ozlabs.org, linux-arm-kernel@lists.infradead.org,
	linux-mips@linux-mips.org, uclinux-dist-devel@blackfin.uclinux.org,
	Wolfram Sang <w.sang@pengutronix.de>,
	Ben Gardner <gardner.ben@gmail.com>,
	Jean Delvare <khali@linux-fr.org>
Date:	Wed,  9 Sep 2009 23:22:50 +0200
Message-Id: <1252531371-14866-4-git-send-email-w.sang@pengutronix.de>
X-Mailer: git-send-email 1.6.3.3
In-Reply-To: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
X-SA-Exim-Connect-IP: 92.198.50.58
X-SA-Exim-Mail-From: w.sang@pengutronix.de
Subject: [PATCH 3/4] i2c/chips: Remove deprecated pca9539-driver
X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000)
X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de)
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24000
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips

The pca9539-driver in drivers/i2c/chips which just exports its registers to
sysfs is superseeded by drivers/gpio/pca953x.c which properly uses the gpiolib.
As this driver has been deprecated for more than a year, finally remove it.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Ben Gardner <gardner.ben@gmail.com>
Cc: Jean Delvare <khali@linux-fr.org>
---
 Documentation/i2c/chips/pca9539 |   58 ---------------
 drivers/i2c/chips/Kconfig       |   13 ----
 drivers/i2c/chips/Makefile      |    1 -
 drivers/i2c/chips/pca9539.c     |  152 ---------------------------------------
 4 files changed, 0 insertions(+), 224 deletions(-)
 delete mode 100644 Documentation/i2c/chips/pca9539
 delete mode 100644 drivers/i2c/chips/pca9539.c

diff --git a/Documentation/i2c/chips/pca9539 b/Documentation/i2c/chips/pca9539
deleted file mode 100644
index 6aff890..0000000
--- a/Documentation/i2c/chips/pca9539
+++ /dev/null
@@ -1,58 +0,0 @@
-Kernel driver pca9539
-=====================
-
-NOTE: this driver is deprecated and will be dropped soon, use
-drivers/gpio/pca9539.c instead.
-
-Supported chips:
-  * Philips PCA9539
-    Prefix: 'pca9539'
-    Addresses scanned: none
-    Datasheet:
-        http://www.semiconductors.philips.com/acrobat/datasheets/PCA9539_2.pdf
-
-Author: Ben Gardner <bgardner@wabtec.com>
-
-
-Description
------------
-
-The Philips PCA9539 is a 16 bit low power I/O device.
-All 16 lines can be individually configured as an input or output.
-The input sense can also be inverted.
-The 16 lines are split between two bytes.
-
-
-Detection
----------
-
-The PCA9539 is difficult to detect and not commonly found in PC machines,
-so you have to pass the I2C bus and address of the installed PCA9539
-devices explicitly to the driver at load time via the force=... parameter.
-
-
-Sysfs entries
--------------
-
-Each is a byte that maps to the 8 I/O bits.
-A '0' suffix is for bits 0-7, while '1' is for bits 8-15.
-
-input[01]     - read the current value
-output[01]    - sets the output value
-direction[01] - direction of each bit: 1=input, 0=output
-invert[01]    - toggle the input bit sense
-
-input reads the actual state of the line and is always available.
-The direction defaults to input for all channels.
-
-
-General Remarks
----------------
-
-Note that each output, direction, and invert entry controls 8 lines.
-You should use the read, modify, write sequence.
-For example. to set output bit 0 of 1.
-  val=$(cat output0)
-  val=$(( $val | 1 ))
-  echo $val > output0
-
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 1b5455e..8cd1a7f 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -33,19 +33,6 @@ config SENSORS_PCF8574
 	  These devices are hard to detect and rarely found on mainstream
 	  hardware.  If unsure, say N.
 
-config SENSORS_PCA9539
-	tristate "Philips PCA9539 16-bit I/O port (DEPRECATED)"
-	depends on EXPERIMENTAL && GPIO_PCA953X = "n"
-	help
-	  If you say yes here you get support for the Philips PCA9539
-	  16-bit I/O port.
-
-	  This driver can also be built as a module.  If so, the module
-	  will be called pca9539.
-
-	  This driver is deprecated and will be dropped soon. Use
-	  drivers/gpio/pca953x.c instead.
-
 config SENSORS_TSL2550
 	tristate "Taos TSL2550 ambient light sensor"
 	depends on EXPERIMENTAL
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index fceb377..8cd778d 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -11,7 +11,6 @@
 #
 
 obj-$(CONFIG_DS1682)		+= ds1682.o
-obj-$(CONFIG_SENSORS_PCA9539)	+= pca9539.o
 obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
deleted file mode 100644
index 270de4e..0000000
--- a/drivers/i2c/chips/pca9539.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
-    pca9539.c - 16-bit I/O port with interrupt and reset
-
-    Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; version 2 of the License.
-*/
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-#include <linux/hwmon-sysfs.h>
-
-/* Addresses to scan: none, device is not autodetected */
-static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_1(pca9539);
-
-enum pca9539_cmd
-{
-	PCA9539_INPUT_0		= 0,
-	PCA9539_INPUT_1		= 1,
-	PCA9539_OUTPUT_0	= 2,
-	PCA9539_OUTPUT_1	= 3,
-	PCA9539_INVERT_0	= 4,
-	PCA9539_INVERT_1	= 5,
-	PCA9539_DIRECTION_0	= 6,
-	PCA9539_DIRECTION_1	= 7,
-};
-
-/* following are the sysfs callback functions */
-static ssize_t pca9539_show(struct device *dev, struct device_attribute *attr,
-			    char *buf)
-{
-	struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
-	struct i2c_client *client = to_i2c_client(dev);
-	return sprintf(buf, "%d\n", i2c_smbus_read_byte_data(client,
-							     psa->index));
-}
-
-static ssize_t pca9539_store(struct device *dev, struct device_attribute *attr,
-			     const char *buf, size_t count)
-{
-	struct sensor_device_attribute *psa = to_sensor_dev_attr(attr);
-	struct i2c_client *client = to_i2c_client(dev);
-	unsigned long val = simple_strtoul(buf, NULL, 0);
-	if (val > 0xff)
-		return -EINVAL;
-	i2c_smbus_write_byte_data(client, psa->index, val);
-	return count;
-}
-
-/* Define the device attributes */
-
-#define PCA9539_ENTRY_RO(name, cmd_idx) \
-	static SENSOR_DEVICE_ATTR(name, S_IRUGO, pca9539_show, NULL, cmd_idx)
-
-#define PCA9539_ENTRY_RW(name, cmd_idx) \
-	static SENSOR_DEVICE_ATTR(name, S_IRUGO | S_IWUSR, pca9539_show, \
-				  pca9539_store, cmd_idx)
-
-PCA9539_ENTRY_RO(input0, PCA9539_INPUT_0);
-PCA9539_ENTRY_RO(input1, PCA9539_INPUT_1);
-PCA9539_ENTRY_RW(output0, PCA9539_OUTPUT_0);
-PCA9539_ENTRY_RW(output1, PCA9539_OUTPUT_1);
-PCA9539_ENTRY_RW(invert0, PCA9539_INVERT_0);
-PCA9539_ENTRY_RW(invert1, PCA9539_INVERT_1);
-PCA9539_ENTRY_RW(direction0, PCA9539_DIRECTION_0);
-PCA9539_ENTRY_RW(direction1, PCA9539_DIRECTION_1);
-
-static struct attribute *pca9539_attributes[] = {
-	&sensor_dev_attr_input0.dev_attr.attr,
-	&sensor_dev_attr_input1.dev_attr.attr,
-	&sensor_dev_attr_output0.dev_attr.attr,
-	&sensor_dev_attr_output1.dev_attr.attr,
-	&sensor_dev_attr_invert0.dev_attr.attr,
-	&sensor_dev_attr_invert1.dev_attr.attr,
-	&sensor_dev_attr_direction0.dev_attr.attr,
-	&sensor_dev_attr_direction1.dev_attr.attr,
-	NULL
-};
-
-static struct attribute_group pca9539_defattr_group = {
-	.attrs = pca9539_attributes,
-};
-
-/* Return 0 if detection is successful, -ENODEV otherwise */
-static int pca9539_detect(struct i2c_client *client, int kind,
-			  struct i2c_board_info *info)
-{
-	struct i2c_adapter *adapter = client->adapter;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
-		return -ENODEV;
-
-	strlcpy(info->type, "pca9539", I2C_NAME_SIZE);
-
-	return 0;
-}
-
-static int pca9539_probe(struct i2c_client *client,
-			 const struct i2c_device_id *id)
-{
-	/* Register sysfs hooks */
-	return sysfs_create_group(&client->dev.kobj,
-				  &pca9539_defattr_group);
-}
-
-static int pca9539_remove(struct i2c_client *client)
-{
-	sysfs_remove_group(&client->dev.kobj, &pca9539_defattr_group);
-	return 0;
-}
-
-static const struct i2c_device_id pca9539_id[] = {
-	{ "pca9539", 0 },
-	{ }
-};
-
-static struct i2c_driver pca9539_driver = {
-	.driver = {
-		.name	= "pca9539",
-	},
-	.probe		= pca9539_probe,
-	.remove		= pca9539_remove,
-	.id_table	= pca9539_id,
-
-	.detect		= pca9539_detect,
-	.address_data	= &addr_data,
-};
-
-static int __init pca9539_init(void)
-{
-	return i2c_add_driver(&pca9539_driver);
-}
-
-static void __exit pca9539_exit(void)
-{
-	i2c_del_driver(&pca9539_driver);
-}
-
-MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
-MODULE_DESCRIPTION("PCA9539 driver");
-MODULE_LICENSE("GPL");
-
-module_init(pca9539_init);
-module_exit(pca9539_exit);
-
-- 
1.6.3.3


From w.sang@pengutronix.de Wed Sep  9 23:25:29 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 09 Sep 2009 23:25:36 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:41307 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493472AbZIIVYO (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 9 Sep 2009 23:24:14 +0200
Received: from themisto.ext.pengutronix.de ([92.198.50.58] helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MlUdz-00009p-RC; Wed, 09 Sep 2009 23:24:03 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	linux-i2c@vger.kernel.org
Cc:	linuxppc-dev@ozlabs.org, linux-arm-kernel@lists.infradead.org,
	linux-mips@linux-mips.org, uclinux-dist-devel@blackfin.uclinux.org,
	Wolfram Sang <w.sang@pengutronix.de>,
	Aurelien Jarno <aurelien@aurel32.net>,
	Jean Delvare <khali@linux-fr.org>
Date:	Wed,  9 Sep 2009 23:22:51 +0200
Message-Id: <1252531371-14866-5-git-send-email-w.sang@pengutronix.de>
X-Mailer: git-send-email 1.6.3.3
In-Reply-To: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
X-SA-Exim-Connect-IP: 92.198.50.58
X-SA-Exim-Mail-From: w.sang@pengutronix.de
Subject: [PATCH 4/4] i2c/chips: Remove deprecated pcf8574-driver
X-SA-Exim-Version: 4.2.1 (built Tue, 09 Jan 2007 17:23:22 +0000)
X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de)
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24001
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips

The pcf8574-driver in drivers/i2c/chips which just exports its register to
sysfs is superseeded by drivers/gpio/pcf857x.c which properly uses the gpiolib.
As this driver has been deprecated for more than a year, finally remove it.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Jean Delvare <khali@linux-fr.org>
---
 Documentation/i2c/chips/pcf8574 |   65 ------------
 drivers/i2c/chips/Kconfig       |   17 ---
 drivers/i2c/chips/Makefile      |    1 -
 drivers/i2c/chips/pcf8574.c     |  215 ---------------------------------------
 4 files changed, 0 insertions(+), 298 deletions(-)
 delete mode 100644 Documentation/i2c/chips/pcf8574
 delete mode 100644 drivers/i2c/chips/pcf8574.c

diff --git a/Documentation/i2c/chips/pcf8574 b/Documentation/i2c/chips/pcf8574
deleted file mode 100644
index 235815c..0000000
--- a/Documentation/i2c/chips/pcf8574
+++ /dev/null
@@ -1,65 +0,0 @@
-Kernel driver pcf8574
-=====================
-
-Supported chips:
-  * Philips PCF8574
-    Prefix: 'pcf8574'
-    Addresses scanned: none
-    Datasheet: Publicly available at the Philips Semiconductors website
-               http://www.semiconductors.philips.com/pip/PCF8574P.html
-
- * Philips PCF8574A
-    Prefix: 'pcf8574a'
-    Addresses scanned: none
-    Datasheet: Publicly available at the Philips Semiconductors website
-               http://www.semiconductors.philips.com/pip/PCF8574P.html
-
-Authors:
-        Frodo Looijaard <frodol@dds.nl>,
-        Philip Edelbrock <phil@netroedge.com>,
-        Dan Eaton <dan.eaton@rocketlogix.com>,
-        Aurelien Jarno <aurelien@aurel32.net>,
-        Jean Delvare <khali@linux-fr.org>,
-
-
-Description
------------
-The PCF8574(A) is an 8-bit I/O expander for the I2C bus produced by Philips
-Semiconductors. It is designed to provide a byte I2C interface to up to 16
-separate devices (8 x PCF8574 and 8 x PCF8574A).
-
-This device consists of a quasi-bidirectional port. Each of the eight I/Os
-can be independently used as an input or output. To setup an I/O as an
-input, you have to write a 1 to the corresponding output.
-
-For more informations see the datasheet.
-
-
-Accessing PCF8574(A) via /sys interface
--------------------------------------
-
-The PCF8574(A) is plainly impossible to detect ! Stupid chip.
-So, you have to pass the I2C bus and address of the installed PCF857A
-and PCF8574A devices explicitly to the driver at load time via the
-force=... parameter.
-
-On detection (i.e. insmod, modprobe et al.), directories are being
-created for each detected PCF8574(A):
-
-/sys/bus/i2c/devices/<0>-<1>/
-where <0> is the bus the chip was detected on (e. g. i2c-0)
-and <1> the chip address ([20..27] or [38..3f]):
-
-(example: /sys/bus/i2c/devices/1-0020/)
-
-Inside these directories, there are two files each:
-read and write (and one file with chip name).
-
-The read file is read-only. Reading gives you the current I/O input
-if the corresponding output is set as 1, otherwise the current output
-value, that is to say 0.
-
-The write file is read/write. Writing a value outputs it on the I/O
-port. Reading returns the last written value. As it is not possible
-to read this value from the chip, you need to write at least once to
-this file before you can read back from it.
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 8cd1a7f..f9618f4 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -16,23 +16,6 @@ config DS1682
 	  This driver can also be built as a module.  If so, the module
 	  will be called ds1682.
 
-config SENSORS_PCF8574
-	tristate "Philips PCF8574 and PCF8574A (DEPRECATED)"
-	depends on EXPERIMENTAL && GPIO_PCF857X = "n"
-	default n
-	help
-	  If you say yes here you get support for Philips PCF8574 and 
-	  PCF8574A chips. These chips are 8-bit I/O expanders for the I2C bus.
-
-	  This driver can also be built as a module.  If so, the module
-	  will be called pcf8574.
-
-	  This driver is deprecated and will be dropped soon. Use
-	  drivers/gpio/pcf857x.c instead.
-
-	  These devices are hard to detect and rarely found on mainstream
-	  hardware.  If unsure, say N.
-
 config SENSORS_TSL2550
 	tristate "Taos TSL2550 ambient light sensor"
 	depends on EXPERIMENTAL
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 8cd778d..749cf36 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -11,7 +11,6 @@
 #
 
 obj-$(CONFIG_DS1682)		+= ds1682.o
-obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
 obj-$(CONFIG_SENSORS_TSL2550)	+= tsl2550.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
deleted file mode 100644
index 6ec3098..0000000
--- a/drivers/i2c/chips/pcf8574.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
-    Copyright (c) 2000  Frodo Looijaard <frodol@dds.nl>, 
-                        Philip Edelbrock <phil@netroedge.com>,
-                        Dan Eaton <dan.eaton@rocketlogix.com>
-    Ported to Linux 2.6 by Aurelien Jarno <aurel32@debian.org> with 
-    the help of Jean Delvare <khali@linux-fr.org>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-    
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-/* A few notes about the PCF8574:
-
-* The PCF8574 is an 8-bit I/O expander for the I2C bus produced by
-  Philips Semiconductors.  It is designed to provide a byte I2C
-  interface to up to 8 separate devices.
-  
-* The PCF8574 appears as a very simple SMBus device which can be
-  read from or written to with SMBUS byte read/write accesses.
-
-  --Dan
-
-*/
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-
-/* Addresses to scan: none, device can't be detected */
-static const unsigned short normal_i2c[] = { I2C_CLIENT_END };
-
-/* Insmod parameters */
-I2C_CLIENT_INSMOD_2(pcf8574, pcf8574a);
-
-/* Each client has this additional data */
-struct pcf8574_data {
-	int write;			/* Remember last written value */
-};
-
-static void pcf8574_init_client(struct i2c_client *client);
-
-/* following are the sysfs callback functions */
-static ssize_t show_read(struct device *dev, struct device_attribute *attr, char *buf)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	return sprintf(buf, "%u\n", i2c_smbus_read_byte(client));
-}
-
-static DEVICE_ATTR(read, S_IRUGO, show_read, NULL);
-
-static ssize_t show_write(struct device *dev, struct device_attribute *attr, char *buf)
-{
-	struct pcf8574_data *data = i2c_get_clientdata(to_i2c_client(dev));
-
-	if (data->write < 0)
-		return data->write;
-
-	return sprintf(buf, "%d\n", data->write);
-}
-
-static ssize_t set_write(struct device *dev, struct device_attribute *attr, const char *buf,
-			 size_t count)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct pcf8574_data *data = i2c_get_clientdata(client);
-	unsigned long val = simple_strtoul(buf, NULL, 10);
-
-	if (val > 0xff)
-		return -EINVAL;
-
-	data->write = val;
-	i2c_smbus_write_byte(client, data->write);
-	return count;
-}
-
-static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write);
-
-static struct attribute *pcf8574_attributes[] = {
-	&dev_attr_read.attr,
-	&dev_attr_write.attr,
-	NULL
-};
-
-static const struct attribute_group pcf8574_attr_group = {
-	.attrs = pcf8574_attributes,
-};
-
-/*
- * Real code
- */
-
-/* Return 0 if detection is successful, -ENODEV otherwise */
-static int pcf8574_detect(struct i2c_client *client, int kind,
-			  struct i2c_board_info *info)
-{
-	struct i2c_adapter *adapter = client->adapter;
-	const char *client_name;
-
-	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
-		return -ENODEV;
-
-	/* Now, we would do the remaining detection. But the PCF8574 is plainly
-	   impossible to detect! Stupid chip. */
-
-	/* Determine the chip type */
-	if (kind <= 0) {
-		if (client->addr >= 0x38 && client->addr <= 0x3f)
-			kind = pcf8574a;
-		else
-			kind = pcf8574;
-	}
-
-	if (kind == pcf8574a)
-		client_name = "pcf8574a";
-	else
-		client_name = "pcf8574";
-	strlcpy(info->type, client_name, I2C_NAME_SIZE);
-
-	return 0;
-}
-
-static int pcf8574_probe(struct i2c_client *client,
-			 const struct i2c_device_id *id)
-{
-	struct pcf8574_data *data;
-	int err;
-
-	data = kzalloc(sizeof(struct pcf8574_data), GFP_KERNEL);
-	if (!data) {
-		err = -ENOMEM;
-		goto exit;
-	}
-
-	i2c_set_clientdata(client, data);
-
-	/* Initialize the PCF8574 chip */
-	pcf8574_init_client(client);
-
-	/* Register sysfs hooks */
-	err = sysfs_create_group(&client->dev.kobj, &pcf8574_attr_group);
-	if (err)
-		goto exit_free;
-	return 0;
-
-      exit_free:
-	kfree(data);
-      exit:
-	return err;
-}
-
-static int pcf8574_remove(struct i2c_client *client)
-{
-	sysfs_remove_group(&client->dev.kobj, &pcf8574_attr_group);
-	kfree(i2c_get_clientdata(client));
-	return 0;
-}
-
-/* Called when we have found a new PCF8574. */
-static void pcf8574_init_client(struct i2c_client *client)
-{
-	struct pcf8574_data *data = i2c_get_clientdata(client);
-	data->write = -EAGAIN;
-}
-
-static const struct i2c_device_id pcf8574_id[] = {
-	{ "pcf8574", 0 },
-	{ "pcf8574a", 0 },
-	{ }
-};
-
-static struct i2c_driver pcf8574_driver = {
-	.driver = {
-		.name	= "pcf8574",
-	},
-	.probe		= pcf8574_probe,
-	.remove		= pcf8574_remove,
-	.id_table	= pcf8574_id,
-
-	.detect		= pcf8574_detect,
-	.address_data	= &addr_data,
-};
-
-static int __init pcf8574_init(void)
-{
-	return i2c_add_driver(&pcf8574_driver);
-}
-
-static void __exit pcf8574_exit(void)
-{
-	i2c_del_driver(&pcf8574_driver);
-}
-
-
-MODULE_AUTHOR
-    ("Frodo Looijaard <frodol@dds.nl>, "
-     "Philip Edelbrock <phil@netroedge.com>, "
-     "Dan Eaton <dan.eaton@rocketlogix.com> "
-     "and Aurelien Jarno <aurelien@aurel32.net>");
-MODULE_DESCRIPTION("PCF8574 driver");
-MODULE_LICENSE("GPL");
-
-module_init(pcf8574_init);
-module_exit(pcf8574_exit);
-- 
1.6.3.3


From David.Daney@caviumnetworks.com Thu Sep 10 00:36:56 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 00:37:03 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:3016 "EHLO smtp3"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1493122AbZIIWg4 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 10 Sep 2009 00:36:56 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by smtp3 with MailMarshal (v6,5,4,7535)
	id <B4aa82df70000>; Wed, 09 Sep 2009 15:36:39 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 9 Sep 2009 15:36:35 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 9 Sep 2009 15:36:35 -0700
Message-ID: <4AA82DF3.5070805@caviumnetworks.com>
Date:	Wed, 09 Sep 2009 15:36:35 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Wu Fei <at.wufei@gmail.com>, Ralf Baechle <ralf@linux-mips.org>
CC:	linux-mips@linux-mips.org
Subject: Re: [PATCH] Shrink the size of tlb handler
References: <20090903142753.GA6482@desktop> <20090903142953.GB6482@desktop>
In-Reply-To: <20090903142953.GB6482@desktop>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 09 Sep 2009 22:36:35.0616 (UTC) FILETIME=[FCE7DA00:01CA319D]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24002
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Wu Fei wrote:
> By combining swapper_pg_dir and module_pg_dir, several if conditions
> can be eliminated from the tlb exception handler. The reason they
> can be combined is that, the effective virtual address of vmalloc
> returned is at the bottom, and of module_alloc returned is at the
> top. It also fixes the bug in vmalloc(), which happens when its
> return address is not covered by the first pgd.
> 
> Signed-off-by: Wu Fei <at.wufei@gmail.com>


I like this patch.  I ported it to my 2.6.27 kernel and it seems to work 
well.

One thing you are missing is that that label_module_alloc should now no 
longer be needed in tlbex.c  It should be removed.

David Daney


> ---
>  arch/mips/include/asm/pgtable-64.h |   11 ++------
>  arch/mips/mm/init.c                |    3 --
>  arch/mips/mm/pgtable-64.c          |    3 --
>  arch/mips/mm/tlbex.c               |   49 ------------------------------------
>  4 files changed, 3 insertions(+), 63 deletions(-)
> 
> diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
> index 4ed9d1b..9cd5089 100644
> --- a/arch/mips/include/asm/pgtable-64.h
> +++ b/arch/mips/include/asm/pgtable-64.h
> @@ -109,13 +109,13 @@
>  
>  #define VMALLOC_START		MAP_BASE
>  #define VMALLOC_END	\
> -	(VMALLOC_START + PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE)
> +	(VMALLOC_START + \
> +	 PTRS_PER_PGD * PTRS_PER_PMD * PTRS_PER_PTE * PAGE_SIZE - (1UL << 32))
>  #if defined(CONFIG_MODULES) && defined(KBUILD_64BIT_SYM32) && \
>  	VMALLOC_START != CKSSEG
>  /* Load modules into 32bit-compatible segment. */
>  #define MODULE_START	CKSSEG
>  #define MODULE_END	(FIXADDR_START-2*PAGE_SIZE)
> -extern pgd_t module_pg_dir[PTRS_PER_PGD];
>  #endif
>  
>  #define pte_ERROR(e) \
> @@ -188,12 +188,7 @@ static inline void pud_clear(pud_t *pudp)
>  #define __pmd_offset(address)	pmd_index(address)
>  
>  /* to find an entry in a kernel page-table-directory */
> -#ifdef MODULE_START
> -#define pgd_offset_k(address) \
> -	((address) >= MODULE_START ? module_pg_dir : pgd_offset(&init_mm, 0UL))
> -#else
> -#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL)
> -#endif
> +#define pgd_offset_k(address) pgd_offset(&init_mm, address)
>  
>  #define pgd_index(address)	(((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
>  #define pmd_index(address)	(((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
> diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
> index 0e82050..38c79c5 100644
> --- a/arch/mips/mm/init.c
> +++ b/arch/mips/mm/init.c
> @@ -475,9 +475,6 @@ unsigned long pgd_current[NR_CPUS];
>   */
>  pgd_t swapper_pg_dir[_PTRS_PER_PGD] __page_aligned(_PGD_ORDER);
>  #ifdef CONFIG_64BIT
> -#ifdef MODULE_START
> -pgd_t module_pg_dir[PTRS_PER_PGD] __page_aligned(PGD_ORDER);
> -#endif
>  pmd_t invalid_pmd_table[PTRS_PER_PMD] __page_aligned(PMD_ORDER);
>  #endif
>  pte_t invalid_pte_table[PTRS_PER_PTE] __page_aligned(PTE_ORDER);
> diff --git a/arch/mips/mm/pgtable-64.c b/arch/mips/mm/pgtable-64.c
> index e4b565a..1121019 100644
> --- a/arch/mips/mm/pgtable-64.c
> +++ b/arch/mips/mm/pgtable-64.c
> @@ -59,9 +59,6 @@ void __init pagetable_init(void)
>  
>  	/* Initialize the entire pgd.  */
>  	pgd_init((unsigned long)swapper_pg_dir);
> -#ifdef MODULE_START
> -	pgd_init((unsigned long)module_pg_dir);
> -#endif
>  	pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
>  
>  	pgd_base = swapper_pg_dir;
> diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
> index 9a17bf8..bc66f57 100644
> --- a/arch/mips/mm/tlbex.c
> +++ b/arch/mips/mm/tlbex.c
> @@ -499,11 +499,7 @@ build_get_pmde64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
>  	 * The vmalloc handling is not in the hotpath.
>  	 */
>  	uasm_i_dmfc0(p, tmp, C0_BADVADDR);
> -#ifdef MODULE_START
> -	uasm_il_bltz(p, r, tmp, label_module_alloc);
> -#else
>  	uasm_il_bltz(p, r, tmp, label_vmalloc);
> -#endif
>  	/* No uasm_i_nop needed here, since the next insn doesn't touch TMP. */
>  
>  #ifdef CONFIG_SMP
> @@ -556,52 +552,7 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, struct uasm_reloc **r,
>  {
>  	long swpd = (long)swapper_pg_dir;
>  
> -#ifdef MODULE_START
> -	long modd = (long)module_pg_dir;
> -
> -	uasm_l_module_alloc(l, *p);
> -	/*
> -	 * Assumption:
> -	 * VMALLOC_START >= 0xc000000000000000UL
> -	 * MODULE_START >= 0xe000000000000000UL
> -	 */
> -	UASM_i_SLL(p, ptr, bvaddr, 2);
> -	uasm_il_bgez(p, r, ptr, label_vmalloc);
> -
> -	if (uasm_in_compat_space_p(MODULE_START) &&
> -	    !uasm_rel_lo(MODULE_START)) {
> -		uasm_i_lui(p, ptr, uasm_rel_hi(MODULE_START)); /* delay slot */
> -	} else {
> -		/* unlikely configuration */
> -		uasm_i_nop(p); /* delay slot */
> -		UASM_i_LA(p, ptr, MODULE_START);
> -	}
> -	uasm_i_dsubu(p, bvaddr, bvaddr, ptr);
> -
> -	if (uasm_in_compat_space_p(modd) && !uasm_rel_lo(modd)) {
> -		uasm_il_b(p, r, label_vmalloc_done);
> -		uasm_i_lui(p, ptr, uasm_rel_hi(modd));
> -	} else {
> -		UASM_i_LA_mostly(p, ptr, modd);
> -		uasm_il_b(p, r, label_vmalloc_done);
> -		if (uasm_in_compat_space_p(modd))
> -			uasm_i_addiu(p, ptr, ptr, uasm_rel_lo(modd));
> -		else
> -			uasm_i_daddiu(p, ptr, ptr, uasm_rel_lo(modd));
> -	}
> -
>  	uasm_l_vmalloc(l, *p);
> -	if (uasm_in_compat_space_p(MODULE_START) &&
> -	    !uasm_rel_lo(MODULE_START) &&
> -	    MODULE_START << 32 == VMALLOC_START)
> -		uasm_i_dsll32(p, ptr, ptr, 0);	/* typical case */
> -	else
> -		UASM_i_LA(p, ptr, VMALLOC_START);
> -#else
> -	uasm_l_vmalloc(l, *p);
> -	UASM_i_LA(p, ptr, VMALLOC_START);
> -#endif
> -	uasm_i_dsubu(p, bvaddr, bvaddr, ptr);
>  
>  	if (uasm_in_compat_space_p(swpd) && !uasm_rel_lo(swpd)) {
>  		uasm_il_b(p, r, label_vmalloc_done);


From gardner.ben@gmail.com Thu Sep 10 01:28:48 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 01:28:55 +0200 (CEST)
Received: from mail-ew0-f225.google.com ([209.85.219.225]:38841 "EHLO
	mail-ew0-f225.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493189AbZIIX2s (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 01:28:48 +0200
Received: by ewy25 with SMTP id 25so4363071ewy.33
        for <linux-mips@linux-mips.org>; Wed, 09 Sep 2009 16:28:42 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type;
        bh=K4JpS9mGrP+JUUt40SmWWJaX27kt0wRummwlgmrXSEQ=;
        b=ave5Fe7ddls7c80i54qCZPhTxFIEJa10TO6dMkb308a9CbK+z7oDXw7Fql9kGXSjJQ
         KUL2bGQXXdlkf8v8oreYsz8pA5C42FfNOBC9Lz8NsyeHqL+RfZS1q1akixU/fUM27Di0
         8z3F95Ni+oyvhaNtLq2Qu+EOxK0pOlA61R2dg=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        b=i5907mrgCcjMl62aazUCkmAla/3pmElaU40W9R1DnDaA2c6oLj2PtoLLWIawqIHM3J
         1jpTTi08oc7NqLMEZerM0xCL5ddDknk+Xl0IhZT6aTuVgR0OxPy8CGbGVDuVUZLV0DEz
         odOKwMEd2TJf0LV3D36hfJh1H2eo4+oyb+lDQ=
MIME-Version: 1.0
Received: by 10.216.36.196 with SMTP id w46mr232293wea.76.1252538922053; Wed, 
	09 Sep 2009 16:28:42 -0700 (PDT)
In-Reply-To: <1252531371-14866-4-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
	 <1252531371-14866-4-git-send-email-w.sang@pengutronix.de>
Date:	Wed, 9 Sep 2009 18:28:42 -0500
Message-ID: <808c8e9d0909091628v3681c0cch50759d24393e570a@mail.gmail.com>
Subject: Re: [PATCH 3/4] i2c/chips: Remove deprecated pca9539-driver
From:	Ben Gardner <gardner.ben@gmail.com>
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	Jean Delvare <khali@linux-fr.org>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <gardner.ben@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24003
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: gardner.ben@gmail.com
Precedence: bulk
X-list: linux-mips

On Wed, Sep 9, 2009 at 4:22 PM, Wolfram Sang<w.sang@pengutronix.de> wrote:
> The pca9539-driver in drivers/i2c/chips which just exports its registers to
> sysfs is superseeded by drivers/gpio/pca953x.c which properly uses the gpiolib.
> As this driver has been deprecated for more than a year, finally remove it.
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Ben Gardner <gardner.ben@gmail.com>
> Cc: Jean Delvare <khali@linux-fr.org>

Acked-by: Ben Gardner <gardner.ben@gmail.com>

Thanks for taking care of this.
Ben

From vapier.adi@gmail.com Thu Sep 10 01:55:01 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 01:55:08 +0200 (CEST)
Received: from mail-yw0-f177.google.com ([209.85.211.177]:50216 "EHLO
	mail-yw0-f177.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493229AbZIIXzB (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 01:55:01 +0200
Received: by ywh7 with SMTP id 7so7092692ywh.21
        for <linux-mips@linux-mips.org>; Wed, 09 Sep 2009 16:54:55 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :from:date:message-id:subject:to:cc:content-type;
        bh=CV9xEng5q+g1urucTVU4sRWTnKldUp3SexzByDrVINA=;
        b=cLBCk0DEj8ENdxVlD2M61MLE9zMwnU3/iGbeX4FdWteI/97L/fd1ELS6aJV2x3nUm4
         qBmEOoxSPgilya6XSz9r/RBo678t6K7XTNZPWhyuImIrUpKGXtRCSxzW/oIKCZyPXf8X
         gMMYq7dJRzFU6w+ElpY8CD0DP4WzywvldPrZs=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc:content-type;
        b=XHg++irwmOeAqGZBRYojCqCa+uyzIbHTW3OxX2WwZ1YPHeSH8aG06CY/ZaijPdi9y2
         gLzkvUdS5Ed3vHGWoW3cLhAV3auF1Arbj5OrgZzPQlnoUl3KLIugDVHD6wNqBZmKkdZn
         BywA6TFfw8Gh08l2WWswMl9DKMX/amYPZ1z3w=
MIME-Version: 1.0
Received: by 10.150.239.15 with SMTP id m15mr1548890ybh.109.1252540495121; 
	Wed, 09 Sep 2009 16:54:55 -0700 (PDT)
In-Reply-To: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
From:	Mike Frysinger <vapier.adi@gmail.com>
Date:	Wed, 9 Sep 2009 19:54:34 -0400
Message-ID: <8bd0f97a0909091654h290180e5ob79178583aca143f@mail.gmail.com>
Subject: Re: [Uclinux-dist-devel] Removing deprecated drivers from 
	drivers/i2c/chips
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org
Content-Type: text/plain; charset=UTF-8
Return-Path: <vapier.adi@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24004
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: vapier.adi@gmail.com
Precedence: bulk
X-list: linux-mips

On Wed, Sep 9, 2009 at 17:22, Wolfram Sang wrote:
> continuing the quest to clean up and ultimately remove the drivers/i2c/chips
> directory, this patch series removes three drivers for GPIO-expanders which are
> obsoleted and marked as deprecated for more than a year. The newer (and better)
> drivers can be found in drivers/gpio.
>
> As it is ensured that the newer drivers cover the same i2c_device_ids, all
> platform_devices will still match. Some defconfig updates may be necessary
> though, but according to [1] this is left to the arch|platform-maintainers
> (also as most defconfigs are quite outdated). For that reason, I put the
> relevant arch-mailing-lists to Cc. Comments are welcome.

the Blackfin defconfigs refer to an input driver for the PCF8574, not
the I2C client driver
-mike

From wsa@pengutronix.de Thu Sep 10 08:26:31 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 08:26:38 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:42449 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492256AbZIJG0b (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 08:26:31 +0200
Received: from octopus.hi.pengutronix.de ([2001:6f8:1178:2:215:17ff:fe12:23b0])
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <wsa@pengutronix.de>)
	id 1Mld6i-0007NT-MG; Thu, 10 Sep 2009 08:26:12 +0200
Received: from wsa by octopus.hi.pengutronix.de with local (Exim 4.69)
	(envelope-from <wsa@pengutronix.de>)
	id 1Mld6f-0001aX-FW; Thu, 10 Sep 2009 08:26:09 +0200
Date:	Thu, 10 Sep 2009 08:26:09 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	Mike Frysinger <vapier.adi@gmail.com>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org
Subject: Re: [Uclinux-dist-devel] Removing deprecated drivers from
	drivers/i2c/chips
Message-ID: <20090910062609.GA26454@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de> <8bd0f97a0909091654h290180e5ob79178583aca143f@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="n8g4imXOkfNTN/H1"
Content-Disposition: inline
In-Reply-To: <8bd0f97a0909091654h290180e5ob79178583aca143f@mail.gmail.com>
User-Agent: Mutt/1.5.18 (2008-05-17)
X-SA-Exim-Connect-IP: 2001:6f8:1178:2:215:17ff:fe12:23b0
X-SA-Exim-Mail-From: wsa@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <wsa@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24005
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips


--n8g4imXOkfNTN/H1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

> the Blackfin defconfigs refer to an input driver for the PCF8574, not
> the I2C client driver

Yup, I am aware of that. With the exception of:

blackfin/configs/PNAV-10_defconfig:773:CONFIG_SENSORS_PCF8574=3Dm

Regards,

   Wolfram

--=20
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

--n8g4imXOkfNTN/H1
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqonAEACgkQD27XaX1/VRsuggCgvHIQBK0PDoMqr0mqllZhomK8
ym8An2/4gTJoai3W+CzOM659DgzCeQuK
=yoJc
-----END PGP SIGNATURE-----

--n8g4imXOkfNTN/H1--

From vapier.adi@gmail.com Thu Sep 10 09:56:03 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 09:56:10 +0200 (CEST)
Received: from mail-yw0-f177.google.com ([209.85.211.177]:36113 "EHLO
	mail-yw0-f177.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492355AbZIJH4D (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 09:56:03 +0200
Received: by ywh7 with SMTP id 7so7443847ywh.21
        for <linux-mips@linux-mips.org>; Thu, 10 Sep 2009 00:55:56 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :from:date:message-id:subject:to:cc:content-type;
        bh=Og2JRVvwtRisyohaZFGF/YuNxmaJs7dAXTImFJc7UMI=;
        b=AKgij8dFi6D1XKc3kP06SS6h+jGKFG7pnQKtJ6vlMmoE53J/fDIPspGawtGE2XBPuf
         RVHodoe+P6+dP4JpJYJ97iTtkr0p4kmWiqSO0+2l/uCuZAA8kU2moPGzA3j1+R01gCt8
         izf6RQNj7tPeE6AvDG8vExVSLY13xcCDMVdds=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :cc:content-type;
        b=L09ygWZf1DS+OMJRNc/Lo5GyP/s+jL/F8GHuAEX852RE81b7wVSeVCVBS7IT5T3o8q
         kQZKRKuDqi2qAZ/zY4k3GPbnjBsQuBiEH4pVMA4jNXN86niw97TmvGDRKiwvA1cpS77o
         Ptr5WRmkmLIixkeIIkr+eQyK0faUFZ2B/EsWo=
MIME-Version: 1.0
Received: by 10.150.164.4 with SMTP id m4mr2188920ybe.140.1252569356120; Thu, 
	10 Sep 2009 00:55:56 -0700 (PDT)
In-Reply-To: <20090910062609.GA26454@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de> 
	<8bd0f97a0909091654h290180e5ob79178583aca143f@mail.gmail.com> 
	<20090910062609.GA26454@pengutronix.de>
From:	Mike Frysinger <vapier.adi@gmail.com>
Date:	Thu, 10 Sep 2009 03:55:36 -0400
Message-ID: <8bd0f97a0909100055n3192deeka93dc853f0139bfc@mail.gmail.com>
Subject: Re: [Uclinux-dist-devel] Removing deprecated drivers from 
	drivers/i2c/chips
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org
Content-Type: text/plain; charset=UTF-8
Return-Path: <vapier.adi@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24006
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: vapier.adi@gmail.com
Precedence: bulk
X-list: linux-mips

On Thu, Sep 10, 2009 at 02:26, Wolfram Sang wrote:
>> the Blackfin defconfigs refer to an input driver for the PCF8574, not
>> the I2C client driver
>
> Yup, I am aware of that. With the exception of:
>
> blackfin/configs/PNAV-10_defconfig:773:CONFIG_SENSORS_PCF8574=m

thanks for double checking.  i'm not sure this board even has this
device.  i'll review the hardware.
-mike

From khali@linux-fr.org Thu Sep 10 12:49:40 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 12:49:47 +0200 (CEST)
Received: from bamako.nerim.net ([62.4.17.28]:58852 "EHLO bamako.nerim.net"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492244AbZIJKtk (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 10 Sep 2009 12:49:40 +0200
Received: from localhost (localhost [127.0.0.1])
	by bamako.nerim.net (Postfix) with ESMTP id E09B639DCB0;
	Thu, 10 Sep 2009 12:49:37 +0200 (CEST)
X-Virus-Scanned: amavisd-new at nerim.net
Received: from bamako.nerim.net ([127.0.0.1])
	by localhost (bamako.nerim.net [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 04+egjYJ86w8; Thu, 10 Sep 2009 12:49:36 +0200 (CEST)
Received: from hyperion.delvare (jdelvare.pck.nerim.net [62.212.121.182])
	by bamako.nerim.net (Postfix) with ESMTP id 96A1839DCA1;
	Thu, 10 Sep 2009 12:49:36 +0200 (CEST)
Date:	Thu, 10 Sep 2009 12:49:37 +0200
From:	Jean Delvare <khali@linux-fr.org>
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,
	uclinux-dist-devel@blackfin.uclinux.org
Subject: Re: Removing deprecated drivers from drivers/i2c/chips
Message-ID: <20090910124937.7b3df062@hyperion.delvare>
In-Reply-To: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
X-Mailer: Claws Mail 3.5.0 (GTK+ 2.14.4; i586-suse-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Return-Path: <khali@linux-fr.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24007
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: khali@linux-fr.org
Precedence: bulk
X-list: linux-mips

Hi Wolfram,

On Wed,  9 Sep 2009 23:22:47 +0200, Wolfram Sang wrote:
> continuing the quest to clean up and ultimately remove the drivers/i2c/chips
> directory, this patch series removes three drivers for GPIO-expanders which are
> obsoleted and marked as deprecated for more than a year. The newer (and better)
> drivers can be found in drivers/gpio.
> 
> As it is ensured that the newer drivers cover the same i2c_device_ids, all
> platform_devices will still match. Some defconfig updates may be necessary
> though, but according to [1] this is left to the arch|platform-maintainers
> (also as most defconfigs are quite outdated). For that reason, I put the
> relevant arch-mailing-lists to Cc. Comments are welcome.

Looks very good, I'll apply the 3 patches removing the legacy drivers.

Not sure about the patch to drivers/gpio/pcf857x.c, as there is no gpio
tree and no maintainer either AFAIK, I guess I shall pick it too?

Thanks,
-- 
Jean Delvare

From bart.vanassche@gmail.com Thu Sep 10 12:52:24 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 12:52:31 +0200 (CEST)
Received: from mail-ew0-f225.google.com ([209.85.219.225]:55162 "EHLO
	mail-ew0-f225.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S2097287AbZIJKwY convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 10 Sep 2009 12:52:24 +0200
Received: by ewy25 with SMTP id 25so4707068ewy.33
        for <linux-mips@linux-mips.org>; Thu, 10 Sep 2009 03:52:17 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type
         :content-transfer-encoding;
        bh=emeznUvZiGdhx1GHKHvOoEXLykryPQxOUIw8NC9+YAs=;
        b=S9GPxziooGQYM9NBnVnZDXm82BZ0+s5lTBStJTm8orD8O78I2GfkW4IOiEZlVyrkpj
         2TDeiOjUkwZ8PFHzImavYKLW4RpKe2IgerTfFxQtdxzs6lZ3ZWxUqY3yulKElephYkrV
         bx/Ly58qQLCjuoAqfPKqEKAA7gW/IE3kUxpuU=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type:content-transfer-encoding;
        b=ugbaooNQrck06s5hbDluf7cYh6uwVSEg8tvKBgsXQibE0RygMT4XNFEHUOIPZLhr5c
         F1tlQRS0roB2o/9hs7Z63h+HqGZnIfLwvDfkl1sT0JyyiVyHpKpGAjQIAbP8x83gCpKj
         yst0xf8GjES+3ukJeFGl4LsL/iE/cbbHFt+hg=
MIME-Version: 1.0
Received: by 10.210.101.1 with SMTP id y1mr743830ebb.60.1252579937789; Thu, 10 
	Sep 2009 03:52:17 -0700 (PDT)
In-Reply-To: <1252531371-14866-3-git-send-email-w.sang@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de>
	 <1252531371-14866-3-git-send-email-w.sang@pengutronix.de>
Date:	Thu, 10 Sep 2009 12:52:17 +0200
Message-ID: <e2e108260909100352l2a30438fj9f0297c1974c0192@mail.gmail.com>
Subject: Re: [PATCH 2/4] i2c/chips: Remove deprecated pcf8575-driver
From:	Bart Van Assche <bart.vanassche@gmail.com>
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	Jean Delvare <khali@linux-fr.org>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT
Return-Path: <bart.vanassche@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24008
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: bart.vanassche@gmail.com
Precedence: bulk
X-list: linux-mips

On Wed, Sep 9, 2009 at 11:22 PM, Wolfram Sang <w.sang@pengutronix.de> wrote:
>
> The pcf8575-driver in drivers/i2c/chips which just exports its register to
> sysfs is superseeded by drivers/gpio/pcf857x.c which properly uses the gpiolib.
> As this driver has been deprecated for more than a year, finally remove it.
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> Cc: Bart Van Assche <bart.vanassche@gmail.com>
> Cc: Jean Delvare <khali@linux-fr.org>
> ---
>  Documentation/i2c/chips/pcf8575 |   69 --------------
>  drivers/i2c/chips/Kconfig       |   18 ----
>  drivers/i2c/chips/Makefile      |    1 -
>  drivers/i2c/chips/pcf8575.c     |  198 ---------------------------------------
>  4 files changed, 0 insertions(+), 286 deletions(-)
>  delete mode 100644 Documentation/i2c/chips/pcf8575
>  delete mode 100644 drivers/i2c/chips/pcf8575.c

This patch removes the documentation file
Documentation/i2c/chips/pcf8575 while there is no documentation under
Documentation/ for the drivers/gpio/pcf857x.c driver. Shouldn't proper
documentation for the pcf857x driver be added to the kernel tree
before the pcf8575 driver is removed ?

Bart.

From w.sang@pengutronix.de Thu Sep 10 13:04:34 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 13:04:40 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:45416 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492233AbZIJLEe (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 13:04:34 +0200
Received: from [2001:6f8:1178:2:221:70ff:fe71:1890] (helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MlhRu-0000Fw-Kf; Thu, 10 Sep 2009 13:04:22 +0200
Date:	Thu, 10 Sep 2009 13:04:19 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	Bart Van Assche <bart.vanassche@gmail.com>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	Jean Delvare <khali@linux-fr.org>
Subject: Re: [PATCH 2/4] i2c/chips: Remove deprecated pcf8575-driver
Message-ID: <20090910110419.GA3266@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de> <1252531371-14866-3-git-send-email-w.sang@pengutronix.de> <e2e108260909100352l2a30438fj9f0297c1974c0192@mail.gmail.com>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="xHFwDpU9dbj6ez1V"
Content-Disposition: inline
In-Reply-To: <e2e108260909100352l2a30438fj9f0297c1974c0192@mail.gmail.com>
User-Agent: Mutt/1.5.18 (2008-05-17)
X-SA-Exim-Connect-IP: 2001:6f8:1178:2:221:70ff:fe71:1890
X-SA-Exim-Mail-From: w.sang@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24009
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips


--xHFwDpU9dbj6ez1V
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


> This patch removes the documentation file
> Documentation/i2c/chips/pcf8575 while there is no documentation under
> Documentation/ for the drivers/gpio/pcf857x.c driver. Shouldn't proper
> documentation for the pcf857x driver be added to the kernel tree
> before the pcf8575 driver is removed ?

I considered moving the documentation, but realized:

1st part is URLs for datasheets. Well, URLs easily grow outdated and those
datasheets are easily to find using your favourite search engine.

2nd part is a short description of the chips which is IMHO sufficently cove=
red
in drivers/gpio/Kconfig.

3rd part (Detection) and 4th part (sysfs-interface) are obsolete for the new
drivers. The gpiolib interface again is covered in Documentation/gpio.txt

So I concluded to simply drop the documentation.

Regards,

   Wolfram

--=20
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

--xHFwDpU9dbj6ez1V
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqo3TMACgkQD27XaX1/VRvFjQCgo1FvA+7ru2LhEIdbNdz63gq+
qZgAoKZE9Vl9Ut69l9xYkFnYk5zyLUA5
=pc+E
-----END PGP SIGNATURE-----

--xHFwDpU9dbj6ez1V--

From w.sang@pengutronix.de Thu Sep 10 13:07:56 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 13:08:02 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:52623 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492223AbZIJLH4 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 13:07:56 +0200
Received: from [2001:6f8:1178:2:221:70ff:fe71:1890] (helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MlhV6-0000Kj-NT; Thu, 10 Sep 2009 13:07:40 +0200
Date:	Thu, 10 Sep 2009 13:07:40 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	Jean Delvare <khali@linux-fr.org>
Cc:	linux-i2c@vger.kernel.org, linuxppc-dev@ozlabs.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@linux-mips.org,
	uclinux-dist-devel@blackfin.uclinux.org
Subject: Re: Removing deprecated drivers from drivers/i2c/chips
Message-ID: <20090910110740.GB3266@pengutronix.de>
References: <1252531371-14866-1-git-send-email-w.sang@pengutronix.de> <20090910124937.7b3df062@hyperion.delvare>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="GID0FwUMdk1T2AWN"
Content-Disposition: inline
In-Reply-To: <20090910124937.7b3df062@hyperion.delvare>
User-Agent: Mutt/1.5.18 (2008-05-17)
X-SA-Exim-Connect-IP: 2001:6f8:1178:2:221:70ff:fe71:1890
X-SA-Exim-Mail-From: w.sang@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24010
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips


--GID0FwUMdk1T2AWN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


> Not sure about the patch to drivers/gpio/pcf857x.c, as there is no gpio
> tree and no maintainer either AFAIK, I guess I shall pick it too?

I'd say so. An Ack from David Brownell would be nice, though.

Regards,

   Wolfram

--=20
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

--GID0FwUMdk1T2AWN
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqo3fwACgkQD27XaX1/VRubLQCfSgZNsCLqCMUHSTodsb+ADje7
8moAniKaGGL+YvVPQzmKGQiBL3LugOtg
=92rb
-----END PGP SIGNATURE-----

--GID0FwUMdk1T2AWN--

From at.wufei@gmail.com Thu Sep 10 13:42:52 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 13:42:59 +0200 (CEST)
Received: from mail-yx0-f195.google.com ([209.85.210.195]:62072 "EHLO
	mail-yx0-f195.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493506AbZIJLmw (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 13:42:52 +0200
Received: by yxe33 with SMTP id 33so26734yxe.0
        for <multiple recipients>; Thu, 10 Sep 2009 04:42:46 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:date:from:to:cc:subject
         :message-id:references:mime-version:content-type:content-disposition
         :in-reply-to:user-agent;
        bh=7R73+dcNZ/iprMyGpWrEPNSFWKJHTc5OpIXVRr/VIAw=;
        b=jcC4iqr8fOv2Y59ZtviP0K/SyHXnTG9f+xd+dy8atcWCl+jAKsk95048HNFRSNHr2y
         Q8uhdSxC02cyWwCGg0s8D/gNpO+BY7RlJT8lC2OFxe7If/ScmUTS3NTiE1qB+iBML3qW
         H4pZqBeZe45UzBQPiMyp0G1kCBqElXUqYWNcM=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=date:from:to:cc:subject:message-id:references:mime-version
         :content-type:content-disposition:in-reply-to:user-agent;
        b=O5RqNRfVzPblBVq+wWPERO89Nj+4ykCQ+Itjrym69Dk5YeEwKiPWGL9vmndC9Etn48
         M1TxVfBA6pDxaS4rmF912ubS9UvQ6NViGm/qCYX/T4q3OigKKhha0HnmuJInypNnyZE6
         PImtm/Scj1qKfdUxE0J689fvGW2fS5xniM3z8=
Received: by 10.90.225.5 with SMTP id x5mr848773agg.87.1252582966072;
        Thu, 10 Sep 2009 04:42:46 -0700 (PDT)
Received: from desktop ([58.31.9.46])
        by mx.google.com with ESMTPS id 39sm187805aga.71.2009.09.10.04.42.41
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Thu, 10 Sep 2009 04:42:45 -0700 (PDT)
Date:	Thu, 10 Sep 2009 19:42:38 +0800
From:	Wu Fei <at.wufei@gmail.com>
To:	David Daney <ddaney@caviumnetworks.com>
Cc:	Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
Subject: Re: [PATCH] cleanup vmalloc_fault for 64bit kernel
Message-ID: <20090910114238.GA7014@desktop>
References: <20090831132811.GA6924@desktop> <4AA7CB3E.1080807@caviumnetworks.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4AA7CB3E.1080807@caviumnetworks.com>
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <at.wufei@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24011
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: at.wufei@gmail.com
Precedence: bulk
X-list: linux-mips

On Wed, Sep 09, 2009 at 08:35:26AM -0700, David Daney wrote:
> Wu Fei wrote:
>> 64bit kernel won't arrive vmalloc_fault, it's not necessary or possible
>> to copy the page table from init_mm.pgd. swapper_pg_dir, module_pg_dir
>> and the process's pgd represent the different virtual address area, and
>> the tlb exception handler accesses the suitable one directly.
>>
>> Signed-off-by: Wu Fei <at.wufei@gmail.com>
>> ---
>>  arch/mips/mm/fault.c |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
>> index f956ecb..e769789 100644
>> --- a/arch/mips/mm/fault.c
>> +++ b/arch/mips/mm/fault.c
>> @@ -58,11 +58,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
>>  	 * only copy the information from the master page table,
>>  	 * nothing more.
>>  	 */
>> +#ifdef CONFIG_32BIT
>>  	if (unlikely(address >= VMALLOC_START && address <= VMALLOC_END))
>>  		goto vmalloc_fault;
>> -#ifdef MODULE_START
>> -	if (unlikely(address >= MODULE_START && address < MODULE_END))
>> -		goto vmalloc_fault;
>>  #endif
>>  
>
> That is not correct.  You can still arrive at do_page_fault() from  
> faults in the vmalloc range.  We need to go directly to the panic code  

That's not a real problem, if do_page_fault() from faults in the vmalloc
range, find_vma() returns NULL and eventually it will arrive no_context.
But anyway, I think your patch is better and readable.

Thanks,
Wufei.

> as I did in my patch: Message-Id:  
> <1251931654-21268-1-git-send-email-ddaney@caviumnetworks.com>
>
> AKA: [PATCH] MIPS: Don't corrupt page tables on vmalloc fault.
>
>
>
>>  	/*
>> @@ -203,6 +201,7 @@ do_sigbus:
>>  	force_sig_info(SIGBUS, &info, tsk);
>>   	return;
>> +#ifdef CONFIG_32BIT
>>  vmalloc_fault:
>>  	{
>>  		/*
>> @@ -241,4 +240,5 @@ vmalloc_fault:
>>  			goto no_context;
>>  		return;
>>  	}
>> +#endif
>>  }
>

From ralf@linux-mips.org Thu Sep 10 16:14:35 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 16:14:38 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:36042 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1493558AbZIJOOf (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 10 Sep 2009 16:14:35 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8AEFO5q010661;
	Thu, 10 Sep 2009 16:15:27 +0200
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8AEFICU010659;
	Thu, 10 Sep 2009 16:15:18 +0200
Date:	Thu, 10 Sep 2009 16:15:18 +0200
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Maxim Uvarov <muvarov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [MIPS] TLB  handler fix for vmalloc'ed addresses
Message-ID: <20090910141518.GA10547@linux-mips.org>
References: <4AA656D8.9040608@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4AA656D8.9040608@ru.mvista.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24012
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Tue, Sep 08, 2009 at 05:06:32PM +0400, Maxim Uvarov wrote:

> Patch is attached.

Please send patches inline.

> TLB exception handler incorrecly handles situation
> with wrong vmalloc'ed addresses.  This patch adds
> verifications for vmalloc'ed addresses (similar to
> x86_64 implementation). So the code now traps inside
> do_page_fault() on access to the wrong area.
> 
> Signed-off-by: Maxim Uvarov <muvarov@ru.mvista.com>
> 
> Test case:
> 
> #include <linux/module.h>
> #include <linux/init.h>
> #include <linux/kernel.h>
> #include <linux/kthread.h>
> #include <linux/delay.h>
> 
> static struct task_struct *ts;
> static int example_thread(void *dummy)
> {
> 	void *ptr;
> 	ptr = vmalloc(16*1024*1024);
> 	for(;;)
> 	{
> 		msleep(100);
> 	}
> }

So your test case allocates vmalloc memory but never touches it.

> 
> static void run_vmalloc(void *unused)
> {
> 	ts=kthread_run(example_thread,NULL,"vtest");
> }
> int init_module (void)
> {
> 	run_vmalloc(NULL);
> 	return 0;
> }
> 
> void cleanup_module (void)
> { /*Nothing*/}
> 
> 
> Originally kernel trapped on BUG() inside exit_mmap() and it was impossible
> to see what has happened. After this patch applied, nice back trace will be
> generated:
> 
> CPU 0 Unable to handle kernel paging request at virtual address c00000000036a148
> Oops[#1]:
> Cpu 0
> $ 0   : 0000000000000000 ffffffff81940000 0000000000000000 00000000ffff05a7
> $ 4   : 0000000000000000 ffffffffffffffff ffffffff81a0b7d0 ffffffff811983e4
> $ 8   : ffffffff817407b0 0000000000000000 0000000000000000 0000000000000000
> $12   : a80000003374bfe0 0000000000008c00 ffffffff811e9df8 0000000000000000
> $16   : ffffffff81164a68 a8000000352a3c50 c00000000036a0e8 0000000000000000
> $20   : 0000000000000000 0000000000000000 0000000000000000 0000000000000000
> $24   : 0000000000000002 a8000000337bb1a0                                  
> $28   : a800000033748000 a80000003374bf70 a80000003374bf70 c00000000036a148
> Hi    : 0000000000000000
> Lo    : 000000000000a311
> epc   : c00000000036a148 0xc00000000036a148     Tainted: P      
> ra    : c00000000036a148 0xc00000000036a148 <-- dead in kernel module vtest
> Status: 10008ce3    KX SX UX KERNEL EXL IE 
> Cause : 00000008
> BadVA : c00000000036a148
> PrId  : 000d0408
> Modules linked in:
> Process vtest (pid: 723, threadinfo=a800000033748000, task=a800000034530340)
> 	Stack : 0000000000000000 a80000003374bf90 ffffffff81176530 ffffffff81176488
> 	ffffffffffffffff ffffffffffffffff 0000000000000000 0000000000000000
> 	0000000000000000 a80000003374bfd0 ffffffff81125024 0000000000000000
> 	0000000000000000 0000000000000000 5a5a5a5a5a5a5a5a 5a5a5a5a5a5a5a5a
> 	5a5a5a5a5a5a5a5a 5a5a5a5a5a5a5aa5
> 	Call Trace:
> 	[<ffffffff81176530>] kthread+0x198/0x1f0
> 	[<ffffffff81176488>] kthread+0xf0/0x1f0
> 	[<ffffffff81125024>] kernel_thread_helper+0x14/0x20
> 
> 
> Code: (Bad address in epc)

This is a 64-bit kernel crash ...

> Index: linux-2.6.21/arch/mips/mm/fault.c
> ===================================================================
> --- linux-2.6.21.orig/arch/mips/mm/fault.c
> +++ linux-2.6.21/arch/mips/mm/fault.c
> @@ -282,22 +282,32 @@ vmalloc_fault:
>  		pte_t *pte_k;
>  
>  		pgd = (pgd_t *) pgd_current[raw_smp_processor_id()] + offset;
> -		pgd_k = init_mm.pgd + offset;
> +		pgd_k = pgd_offset_k(address);
>  
>  		if (!pgd_present(*pgd_k))
>  			goto no_context;
> -		set_pgd(pgd, *pgd_k);
> +		if (unlikely(!pgd_present(*pgd)))
> +			set_pgd(pgd, *pgd_k);
> +		else if (pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_k))
> +				goto no_context;
>  
>  		pud = pud_offset(pgd, address);
>  		pud_k = pud_offset(pgd_k, address);
>  		if (!pud_present(*pud_k))
>  			goto no_context;
> +		if (pud_none(*pud) ||
> +				pud_page_vaddr(*pud) != pud_page_vaddr(*pud_k))
> +			goto no_context;
>  
>  		pmd = pmd_offset(pud, address);
>  		pmd_k = pmd_offset(pud_k, address);
>  		if (!pmd_present(*pmd_k))
>  			goto no_context;
> -		set_pmd(pmd, *pmd_k);
> +		if (!pmd_present(*pmd))
> +			set_pmd(pmd, *pmd_k);
> +		else
> +			if (pmd_page(*pmd) != pmd_page(*pmd_k))
> +				goto no_context;
>  
>  		pte_k = pte_offset_kernel(pmd_k, address);
>  		if (!pte_present(*pte_k))

... but on 64-bit kernels vmalloc_fault: should not be reached ever.

  Ralf

From muvarov@ru.mvista.com Thu Sep 10 16:37:52 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 16:37:59 +0200 (CEST)
Received: from ru.mvista.com ([213.79.90.228]:1055 "EHLO
	buildserver.ru.mvista.com" rhost-flags-OK-FAIL-OK-FAIL)
	by ftp.linux-mips.org with ESMTP id S1493558AbZIJOhw (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 16:37:52 +0200
Received: from [192.168.11.243] (unknown [10.150.0.9])
	by buildserver.ru.mvista.com (Postfix) with ESMTP
	id E0829881D; Thu, 10 Sep 2009 19:37:48 +0500 (SAMST)
Message-ID: <4AA90F3B.6000204@ru.mvista.com>
Date:	Thu, 10 Sep 2009 18:37:47 +0400
From:	Maxim Uvarov <muvarov@ru.mvista.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	linux-mips@linux-mips.org
Subject: Re: [MIPS] TLB  handler fix for vmalloc'ed addresses
References: <4AA656D8.9040608@ru.mvista.com> <20090910141518.GA10547@linux-mips.org>
In-Reply-To: <20090910141518.GA10547@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <muvarov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24013
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: muvarov@ru.mvista.com
Precedence: bulk
X-list: linux-mips

Ralf Baechle wrote:
> On Tue, Sep 08, 2009 at 05:06:32PM +0400, Maxim Uvarov wrote:
> 
>> Patch is attached.
> 
> Please send patches inline.
> 
>> TLB exception handler incorrecly handles situation
>> with wrong vmalloc'ed addresses.  This patch adds
>> verifications for vmalloc'ed addresses (similar to
>> x86_64 implementation). So the code now traps inside
>> do_page_fault() on access to the wrong area.
>>
>> Signed-off-by: Maxim Uvarov <muvarov@ru.mvista.com>
>>
>> Test case:
>>
>> #include <linux/module.h>
>> #include <linux/init.h>
>> #include <linux/kernel.h>
>> #include <linux/kthread.h>
>> #include <linux/delay.h>
>>
>> static struct task_struct *ts;
>> static int example_thread(void *dummy)
>> {
>> 	void *ptr;
>> 	ptr = vmalloc(16*1024*1024);
>> 	for(;;)
>> 	{
>> 		msleep(100);
>> 	}
>> }
> 
> So your test case allocates vmalloc memory but never touches it.

Yes, it is so. Bug occurs on rmmod this module. (Module does not free memory
allocated with vmalloc().

> 
>> static void run_vmalloc(void *unused)
>> {
>> 	ts=kthread_run(example_thread,NULL,"vtest");
>> }
>> int init_module (void)
>> {
>> 	run_vmalloc(NULL);
>> 	return 0;
>> }
>>
>> void cleanup_module (void)
>> { /*Nothing*/}
>>
>>
>> Originally kernel trapped on BUG() inside exit_mmap() and it was impossible
>> to see what has happened. After this patch applied, nice back trace will be
>> generated:
>>
>> CPU 0 Unable to handle kernel paging request at virtual address c00000000036a148
>> Oops[#1]:
>> Cpu 0
>> $ 0   : 0000000000000000 ffffffff81940000 0000000000000000 00000000ffff05a7
>> $ 4   : 0000000000000000 ffffffffffffffff ffffffff81a0b7d0 ffffffff811983e4
>> $ 8   : ffffffff817407b0 0000000000000000 0000000000000000 0000000000000000
>> $12   : a80000003374bfe0 0000000000008c00 ffffffff811e9df8 0000000000000000
>> $16   : ffffffff81164a68 a8000000352a3c50 c00000000036a0e8 0000000000000000
>> $20   : 0000000000000000 0000000000000000 0000000000000000 0000000000000000
>> $24   : 0000000000000002 a8000000337bb1a0                                  
>> $28   : a800000033748000 a80000003374bf70 a80000003374bf70 c00000000036a148
>> Hi    : 0000000000000000
>> Lo    : 000000000000a311
>> epc   : c00000000036a148 0xc00000000036a148     Tainted: P      
>> ra    : c00000000036a148 0xc00000000036a148 <-- dead in kernel module vtest
>> Status: 10008ce3    KX SX UX KERNEL EXL IE 
>> Cause : 00000008
>> BadVA : c00000000036a148
>> PrId  : 000d0408
>> Modules linked in:
>> Process vtest (pid: 723, threadinfo=a800000033748000, task=a800000034530340)
>> 	Stack : 0000000000000000 a80000003374bf90 ffffffff81176530 ffffffff81176488
>> 	ffffffffffffffff ffffffffffffffff 0000000000000000 0000000000000000
>> 	0000000000000000 a80000003374bfd0 ffffffff81125024 0000000000000000
>> 	0000000000000000 0000000000000000 5a5a5a5a5a5a5a5a 5a5a5a5a5a5a5a5a
>> 	5a5a5a5a5a5a5a5a 5a5a5a5a5a5a5aa5
>> 	Call Trace:
>> 	[<ffffffff81176530>] kthread+0x198/0x1f0
>> 	[<ffffffff81176488>] kthread+0xf0/0x1f0
>> 	[<ffffffff81125024>] kernel_thread_helper+0x14/0x20
>>
>>
>> Code: (Bad address in epc)
> 
> This is a 64-bit kernel crash ...
> 
>> Index: linux-2.6.21/arch/mips/mm/fault.c
>> ===================================================================
>> --- linux-2.6.21.orig/arch/mips/mm/fault.c
>> +++ linux-2.6.21/arch/mips/mm/fault.c
>> @@ -282,22 +282,32 @@ vmalloc_fault:
>>  		pte_t *pte_k;
>>  
>>  		pgd = (pgd_t *) pgd_current[raw_smp_processor_id()] + offset;
>> -		pgd_k = init_mm.pgd + offset;
>> +		pgd_k = pgd_offset_k(address);
>>  
>>  		if (!pgd_present(*pgd_k))
>>  			goto no_context;
>> -		set_pgd(pgd, *pgd_k);
>> +		if (unlikely(!pgd_present(*pgd)))
>> +			set_pgd(pgd, *pgd_k);
>> +		else if (pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_k))
>> +				goto no_context;
>>  
>>  		pud = pud_offset(pgd, address);
>>  		pud_k = pud_offset(pgd_k, address);
>>  		if (!pud_present(*pud_k))
>>  			goto no_context;
>> +		if (pud_none(*pud) ||
>> +				pud_page_vaddr(*pud) != pud_page_vaddr(*pud_k))
>> +			goto no_context;
>>  
>>  		pmd = pmd_offset(pud, address);
>>  		pmd_k = pmd_offset(pud_k, address);
>>  		if (!pmd_present(*pmd_k))
>>  			goto no_context;
>> -		set_pmd(pmd, *pmd_k);
>> +		if (!pmd_present(*pmd))
>> +			set_pmd(pmd, *pmd_k);
>> +		else
>> +			if (pmd_page(*pmd) != pmd_page(*pmd_k))
>> +				goto no_context;
>>  
>>  		pte_k = pte_offset_kernel(pmd_k, address);
>>  		if (!pte_present(*pte_k))
> 
> ... but on 64-bit kernels vmalloc_fault: should not be reached ever.
> 
Ah. OK.
>   Ralf


From ralf@linux-mips.org Thu Sep 10 17:36:53 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 17:36:56 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:47727 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1492378AbZIJPgx (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 10 Sep 2009 17:36:53 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8AFbmEh012042;
	Thu, 10 Sep 2009 17:37:51 +0200
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8AFbjxe012039;
	Thu, 10 Sep 2009 17:37:45 +0200
Date:	Thu, 10 Sep 2009 17:37:44 +0200
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Maxim Uvarov <muvarov@ru.mvista.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [MIPS] TLB  handler fix for vmalloc'ed addresses
Message-ID: <20090910153744.GA10998@linux-mips.org>
References: <4AA656D8.9040608@ru.mvista.com> <20090910141518.GA10547@linux-mips.org> <4AA90F3B.6000204@ru.mvista.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4AA90F3B.6000204@ru.mvista.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24014
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Thu, Sep 10, 2009 at 06:37:47PM +0400, Maxim Uvarov wrote:

>>> TLB exception handler incorrecly handles situation
>>> with wrong vmalloc'ed addresses.  This patch adds
>>> verifications for vmalloc'ed addresses (similar to
>>> x86_64 implementation). So the code now traps inside
>>> do_page_fault() on access to the wrong area.
>>>
>>> Signed-off-by: Maxim Uvarov <muvarov@ru.mvista.com>
>>>
>>> Test case:
>>>
>>> #include <linux/module.h>
>>> #include <linux/init.h>
>>> #include <linux/kernel.h>
>>> #include <linux/kthread.h>
>>> #include <linux/delay.h>
>>>
>>> static struct task_struct *ts;
>>> static int example_thread(void *dummy)
>>> {
>>> 	void *ptr;
>>> 	ptr = vmalloc(16*1024*1024);
>>> 	for(;;)
>>> 	{
>>> 		msleep(100);
>>> 	}
>>> }
>>
>> So your test case allocates vmalloc memory but never touches it.
>
> Yes, it is so. Bug occurs on rmmod this module. (Module does not free memory
> allocated with vmalloc().

Nor does it stop the thread on exit or avoid unloading.  So panicing is
expected.

  Ralf

From muvarov@ru.mvista.com Thu Sep 10 17:48:11 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 17:48:18 +0200 (CEST)
Received: from ru.mvista.com ([213.79.90.228]:1265 "EHLO
	buildserver.ru.mvista.com" rhost-flags-OK-FAIL-OK-FAIL)
	by ftp.linux-mips.org with ESMTP id S1493561AbZIJPsL (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 17:48:11 +0200
Received: from [192.168.11.243] (unknown [10.150.0.9])
	by buildserver.ru.mvista.com (Postfix) with ESMTP
	id CC388881D; Thu, 10 Sep 2009 20:48:09 +0500 (SAMST)
Message-ID: <4AA91FB9.205@ru.mvista.com>
Date:	Thu, 10 Sep 2009 19:48:09 +0400
From:	Maxim Uvarov <muvarov@ru.mvista.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	linux-mips@linux-mips.org
Subject: Re: [MIPS] TLB  handler fix for vmalloc'ed addresses
References: <4AA656D8.9040608@ru.mvista.com> <20090910141518.GA10547@linux-mips.org> <4AA90F3B.6000204@ru.mvista.com> <20090910153744.GA10998@linux-mips.org>
In-Reply-To: <20090910153744.GA10998@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <muvarov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24015
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: muvarov@ru.mvista.com
Precedence: bulk
X-list: linux-mips

>>>> }
>>> So your test case allocates vmalloc memory but never touches it.
>> Yes, it is so. Bug occurs on rmmod this module. (Module does not free memory
>> allocated with vmalloc().
> 
> Nor does it stop the thread on exit or avoid unloading.  So panicing is
> expected.

Ralf, I'm sorry for misunderstanding.  Original kernel does panic in this situation. 
In my patch it went to panic with
+		else if (pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_k))
+				goto no_context;

Actually it was the reason of this patch.

But looks like we need go immediately to no_context for 64 bit and do not do this checks.

Maxim.

From muvarov@ru.mvista.com Thu Sep 10 18:00:08 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 10 Sep 2009 18:00:16 +0200 (CEST)
Received: from ru.mvista.com ([213.79.90.228]:1303 "EHLO
	buildserver.ru.mvista.com" rhost-flags-OK-FAIL-OK-FAIL)
	by ftp.linux-mips.org with ESMTP id S1492433AbZIJQAI (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 10 Sep 2009 18:00:08 +0200
Received: from [192.168.11.243] (unknown [10.150.0.9])
	by buildserver.ru.mvista.com (Postfix) with ESMTP
	id 2896E881D; Thu, 10 Sep 2009 21:00:08 +0500 (SAMST)
Message-ID: <4AA92287.3090608@ru.mvista.com>
Date:	Thu, 10 Sep 2009 20:00:07 +0400
From:	Maxim Uvarov <muvarov@ru.mvista.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	linux-mips@linux-mips.org
Subject: Re: [MIPS] TLB  handler fix for vmalloc'ed addresses
References: <4AA656D8.9040608@ru.mvista.com> <20090910141518.GA10547@linux-mips.org> <4AA90F3B.6000204@ru.mvista.com> <20090910153744.GA10998@linux-mips.org> <4AA91FB9.205@ru.mvista.com>
In-Reply-To: <4AA91FB9.205@ru.mvista.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <muvarov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24016
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: muvarov@ru.mvista.com
Precedence: bulk
X-list: linux-mips

Maxim Uvarov wrote:
>>>>> }
>>>> So your test case allocates vmalloc memory but never touches it.
>>> Yes, it is so. Bug occurs on rmmod this module. (Module does not free 
>>> memory
>>> allocated with vmalloc().
>>
>> Nor does it stop the thread on exit or avoid unloading.  So panicing is
>> expected.
> 
> Ralf, I'm sorry for misunderstanding.  Original kernel does panic in 
> this situation. In my patch it went to panic with


Original kernel does  _NOT_ panic.


> +        else if (pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_k))
> +                goto no_context;
> 
> Actually it was the reason of this patch.
> 
> But looks like we need go immediately to no_context for 64 bit and do 
> not do this checks.
> 
> Maxim.
> 


From David.Daney@caviumnetworks.com Fri Sep 11 01:55:50 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 11 Sep 2009 01:55:58 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:16039 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493567AbZIJXzu (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 11 Sep 2009 01:55:50 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4aa991f40000>; Thu, 10 Sep 2009 16:55:32 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 10 Sep 2009 16:54:44 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 10 Sep 2009 16:54:44 -0700
Message-ID: <4AA991C1.1050800@caviumnetworks.com>
Date:	Thu, 10 Sep 2009 16:54:41 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
CC:	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>, x86@kernel.org,
	ralf@linux-mips.org, linux-mips@linux-mips.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux390@de.ibm.com, linux-s390@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	Koichi Yasutake <yasutake.koichi@jp.panasonic.com>,
	linux-am33-list@redhat.com, Kyle McMartin <kyle@mcmartin.ca>,
	Helge Deller <deller@gmx.de>, linux-parisc@vger.kernel.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>, linuxppc-dev@ozlabs.org,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	linux-alpha@vger.kernel.org,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	Mike Frysinger <vapier@gentoo.org>,
	uclinux-dist-devel@blackfin.uclinux.org
Subject: [PATCH 00/10] Add support for GCC's __builtin_unreachable() and use
 it in BUG.
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 10 Sep 2009 23:54:44.0061 (UTC) FILETIME=[11D988D0:01CA3272]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24017
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Starting with version 4.5, GCC has a new built-in function called
__builtin_unreachable().  The function tells the compiler that control
flow will never reach that point.  Currently we trick the compiler by
putting in for(;;); but this has the disadvantage that extra code is
emitted for an endless loop.  For an i386 kernel using
__builtin_unreachable() results in an allyesconfig that is nearly 4000
bytes smaller.

This patch set adds support to compiler.h creating a
new macro usable in the kernel called unreachable().  If the compiler
lacks __builtin_unreachable(), it just expands to for(;;).

The x86 and MIPS patches I actually tested with a GCC-4.5 snapshot.
Lacking the ability to test the rest of the architectures, I just did
what seemed right without even trying to compile the kernel.

01/10 adds the compiler.h support, the rest of the patches retrofit
the various architecture BUG macros to use it instead of for(;;) or
while(1) loops.

I will reply with the 10 patches.

The architecture specific patches I will send to a smaller set of
people.

David Daney (10):
   Add support for GCC-4.5's __builtin_unreachable() to compiler.h
   x86: Convert BUG() to use unreachable()
   MIPS: Convert BUG() to use unreachable()
   s390: Convert BUG() to use unreachable()
   mn10300: Convert BUG() to use unreachable()
   parisc: Convert BUG() to use unreachable()
   powerpc: Convert BUG() to use unreachable()
   alpha: Convert BUG() to use unreachable()
   avr32: Convert BUG() to use unreachable()
   blackfin: Convert BUG() to use unreachable()

  arch/alpha/include/asm/bug.h    |    2 +-
  arch/avr32/include/asm/bug.h    |    2 +-
  arch/blackfin/include/asm/bug.h |    2 +-
  arch/mips/include/asm/bug.h     |    4 +---
  arch/mn10300/include/asm/bug.h  |    3 ++-
  arch/parisc/include/asm/bug.h   |    4 ++--
  arch/powerpc/include/asm/bug.h  |    2 +-
  arch/s390/include/asm/bug.h     |    2 +-
  arch/x86/include/asm/bug.h      |    4 ++--
  include/linux/compiler-gcc4.h   |   14 ++++++++++++++
  include/linux/compiler.h        |    5 +++++
  11 files changed, 31 insertions(+), 13 deletions(-)


From David.Daney@caviumnetworks.com Fri Sep 11 01:57:39 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 11 Sep 2009 01:57:45 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:16091 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493567AbZIJX5j (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 11 Sep 2009 01:57:39 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4aa9926c0002>; Thu, 10 Sep 2009 16:57:32 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 10 Sep 2009 16:57:04 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 10 Sep 2009 16:57:04 -0700
Received: from dd1.caveonetworks.com (localhost.localdomain [127.0.0.1])
	by dd1.caveonetworks.com (8.14.2/8.14.2) with ESMTP id n8ANv03a002967;
	Thu, 10 Sep 2009 16:57:00 -0700
Received: (from ddaney@localhost)
	by dd1.caveonetworks.com (8.14.2/8.14.2/Submit) id n8ANv0xN002966;
	Thu, 10 Sep 2009 16:57:00 -0700
From:	David Daney <ddaney@caviumnetworks.com>
To:	torvalds@linux-foundation.org, akpm@linux-foundation.org
Cc:	linux-kernel@vger.kernel.org,
	David Daney <ddaney@caviumnetworks.com>, ralf@linux-mips.org,
	linux-mips@linux-mips.org
Subject: [PATCH 03/10] MIPS: Convert BUG() to use unreachable()
Date:	Thu, 10 Sep 2009 16:56:44 -0700
Message-Id: <1252627011-2933-3-git-send-email-ddaney@caviumnetworks.com>
X-Mailer: git-send-email 1.6.0.6
In-Reply-To: <4AA991C1.1050800@caviumnetworks.com>
References: <4AA991C1.1050800@caviumnetworks.com>
X-OriginalArrivalTime: 10 Sep 2009 23:57:04.0813 (UTC) FILETIME=[65BE95D0:01CA3272]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24018
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Use the new unreachable() macro instead of while(1);

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: ralf@linux-mips.org
CC: linux-mips@linux-mips.org
---
 arch/mips/include/asm/bug.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
index 6cf29c2..540c98a 100644
--- a/arch/mips/include/asm/bug.h
+++ b/arch/mips/include/asm/bug.h
@@ -11,9 +11,7 @@
 static inline void __noreturn BUG(void)
 {
 	__asm__ __volatile__("break %0" : : "i" (BRK_BUG));
-	/* Fool GCC into thinking the function doesn't return. */
-	while (1)
-		;
+	unreachable();
 }
 
 #define HAVE_ARCH_BUG
-- 
1.6.2.5


From David.Daney@caviumnetworks.com Fri Sep 11 01:58:03 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 11 Sep 2009 01:58:10 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:16136 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493610AbZIJX5r (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 11 Sep 2009 01:57:47 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4aa9926d0002>; Thu, 10 Sep 2009 16:57:33 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 10 Sep 2009 16:57:05 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Thu, 10 Sep 2009 16:57:04 -0700
Received: from dd1.caveonetworks.com (localhost.localdomain [127.0.0.1])
	by dd1.caveonetworks.com (8.14.2/8.14.2) with ESMTP id n8ANuvpw002959;
	Thu, 10 Sep 2009 16:56:57 -0700
Received: (from ddaney@localhost)
	by dd1.caveonetworks.com (8.14.2/8.14.2/Submit) id n8ANupK1002957;
	Thu, 10 Sep 2009 16:56:51 -0700
From:	David Daney <ddaney@caviumnetworks.com>
To:	torvalds@linux-foundation.org, akpm@linux-foundation.org
Cc:	linux-kernel@vger.kernel.org,
	David Daney <ddaney@caviumnetworks.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>, x86@kernel.org,
	ralf@linux-mips.org, linux-mips@linux-mips.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux390@de.ibm.com, linux-s390@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	Koichi Yasutake <yasutake.koichi@jp.panasonic.com>,
	linux-am33-list@redhat.com, Kyle McMartin <kyle@mcmartin.ca>,
	Helge Deller <deller@gmx.de>, linux-parisc@vger.kernel.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>, linuxppc-dev@ozlabs.org,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	linux-alpha@vger.kernel.org,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	Mike Frysinger <vapier@gentoo.org>,
	uclinux-dist-devel@blackfin.uclinux.org
Subject: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() to compiler.h
Date:	Thu, 10 Sep 2009 16:56:42 -0700
Message-Id: <1252627011-2933-1-git-send-email-ddaney@caviumnetworks.com>
X-Mailer: git-send-email 1.6.0.6
In-Reply-To: <4AA991C1.1050800@caviumnetworks.com>
References: <4AA991C1.1050800@caviumnetworks.com>
X-OriginalArrivalTime: 10 Sep 2009 23:57:04.0797 (UTC) FILETIME=[65BC24D0:01CA3272]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24019
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Starting with version 4.5, GCC has a new built-in function
__builtin_unreachable() that can be used in places like the kernel's
BUG() where inline assembly is used to transfer control flow.  This
eliminated the need for an endless loop in these places.

The patch adds a new macro 'unreachable()' that will expand to either
__builtin_unreachable() or an endless loop depending on the compiler
version.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: x86@kernel.org
CC: ralf@linux-mips.org
CC: linux-mips@linux-mips.org
CC: Martin Schwidefsky <schwidefsky@de.ibm.com>
CC: Heiko Carstens <heiko.carstens@de.ibm.com>
CC: linux390@de.ibm.com
CC: linux-s390@vger.kernel.org
CC: David Howells <dhowells@redhat.com>
CC: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
CC: linux-am33-list@redhat.com
CC: Kyle McMartin <kyle@mcmartin.ca>
CC: Helge Deller <deller@gmx.de>
CC: linux-parisc@vger.kernel.org
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev@ozlabs.org
CC: Richard Henderson <rth@twiddle.net>
CC: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
CC: linux-alpha@vger.kernel.org
CC: Haavard Skinnemoen <hskinnemoen@atmel.com>
CC: Mike Frysinger <vapier@gentoo.org>
CC: uclinux-dist-devel@blackfin.uclinux.org
---
 include/linux/compiler-gcc4.h |   14 ++++++++++++++
 include/linux/compiler.h      |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index 450fa59..ab3af40 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -36,4 +36,18 @@
    the kernel context */
 #define __cold			__attribute__((__cold__))
 
+
+#if __GNUC_MINOR__ >= 5
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+#endif
+
 #endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 04fb513..7efd73f 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -144,6 +144,11 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 # define barrier() __memory_barrier()
 #endif
 
+/* Unreachable code */
+#ifndef unreachable
+# define unreachable() do { for (;;) ; } while (0)
+#endif
+
 #ifndef RELOC_HIDE
 # define RELOC_HIDE(ptr, off)					\
   ({ unsigned long __ptr;					\
-- 
1.6.2.5


From rth@twiddle.net Fri Sep 11 02:14:36 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 11 Sep 2009 02:14:44 +0200 (CEST)
Received: from are.twiddle.net ([75.149.56.221]:43607 "EHLO are.twiddle.net"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493028AbZIKAOg (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 11 Sep 2009 02:14:36 +0200
Received: from stone.twiddle.home (stone.twiddle.home [172.31.0.16])
	by are.twiddle.net (Postfix) with ESMTPSA id 1CEB6576;
	Thu, 10 Sep 2009 17:14:32 -0700 (PDT)
Message-ID: <4AA99666.4090207@twiddle.net>
Date:	Thu, 10 Sep 2009 17:14:30 -0700
From:	Richard Henderson <rth@twiddle.net>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3
MIME-Version: 1.0
To:	David Daney <ddaney@caviumnetworks.com>
CC:	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>, x86@kernel.org,
	ralf@linux-mips.org, linux-mips@linux-mips.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux390@de.ibm.com, linux-s390@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	Koichi Yasutake <yasutake.koichi@jp.panasonic.com>,
	linux-am33-list@redhat.com, Kyle McMartin <kyle@mcmartin.ca>,
	Helge Deller <deller@gmx.de>, linux-parisc@vger.kernel.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>, linuxppc-dev@ozlabs.org,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	linux-alpha@vger.kernel.org,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	Mike Frysinger <vapier@gentoo.org>,
	uclinux-dist-devel@blackfin.uclinux.org
Subject: Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable()
 to compiler.h
References: <4AA991C1.1050800@caviumnetworks.com> <1252627011-2933-1-git-send-email-ddaney@caviumnetworks.com>
In-Reply-To: <1252627011-2933-1-git-send-email-ddaney@caviumnetworks.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <rth@twiddle.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24020
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: rth@twiddle.net
Precedence: bulk
X-list: linux-mips

On 09/10/2009 04:56 PM, David Daney wrote:
> +#ifndef unreachable
> +# define unreachable() do { for (;;) ; } while (0)
> +#endif

#define unreachable() do { } while (1)


r~

From David.Daney@caviumnetworks.com Fri Sep 11 17:59:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 11 Sep 2009 17:59:37 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:13468 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492789AbZIKP7a (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 11 Sep 2009 17:59:30 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4aaa73d00000>; Fri, 11 Sep 2009 08:59:12 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Fri, 11 Sep 2009 08:58:29 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Fri, 11 Sep 2009 08:58:28 -0700
Message-ID: <4AAA73A4.9010601@caviumnetworks.com>
Date:	Fri, 11 Sep 2009 08:58:28 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Michael Buesch <mb@bu3sch.de>
CC:	linuxppc-dev@lists.ozlabs.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, linux-mips@linux-mips.org,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>, linux-s390@vger.kernel.org,
	linux-am33-list@redhat.com, Helge Deller <deller@gmx.de>,
	x86@kernel.org, Ingo Molnar <mingo@redhat.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	uclinux-dist-devel@blackfin.uclinux.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Richard Henderson <rth@twiddle.net>,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	ralf@linux-mips.org, Kyle McMartin <kyle@mcmartin.ca>,
	linux-alpha@vger.kernel.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	linux390@de.ibm.com,
	Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Subject: Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable()
 to compiler.h
References: <4AA991C1.1050800@caviumnetworks.com> <1252627011-2933-1-git-send-email-ddaney@caviumnetworks.com> <200909111633.00665.mb@bu3sch.de>
In-Reply-To: <200909111633.00665.mb@bu3sch.de>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 11 Sep 2009 15:58:28.0891 (UTC) FILETIME=[B4225EB0:01CA32F8]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24021
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Michael Buesch wrote:
> On Friday 11 September 2009 01:56:42 David Daney wrote:
>> +/* Unreachable code */
>> +#ifndef unreachable
>> +# define unreachable() do { for (;;) ; } while (0)
>> +#endif
> 
> # define unreachable() do { } while (1)
> 
> ? :)

Clearly I was not thinking clearly when I wrote that part.  RTH noted 
the same thing.  I will fix it.

Thanks,
David Daney

From julia@diku.dk Fri Sep 11 18:21:05 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 11 Sep 2009 18:21:14 +0200 (CEST)
Received: from mgw2.diku.dk ([130.225.96.92]:57401 "EHLO mgw2.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492847AbZIKQVF (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 11 Sep 2009 18:21:05 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw2.diku.dk (Postfix) with ESMTP id D506F19BB8C;
	Fri, 11 Sep 2009 18:21:01 +0200 (CEST)
Received: from mgw2.diku.dk ([127.0.0.1])
 by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
 id 24481-14; Fri, 11 Sep 2009 18:21:00 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw2.diku.dk (Postfix) with ESMTP id B883019BB8B;
	Fri, 11 Sep 2009 18:21:00 +0200 (CEST)
Received: from pc-004.diku.dk (pc-004.diku.dk [130.225.97.4])
	by nhugin.diku.dk (Postfix) with ESMTP
	id EBC596DF84F; Fri, 11 Sep 2009 18:19:13 +0200 (CEST)
Received: by pc-004.diku.dk (Postfix, from userid 3767)
	id A1E69383C5; Fri, 11 Sep 2009 18:21:00 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by pc-004.diku.dk (Postfix) with ESMTP id 9BE003830C;
	Fri, 11 Sep 2009 18:21:00 +0200 (CEST)
Date:	Fri, 11 Sep 2009 18:21:00 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
Message-ID: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Virus-Scanned: amavisd-new at diku.dk
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24022
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

From: Julia Lawall <julia@diku.dk>

Error handling code following a kzalloc should free the allocated data.
Error handling code following an ioremap should iounmap the allocated data.

The semantic match that finds the first problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...x...+> }
(
x->f1 = E
|
 (x->f1 == NULL || ...)
|
 f(...,x->f1,...)
)
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
---
 arch/mips/txx9/generic/setup.c      |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index a205e2b..5744af2 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -781,8 +781,10 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 	if (!iocled)
 		return;
 	iocled->mmioaddr = ioremap(baseaddr, 1);
-	if (!iocled->mmioaddr)
+	if (!iocled->mmioaddr) {
+		kfree(iocled);
 		return;
+	}
 	iocled->chip.get = txx9_iocled_get;
 	iocled->chip.set = txx9_iocled_set;
 	iocled->chip.direction_input = txx9_iocled_dir_in;
@@ -790,8 +792,11 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 	iocled->chip.label = "iocled";
 	iocled->chip.base = basenum;
 	iocled->chip.ngpio = num;
-	if (gpiochip_add(&iocled->chip))
+	if (gpiochip_add(&iocled->chip)) {
+		iounmap(iocled->mmioaddr);
+		kfree(iocled);
 		return;
+	}
 	if (basenum < 0)
 		basenum = iocled->chip.base;
 

From geert.uytterhoeven@gmail.com Sat Sep 12 09:22:51 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 12 Sep 2009 09:22:59 +0200 (CEST)
Received: from mail-pz0-f196.google.com ([209.85.222.196]:43114 "EHLO
	mail-pz0-f196.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492489AbZILHWv convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 12 Sep 2009 09:22:51 +0200
Received: by pzk34 with SMTP id 34so1372643pzk.25
        for <multiple recipients>; Sat, 12 Sep 2009 00:22:43 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:sender:received:in-reply-to
         :references:date:x-google-sender-auth:message-id:subject:from:to:cc
         :content-type:content-transfer-encoding;
        bh=BYfes+zK7C0QrRX59HJns71yQgIMusYiQ4nZojFPVWg=;
        b=g9H6mtBPKhSe8IGifgFQIv0y/Oz3EmQGlipzps5XlaYuzvB56dQUwlwRoOgdHafwZ9
         smKuFnW2qEhF1GO2cKZKc1lww1fpGS3IEXGBijJZ4mbF0aAMy3DHCk5D8cXS3z2+Gzjs
         3E7iXoFsOZELr/ODjzQ9v+3vjYI2oajEjTPow=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:sender:in-reply-to:references:date
         :x-google-sender-auth:message-id:subject:from:to:cc:content-type
         :content-transfer-encoding;
        b=kVElTN3oryoBOHPcgT/LgC+poKPhTuTX7tc3M01PI9YoXDjRPcBjx2R4hfxlPCt51J
         B/0hUVUG47xe05glhIW4g2MTlj3KPXDP5H3kVREmjA61kOZ/T7cNY9z5PWfYNpJzMeyT
         JtnlJYzhsypIcFsReHLr34R1zBTyl1EhFLmFw=
MIME-Version: 1.0
Received: by 10.142.74.4 with SMTP id w4mr330649wfa.195.1252740163196; Sat, 12 
	Sep 2009 00:22:43 -0700 (PDT)
In-Reply-To: <4AAA73A4.9010601@caviumnetworks.com>
References: <4AA991C1.1050800@caviumnetworks.com>
	 <1252627011-2933-1-git-send-email-ddaney@caviumnetworks.com>
	 <200909111633.00665.mb@bu3sch.de>
	 <4AAA73A4.9010601@caviumnetworks.com>
Date:	Sat, 12 Sep 2009 09:22:43 +0200
X-Google-Sender-Auth: 42a0362e6b437612
Message-ID: <10f740e80909120022m72ad5ea7t692fba93cd3114e9@mail.gmail.com>
Subject: Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable() 
	to compiler.h
From:	Geert Uytterhoeven <geert@linux-m68k.org>
To:	David Daney <ddaney@caviumnetworks.com>
Cc:	Michael Buesch <mb@bu3sch.de>, linuxppc-dev@lists.ozlabs.org,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	linux-mips@linux-mips.org,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>, linux-s390@vger.kernel.org,
	linux-am33-list@redhat.com, Helge Deller <deller@gmx.de>,
	x86@kernel.org, Ingo Molnar <mingo@redhat.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	uclinux-dist-devel@blackfin.uclinux.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Richard Henderson <rth@twiddle.net>,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	ralf@linux-mips.org, Kyle McMartin <kyle@mcmartin.ca>,
	linux-alpha@vger.kernel.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	linux390@de.ibm.com,
	Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8BIT
Return-Path: <geert.uytterhoeven@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24023
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: geert@linux-m68k.org
Precedence: bulk
X-list: linux-mips

On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
> Michael Buesch wrote:
>>
>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>
>>> +/* Unreachable code */
>>> +#ifndef unreachable
>>> +# define unreachable() do { for (;;) ; } while (0)
>>> +#endif
>>
>> # define unreachable() do { } while (1)
>>
>> ? :)
>
> Clearly I was not thinking clearly when I wrote that part. Â RTH noted the
> same thing. Â I will fix it.

However, people are so used to seeing the `do { } while (0)' idiom,
that they might miss
there's a `1' here, not a `0'.

So perhaps it's better to use plain `for (;;)' for infinite loops?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

From anemo@mba.ocn.ne.jp Sun Sep 13 16:25:57 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 13 Sep 2009 16:26:04 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:64066 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1492464AbZIMOZ5 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 13 Sep 2009 16:25:57 +0200
Received: from localhost (p5010-ipad310funabasi.chiba.ocn.ne.jp [123.217.207.10])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 4A1466699; Sun, 13 Sep 2009 23:25:48 +0900 (JST)
Date:	Sun, 13 Sep 2009 23:25:48 +0900 (JST)
Message-Id: <20090913.232548.253168283.anemo@mba.ocn.ne.jp>
To:	julia@diku.dk
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 5.2 on Emacs 22.2 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24024
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

On Fri, 11 Sep 2009 18:21:00 +0200 (CEST), Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Error handling code following a kzalloc should free the allocated data.
> Error handling code following an ioremap should iounmap the allocated data.
> 
> The semantic match that finds the first problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)

Thank you for finding this out.

This patch add some correctness, but obviously incomplete: there are
more error pathes without iounmap/kfree/etc. in this function.

And I like goto-style cleanup, as Mark Brown said in reply for your
sound/soc patch.

Could you make a new patch?

---
Atsushi Nemoto

From julia@diku.dk Sun Sep 13 17:14:11 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 13 Sep 2009 17:14:18 +0200 (CEST)
Received: from mgw1.diku.dk ([130.225.96.91]:51608 "EHLO mgw1.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492696AbZIMPOL (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 13 Sep 2009 17:14:11 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw1.diku.dk (Postfix) with ESMTP id 3ABAE52C325;
	Sun, 13 Sep 2009 17:14:08 +0200 (CEST)
X-Virus-Scanned: amavisd-new at diku.dk
Received: from mgw1.diku.dk ([127.0.0.1])
	by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ojxZV+39Wxrn; Sun, 13 Sep 2009 17:14:06 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw1.diku.dk (Postfix) with ESMTP id E683E52C31C;
	Sun, 13 Sep 2009 17:14:06 +0200 (CEST)
Received: from ask.diku.dk (ask.diku.dk [130.225.96.225])
	by nhugin.diku.dk (Postfix) with ESMTP
	id 7AE3D6DF835; Sun, 13 Sep 2009 17:12:17 +0200 (CEST)
Received: by ask.diku.dk (Postfix, from userid 3767)
	id C6AE9F35A; Sun, 13 Sep 2009 17:14:06 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by ask.diku.dk (Postfix) with ESMTP id BF1A9F0AB;
	Sun, 13 Sep 2009 17:14:06 +0200 (CEST)
Date:	Sun, 13 Sep 2009 17:14:06 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
In-Reply-To: <20090913.232548.253168283.anemo@mba.ocn.ne.jp>
Message-ID: <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
 <20090913.232548.253168283.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24025
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

On Sun, 13 Sep 2009, Atsushi Nemoto wrote:

> On Fri, 11 Sep 2009 18:21:00 +0200 (CEST), Julia Lawall <julia@diku.dk> wrote:
> > From: Julia Lawall <julia@diku.dk>
> > 
> > Error handling code following a kzalloc should free the allocated data.
> > Error handling code following an ioremap should iounmap the allocated data.
> > 
> > The semantic match that finds the first problem is as follows:
> > (http://www.emn.fr/x-info/coccinelle/)
> 
> Thank you for finding this out.
> 
> This patch add some correctness, but obviously incomplete: there are
> more error pathes without iounmap/kfree/etc. in this function.

The only other error path that I see is:

       pdev = platform_device_alloc("leds-gpio", basenum);
        if (!pdev)
                return;

But at that point the call gpiochip_add(&iocled->chip) has already 
succeeded.  From looking at this function, I have the impression that it 
makes the iocled structure available from a global array, gpio_desc.  
Since the function containing the above code doesn't return any error 
code, perhaps the caller will not know whether this platform_device_alloc 
error occurred or not.  There would also be at least the problem of 
getting the pointer out of the gpio_desc structure.  I guess this could be 
done with gpiochip_remove?

I can certainly make a new patch using the goto style, but let me know 
what to do about the above issue.

thanks,
julia


> And I like goto-style cleanup, as Mark Brown said in reply for your
> sound/soc patch.
> 
> Could you make a new patch?
> 
> ---
> Atsushi Nemoto
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

From anemo@mba.ocn.ne.jp Sun Sep 13 17:33:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 13 Sep 2009 17:33:36 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:52780 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1492765AbZIMPda (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 13 Sep 2009 17:33:30 +0200
Received: from localhost (p5010-ipad310funabasi.chiba.ocn.ne.jp [123.217.207.10])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 3059D66CA; Mon, 14 Sep 2009 00:33:21 +0900 (JST)
Date:	Mon, 14 Sep 2009 00:33:21 +0900 (JST)
Message-Id: <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
To:	julia@diku.dk
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
	<20090913.232548.253168283.anemo@mba.ocn.ne.jp>
	<Pine.LNX.4.64.0909131708190.25903@ask.diku.dk>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 5.2 on Emacs 22.2 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24026
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

On Sun, 13 Sep 2009 17:14:06 +0200 (CEST), Julia Lawall <julia@diku.dk> wrote:
> > This patch add some correctness, but obviously incomplete: there are
> > more error pathes without iounmap/kfree/etc. in this function.
> 
> The only other error path that I see is:
> 
>        pdev = platform_device_alloc("leds-gpio", basenum);
>         if (!pdev)
>                 return;
> 
> But at that point the call gpiochip_add(&iocled->chip) has already 
> succeeded.  From looking at this function, I have the impression that it 
> makes the iocled structure available from a global array, gpio_desc.  
> Since the function containing the above code doesn't return any error 
> code, perhaps the caller will not know whether this platform_device_alloc 
> error occurred or not.  There would also be at least the problem of 
> getting the pointer out of the gpio_desc structure.  I guess this could be 
> done with gpiochip_remove?
> 
> I can certainly make a new patch using the goto style, but let me know 
> what to do about the above issue.

Yes, this gpiochip is only used by leds-gpio driver.  So
gpiochip_remove() would be the right thing to do when something
failed.

Also there is one another error path: platform_device_add() failure at
the end of this function.

Thanks.
---
Atsushi Nemoto

From julia@diku.dk Sun Sep 13 17:49:42 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 13 Sep 2009 17:49:48 +0200 (CEST)
Received: from mgw2.diku.dk ([130.225.96.92]:42942 "EHLO mgw2.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492783AbZIMPtm (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 13 Sep 2009 17:49:42 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw2.diku.dk (Postfix) with ESMTP id B758719BB3D;
	Sun, 13 Sep 2009 17:49:41 +0200 (CEST)
Received: from mgw2.diku.dk ([127.0.0.1])
 by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
 id 31179-14; Sun, 13 Sep 2009 17:49:40 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw2.diku.dk (Postfix) with ESMTP id 7B73719BB3B;
	Sun, 13 Sep 2009 17:49:40 +0200 (CEST)
Received: from ask.diku.dk (ask.diku.dk [130.225.96.225])
	by nhugin.diku.dk (Postfix) with ESMTP
	id 067166DF84F; Sun, 13 Sep 2009 17:47:51 +0200 (CEST)
Received: by ask.diku.dk (Postfix, from userid 3767)
	id 5D812F35C; Sun, 13 Sep 2009 17:49:40 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by ask.diku.dk (Postfix) with ESMTP id 5525FF017;
	Sun, 13 Sep 2009 17:49:40 +0200 (CEST)
Date:	Sun, 13 Sep 2009 17:49:40 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
In-Reply-To: <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
Message-ID: <Pine.LNX.4.64.0909131749150.25903@ask.diku.dk>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
 <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk>
 <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Virus-Scanned: amavisd-new at diku.dk
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24027
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

On Mon, 14 Sep 2009, Atsushi Nemoto wrote:

> On Sun, 13 Sep 2009 17:14:06 +0200 (CEST), Julia Lawall <julia@diku.dk> wrote:
> > > This patch add some correctness, but obviously incomplete: there are
> > > more error pathes without iounmap/kfree/etc. in this function.
> > 
> > The only other error path that I see is:
> > 
> >        pdev = platform_device_alloc("leds-gpio", basenum);
> >         if (!pdev)
> >                 return;
> > 
> > But at that point the call gpiochip_add(&iocled->chip) has already 
> > succeeded.  From looking at this function, I have the impression that it 
> > makes the iocled structure available from a global array, gpio_desc.  
> > Since the function containing the above code doesn't return any error 
> > code, perhaps the caller will not know whether this platform_device_alloc 
> > error occurred or not.  There would also be at least the problem of 
> > getting the pointer out of the gpio_desc structure.  I guess this could be 
> > done with gpiochip_remove?
> > 
> > I can certainly make a new patch using the goto style, but let me know 
> > what to do about the above issue.
> 
> Yes, this gpiochip is only used by leds-gpio driver.  So
> gpiochip_remove() would be the right thing to do when something
> failed.
> 
> Also there is one another error path: platform_device_add() failure at
> the end of this function.

OK, I see.  I will submit an improved patch.  Thanks for the explanations.

julia

From julia@diku.dk Sun Sep 13 21:15:24 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 13 Sep 2009 21:15:34 +0200 (CEST)
Received: from mgw2.diku.dk ([130.225.96.92]:39212 "EHLO mgw2.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492742AbZIMTPY (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sun, 13 Sep 2009 21:15:24 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw2.diku.dk (Postfix) with ESMTP id CFDB019BB43;
	Sun, 13 Sep 2009 21:15:19 +0200 (CEST)
Received: from mgw2.diku.dk ([127.0.0.1])
 by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
 id 00978-02; Sun, 13 Sep 2009 21:15:18 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw2.diku.dk (Postfix) with ESMTP id 8350019BB21;
	Sun, 13 Sep 2009 21:15:18 +0200 (CEST)
Received: from ask.diku.dk (ask.diku.dk [130.225.96.225])
	by nhugin.diku.dk (Postfix) with ESMTP
	id D369E6DF835; Sun, 13 Sep 2009 21:13:28 +0200 (CEST)
Received: by ask.diku.dk (Postfix, from userid 3767)
	id 65836F362; Sun, 13 Sep 2009 21:15:18 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by ask.diku.dk (Postfix) with ESMTP id 5DD2FF0AB;
	Sun, 13 Sep 2009 21:15:18 +0200 (CEST)
Date:	Sun, 13 Sep 2009 21:15:18 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
In-Reply-To: <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
Message-ID: <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
 <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk>
 <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Virus-Scanned: amavisd-new at diku.dk
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24028
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

From: Julia Lawall <julia@diku.dk>

Error handling code following a kzalloc should free the allocated data.
Error handling code following an ioremap should iounmap the allocated data.

The semantic match that finds the first problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...x...+> }
(
x->f1 = E
|
 (x->f1 == NULL || ...)
|
 f(...,x->f1,...)
)
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
---
 arch/mips/txx9/generic/setup.c      |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index a205e2b..c860810 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -782,7 +782,7 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 		return;
 	iocled->mmioaddr = ioremap(baseaddr, 1);
 	if (!iocled->mmioaddr)
-		return;
+		goto out_free;
 	iocled->chip.get = txx9_iocled_get;
 	iocled->chip.set = txx9_iocled_set;
 	iocled->chip.direction_input = txx9_iocled_dir_in;
@@ -791,13 +791,13 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 	iocled->chip.base = basenum;
 	iocled->chip.ngpio = num;
 	if (gpiochip_add(&iocled->chip))
-		return;
+		goto out_unmap;
 	if (basenum < 0)
 		basenum = iocled->chip.base;
 
 	pdev = platform_device_alloc("leds-gpio", basenum);
 	if (!pdev)
-		return;
+		goto out_gpio;
 	iocled->pdata.num_leds = num;
 	iocled->pdata.leds = iocled->leds;
 	for (i = 0; i < num; i++) {
@@ -812,7 +812,16 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 	}
 	pdev->dev.platform_data = &iocled->pdata;
 	if (platform_device_add(pdev))
-		platform_device_put(pdev);
+		goto out_pdev;
+	return;
+out_pdev:
+	platform_device_put(pdev);
+out_gpio:
+	gpio_remove(&iocled->chip);
+out_unmap:
+	iounmap(iocled->mmioaddr);
+out_free:
+	kfree(iocled);
 }
 #else /* CONFIG_LEDS_GPIO */
 void __init txx9_iocled_init(unsigned long baseaddr,

From ralf@linux-mips.org Mon Sep 14 16:55:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 14 Sep 2009 16:55:37 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:58259 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1492834AbZINOza (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 14 Sep 2009 16:55:30 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8EEuRGN003028;
	Mon, 14 Sep 2009 16:56:28 +0200
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8EEuJOs003023;
	Mon, 14 Sep 2009 16:56:19 +0200
Date:	Mon, 14 Sep 2009 16:56:18 +0200
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Julia Lawall <julia@diku.dk>
Cc:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
Message-ID: <20090914145618.GB1934@linux-mips.org>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk> <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk> <20090914.003321.160496287.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24029
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Sun, Sep 13, 2009 at 09:15:18PM +0200, Julia Lawall wrote:

> From: Julia Lawall <julia@diku.dk>
> 
> Error handling code following a kzalloc should free the allocated data.
> Error handling code following an ioremap should iounmap the allocated data.
> 
> The semantic match that finds the first problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)

Guess this one looks right, applied.

Thanks,

  Ralf

From David.Daney@caviumnetworks.com Mon Sep 14 17:40:39 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 14 Sep 2009 17:40:46 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:17030 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492834AbZINPkj (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 14 Sep 2009 17:40:39 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4aae63e50000>; Mon, 14 Sep 2009 08:40:21 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 14 Sep 2009 08:40:25 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 14 Sep 2009 08:40:24 -0700
Message-ID: <4AAE63E7.90909@caviumnetworks.com>
Date:	Mon, 14 Sep 2009 08:40:23 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Geert Uytterhoeven <geert@linux-m68k.org>
CC:	Michael Buesch <mb@bu3sch.de>, linuxppc-dev@lists.ozlabs.org,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	linux-mips@linux-mips.org,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>,
	"H. Peter Anvin" <hpa@zytor.com>, linux-s390@vger.kernel.org,
	linux-am33-list@redhat.com, Helge Deller <deller@gmx.de>,
	x86@kernel.org, Ingo Molnar <mingo@redhat.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	uclinux-dist-devel@blackfin.uclinux.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Richard Henderson <rth@twiddle.net>,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org,
	ralf@linux-mips.org, Kyle McMartin <kyle@mcmartin.ca>,
	linux-alpha@vger.kernel.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	linux390@de.ibm.com,
	Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Subject: Re: [PATCH 01/10] Add support for GCC-4.5's __builtin_unreachable()
 	to compiler.h
References: <4AA991C1.1050800@caviumnetworks.com>	 <1252627011-2933-1-git-send-email-ddaney@caviumnetworks.com>	 <200909111633.00665.mb@bu3sch.de>	 <4AAA73A4.9010601@caviumnetworks.com> <10f740e80909120022m72ad5ea7t692fba93cd3114e9@mail.gmail.com>
In-Reply-To: <10f740e80909120022m72ad5ea7t692fba93cd3114e9@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 14 Sep 2009 15:40:24.0988 (UTC) FILETIME=[AD5125C0:01CA3551]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24030
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Geert Uytterhoeven wrote:
> On Fri, Sep 11, 2009 at 17:58, David Daney<ddaney@caviumnetworks.com> wrote:
>> Michael Buesch wrote:
>>> On Friday 11 September 2009 01:56:42 David Daney wrote:
>>>> +/* Unreachable code */
>>>> +#ifndef unreachable
>>>> +# define unreachable() do { for (;;) ; } while (0)
>>>> +#endif
>>> # define unreachable() do { } while (1)
>>>
>>> ? :)
>> Clearly I was not thinking clearly when I wrote that part.  RTH noted the
>> same thing.  I will fix it.
> 
> However, people are so used to seeing the `do { } while (0)' idiom,
> that they might miss
> there's a `1' here, not a `0'.
> 
> So perhaps it's better to use plain `for (;;)' for infinite loops?
> 

I don't think so.  The only valid token that can follow 'do { } while 
(1)' is ';', any statement may follow 'for (;;)', so there is a greater 
possibility to silently screw things up with the for(;;) form.

David Daney


From David.Daney@caviumnetworks.com Mon Sep 14 23:51:29 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 14 Sep 2009 23:51:36 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:9324 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S2097347AbZINVvV (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 14 Sep 2009 23:51:21 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4aaebac20000>; Mon, 14 Sep 2009 14:50:58 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 14 Sep 2009 14:50:59 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Mon, 14 Sep 2009 14:50:59 -0700
Message-ID: <4AAEBAC2.1050905@caviumnetworks.com>
Date:	Mon, 14 Sep 2009 14:50:58 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
CC:	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>, x86@kernel.org,
	ralf@linux-mips.org, linux-mips@linux-mips.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	linux390@de.ibm.com, linux-s390@vger.kernel.org,
	David Howells <dhowells@redhat.com>,
	Koichi Yasutake <yasutake.koichi@jp.panasonic.com>,
	linux-am33-list@redhat.com, Kyle McMartin <kyle@mcmartin.ca>,
	Helge Deller <deller@gmx.de>, linux-parisc@vger.kernel.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Paul Mackerras <paulus@samba.org>, linuxppc-dev@ozlabs.org,
	Richard Henderson <rth@twiddle.net>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	linux-alpha@vger.kernel.org,
	Haavard Skinnemoen <hskinnemoen@atmel.com>,
	Mike Frysinger <vapier@gentoo.org>,
	uclinux-dist-devel@blackfin.uclinux.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-arch@vger.kernel.org, Roland McGrath <roland@redhat.com>
Subject: [PATCH 00/11] Add support for GCC's __builtin_unreachable() and use
 it in BUG (v2).
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 14 Sep 2009 21:50:59.0414 (UTC) FILETIME=[72114F60:01CA3585]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24031
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

When I sent the first version, I had not realized that Roland McGrath
had only a day or two earlier submitted a very similar patch (although
one that only fixed up the x86 case).

I have been working on this quite a while now, starting with adding
the required support to GCC, so with an eye towards finishing it up I
have this new version.

 From the announcement of the first version:

Starting with version 4.5, GCC has a new built-in function called
__builtin_unreachable().  The function tells the compiler that control
flow will never reach that point.  Currently we trick the compiler by
putting in for(;;); but this has the disadvantage that extra code is
emitted for an endless loop.  For an i386 kernel using
__builtin_unreachable() results in an defaultconfig that is nearly 4000
bytes smaller.

This patch set adds support to compiler.h creating a
new macro usable in the kernel called unreachable().  If the compiler
lacks __builtin_unreachable(), it just expands to for(;;).

The x86 and MIPS patches I actually tested with a GCC-4.5 snapshot.
Lacking the ability to test the rest of the architectures, I just did
what seemed right without even trying to compile the kernel.

For version 2:

I fixed a couple of checkpatch issues, and simplified the
unreachable() macro for the pre-GCC-4.5 case (as suggested by Richard
Henderson).  Also several Acked-by: were added.

New in this version (as suggested by Ingo Molnar) I added 11/11 which
uses unreachable() in asm-generic/bug.h for !CONFIG_BUG case.  This
one may be a little controversial as it will end up making code
slightly larger when !CONFIG_BUG and you are using a pre-GCC-4.5
compiler.

I will reply with the 11 patches.

David Daney (11):
   Add support for GCC-4.5's __builtin_unreachable() to compiler.h (v2)
   x86: Convert BUG() to use unreachable()
   MIPS: Convert BUG() to use unreachable()
   s390: Convert BUG() to use unreachable()
   mn10300: Convert BUG() to use unreachable()
   parisc: Convert BUG() to use unreachable()
   powerpc: Convert BUG() to use unreachable()
   alpha: Convert BUG() to use unreachable()
   avr32: Convert BUG() to use unreachable()
   blackfin: Convert BUG() to use unreachable()
   Use unreachable() in asm-generic/bug.h for !CONFIG_BUG case.

  arch/alpha/include/asm/bug.h    |    3 ++-
  arch/avr32/include/asm/bug.h    |    2 +-
  arch/blackfin/include/asm/bug.h |    2 +-
  arch/mips/include/asm/bug.h     |    4 +---
  arch/mn10300/include/asm/bug.h  |    3 ++-
  arch/parisc/include/asm/bug.h   |    4 ++--
  arch/powerpc/include/asm/bug.h  |    2 +-
  arch/s390/include/asm/bug.h     |    2 +-
  arch/x86/include/asm/bug.h      |    4 ++--
  include/asm-generic/bug.h       |    4 ++--
  include/linux/compiler-gcc4.h   |   14 ++++++++++++++
  include/linux/compiler.h        |    5 +++++
  12 files changed, 34 insertions(+), 15 deletions(-)


From julia@diku.dk Tue Sep 15 07:03:49 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 15 Sep 2009 07:03:55 +0200 (CEST)
Received: from mgw1.diku.dk ([130.225.96.91]:47466 "EHLO mgw1.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1491879AbZIOFDt (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 15 Sep 2009 07:03:49 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw1.diku.dk (Postfix) with ESMTP id BAE1B52C3C5;
	Tue, 15 Sep 2009 07:03:43 +0200 (CEST)
X-Virus-Scanned: amavisd-new at diku.dk
Received: from mgw1.diku.dk ([127.0.0.1])
	by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id tqSW4wq9EoWG; Tue, 15 Sep 2009 07:03:42 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw1.diku.dk (Postfix) with ESMTP id 7C21452C3C3;
	Tue, 15 Sep 2009 07:03:42 +0200 (CEST)
Received: from ask.diku.dk (ask.diku.dk [130.225.96.225])
	by nhugin.diku.dk (Postfix) with ESMTP
	id E39DB6DF823; Tue, 15 Sep 2009 07:01:50 +0200 (CEST)
Received: by ask.diku.dk (Postfix, from userid 3767)
	id 5D9FBF3A6; Tue, 15 Sep 2009 07:03:42 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by ask.diku.dk (Postfix) with ESMTP id 530F5F0AB;
	Tue, 15 Sep 2009 07:03:42 +0200 (CEST)
Date:	Tue, 15 Sep 2009 07:03:42 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
In-Reply-To: <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
Message-ID: <Pine.LNX.4.64.0909150701170.11392@ask.diku.dk>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
 <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk>
 <20090914.003321.160496287.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24032
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

> +out_pdev:
> +	platform_device_put(pdev);
> +out_gpio:
> +	gpio_remove(&iocled->chip);

I just noticed that the prototype of gpio_remove has __must_check
I don't think there is anything to check here; since the thing is not 
fully initialized here, it is unlikely to be busy.  Should there be (void) 
in front of it?

julia

From ralf.roesch@rw-gmbh.de Tue Sep 15 16:02:07 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 15 Sep 2009 16:02:13 +0200 (CEST)
Received: from rs1.rw-gmbh.net ([213.239.201.58]:53077 "EHLO rs1.rw-gmbh.net"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492235AbZIOOCH (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 15 Sep 2009 16:02:07 +0200
Received: from p50992dee.dip0.t-ipconnect.de ([80.153.45.238] helo=ximap.rw-gmbh.biz)
	by rs1.rw-gmbh.net with esmtp (Exim 4.69)
	(envelope-from <ralf.roesch@rw-gmbh.de>)
	id 1MnYbb-0002nN-SR; Tue, 15 Sep 2009 16:02:04 +0200
Received: from [192.168.178.44] (rr-2600 [192.168.178.44])
	by ximap.rw-gmbh.biz (Postfix) with ESMTP
	id 5B13F174B2E; Tue, 15 Sep 2009 16:04:31 +0200 (CEST)
Message-ID: <4AAF9E5B.5040909@rw-gmbh.de>
Date:	Tue, 15 Sep 2009 16:02:03 +0200
From:	=?windows-1252?Q?Ralf_R=F6sch?= <ralf.roesch@rw-gmbh.de>
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
MIME-Version: 1.0
To:	Julia Lawall <julia@diku.dk>
Cc:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, ralf@linux-mips.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk> <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk> <20090914.003321.160496287.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
In-Reply-To: <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 8bit
Return-Path: <ralf.roesch@rw-gmbh.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24033
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf.roesch@rw-gmbh.de
Precedence: bulk
X-list: linux-mips

The gpio_remove is missing:
  arch/mips/txx9/generic/setup.c:838: error: implicit declaration of function ‘gpio_remove’

Should it be gpiochip_remove() instead?

--
Ralf Roesch


The Julia Lawall schrieb:
> From: Julia Lawall <julia@diku.dk>
>
> Error handling code following a kzalloc should free the allocated data.
> Error handling code following an ioremap should iounmap the allocated data.
>
> The semantic match that finds the first problem is as follows:
> (http://www.emn.fr/x-info/coccinelle/)
>
> // <smpl>
> @r exists@
> local idexpression x;
> statement S;
> expression E;
> identifier f,f1,l;
> position p1,p2;
> expression *ptr != NULL;
> @@
>
> x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
> ...
> if (x == NULL) S
> <... when != x
>      when != if (...) { <+...x...+> }
> (
> x->f1 = E
> |
>  (x->f1 == NULL || ...)
> |
>  f(...,x->f1,...)
> )
> ...>
> (
>  return \(0\|<+...x...+>\|ptr\);
> |
>  return@p2 ...;
> )
>
> @script:python@
> p1 << r.p1;
> p2 << r.p2;
> @@
>
> print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
> // </smpl>
>
> Signed-off-by: Julia Lawall <julia@diku.dk>
> ---
>  arch/mips/txx9/generic/setup.c      |   17 +++++++++++++----
>  1 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
> index a205e2b..c860810 100644
> --- a/arch/mips/txx9/generic/setup.c
> +++ b/arch/mips/txx9/generic/setup.c
> @@ -782,7 +782,7 @@ void __init txx9_iocled_init(unsigned long baseaddr,
>  		return;
>  	iocled->mmioaddr = ioremap(baseaddr, 1);
>  	if (!iocled->mmioaddr)
> -		return;
> +		goto out_free;
>  	iocled->chip.get = txx9_iocled_get;
>  	iocled->chip.set = txx9_iocled_set;
>  	iocled->chip.direction_input = txx9_iocled_dir_in;
> @@ -791,13 +791,13 @@ void __init txx9_iocled_init(unsigned long baseaddr,
>  	iocled->chip.base = basenum;
>  	iocled->chip.ngpio = num;
>  	if (gpiochip_add(&iocled->chip))
> -		return;
> +		goto out_unmap;
>  	if (basenum < 0)
>  		basenum = iocled->chip.base;
>  
>  	pdev = platform_device_alloc("leds-gpio", basenum);
>  	if (!pdev)
> -		return;
> +		goto out_gpio;
>  	iocled->pdata.num_leds = num;
>  	iocled->pdata.leds = iocled->leds;
>  	for (i = 0; i < num; i++) {
> @@ -812,7 +812,16 @@ void __init txx9_iocled_init(unsigned long baseaddr,
>  	}
>  	pdev->dev.platform_data = &iocled->pdata;
>  	if (platform_device_add(pdev))
> -		platform_device_put(pdev);
> +		goto out_pdev;
> +	return;
> +out_pdev:
> +	platform_device_put(pdev);
> +out_gpio:
> +	gpio_remove(&iocled->chip);
> +out_unmap:
> +	iounmap(iocled->mmioaddr);
> +out_free:
> +	kfree(iocled);
>  }
>  #else /* CONFIG_LEDS_GPIO */
>  void __init txx9_iocled_init(unsigned long baseaddr,
>
>   


From julia@diku.dk Tue Sep 15 16:35:31 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 15 Sep 2009 16:35:39 +0200 (CEST)
Received: from mgw1.diku.dk ([130.225.96.91]:54290 "EHLO mgw1.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492725AbZIOOfb (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 15 Sep 2009 16:35:31 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw1.diku.dk (Postfix) with ESMTP id 8563E52C47B;
	Tue, 15 Sep 2009 16:35:28 +0200 (CEST)
X-Virus-Scanned: amavisd-new at diku.dk
Received: from mgw1.diku.dk ([127.0.0.1])
	by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 1acEjmLDqTIZ; Tue, 15 Sep 2009 16:35:26 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw1.diku.dk (Postfix) with ESMTP id CA6F752C3C3;
	Tue, 15 Sep 2009 16:35:26 +0200 (CEST)
Received: from pc-004.diku.dk (pc-004.diku.dk [130.225.97.4])
	by nhugin.diku.dk (Postfix) with ESMTP
	id 932496DF823; Tue, 15 Sep 2009 16:33:34 +0200 (CEST)
Received: by pc-004.diku.dk (Postfix, from userid 3767)
	id 9472C383F5; Tue, 15 Sep 2009 16:35:26 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by pc-004.diku.dk (Postfix) with ESMTP id 8FE7238330;
	Tue, 15 Sep 2009 16:35:26 +0200 (CEST)
Date:	Tue, 15 Sep 2009 16:35:26 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	=?windows-1252?Q?Ralf_R=F6sch?= <ralf.roesch@rw-gmbh.de>
Cc:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>, ralf@linux-mips.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
In-Reply-To: <4AAF9E5B.5040909@rw-gmbh.de>
Message-ID: <Pine.LNX.4.64.0909151634030.8549@pc-004.diku.dk>
References: <Pine.LNX.4.64.0909111820370.10552@pc-004.diku.dk>
 <20090913.232548.253168283.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909131708190.25903@ask.diku.dk>
 <20090914.003321.160496287.anemo@mba.ocn.ne.jp> <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
 <4AAF9E5B.5040909@rw-gmbh.de>
MIME-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="-511572895-1888724175-1253025326=:8549"
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24034
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---511572895-1888724175-1253025326=:8549
Content-Type: TEXT/PLAIN; charset=iso-8859-1
Content-Transfer-Encoding: 8BIT

On Tue, 15 Sep 2009, Ralf Rösch wrote:

> The gpio_remove is missing:
>  arch/mips/txx9/generic/setup.c:838: error: implicit declaration of function
>  ?gpio_remove?
> 
> Should it be gpiochip_remove() instead?

Oops, sorry about that.  That is indeed the function I was looking at.

I can submit a revised patch, but I sent another question asking about 
whether something should be done about the fact that gpiochip_remove is 
declared as follows:

extern int __must_check gpiochip_remove(struct gpio_chip *chip);

I don't think the call can fail at this point, but should something be 
done to avoid a compiler warning?

thanks,
julia


> --
> Ralf Roesch
> 
> 
> The Julia Lawall schrieb:
> > From: Julia Lawall <julia@diku.dk>
> >
> > Error handling code following a kzalloc should free the allocated data.
> > Error handling code following an ioremap should iounmap the allocated data.
> >
> > The semantic match that finds the first problem is as follows:
> > (http://www.emn.fr/x-info/coccinelle/)
> >
> > // <smpl>
> > @r exists@
> > local idexpression x;
> > statement S;
> > expression E;
> > identifier f,f1,l;
> > position p1,p2;
> > expression *ptr != NULL;
> > @@
> >
> > x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
> > ...
> > if (x == NULL) S
> > <... when != x
> >      when != if (...) { <+...x...+> }
> > (
> > x->f1 = E
> > |
> >  (x->f1 == NULL || ...)
> > |
> >  f(...,x->f1,...)
> > )
> > ...>
> > (
> >  return \(0\|<+...x...+>\|ptr\);
> > |
> >  return@p2 ...;
> > )
> >
> > @script:python@
> > p1 << r.p1;
> > p2 << r.p2;
> > @@
> >
> > print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <julia@diku.dk>
> > ---
> >  arch/mips/txx9/generic/setup.c      |   17 +++++++++++++----
> >  1 files changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
> > index a205e2b..c860810 100644
> > --- a/arch/mips/txx9/generic/setup.c
> > +++ b/arch/mips/txx9/generic/setup.c
> > @@ -782,7 +782,7 @@ void __init txx9_iocled_init(unsigned long baseaddr,
> >   	return;
> >   iocled->mmioaddr = ioremap(baseaddr, 1);
> >   if (!iocled->mmioaddr)
> > -		return;
> > +		goto out_free;
> >   iocled->chip.get = txx9_iocled_get;
> >   iocled->chip.set = txx9_iocled_set;
> >   iocled->chip.direction_input = txx9_iocled_dir_in;
> > @@ -791,13 +791,13 @@ void __init txx9_iocled_init(unsigned long baseaddr,
> >   iocled->chip.base = basenum;
> >   iocled->chip.ngpio = num;
> >   if (gpiochip_add(&iocled->chip))
> > -		return;
> > +		goto out_unmap;
> >   if (basenum < 0)
> >    basenum = iocled->chip.base;
> >  
> >   pdev = platform_device_alloc("leds-gpio", basenum);
> >   if (!pdev)
> > -		return;
> > +		goto out_gpio;
> >   iocled->pdata.num_leds = num;
> >   iocled->pdata.leds = iocled->leds;
> >   for (i = 0; i < num; i++) {
> > @@ -812,7 +812,16 @@ void __init txx9_iocled_init(unsigned long baseaddr,
> >   }
> >   pdev->dev.platform_data = &iocled->pdata;
> >   if (platform_device_add(pdev))
> > -		platform_device_put(pdev);
> > +		goto out_pdev;
> > +	return;
> > +out_pdev:
> > +	platform_device_put(pdev);
> > +out_gpio:
> > +	gpio_remove(&iocled->chip);
> > +out_unmap:
> > +	iounmap(iocled->mmioaddr);
> > +out_free:
> > +	kfree(iocled);
> >  }
> >  #else /* CONFIG_LEDS_GPIO */
> >  void __init txx9_iocled_init(unsigned long baseaddr,
> >
> >   
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
---511572895-1888724175-1253025326=:8549--

From anemo@mba.ocn.ne.jp Tue Sep 15 17:45:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 15 Sep 2009 17:45:37 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:57215 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1493136AbZIOPpa (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 15 Sep 2009 17:45:30 +0200
Received: from localhost (p8092-ipad307funabasi.chiba.ocn.ne.jp [123.217.186.92])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 15FC66AE0; Wed, 16 Sep 2009 00:45:24 +0900 (JST)
Date:	Wed, 16 Sep 2009 00:45:25 +0900 (JST)
Message-Id: <20090916.004525.74746264.anemo@mba.ocn.ne.jp>
To:	julia@diku.dk
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <Pine.LNX.4.64.0909150701170.11392@ask.diku.dk>
References: <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
	<Pine.LNX.4.64.0909132113520.31000@ask.diku.dk>
	<Pine.LNX.4.64.0909150701170.11392@ask.diku.dk>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 5.2 on Emacs 22.2 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24035
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

On Tue, 15 Sep 2009 07:03:42 +0200 (CEST), Julia Lawall <julia@diku.dk> wrote:
> > +out_pdev:
> > +	platform_device_put(pdev);
> > +out_gpio:
> > +	gpio_remove(&iocled->chip);
> 
> I just noticed that the prototype of gpio_remove has __must_check
> I don't think there is anything to check here; since the thing is not 
> fully initialized here, it is unlikely to be busy.  Should there be (void) 
> in front of it?

The void casting does not silence the warning.  How about this?

	if (gpiochip_remove(&iocled->chip))
		return;

In general, memory leak would be less serious than crash or data
corruption ;)

---
Atsushi Nemoto

From julia@diku.dk Tue Sep 15 17:47:31 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 15 Sep 2009 17:47:37 +0200 (CEST)
Received: from mgw1.diku.dk ([130.225.96.91]:34420 "EHLO mgw1.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493169AbZIOPrb (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 15 Sep 2009 17:47:31 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw1.diku.dk (Postfix) with ESMTP id 0CB0652C3CD;
	Tue, 15 Sep 2009 17:47:28 +0200 (CEST)
X-Virus-Scanned: amavisd-new at diku.dk
Received: from mgw1.diku.dk ([127.0.0.1])
	by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id YLAlXk30vsnt; Tue, 15 Sep 2009 17:47:26 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw1.diku.dk (Postfix) with ESMTP id DAF5C52C3CA;
	Tue, 15 Sep 2009 17:47:26 +0200 (CEST)
Received: from pc-004.diku.dk (pc-004.diku.dk [130.225.97.4])
	by nhugin.diku.dk (Postfix) with ESMTP
	id AE1436DF835; Tue, 15 Sep 2009 17:45:34 +0200 (CEST)
Received: by pc-004.diku.dk (Postfix, from userid 3767)
	id BE1F4383F7; Tue, 15 Sep 2009 17:47:26 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by pc-004.diku.dk (Postfix) with ESMTP id BB8DA3830C;
	Tue, 15 Sep 2009 17:47:26 +0200 (CEST)
Date:	Tue, 15 Sep 2009 17:47:26 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
In-Reply-To: <20090916.004525.74746264.anemo@mba.ocn.ne.jp>
Message-ID: <Pine.LNX.4.64.0909151747120.8549@pc-004.diku.dk>
References: <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
 <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk> <Pine.LNX.4.64.0909150701170.11392@ask.diku.dk>
 <20090916.004525.74746264.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24036
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

On Wed, 16 Sep 2009, Atsushi Nemoto wrote:

> On Tue, 15 Sep 2009 07:03:42 +0200 (CEST), Julia Lawall <julia@diku.dk> wrote:
> > > +out_pdev:
> > > +	platform_device_put(pdev);
> > > +out_gpio:
> > > +	gpio_remove(&iocled->chip);
> > 
> > I just noticed that the prototype of gpio_remove has __must_check
> > I don't think there is anything to check here; since the thing is not 
> > fully initialized here, it is unlikely to be busy.  Should there be (void) 
> > in front of it?
> 
> The void casting does not silence the warning.  How about this?
> 
> 	if (gpiochip_remove(&iocled->chip))
> 		return;
> 
> In general, memory leak would be less serious than crash or data
> corruption ;)

OK, I will send an updated patch shortly.

julia

From julia@diku.dk Tue Sep 15 17:56:17 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 15 Sep 2009 17:56:27 +0200 (CEST)
Received: from mgw1.diku.dk ([130.225.96.91]:57352 "EHLO mgw1.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493136AbZIOP4R (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 15 Sep 2009 17:56:17 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw1.diku.dk (Postfix) with ESMTP id 76F7152C47F;
	Tue, 15 Sep 2009 17:56:16 +0200 (CEST)
X-Virus-Scanned: amavisd-new at diku.dk
Received: from mgw1.diku.dk ([127.0.0.1])
	by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 9+lJ4h0LRoIJ; Tue, 15 Sep 2009 17:56:15 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw1.diku.dk (Postfix) with ESMTP id 10F9152C3CD;
	Tue, 15 Sep 2009 17:56:15 +0200 (CEST)
Received: from pc-004.diku.dk (pc-004.diku.dk [130.225.97.4])
	by nhugin.diku.dk (Postfix) with ESMTP
	id D727B6DF893; Tue, 15 Sep 2009 17:54:22 +0200 (CEST)
Received: by pc-004.diku.dk (Postfix, from userid 3767)
	id EA553383F7; Tue, 15 Sep 2009 17:56:14 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by pc-004.diku.dk (Postfix) with ESMTP id E7BA83830C;
	Tue, 15 Sep 2009 17:56:14 +0200 (CEST)
Date:	Tue, 15 Sep 2009 17:56:14 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf@linux-mips.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/8] arch/mips/txx9: introduce missing kfree, iounmap
In-Reply-To: <20090916.004525.74746264.anemo@mba.ocn.ne.jp>
Message-ID: <Pine.LNX.4.64.0909151755280.8549@pc-004.diku.dk>
References: <20090914.003321.160496287.anemo@mba.ocn.ne.jp>
 <Pine.LNX.4.64.0909132113520.31000@ask.diku.dk> <Pine.LNX.4.64.0909150701170.11392@ask.diku.dk>
 <20090916.004525.74746264.anemo@mba.ocn.ne.jp>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24037
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

From: Julia Lawall <julia@diku.dk>

Error handling code following a kzalloc should free the allocated data.
Error handling code following an ioremap should iounmap the allocated data.

The semantic match that finds the first problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...x...+> }
(
x->f1 = E
|
 (x->f1 == NULL || ...)
|
 f(...,x->f1,...)
)
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
---
 arch/mips/txx9/generic/setup.c      |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index a205e2b..dfe4720 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -782,7 +782,7 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 		return;
 	iocled->mmioaddr = ioremap(baseaddr, 1);
 	if (!iocled->mmioaddr)
-		return;
+		goto out_free;
 	iocled->chip.get = txx9_iocled_get;
 	iocled->chip.set = txx9_iocled_set;
 	iocled->chip.direction_input = txx9_iocled_dir_in;
@@ -791,13 +791,13 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 	iocled->chip.base = basenum;
 	iocled->chip.ngpio = num;
 	if (gpiochip_add(&iocled->chip))
-		return;
+		goto out_unmap;
 	if (basenum < 0)
 		basenum = iocled->chip.base;
 
 	pdev = platform_device_alloc("leds-gpio", basenum);
 	if (!pdev)
-		return;
+		goto out_gpio;
 	iocled->pdata.num_leds = num;
 	iocled->pdata.leds = iocled->leds;
 	for (i = 0; i < num; i++) {
@@ -812,7 +812,17 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 	}
 	pdev->dev.platform_data = &iocled->pdata;
 	if (platform_device_add(pdev))
-		platform_device_put(pdev);
+		goto out_pdev;
+	return;
+out_pdev:
+	platform_device_put(pdev);
+out_gpio:
+	if (gpiochip_remove(&iocled->chip))
+		return;
+out_unmap:
+	iounmap(iocled->mmioaddr);
+out_free:
+	kfree(iocled);
 }
 #else /* CONFIG_LEDS_GPIO */
 void __init txx9_iocled_init(unsigned long baseaddr,

From ralf.roesch@rw-gmbh.de Wed Sep 16 08:02:50 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 16 Sep 2009 08:02:57 +0200 (CEST)
Received: from rs1.rw-gmbh.net ([213.239.201.58]:42231 "EHLO rs1.rw-gmbh.net"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492281AbZIPGCu (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 16 Sep 2009 08:02:50 +0200
Received: from pd951a7a4.dip0.t-ipconnect.de ([217.81.167.164] helo=localhost.localdomain)
	by rs1.rw-gmbh.net with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.69)
	(envelope-from <ralf.roesch@rw-gmbh.de>)
	id 1MnnbJ-0007Ss-KL
	for linux-mips@linux-mips.org; Wed, 16 Sep 2009 08:02:45 +0200
From:	Ralf Roesch <ralf.roesch@rw-gmbh.de>
To:	linux-mips@linux-mips.org
Subject: [PATCH] MIPS: TXx9: Fix error handling / Fix for noenexisting gpio_remove.
Date:	Wed, 16 Sep 2009 08:01:20 +0200
Message-Id: <1253080880-11123-1-git-send-email-ralf.roesch@rw-gmbh.de>
X-Mailer: git-send-email 1.6.3.3
Return-Path: <ralf.roesch@rw-gmbh.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24038
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf.roesch@rw-gmbh.de
Precedence: bulk
X-list: linux-mips

error was introduced by commit 0385d1f3d394c6814be0b165c153fc3fc254469a

Signed-off-by: Ralf Roesch <ralf.roesch@rw-gmbh.de>
---
 arch/mips/txx9/generic/setup.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index ed794c1..cff5578 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -835,7 +835,8 @@ void __init txx9_iocled_init(unsigned long baseaddr,
 out_pdev:
 	platform_device_put(pdev);
 out_gpio:
-	gpio_remove(&iocled->chip);
+	if (gpiochip_remove(&iocled->chip))
+		return;
 out_unmap:
 	iounmap(iocled->mmioaddr);
 out_free:
-- 
1.6.3.3


From f.fainelli@gmail.com Wed Sep 16 09:44:32 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 16 Sep 2009 09:44:39 +0200 (CEST)
Received: from mail-ew0-f225.google.com ([209.85.219.225]:47011 "EHLO
	mail-ew0-f225.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492332AbZIPHoc (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 16 Sep 2009 09:44:32 +0200
Received: by ewy25 with SMTP id 25so2661666ewy.33
        for <multiple recipients>; Wed, 16 Sep 2009 00:44:26 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:sender:from:date:subject
         :mime-version:x-uid:x-length:to:cc:reply-to:content-type
         :content-transfer-encoding:content-disposition:message-id;
        bh=Cw+xT34KFmUivnBW/b8v75D8NsJRkAkyiNXMeKSkw+s=;
        b=tHipxmEzgyRhQLPR/wnlGMV08z8CdzWQkcFfGIJAks/FXyLSE0INTxX3EC3nyffrND
         45iqoNBLfkkAsT9sJRWhz3YvKCMnmY/DpWFB42Z6R4mc0bEGD+eiS1I2b3TrfMpGjeLR
         sJmDg70Q0Emj4s4jYmCYBcyCdFJTyVfNt+9K8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=sender:from:date:subject:mime-version:x-uid:x-length:to:cc:reply-to
         :content-type:content-transfer-encoding:content-disposition
         :message-id;
        b=CjbbFXH5KZim/ElLiwzwhsXtQXFI6syZlKbZWoC9kgTpj3dvIpYk4iDn09EUQT7jRm
         2dSxaZUSHrOCkzffqWyhsD7IcWr6A4aV/8q3+3mW40GBVEFUYB88wmFyGTgOLenOY8vL
         F5+exVBAr7SW59zelR/qXz18VN82FQHQeZDA8=
Received: by 10.211.130.6 with SMTP id h6mr9446899ebn.97.1253087066595;
        Wed, 16 Sep 2009 00:44:26 -0700 (PDT)
Received: from lenovo.localnet (147.59.76-86.rev.gaoland.net [86.76.59.147])
        by mx.google.com with ESMTPS id 10sm1320657eyd.24.2009.09.16.00.44.25
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Wed, 16 Sep 2009 00:44:25 -0700 (PDT)
From:	Florian Fainelli <florian@openwrt.org>
Date:	Wed, 16 Sep 2009 09:44:22 +0200
Subject: [PATCH] cpmac: fix compilation errors against undeclared BUS_ID_SIZE
MIME-Version: 1.0
X-UID:	1380
X-Length: 3115
To:	David Miller <davem@davemloft.net>
Cc:	netdev@vger.kernel.org, Ralf Baechle <ralf@linux-mips.org>,
	linux-mips@linux-mips.org
Reply-To: Florian Fainelli <florian@openwrt.org>
Content-Type: text/plain;
  charset="utf-8"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200909160944.24265.florian@openwrt.org>
Return-Path: <f.fainelli@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24039
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: florian@openwrt.org
Precedence: bulk
X-list: linux-mips

Hi David,

This is relevant for 2.6.32-rc0, thanks !
--
From: Florian Fainelli <florian@openwrt.org>
Subject: [PATCH] cpmac: fix compilation errors against undeclared BUS_ID_SIZE

With the removal of BUS_ID_SIZE, cpmac was not fully
converted to use MII_BUS_ID_SIZE as it ought to. This
patch fixes the following cpmac build failure:
 CC      drivers/net/cpmac.o
drivers/net/cpmac.c: In function 'cpmac_start_xmit':
drivers/net/cpmac.c:563: warning: comparison of distinct pointer types lacks a cast
drivers/net/cpmac.c: In function 'cpmac_probe':
drivers/net/cpmac.c:1112: error: 'BUS_ID_SIZE' undeclared (first use in this function)
drivers/net/cpmac.c:1112: error: (Each undeclared identifier is reported only once
drivers/net/cpmac.c:1112: error: for each function it appears in.)

Reported-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Florian Fainelli <florian@openwrt.org>
---
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
index 3e3fab8..61f9da2 100644
--- a/drivers/net/cpmac.c
+++ b/drivers/net/cpmac.c
@@ -1109,7 +1109,7 @@ static int external_switch;
 static int __devinit cpmac_probe(struct platform_device *pdev)
 {
 	int rc, phy_id;
-	char mdio_bus_id[BUS_ID_SIZE];
+	char mdio_bus_id[MII_BUS_ID_SIZE];
 	struct resource *mem;
 	struct cpmac_priv *priv;
 	struct net_device *dev;
@@ -1118,7 +1118,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 	pdata = pdev->dev.platform_data;
 
 	if (external_switch || dumb_switch) {
-		strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
+		strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */
 		phy_id = pdev->id;
 	} else {
 		for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
@@ -1126,7 +1126,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 				continue;
 			if (!cpmac_mii->phy_map[phy_id])
 				continue;
-			strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE);
+			strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE);
 			break;
 		}
 	}
@@ -1167,7 +1167,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev)
 	priv->msg_enable = netif_msg_init(debug_level, 0xff);
 	memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
 
-	snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
+	snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
 
 	priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
 						PHY_INTERFACE_MODE_MII);



From David.Daney@caviumnetworks.com Wed Sep 16 20:10:13 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 16 Sep 2009 20:10:20 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:10272 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S2097307AbZIPSKK (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 16 Sep 2009 20:10:10 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4ab129f00000>; Wed, 16 Sep 2009 11:09:52 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 16 Sep 2009 11:09:36 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 16 Sep 2009 11:09:36 -0700
Message-ID: <4AB129DF.8060200@caviumnetworks.com>
Date:	Wed, 16 Sep 2009 11:09:35 -0700
From:	David Daney <ddaney@caviumnetworks.com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090320)
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
CC:	linux-mips@linux-mips.org
Subject: Re: [PATCH] MIPS: Don't write ones to reserved entryhi bits.
References: <1241812330-21041-1-git-send-email-ddaney@caviumnetworks.com> <20090527162937.GA9831@linux-mips.org>
In-Reply-To: <20090527162937.GA9831@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-OriginalArrivalTime: 16 Sep 2009 18:09:36.0381 (UTC) FILETIME=[D996D2D0:01CA36F8]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24040
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

Ralf Baechle wrote:
> On Fri, May 08, 2009 at 12:52:10PM -0700, David Daney wrote:
> 
>> According to the MIPS64 Privileged Resource Architecture manual, only
>> values of zero may be written to bits 8..10 of CP0 entryhi.  We need
>> to add masking by ASID_MASK.
> 
> Yes, I've silently been relying on the hardware chopping off the excess
> bits for no better reason that it saving an instruction.  One of the
> functions you've touched is switch_mm() which is being used in context
> switches and any changes to it will show up in context switching
> benchmarks.
> 
> The patch you did (and along with that some older SMTC changes by Kevin)
> can be done slightly more elegant because we already have:
> 
> #define cpu_asid(cpu, mm)       (cpu_context((cpu), (mm)) & ASID_MASK)
> 
> in <asm/mmu_context.h>.
> 
> We used to optimize the ASID managment code by code patching even, see
> mmu_context.h in 78c388aed2b7184182c08428db1de6c872d815f5.
> 
>   Ralf
> 
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
> 

This is nice, but you never committed it.

David Daney.



>  arch/mips/include/asm/mmu_context.h |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/mips/include/asm/mmu_context.h b/arch/mips/include/asm/mmu_context.h
> index d7f3eb0..25a50fa 100644
> --- a/arch/mips/include/asm/mmu_context.h
> +++ b/arch/mips/include/asm/mmu_context.h
> @@ -164,12 +164,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
>  	 * having ASID_MASK smaller than the hardware maximum,
>  	 * make sure no "soft" bits become "hard"...
>  	 */
> -	write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK)
> -			| (cpu_context(cpu, next) & ASID_MASK));
> +	write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK) |
> +			 cpu_asid(cpu, next));
>  	ehb(); /* Make sure it propagates to TCStatus */
>  	evpe(mtflags);
>  #else
> -	write_c0_entryhi(cpu_context(cpu, next));
> +	write_c0_entryhi(cpu_asid(cpu, next));
>  #endif /* CONFIG_MIPS_MT_SMTC */
>  	TLBMISS_HANDLER_SETUP_PGD(next->pgd);
>  
> @@ -225,11 +225,11 @@ activate_mm(struct mm_struct *prev, struct mm_struct *next)
>  	}
>  	/* See comments for similar code above */
>  	write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK) |
> -	                 (cpu_context(cpu, next) & ASID_MASK));
> +	                 cpu_asid(cpu, next));
>  	ehb(); /* Make sure it propagates to TCStatus */
>  	evpe(mtflags);
>  #else
> -	write_c0_entryhi(cpu_context(cpu, next));
> +	write_c0_entryhi(cpu_asid(cpu, next));
>  #endif /* CONFIG_MIPS_MT_SMTC */
>  	TLBMISS_HANDLER_SETUP_PGD(next->pgd);
>  
> 


From David.Daney@caviumnetworks.com Wed Sep 16 23:54:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 16 Sep 2009 23:54:37 +0200 (CEST)
Received: from mail3.caviumnetworks.com ([12.108.191.235]:17291 "EHLO
	mail3.caviumnetworks.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493385AbZIPVya (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 16 Sep 2009 23:54:30 +0200
Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6,5,4,7535)
	id <B4ab15e890000>; Wed, 16 Sep 2009 14:54:17 -0700
Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 16 Sep 2009 14:54:22 -0700
Received: from dd1.caveonetworks.com ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959);
	 Wed, 16 Sep 2009 14:54:21 -0700
Received: from dd1.caveonetworks.com (localhost.localdomain [127.0.0.1])
	by dd1.caveonetworks.com (8.14.2/8.14.2) with ESMTP id n8GLsJKU022045;
	Wed, 16 Sep 2009 14:54:19 -0700
Received: (from ddaney@localhost)
	by dd1.caveonetworks.com (8.14.2/8.14.2/Submit) id n8GLsI1R022043;
	Wed, 16 Sep 2009 14:54:18 -0700
From:	David Daney <ddaney@caviumnetworks.com>
To:	linux-mips@linux-mips.org, ralf@linux-mips.org
Cc:	David Daney <ddaney@caviumnetworks.com>
Subject: [PATCH] MIPS: Octeon:  Move some platform device registration to its own file.
Date:	Wed, 16 Sep 2009 14:54:18 -0700
Message-Id: <1253138058-22018-1-git-send-email-ddaney@caviumnetworks.com>
X-Mailer: git-send-email 1.6.0.6
X-OriginalArrivalTime: 16 Sep 2009 21:54:21.0945 (UTC) FILETIME=[3F9C9690:01CA3718]
Return-Path: <David.Daney@caviumnetworks.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24041
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ddaney@caviumnetworks.com
Precedence: bulk
X-list: linux-mips

There is a bunch of platform device registration in
arch/mips/cavium-octeon/setup.c.  We move it to its own file in
preparation for adding more platform devices.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
---
 arch/mips/cavium-octeon/Makefile          |    4 +-
 arch/mips/cavium-octeon/octeon-platform.c |  164 +++++++++++++++++++++++++++++
 arch/mips/cavium-octeon/setup.c           |  146 -------------------------
 3 files changed, 166 insertions(+), 148 deletions(-)
 create mode 100644 arch/mips/cavium-octeon/octeon-platform.c

diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile
index e59a80a..6d13c78 100644
--- a/arch/mips/cavium-octeon/Makefile
+++ b/arch/mips/cavium-octeon/Makefile
@@ -6,10 +6,10 @@
 # License.  See the file "COPYING" in the main directory of this archive
 # for more details.
 #
-# Copyright (C) 2005-2008 Cavium Networks
+# Copyright (C) 2005-2009 Cavium Networks
 #
 
-obj-y := setup.o serial.o octeon-irq.o csrc-octeon.o
+obj-y := setup.o serial.o octeon-platform.o octeon-irq.o csrc-octeon.o
 obj-y += dma-octeon.o flash_setup.o
 obj-y += octeon-memcpy.o
 
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
new file mode 100644
index 0000000..be711dd
--- /dev/null
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -0,0 +1,164 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2004-2009 Cavium Networks
+ * Copyright (C) 2008 Wind River Systems
+ */
+
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <asm/octeon/octeon.h>
+#include <asm/octeon/cvmx-rnm-defs.h>
+
+static struct octeon_cf_data octeon_cf_data;
+
+static int __init octeon_cf_device_init(void)
+{
+	union cvmx_mio_boot_reg_cfgx mio_boot_reg_cfg;
+	unsigned long base_ptr, region_base, region_size;
+	struct platform_device *pd;
+	struct resource cf_resources[3];
+	unsigned int num_resources;
+	int i;
+	int ret = 0;
+
+	/* Setup octeon-cf platform device if present. */
+	base_ptr = 0;
+	if (octeon_bootinfo->major_version == 1
+		&& octeon_bootinfo->minor_version >= 1) {
+		if (octeon_bootinfo->compact_flash_common_base_addr)
+			base_ptr =
+				octeon_bootinfo->compact_flash_common_base_addr;
+	} else {
+		base_ptr = 0x1d000800;
+	}
+
+	if (!base_ptr)
+		return ret;
+
+	/* Find CS0 region. */
+	for (i = 0; i < 8; i++) {
+		mio_boot_reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(i));
+		region_base = mio_boot_reg_cfg.s.base << 16;
+		region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
+		if (mio_boot_reg_cfg.s.en && base_ptr >= region_base
+		    && base_ptr < region_base + region_size)
+			break;
+	}
+	if (i >= 7) {
+		/* i and i + 1 are CS0 and CS1, both must be less than 8. */
+		goto out;
+	}
+	octeon_cf_data.base_region = i;
+	octeon_cf_data.is16bit = mio_boot_reg_cfg.s.width;
+	octeon_cf_data.base_region_bias = base_ptr - region_base;
+	memset(cf_resources, 0, sizeof(cf_resources));
+	num_resources = 0;
+	cf_resources[num_resources].flags	= IORESOURCE_MEM;
+	cf_resources[num_resources].start	= region_base;
+	cf_resources[num_resources].end	= region_base + region_size - 1;
+	num_resources++;
+
+
+	if (!(base_ptr & 0xfffful)) {
+		/*
+		 * Boot loader signals availability of DMA (true_ide
+		 * mode) by setting low order bits of base_ptr to
+		 * zero.
+		 */
+
+		/* Asume that CS1 immediately follows. */
+		mio_boot_reg_cfg.u64 =
+			cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(i + 1));
+		region_base = mio_boot_reg_cfg.s.base << 16;
+		region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
+		if (!mio_boot_reg_cfg.s.en)
+			goto out;
+
+		cf_resources[num_resources].flags	= IORESOURCE_MEM;
+		cf_resources[num_resources].start	= region_base;
+		cf_resources[num_resources].end	= region_base + region_size - 1;
+		num_resources++;
+
+		octeon_cf_data.dma_engine = 0;
+		cf_resources[num_resources].flags	= IORESOURCE_IRQ;
+		cf_resources[num_resources].start	= OCTEON_IRQ_BOOTDMA;
+		cf_resources[num_resources].end	= OCTEON_IRQ_BOOTDMA;
+		num_resources++;
+	} else {
+		octeon_cf_data.dma_engine = -1;
+	}
+
+	pd = platform_device_alloc("pata_octeon_cf", -1);
+	if (!pd) {
+		ret = -ENOMEM;
+		goto out;
+	}
+	pd->dev.platform_data = &octeon_cf_data;
+
+	ret = platform_device_add_resources(pd, cf_resources, num_resources);
+	if (ret)
+		goto fail;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		goto fail;
+
+	return ret;
+fail:
+	platform_device_put(pd);
+out:
+	return ret;
+}
+device_initcall(octeon_cf_device_init);
+
+/* Octeon Random Number Generator.  */
+static int __init octeon_rng_device_init(void)
+{
+	struct platform_device *pd;
+	int ret = 0;
+
+	struct resource rng_resources[] = {
+		{
+			.flags	= IORESOURCE_MEM,
+			.start	= XKPHYS_TO_PHYS(CVMX_RNM_CTL_STATUS),
+			.end	= XKPHYS_TO_PHYS(CVMX_RNM_CTL_STATUS) + 0xf
+		}, {
+			.flags	= IORESOURCE_MEM,
+			.start	= cvmx_build_io_address(8, 0),
+			.end	= cvmx_build_io_address(8, 0) + 0x7
+		}
+	};
+
+	pd = platform_device_alloc("octeon_rng", -1);
+	if (!pd) {
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = platform_device_add_resources(pd, rng_resources,
+					    ARRAY_SIZE(rng_resources));
+	if (ret)
+		goto fail;
+
+	ret = platform_device_add(pd);
+	if (ret)
+		goto fail;
+
+	return ret;
+fail:
+	platform_device_put(pd);
+
+out:
+	return ret;
+}
+device_initcall(octeon_rng_device_init);
+
+MODULE_AUTHOR("David Daney <ddaney@caviumnetworks.com>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Platform driver for Octeon SOC");
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index d8cf674..f58eed6 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -11,7 +11,6 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/irq.h>
 #include <linux/serial.h>
 #include <linux/smp.h>
 #include <linux/types.h>
@@ -33,7 +32,6 @@
 #include <asm/time.h>
 
 #include <asm/octeon/octeon.h>
-#include <asm/octeon/cvmx-rnm-defs.h>
 
 #ifdef CONFIG_CAVIUM_DECODE_RSL
 extern void cvmx_interrupt_rsl_decode(void);
@@ -830,147 +828,3 @@ void prom_free_prom_memory(void)
 	   CONFIG_CAVIUM_RESERVE32_USE_WIRED_TLB option is set */
 	octeon_hal_setup_reserved32();
 }
-
-static struct octeon_cf_data octeon_cf_data;
-
-static int __init octeon_cf_device_init(void)
-{
-	union cvmx_mio_boot_reg_cfgx mio_boot_reg_cfg;
-	unsigned long base_ptr, region_base, region_size;
-	struct platform_device *pd;
-	struct resource cf_resources[3];
-	unsigned int num_resources;
-	int i;
-	int ret = 0;
-
-	/* Setup octeon-cf platform device if present. */
-	base_ptr = 0;
-	if (octeon_bootinfo->major_version == 1
-		&& octeon_bootinfo->minor_version >= 1) {
-		if (octeon_bootinfo->compact_flash_common_base_addr)
-			base_ptr =
-				octeon_bootinfo->compact_flash_common_base_addr;
-	} else {
-		base_ptr = 0x1d000800;
-	}
-
-	if (!base_ptr)
-		return ret;
-
-	/* Find CS0 region. */
-	for (i = 0; i < 8; i++) {
-		mio_boot_reg_cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(i));
-		region_base = mio_boot_reg_cfg.s.base << 16;
-		region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
-		if (mio_boot_reg_cfg.s.en && base_ptr >= region_base
-		    && base_ptr < region_base + region_size)
-			break;
-	}
-	if (i >= 7) {
-		/* i and i + 1 are CS0 and CS1, both must be less than 8. */
-		goto out;
-	}
-	octeon_cf_data.base_region = i;
-	octeon_cf_data.is16bit = mio_boot_reg_cfg.s.width;
-	octeon_cf_data.base_region_bias = base_ptr - region_base;
-	memset(cf_resources, 0, sizeof(cf_resources));
-	num_resources = 0;
-	cf_resources[num_resources].flags	= IORESOURCE_MEM;
-	cf_resources[num_resources].start	= region_base;
-	cf_resources[num_resources].end	= region_base + region_size - 1;
-	num_resources++;
-
-
-	if (!(base_ptr & 0xfffful)) {
-		/*
-		 * Boot loader signals availability of DMA (true_ide
-		 * mode) by setting low order bits of base_ptr to
-		 * zero.
-		 */
-
-		/* Asume that CS1 immediately follows. */
-		mio_boot_reg_cfg.u64 =
-			cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(i + 1));
-		region_base = mio_boot_reg_cfg.s.base << 16;
-		region_size = (mio_boot_reg_cfg.s.size + 1) << 16;
-		if (!mio_boot_reg_cfg.s.en)
-			goto out;
-
-		cf_resources[num_resources].flags	= IORESOURCE_MEM;
-		cf_resources[num_resources].start	= region_base;
-		cf_resources[num_resources].end	= region_base + region_size - 1;
-		num_resources++;
-
-		octeon_cf_data.dma_engine = 0;
-		cf_resources[num_resources].flags	= IORESOURCE_IRQ;
-		cf_resources[num_resources].start	= OCTEON_IRQ_BOOTDMA;
-		cf_resources[num_resources].end	= OCTEON_IRQ_BOOTDMA;
-		num_resources++;
-	} else {
-		octeon_cf_data.dma_engine = -1;
-	}
-
-	pd = platform_device_alloc("pata_octeon_cf", -1);
-	if (!pd) {
-		ret = -ENOMEM;
-		goto out;
-	}
-	pd->dev.platform_data = &octeon_cf_data;
-
-	ret = platform_device_add_resources(pd, cf_resources, num_resources);
-	if (ret)
-		goto fail;
-
-	ret = platform_device_add(pd);
-	if (ret)
-		goto fail;
-
-	return ret;
-fail:
-	platform_device_put(pd);
-out:
-	return ret;
-}
-device_initcall(octeon_cf_device_init);
-
-/* Octeon Random Number Generator.  */
-static int __init octeon_rng_device_init(void)
-{
-	struct platform_device *pd;
-	int ret = 0;
-
-	struct resource rng_resources[] = {
-		{
-			.flags	= IORESOURCE_MEM,
-			.start	= XKPHYS_TO_PHYS(CVMX_RNM_CTL_STATUS),
-			.end	= XKPHYS_TO_PHYS(CVMX_RNM_CTL_STATUS) + 0xf
-		}, {
-			.flags	= IORESOURCE_MEM,
-			.start	= cvmx_build_io_address(8, 0),
-			.end	= cvmx_build_io_address(8, 0) + 0x7
-		}
-	};
-
-	pd = platform_device_alloc("octeon_rng", -1);
-	if (!pd) {
-		ret = -ENOMEM;
-		goto out;
-	}
-
-	ret = platform_device_add_resources(pd, rng_resources,
-					    ARRAY_SIZE(rng_resources));
-	if (ret)
-		goto fail;
-
-	ret = platform_device_add(pd);
-	if (ret)
-		goto fail;
-
-	return ret;
-fail:
-	platform_device_put(pd);
-
-out:
-	return ret;
-}
-device_initcall(octeon_rng_device_init);
-- 
1.6.0.6


From anemo@mba.ocn.ne.jp Thu Sep 17 15:53:05 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 17 Sep 2009 15:53:12 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:58367 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1491939AbZIQNxF (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 17 Sep 2009 15:53:05 +0200
Received: from localhost (p4003-ipad310funabasi.chiba.ocn.ne.jp [123.217.206.3])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 5B3506A3B; Thu, 17 Sep 2009 22:52:57 +0900 (JST)
Date:	Thu, 17 Sep 2009 22:52:59 +0900 (JST)
Message-Id: <20090917.225259.173376281.anemo@mba.ocn.ne.jp>
To:	ralf.roesch@rw-gmbh.de
Cc:	linux-mips@linux-mips.org, Julia Lawall <julia@diku.dk>
Subject: Re: [PATCH] MIPS: TXx9: Fix error handling / Fix for noenexisting
 gpio_remove.
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <1253080880-11123-1-git-send-email-ralf.roesch@rw-gmbh.de>
References: <1253080880-11123-1-git-send-email-ralf.roesch@rw-gmbh.de>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 5.2 on Emacs 22.2 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24042
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

On Wed, 16 Sep 2009 08:01:20 +0200, Ralf Roesch <ralf.roesch@rw-gmbh.de> wrote:
> error was introduced by commit 0385d1f3d394c6814be0b165c153fc3fc254469a

Thanks, this patch should be holded into the original commit before
mainlining.  The result should be same as Julia's revised patch.

I don't mind ether way, I just hope keeping bisectability on mainline.
Is it too late, (yet another) Ralf ?

---
Atsushi Nemoto

From weiyi.huang@gmail.com Fri Sep 18 09:14:41 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 09:14:48 +0200 (CEST)
Received: from mail-px0-f176.google.com ([209.85.216.176]:63664 "EHLO
	mail-px0-f176.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492097AbZIRHOl (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 18 Sep 2009 09:14:41 +0200
Received: by pxi6 with SMTP id 6so681178pxi.21
        for <multiple recipients>; Fri, 18 Sep 2009 00:14:34 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=xn0cI6J/xR+NtmvDKlzecuTqp/TO+cAHInSZbLhcZaI=;
        b=FKoVeOvLt6KL3pj/5Y5Q2vQGChIpQF18mtybE6IjcsjLskkFbvhD2i2UG5oNcOQ9kf
         sTDMKBObmGMOscGLPBN10Rdxxg+Zy/SM5H2j3u39PtZL6B9prq6wAjGDvsfBEth1OWjS
         cDhy6zz3oexC6V3O0Pq9cS7xJ5xpnGDjoCD0w=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=EPiUAX8wjvA2Tl3ga/Xu3Hs8J5UvJvW3RHsv+IJrkCJxPu8fmafeJ/zlsobgURG4wg
         fehElCFRI59HxTftyU9v3gM7mwbvh8Z4z9PjapNh0LCRbTShlhGu5//OLzyFdHmuD7PB
         LE5Sn5Mt0e1E2QKaGBW6H8WbqhrqNJ95Yga2s=
Received: by 10.114.162.20 with SMTP id k20mr1892903wae.135.1253258072736;
        Fri, 18 Sep 2009 00:14:32 -0700 (PDT)
Received: from localhost.localdomain ([58.212.86.177])
        by mx.google.com with ESMTPS id 20sm762569pxi.12.2009.09.18.00.14.28
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 18 Sep 2009 00:14:31 -0700 (PDT)
From:	Huang Weiyi <weiyi.huang@gmail.com>
To:	ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org, Huang Weiyi <weiyi.huang@gmail.com>
Subject: [PATCH 1/2] MIPS: BCM63xx: remove duplicated #include
Date:	Fri, 18 Sep 2009 15:14:19 +0800
Message-Id: <1253258059-3340-1-git-send-email-weiyi.huang@gmail.com>
X-Mailer: git-send-email 1.6.1.2
Return-Path: <weiyi.huang@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24043
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: weiyi.huang@gmail.com
Precedence: bulk
X-list: linux-mips

Remove duplicated #include('s) in
  arch/mips/bcm63xx/boards/board_bcm963xx.c

Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>
---
 arch/mips/bcm63xx/boards/board_bcm963xx.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index fd77f54..12add0c 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -20,7 +20,6 @@
 #include <bcm63xx_cpu.h>
 #include <bcm63xx_regs.h>
 #include <bcm63xx_io.h>
-#include <bcm63xx_board.h>
 #include <bcm63xx_dev_pci.h>
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_dsp.h>
-- 
1.6.1.3


From weiyi.huang@gmail.com Fri Sep 18 09:15:06 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 09:15:14 +0200 (CEST)
Received: from mail-pz0-f196.google.com ([209.85.222.196]:61600 "EHLO
	mail-pz0-f196.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492105AbZIRHOx (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 18 Sep 2009 09:14:53 +0200
Received: by pzk34 with SMTP id 34so638853pzk.22
        for <multiple recipients>; Fri, 18 Sep 2009 00:14:44 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=7CASoQPLtrbnru5R75N86gelNWTMk7iyGBtGwvx3k6E=;
        b=c9DTb8jpQDxdYgLQaKDPJVsv5JyOuidLdhMUogRs/objHgjP4in7RPx5o1avFiZUa6
         lqde6YkTLSkZcZetzQW26zMyCMsODnuLr4n9jGfY3Obrwg69iKEHfPTUqTzeNT0nfQJw
         qz5GJape1vD9GuElJTm0kalAgcdZ9fTAK0MVg=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=S7jrZxADX0DRFnwNlkEcAA23YfLR/GDdciFvvItqz13oTak9g0OfhAtWZGczJ1cOb0
         lvmrfB0C99sFa1+XXtmwFcKXhzSWiSNh7NQWVFswNflT48JIgMIDoduDCvX78OuMVovT
         muhUnmII58VKdfaAFj32Zm53MzMFFpBTwGCzE=
Received: by 10.115.45.5 with SMTP id x5mr1867320waj.182.1253258084877;
        Fri, 18 Sep 2009 00:14:44 -0700 (PDT)
Received: from localhost.localdomain ([58.212.86.177])
        by mx.google.com with ESMTPS id 20sm765979pxi.8.2009.09.18.00.14.40
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 18 Sep 2009 00:14:43 -0700 (PDT)
From:	Huang Weiyi <weiyi.huang@gmail.com>
To:	ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org, Huang Weiyi <weiyi.huang@gmail.com>
Subject: [PATCH 2/2] MIPS: remove duplicated #include
Date:	Fri, 18 Sep 2009 15:14:35 +0800
Message-Id: <1253258075-3088-1-git-send-email-weiyi.huang@gmail.com>
X-Mailer: git-send-email 1.6.1.2
Return-Path: <weiyi.huang@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24044
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: weiyi.huang@gmail.com
Precedence: bulk
X-list: linux-mips

Remove duplicated #include('s) in
  arch/mips/kernel/smp.c

Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>
---
 arch/mips/kernel/smp.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 64668a9..119a95e 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -32,7 +32,6 @@
 #include <linux/cpumask.h>
 #include <linux/cpu.h>
 #include <linux/err.h>
-#include <linux/smp.h>
 
 #include <asm/atomic.h>
 #include <asm/cpu.h>
-- 
1.6.1.3


From ralf.roesch@rw-gmbh.de Fri Sep 18 10:12:34 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 10:12:41 +0200 (CEST)
Received: from rs1.rw-gmbh.net ([213.239.201.58]:37092 "EHLO rs1.rw-gmbh.net"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492185AbZIRIMe (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 10:12:34 +0200
Received: from pd951aadc.dip0.t-ipconnect.de ([217.81.170.220] helo=[192.168.178.24])
	by rs1.rw-gmbh.net with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.69)
	(envelope-from <ralf.roesch@rw-gmbh.de>)
	id 1MoYa1-0006Fn-7Q; Fri, 18 Sep 2009 10:12:33 +0200
Message-ID: <4AB340F0.5050101@rw-gmbh.de>
Date:	Fri, 18 Sep 2009 10:12:32 +0200
From:	Ralf Roesch <ralf.roesch@rw-gmbh.de>
User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701)
MIME-Version: 1.0
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
CC:	linux-mips@linux-mips.org, Julia Lawall <julia@diku.dk>
Subject: Re: [PATCH] MIPS: TXx9: Fix error handling / Fix for noenexisting
 gpio_remove.
References: <1253080880-11123-1-git-send-email-ralf.roesch@rw-gmbh.de> <20090917.225259.173376281.anemo@mba.ocn.ne.jp>
In-Reply-To: <20090917.225259.173376281.anemo@mba.ocn.ne.jp>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <ralf.roesch@rw-gmbh.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24045
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf.roesch@rw-gmbh.de
Precedence: bulk
X-list: linux-mips

On Thu Sep 17 2009 15:52:59 GMT+0200 (CEST), Atsushi Nemoto  wrote:
> Thanks, this patch should be holded into the original commit before
> mainlining.  The result should be same as Julia's revised patch.
>
> I don't mind ether way, I just hope keeping bisectability on mainline.
> Is it too late, (yet another) Ralf ?
>
>   
Not for me Atshushi, thanks.
--
the other Ralf ;-)

From mbizon@freebox.fr Fri Sep 18 13:05:11 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 13:05:17 +0200 (CEST)
Received: from smtp6-g21.free.fr ([212.27.42.6]:44595 "EHLO smtp6-g21.free.fr"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492728AbZIRLFL (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 13:05:11 +0200
Received: from smtp6-g21.free.fr (localhost [127.0.0.1])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 23325E08104;
	Fri, 18 Sep 2009 13:05:01 +0200 (CEST)
Received: from [213.228.1.107] (sakura.staff.proxad.net [213.228.1.107])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 35950E08048;
	Fri, 18 Sep 2009 13:04:59 +0200 (CEST)
Subject: [PATCH] MIPS: BCM63xx: Add serial driver for bcm63xx integrated
 UART.
From:	Maxime Bizon <mbizon@freebox.fr>
Reply-To: mbizon@freebox.fr
To:	Greg Kroah-Hartman <gregkh@suse.de>
Cc:	linux-serial@vger.kernel.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
Content-Type: text/plain
Organization: Freebox
Date:	Fri, 18 Sep 2009 13:04:58 +0200
Message-Id: <1253271898.1627.272.camel@sakura.staff.proxad.net>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 7bit
Return-Path: <mbizon@freebox.fr>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24046
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mbizon@freebox.fr
Precedence: bulk
X-list: linux-mips


Hi Greg,

This is a serial driver for the bcm63xx mips SOCs, it was already posted
twice:

one year ago: http://marc.info/?l=linux-serial&m=122438266322439&w=2
three months ago: http://lkml.org/lkml/2009/7/1/370

but got no review or ack.


Linus merged the SOC support patch from Ralf tree yesterday, but without
serial support.

Could you please have a look at it ? Is it ok if it goes upstream
through Ralf tree ?

Thanks !



Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---

diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
index aaa585c..cff75de 100644
--- a/arch/mips/bcm63xx/Makefile
+++ b/arch/mips/bcm63xx/Makefile
@@ -1,5 +1,5 @@
 obj-y		+= clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
-		   dev-dsp.o dev-enet.o
+		   dev-dsp.o dev-enet.o dev-uart.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
 obj-y		+= boards/
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index fd77f54..d3fdf27 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -24,6 +24,7 @@
 #include <bcm63xx_dev_pci.h>
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_dsp.h>
+#include <bcm63xx_dev_uart.h>
 #include <board_bcm963xx.h>
 
 #define PFX	"board_bcm963xx: "
@@ -793,6 +794,8 @@ int __init board_register_devices(void)
 {
 	u32 val;
 
+	bcm63xx_uart_register();
+
 	if (board.has_enet0 &&
 	    !board_get_mac_address(board.enet0.mac_addr))
 		bcm63xx_enet_register(0, &board.enet0);
diff --git a/arch/mips/bcm63xx/dev-uart.c b/arch/mips/bcm63xx/dev-uart.c
new file mode 100644
index 0000000..5f3d89c
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-uart.c
@@ -0,0 +1,41 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <bcm63xx_cpu.h>
+#include <bcm63xx_dev_uart.h>
+
+static struct resource uart_resources[] = {
+	{
+		.start		= -1, /* filled at runtime */
+		.end		= -1, /* filled at runtime */
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= -1, /* filled at runtime */
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device bcm63xx_uart_device = {
+	.name		= "bcm63xx_uart",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(uart_resources),
+	.resource	= uart_resources,
+};
+
+int __init bcm63xx_uart_register(void)
+{
+	uart_resources[0].start = bcm63xx_regset_address(RSET_UART0);
+	uart_resources[0].end = uart_resources[0].start;
+	uart_resources[0].end += RSET_UART_SIZE - 1;
+	uart_resources[1].start = bcm63xx_get_irq_number(IRQ_UART0);
+	return platform_device_register(&bcm63xx_uart_device);
+}
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_uart.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_uart.h
new file mode 100644
index 0000000..bf348f5
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_uart.h
@@ -0,0 +1,6 @@
+#ifndef BCM63XX_DEV_UART_H_
+#define BCM63XX_DEV_UART_H_
+
+int bcm63xx_uart_register(void);
+
+#endif /* BCM63XX_DEV_UART_H_ */
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 03422ce..e707120 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1458,4 +1458,23 @@ config SERIAL_TIMBERDALE
 	---help---
 	Add support for UART controller on timberdale.
 
+config SERIAL_BCM63XX
+	tristate "bcm63xx serial port support"
+	select SERIAL_CORE
+	depends on BCM63XX
+	help
+	  If you have a bcm63xx CPU, you can enable its onboard
+	  serial port by enabling this options.
+
+          To compile this driver as a module, choose M here: the
+          module will be called bcm963xx_uart.
+
+config SERIAL_BCM63XX_CONSOLE
+	bool "Console on bcm63xx serial port"
+	depends on SERIAL_BCM63XX=y
+	select SERIAL_CORE_CONSOLE
+	help
+	  If you have enabled the serial port on the bcm63xx CPU
+	  you can make it the console by answering Y to this option.
+
 endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 97f6fcc..d21d5dd 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
 obj-$(CONFIG_SERIAL_PXA) += pxa.o
 obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o
 obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
+obj-$(CONFIG_SERIAL_BCM63XX) += bcm63xx_uart.o
 obj-$(CONFIG_SERIAL_BFIN) += bfin_5xx.o
 obj-$(CONFIG_SERIAL_BFIN_SPORT) += bfin_sport_uart.o
 obj-$(CONFIG_SERIAL_SAMSUNG) += samsung.o
diff --git a/drivers/serial/bcm63xx_uart.c b/drivers/serial/bcm63xx_uart.c
new file mode 100644
index 0000000..beddaa6
--- /dev/null
+++ b/drivers/serial/bcm63xx_uart.c
@@ -0,0 +1,890 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Derived from many drivers using generic_serial interface.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ *
+ *  Serial driver for BCM63xx integrated UART.
+ *
+ * Hardware flow control was _not_ tested since I only have RX/TX on
+ * my board.
+ */
+
+#if defined(CONFIG_SERIAL_BCM63XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/console.h>
+#include <linux/clk.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/sysrq.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+
+#include <bcm63xx_clk.h>
+#include <bcm63xx_irq.h>
+#include <bcm63xx_regs.h>
+#include <bcm63xx_io.h>
+
+#define BCM63XX_NR_UARTS	1
+
+static struct uart_port ports[BCM63XX_NR_UARTS];
+
+/*
+ * rx interrupt mask / stat
+ *
+ * mask:
+ *  - rx fifo full
+ *  - rx fifo above threshold
+ *  - rx fifo not empty for too long
+ */
+#define UART_RX_INT_MASK	(UART_IR_MASK(UART_IR_RXOVER) |		\
+				UART_IR_MASK(UART_IR_RXTHRESH) |	\
+				UART_IR_MASK(UART_IR_RXTIMEOUT))
+
+#define UART_RX_INT_STAT	(UART_IR_STAT(UART_IR_RXOVER) |		\
+				UART_IR_STAT(UART_IR_RXTHRESH) |	\
+				UART_IR_STAT(UART_IR_RXTIMEOUT))
+
+/*
+ * tx interrupt mask / stat
+ *
+ * mask:
+ * - tx fifo empty
+ * - tx fifo below threshold
+ */
+#define UART_TX_INT_MASK	(UART_IR_MASK(UART_IR_TXEMPTY) |	\
+				UART_IR_MASK(UART_IR_TXTRESH))
+
+#define UART_TX_INT_STAT	(UART_IR_STAT(UART_IR_TXEMPTY) |	\
+				UART_IR_STAT(UART_IR_TXTRESH))
+
+/*
+ * external input interrupt
+ *
+ * mask: any edge on CTS, DCD
+ */
+#define UART_EXTINP_INT_MASK	(UART_EXTINP_IRMASK(UART_EXTINP_IR_CTS) | \
+				 UART_EXTINP_IRMASK(UART_EXTINP_IR_DCD))
+
+/*
+ * handy uart register accessor
+ */
+static inline unsigned int bcm_uart_readl(struct uart_port *port,
+					 unsigned int offset)
+{
+	return bcm_readl(port->membase + offset);
+}
+
+static inline void bcm_uart_writel(struct uart_port *port,
+				  unsigned int value, unsigned int offset)
+{
+	bcm_writel(value, port->membase + offset);
+}
+
+/*
+ * serial core request to check if uart tx fifo is empty
+ */
+static unsigned int bcm_uart_tx_empty(struct uart_port *port)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_IR_REG);
+	return (val & UART_IR_STAT(UART_IR_TXEMPTY)) ? 1 : 0;
+}
+
+/*
+ * serial core request to set RTS and DTR pin state and loopback mode
+ */
+static void bcm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_MCTL_REG);
+	val &= ~(UART_MCTL_DTR_MASK | UART_MCTL_RTS_MASK);
+	/* invert of written value is reflected on the pin */
+	if (!(mctrl & TIOCM_DTR))
+		val |= UART_MCTL_DTR_MASK;
+	if (!(mctrl & TIOCM_RTS))
+		val |= UART_MCTL_RTS_MASK;
+	bcm_uart_writel(port, val, UART_MCTL_REG);
+
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	if (mctrl & TIOCM_LOOP)
+		val |= UART_CTL_LOOPBACK_MASK;
+	else
+		val &= ~UART_CTL_LOOPBACK_MASK;
+	bcm_uart_writel(port, val, UART_CTL_REG);
+}
+
+/*
+ * serial core request to return RI, CTS, DCD and DSR pin state
+ */
+static unsigned int bcm_uart_get_mctrl(struct uart_port *port)
+{
+	unsigned int val, mctrl;
+
+	mctrl = 0;
+	val = bcm_uart_readl(port, UART_EXTINP_REG);
+	if (val & UART_EXTINP_RI_MASK)
+		mctrl |= TIOCM_RI;
+	if (val & UART_EXTINP_CTS_MASK)
+		mctrl |= TIOCM_CTS;
+	if (val & UART_EXTINP_DCD_MASK)
+		mctrl |= TIOCM_CD;
+	if (val & UART_EXTINP_DSR_MASK)
+		mctrl |= TIOCM_DSR;
+	return mctrl;
+}
+
+/*
+ * serial core request to disable tx ASAP (used for flow control)
+ */
+static void bcm_uart_stop_tx(struct uart_port *port)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	val &= ~(UART_CTL_TXEN_MASK);
+	bcm_uart_writel(port, val, UART_CTL_REG);
+
+	val = bcm_uart_readl(port, UART_IR_REG);
+	val &= ~UART_TX_INT_MASK;
+	bcm_uart_writel(port, val, UART_IR_REG);
+}
+
+/*
+ * serial core request to (re)enable tx
+ */
+static void bcm_uart_start_tx(struct uart_port *port)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_IR_REG);
+	val |= UART_TX_INT_MASK;
+	bcm_uart_writel(port, val, UART_IR_REG);
+
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	val |= UART_CTL_TXEN_MASK;
+	bcm_uart_writel(port, val, UART_CTL_REG);
+}
+
+/*
+ * serial core request to stop rx, called before port shutdown
+ */
+static void bcm_uart_stop_rx(struct uart_port *port)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_IR_REG);
+	val &= ~UART_RX_INT_MASK;
+	bcm_uart_writel(port, val, UART_IR_REG);
+}
+
+/*
+ * serial core request to enable modem status interrupt reporting
+ */
+static void bcm_uart_enable_ms(struct uart_port *port)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_IR_REG);
+	val |= UART_IR_MASK(UART_IR_EXTIP);
+	bcm_uart_writel(port, val, UART_IR_REG);
+}
+
+/*
+ * serial core request to start/stop emitting break char
+ */
+static void bcm_uart_break_ctl(struct uart_port *port, int ctl)
+{
+	unsigned long flags;
+	unsigned int val;
+
+	spin_lock_irqsave(&port->lock, flags);
+
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	if (ctl)
+		val |= UART_CTL_XMITBRK_MASK;
+	else
+		val &= ~UART_CTL_XMITBRK_MASK;
+	bcm_uart_writel(port, val, UART_CTL_REG);
+
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+/*
+ * return port type in string format
+ */
+static const char *bcm_uart_type(struct uart_port *port)
+{
+	return (port->type == PORT_BCM63XX) ? "bcm63xx_uart" : NULL;
+}
+
+/*
+ * read all chars in rx fifo and send them to core
+ */
+static void bcm_uart_do_rx(struct uart_port *port)
+{
+	struct tty_struct *tty;
+	unsigned int max_count;
+
+	/* limit number of char read in interrupt, should not be
+	 * higher than fifo size anyway since we're much faster than
+	 * serial port */
+	max_count = 32;
+	tty = port->info->port.tty;
+	do {
+		unsigned int iestat, c, cstat;
+		char flag;
+
+		/* get overrun/fifo empty information from ier
+		 * register */
+		iestat = bcm_uart_readl(port, UART_IR_REG);
+		if (!(iestat & UART_IR_STAT(UART_IR_RXNOTEMPTY)))
+			break;
+
+		cstat = c = bcm_uart_readl(port, UART_FIFO_REG);
+		port->icount.rx++;
+		flag = TTY_NORMAL;
+		c &= 0xff;
+
+		if (unlikely((cstat & UART_FIFO_ANYERR_MASK))) {
+			/* do stats first */
+			if (cstat & UART_FIFO_BRKDET_MASK) {
+				port->icount.brk++;
+				if (uart_handle_break(port))
+					continue;
+			}
+
+			if (cstat & UART_FIFO_PARERR_MASK)
+				port->icount.parity++;
+			if (cstat & UART_FIFO_FRAMEERR_MASK)
+				port->icount.frame++;
+
+			/* update flag wrt read_status_mask */
+			cstat &= port->read_status_mask;
+			if (cstat & UART_FIFO_BRKDET_MASK)
+				flag = TTY_BREAK;
+			if (cstat & UART_FIFO_FRAMEERR_MASK)
+				flag = TTY_FRAME;
+			if (cstat & UART_FIFO_PARERR_MASK)
+				flag = TTY_PARITY;
+		}
+
+		if (uart_handle_sysrq_char(port, c))
+			continue;
+
+		if (unlikely(iestat & UART_IR_STAT(UART_IR_RXOVER))) {
+			port->icount.overrun++;
+			tty_insert_flip_char(tty, 0, TTY_OVERRUN);
+		}
+
+		if ((cstat & port->ignore_status_mask) == 0)
+			tty_insert_flip_char(tty, c, flag);
+
+	} while (--max_count);
+
+	tty_flip_buffer_push(tty);
+}
+
+/*
+ * fill tx fifo with chars to send, stop when fifo is about to be full
+ * or when all chars have been sent.
+ */
+static void bcm_uart_do_tx(struct uart_port *port)
+{
+	struct circ_buf *xmit;
+	unsigned int val, max_count;
+
+	if (port->x_char) {
+		bcm_uart_writel(port, port->x_char, UART_FIFO_REG);
+		port->icount.tx++;
+		port->x_char = 0;
+		return;
+	}
+
+	if (uart_tx_stopped(port)) {
+		bcm_uart_stop_tx(port);
+		return;
+	}
+
+	xmit = &port->info->xmit;
+	if (uart_circ_empty(xmit))
+		goto txq_empty;
+
+	val = bcm_uart_readl(port, UART_MCTL_REG);
+	val = (val & UART_MCTL_TXFIFOFILL_MASK) >> UART_MCTL_TXFIFOFILL_SHIFT;
+	max_count = port->fifosize - val;
+
+	while (max_count--) {
+		unsigned int c;
+
+		c = xmit->buf[xmit->tail];
+		bcm_uart_writel(port, c, UART_FIFO_REG);
+		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+		port->icount.tx++;
+		if (uart_circ_empty(xmit))
+			break;
+	}
+
+	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+		uart_write_wakeup(port);
+
+	if (uart_circ_empty(xmit))
+		goto txq_empty;
+	return;
+
+txq_empty:
+	/* nothing to send, disable transmit interrupt */
+	val = bcm_uart_readl(port, UART_IR_REG);
+	val &= ~UART_TX_INT_MASK;
+	bcm_uart_writel(port, val, UART_IR_REG);
+	return;
+}
+
+/*
+ * process uart interrupt
+ */
+static irqreturn_t bcm_uart_interrupt(int irq, void *dev_id)
+{
+	struct uart_port *port;
+	unsigned int irqstat;
+
+	port = dev_id;
+	spin_lock(&port->lock);
+
+	irqstat = bcm_uart_readl(port, UART_IR_REG);
+	if (irqstat & UART_RX_INT_STAT)
+		bcm_uart_do_rx(port);
+
+	if (irqstat & UART_TX_INT_STAT)
+		bcm_uart_do_tx(port);
+
+	if (irqstat & UART_IR_MASK(UART_IR_EXTIP)) {
+		unsigned int estat;
+
+		estat = bcm_uart_readl(port, UART_EXTINP_REG);
+		if (estat & UART_EXTINP_IRSTAT(UART_EXTINP_IR_CTS))
+			uart_handle_cts_change(port,
+					       estat & UART_EXTINP_CTS_MASK);
+		if (estat & UART_EXTINP_IRSTAT(UART_EXTINP_IR_DCD))
+			uart_handle_dcd_change(port,
+					       estat & UART_EXTINP_DCD_MASK);
+	}
+
+	spin_unlock(&port->lock);
+	return IRQ_HANDLED;
+}
+
+/*
+ * enable rx & tx operation on uart
+ */
+static void bcm_uart_enable(struct uart_port *port)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	val |= (UART_CTL_BRGEN_MASK | UART_CTL_TXEN_MASK | UART_CTL_RXEN_MASK);
+	bcm_uart_writel(port, val, UART_CTL_REG);
+}
+
+/*
+ * disable rx & tx operation on uart
+ */
+static void bcm_uart_disable(struct uart_port *port)
+{
+	unsigned int val;
+
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	val &= ~(UART_CTL_BRGEN_MASK | UART_CTL_TXEN_MASK |
+		 UART_CTL_RXEN_MASK);
+	bcm_uart_writel(port, val, UART_CTL_REG);
+}
+
+/*
+ * clear all unread data in rx fifo and unsent data in tx fifo
+ */
+static void bcm_uart_flush(struct uart_port *port)
+{
+	unsigned int val;
+
+	/* empty rx and tx fifo */
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	val |= UART_CTL_RSTRXFIFO_MASK | UART_CTL_RSTTXFIFO_MASK;
+	bcm_uart_writel(port, val, UART_CTL_REG);
+
+	/* read any pending char to make sure all irq status are
+	 * cleared */
+	(void)bcm_uart_readl(port, UART_FIFO_REG);
+}
+
+/*
+ * serial core request to initialize uart and start rx operation
+ */
+static int bcm_uart_startup(struct uart_port *port)
+{
+	unsigned int val;
+	int ret;
+
+	/* mask all irq and flush port */
+	bcm_uart_disable(port);
+	bcm_uart_writel(port, 0, UART_IR_REG);
+	bcm_uart_flush(port);
+
+	/* clear any pending external input interrupt */
+	(void)bcm_uart_readl(port, UART_EXTINP_REG);
+
+	/* set rx/tx fifo thresh to fifo half size */
+	val = bcm_uart_readl(port, UART_MCTL_REG);
+	val &= ~(UART_MCTL_RXFIFOTHRESH_MASK | UART_MCTL_TXFIFOTHRESH_MASK);
+	val |= (port->fifosize / 2) << UART_MCTL_RXFIFOTHRESH_SHIFT;
+	val |= (port->fifosize / 2) << UART_MCTL_TXFIFOTHRESH_SHIFT;
+	bcm_uart_writel(port, val, UART_MCTL_REG);
+
+	/* set rx fifo timeout to 1 char time */
+	val = bcm_uart_readl(port, UART_CTL_REG);
+	val &= ~UART_CTL_RXTMOUTCNT_MASK;
+	val |= 1 << UART_CTL_RXTMOUTCNT_SHIFT;
+	bcm_uart_writel(port, val, UART_CTL_REG);
+
+	/* report any edge on dcd and cts */
+	val = UART_EXTINP_INT_MASK;
+	val |= UART_EXTINP_DCD_NOSENSE_MASK;
+	val |= UART_EXTINP_CTS_NOSENSE_MASK;
+	bcm_uart_writel(port, val, UART_EXTINP_REG);
+
+	/* register irq and enable rx interrupts */
+	ret = request_irq(port->irq, bcm_uart_interrupt, 0,
+			  bcm_uart_type(port), port);
+	if (ret)
+		return ret;
+	bcm_uart_writel(port, UART_RX_INT_MASK, UART_IR_REG);
+	bcm_uart_enable(port);
+	return 0;
+}
+
+/*
+ * serial core request to flush & disable uart
+ */
+static void bcm_uart_shutdown(struct uart_port *port)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&port->lock, flags);
+	bcm_uart_writel(port, 0, UART_IR_REG);
+	spin_unlock_irqrestore(&port->lock, flags);
+
+	bcm_uart_disable(port);
+	bcm_uart_flush(port);
+	free_irq(port->irq, port);
+}
+
+/*
+ * serial core request to change current uart setting
+ */
+static void bcm_uart_set_termios(struct uart_port *port,
+				 struct ktermios *new,
+				 struct ktermios *old)
+{
+	unsigned int ctl, baud, quot, ier;
+	unsigned long flags;
+
+	spin_lock_irqsave(&port->lock, flags);
+
+	/* disable uart while changing speed */
+	bcm_uart_disable(port);
+	bcm_uart_flush(port);
+
+	/* update Control register */
+	ctl = bcm_uart_readl(port, UART_CTL_REG);
+	ctl &= ~UART_CTL_BITSPERSYM_MASK;
+
+	switch (new->c_cflag & CSIZE) {
+	case CS5:
+		ctl |= (0 << UART_CTL_BITSPERSYM_SHIFT);
+		break;
+	case CS6:
+		ctl |= (1 << UART_CTL_BITSPERSYM_SHIFT);
+		break;
+	case CS7:
+		ctl |= (2 << UART_CTL_BITSPERSYM_SHIFT);
+		break;
+	default:
+		ctl |= (3 << UART_CTL_BITSPERSYM_SHIFT);
+		break;
+	}
+
+	ctl &= ~UART_CTL_STOPBITS_MASK;
+	if (new->c_cflag & CSTOPB)
+		ctl |= UART_CTL_STOPBITS_2;
+	else
+		ctl |= UART_CTL_STOPBITS_1;
+
+	ctl &= ~(UART_CTL_RXPAREN_MASK | UART_CTL_TXPAREN_MASK);
+	if (new->c_cflag & PARENB)
+		ctl |= (UART_CTL_RXPAREN_MASK | UART_CTL_TXPAREN_MASK);
+	ctl &= ~(UART_CTL_RXPAREVEN_MASK | UART_CTL_TXPAREVEN_MASK);
+	if (new->c_cflag & PARODD)
+		ctl |= (UART_CTL_RXPAREVEN_MASK | UART_CTL_TXPAREVEN_MASK);
+	bcm_uart_writel(port, ctl, UART_CTL_REG);
+
+	/* update Baudword register */
+	baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16);
+	quot = uart_get_divisor(port, baud) - 1;
+	bcm_uart_writel(port, quot, UART_BAUD_REG);
+
+	/* update Interrupt register */
+	ier = bcm_uart_readl(port, UART_IR_REG);
+
+	ier &= ~UART_IR_MASK(UART_IR_EXTIP);
+	if (UART_ENABLE_MS(port, new->c_cflag))
+		ier |= UART_IR_MASK(UART_IR_EXTIP);
+
+	bcm_uart_writel(port, ier, UART_IR_REG);
+
+	/* update read/ignore mask */
+	port->read_status_mask = UART_FIFO_VALID_MASK;
+	if (new->c_iflag & INPCK) {
+		port->read_status_mask |= UART_FIFO_FRAMEERR_MASK;
+		port->read_status_mask |= UART_FIFO_PARERR_MASK;
+	}
+	if (new->c_iflag & (BRKINT))
+		port->read_status_mask |= UART_FIFO_BRKDET_MASK;
+
+	port->ignore_status_mask = 0;
+	if (new->c_iflag & IGNPAR)
+		port->ignore_status_mask |= UART_FIFO_PARERR_MASK;
+	if (new->c_iflag & IGNBRK)
+		port->ignore_status_mask |= UART_FIFO_BRKDET_MASK;
+	if (!(new->c_cflag & CREAD))
+		port->ignore_status_mask |= UART_FIFO_VALID_MASK;
+
+	uart_update_timeout(port, new->c_cflag, baud);
+	bcm_uart_enable(port);
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+/*
+ * serial core request to claim uart iomem
+ */
+static int bcm_uart_request_port(struct uart_port *port)
+{
+	unsigned int size;
+
+	size = RSET_UART_SIZE;
+	if (!request_mem_region(port->mapbase, size, "bcm63xx")) {
+		dev_err(port->dev, "Memory region busy\n");
+		return -EBUSY;
+	}
+
+	port->membase = ioremap(port->mapbase, size);
+	if (!port->membase) {
+		dev_err(port->dev, "Unable to map registers\n");
+		release_mem_region(port->mapbase, size);
+		return -EBUSY;
+	}
+	return 0;
+}
+
+/*
+ * serial core request to release uart iomem
+ */
+static void bcm_uart_release_port(struct uart_port *port)
+{
+	release_mem_region(port->mapbase, RSET_UART_SIZE);
+	iounmap(port->membase);
+}
+
+/*
+ * serial core request to do any port required autoconfiguration
+ */
+static void bcm_uart_config_port(struct uart_port *port, int flags)
+{
+	if (flags & UART_CONFIG_TYPE) {
+		if (bcm_uart_request_port(port))
+			return;
+		port->type = PORT_BCM63XX;
+	}
+}
+
+/*
+ * serial core request to check that port information in serinfo are
+ * suitable
+ */
+static int bcm_uart_verify_port(struct uart_port *port,
+				struct serial_struct *serinfo)
+{
+	if (port->type != PORT_BCM63XX)
+		return -EINVAL;
+	if (port->irq != serinfo->irq)
+		return -EINVAL;
+	if (port->iotype != serinfo->io_type)
+		return -EINVAL;
+	if (port->mapbase != (unsigned long)serinfo->iomem_base)
+		return -EINVAL;
+	return 0;
+}
+
+/* serial core callbacks */
+static struct uart_ops bcm_uart_ops = {
+	.tx_empty	= bcm_uart_tx_empty,
+	.get_mctrl	= bcm_uart_get_mctrl,
+	.set_mctrl	= bcm_uart_set_mctrl,
+	.start_tx	= bcm_uart_start_tx,
+	.stop_tx	= bcm_uart_stop_tx,
+	.stop_rx	= bcm_uart_stop_rx,
+	.enable_ms	= bcm_uart_enable_ms,
+	.break_ctl	= bcm_uart_break_ctl,
+	.startup	= bcm_uart_startup,
+	.shutdown	= bcm_uart_shutdown,
+	.set_termios	= bcm_uart_set_termios,
+	.type		= bcm_uart_type,
+	.release_port	= bcm_uart_release_port,
+	.request_port	= bcm_uart_request_port,
+	.config_port	= bcm_uart_config_port,
+	.verify_port	= bcm_uart_verify_port,
+};
+
+
+
+#ifdef CONFIG_SERIAL_BCM63XX_CONSOLE
+static inline void wait_for_xmitr(struct uart_port *port)
+{
+	unsigned int tmout;
+
+	/* Wait up to 10ms for the character(s) to be sent. */
+	tmout = 10000;
+	while (--tmout) {
+		unsigned int val;
+
+		val = bcm_uart_readl(port, UART_IR_REG);
+		if (val & UART_IR_STAT(UART_IR_TXEMPTY))
+			break;
+		udelay(1);
+	}
+
+	/* Wait up to 1s for flow control if necessary */
+	if (port->flags & UPF_CONS_FLOW) {
+		tmout = 1000000;
+		while (--tmout) {
+			unsigned int val;
+
+			val = bcm_uart_readl(port, UART_EXTINP_REG);
+			if (val & UART_EXTINP_CTS_MASK)
+				break;
+			udelay(1);
+		}
+	}
+}
+
+/*
+ * output given char
+ */
+static void bcm_console_putchar(struct uart_port *port, int ch)
+{
+	wait_for_xmitr(port);
+	bcm_uart_writel(port, ch, UART_FIFO_REG);
+}
+
+/*
+ * console core request to output given string
+ */
+static void bcm_console_write(struct console *co, const char *s,
+			      unsigned int count)
+{
+	struct uart_port *port;
+	unsigned long flags;
+	int locked;
+
+	port = &ports[co->index];
+
+	local_irq_save(flags);
+	if (port->sysrq) {
+		/* bcm_uart_interrupt() already took the lock */
+		locked = 0;
+	} else if (oops_in_progress) {
+		locked = spin_trylock(&port->lock);
+	} else {
+		spin_lock(&port->lock);
+		locked = 1;
+	}
+
+	/* call helper to deal with \r\n */
+	uart_console_write(port, s, count, bcm_console_putchar);
+
+	/* and wait for char to be transmitted */
+	wait_for_xmitr(port);
+
+	if (locked)
+		spin_unlock(&port->lock);
+	local_irq_restore(flags);
+}
+
+/*
+ * console core request to setup given console, find matching uart
+ * port and setup it.
+ */
+static int bcm_console_setup(struct console *co, char *options)
+{
+	struct uart_port *port;
+	int baud = 9600;
+	int bits = 8;
+	int parity = 'n';
+	int flow = 'n';
+
+	if (co->index < 0 || co->index >= BCM63XX_NR_UARTS)
+		return -EINVAL;
+	port = &ports[co->index];
+	if (!port->membase)
+		return -ENODEV;
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+	return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct uart_driver bcm_uart_driver;
+
+static struct console bcm63xx_console = {
+	.name		= "ttyS",
+	.write		= bcm_console_write,
+	.device		= uart_console_device,
+	.setup		= bcm_console_setup,
+	.flags		= CON_PRINTBUFFER,
+	.index		= -1,
+	.data		= &bcm_uart_driver,
+};
+
+static int __init bcm63xx_console_init(void)
+{
+	register_console(&bcm63xx_console);
+	return 0;
+}
+
+console_initcall(bcm63xx_console_init);
+
+#define BCM63XX_CONSOLE	(&bcm63xx_console)
+#else
+#define BCM63XX_CONSOLE	NULL
+#endif /* CONFIG_SERIAL_BCM63XX_CONSOLE */
+
+static struct uart_driver bcm_uart_driver = {
+	.owner		= THIS_MODULE,
+	.driver_name	= "bcm63xx_uart",
+	.dev_name	= "ttyS",
+	.major		= TTY_MAJOR,
+	.minor		= 64,
+	.nr		= 1,
+	.cons		= BCM63XX_CONSOLE,
+};
+
+/*
+ * platform driver probe/remove callback
+ */
+static int __devinit bcm_uart_probe(struct platform_device *pdev)
+{
+	struct resource *res_mem, *res_irq;
+	struct uart_port *port;
+	struct clk *clk;
+	int ret;
+
+	if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS)
+		return -EINVAL;
+
+	if (ports[pdev->id].membase)
+		return -EBUSY;
+
+	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res_mem)
+		return -ENODEV;
+
+	res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!res_irq)
+		return -ENODEV;
+
+	clk = clk_get(&pdev->dev, "periph");
+	if (IS_ERR(clk))
+		return -ENODEV;
+
+	port = &ports[pdev->id];
+	memset(port, 0, sizeof(*port));
+	port->iotype = UPIO_MEM;
+	port->mapbase = res_mem->start;
+	port->irq = res_irq->start;
+	port->ops = &bcm_uart_ops;
+	port->flags = UPF_BOOT_AUTOCONF;
+	port->dev = &pdev->dev;
+	port->fifosize = 16;
+	port->uartclk = clk_get_rate(clk) / 2;
+	clk_put(clk);
+
+	ret = uart_add_one_port(&bcm_uart_driver, port);
+	if (ret) {
+		kfree(port);
+		return ret;
+	}
+	platform_set_drvdata(pdev, port);
+	return 0;
+}
+
+static int __devexit bcm_uart_remove(struct platform_device *pdev)
+{
+	struct uart_port *port;
+
+	port = platform_get_drvdata(pdev);
+	uart_remove_one_port(&bcm_uart_driver, port);
+	platform_set_drvdata(pdev, NULL);
+	/* mark port as free */
+	ports[pdev->id].membase = 0;
+	return 0;
+}
+
+/*
+ * platform driver stuff
+ */
+static struct platform_driver bcm_uart_platform_driver = {
+	.probe	= bcm_uart_probe,
+	.remove	= __devexit_p(bcm_uart_remove),
+	.driver	= {
+		.owner = THIS_MODULE,
+		.name  = "bcm63xx_uart",
+	},
+};
+
+static int __init bcm_uart_init(void)
+{
+	int ret;
+
+	ret = uart_register_driver(&bcm_uart_driver);
+	if (ret)
+		return ret;
+
+	ret = platform_driver_register(&bcm_uart_platform_driver);
+	if (ret)
+		uart_unregister_driver(&bcm_uart_driver);
+
+	return ret;
+}
+
+static void __exit bcm_uart_exit(void)
+{
+	platform_driver_unregister(&bcm_uart_platform_driver);
+	uart_unregister_driver(&bcm_uart_driver);
+}
+
+module_init(bcm_uart_init);
+module_exit(bcm_uart_exit);
+
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("Broadcom 63<xx integrated uart driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 23d2fb0..7abe73b 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -174,6 +174,9 @@
 /* Qualcomm MSM SoCs */
 #define PORT_MSM	88
 
+/* BCM63xx family SoCs */
+#define PORT_BCM63XX	89
+
 #ifdef __KERNEL__
 
 #include <linux/compiler.h>


-- 
Maxime



From mbizon@freebox.fr Fri Sep 18 13:21:40 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 13:21:46 +0200 (CEST)
Received: from smtp6-g21.free.fr ([212.27.42.6]:42393 "EHLO smtp6-g21.free.fr"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492865AbZIRLVk (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 13:21:40 +0200
Received: from smtp6-g21.free.fr (localhost [127.0.0.1])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 0E12EE08150;
	Fri, 18 Sep 2009 13:21:34 +0200 (CEST)
Received: from [213.228.1.107] (sakura.staff.proxad.net [213.228.1.107])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 29F77E08089;
	Fri, 18 Sep 2009 13:21:32 +0200 (CEST)
Subject: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
From:	Maxime Bizon <mbizon@freebox.fr>
Reply-To: mbizon@freebox.fr
To:	Wolfram Sang <w.sang@pengutronix.de>,
	Greg Kroah-Hartman <gregkh@suse.de>
Cc:	linux-pcmcia@lists.infradead.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
Content-Type: text/plain
Organization: Freebox
Date:	Fri, 18 Sep 2009 13:21:31 +0200
Message-Id: <1253272891.1627.284.camel@sakura.staff.proxad.net>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 7bit
Return-Path: <mbizon@freebox.fr>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24047
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mbizon@freebox.fr
Precedence: bulk
X-list: linux-mips


Hi Wolfram & Greg,

It seems Dominik is busy, and you're the one acking pcmcia patch at the
moment so I'm sending this to you.


This is a pcmcia/cardbus driver for the bcm63xx mips SOCs, it was
already posted twice:

last year: http://lists.infradead.org/pipermail/linux-pcmcia/2008-October/005942.html
three months ago: http://lists.infradead.org/pipermail/linux-pcmcia/2009-July/006196.html

and got no review.

Could you please have a look at it ?

Thanks !


Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---

diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
index cff75de..c146d1e 100644
--- a/arch/mips/bcm63xx/Makefile
+++ b/arch/mips/bcm63xx/Makefile
@@ -1,5 +1,5 @@
 obj-y		+= clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
-		   dev-dsp.o dev-enet.o dev-uart.o
+		   dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
 obj-y		+= boards/
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index d3fdf27..e3e6205 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -24,6 +24,7 @@
 #include <bcm63xx_dev_pci.h>
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_dsp.h>
+#include <bcm63xx_dev_pcmcia.h>
 #include <bcm63xx_dev_uart.h>
 #include <board_bcm963xx.h>
 
@@ -796,6 +797,9 @@ int __init board_register_devices(void)
 
 	bcm63xx_uart_register();
 
+	if (board.has_pccard)
+		bcm63xx_pcmcia_register();
+
 	if (board.has_enet0 &&
 	    !board_get_mac_address(board.enet0.mac_addr))
 		bcm63xx_enet_register(0, &board.enet0);
diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c
new file mode 100644
index 0000000..40ec4bc
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-pcmcia.c
@@ -0,0 +1,135 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <asm/bootinfo.h>
+#include <linux/platform_device.h>
+#include <bcm63xx_cs.h>
+#include <bcm63xx_cpu.h>
+#include <bcm63xx_dev_pcmcia.h>
+#include <bcm63xx_io.h>
+#include <bcm63xx_regs.h>
+
+static struct resource pcmcia_resources[] = {
+	/* pcmcia registers */
+	{
+		.start		= -1, /* filled at runtime */
+		.end		= -1, /* filled at runtime */
+		.flags		= IORESOURCE_MEM,
+	},
+
+	/* pcmcia memory zone resources */
+	{
+		.start		= BCM_PCMCIA_COMMON_BASE_PA,
+		.end		= BCM_PCMCIA_COMMON_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= BCM_PCMCIA_ATTR_BASE_PA,
+		.end		= BCM_PCMCIA_ATTR_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= BCM_PCMCIA_IO_BASE_PA,
+		.end		= BCM_PCMCIA_IO_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+
+	/* PCMCIA irq */
+	{
+		.start		= -1, /* filled at runtime */
+		.flags		= IORESOURCE_IRQ,
+	},
+
+	/* declare PCMCIA IO resource also */
+	{
+		.start		= BCM_PCMCIA_IO_BASE_PA,
+		.end		= BCM_PCMCIA_IO_END_PA,
+		.flags		= IORESOURCE_IO,
+	},
+};
+
+static struct bcm63xx_pcmcia_platform_data pd;
+
+static struct platform_device bcm63xx_pcmcia_device = {
+	.name		= "bcm63xx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(pcmcia_resources),
+	.resource	= pcmcia_resources,
+	.dev		= {
+		.platform_data = &pd,
+	},
+};
+
+static int __init config_pcmcia_cs(unsigned int cs,
+				   u32 base, unsigned int size)
+{
+	int ret;
+
+	ret = bcm63xx_set_cs_status(cs, 0);
+	if (!ret)
+		ret = bcm63xx_set_cs_base(cs, base, size);
+	if (!ret)
+		ret = bcm63xx_set_cs_status(cs, 1);
+	return ret;
+}
+
+static const __initdata unsigned int pcmcia_cs[3][3] = {
+	/* cs, base address, size */
+	{ MPI_CS_PCMCIA_COMMON, BCM_PCMCIA_COMMON_BASE_PA,
+	  BCM_PCMCIA_COMMON_SIZE },
+
+	{ MPI_CS_PCMCIA_ATTR, BCM_PCMCIA_ATTR_BASE_PA,
+	  BCM_PCMCIA_ATTR_SIZE },
+
+	{ MPI_CS_PCMCIA_IO, BCM_PCMCIA_IO_BASE_PA,
+	  BCM_PCMCIA_IO_SIZE },
+};
+
+int __init bcm63xx_pcmcia_register(void)
+{
+	int ret, i;
+
+	if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
+		return 0;
+
+	/* use correct pcmcia ready gpio depending on processor */
+	switch (bcm63xx_get_cpu_id()) {
+	case BCM6348_CPU_ID:
+		pd.ready_gpio = 22;
+		break;
+
+	case BCM6358_CPU_ID:
+		pd.ready_gpio = 22;
+		break;
+
+	default:
+		return -ENODEV;
+	}
+
+	pcmcia_resources[0].start = bcm63xx_regset_address(RSET_PCMCIA);
+	pcmcia_resources[0].end = pcmcia_resources[0].start;
+	pcmcia_resources[0].end += RSET_PCMCIA_SIZE - 1;
+	pcmcia_resources[4].start = bcm63xx_get_irq_number(IRQ_PCMCIA);
+
+	/* configure pcmcia chip selects */
+	for (i = 0; i < 3; i++) {
+		ret = config_pcmcia_cs(pcmcia_cs[i][0],
+				       pcmcia_cs[i][1],
+				       pcmcia_cs[i][2]);
+		if (ret)
+			goto out_err;
+	}
+
+	return platform_device_register(&bcm63xx_pcmcia_device);
+
+out_err:
+	printk(KERN_ERR "unable to set pcmcia chip select");
+	return ret;
+}
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
new file mode 100644
index 0000000..2beb396
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
@@ -0,0 +1,13 @@
+#ifndef BCM63XX_DEV_PCMCIA_H_
+#define BCM63XX_DEV_PCMCIA_H_
+
+/*
+ * PCMCIA driver platform data
+ */
+struct bcm63xx_pcmcia_platform_data {
+	unsigned int ready_gpio;
+};
+
+int bcm63xx_pcmcia_register(void);
+
+#endif /* BCM63XX_DEV_PCMCIA_H_ */
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index fbf965b..17f38a7 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -192,6 +192,10 @@ config PCMCIA_AU1X00
 	tristate "Au1x00 pcmcia support"
 	depends on SOC_AU1X00 && PCMCIA
 
+config PCMCIA_BCM63XX
+	tristate "bcm63xx pcmcia support"
+	depends on BCM63XX && PCMCIA
+
 config PCMCIA_SA1100
 	tristate "SA1100 support"
 	depends on ARM && ARCH_SA1100 && PCMCIA
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 047394d..1ee57f0 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_PCMCIA_SA1111)			+= sa11xx_core.o sa1111_cs.o
 obj-$(CONFIG_M32R_PCC)				+= m32r_pcc.o
 obj-$(CONFIG_M32R_CFC)				+= m32r_cfc.o
 obj-$(CONFIG_PCMCIA_AU1X00)			+= au1x00_ss.o
+obj-$(CONFIG_PCMCIA_BCM63XX)			+= bcm63xx_pcmcia.o
 obj-$(CONFIG_PCMCIA_VRC4171)			+= vrc4171_card.o
 obj-$(CONFIG_PCMCIA_VRC4173)			+= vrc4173_cardu.o
 obj-$(CONFIG_OMAP_CF)				+= omap_cf.o
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
new file mode 100644
index 0000000..2981aff
--- /dev/null
+++ b/drivers/pcmcia/bcm63xx_pcmcia.c
@@ -0,0 +1,537 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/timer.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/gpio.h>
+
+#include <bcm63xx_regs.h>
+#include <bcm63xx_io.h>
+#include "bcm63xx_pcmcia.h"
+
+#define PFX	"bcm63xx_pcmcia: "
+
+#ifdef CONFIG_CARDBUS
+/* if cardbus is used, platform device needs reference to actual pci
+ * device */
+static struct pci_dev *bcm63xx_cb_dev;
+#endif
+
+/*
+ * read/write helper for pcmcia regs
+ */
+static inline u32 pcmcia_readl(struct bcm63xx_pcmcia_socket *skt, u32 off)
+{
+	return bcm_readl(skt->base + off);
+}
+
+static inline void pcmcia_writel(struct bcm63xx_pcmcia_socket *skt,
+				 u32 val, u32 off)
+{
+	bcm_writel(val, skt->base + off);
+}
+
+/*
+ * (Re-)Initialise the socket, turning on status interrupts and PCMCIA
+ * bus.  This must wait for power to stabilise so that the card status
+ * signals report correctly.
+ */
+static int bcm63xx_pcmcia_sock_init(struct pcmcia_socket *sock)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	skt = sock->driver_data;
+	return 0;
+}
+
+/*
+ * Remove power on the socket, disable IRQs from the card.
+ * Turn off status interrupts, and disable the PCMCIA bus.
+ */
+static int bcm63xx_pcmcia_suspend(struct pcmcia_socket *sock)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	skt = sock->driver_data;
+	return 0;
+}
+
+/*
+ * Implements the set_socket() operation for the in-kernel PCMCIA
+ * service (formerly SS_SetSocket in Card Services). We more or
+ * less punt all of this work and let the kernel handle the details
+ * of power configuration, reset, &c. We also record the value of
+ * `state' in order to regurgitate it to the PCMCIA core later.
+ */
+static int bcm63xx_pcmcia_set_socket(struct pcmcia_socket *sock,
+				     socket_state_t *state)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	unsigned long flags;
+	u32 val;
+
+	skt = sock->driver_data;
+
+	spin_lock_irqsave(&skt->lock, flags);
+
+	/* apply requested socket power */
+	/* FIXME: hardware can't do this */
+
+	/* apply socket reset */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+	if (state->flags & SS_RESET)
+		val |= PCMCIA_C1_RESET_MASK;
+	else
+		val &= ~PCMCIA_C1_RESET_MASK;
+
+	/* reverse reset logic for cardbus card */
+	if (skt->card_detected && (skt->card_type & CARD_CARDBUS))
+		val ^= PCMCIA_C1_RESET_MASK;
+
+	pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+	/* keep requested state for event reporting */
+	skt->requested_state = *state;
+
+	spin_unlock_irqrestore(&skt->lock, flags);
+
+	return 0;
+}
+
+/*
+ * identity cardtype from VS[12] input, CD[12] input while only VS2 is
+ * floating, and CD[12] input while only VS1 is floating
+ */
+enum {
+	IN_VS1 = (1 << 0),
+	IN_VS2 = (1 << 1),
+	IN_CD1_VS2H = (1 << 2),
+	IN_CD2_VS2H = (1 << 3),
+	IN_CD1_VS1H = (1 << 4),
+	IN_CD2_VS1H = (1 << 5),
+};
+
+static const u8 vscd_to_cardtype[] = {
+
+	/* VS1 float, VS2 float */
+	[IN_VS1 | IN_VS2] = (CARD_PCCARD | CARD_5V),
+
+	/* VS1 grounded, VS2 float */
+	[IN_VS2] = (CARD_PCCARD | CARD_5V | CARD_3V),
+
+	/* VS1 grounded, VS2 grounded */
+	[0] = (CARD_PCCARD | CARD_5V | CARD_3V | CARD_XV),
+
+	/* VS1 tied to CD1, VS2 float */
+	[IN_VS1 | IN_VS2 | IN_CD1_VS1H] = (CARD_CARDBUS | CARD_3V),
+
+	/* VS1 grounded, VS2 tied to CD2 */
+	[IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V | CARD_XV),
+
+	/* VS1 tied to CD2, VS2 grounded */
+	[IN_VS1 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_3V | CARD_XV | CARD_YV),
+
+	/* VS1 float, VS2 grounded */
+	[IN_VS1] = (CARD_PCCARD | CARD_XV),
+
+	/* VS1 float, VS2 tied to CD2 */
+	[IN_VS1 | IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V),
+
+	/* VS1 float, VS2 tied to CD1 */
+	[IN_VS1 | IN_VS2 | IN_CD1_VS2H] = (CARD_CARDBUS | CARD_XV | CARD_YV),
+
+	/* VS1 tied to CD2, VS2 float */
+	[IN_VS1 | IN_VS2 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_YV),
+
+	/* VS2 grounded, VS1 is tied to CD1, CD2 is grounded */
+	[IN_VS1 | IN_CD1_VS1H] = 0, /* ignore cardbay */
+};
+
+/*
+ * poll hardware to check card insertion status
+ */
+static unsigned int __get_socket_status(struct bcm63xx_pcmcia_socket *skt)
+{
+	unsigned int stat;
+	u32 val;
+
+	stat = 0;
+
+	/* check CD for card presence */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+
+	if (!(val & PCMCIA_C1_CD1_MASK) && !(val & PCMCIA_C1_CD2_MASK))
+		stat |= SS_DETECT;
+
+	/* if new insertion, detect cardtype */
+	if ((stat & SS_DETECT) && !skt->card_detected) {
+		unsigned int stat = 0;
+
+		/* float VS1, float VS2 */
+		val |= PCMCIA_C1_VS1OE_MASK;
+		val |= PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read VS[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_VS1_MASK) ? IN_VS1 : 0;
+		stat |= (val & PCMCIA_C1_VS2_MASK) ? IN_VS2 : 0;
+
+		/* drive VS1 low, float VS2 */
+		val &= ~PCMCIA_C1_VS1OE_MASK;
+		val |= PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read CD[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS2H : 0;
+		stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS2H : 0;
+
+		/* float VS1, drive VS2 low */
+		val |= PCMCIA_C1_VS1OE_MASK;
+		val &= ~PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read CD[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS1H : 0;
+		stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS1H : 0;
+
+		/* guess cardtype from all this */
+		skt->card_type = vscd_to_cardtype[stat];
+		if (!skt->card_type)
+			printk(KERN_ERR PFX "unsupported card type\n");
+
+		/* drive both VS pin to 0 again */
+		val &= ~(PCMCIA_C1_VS1OE_MASK | PCMCIA_C1_VS2OE_MASK);
+
+		/* enable correct logic */
+		val &= ~(PCMCIA_C1_EN_PCMCIA_MASK | PCMCIA_C1_EN_CARDBUS_MASK);
+		if (skt->card_type & CARD_PCCARD)
+			val |= PCMCIA_C1_EN_PCMCIA_MASK;
+		else
+			val |= PCMCIA_C1_EN_CARDBUS_MASK;
+
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+	}
+	skt->card_detected = (stat & SS_DETECT) ? 1 : 0;
+
+	/* report card type/voltage */
+	if (skt->card_type & CARD_CARDBUS)
+		stat |= SS_CARDBUS;
+	if (skt->card_type & CARD_3V)
+		stat |= SS_3VCARD;
+	if (skt->card_type & CARD_XV)
+		stat |= SS_XVCARD;
+	stat |= SS_POWERON;
+
+	if (gpio_get_value(skt->pd->ready_gpio))
+		stat |= SS_READY;
+
+	return stat;
+}
+
+/*
+ * core request to get current socket status
+ */
+static int bcm63xx_pcmcia_get_status(struct pcmcia_socket *sock,
+				     unsigned int *status)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+
+	skt = sock->driver_data;
+
+	spin_lock_bh(&skt->lock);
+	*status = __get_socket_status(skt);
+	spin_unlock_bh(&skt->lock);
+
+	return 0;
+}
+
+/*
+ * socket polling timer callback
+ */
+static void bcm63xx_pcmcia_poll(unsigned long data)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	unsigned int stat, events;
+
+	skt = (struct bcm63xx_pcmcia_socket *)data;
+
+	spin_lock_bh(&skt->lock);
+
+	stat = __get_socket_status(skt);
+
+	/* keep only changed bits, and mask with required one from the
+	 * core */
+	events = (stat ^ skt->old_status) & skt->requested_state.csc_mask;
+	skt->old_status = stat;
+	spin_unlock_bh(&skt->lock);
+
+	if (events)
+		pcmcia_parse_events(&skt->socket, events);
+
+	mod_timer(&skt->timer,
+		  jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
+}
+
+static int bcm63xx_pcmcia_set_io_map(struct pcmcia_socket *sock,
+				     struct pccard_io_map *map)
+{
+	/* this doesn't seem to be called by pcmcia layer if static
+	 * mapping is used */
+	return 0;
+}
+
+static int bcm63xx_pcmcia_set_mem_map(struct pcmcia_socket *sock,
+				      struct pccard_mem_map *map)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct resource *res;
+
+	skt = sock->driver_data;
+	if (map->flags & MAP_ATTRIB)
+		res = skt->attr_res;
+	else
+		res = skt->common_res;
+
+	map->static_start = res->start + map->card_start;
+	return 0;
+}
+
+static struct pccard_operations bcm63xx_pcmcia_operations = {
+	.init			= bcm63xx_pcmcia_sock_init,
+	.suspend		= bcm63xx_pcmcia_suspend,
+	.get_status		= bcm63xx_pcmcia_get_status,
+	.set_socket		= bcm63xx_pcmcia_set_socket,
+	.set_io_map		= bcm63xx_pcmcia_set_io_map,
+	.set_mem_map		= bcm63xx_pcmcia_set_mem_map,
+};
+
+/*
+ * register pcmcia socket to core
+ */
+static int bcm63xx_drv_pcmcia_probe(struct platform_device *pdev)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct pcmcia_socket *sock;
+	struct resource *res, *irq_res;
+	unsigned int regmem_size = 0, iomem_size = 0;
+	u32 val;
+	int ret;
+
+	skt = kzalloc(sizeof(*skt), GFP_KERNEL);
+	if (!skt)
+		return -ENOMEM;
+	spin_lock_init(&skt->lock);
+	sock = &skt->socket;
+	sock->driver_data = skt;
+
+	/* make sure we have all resources we need */
+	skt->common_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	skt->attr_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	skt->pd = pdev->dev.platform_data;
+	if (!skt->common_res || !skt->attr_res || !irq_res || !skt->pd) {
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/* remap pcmcia registers */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	regmem_size = res->end - res->start + 1;
+	if (!request_mem_region(res->start, regmem_size, "bcm63xx_pcmcia")) {
+		ret = -EINVAL;
+		goto err;
+	}
+	skt->reg_res = res;
+
+	skt->base = ioremap(res->start, regmem_size);
+	if (!skt->base) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	/* remap io registers */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+	iomem_size = res->end - res->start + 1;
+	skt->io_base = ioremap(res->start, iomem_size);
+	if (!skt->io_base) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	/* resources are static */
+	sock->resource_ops = &pccard_static_ops;
+	sock->ops = &bcm63xx_pcmcia_operations;
+	sock->owner = THIS_MODULE;
+	sock->dev.parent = &pdev->dev;
+	sock->features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
+	sock->io_offset = (unsigned long)skt->io_base;
+	sock->pci_irq = irq_res->start;
+
+#ifdef CONFIG_CARDBUS
+	sock->cb_dev = bcm63xx_cb_dev;
+	if (bcm63xx_cb_dev)
+		sock->features |= SS_CAP_CARDBUS;
+#endif
+
+	/* assume common & attribute memory have the same size */
+	sock->map_size = skt->common_res->end - skt->common_res->start + 1;
+
+	/* initialize polling timer */
+	setup_timer(&skt->timer, bcm63xx_pcmcia_poll, (unsigned long)skt);
+
+	/* initialize  pcmcia  control register,  drive  VS[12] to  0,
+	 * leave CB IDSEL to the old  value since it is set by the PCI
+	 * layer */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+	val &= PCMCIA_C1_CBIDSEL_MASK;
+	val |= PCMCIA_C1_EN_PCMCIA_GPIO_MASK;
+	pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+	/* FIXME set correct pcmcia timings */
+	val = PCMCIA_C2_DATA16_MASK;
+	val |= 10 << PCMCIA_C2_RWCOUNT_SHIFT;
+	val |= 6 << PCMCIA_C2_INACTIVE_SHIFT;
+	val |= 3 << PCMCIA_C2_SETUP_SHIFT;
+	val |= 3 << PCMCIA_C2_HOLD_SHIFT;
+	pcmcia_writel(skt, val, PCMCIA_C2_REG);
+
+	/* request and setup ready gpio */
+	ret = gpio_request(skt->pd->ready_gpio, "bcm63xx_pcmcia");
+	if (ret < 0)
+		goto err;
+
+	ret = gpio_direction_input(skt->pd->ready_gpio);
+	if (ret < 0)
+		goto err_gpio;
+
+	ret = pcmcia_register_socket(sock);
+	if (ret)
+		goto err_gpio;
+
+	/* start polling socket */
+	mod_timer(&skt->timer,
+		  jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
+
+	platform_set_drvdata(pdev, skt);
+	return 0;
+
+err_gpio:
+	gpio_free(skt->pd->ready_gpio);
+
+err:
+	if (skt->io_base)
+		iounmap(skt->io_base);
+	if (skt->base)
+		iounmap(skt->base);
+	if (skt->reg_res)
+		release_mem_region(skt->reg_res->start, regmem_size);
+	kfree(skt);
+	return ret;
+}
+
+static int bcm63xx_drv_pcmcia_remove(struct platform_device *pdev)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct resource *res;
+
+	skt = platform_get_drvdata(pdev);
+	del_timer_sync(&skt->timer);
+	iounmap(skt->base);
+	iounmap(skt->io_base);
+	res = skt->reg_res;
+	release_mem_region(res->start, res->end - res->start + 1);
+	gpio_free(skt->pd->ready_gpio);
+	platform_set_drvdata(pdev, NULL);
+	kfree(skt);
+	return 0;
+}
+
+struct platform_driver bcm63xx_pcmcia_driver = {
+	.probe	= bcm63xx_drv_pcmcia_probe,
+	.remove	= __devexit_p(bcm63xx_drv_pcmcia_remove),
+	.driver	= {
+		.name	= "bcm63xx_pcmcia",
+		.owner  = THIS_MODULE,
+	},
+};
+
+#ifdef CONFIG_CARDBUS
+static int __devinit bcm63xx_cb_probe(struct pci_dev *dev,
+				      const struct pci_device_id *id)
+{
+	/* keep pci device */
+	bcm63xx_cb_dev = dev;
+	return platform_driver_register(&bcm63xx_pcmcia_driver);
+}
+
+static void __devexit bcm63xx_cb_exit(struct pci_dev *dev)
+{
+	platform_driver_unregister(&bcm63xx_pcmcia_driver);
+	bcm63xx_cb_dev = NULL;
+}
+
+static struct pci_device_id bcm63xx_cb_table[] = {
+	{
+		.vendor		= PCI_VENDOR_ID_BROADCOM,
+		.device		= PCI_ANY_ID,
+		.subvendor	= PCI_VENDOR_ID_BROADCOM,
+		.subdevice	= PCI_ANY_ID,
+		.class		= PCI_CLASS_BRIDGE_CARDBUS << 8,
+		.class_mask	= ~0,
+	},
+
+	{ },
+};
+
+MODULE_DEVICE_TABLE(pci, bcm63xx_cb_table);
+
+static struct pci_driver bcm63xx_cardbus_driver = {
+	.name		= "yenta_cardbus",
+	.id_table	= bcm63xx_cb_table,
+	.probe		= bcm63xx_cb_probe,
+	.remove		= __devexit_p(bcm63xx_cb_exit),
+};
+#endif
+
+/*
+ * if cardbus support is enabled, register our platform device after
+ * our fake cardbus bridge has been registered
+ */
+static int __init bcm63xx_pcmcia_init(void)
+{
+#ifdef CONFIG_CARDBUS
+	return pci_register_driver(&bcm63xx_cardbus_driver);
+#else
+	return platform_driver_register(&bcm63xx_pcmcia_driver);
+#endif
+}
+
+static void __exit bcm63xx_pcmcia_exit(void)
+{
+#ifdef CONFIG_CARDBUS
+	return pci_unregister_driver(&bcm63xx_cardbus_driver);
+#else
+	platform_driver_unregister(&bcm63xx_pcmcia_driver);
+#endif
+}
+
+module_init(bcm63xx_pcmcia_init);
+module_exit(bcm63xx_pcmcia_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm63xx Socket Controller");
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.h b/drivers/pcmcia/bcm63xx_pcmcia.h
new file mode 100644
index 0000000..85de866
--- /dev/null
+++ b/drivers/pcmcia/bcm63xx_pcmcia.h
@@ -0,0 +1,65 @@
+#ifndef BCM63XX_PCMCIA_H_
+#define BCM63XX_PCMCIA_H_
+
+#include <linux/types.h>
+#include <linux/timer.h>
+#include <pcmcia/ss.h>
+#include <bcm63xx_dev_pcmcia.h>
+
+/* socket polling rate in ms */
+#define BCM63XX_PCMCIA_POLL_RATE	500
+
+enum {
+	CARD_CARDBUS = (1 << 0),
+
+	CARD_PCCARD = (1 << 1),
+
+	CARD_5V = (1 << 2),
+
+	CARD_3V = (1 << 3),
+
+	CARD_XV = (1 << 4),
+
+	CARD_YV = (1 << 5),
+};
+
+struct bcm63xx_pcmcia_socket {
+	struct pcmcia_socket socket;
+
+	/* platform specific data */
+	struct bcm63xx_pcmcia_platform_data *pd;
+
+	/* all regs access are protected by this spinlock */
+	spinlock_t lock;
+
+	/* pcmcia registers resource */
+	struct resource *reg_res;
+
+	/* base remapped address of registers */
+	void __iomem *base;
+
+	/* whether a card is detected at the moment */
+	int card_detected;
+
+	/* type of detected card (mask of above enum) */
+	u8 card_type;
+
+	/* keep last socket status to implement event reporting */
+	unsigned int old_status;
+
+	/* backup of requested socket state */
+	socket_state_t requested_state;
+
+	/* timer used for socket status polling */
+	struct timer_list timer;
+
+	/* attribute/common memory resources */
+	struct resource *attr_res;
+	struct resource *common_res;
+	struct resource *io_res;
+
+	/* base address of io memory */
+	void __iomem *io_base;
+};
+
+#endif /* BCM63XX_PCMCIA_H_ */


-- 
Maxime



From ralf@linux-mips.org Fri Sep 18 15:47:59 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 15:48:02 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:47510 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1493166AbZIRNr7 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 15:47:59 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8IDn5JO014010;
	Fri, 18 Sep 2009 15:49:05 +0200
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8IDn4PB014006;
	Fri, 18 Sep 2009 15:49:04 +0200
Date:	Fri, 18 Sep 2009 15:49:04 +0200
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Huang Weiyi <weiyi.huang@gmail.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 1/2] MIPS: BCM63xx: remove duplicated #include
Message-ID: <20090918134904.GA13602@linux-mips.org>
References: <1253258059-3340-1-git-send-email-weiyi.huang@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253258059-3340-1-git-send-email-weiyi.huang@gmail.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24048
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Fri, Sep 18, 2009 at 03:14:19PM +0800, Huang Weiyi wrote:
> From: Huang Weiyi <weiyi.huang@gmail.com>
> Date: Fri, 18 Sep 2009 15:14:19 +0800
> To: ralf@linux-mips.org
> Cc: linux-mips@linux-mips.org, Huang Weiyi <weiyi.huang@gmail.com>
> Subject: [PATCH 1/2] MIPS: BCM63xx: remove duplicated #include
> 
> Remove duplicated #include('s) in
>   arch/mips/bcm63xx/boards/board_bcm963xx.c
> 
> Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>

Applied.  Thanks,

  Ralf

From ralf@linux-mips.org Fri Sep 18 15:48:19 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 15:48:24 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:47514 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1493191AbZIRNsN (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 15:48:13 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8IDnM4w014017;
	Fri, 18 Sep 2009 15:49:22 +0200
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8IDnMMG014016;
	Fri, 18 Sep 2009 15:49:22 +0200
Date:	Fri, 18 Sep 2009 15:49:22 +0200
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Huang Weiyi <weiyi.huang@gmail.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 2/2] MIPS: remove duplicated #include
Message-ID: <20090918134922.GB13602@linux-mips.org>
References: <1253258075-3088-1-git-send-email-weiyi.huang@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253258075-3088-1-git-send-email-weiyi.huang@gmail.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24049
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Fri, Sep 18, 2009 at 03:14:35PM +0800, Huang Weiyi wrote:
> From: Huang Weiyi <weiyi.huang@gmail.com>
> Date: Fri, 18 Sep 2009 15:14:35 +0800
> To: ralf@linux-mips.org
> Cc: linux-mips@linux-mips.org, Huang Weiyi <weiyi.huang@gmail.com>
> Subject: [PATCH 2/2] MIPS: remove duplicated #include
> 
> Remove duplicated #include('s) in
>   arch/mips/kernel/smp.c
> 
> Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>

Applied.  Thanks,

  Ralf

From gregkh@suse.de Fri Sep 18 16:57:36 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 16:57:42 +0200 (CEST)
Received: from cantor.suse.de ([195.135.220.2]:58985 "EHLO mx1.suse.de"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493166AbZIRO5g (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 16:57:36 +0200
Received: from relay2.suse.de (mail2.suse.de [195.135.221.8])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.suse.de (Postfix) with ESMTP id F1CB48E8CC;
	Fri, 18 Sep 2009 16:57:35 +0200 (CEST)
Date:	Fri, 18 Sep 2009 07:57:15 -0700
From:	Greg KH <gregkh@suse.de>
To:	Maxime Bizon <mbizon@freebox.fr>
Cc:	linux-serial@vger.kernel.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: BCM63xx: Add serial driver for bcm63xx
	integrated UART.
Message-ID: <20090918145715.GB8884@suse.de>
References: <1253271898.1627.272.camel@sakura.staff.proxad.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253271898.1627.272.camel@sakura.staff.proxad.net>
User-Agent: Mutt/1.5.17 (2007-11-01)
Return-Path: <gregkh@suse.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24050
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: gregkh@suse.de
Precedence: bulk
X-list: linux-mips

On Fri, Sep 18, 2009 at 01:04:58PM +0200, Maxime Bizon wrote:
> 
> Hi Greg,
> 
> This is a serial driver for the bcm63xx mips SOCs, it was already posted
> twice:
> 
> one year ago: http://marc.info/?l=linux-serial&m=122438266322439&w=2
> three months ago: http://lkml.org/lkml/2009/7/1/370
> 
> but got no review or ack.
> 
> 
> Linus merged the SOC support patch from Ralf tree yesterday, but without
> serial support.
> 
> Could you please have a look at it ? Is it ok if it goes upstream
> through Ralf tree ?

I have no objection for this to go through Ralf's tree.  Or if he needs
it to go through mine, just let me know.

> Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

Acked-by: Greg Kroah-Hartman <gregkh@suse.de>


thanks,

greg k-h

From gregkh@suse.de Fri Sep 18 18:10:06 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 18:10:12 +0200 (CEST)
Received: from cantor.suse.de ([195.135.220.2]:60646 "EHLO mx1.suse.de"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493262AbZIRQKG (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 18:10:06 +0200
Received: from relay2.suse.de (mail2.suse.de [195.135.221.8])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.suse.de (Postfix) with ESMTP id B2CFE8D893;
	Fri, 18 Sep 2009 18:10:03 +0200 (CEST)
Date:	Fri, 18 Sep 2009 09:07:37 -0700
From:	Greg KH <gregkh@suse.de>
To:	Maxime Bizon <mbizon@freebox.fr>
Cc:	Wolfram Sang <w.sang@pengutronix.de>,
	linux-pcmcia@lists.infradead.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
Message-ID: <20090918160737.GD22717@suse.de>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253272891.1627.284.camel@sakura.staff.proxad.net>
User-Agent: Mutt/1.5.20 (2009-06-14)
Return-Path: <gregkh@suse.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24051
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: gregkh@suse.de
Precedence: bulk
X-list: linux-mips

On Fri, Sep 18, 2009 at 01:21:31PM +0200, Maxime Bizon wrote:
> 
> Hi Wolfram & Greg,
> 
> It seems Dominik is busy, and you're the one acking pcmcia patch at the
> moment so I'm sending this to you.
> 
> 
> This is a pcmcia/cardbus driver for the bcm63xx mips SOCs, it was
> already posted twice:
> 
> last year: http://lists.infradead.org/pipermail/linux-pcmcia/2008-October/005942.html
> three months ago: http://lists.infradead.org/pipermail/linux-pcmcia/2009-July/006196.html
> 
> and got no review.
> 
> Could you please have a look at it ?

I'll trust Wolfram on these.  If he queues stuff up, I can get them to
Linus.

thanks,

greg k-h

From sshtylyov@ru.mvista.com Fri Sep 18 18:19:56 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 18:20:03 +0200 (CEST)
Received: from h155.mvista.com ([63.81.120.155]:36406 "EHLO imap.sh.mvista.com"
	rhost-flags-OK-FAIL-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S2097367AbZIRQT4 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 18:19:56 +0200
Received: from [192.168.11.189] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id C773A3ECA; Fri, 18 Sep 2009 09:19:50 -0700 (PDT)
Message-ID: <4AB3B3B9.1040804@ru.mvista.com>
Date:	Fri, 18 Sep 2009 20:22:17 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc:	ralf.roesch@rw-gmbh.de, linux-mips@linux-mips.org,
	Julia Lawall <julia@diku.dk>
Subject: Re: [PATCH] MIPS: TXx9: Fix error handling / Fix for noenexisting
 gpio_remove.
References: <1253080880-11123-1-git-send-email-ralf.roesch@rw-gmbh.de> <20090917.225259.173376281.anemo@mba.ocn.ne.jp>
In-Reply-To: <20090917.225259.173376281.anemo@mba.ocn.ne.jp>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24052
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips

Hello.

Atsushi Nemoto wrote:

>>error was introduced by commit 0385d1f3d394c6814be0b165c153fc3fc254469a

> Thanks, this patch should be holded into the original commit before
> mainlining.  The result should be same as Julia's revised patch.

> I don't mind ether way, I just hope keeping bisectability on mainline.
> Is it too late, (yet another) Ralf ?

    Well, Ralf B. has already committed Julia's broken patch at 9/14.

> ---
> Atsushi Nemoto

WBR, Sergei

From julia@diku.dk Fri Sep 18 22:03:23 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 22:03:30 +0200 (CEST)
Received: from mgw2.diku.dk ([130.225.96.92]:49470 "EHLO mgw2.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S2097378AbZIRUDX (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 18 Sep 2009 22:03:23 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw2.diku.dk (Postfix) with ESMTP id 6C20619BCCC;
	Fri, 18 Sep 2009 22:03:18 +0200 (CEST)
Received: from mgw2.diku.dk ([127.0.0.1])
 by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
 id 27430-11; Fri, 18 Sep 2009 22:03:17 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw2.diku.dk (Postfix) with ESMTP id 62C7D19BCC3;
	Fri, 18 Sep 2009 22:03:17 +0200 (CEST)
Received: from ask.diku.dk (ask.diku.dk [130.225.96.225])
	by nhugin.diku.dk (Postfix) with ESMTP
	id E57976DF835; Fri, 18 Sep 2009 22:01:20 +0200 (CEST)
Received: by ask.diku.dk (Postfix, from userid 3767)
	id 49EABF455; Fri, 18 Sep 2009 22:03:17 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by ask.diku.dk (Postfix) with ESMTP id 447E3F0AB;
	Fri, 18 Sep 2009 22:03:17 +0200 (CEST)
Date:	Fri, 18 Sep 2009 22:03:17 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: question about arch/mips/kernel/smtc.c
Message-ID: <Pine.LNX.4.64.0909182202140.4238@ask.diku.dk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-Virus-Scanned: amavisd-new at diku.dk
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24053
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

The file arch/mips/kernel/smtc.c contains:

static struct irqaction irq_ipi = {
        .handler        = ipi_interrupt,
        .flags          = IRQF_DISABLED,
        .name           = "SMTC_IPI",
        .flags          = IRQF_PERCPU
};

Is it intentional that there are two definitions of the flags field?

julia

From rientjes@google.com Fri Sep 18 22:11:28 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 22:11:35 +0200 (CEST)
Received: from smtp-out.google.com ([216.239.33.17]:61522 "EHLO
	smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S2097375AbZIRUL2 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 18 Sep 2009 22:11:28 +0200
Received: from spaceape9.eur.corp.google.com (spaceape9.eur.corp.google.com [172.28.16.143])
	by smtp-out.google.com with ESMTP id n8IK75tE030534;
	Fri, 18 Sep 2009 21:07:07 +0100
DKIM-Signature:	v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;
	t=1253304537; bh=a9u8/sl/HzTGw1crlweuy9VAk6Q=;
	h=DomainKey-Signature:Date:From:X-X-Sender:To:cc:Subject:
	 In-Reply-To:Message-ID:References:User-Agent:MIME-Version:
	 Content-Type:X-System-Of-Record; b=G963yvRsZsKmZUX2/8X6F1ln8A4BEho
	6K+/wHv7BvrnySp+b+/MHlZX7AqHZ8lkcuQ7uxhbtOVcJWsTMgV5heQ==
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;
	h=date:from:x-x-sender:to:cc:subject:in-reply-to:message-id:
	references:user-agent:mime-version:content-type:x-system-of-record;
	b=SK+6RYKM6CWCyX7+34nyjHaVulT8j++2YFog35khPxfnXcLLQfFej3IFgcUJcserp
	23CkfsBvDIZlVX3V72ygw==
Received: from pzk28 (pzk28.prod.google.com [10.243.19.156])
	by spaceape9.eur.corp.google.com with ESMTP id n8IK6kZr005078;
	Fri, 18 Sep 2009 13:07:03 -0700
Received: by pzk28 with SMTP id 28so1070873pzk.5
        for <multiple recipients>; Fri, 18 Sep 2009 13:07:02 -0700 (PDT)
Received: by 10.114.19.30 with SMTP id 30mr3057868was.134.1253304422371;
        Fri, 18 Sep 2009 13:07:02 -0700 (PDT)
Received: from chino.kir.corp.google.com (chino.kir.corp.google.com [172.31.12.59])
        by mx.google.com with ESMTPS id 22sm658830pzk.14.2009.09.18.13.07.00
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 18 Sep 2009 13:07:01 -0700 (PDT)
Date:	Fri, 18 Sep 2009 13:06:59 -0700 (PDT)
From:	David Rientjes <rientjes@google.com>
X-X-Sender: rientjes@chino.kir.corp.google.com
To:	Eric B Munson <ebmunson@us.ibm.com>
cc:	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, rdunlap@xenotime.net,
	michael@ellerman.id.au, ralf@linux-mips.org, wli@holomorphy.com,
	mel@csn.ul.ie, dhowells@redhat.com, arnd@arndb.de,
	fengguang.wu@intel.com, shuber2@gmail.com,
	hugh.dickins@tiscali.co.uk, zohar@us.ibm.com, hugh@veritas.com,
	mtk.manpages@gmail.com, chris@zankel.net,
	linux-man@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-alpha@vger.kernel.org, linux-mips@linux-mips.org,
	linux-parisc@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH 1/7] hugetlbfs: Allow the creation of files suitable for
 MAP_PRIVATE on the vfs internal mount
In-Reply-To: <0f28cb0d89a7b83f7edf92181c5d13422f5b009c.1253276847.git.ebmunson@us.ibm.com>
Message-ID: <alpine.DEB.1.00.0909181306450.27556@chino.kir.corp.google.com>
References: <653aa659fd7970f7428f4eb41fa10693064e4daf.1253272709.git.ebmunson@us.ibm.com> <0f28cb0d89a7b83f7edf92181c5d13422f5b009c.1253276847.git.ebmunson@us.ibm.com>
User-Agent: Alpine 1.00 (DEB 882 2007-12-20)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-System-Of-Record: true
Return-Path: <rientjes@google.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24054
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: rientjes@google.com
Precedence: bulk
X-list: linux-mips

On Fri, 18 Sep 2009, Eric B Munson wrote:

> There are two means of creating mappings backed by huge pages:
> 
>         1. mmap() a file created on hugetlbfs
>         2. Use shm which creates a file on an internal mount which essentially
>            maps it MAP_SHARED
> 
> The internal mount is only used for shared mappings but there is very
> little that stops it being used for private mappings. This patch extends
> hugetlbfs_file_setup() to deal with the creation of files that will be
> mapped MAP_PRIVATE on the internal hugetlbfs mount. This extended API is
> used in a subsequent patch to implement the MAP_HUGETLB mmap() flag.
> 
> Signed-off-by: Eric Munson <ebmunson@us.ibm.com>

Acked-by: David Rientjes <rientjes@google.com>

From rientjes@google.com Fri Sep 18 22:12:50 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 18 Sep 2009 22:12:58 +0200 (CEST)
Received: from smtp-out.google.com ([216.239.33.17]:61950 "EHLO
	smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S2097378AbZIRUMu (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 18 Sep 2009 22:12:50 +0200
Received: from spaceape10.eur.corp.google.com (spaceape10.eur.corp.google.com [172.28.16.144])
	by smtp-out.google.com with ESMTP id n8IK8SBx029820;
	Fri, 18 Sep 2009 21:08:29 +0100
DKIM-Signature:	v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;
	t=1253304622; bh=wXY/xbSoeKeP/UnNPC5kfD6E6T0=;
	h=DomainKey-Signature:Date:From:X-X-Sender:To:cc:Subject:
	 In-Reply-To:Message-ID:References:User-Agent:MIME-Version:
	 Content-Type:X-System-Of-Record; b=b5jjV2xZcvLojoKs5XwUbncRdSrjpOH
	qj2fA94tirxKST/n6Jkac6W7Ijs1CEtI0bBCAEVr7BnDz6DFh1IgMQA==
DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;
	h=date:from:x-x-sender:to:cc:subject:in-reply-to:message-id:
	references:user-agent:mime-version:content-type:x-system-of-record;
	b=M5moPOQwk+gcOMMEZQv+1U+vlkgf2t48QGXUQbZfSG0CYyBMvo/fLnI+wa9DqGuwY
	weCOo/azhiDHv98jvPSzg==
Received: from pzk41 (pzk41.prod.google.com [10.243.19.169])
	by spaceape10.eur.corp.google.com with ESMTP id n8IK8Pbr014019;
	Fri, 18 Sep 2009 13:08:26 -0700
Received: by pzk41 with SMTP id 41so925541pzk.4
        for <multiple recipients>; Fri, 18 Sep 2009 13:08:25 -0700 (PDT)
Received: by 10.114.242.5 with SMTP id p5mr3091656wah.66.1253304503603;
        Fri, 18 Sep 2009 13:08:23 -0700 (PDT)
Received: from chino.kir.corp.google.com (chino.kir.corp.google.com [172.31.12.59])
        by mx.google.com with ESMTPS id 22sm661834pzk.10.2009.09.18.13.08.22
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 18 Sep 2009 13:08:23 -0700 (PDT)
Date:	Fri, 18 Sep 2009 13:08:22 -0700 (PDT)
From:	David Rientjes <rientjes@google.com>
X-X-Sender: rientjes@chino.kir.corp.google.com
To:	Eric B Munson <ebmunson@us.ibm.com>
cc:	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, rdunlap@xenotime.net,
	michael@ellerman.id.au, ralf@linux-mips.org, wli@holomorphy.com,
	mel@csn.ul.ie, dhowells@redhat.com, arnd@arndb.de,
	fengguang.wu@intel.com, shuber2@gmail.com,
	hugh.dickins@tiscali.co.uk, zohar@us.ibm.com, hugh@veritas.com,
	mtk.manpages@gmail.com, chris@zankel.net,
	linux-man@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-alpha@vger.kernel.org, linux-mips@linux-mips.org,
	linux-parisc@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: [PATCH 2/7] Add MAP_HUGETLB for mmaping pseudo-anonymous huge
 page regions
In-Reply-To: <08251014d2eb30e9016bab16404133f5c13beacf.1253272709.git.ebmunson@us.ibm.com>
Message-ID: <alpine.DEB.1.00.0909181308110.27556@chino.kir.corp.google.com>
References: <cover.1253272709.git.ebmunson@us.ibm.com> <653aa659fd7970f7428f4eb41fa10693064e4daf.1253272709.git.ebmunson@us.ibm.com> <08251014d2eb30e9016bab16404133f5c13beacf.1253272709.git.ebmunson@us.ibm.com>
User-Agent: Alpine 1.00 (DEB 882 2007-12-20)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-System-Of-Record: true
Return-Path: <rientjes@google.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24055
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: rientjes@google.com
Precedence: bulk
X-list: linux-mips

On Fri, 18 Sep 2009, Eric B Munson wrote:

> This patch adds a flag for mmap that will be used to request a huge
> page region that will look like anonymous memory to user space.  This
> is accomplished by using a file on the internal vfsmount.  MAP_HUGETLB
> is a modifier of MAP_ANONYMOUS and so must be specified with it.  The
> region will behave the same as a MAP_ANONYMOUS region using small pages.
> 
> Signed-off-by: Eric B Munson <ebmunson@us.ibm.com>

Acked-by: David Rientjes <rientjes@google.com>

From cernekee@gmail.com Sat Sep 19 04:21:50 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 19 Sep 2009 04:21:58 +0200 (CEST)
Received: from [65.98.92.6] ([65.98.92.6]:1696 "EHLO b32.net"
	rhost-flags-FAIL-FAIL-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1491787AbZISCVu (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 19 Sep 2009 04:21:50 +0200
Received: (qmail 32385 invoked from network); 19 Sep 2009 02:21:44 -0000
Received: from unknown (HELO two) (127.0.0.1)
  by 127.0.0.1 with SMTP; 19 Sep 2009 02:21:44 -0000
Received: by two (sSMTP sendmail emulation); Fri, 18 Sep 2009 19:21:44 -0700
From:	Kevin Cernekee <cernekee@gmail.com>
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	<linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>
Date:	Fri, 18 Sep 2009 19:12:45 -0700
Subject: [PATCH] MIPS: Avoid destructive invalidation on partial L2 cachelines
Message-Id: <de70b67245e012ab0c11b520a721989b@localhost>
User-Agent: vim 7.1
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Return-Path: <cernekee@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24056
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: cernekee@gmail.com
Precedence: bulk
X-list: linux-mips

This extends commit a8ca8b64e3fdfec17679cba0ca5ce6e3ffed092d to cover
the board cache code.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
---
 arch/mips/mm/sc-mips.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/mips/mm/sc-mips.c b/arch/mips/mm/sc-mips.c
index b55c2d1..5ab5fa8 100644
--- a/arch/mips/mm/sc-mips.c
+++ b/arch/mips/mm/sc-mips.c
@@ -32,6 +32,11 @@ static void mips_sc_wback_inv(unsigned long addr, unsigned long size)
  */
 static void mips_sc_inv(unsigned long addr, unsigned long size)
 {
+	unsigned long lsize = cpu_scache_line_size();
+	unsigned long almask = ~(lsize - 1);
+
+	cache_op(Hit_Writeback_Inv_SD, addr & almask);
+	cache_op(Hit_Writeback_Inv_SD, (addr + size - 1) & almask);
 	blast_inv_scache_range(addr, addr + size);
 }
 
-- 
1.6.3.1


From f.fainelli@gmail.com Sat Sep 19 12:43:25 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 19 Sep 2009 12:43:31 +0200 (CEST)
Received: from mail-ew0-f225.google.com ([209.85.219.225]:35310 "EHLO
	mail-ew0-f225.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492369AbZISKnZ convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Sat, 19 Sep 2009 12:43:25 +0200
Received: by ewy25 with SMTP id 25so1826469ewy.33
        for <multiple recipients>; Sat, 19 Sep 2009 03:43:19 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:sender:from:reply-to:to
         :subject:date:user-agent:cc:references:in-reply-to:mime-version
         :content-type:content-transfer-encoding:content-disposition
         :message-id;
        bh=2abi43fqIlgh8GSk5rP/ZNCSVAQ0GVEuz0P2rto7uHE=;
        b=LDe5E3DvIefFwr7zrrG+ahEcqBi2eT2bhGunJ/RGusoXS0XuRyzXeTVeFQA3tks0aK
         76top25kGy9l7YieFw2UXzG2k9J0MHDkC3kTh9ZDiXOVrUQjhmeScPFx4UZbWnOYxIFv
         re890TW/TwufQsFKs3PNrj9ldsPWcEyc/YK0c=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=sender:from:reply-to:to:subject:date:user-agent:cc:references
         :in-reply-to:mime-version:content-type:content-transfer-encoding
         :content-disposition:message-id;
        b=aBQp397FWiBH8QIx1ykdLaQ6v9mojPHaQHNLlwv6lLNEuU4V383eonBuqpgLkDej48
         er0r9iTYPwMRdwjIsBn6N8WdQJ+AULkE7ltLkV3XQ1tki254Ibw2lk1BJsiuenYEIF0F
         SL1wRFiTHaVD6XbG5TNZzfT/Ikh0Ya37qvO2Q=
Received: by 10.210.60.13 with SMTP id i13mr669665eba.8.1253356999442;
        Sat, 19 Sep 2009 03:43:19 -0700 (PDT)
Received: from lenovo.localnet (147.59.76-86.rev.gaoland.net [86.76.59.147])
        by mx.google.com with ESMTPS id 28sm2932206eyg.9.2009.09.19.03.43.17
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Sat, 19 Sep 2009 03:43:18 -0700 (PDT)
From:	Florian Fainelli <florian@openwrt.org>
Reply-To: Florian Fainelli <florian@openwrt.org>
To:	David Miller <davem@davemloft.net>
Subject: Re: [PATCH] cpmac: fix compilation errors against undeclared BUS_ID_SIZE
Date:	Sat, 19 Sep 2009 12:43:08 +0200
User-Agent: KMail/1.11.4 (Linux/2.6.29-2-686; KDE/4.2.4; i686; ; )
Cc:	netdev@vger.kernel.org, Ralf Baechle <ralf@linux-mips.org>,
	linux-mips@linux-mips.org
References: <200909160944.24265.florian@openwrt.org>
In-Reply-To: <200909160944.24265.florian@openwrt.org>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 8BIT
Content-Disposition: inline
Message-Id: <200909191243.09166.florian@openwrt.org>
Return-Path: <f.fainelli@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24057
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: florian@openwrt.org
Precedence: bulk
X-list: linux-mips

David,

Ping ? This fixes a build failure. Thank you very much !

Le mercredi 16 septembre 2009 09:44:22, Florian Fainelli a Ã©crit :
> Hi David,
>
> This is relevant for 2.6.32-rc0, thanks !
> --
> From: Florian Fainelli <florian@openwrt.org>
> Subject: [PATCH] cpmac: fix compilation errors against undeclared
> BUS_ID_SIZE
>
> With the removal of BUS_ID_SIZE, cpmac was not fully
> converted to use MII_BUS_ID_SIZE as it ought to. This
> patch fixes the following cpmac build failure:
>  CC      drivers/net/cpmac.o
> drivers/net/cpmac.c: In function 'cpmac_start_xmit':
> drivers/net/cpmac.c:563: warning: comparison of distinct pointer types
> lacks a cast drivers/net/cpmac.c: In function 'cpmac_probe':
> drivers/net/cpmac.c:1112: error: 'BUS_ID_SIZE' undeclared (first use in
> this function) drivers/net/cpmac.c:1112: error: (Each undeclared identifier
> is reported only once drivers/net/cpmac.c:1112: error: for each function it
> appears in.)
>
> Reported-by: Ralf Baechle <ralf@linux-mips.org>
> Signed-off-by: Florian Fainelli <florian@openwrt.org>
> ---
> diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c
> index 3e3fab8..61f9da2 100644
> --- a/drivers/net/cpmac.c
> +++ b/drivers/net/cpmac.c
> @@ -1109,7 +1109,7 @@ static int external_switch;
>  static int __devinit cpmac_probe(struct platform_device *pdev)
>  {
>  	int rc, phy_id;
> -	char mdio_bus_id[BUS_ID_SIZE];
> +	char mdio_bus_id[MII_BUS_ID_SIZE];
>  	struct resource *mem;
>  	struct cpmac_priv *priv;
>  	struct net_device *dev;
> @@ -1118,7 +1118,7 @@ static int __devinit cpmac_probe(struct
> platform_device *pdev) pdata = pdev->dev.platform_data;
>
>  	if (external_switch || dumb_switch) {
> -		strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */
> +		strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */
>  		phy_id = pdev->id;
>  	} else {
>  		for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) {
> @@ -1126,7 +1126,7 @@ static int __devinit cpmac_probe(struct
> platform_device *pdev) continue;
>  			if (!cpmac_mii->phy_map[phy_id])
>  				continue;
> -			strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE);
> +			strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE);
>  			break;
>  		}
>  	}
> @@ -1167,7 +1167,7 @@ static int __devinit cpmac_probe(struct
> platform_device *pdev) priv->msg_enable = netif_msg_init(debug_level,
> 0xff);
>  	memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
>
> -	snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id);
> +	snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id,
> phy_id);
>
>  	priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0,
>  						PHY_INTERFACE_MODE_MII);

-- 
Best regards, Florian Fainelli
Email: florian@openwrt.org
Web: http://openwrt.org
IRC: [florian] on irc.freenode.net
-------------------------------

From wsa@pengutronix.de Sat Sep 19 17:48:07 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 19 Sep 2009 17:48:13 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:47445 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493070AbZISPsG (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 19 Sep 2009 17:48:06 +0200
Received: from octopus.hi.pengutronix.de ([2001:6f8:1178:2:215:17ff:fe12:23b0])
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <wsa@pengutronix.de>)
	id 1Mp2AH-0004t9-Sf; Sat, 19 Sep 2009 17:47:57 +0200
Received: from wsa by octopus.hi.pengutronix.de with local (Exim 4.69)
	(envelope-from <wsa@pengutronix.de>)
	id 1Mp2AF-0002qa-99; Sat, 19 Sep 2009 17:47:55 +0200
Date:	Sat, 19 Sep 2009 17:47:55 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	Maxime Bizon <mbizon@freebox.fr>
Cc:	Greg Kroah-Hartman <gregkh@suse.de>, linux-mips@linux-mips.org,
	linux-pcmcia@lists.infradead.org,
	Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
Message-ID: <20090919154755.GA27704@pengutronix.de>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="bp/iNruPH9dso1Pn"
Content-Disposition: inline
In-Reply-To: <1253272891.1627.284.camel@sakura.staff.proxad.net>
User-Agent: Mutt/1.5.18 (2008-05-17)
X-SA-Exim-Connect-IP: 2001:6f8:1178:2:215:17ff:fe12:23b0
X-SA-Exim-Mail-From: wsa@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <wsa@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24058
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips


--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi, Maxime,

On Fri, Sep 18, 2009 at 01:21:31PM +0200, Maxime Bizon wrote:

> It seems Dominik is busy, and you're the one acking pcmcia patch at the
> moment so I'm sending this to you.

I can't make it for 2.6.32, but will try to get it queued for 2.6.33. What
about the second FIXME in the driver BTW?

Regards,

   Wolfram

--=20
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

--bp/iNruPH9dso1Pn
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkq0/SsACgkQD27XaX1/VRvkJACgkEHn15VkqwUJJWZb6oqgBp1+
QcQAn06yTBgPiL2LaXpME/Tard5ZSATG
=1cc6
-----END PGP SIGNATURE-----

--bp/iNruPH9dso1Pn--

From ukl@pengutronix.de Mon Sep 21 10:41:01 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 21 Sep 2009 10:41:09 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:52503 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492473AbZIUIlB (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 21 Sep 2009 10:41:01 +0200
Received: from octopus.hi.pengutronix.de ([2001:6f8:1178:2:215:17ff:fe12:23b0])
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <ukl@pengutronix.de>)
	id 1MpeS0-0005L9-LB; Mon, 21 Sep 2009 10:40:48 +0200
Received: from ukl by octopus.hi.pengutronix.de with local (Exim 4.69)
	(envelope-from <ukl@pengutronix.de>)
	id 1MpeRx-0005yE-B9; Mon, 21 Sep 2009 10:40:45 +0200
From:	=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= 
	<u.kleine-koenig@pengutronix.de>
To:	linux-mips@linux-mips.org, oprofile-list@lists.sf.net
Cc:	Wu Zhangjin <wuzj@lemote.com>, Yanhua <yanh@lemote.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Robert Richter <robert.richter@amd.com>
Subject: [PATCH 3/3] Fix typo "enalbe" -> "enable"
Date:	Mon, 21 Sep 2009 10:40:37 +0200
Message-Id: <1253522437-22919-1-git-send-email-u.kleine-koenig@pengutronix.de>
X-Mailer: git-send-email 1.6.4.3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-SA-Exim-Connect-IP: 2001:6f8:1178:2:215:17ff:fe12:23b0
X-SA-Exim-Mail-From: ukl@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <ukl@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24059
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ukl@pengutronix.de
Precedence: bulk
X-list: linux-mips

Signed-off-by: Uwe Kleine-KÃ¶nig <u.kleine-koenig@pengutronix.de>
Cc: Wu Zhangjin <wuzj@lemote.com>
Cc: Yanhua <yanh@lemote.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Robert Richter <robert.richter@amd.com>
---
 arch/mips/oprofile/op_model_loongson2.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/mips/oprofile/op_model_loongson2.c b/arch/mips/oprofile/op_model_loongson2.c
index 655cb8d..deed1d5 100644
--- a/arch/mips/oprofile/op_model_loongson2.c
+++ b/arch/mips/oprofile/op_model_loongson2.c
@@ -44,7 +44,7 @@ static struct loongson2_register_config {
 	unsigned int ctrl;
 	unsigned long long reset_counter1;
 	unsigned long long reset_counter2;
-	int cnt1_enalbed, cnt2_enalbed;
+	int cnt1_enabled, cnt2_enabled;
 } reg;
 
 DEFINE_SPINLOCK(sample_lock);
@@ -81,8 +81,8 @@ static void loongson2_reg_setup(struct op_counter_config *cfg)
 
 	reg.ctrl = ctrl;
 
-	reg.cnt1_enalbed = cfg[0].enabled;
-	reg.cnt2_enalbed = cfg[1].enabled;
+	reg.cnt1_enabled = cfg[0].enabled;
+	reg.cnt2_enabled = cfg[1].enabled;
 
 }
 
@@ -99,7 +99,7 @@ static void loongson2_cpu_setup(void *args)
 static void loongson2_cpu_start(void *args)
 {
 	/* Start all counters on current CPU */
-	if (reg.cnt1_enalbed || reg.cnt2_enalbed)
+	if (reg.cnt1_enabled || reg.cnt2_enabled)
 		write_c0_perfctrl(reg.ctrl);
 }
 
@@ -125,7 +125,7 @@ static irqreturn_t loongson2_perfcount_handler(int irq, void *dev_id)
 	 */
 
 	/* Check whether the irq belongs to me */
-	enabled = reg.cnt1_enalbed | reg.cnt2_enalbed;
+	enabled = reg.cnt1_enabled | reg.cnt2_enabled;
 	if (!enabled)
 		return IRQ_NONE;
 
@@ -136,12 +136,12 @@ static irqreturn_t loongson2_perfcount_handler(int irq, void *dev_id)
 	spin_lock_irqsave(&sample_lock, flags);
 
 	if (counter1 & LOONGSON2_PERFCNT_OVERFLOW) {
-		if (reg.cnt1_enalbed)
+		if (reg.cnt1_enabled)
 			oprofile_add_sample(regs, 0);
 		counter1 = reg.reset_counter1;
 	}
 	if (counter2 & LOONGSON2_PERFCNT_OVERFLOW) {
-		if (reg.cnt2_enalbed)
+		if (reg.cnt2_enabled)
 			oprofile_add_sample(regs, 1);
 		counter2 = reg.reset_counter2;
 	}
-- 
1.6.4.3


From julia@diku.dk Mon Sep 21 17:09:03 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 21 Sep 2009 17:09:10 +0200 (CEST)
Received: from mgw1.diku.dk ([130.225.96.91]:41751 "EHLO mgw1.diku.dk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492960AbZIUPJC (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 21 Sep 2009 17:09:02 +0200
Received: from localhost (localhost [127.0.0.1])
	by mgw1.diku.dk (Postfix) with ESMTP id 24AD052C387;
	Mon, 21 Sep 2009 17:08:57 +0200 (CEST)
X-Virus-Scanned: amavisd-new at diku.dk
Received: from mgw1.diku.dk ([127.0.0.1])
	by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id PHWAUhsW9HQg; Mon, 21 Sep 2009 17:08:55 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw1.diku.dk (Postfix) with ESMTP id CF7A652C3D6;
	Mon, 21 Sep 2009 17:08:55 +0200 (CEST)
Received: from pc-004.diku.dk (pc-004.diku.dk [130.225.97.4])
	by nhugin.diku.dk (Postfix) with ESMTP
	id 89D1B6DF893; Mon, 21 Sep 2009 17:06:55 +0200 (CEST)
Received: by pc-004.diku.dk (Postfix, from userid 3767)
	id B1FE83841D; Mon, 21 Sep 2009 17:08:55 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1])
	by pc-004.diku.dk (Postfix) with ESMTP id AC6A93830C;
	Mon, 21 Sep 2009 17:08:55 +0200 (CEST)
Date:	Mon, 21 Sep 2009 17:08:55 +0200 (CEST)
From:	Julia Lawall <julia@diku.dk>
To:	dmitri.vorobiev@gmail.com, ralf@linux-mips.org,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] arch/mips: remove duplicate structure field initialization
Message-ID: <Pine.LNX.4.64.0909211708200.8549@pc-004.diku.dk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Return-Path: <julia@diku.dk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24060
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: julia@diku.dk
Precedence: bulk
X-list: linux-mips

From: Julia Lawall <julia@diku.dk>

The definition of the irq_ipi structure has two initializations of the
flags field.  This combines them.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
identifier I, s, fld;
position p0,p;
expression E;
@@

struct I s =@p0 { ... .fld@p = E, ...};

@s@
identifier I, s, r.fld;
position r.p0,p;
expression E;
@@

struct I s =@p0 { ... .fld@p = E, ...};

@script:python@
p0 << r.p0;
fld << r.fld;
ps << s.p;
pr << r.p;
@@

if int(ps[0].line)!=int(pr[0].line) or int(ps[0].column)!=int(pr[0].column):
  cocci.print_main(fld,p0)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/mips/kernel/smtc.c             |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 67153a0..4d181df 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -1098,9 +1098,8 @@ static void ipi_irq_dispatch(void)
 
 static struct irqaction irq_ipi = {
 	.handler	= ipi_interrupt,
-	.flags		= IRQF_DISABLED,
-	.name		= "SMTC_IPI",
-	.flags		= IRQF_PERCPU
+	.flags		= IRQF_DISABLED | IRQF_PERCPU,
+	.name		= "SMTC_IPI"
 };
 
 static void setup_cross_vpe_interrupts(unsigned int nvpe)

From ralf@linux-mips.org Mon Sep 21 21:24:15 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 21 Sep 2009 21:24:22 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:58674 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493221AbZIUTYP (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 21 Sep 2009 21:24:15 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8LJPNxh020603;
	Mon, 21 Sep 2009 20:25:23 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8LJPL18020601;
	Mon, 21 Sep 2009 20:25:21 +0100
Date:	Mon, 21 Sep 2009 20:25:20 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Julia Lawall <julia@diku.dk>,
	"Kevin D. Kissell" <kevink@paralogos.com>
Cc:	dmitri.vorobiev@gmail.com, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] arch/mips: remove duplicate structure field
	initialization
Message-ID: <20090921192520.GB17310@linux-mips.org>
References: <Pine.LNX.4.64.0909211708200.8549@pc-004.diku.dk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <Pine.LNX.4.64.0909211708200.8549@pc-004.diku.dk>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24061
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Mon, Sep 21, 2009 at 05:08:55PM +0200, Julia Lawall wrote:

Adding Kevin "SMTC Kissel to cc.

> From: Julia Lawall <julia@diku.dk>
> 
> The definition of the irq_ipi structure has two initializations of the
> flags field.  This combines them.
> 
> The semantic match that finds this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @r@
> identifier I, s, fld;
> position p0,p;
> expression E;
> @@
> 
> struct I s =@p0 { ... .fld@p = E, ...};
> 
> @s@
> identifier I, s, r.fld;
> position r.p0,p;
> expression E;
> @@
> 
> struct I s =@p0 { ... .fld@p = E, ...};
> 
> @script:python@
> p0 << r.p0;
> fld << r.fld;
> ps << s.p;
> pr << r.p;
> @@
> 
> if int(ps[0].line)!=int(pr[0].line) or int(ps[0].column)!=int(pr[0].column):
>   cocci.print_main(fld,p0)
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
>  arch/mips/kernel/smtc.c             |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
> index 67153a0..4d181df 100644
> --- a/arch/mips/kernel/smtc.c
> +++ b/arch/mips/kernel/smtc.c
> @@ -1098,9 +1098,8 @@ static void ipi_irq_dispatch(void)
>  
>  static struct irqaction irq_ipi = {
>  	.handler	= ipi_interrupt,
> -	.flags		= IRQF_DISABLED,
> -	.name		= "SMTC_IPI",
> -	.flags		= IRQF_PERCPU
> +	.flags		= IRQF_DISABLED | IRQF_PERCPU,
> +	.name		= "SMTC_IPI"
>  };
>  
>  static void setup_cross_vpe_interrupts(unsigned int nvpe)

The actual semantic of this code as implemented by gcc is that all but the
last initializer are ignored so until somebody actually tests your code
I'll just remove the first of the two initializers and put a comment there.

  Ralf

From kevink@paralogos.com Mon Sep 21 22:23:52 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 21 Sep 2009 22:23:58 +0200 (CEST)
Received: from gateway11.websitewelcome.com ([67.18.72.139]:33935 "HELO
	gateway11.websitewelcome.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with SMTP id S1493241AbZIUUXv (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 21 Sep 2009 22:23:51 +0200
Received: (qmail 14101 invoked from network); 21 Sep 2009 20:36:29 -0000
Received: from gator750.hostgator.com (174.132.194.2)
  by gateway11.websitewelcome.com with SMTP; 21 Sep 2009 20:36:29 -0000
Received: from 216-239-45-4.google.com ([216.239.45.4]:51199 helo=epiktistes.mtv.corp.google.com)
	by gator750.hostgator.com with esmtpa (Exim 4.69)
	(envelope-from <kevink@paralogos.com>)
	id 1MppQI-0003ik-Dp; Mon, 21 Sep 2009 15:23:46 -0500
Message-ID: <4AB7E0D1.10506@paralogos.com>
Date:	Mon, 21 Sep 2009 13:23:45 -0700
From:	"Kevin D. Kissell" <kevink@paralogos.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
CC:	Julia Lawall <julia@diku.dk>, dmitri.vorobiev@gmail.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] arch/mips: remove duplicate structure field	initialization
References: <Pine.LNX.4.64.0909211708200.8549@pc-004.diku.dk> <20090921192520.GB17310@linux-mips.org>
In-Reply-To: <20090921192520.GB17310@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator750.hostgator.com
X-AntiAbuse: Original Domain - linux-mips.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - paralogos.com
Return-Path: <kevink@paralogos.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24062
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: kevink@paralogos.com
Precedence: bulk
X-list: linux-mips

I'm still on the mailing list, and had seen this going by.  I'm not sure 
where that second .flags declaration got added.  Way, way back when I 
was pretty much the only maintainer of the file, irq_ipi.flags was 
explicitly  initialized to IRQF_DISABLED by an actual assignment 
statement in setp_cross_vpe_interrupts(), and the per-CPUness was 
handled by an "irq_desc[cpu_ipi_irq].status |= IRQ_PER_CPU".  My guess 
is that first someone (maybe me) migrated the IRQF_DISABLED assignment 
into the declaration of the struct, and that later someone found the 
IRQ_PER_CPU thing bogus or deprecated and converted it into a second 
.flags line in the struct declaration, missing the fact that there was 
already one there.

In any case, I'm willing to sign off on Julia's patch.  It's certainly 
more important that the IRQ be PER_CPU than initially DISABLED, but 
during the time when SMTC was seeing its heaviest testing at MIPS, both 
attributes were true.

          Regards,

          Kevin K.

Ralf Baechle wrote:
> On Mon, Sep 21, 2009 at 05:08:55PM +0200, Julia Lawall wrote:
>
> Adding Kevin "SMTC Kissel to cc.
>
>   
>> From: Julia Lawall <julia@diku.dk>
>>
>> The definition of the irq_ipi structure has two initializations of the
>> flags field.  This combines them.
>>
>> The semantic match that finds this problem is as follows:
>> (http://coccinelle.lip6.fr/)
>>
>> // <smpl>
>> @r@
>> identifier I, s, fld;
>> position p0,p;
>> expression E;
>> @@
>>
>> struct I s =@p0 { ... .fld@p = E, ...};
>>
>> @s@
>> identifier I, s, r.fld;
>> position r.p0,p;
>> expression E;
>> @@
>>
>> struct I s =@p0 { ... .fld@p = E, ...};
>>
>> @script:python@
>> p0 << r.p0;
>> fld << r.fld;
>> ps << s.p;
>> pr << r.p;
>> @@
>>
>> if int(ps[0].line)!=int(pr[0].line) or int(ps[0].column)!=int(pr[0].column):
>>   cocci.print_main(fld,p0)
>> // </smpl>
>>
>> Signed-off-by: Julia Lawall <julia@diku.dk>
>>
>> ---
>>  arch/mips/kernel/smtc.c             |    5 ++---
>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
>> index 67153a0..4d181df 100644
>> --- a/arch/mips/kernel/smtc.c
>> +++ b/arch/mips/kernel/smtc.c
>> @@ -1098,9 +1098,8 @@ static void ipi_irq_dispatch(void)
>>  
>>  static struct irqaction irq_ipi = {
>>  	.handler	= ipi_interrupt,
>> -	.flags		= IRQF_DISABLED,
>> -	.name		= "SMTC_IPI",
>> -	.flags		= IRQF_PERCPU
>> +	.flags		= IRQF_DISABLED | IRQF_PERCPU,
>> +	.name		= "SMTC_IPI"
>>  };
>>  
>>  static void setup_cross_vpe_interrupts(unsigned int nvpe)
>>     
>
> The actual semantic of this code as implemented by gcc is that all but the
> last initializer are ignored so until somebody actually tests your code
> I'll just remove the first of the two initializers and put a comment there.
>
>   Ralf
>   


From kevink@paralogos.com Mon Sep 21 22:41:54 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 21 Sep 2009 22:42:00 +0200 (CEST)
Received: from gateway03.websitewelcome.com ([69.93.38.21]:36856 "HELO
	gateway03.websitewelcome.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with SMTP id S1493245AbZIUUlx (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 21 Sep 2009 22:41:53 +0200
Received: (qmail 13219 invoked from network); 21 Sep 2009 20:51:25 -0000
Received: from gator750.hostgator.com (174.132.194.2)
  by gateway03.websitewelcome.com with SMTP; 21 Sep 2009 20:51:25 -0000
Received: from 216-239-45-4.google.com ([216.239.45.4]:34526 helo=epiktistes.mtv.corp.google.com)
	by gator750.hostgator.com with esmtpa (Exim 4.69)
	(envelope-from <kevink@paralogos.com>)
	id 1Mpphm-0001Av-TW; Mon, 21 Sep 2009 15:41:51 -0500
Message-ID: <4AB7E50D.4090509@paralogos.com>
Date:	Mon, 21 Sep 2009 13:41:49 -0700
From:	"Kevin D. Kissell" <kevink@paralogos.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
CC:	Julia Lawall <julia@diku.dk>, dmitri.vorobiev@gmail.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] arch/mips: remove duplicate structure field	initialization
References: <Pine.LNX.4.64.0909211708200.8549@pc-004.diku.dk> <20090921192520.GB17310@linux-mips.org> <4AB7E0D1.10506@paralogos.com>
In-Reply-To: <4AB7E0D1.10506@paralogos.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator750.hostgator.com
X-AntiAbuse: Original Domain - linux-mips.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - paralogos.com
Return-Path: <kevink@paralogos.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24063
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: kevink@paralogos.com
Precedence: bulk
X-list: linux-mips

Ha!  Found the breakage.  It wasn't a two-phase commit.  It was just an 
overworked mantainer in a hurry, in July 2007.  See commit 
033890b084adfa367c544864451d7730552ce8bf

Regards,

Kevin K.

Kevin D. Kissell wrote:
> I'm still on the mailing list, and had seen this going by.  I'm not 
> sure where that second .flags declaration got added.  Way, way back 
> when I was pretty much the only maintainer of the file, irq_ipi.flags 
> was explicitly  initialized to IRQF_DISABLED by an actual assignment 
> statement in setp_cross_vpe_interrupts(), and the per-CPUness was 
> handled by an "irq_desc[cpu_ipi_irq].status |= IRQ_PER_CPU".  My guess 
> is that first someone (maybe me) migrated the IRQF_DISABLED assignment 
> into the declaration of the struct, and that later someone found the 
> IRQ_PER_CPU thing bogus or deprecated and converted it into a second 
> .flags line in the struct declaration, missing the fact that there was 
> already one there.
>
> In any case, I'm willing to sign off on Julia's patch.  It's certainly 
> more important that the IRQ be PER_CPU than initially DISABLED, but 
> during the time when SMTC was seeing its heaviest testing at MIPS, 
> both attributes were true.
>
>          Regards,
>
>          Kevin K.
>
> Ralf Baechle wrote:
>> On Mon, Sep 21, 2009 at 05:08:55PM +0200, Julia Lawall wrote:
>>
>> Adding Kevin "SMTC Kissel to cc.
>>
>>  
>>> From: Julia Lawall <julia@diku.dk>
>>>
>>> The definition of the irq_ipi structure has two initializations of the
>>> flags field.  This combines them.
>>>
>>> The semantic match that finds this problem is as follows:
>>> (http://coccinelle.lip6.fr/)
>>>
>>> // <smpl>
>>> @r@
>>> identifier I, s, fld;
>>> position p0,p;
>>> expression E;
>>> @@
>>>
>>> struct I s =@p0 { ... .fld@p = E, ...};
>>>
>>> @s@
>>> identifier I, s, r.fld;
>>> position r.p0,p;
>>> expression E;
>>> @@
>>>
>>> struct I s =@p0 { ... .fld@p = E, ...};
>>>
>>> @script:python@
>>> p0 << r.p0;
>>> fld << r.fld;
>>> ps << s.p;
>>> pr << r.p;
>>> @@
>>>
>>> if int(ps[0].line)!=int(pr[0].line) or 
>>> int(ps[0].column)!=int(pr[0].column):
>>>   cocci.print_main(fld,p0)
>>> // </smpl>
>>>
>>> Signed-off-by: Julia Lawall <julia@diku.dk>
>>>
>>> ---
>>>  arch/mips/kernel/smtc.c             |    5 ++---
>>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
>>> index 67153a0..4d181df 100644
>>> --- a/arch/mips/kernel/smtc.c
>>> +++ b/arch/mips/kernel/smtc.c
>>> @@ -1098,9 +1098,8 @@ static void ipi_irq_dispatch(void)
>>>  
>>>  static struct irqaction irq_ipi = {
>>>      .handler    = ipi_interrupt,
>>> -    .flags        = IRQF_DISABLED,
>>> -    .name        = "SMTC_IPI",
>>> -    .flags        = IRQF_PERCPU
>>> +    .flags        = IRQF_DISABLED | IRQF_PERCPU,
>>> +    .name        = "SMTC_IPI"
>>>  };
>>>  
>>>  static void setup_cross_vpe_interrupts(unsigned int nvpe)
>>>     
>>
>> The actual semantic of this code as implemented by gcc is that all 
>> but the
>> last initializer are ignored so until somebody actually tests your code
>> I'll just remove the first of the two initializers and put a comment 
>> there.
>>
>>   Ralf
>>   
>
>


From ralf@linux-mips.org Mon Sep 21 22:54:43 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 21 Sep 2009 22:54:51 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:33940 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493264AbZIUUyn (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 21 Sep 2009 22:54:43 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8LKtrgg024545;
	Mon, 21 Sep 2009 21:55:53 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8LKtqCw024543;
	Mon, 21 Sep 2009 21:55:52 +0100
Date:	Mon, 21 Sep 2009 21:55:52 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	"Kevin D. Kissell" <kevink@paralogos.com>
Cc:	Julia Lawall <julia@diku.dk>, dmitri.vorobiev@gmail.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] arch/mips: remove duplicate structure field
	initialization
Message-ID: <20090921205551.GA20341@linux-mips.org>
References: <Pine.LNX.4.64.0909211708200.8549@pc-004.diku.dk> <20090921192520.GB17310@linux-mips.org> <4AB7E0D1.10506@paralogos.com> <4AB7E50D.4090509@paralogos.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4AB7E50D.4090509@paralogos.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24064
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Mon, Sep 21, 2009 at 01:41:49PM -0700, Kevin D. Kissell wrote:

> Ha!  Found the breakage.  It wasn't a two-phase commit.  It was just an  
> overworked mantainer in a hurry, in July 2007.  See commit  
> 033890b084adfa367c544864451d7730552ce8bf

An overworked maintainer in cooperation with a broken compiler.  Worse -
it's not the first time this type of bug strikes but probably this was
never brought to the gcc maintainers' attention.

  Ralf

From mason@upwardaccess.com Mon Sep 21 23:13:34 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 21 Sep 2009 23:13:42 +0200 (CEST)
Received: from mail.upwardaccess.com ([70.89.180.121]:1807 "EHLO
	upwardaccess.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1493265AbZIUVNe (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 21 Sep 2009 23:13:34 +0200
Received: from hawaii.upwardaccess.com (unverified [10.61.7.126]) 
	by upwardaccess.com (SurgeMail 3.9e) with ESMTP id 895964-1847469 
	for <linux-mips@linux-mips.org>; Mon, 21 Sep 2009 14:12:58 -0700
Received: by hawaii.upwardaccess.com (Postfix, from userid 500)
	id 047F335425B; Mon, 21 Sep 2009 14:13:24 -0700 (PDT)
From:	Mark Mason <mmason@upwardaccess.com>
To:	linux-mips@linux-mips.org
Cc:	Mark Mason <mmason@upwardaccess.com>
Subject: [PATCH] When complaining about attempting to set the irq affinity to multiple cpus,
Date:	Mon, 21 Sep 2009 14:13:24 -0700
Message-Id: <1253567604-6734-1-git-send-email-mmason@upwardaccess.com>
X-Mailer: git-send-email 1.6.0.2
X-Originating-IP: 10.61.7.126
X-Authenticated-User: mmason@upwardaccess.com 
Return-Path: <mason@upwardaccess.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24065
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mmason@upwardaccess.com
Precedence: bulk
X-list: linux-mips

---
 arch/mips/sibyte/bcm1480/irq.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c
index ba59839..fc87ea4 100644
--- a/arch/mips/sibyte/bcm1480/irq.c
+++ b/arch/mips/sibyte/bcm1480/irq.c
@@ -118,7 +118,11 @@ static int bcm1480_set_affinity(unsigned int irq, const struct cpumask *mask)
 	unsigned int irq_dirty;
 
 	if (cpumask_weight(mask) != 1) {
-		printk("attempted to set irq affinity for irq %d to multiple CPUs\n", irq);
+		printk("attempted to set irq affinity for irq %d to multiple CPUs:", irq);
+		/* Print the mask */
+		for_each_cpu(i, mask)
+			printk(" %d", i);
+		printk("\n");
 		return -1;
 	}
 	i = cpumask_first(mask);
-- 
1.6.0.2


From davem@davemloft.net Tue Sep 22 07:38:22 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 22 Sep 2009 07:38:30 +0200 (CEST)
Received: from 74-93-104-97-Washington.hfc.comcastbusiness.net ([74.93.104.97]:36409
	"EHLO sunset.davemloft.net" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492209AbZIVFiW (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 22 Sep 2009 07:38:22 +0200
Received: from localhost (localhost [127.0.0.1])
	by sunset.davemloft.net (Postfix) with ESMTP id AFAB3C8C1EF;
	Mon, 21 Sep 2009 22:38:30 -0700 (PDT)
Date:	Mon, 21 Sep 2009 22:38:30 -0700 (PDT)
Message-Id: <20090921.223830.164776940.davem@davemloft.net>
To:	florian@openwrt.org
Cc:	netdev@vger.kernel.org, ralf@linux-mips.org,
	linux-mips@linux-mips.org
Subject: Re: [PATCH] cpmac: fix compilation errors against undeclared
 BUS_ID_SIZE
From:	David Miller <davem@davemloft.net>
In-Reply-To: <200909191243.09166.florian@openwrt.org>
References: <200909160944.24265.florian@openwrt.org>
	<200909191243.09166.florian@openwrt.org>
X-Mailer: Mew version 6.2.51 on Emacs 22.1 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Return-Path: <davem@davemloft.net>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24066
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: davem@davemloft.net
Precedence: bulk
X-list: linux-mips

From: Florian Fainelli <florian@openwrt.org>
Date: Sat, 19 Sep 2009 12:43:08 +0200

> David,
> 
> Ping ? This fixes a build failure. Thank you very much !

Applied, thanks.

From jaswinder@kernel.org Tue Sep 22 15:27:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 22 Sep 2009 15:27:37 +0200 (CEST)
Received: from hera.kernel.org ([140.211.167.34]:51922 "EHLO hera.kernel.org"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492616AbZIVN1a (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 22 Sep 2009 15:27:30 +0200
Received: from [192.168.1.220] (triband-del-59.180.23.123.bol.net.in [59.180.23.123] (may be forged))
	(authenticated bits=0)
	by hera.kernel.org (8.14.2/8.13.8) with ESMTP id n8MDRCIs016616
	(version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
	Tue, 22 Sep 2009 13:27:15 GMT
Subject: [PATCH] MIPS: includecheck fix: bcm63xx, board_bcm963xx.c
From:	Jaswinder Singh Rajput <jaswinder@kernel.org>
To:	Ralf Baechle <ralf@linux-mips.org>,
	Florian Fainelli <florian@openwrt.org>,
	Maxime Bizon <mbizon@freebox.fr>,
	linux-mips <linux-mips@linux-mips.org>,
	LKML <linux-kernel@vger.kernel.org>
Content-Type: text/plain
Date:	Tue, 22 Sep 2009 18:57:17 +0530
Message-Id: <1253626037.3784.13.camel@ht.satnam>
Mime-Version: 1.0
X-Mailer: Evolution 2.24.5 (2.24.5-2.fc10) 
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: ClamAV 0.93.3/9821/Mon Sep 21 23:48:15 2009 on hera.kernel.org
X-Virus-Status:	Clean
Return-Path: <jaswinder@kernel.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24067
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: jaswinder@kernel.org
Precedence: bulk
X-list: linux-mips


fix the following 'make includecheck' warning:

  arch/mips/bcm63xx/boards/board_bcm963xx.c: bcm63xx_board.h is included more than once.

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 arch/mips/bcm63xx/boards/board_bcm963xx.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index fd77f54..12add0c 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -20,7 +20,6 @@
 #include <bcm63xx_cpu.h>
 #include <bcm63xx_regs.h>
 #include <bcm63xx_io.h>
-#include <bcm63xx_board.h>
 #include <bcm63xx_dev_pci.h>
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_dsp.h>
-- 
1.6.0.6



From jaswinder@kernel.org Tue Sep 22 15:29:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 22 Sep 2009 15:29:36 +0200 (CEST)
Received: from hera.kernel.org ([140.211.167.34]:51977 "EHLO hera.kernel.org"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492719AbZIVN3a (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 22 Sep 2009 15:29:30 +0200
Received: from [192.168.1.220] (triband-del-59.180.23.123.bol.net.in [59.180.23.123] (may be forged))
	(authenticated bits=0)
	by hera.kernel.org (8.14.2/8.13.8) with ESMTP id n8MDTLQU017190
	(version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO);
	Tue, 22 Sep 2009 13:29:26 GMT
Subject: [PATCH] MIPS: includecheck fix: smp.c
From:	Jaswinder Singh Rajput <jaswinder@kernel.org>
To:	Ralf Baechle <ralf@linux-mips.org>,
	linux-mips <linux-mips@linux-mips.org>,
	LKML <linux-kernel@vger.kernel.org>
Content-Type: text/plain
Date:	Tue, 22 Sep 2009 18:59:27 +0530
Message-Id: <1253626167.3784.15.camel@ht.satnam>
Mime-Version: 1.0
X-Mailer: Evolution 2.24.5 (2.24.5-2.fc10) 
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: ClamAV 0.93.3/9821/Mon Sep 21 23:48:15 2009 on hera.kernel.org
X-Virus-Status:	Clean
Return-Path: <jaswinder@kernel.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24068
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: jaswinder@kernel.org
Precedence: bulk
X-list: linux-mips


fix the following 'make includecheck' warning:

  arch/mips/kernel/smp.c: linux/smp.h is included more than once.

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
 arch/mips/kernel/smp.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 64668a9..119a95e 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -32,7 +32,6 @@
 #include <linux/cpumask.h>
 #include <linux/cpu.h>
 #include <linux/err.h>
-#include <linux/smp.h>
 
 #include <asm/atomic.h>
 #include <asm/cpu.h>
-- 
1.6.0.6



From wuzj@lemote.com Wed Sep 23 09:39:05 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 09:39:12 +0200 (CEST)
Received: from [222.92.8.141] ([222.92.8.141]:41794 "EHLO lemote.com"
	rhost-flags-FAIL-FAIL-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492097AbZIWHjF (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 09:39:05 +0200
Received: from localhost (localhost [127.0.0.1])
	by lemote.com (Postfix) with ESMTP id 319FC31CC9A;
	Wed, 23 Sep 2009 15:28:27 +0800 (CST)
X-Virus-Scanned: Debian amavisd-new at lemote.com
Received: from lemote.com ([127.0.0.1])
	by localhost (www.lemote.com [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id qZdurydITM+4; Wed, 23 Sep 2009 15:28:11 +0800 (CST)
Received: from [172.16.2.101] (unknown [222.92.8.142])
	by lemote.com (Postfix) with ESMTP id D7ADC31CC89;
	Wed, 23 Sep 2009 15:28:11 +0800 (CST)
Subject: Re: [PATCH 3/3] Fix typo "enalbe" -> "enable"
From:	Wu Zhangjin <wuzj@lemote.com>
Reply-To: wuzj@lemote.com
To:	Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= 
	<u.kleine-koenig@pengutronix.de>
Cc:	linux-mips@linux-mips.org, oprofile-list@lists.sf.net,
	Yanhua <yanh@lemote.com>, Ralf Baechle <ralf@linux-mips.org>,
	Robert Richter <robert.richter@amd.com>
In-Reply-To: <1253522437-22919-1-git-send-email-u.kleine-koenig@pengutronix.de>
References: <1253522437-22919-1-git-send-email-u.kleine-koenig@pengutronix.de>
Content-Type: text/plain; charset="UTF-8"
Organization: www.lemote.com, Changshu City, JiangSu Province, China
Date:	Wed, 23 Sep 2009 15:38:33 +0800
Message-Id: <1253691513.17306.5.camel@falcon>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 8bit
Return-Path: <wuzj@lemote.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24069
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: wuzj@lemote.com
Precedence: bulk
X-list: linux-mips

On Mon, 2009-09-21 at 10:40 +0200, Uwe Kleine-KÃ¶nig wrote:
> Signed-off-by: Uwe Kleine-KÃ¶nig <u.kleine-koenig@pengutronix.de>
> Cc: Wu Zhangjin <wuzj@lemote.com>
> Cc: Yanhua <yanh@lemote.com>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Robert Richter <robert.richter@amd.com>
> ---
>  arch/mips/oprofile/op_model_loongson2.c |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/mips/oprofile/op_model_loongson2.c b/arch/mips/oprofile/op_model_loongson2.c
> index 655cb8d..deed1d5 100644
> --- a/arch/mips/oprofile/op_model_loongson2.c
> +++ b/arch/mips/oprofile/op_model_loongson2.c
> @@ -44,7 +44,7 @@ static struct loongson2_register_config {
>  	unsigned int ctrl;
>  	unsigned long long reset_counter1;
>  	unsigned long long reset_counter2;
> -	int cnt1_enalbed, cnt2_enalbed;
> +	int cnt1_enabled, cnt2_enabled;
>  } reg;
>  
>  DEFINE_SPINLOCK(sample_lock);
> @@ -81,8 +81,8 @@ static void loongson2_reg_setup(struct op_counter_config *cfg)
>  
>  	reg.ctrl = ctrl;
>  
> -	reg.cnt1_enalbed = cfg[0].enabled;
> -	reg.cnt2_enalbed = cfg[1].enabled;
> +	reg.cnt1_enabled = cfg[0].enabled;
> +	reg.cnt2_enabled = cfg[1].enabled;
>  
>  }
>  
> @@ -99,7 +99,7 @@ static void loongson2_cpu_setup(void *args)
>  static void loongson2_cpu_start(void *args)
>  {
>  	/* Start all counters on current CPU */
> -	if (reg.cnt1_enalbed || reg.cnt2_enalbed)
> +	if (reg.cnt1_enabled || reg.cnt2_enabled)
>  		write_c0_perfctrl(reg.ctrl);
>  }
>  
> @@ -125,7 +125,7 @@ static irqreturn_t loongson2_perfcount_handler(int irq, void *dev_id)
>  	 */
>  
>  	/* Check whether the irq belongs to me */
> -	enabled = reg.cnt1_enalbed | reg.cnt2_enalbed;
> +	enabled = reg.cnt1_enabled | reg.cnt2_enabled;
>  	if (!enabled)
>  		return IRQ_NONE;
>  
> @@ -136,12 +136,12 @@ static irqreturn_t loongson2_perfcount_handler(int irq, void *dev_id)
>  	spin_lock_irqsave(&sample_lock, flags);
>  
>  	if (counter1 & LOONGSON2_PERFCNT_OVERFLOW) {
> -		if (reg.cnt1_enalbed)
> +		if (reg.cnt1_enabled)
>  			oprofile_add_sample(regs, 0);
>  		counter1 = reg.reset_counter1;
>  	}
>  	if (counter2 & LOONGSON2_PERFCNT_OVERFLOW) {
> -		if (reg.cnt2_enalbed)
> +		if (reg.cnt2_enabled)
>  			oprofile_add_sample(regs, 1);
>  		counter2 = reg.reset_counter2;
>  	}

Acked, thanks!

Regards,
	Wu Zhangjin


From ralf@linux-mips.org Wed Sep 23 11:12:13 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 11:12:20 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:53195 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492205AbZIWJMN (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 11:12:13 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8N9DO1b005924;
	Wed, 23 Sep 2009 10:13:24 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8N9DO99005923;
	Wed, 23 Sep 2009 10:13:24 +0100
Date:	Wed, 23 Sep 2009 10:13:23 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	"Kevin D. Kissell" <kevink@paralogos.com>
Cc:	Julia Lawall <julia@diku.dk>, dmitri.vorobiev@gmail.com,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] arch/mips: remove duplicate structure field
	initialization
Message-ID: <20090923091323.GC5457@linux-mips.org>
References: <Pine.LNX.4.64.0909211708200.8549@pc-004.diku.dk> <20090921192520.GB17310@linux-mips.org> <4AB7E0D1.10506@paralogos.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4AB7E0D1.10506@paralogos.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24070
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Mon, Sep 21, 2009 at 01:23:45PM -0700, Kevin D. Kissell wrote:

> I'm still on the mailing list, and had seen this going by.  I'm not sure  
> where that second .flags declaration got added.  Way, way back when I  
> was pretty much the only maintainer of the file, irq_ipi.flags was  
> explicitly  initialized to IRQF_DISABLED by an actual assignment  
> statement in setp_cross_vpe_interrupts(), and the per-CPUness was  
> handled by an "irq_desc[cpu_ipi_irq].status |= IRQ_PER_CPU".  My guess  
> is that first someone (maybe me) migrated the IRQF_DISABLED assignment  
> into the declaration of the struct, and that later someone found the  
> IRQ_PER_CPU thing bogus or deprecated and converted it into a second  
> .flags line in the struct declaration, missing the fact that there was  
> already one there.
>
> In any case, I'm willing to sign off on Julia's patch.  It's certainly  
> more important that the IRQ be PER_CPU than initially DISABLED, but  
> during the time when SMTC was seeing its heaviest testing at MIPS, both  
> attributes were true.

I've reverted my patch and merged Julia's original patch with an extra
comment added.

Thanks Julia,

   Ralf

From ralf@linux-mips.org Wed Sep 23 11:15:12 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 11:15:19 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:48384 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492205AbZIWJPM (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 11:15:12 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8N9BNiH005876;
	Wed, 23 Sep 2009 10:11:24 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8N9BMKm005873;
	Wed, 23 Sep 2009 10:11:22 +0100
Date:	Wed, 23 Sep 2009 10:11:21 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc:	Florian Fainelli <florian@openwrt.org>,
	Maxime Bizon <mbizon@freebox.fr>,
	linux-mips <linux-mips@linux-mips.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MIPS: includecheck fix: bcm63xx, board_bcm963xx.c
Message-ID: <20090923091121.GA5457@linux-mips.org>
References: <1253626037.3784.13.camel@ht.satnam>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253626037.3784.13.camel@ht.satnam>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24071
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Tue, Sep 22, 2009 at 06:57:17PM +0530, Jaswinder Singh Rajput wrote:

> fix the following 'make includecheck' warning:
> 
>   arch/mips/bcm63xx/boards/board_bcm963xx.c: bcm63xx_board.h is included more than once.
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>

I've already merged a patch which didn't yet make it to kernel.org for this
issue a few days ago.

Thanks anyway!

  Ralf

From ralf@linux-mips.org Wed Sep 23 11:15:49 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 11:15:56 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:48438 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492205AbZIWJPs (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 11:15:48 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8N9Ba1o005883;
	Wed, 23 Sep 2009 10:11:36 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8N9Bahj005882;
	Wed, 23 Sep 2009 10:11:36 +0100
Date:	Wed, 23 Sep 2009 10:11:35 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc:	linux-mips <linux-mips@linux-mips.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MIPS: includecheck fix: smp.c
Message-ID: <20090923091135.GB5457@linux-mips.org>
References: <1253626167.3784.15.camel@ht.satnam>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253626167.3784.15.camel@ht.satnam>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24072
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Tue, Sep 22, 2009 at 06:59:27PM +0530, Jaswinder Singh Rajput wrote:

> fix the following 'make includecheck' warning:
> 
>   arch/mips/kernel/smp.c: linux/smp.h is included more than once.
> 
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>

I've already merged a patch which didn't yet make it to kernel.org for this 
issue a few days ago.

Thanks anyway!

  Ralf

From ralf@linux-mips.org Wed Sep 23 11:18:30 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 11:18:38 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:48474 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492205AbZIWJSa (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 11:18:30 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8N9Jbqf006203;
	Wed, 23 Sep 2009 10:19:37 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8N9JYRG006200;
	Wed, 23 Sep 2009 10:19:34 +0100
Date:	Wed, 23 Sep 2009 10:19:34 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= 
	<u.kleine-koenig@pengutronix.de>
Cc:	linux-mips@linux-mips.org, oprofile-list@lists.sf.net,
	Wu Zhangjin <wuzj@lemote.com>, Yanhua <yanh@lemote.com>,
	Robert Richter <robert.richter@amd.com>
Subject: Re: [PATCH 3/3] Fix typo "enalbe" -> "enable"
Message-ID: <20090923091934.GD5457@linux-mips.org>
References: <1253522437-22919-1-git-send-email-u.kleine-koenig@pengutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <1253522437-22919-1-git-send-email-u.kleine-koenig@pengutronix.de>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24073
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Mon, Sep 21, 2009 at 10:40:37AM +0200, Uwe Kleine-König wrote:

Thanks, applied!

  Ralf

From ralf@linux-mips.org Wed Sep 23 11:26:48 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 11:26:53 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:59812 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493000AbZIWJ0r (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 11:26:47 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8N9S2Px006518;
	Wed, 23 Sep 2009 10:28:02 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8N9S00X006517;
	Wed, 23 Sep 2009 10:28:00 +0100
Date:	Wed, 23 Sep 2009 10:28:00 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Greg KH <gregkh@suse.de>
Cc:	Maxime Bizon <mbizon@freebox.fr>, linux-serial@vger.kernel.org,
	linux-mips@linux-mips.org
Subject: Re: [PATCH] MIPS: BCM63xx: Add serial driver for bcm63xx
	integrated UART.
Message-ID: <20090923092800.GE5457@linux-mips.org>
References: <1253271898.1627.272.camel@sakura.staff.proxad.net> <20090918145715.GB8884@suse.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20090918145715.GB8884@suse.de>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24074
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Fri, Sep 18, 2009 at 07:57:15AM -0700, Greg KH wrote:

> > This is a serial driver for the bcm63xx mips SOCs, it was already posted
> > twice:
> > 
> > one year ago: http://marc.info/?l=linux-serial&m=122438266322439&w=2
> > three months ago: http://lkml.org/lkml/2009/7/1/370
> > 
> > but got no review or ack.
> > 
> > 
> > Linus merged the SOC support patch from Ralf tree yesterday, but without
> > serial support.
> > 
> > Could you please have a look at it ? Is it ok if it goes upstream
> > through Ralf tree ?
> 
> I have no objection for this to go through Ralf's tree.  Or if he needs
> it to go through mine, just let me know.
> 
> > Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
> > Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
> 
> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>

Thanks, merged.  Will go to Linus asap.

  Ralf

From mbizon@freebox.fr Wed Sep 23 11:31:10 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 11:31:17 +0200 (CEST)
Received: from smtp6-g21.free.fr ([212.27.42.6]:59196 "EHLO smtp6-g21.free.fr"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493041AbZIWJbJ (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 11:31:09 +0200
Received: from smtp6-g21.free.fr (localhost [127.0.0.1])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 23CD2E0804F;
	Wed, 23 Sep 2009 11:31:03 +0200 (CEST)
Received: from [213.228.1.107] (sakura.staff.proxad.net [213.228.1.107])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 3329DE08016;
	Wed, 23 Sep 2009 11:31:01 +0200 (CEST)
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
From:	Maxime Bizon <mbizon@freebox.fr>
Reply-To: mbizon@freebox.fr
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	Greg Kroah-Hartman <gregkh@suse.de>, linux-mips@linux-mips.org,
	linux-pcmcia@lists.infradead.org,
	Ralf Baechle <ralf@linux-mips.org>
In-Reply-To: <20090919154755.GA27704@pengutronix.de>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>
	 <20090919154755.GA27704@pengutronix.de>
Content-Type: text/plain
Organization: Freebox
Date:	Wed, 23 Sep 2009 11:31:00 +0200
Message-Id: <1253698260.1627.391.camel@sakura.staff.proxad.net>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 7bit
Return-Path: <mbizon@freebox.fr>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24075
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mbizon@freebox.fr
Precedence: bulk
X-list: linux-mips


On Sat, 2009-09-19 at 17:47 +0200, Wolfram Sang wrote:

> I can't make it for 2.6.32, but will try to get it queued for 2.6.33.
> What about the second FIXME in the driver BTW?

It should go away.

The timings are correct for slowest type of access (attribute memory if
I remember well).

At first I thought it would be possible to change the timings
dynamically to speedup other memory regions, but a driver may do
attribute memory access anytime without warning us, so we have to stick
with the slowest value.

I will resubmit the patch without the FIXME.

-- 
Maxime



From ralf@linux-mips.org Wed Sep 23 11:34:15 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 11:34:23 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:35025 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493031AbZIWJeP (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 11:34:15 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8N9ZT56006615;
	Wed, 23 Sep 2009 10:35:29 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8N9ZTnU006612;
	Wed, 23 Sep 2009 10:35:29 +0100
Date:	Wed, 23 Sep 2009 10:35:29 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	Maxime Bizon <mbizon@freebox.fr>,
	Greg Kroah-Hartman <gregkh@suse.de>, linux-mips@linux-mips.org,
	linux-pcmcia@lists.infradead.org
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
Message-ID: <20090923093529.GF5457@linux-mips.org>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net> <20090919154755.GA27704@pengutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20090919154755.GA27704@pengutronix.de>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24076
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Sat, Sep 19, 2009 at 05:47:55PM +0200, Wolfram Sang wrote:

> On Fri, Sep 18, 2009 at 01:21:31PM +0200, Maxime Bizon wrote:
> 
> > It seems Dominik is busy, and you're the one acking pcmcia patch at the
> > moment so I'm sending this to you.
> 
> I can't make it for 2.6.32, but will try to get it queued for 2.6.33. What
> about the second FIXME in the driver BTW?

If you're otherwise ok with the patch can handle feeding things upstream to
Linux.  Without PCMCIA / Cardbus support the value of the BCM63xx in
the upstream kernel is limited for another few months and there is no
point in being so cautious with this patch as it doesn't touch an other
files.

  Ralf

From w.sang@pengutronix.de Wed Sep 23 13:58:47 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 13:58:53 +0200 (CEST)
Received: from metis.ext.pengutronix.de ([92.198.50.35]:60335 "EHLO
	metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493012AbZIWL6r (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 23 Sep 2009 13:58:47 +0200
Received: from [2001:6f8:1178:2:221:70ff:fe71:1890] (helo=pengutronix.de)
	by metis.ext.pengutronix.de with esmtp (Exim 4.63)
	(envelope-from <w.sang@pengutronix.de>)
	id 1MqQUb-0002yX-4Q; Wed, 23 Sep 2009 13:58:41 +0200
Date:	Wed, 23 Sep 2009 13:58:40 +0200
From:	Wolfram Sang <w.sang@pengutronix.de>
To:	Maxime Bizon <mbizon@freebox.fr>
Cc:	Greg Kroah-Hartman <gregkh@suse.de>, linux-mips@linux-mips.org,
	linux-pcmcia@lists.infradead.org,
	Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
Message-ID: <20090923115840.GA3131@pengutronix.de>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net> <20090919154755.GA27704@pengutronix.de> <1253698260.1627.391.camel@sakura.staff.proxad.net>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="mP3DRpeJDSE+ciuQ"
Content-Disposition: inline
In-Reply-To: <1253698260.1627.391.camel@sakura.staff.proxad.net>
User-Agent: Mutt/1.5.18 (2008-05-17)
X-SA-Exim-Connect-IP: 2001:6f8:1178:2:221:70ff:fe71:1890
X-SA-Exim-Mail-From: w.sang@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-mips@linux-mips.org
Return-Path: <w.sang@pengutronix.de>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24077
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: w.sang@pengutronix.de
Precedence: bulk
X-list: linux-mips


--mP3DRpeJDSE+ciuQ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

> I will resubmit the patch without the FIXME.

Give me some more minutes for a closer glimpse.

--=20
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

--mP3DRpeJDSE+ciuQ
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkq6DXAACgkQD27XaX1/VRt7hwCgsA5pNID12+3rAcU5IWwRhsHY
x7UAoKA8g1SCgNexZCMcR/+r9mUeJ8Av
=P5Sv
-----END PGP SIGNATURE-----

--mP3DRpeJDSE+ciuQ--

From mbizon@freebox.fr Wed Sep 23 14:45:26 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 14:45:32 +0200 (CEST)
Received: from smtp6-g21.free.fr ([212.27.42.6]:46061 "EHLO smtp6-g21.free.fr"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492958AbZIWMp0 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 14:45:26 +0200
Received: from smtp6-g21.free.fr (localhost [127.0.0.1])
	by smtp6-g21.free.fr (Postfix) with ESMTP id C6E11E0808D;
	Wed, 23 Sep 2009 14:45:18 +0200 (CEST)
Received: from [213.228.1.107] (sakura.staff.proxad.net [213.228.1.107])
	by smtp6-g21.free.fr (Postfix) with ESMTP id D49D4E080E2;
	Wed, 23 Sep 2009 14:45:15 +0200 (CEST)
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
From:	Maxime Bizon <mbizon@freebox.fr>
Reply-To: mbizon@freebox.fr
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-pcmcia@lists.infradead.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
In-Reply-To: <20090923123143.GB3131@pengutronix.de>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>
	 <20090923123143.GB3131@pengutronix.de>
Content-Type: text/plain
Organization: Freebox
Date:	Wed, 23 Sep 2009 14:45:15 +0200
Message-Id: <1253709915.1627.397.camel@sakura.staff.proxad.net>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 7bit
Return-Path: <mbizon@freebox.fr>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24078
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mbizon@freebox.fr
Precedence: bulk
X-list: linux-mips


On Wed, 2009-09-23 at 14:31 +0200, Wolfram Sang wrote:

> Okay, here is a fast review. If you fix the mentioned points (or give me good
> reasons why not ;)), then you might add my
> 
> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
> 
> I am fine with Ralf picking this up.

Agreed on all your points and will fix them. Thanks.

Ralf, please give me a couple of days to fix this and I will send you an
updated patch.

-- 
Maxime



From rwmacleod@gmail.com Wed Sep 23 20:27:34 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 20:27:41 +0200 (CEST)
Received: from mail-yx0-f185.google.com ([209.85.210.185]:49260 "EHLO
	mail-yx0-f185.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493535AbZIWS1e (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 23 Sep 2009 20:27:34 +0200
Received: by yxe15 with SMTP id 15so1203166yxe.22
        for <linux-mips@linux-mips.org>; Wed, 23 Sep 2009 11:27:26 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:date:message-id:subject
         :from:to:content-type;
        bh=VWSkP4KCQxMT/NjDYaAjz9uPHgC7XesJCJjIV0jGt5A=;
        b=tp1cG7ZhEE8zMOnC7OavkXfGlNa/YqGQgajLlM2JM62kOYkfoLcpLJsHZAo8ak+dqi
         mqK8aYSnuaEPevqP+6PWibu+jpg1HHxbK+XRX1f57CVIVwWpiutAksZHtIzN0+XJgHkC
         xIdYr519LlL5cjn1crDRXR5zZQUQqbFCGX6a8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:date:message-id:subject:from:to:content-type;
        b=OJ5Jc7/SFKAd6uzvTV64BizVEpYeAIzTiW8TNMo1eOVdijZluHBmYA3wc2s+sWk6G5
         LamUoKhMm++RWgBehffqSpcMmS8wLdgF9jCmQI60yPexNWkU4Kx8lygL4mEaWxn67x5y
         ZU4/3BQvcgC6KZDqudcVsQQwNo9gIXqvazsP8=
MIME-Version: 1.0
Received: by 10.90.22.29 with SMTP id 29mr1495910agv.25.1253730446199; Wed, 23 
	Sep 2009 11:27:26 -0700 (PDT)
Date:	Wed, 23 Sep 2009 14:27:26 -0400
Message-ID: <21f828e90909231127h70f69047v91b9261226681d53@mail.gmail.com>
Subject: MIPS: [raw_]smp_processor_id uses current_thread_info
From:	Randy MacLeod <rwmacleod@gmail.com>
To:	linux-mips@linux-mips.org
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <rwmacleod@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24079
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: rwmacleod@gmail.com
Precedence: bulk
X-list: linux-mips

Hi,

I'd like advice on changing the implementation of smp_processor_id on
Cavium specifically and/or MIPS generally.

Currently we have: arch/mips/include/asm/smp.h
#define raw_smp_processor_id() (current_thread_info()->cpu)

A co-worker has an issue where the current thread pointer is corrupted
on a Cavium MIPS system running 2.6.14 (but the same code exists in 2.6.31).
During the resulting panic() the kernel calls smp_processor_id()
which dereferences the corrupt task pointer again - ouch. I've notice that
other arches have raw_smp_processor_id() defined to
 - a platform specific register read, or
 - a percpu variable or
 - have a hard_smp_processor_id() defined
This last one is presumably for times when you don't trust the kernel
data structures to be
sane.

I can create a patch that calls cvmx_get_core_num(); for cavium.
Is there a more generic way to get the cpu number on MIPS?

Thanks,
-- 
../Randy/..

From mason@upwardaccess.com Wed Sep 23 22:35:20 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 22:35:27 +0200 (CEST)
Received: from mail.upwardaccess.com ([70.89.180.121]:2199 "EHLO
	upwardaccess.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1493444AbZIWUfU (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 23 Sep 2009 22:35:20 +0200
Received: from hawaii.upwardaccess.com (unverified [10.61.7.126]) 
	by upwardaccess.com (SurgeMail 3.9e) with ESMTP id 913858-1847469 
	for multiple; Wed, 23 Sep 2009 13:34:46 -0700
Received: by hawaii.upwardaccess.com (Postfix, from userid 500)
	id E25F235425B; Wed, 23 Sep 2009 13:35:09 -0700 (PDT)
From:	Mark Mason <mmason@upwardaccess.com>
To:	ralf@linux-mips.org, glowingpurple@gmail.com,
	linux-mips@linux-mips.org
Cc:	Mark Mason <mmason@upwardaccess.com>
Subject: [PATCH] Sibyte: fix compilation error.
Date:	Wed, 23 Sep 2009 13:35:09 -0700
Message-Id: <1253738109-29457-1-git-send-email-mmason@upwardaccess.com>
X-Mailer: git-send-email 1.6.0.2
X-Originating-IP: 10.61.7.126
X-Authenticated-User: mmason@upwardaccess.com 
Return-Path: <mason@upwardaccess.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24080
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mmason@upwardaccess.com
Precedence: bulk
X-list: linux-mips

---
 arch/mips/sibyte/swarm/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
index 623ffc9..5277aac 100644
--- a/arch/mips/sibyte/swarm/setup.c
+++ b/arch/mips/sibyte/swarm/setup.c
@@ -106,7 +106,7 @@ void read_persistent_clock(struct timespec *ts)
 		break;
 	}
 	ts->tv_sec = sec;
-	tv->tv_nsec = 0;
+	ts->tv_nsec = 0;
 }
 
 int rtc_mips_set_time(unsigned long sec)
-- 
1.6.0.2


From ralf@linux-mips.org Wed Sep 23 22:48:52 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 22:48:59 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:46297 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493507AbZIWUsw (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 22:48:52 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8NKo5XF022204;
	Wed, 23 Sep 2009 21:50:07 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8NKo40q022202;
	Wed, 23 Sep 2009 21:50:04 +0100
Date:	Wed, 23 Sep 2009 21:50:04 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Mark Mason <mmason@upwardaccess.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH] When complaining about attempting to set the irq
	affinity to multiple cpus,
Message-ID: <20090923205004.GA21971@linux-mips.org>
References: <1253567604-6734-1-git-send-email-mmason@upwardaccess.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253567604-6734-1-git-send-email-mmason@upwardaccess.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24081
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Mon, Sep 21, 2009 at 02:13:24PM -0700, Mark Mason wrote:

>  arch/mips/sibyte/bcm1480/irq.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c
> index ba59839..fc87ea4 100644
> --- a/arch/mips/sibyte/bcm1480/irq.c
> +++ b/arch/mips/sibyte/bcm1480/irq.c
> @@ -118,7 +118,11 @@ static int bcm1480_set_affinity(unsigned int irq, const struct cpumask *mask)
>  	unsigned int irq_dirty;
>  
>  	if (cpumask_weight(mask) != 1) {
> -		printk("attempted to set irq affinity for irq %d to multiple CPUs\n", irq);
> +		printk("attempted to set irq affinity for irq %d to multiple CPUs:", irq);
> +		/* Print the mask */
> +		for_each_cpu(i, mask)
> +			printk(" %d", i);
> +		printk("\n");

The whole if block is a zombie that was supposed to have been
removed by commit 14275ccdb1e4b487cca745aba994699c426a31ee but then
returned in 92241940be501f798cb21db344bbb3d1ec3c4f1c.  So I went for a
slightly different patch, see below.

Thanks,

  Ralf

MIPS: BCM1480: Re-apply patch lost due to bad resolution of merge conflict.

Patch 14275ccdb1e4b487cca745aba994699c426a31ee and
d5dedd4507d307eb3f35f21b6e16f336fdc0d82a are conflicting and the
conflict was resolved badly in merge
92241940be501f798cb21db344bbb3d1ec3c4f1c resulting in the BCM1480 changes
of 14275ccdb1e4b487cca745aba994699c426a31ee getting lost.  Sort out the
damage.

Reported and initial patch by Mark Mason <mmason@upwardaccess.com>.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c
index ba59839..4070268 100644
--- a/arch/mips/sibyte/bcm1480/irq.c
+++ b/arch/mips/sibyte/bcm1480/irq.c
@@ -117,10 +117,6 @@ static int bcm1480_set_affinity(unsigned int irq, const struct cpumask *mask)
 	unsigned long flags;
 	unsigned int irq_dirty;
 
-	if (cpumask_weight(mask) != 1) {
-		printk("attempted to set irq affinity for irq %d to multiple CPUs\n", irq);
-		return -1;
-	}
 	i = cpumask_first(mask);
 
 	/* Convert logical CPU to physical CPU */

From ralf@linux-mips.org Wed Sep 23 22:59:59 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 23:00:08 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:46545 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493513AbZIWU77 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 22:59:59 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8NL1D7T022553;
	Wed, 23 Sep 2009 22:01:13 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8NL1D11022552;
	Wed, 23 Sep 2009 22:01:13 +0100
Date:	Wed, 23 Sep 2009 22:01:13 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Mark Mason <mmason@upwardaccess.com>
Cc:	glowingpurple@gmail.com, linux-mips@linux-mips.org
Subject: Re: [PATCH] Sibyte: fix compilation error.
Message-ID: <20090923210113.GA22516@linux-mips.org>
References: <1253738109-29457-1-git-send-email-mmason@upwardaccess.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1253738109-29457-1-git-send-email-mmason@upwardaccess.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24082
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Wed, Sep 23, 2009 at 01:35:09PM -0700, Mark Mason wrote:

Thanks, applied.

  Ralf

From ralf@linux-mips.org Wed Sep 23 23:22:49 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 23 Sep 2009 23:22:57 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:37645 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493518AbZIWVWt (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Wed, 23 Sep 2009 23:22:49 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8NLO1eo023167;
	Wed, 23 Sep 2009 22:24:01 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8NLO1Yt023165;
	Wed, 23 Sep 2009 22:24:01 +0100
Date:	Wed, 23 Sep 2009 22:24:01 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Mark E Mason <mason@broadcom.com>
Cc:	Mark Mason <mmason@upwardaccess.com>,
	"linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Subject: Re: [PATCH] When complaining about attempting to set the irq
	affinity to multiple cpus,
Message-ID: <20090923212401.GB22516@linux-mips.org>
References: <1253567604-6734-1-git-send-email-mmason@upwardaccess.com> <20090923205004.GA21971@linux-mips.org> <BD3F7F1EFBA6D54DB056C4FFA4514008037D6641C8@SJEXCHCCR01.corp.ad.broadcom.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <BD3F7F1EFBA6D54DB056C4FFA4514008037D6641C8@SJEXCHCCR01.corp.ad.broadcom.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24083
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Wed, Sep 23, 2009 at 02:09:34PM -0700, Mark E Mason wrote:

> Did we ever figure out why the kernel was attempting to set the affinity to more than one CPU? The hardware certainly supports doing that (but we're not at the moment).

The hardware semantics is a bit ususual.  On Sibyte the hardware will
route an interrupt to all CPUs set in the affinity mask.  On most other
systems that I'm aware of it will route the interrupt to only one of
CPUs selected by irq_chip->set_affinity().  We don't want such an
stampede so the Sibyte interrupt code clears all but the lowest set
bit from the set_affinity() argument.  Either way, attempting to set
the mask to an arbitrary non-empty set is entirely legal so the warning
itself was a bug and the volume potencially made them a real problem for
a few users.

  Ralf

From ralf@linux-mips.org Thu Sep 24 00:19:35 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 00:19:42 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:38931 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493301AbZIWWTf (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 24 Sep 2009 00:19:35 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8NMKKDH024742;
	Wed, 23 Sep 2009 23:20:20 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8NMK3be024719;
	Wed, 23 Sep 2009 23:20:03 +0100
Date:	Wed, 23 Sep 2009 23:20:03 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Kevin Cernekee <cernekee@gmail.com>
Cc:	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: Avoid destructive invalidation on partial L2
	cachelines
Message-ID: <20090923221937.GC22516@linux-mips.org>
References: <de70b67245e012ab0c11b520a721989b@localhost>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <de70b67245e012ab0c11b520a721989b@localhost>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24084
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Fri, Sep 18, 2009 at 07:12:45PM -0700, Kevin Cernekee wrote:

> This extends commit a8ca8b64e3fdfec17679cba0ca5ce6e3ffed092d to cover
> the board cache code.
> 
> Signed-off-by: Kevin Cernekee <cernekee@gmail.com>

Thanks Kevin, applied.

  Ralf

From manuel.lauss@googlemail.com Thu Sep 24 08:44:45 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 08:44:51 +0200 (CEST)
Received: from mail-bw0-f208.google.com ([209.85.218.208]:52162 "EHLO
	mail-bw0-f208.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492134AbZIXGok (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 24 Sep 2009 08:44:40 +0200
Received: by bwz4 with SMTP id 4so1132459bwz.0
        for <linux-mips@linux-mips.org>; Wed, 23 Sep 2009 23:44:35 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:mime-version:received:date:message-id:subject
         :from:to:cc:content-type;
        bh=56stehPIurl7gobcyKEvd4LAFzEyWCkelP9hYDNTHJQ=;
        b=FOPOG5Xe/A0z+ULO71P8nZPHU7xxsIqpYJtDwIN3yLOLoPVAhZQXwrbORTbXM3TfYb
         IBSpVixWKNH6rLXhUzjssBL/x9mA0jE2s3dY2HO5Bf+OBU5Z5/HRVy7maA88ItqX0VSg
         hIRGSkaRpA1JO0zPNY0pFtPjYQyR1JQaVYB4M=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=mime-version:date:message-id:subject:from:to:cc:content-type;
        b=NXpDZhRiIjGluFydX8rJHXXa6pxawJakXDBuwp7Qkq474NPeNxo5FUzunN2TA9V1Ah
         bkpW2ZrEzzJ4Y6C6EmiIzOJN138iAptVIskbKmCMb1UikKhnOEZgd2ZqdaKvjsCpDqly
         QQ1R46Qcxmb4A34mgzJh8oSD9mY6xYwTy576M=
MIME-Version: 1.0
Received: by 10.223.24.87 with SMTP id u23mr1065249fab.81.1253774674718; Wed, 
	23 Sep 2009 23:44:34 -0700 (PDT)
Date:	Thu, 24 Sep 2009 08:44:34 +0200
Message-ID: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
Subject: MIPS: Alchemy build broken in latest linus-git
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Sam Ravnborg <sam@ravnborg.org>
Cc:	Linux-MIPS <linux-mips@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24085
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

Hi Sam!

Commit 51b563fc93c8cb5bff1d67a0a71c374e4a4ea049 breaks
Alchemy build in vmlinux.lds:


mipsel-softfloat-linux-gnu-gcc -E
-Wp,-MD,arch/mips/kernel/.vmlinux.lds.d  -nostdinc -isystem
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.3.4/include -Iinclude
-Iinclude2 -I/mnt/work/au1200/kernel/linux-2.6.git/include
-I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include -include
include/linux/autoconf.h -D__KERNEL__
-D"VMLINUX_LOAD_ADDRESS=0xffffffff80100000" -D"DATAOFFSET=0" -P -C
-Umips -D__ASSEMBLY__ -DLINKER_SCRIPT -o arch/mips/kernel/vmlinux.lds
/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/kernel/vmlinux.lds.S
In file included from
/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/kernel/vmlinux.lds.S:2:
/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/page.h:12:20:
error: spaces.h: No such file or directory
make[2]: *** [arch/mips/kernel/vmlinux.lds] Error 1
make[1]: *** [arch/mips/kernel] Error 2
make: *** [sub-make] Error 2

I tracked it to this part in the commit:
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index c825b14..77f5021 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
[...]
-#
-# Choosing incompatible machines durings configuration will result in
-# error messages during linking.  Select a default linkscript if
-# none has been choosen above.
-#
-
-CPPFLAGS_vmlinux.lds := \
-       $(KBUILD_CFLAGS) \
-       -D"LOADADDR=$(load-y)" \
-       -D"JIFFIES=$(JIFFIES)" \
-       -D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)"
-


This eliminates the a whole lot of include directives, among which is
"-Iarch/mips/include/asm/mach-generic" which provides a path to the
now-missing "spaces.h".

Is there a cheap way to add this back again?

For reference, here's the full compiler command for the previously-working
case:

mipsel-softfloat-linux-gnu-gcc -E
-Wp,-MD,arch/mips/kernel/.vmlinux.lds.d  -nostdinc -isystem
/usr/lib/gcc/mipsel-softfloat-linux-gnu/4.3.4/include -Iinclude
-Iinclude2 -I/mnt/work/au1200/kernel/linux-2.6.git/include
-I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include -include
include/linux/autoconf.h -D__KERNEL__ -Wall -Wundef
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common
-Werror-implicit-function-declaration -Wno-format-security
-fno-delete-null-pointer-checks -O2 -ffunction-sections
-mno-check-zero-division -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe
-msoft-float -ffreestanding -march=mips32 -Wa,-mips32 -Wa,--trap
-I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/mach-db1x00
  -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/mach-au1x00
  -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/mach-generic
-D"VMLINUX_LOAD_ADDRESS=0xffffffff80100000"
-D"LOADADDR=0xffffffff80100000" -D"JIFFIES=jiffies_64"
-D"DATAOFFSET=0" -P -C -Umips -D__ASSEMBLY__ -o
arch/mips/kernel/vmlinux.lds
/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/kernel/vmlinux.lds.S

Btw, I've been using bash-4 on my hosts since Gentoo added it to
their repos a few months ago, and I haven't noticed any breakages
so far.

Thanks!
        Manuel Lauss

From dmitri.vorobiev@gmail.com Thu Sep 24 09:49:54 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 09:50:01 +0200 (CEST)
Received: from mail-bw0-f208.google.com ([209.85.218.208]:36876 "EHLO
	mail-bw0-f208.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492200AbZIXHty (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 24 Sep 2009 09:49:54 +0200
Received: by bwz4 with SMTP id 4so1158754bwz.0
        for <linux-mips@linux-mips.org>; Thu, 24 Sep 2009 00:49:48 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type;
        bh=SnnVxgOW7+Sr5F8AFW3b/SN7dJyxOAnRSHyHUGk4vFQ=;
        b=mPnvGZCYkGSbg2OJ06JHeWPgnlEVN5/6Q3ZPDUqVshHjlXTvJMkE3XPPWqIrSbkx8k
         9B+H5WJiN4DulgbbohWX+22mgFhYc2M0RqtQ3u+SBCPmKwauisVXe7Wrg6GKJakw8f9y
         aQ+fx+A6Mba8yljs2Q2OwEeNQS4U67qeEdQpY=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        b=hZfpUe0KkCKgFyJETBq0peWSnZgcS0SZNXGoECMpVjoPPK9rJhrkIOpPUh9Vs/7YYk
         Szo2L31FacD5lh/WqS62lbtPh4nxAt2lwBp4nmaOCLWGVEfIl/NTf3A6LmjFQiGRSm13
         yr+qoFl0xumqOrqIzEhP2LUYJ6Peq7xaqO7ok=
MIME-Version: 1.0
Received: by 10.223.144.70 with SMTP id y6mr1032533fau.5.1253778588121; Thu, 
	24 Sep 2009 00:49:48 -0700 (PDT)
In-Reply-To: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
Date:	Thu, 24 Sep 2009 10:49:48 +0300
Message-ID: <90edad820909240049j693d6712wb659a469025c584f@mail.gmail.com>
Subject: Re: MIPS: Alchemy build broken in latest linus-git
From:	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
To:	Manuel Lauss <manuel.lauss@googlemail.com>
Cc:	Sam Ravnborg <sam@ravnborg.org>,
	Linux-MIPS <linux-mips@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24086
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips

On Thu, Sep 24, 2009 at 9:44 AM, Manuel Lauss
<manuel.lauss@googlemail.com> wrote:
> Hi Sam!
>

[skipped]

> error: spaces.h: No such file or directory

The same problem for the SGI IP22.

Thanks,
Dmitri

From sam@ravnborg.org Thu Sep 24 11:15:43 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 11:15:50 +0200 (CEST)
Received: from [195.41.46.236] ([195.41.46.236]:46180 "EHLO pfepb.post.tele.dk"
	rhost-flags-FAIL-FAIL-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492252AbZIXJPn (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 24 Sep 2009 11:15:43 +0200
Received: from merkur.ravnborg.org (x1-6-00-1e-2a-84-ae-3e.k225.webspeed.dk [80.163.61.94])
	by pfepb.post.tele.dk (Postfix) with ESMTP id 2EF52F84054;
	Thu, 24 Sep 2009 11:15:40 +0200 (CEST)
Date:	Thu, 24 Sep 2009 11:15:40 +0200
From:	Sam Ravnborg <sam@ravnborg.org>
To:	Manuel Lauss <manuel.lauss@googlemail.com>
Cc:	Linux-MIPS <linux-mips@linux-mips.org>
Subject: Re: MIPS: Alchemy build broken in latest linus-git
Message-ID: <20090924091539.GA929@merkur.ravnborg.org>
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <sam@ravnborg.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24087
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: sam@ravnborg.org
Precedence: bulk
X-list: linux-mips

On Thu, Sep 24, 2009 at 08:44:34AM +0200, Manuel Lauss wrote:
> Hi Sam!
> 
> Commit 51b563fc93c8cb5bff1d67a0a71c374e4a4ea049 breaks
> Alchemy build in vmlinux.lds:
> 
> 
> mipsel-softfloat-linux-gnu-gcc -E
> -Wp,-MD,arch/mips/kernel/.vmlinux.lds.d  -nostdinc -isystem
> /usr/lib/gcc/mipsel-softfloat-linux-gnu/4.3.4/include -Iinclude
> -Iinclude2 -I/mnt/work/au1200/kernel/linux-2.6.git/include
> -I/mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include -include
> include/linux/autoconf.h -D__KERNEL__
> -D"VMLINUX_LOAD_ADDRESS=0xffffffff80100000" -D"DATAOFFSET=0" -P -C
> -Umips -D__ASSEMBLY__ -DLINKER_SCRIPT -o arch/mips/kernel/vmlinux.lds
> /mnt/work/au1200/kernel/linux-2.6.git/arch/mips/kernel/vmlinux.lds.S
> In file included from
> /mnt/work/au1200/kernel/linux-2.6.git/arch/mips/kernel/vmlinux.lds.S:2:
> /mnt/work/au1200/kernel/linux-2.6.git/arch/mips/include/asm/page.h:12:20:
> error: spaces.h: No such file or directory
> make[2]: *** [arch/mips/kernel/vmlinux.lds] Error 1
> make[1]: *** [arch/mips/kernel] Error 2
> make: *** [sub-make] Error 2
> 
> I tracked it to this part in the commit:
> diff --git a/arch/mips/Makefile b/arch/mips/Makefile
> index c825b14..77f5021 100644
> --- a/arch/mips/Makefile
> +++ b/arch/mips/Makefile
> [...]
> -#
> -# Choosing incompatible machines durings configuration will result in
> -# error messages during linking.  Select a default linkscript if
> -# none has been choosen above.
> -#
> -
> -CPPFLAGS_vmlinux.lds := \
> -       $(KBUILD_CFLAGS) \
> -       -D"LOADADDR=$(load-y)" \
> -       -D"JIFFIES=$(JIFFIES)" \
> -       -D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)"
> -

I'm away from my machine atm.
Could you try to add the following to arch/mips/kernel/makefile:

CPPFFLAGS_vmlinux.lds += $(KBUILD_CFLAGS)

This should fix it.

	Sam

From manuel.lauss@googlemail.com Thu Sep 24 11:24:52 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 11:24:58 +0200 (CEST)
Received: from mail-bw0-f208.google.com ([209.85.218.208]:40978 "EHLO
	mail-bw0-f208.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492326AbZIXJYw (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 24 Sep 2009 11:24:52 +0200
Received: by bwz4 with SMTP id 4so1207168bwz.0
        for <linux-mips@linux-mips.org>; Thu, 24 Sep 2009 02:24:46 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type;
        bh=AstFJ06D68nZbPy4uPs7cEXDrD1fDTQkqvqQD/4Lk5U=;
        b=fJRcbufMn9ugW747YC92HDZ769wDJ+1q5kX6+AnhOUrxMHq9uU8f/wZ7kIMj6i3qe/
         hMcg5+1Dp/7Kh/Coab6utSaPQUuPiFvft8eltZswb4VkdkFsWuPzwjIl4LFPXYO913qW
         XINO3d6nzhX8F5z/ktww+GlnMlgPRcDIxroP8=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        b=LjQVnKRFdBw8lu819WO4NiBdv9zNHl7ZN2FQOo3PMndKom7Dv46JNv+FIyG09DNlJR
         T7xZjRJMvJl17MyGbBiEetyjpfAF72FQB/YM4tOs+vZcP/CRv3ivXYs6VpKcvEj28iub
         lKn6u6fTUMVCm0zxrdR0t3sn5uMr25AyPrcXY=
MIME-Version: 1.0
Received: by 10.103.80.18 with SMTP id h18mr1367551mul.65.1253784285976; Thu, 
	24 Sep 2009 02:24:45 -0700 (PDT)
In-Reply-To: <20090924091539.GA929@merkur.ravnborg.org>
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
	 <20090924091539.GA929@merkur.ravnborg.org>
Date:	Thu, 24 Sep 2009 11:24:45 +0200
Message-ID: <f861ec6f0909240224m4b5dcbd9hc835409e7a66102d@mail.gmail.com>
Subject: Re: MIPS: Alchemy build broken in latest linus-git
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Sam Ravnborg <sam@ravnborg.org>
Cc:	Linux-MIPS <linux-mips@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24088
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

> I'm away from my machine atm.
> Could you try to add the following to arch/mips/kernel/makefile:
>
> CPPFFLAGS_vmlinux.lds += $(KBUILD_CFLAGS)
>
> This should fix it.

Thank you, that did it.

        Manuel Lauss

From manuel.lauss@googlemail.com Thu Sep 24 11:41:48 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 11:41:54 +0200 (CEST)
Received: from mail-bw0-f208.google.com ([209.85.218.208]:62043 "EHLO
	mail-bw0-f208.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492313AbZIXJls (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 24 Sep 2009 11:41:48 +0200
Received: by bwz4 with SMTP id 4so1216079bwz.0
        for <linux-mips@linux-mips.org>; Thu, 24 Sep 2009 02:41:42 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type;
        bh=Sztkcj1QUoIyUyzPvqPPgX2xNCf/iwOs7lpkEKbHgek=;
        b=eeJmlZEi9Hg0nXj7oRodB9nbmzveSvWOhlPIJLHTczLKLqMuTLFV37EBnQCIGi2QVp
         EgOwp9rX3OURwFs5htq2uJaG3Tay5up8ZHuaHtp3XgTkqu36/cvYmc+OPvRKDR6rWZ4q
         7fE4Hxl4rYjOaxJC4kt7kV0kzwbX1Ob35ty/E=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        b=pcoYDB7lB7cI6meAgU18CLUqNmstKjMg2kRx2jLrLdpju84CNaYnfL2Ee5EoSgwW83
         OzJEr0ibI6YGEmvShybYduYVkLI76ExYNt3+EHnQ7j9WFQecwA2nagqX5lwbhWS6Xp2u
         K9xHwmq4o0tmS2wgjYvhRCoVGFKvnRMTdZbLA=
MIME-Version: 1.0
Received: by 10.103.85.28 with SMTP id n28mr1383110mul.66.1253785301301; Thu, 
	24 Sep 2009 02:41:41 -0700 (PDT)
In-Reply-To: <f861ec6f0909240224m4b5dcbd9hc835409e7a66102d@mail.gmail.com>
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
	 <20090924091539.GA929@merkur.ravnborg.org>
	 <f861ec6f0909240224m4b5dcbd9hc835409e7a66102d@mail.gmail.com>
Date:	Thu, 24 Sep 2009 11:41:41 +0200
Message-ID: <f861ec6f0909240241x5c5858d4g4d44b40107021bb6@mail.gmail.com>
Subject: Re: MIPS: Alchemy build broken in latest linus-git
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Sam Ravnborg <sam@ravnborg.org>
Cc:	Linux-MIPS <linux-mips@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24089
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

On Thu, Sep 24, 2009 at 11:24 AM, Manuel Lauss
<manuel.lauss@googlemail.com> wrote:
>> I'm away from my machine atm.
>> Could you try to add the following to arch/mips/kernel/makefile:
>>
>> CPPFFLAGS_vmlinux.lds += $(KBUILD_CFLAGS)
>>
>> This should fix it.
>
> Thank you, that did it.

Spoke too soon:

This leaves unprocessed directives in vmlinux.lds:

[...]
OUTPUT_ARCH(mips)
ENTRY(kernel_entry)
PHDRS {
 text PT_LOAD FLAGS(7); /* RWX */
 note PT_NOTE FLAGS(4); /* R__ */
}
ifdef 1
 ifdef 1
  jiffies = jiffies_64;
 else
  jiffies = jiffies_64 + 4;
 endif
else
 jiffies = jiffies_64;
endif
SECTIONS
{
 . = 0xffffffff80100000;
 /* read-only */
 _text = .; /* Text and read-only data */
[...]


        Manuel Lauss

From manuel.lauss@googlemail.com Thu Sep 24 14:09:55 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 14:10:01 +0200 (CEST)
Received: from fg-out-1718.google.com ([72.14.220.159]:1735 "EHLO
	fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1492256AbZIXMJz (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 24 Sep 2009 14:09:55 +0200
Received: by fg-out-1718.google.com with SMTP id d23so503345fga.6
        for <linux-mips@linux-mips.org>; Thu, 24 Sep 2009 05:09:55 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from
         :organization:user-agent:mime-version:to:cc:subject:references
         :in-reply-to:content-type:content-transfer-encoding;
        bh=//V/TyCBJ6ZJcjcjCWwTXRUXX5MdLSebuFMMn/4kaSM=;
        b=oHgS3/f/fre542JdEtF48zHsdxaKybKgeyRYILE7yuR1CrAJUdrEoEqLnhvqSEYM56
         YVcG+v55y00U7NkDYzYRvtatulEQFqxz9/AzfYVKyWfq3dsc566jhPFbGaUdhSre3+ge
         x7yMwEFD3ak04reTsP+hVSnVFtc8zTPIZ+ZzE=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=message-id:date:from:organization:user-agent:mime-version:to:cc
         :subject:references:in-reply-to:content-type
         :content-transfer-encoding;
        b=Es2KF+b4uUCv0d9hh0/foihR1X1DoXrYQFHjRoc4j2WW2Di6bJlVVer+fDPmBNQCm3
         wbhFsqHqprDEvZ+7pT2aC0XmerxVH+n0mtCq/eTBlDlGP20hcmPQEIjZs88Htmb1z/l6
         mmV91XhqHlqbhgorvtVIBYPFpWV3qIa5gn6Cs=
Received: by 10.86.16.9 with SMTP id 9mr2846953fgp.8.1253794195222;
        Thu, 24 Sep 2009 05:09:55 -0700 (PDT)
Received: from ?0.0.0.0? (p5496B0C7.dip.t-dialin.net [84.150.176.199])
        by mx.google.com with ESMTPS id d6sm1762188fga.6.2009.09.24.05.09.52
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Thu, 24 Sep 2009 05:09:54 -0700 (PDT)
Message-ID: <4ABB6189.5010909@gmail.com>
Date:	Thu, 24 Sep 2009 14:09:45 +0200
From:	Manuel Lauss <manuel.lauss@googlemail.com>
Organization: Private
User-Agent: Thunderbird 2.0.0.23 (X11/20090828)
MIME-Version: 1.0
To:	Manuel Lauss <manuel.lauss@googlemail.com>
CC:	Sam Ravnborg <sam@ravnborg.org>,
	Linux-MIPS <linux-mips@linux-mips.org>,
	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
Subject: Re: MIPS: Alchemy build broken in latest linus-git [with patch]
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>	 <20090924091539.GA929@merkur.ravnborg.org>	 <f861ec6f0909240224m4b5dcbd9hc835409e7a66102d@mail.gmail.com> <f861ec6f0909240241x5c5858d4g4d44b40107021bb6@mail.gmail.com>
In-Reply-To: <f861ec6f0909240241x5c5858d4g4d44b40107021bb6@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24090
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

Manuel Lauss wrote:
> On Thu, Sep 24, 2009 at 11:24 AM, Manuel Lauss
> <manuel.lauss@googlemail.com> wrote:
>>> I'm away from my machine atm.
>>> Could you try to add the following to arch/mips/kernel/makefile:
>>>
>>> CPPFFLAGS_vmlinux.lds += $(KBUILD_CFLAGS)
>>>
>>> This should fix it.
>> Thank you, that did it.
> 
> Spoke too soon:
> 
> This leaves unprocessed directives in vmlinux.lds:
> 
> [...]
> OUTPUT_ARCH(mips)
> ENTRY(kernel_entry)
> PHDRS {
>  text PT_LOAD FLAGS(7); /* RWX */
>  note PT_NOTE FLAGS(4); /* R__ */
> }
> ifdef 1
>  ifdef 1
>   jiffies = jiffies_64;
>  else
>   jiffies = jiffies_64 + 4;
>  endif
> else
>  jiffies = jiffies_6

... which is of course easily fixed after consumption of
unhealthy amounts of coffee.

Patch below works for me.

Thank you Sam!
	Manuel Lauss

---

From: Manuel Lauss <manuel.lauss@gmail.com>
Subject: [PATCH] MIPS: fix build of vmlinux.lds

Commit 51b563fc93c8cb5bff1d67a0a71c374e4a4ea049 removed a few
CPPFLAGS with vital include paths necessary to build vmlinux.lds
on MIPS, and moved the calculation of the 'jiffies' symbol
directly to vmlinux.lds.S but forgot to change make ifdef/... to
cpp macros.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
 arch/mips/kernel/Makefile      |    2 ++
 arch/mips/kernel/vmlinux.lds.S |   12 ++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index e961221..8e26e9c 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -91,3 +91,5 @@ CFLAGS_cpu-bugs64.o	= $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/n
 obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT)	+= 8250-platform.o

 EXTRA_CFLAGS += -Werror
+
+CPPFLAGS_vmlinux.lds		:= $(KBUILD_CFLAGS)
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 9bf0e3d..162b299 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -11,15 +11,15 @@ PHDRS {
 	note PT_NOTE FLAGS(4);	/* R__ */
 }

-ifdef CONFIG_32BIT
-	ifdef CONFIG_CPU_LITTLE_ENDIAN
+#ifdef CONFIG_32BIT
+	#ifdef CONFIG_CPU_LITTLE_ENDIAN
 		jiffies  = jiffies_64;
-	else
+	#else
 		jiffies  = jiffies_64 + 4;
-	endif
-else
+	#endif
+#else
 	jiffies  = jiffies_64;
-endif
+#endif

 SECTIONS
 {
--
1.6.5.rc1

From dmitri.vorobiev@gmail.com Thu Sep 24 14:23:57 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 14:24:05 +0200 (CEST)
Received: from mail-fx0-f221.google.com ([209.85.220.221]:48453 "EHLO
	mail-fx0-f221.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493089AbZIXMX5 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 24 Sep 2009 14:23:57 +0200
Received: by fxm21 with SMTP id 21so1280351fxm.33
        for <linux-mips@linux-mips.org>; Thu, 24 Sep 2009 05:23:51 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type;
        bh=NDvmG7rzdIRqpIG1TcF1vAe/FliuFWvffKHVuHFhEvE=;
        b=MpTEzrtRWCACywEK8ZX0ppwHMMqyPFNRLeg4vOFA6m1REVLWKaXzPyjVlKmGfj5iXR
         sTcZM/rXWnyHj8gIp5KFNLEQ72RDPPEebaH2BG1sepv9G4PEd5FHNgRnKDdJhej87QmI
         gUady4E1gKlP+6JwfAKgO5jqIV3ivuoTI5yNY=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        b=xsqvlQhW58/cZOS0WetFa6qJNJrbTfnJcn19szL4X4J2781ucIl92PsjC+ZIHRy+ge
         YP+yUy8vIOEwq2faZ0D7ci6GKIb5eneoNeI4GvP4iTMd8wU0O3w0jb94HnAjakbI+9We
         Sv+DxRZtNAMnrzhBuKUsDJkQ9olTsVnlvdSVs=
MIME-Version: 1.0
Received: by 10.223.161.205 with SMTP id s13mr1215254fax.27.1253795031455; 
	Thu, 24 Sep 2009 05:23:51 -0700 (PDT)
In-Reply-To: <4ABB6189.5010909@gmail.com>
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
	 <20090924091539.GA929@merkur.ravnborg.org>
	 <f861ec6f0909240224m4b5dcbd9hc835409e7a66102d@mail.gmail.com>
	 <f861ec6f0909240241x5c5858d4g4d44b40107021bb6@mail.gmail.com>
	 <4ABB6189.5010909@gmail.com>
Date:	Thu, 24 Sep 2009 15:23:51 +0300
Message-ID: <90edad820909240523m4f284d0ep1cf0abf0f4909d9c@mail.gmail.com>
Subject: Re: MIPS: Alchemy build broken in latest linus-git [with patch]
From:	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
To:	Manuel Lauss <manuel.lauss@googlemail.com>
Cc:	Sam Ravnborg <sam@ravnborg.org>,
	Linux-MIPS <linux-mips@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24091
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips

On Thu, Sep 24, 2009 at 3:09 PM, Manuel Lauss
<manuel.lauss@googlemail.com> wrote:
> Manuel Lauss wrote:
>> On Thu, Sep 24, 2009 at 11:24 AM, Manuel Lauss
>> <manuel.lauss@googlemail.com> wrote:
>>>> I'm away from my machine atm.
>>>> Could you try to add the following to arch/mips/kernel/makefile:
>>>>
>>>> CPPFFLAGS_vmlinux.lds += $(KBUILD_CFLAGS)
>>>>
>>>> This should fix it.
>>> Thank you, that did it.
>>
>> Spoke too soon:
>>
>> This leaves unprocessed directives in vmlinux.lds:
>>
>> [...]
>> OUTPUT_ARCH(mips)
>> ENTRY(kernel_entry)
>> PHDRS {
>>  text PT_LOAD FLAGS(7); /* RWX */
>>  note PT_NOTE FLAGS(4); /* R__ */
>> }
>> ifdef 1
>>  ifdef 1
>>   jiffies = jiffies_64;
>>  else
>>   jiffies = jiffies_64 + 4;
>>  endif
>> else
>>  jiffies = jiffies_6
>
> ... which is of course easily fixed after consumption of
> unhealthy amounts of coffee.
>
> Patch below works for me.

For me too, and I am using a custom IP22 config.

Thanks!

Dmitri

From ralf@linux-mips.org Thu Sep 24 17:50:15 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 17:50:22 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:57672 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1492630AbZIXPuP (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 24 Sep 2009 17:50:15 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8OFpU2A013512;
	Thu, 24 Sep 2009 16:51:30 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8OFpTZX013510;
	Thu, 24 Sep 2009 16:51:29 +0100
Date:	Thu, 24 Sep 2009 16:51:29 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Randy MacLeod <rwmacleod@gmail.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: MIPS: [raw_]smp_processor_id uses current_thread_info
Message-ID: <20090924155129.GA11576@linux-mips.org>
References: <21f828e90909231127h70f69047v91b9261226681d53@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <21f828e90909231127h70f69047v91b9261226681d53@mail.gmail.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24092
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Wed, Sep 23, 2009 at 02:27:26PM -0400, Randy MacLeod wrote:

> I'd like advice on changing the implementation of smp_processor_id on
> Cavium specifically and/or MIPS generally.
> 
> Currently we have: arch/mips/include/asm/smp.h
> #define raw_smp_processor_id() (current_thread_info()->cpu)
> 
> A co-worker has an issue where the current thread pointer is corrupted
> on a Cavium MIPS system running 2.6.14 (but the same code exists in 2.6.31).
> During the resulting panic() the kernel calls smp_processor_id()
> which dereferences the corrupt task pointer again - ouch. I've notice that
> other arches have raw_smp_processor_id() defined to
>  - a platform specific register read, or
>  - a percpu variable or
>  - have a hard_smp_processor_id() defined
> This last one is presumably for times when you don't trust the kernel
> data structures to be
> sane.

Dereferencing current_thread_info()->cpu is fairly likely to hit in the cache
so probably a single cycle operation.  raw_smp_processor_id() is also a
very common operation so you really don't want to change it to something
slower except for a debugging kernel.

If you have a good kernel stack pointer you can compute the thread pointer
from that:

	ori     $28, sp, _THREAD_MASK
	xori    $28, _THREAD_MASK

> I can create a patch that calls cvmx_get_core_num(); for cavium.
> Is there a more generic way to get the cpu number on MIPS?

raw_smp_processor_id() returns the processor ID as counted by Linux.  That
number does not necessarily match the firmware's numbering.

  Ralf

From anemo@mba.ocn.ne.jp Thu Sep 24 19:10:45 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 19:10:51 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:58710 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1493286AbZIXRKo (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 24 Sep 2009 19:10:44 +0200
Received: from localhost (p5080-ipad304funabasi.chiba.ocn.ne.jp [123.217.159.80])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 457F96D6A; Fri, 25 Sep 2009 02:10:36 +0900 (JST)
Date:	Fri, 25 Sep 2009 02:10:39 +0900 (JST)
Message-Id: <20090925.021039.179960776.anemo@mba.ocn.ne.jp>
To:	david-b@pacbell.net
Cc:	linux-mips@linux-mips.org, spi-devel-general@lists.sourceforge.net,
	ralf@linux-mips.org
Subject: Re: [PATCH 2/2] spi_txx9: Fix bit rate calculation
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <20090904163227.GB6699@linux-mips.org>
References: <1251986341-16938-2-git-send-email-anemo@mba.ocn.ne.jp>
	<20090904163227.GB6699@linux-mips.org>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 5.2 on Emacs 22.2 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24093
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

On Fri, 4 Sep 2009 17:32:27 +0100, Ralf Baechle <ralf@linux-mips.org> wrote:
> Atsushi's patches should probably be merged together.  I can take care of
> that if the SPI bit is acked by a maintainer.

David, could you give us Ack ?

[PATCH 1/2] txx9: Fix spi-baseclk value
[PATCH 2/2] spi_txx9: Fix bit rate calculation

---
Atsushi Nemoto

From kevink@paralogos.com Thu Sep 24 20:16:31 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 20:16:38 +0200 (CEST)
Received: from gateway09.websitewelcome.com ([69.93.243.4]:33603 "HELO
	gateway09.websitewelcome.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with SMTP id S1493286AbZIXSQb (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 24 Sep 2009 20:16:31 +0200
Received: (qmail 16014 invoked from network); 24 Sep 2009 18:27:03 -0000
Received: from gator750.hostgator.com (174.132.194.2)
  by gateway09.websitewelcome.com with SMTP; 24 Sep 2009 18:27:03 -0000
Received: from 216-239-45-4.google.com ([216.239.45.4]:56071 helo=epiktistes.mtv.corp.google.com)
	by gator750.hostgator.com with esmtpa (Exim 4.69)
	(envelope-from <kevink@paralogos.com>)
	id 1Mqsrj-0001sP-5E; Thu, 24 Sep 2009 13:16:27 -0500
Message-ID: <4ABBB779.1040201@paralogos.com>
Date:	Thu, 24 Sep 2009 11:16:25 -0700
From:	"Kevin D. Kissell" <kevink@paralogos.com>
User-Agent: Thunderbird 2.0.0.23 (X11/20090817)
MIME-Version: 1.0
To:	Ralf Baechle <ralf@linux-mips.org>
CC:	Randy MacLeod <rwmacleod@gmail.com>, linux-mips@linux-mips.org
Subject: Re: MIPS: [raw_]smp_processor_id uses current_thread_info
References: <21f828e90909231127h70f69047v91b9261226681d53@mail.gmail.com> <20090924155129.GA11576@linux-mips.org>
In-Reply-To: <20090924155129.GA11576@linux-mips.org>
Content-Type: multipart/alternative;
 boundary="------------060409050907000907080309"
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator750.hostgator.com
X-AntiAbuse: Original Domain - linux-mips.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - paralogos.com
Return-Path: <kevink@paralogos.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24094
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: kevink@paralogos.com
Precedence: bulk
X-list: linux-mips

This is a multi-part message in MIME format.
--------------060409050907000907080309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ralf Baechle wrote:
> On Wed, Sep 23, 2009 at 02:27:26PM -0400, Randy MacLeod wrote:
>
>   
>> I'd like advice on changing the implementation of smp_processor_id on
>> Cavium specifically and/or MIPS generally.
>>
>> Currently we have: arch/mips/include/asm/smp.h
>> #define raw_smp_processor_id() (current_thread_info()->cpu)
>>
>> A co-worker has an issue where the current thread pointer is corrupted
>> on a Cavium MIPS system running 2.6.14 (but the same code exists in 2.6.31).
>> During the resulting panic() the kernel calls smp_processor_id()
>> which dereferences the corrupt task pointer again - ouch. I've notice that
>> other arches have raw_smp_processor_id() defined to
>>  - a platform specific register read, or
>>  - a percpu variable or
>>  - have a hard_smp_processor_id() defined
>> This last one is presumably for times when you don't trust the kernel
>> data structures to be
>> sane.
>>     
>
> Dereferencing current_thread_info()->cpu is fairly likely to hit in the cache
> so probably a single cycle operation.
Ironically, it's statistically faster than reading a dedicated CP0 
register on those cores that have them, even if that were otherwise a 
good idea (see below), since access to CP0 registers generally doesn't 
pipeline!

>   raw_smp_processor_id() is also a
> very common operation so you really don't want to change it to something
> slower except for a debugging kernel.
>
> If you have a good kernel stack pointer you can compute the thread pointer
> from that:
>
> 	ori     $28, sp, _THREAD_MASK
> 	xori    $28, _THREAD_MASK
>
>   
>> I can create a patch that calls cvmx_get_core_num(); for cavium.
>> Is there a more generic way to get the cpu number on MIPS?
>>     
>
> raw_smp_processor_id() returns the processor ID as counted by Linux.  That
> number does not necessarily match the firmware's numbering.
Nor does it necessarily match the MIPS32R2's hardware CPU number in the 
EBase register.  smp_processor_id() is fundamentally a software concept, 
and it's more a lucky coincidence than an ironclad rule when it tracks 
hardware/firmware numbering.


          Regards,

          Kevin K.

--------------060409050907000907080309
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ralf Baechle wrote:
<blockquote cite="mid:20090924155129.GA11576@linux-mips.org" type="cite">
  <pre wrap="">On Wed, Sep 23, 2009 at 02:27:26PM -0400, Randy MacLeod wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">I'd like advice on changing the implementation of smp_processor_id on
Cavium specifically and/or MIPS generally.

Currently we have: arch/mips/include/asm/smp.h
#define raw_smp_processor_id() (current_thread_info()-&gt;cpu)

A co-worker has an issue where the current thread pointer is corrupted
on a Cavium MIPS system running 2.6.14 (but the same code exists in 2.6.31).
During the resulting panic() the kernel calls smp_processor_id()
which dereferences the corrupt task pointer again - ouch. I've notice that
other arches have raw_smp_processor_id() defined to
 - a platform specific register read, or
 - a percpu variable or
 - have a hard_smp_processor_id() defined
This last one is presumably for times when you don't trust the kernel
data structures to be
sane.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
Dereferencing current_thread_info()-&gt;cpu is fairly likely to hit in the cache
so probably a single cycle operation.</pre>
</blockquote>
Ironically, it's statistically faster than reading a dedicated CP0
register on those cores that have them, even if that were otherwise a
good idea (see below), since access to CP0 registers generally doesn't
pipeline!<br>
<br>
<blockquote cite="mid:20090924155129.GA11576@linux-mips.org" type="cite">
  <pre wrap="">  raw_smp_processor_id() is also a
very common operation so you really don't want to change it to something
slower except for a debugging kernel.

If you have a good kernel stack pointer you can compute the thread pointer
from that:

	ori     $28, sp, _THREAD_MASK
	xori    $28, _THREAD_MASK

  </pre>
  <blockquote type="cite">
    <pre wrap="">I can create a patch that calls cvmx_get_core_num(); for cavium.
Is there a more generic way to get the cpu number on MIPS?
    </pre>
  </blockquote>
  <pre wrap=""><!---->
raw_smp_processor_id() returns the processor ID as counted by Linux.  That
number does not necessarily match the firmware's numbering.</pre>
</blockquote>
Nor does it necessarily match the MIPS32R2's hardware CPU number in the
EBase register.&nbsp; smp_processor_id() is fundamentally a software
concept, and it's more a lucky coincidence than an ironclad rule when
it tracks hardware/firmware numbering.<br>
<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; Regards,<br>
<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; Kevin K.<br>
</body>
</html>

--------------060409050907000907080309--

From sam@ravnborg.org Thu Sep 24 21:43:58 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 24 Sep 2009 21:44:05 +0200 (CEST)
Received: from [195.41.46.235] ([195.41.46.235]:60526 "EHLO pfepa.post.tele.dk"
	rhost-flags-FAIL-FAIL-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493317AbZIXTn6 (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Thu, 24 Sep 2009 21:43:58 +0200
Received: from merkur.ravnborg.org (x1-6-00-1e-2a-84-ae-3e.k225.webspeed.dk [80.163.61.94])
	by pfepa.post.tele.dk (Postfix) with ESMTP id 6BD93A5005D;
	Thu, 24 Sep 2009 21:43:48 +0200 (CEST)
Date:	Thu, 24 Sep 2009 21:43:48 +0200
From:	Sam Ravnborg <sam@ravnborg.org>
To:	Manuel Lauss <manuel.lauss@googlemail.com>
Cc:	Linux-MIPS <linux-mips@linux-mips.org>,
	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
Subject: Re: MIPS: Alchemy build broken in latest linus-git [with patch]
Message-ID: <20090924194348.GA1922@merkur.ravnborg.org>
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com> <20090924091539.GA929@merkur.ravnborg.org> <f861ec6f0909240224m4b5dcbd9hc835409e7a66102d@mail.gmail.com> <f861ec6f0909240241x5c5858d4g4d44b40107021bb6@mail.gmail.com> <4ABB6189.5010909@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <4ABB6189.5010909@gmail.com>
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <sam@ravnborg.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24095
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: sam@ravnborg.org
Precedence: bulk
X-list: linux-mips

> 
> From: Manuel Lauss <manuel.lauss@gmail.com>
> Subject: [PATCH] MIPS: fix build of vmlinux.lds
> 
> Commit 51b563fc93c8cb5bff1d67a0a71c374e4a4ea049 removed a few
> CPPFLAGS with vital include paths necessary to build vmlinux.lds
> on MIPS, and moved the calculation of the 'jiffies' symbol
> directly to vmlinux.lds.S but forgot to change make ifdef/... to
> cpp macros.
> 
> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>

Thanks for providing a patch!

The assignment of CPPFLAGS was supposed to be
in arch/mips/kernel/MAkefile.

I fixed this up.
Please test this patch - I will await testing
feedback before I submit to Linus.

	Sam


From bfc4d46080e26f5806f0aa59e95fd5d284ca1fd4 Mon Sep 17 00:00:00 2001
From: Manuel Lauss <manuel.lauss@gmail.com>
Date: Thu, 24 Sep 2009 21:44:24 +0200
Subject: [PATCH] mips: fix build of vmlinux.lds

Commit 51b563fc93c8cb5bff1d67a0a71c374e4a4ea049 ("arm, cris, mips,
sparc, powerpc, um, xtensa: fix build with bash 4.0") removed a few
CPPFLAGS with vital include paths necessary to build vmlinux.lds
on MIPS, and moved the calculation of the 'jiffies' symbol
directly to vmlinux.lds.S but forgot to change make ifdef/... to
cpp macros.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
[sam: moved assignment of CPPFLAGS arch/mips/kernel/Makefile]
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/mips/kernel/Makefile      |    2 ++
 arch/mips/kernel/vmlinux.lds.S |   12 ++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index e961221..eecd2a9 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -2,6 +2,8 @@
 # Makefile for the Linux/MIPS kernel.
 #
 
+CPPFLAGS_vmlinux.lds := $(KBUILD_CFLAGS)
+
 extra-y		:= head.o init_task.o vmlinux.lds
 
 obj-y		+= cpu-probe.o branch.o entry.o genex.o irq.o process.o \
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 9bf0e3d..162b299 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -11,15 +11,15 @@ PHDRS {
 	note PT_NOTE FLAGS(4);	/* R__ */
 }
 
-ifdef CONFIG_32BIT
-	ifdef CONFIG_CPU_LITTLE_ENDIAN
+#ifdef CONFIG_32BIT
+	#ifdef CONFIG_CPU_LITTLE_ENDIAN
 		jiffies  = jiffies_64;
-	else
+	#else
 		jiffies  = jiffies_64 + 4;
-	endif
-else
+	#endif
+#else
 	jiffies  = jiffies_64;
-endif
+#endif
 
 SECTIONS
 {
-- 
1.6.2.5


From mason@upwardaccess.com Fri Sep 25 00:27:31 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 25 Sep 2009 00:27:37 +0200 (CEST)
Received: from mail.upwardaccess.com ([70.89.180.121]:3273 "EHLO
	upwardaccess.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S2097344AbZIXW1b (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 25 Sep 2009 00:27:31 +0200
Received: from hawaii.upwardaccess.com (unverified [10.61.7.126]) 
	by upwardaccess.com (SurgeMail 3.9e) with ESMTP id 926945-1847469 
	for <linux-mips@linux-mips.org>; Thu, 24 Sep 2009 15:27:19 -0700
Received: by hawaii.upwardaccess.com (Postfix, from userid 500)
	id 6E11835425C; Thu, 24 Sep 2009 15:27:19 -0700 (PDT)
Date:	Thu, 24 Sep 2009 15:27:19 -0700
From:	Mark Mason <mmason@upwardaccess.com>
To:	linux-mips@linux-mips.org
Subject: linux-mips.git broken compiling for smp targets
Message-ID: <20090924222719.GA18095@upwardaccess.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.17 (2007-11-01)
X-Originating-IP: 10.61.7.126
X-Authenticated-User: mmason@upwardaccess.com 
Return-Path: <mason@upwardaccess.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24096
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mmason@upwardaccess.com
Precedence: bulk
X-list: linux-mips

Hello all,

I'm getting the following compiling for my bcm1480:

  CALL    scripts/checksyscalls.sh
  CHK     include/linux/compile.h
  CC      arch/mips/kernel/smp.o
arch/mips/kernel/smp.c: In function `arch_send_call_function_single_ipi':
arch/mips/kernel/smp.c:140: error: incompatible type for argument 1 of indirect function call
make[1]: *** [arch/mips/kernel/smp.o] Error 1
make: *** [arch/mips/kernel] Error 2

Anyone else running into this?

Thanks,
Mark

From dmitri.vorobiev@gmail.com Fri Sep 25 10:48:32 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 25 Sep 2009 10:48:40 +0200 (CEST)
Received: from mail-fx0-f221.google.com ([209.85.220.221]:53062 "EHLO
	mail-fx0-f221.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492443AbZIYIsc (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 25 Sep 2009 10:48:32 +0200
Received: by fxm21 with SMTP id 21so1925361fxm.33
        for <linux-mips@linux-mips.org>; Fri, 25 Sep 2009 01:48:25 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type;
        bh=PT+2yIWNizmFQajJi9tScOPfnvCofWCqgKg1NxHTsow=;
        b=WHngcsaZxkI2M5TYPIeexh3XBOWHqBHmk7hZPsnRf6VV4xE/0rpybp8Idcb58Q49fK
         JnUHaXXKePdSwOp08KlnIdg/VUCt06pk2EHCYfIXyyUQQ+F/KKZ7lpQqj2lZTRtICVXb
         nChqH/yqbuSIsFtJQq27KYUNXB73NpTDQF5gI=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        b=DCpADlgIXCZG+1HJuV2QXOv50xh79KOoufyKCviS1dYWfnhvlhh9Qbj0ifgjbv365a
         PnfaTST3scxrhudlfcOjpZZGzsSdS8daszkOJAyD7Kuke4W8lfCHRaKBgpTHwGW5uoeN
         SymW23W+qo5yipmZ1L+fFpLK25dmPaRbqedPA=
MIME-Version: 1.0
Received: by 10.223.144.67 with SMTP id y3mr1690551fau.40.1253868505765; Fri, 
	25 Sep 2009 01:48:25 -0700 (PDT)
In-Reply-To: <20090924194348.GA1922@merkur.ravnborg.org>
References: <f861ec6f0909232344s72af6bax5bd77f1a5be45b4f@mail.gmail.com>
	 <20090924091539.GA929@merkur.ravnborg.org>
	 <f861ec6f0909240224m4b5dcbd9hc835409e7a66102d@mail.gmail.com>
	 <f861ec6f0909240241x5c5858d4g4d44b40107021bb6@mail.gmail.com>
	 <4ABB6189.5010909@gmail.com>
	 <20090924194348.GA1922@merkur.ravnborg.org>
Date:	Fri, 25 Sep 2009 11:48:25 +0300
Message-ID: <90edad820909250148s41deacb0x89a6aab14a10170c@mail.gmail.com>
Subject: Re: MIPS: Alchemy build broken in latest linus-git [with patch]
From:	Dmitri Vorobiev <dmitri.vorobiev@gmail.com>
To:	Sam Ravnborg <sam@ravnborg.org>
Cc:	Manuel Lauss <manuel.lauss@googlemail.com>,
	Linux-MIPS <linux-mips@linux-mips.org>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <dmitri.vorobiev@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24097
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: dmitri.vorobiev@gmail.com
Precedence: bulk
X-list: linux-mips

On Thu, Sep 24, 2009 at 10:43 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
>>
>> From: Manuel Lauss <manuel.lauss@gmail.com>
>> Subject: [PATCH] MIPS: fix build of vmlinux.lds
>>
>> Commit 51b563fc93c8cb5bff1d67a0a71c374e4a4ea049 removed a few
>> CPPFLAGS with vital include paths necessary to build vmlinux.lds
>> on MIPS, and moved the calculation of the 'jiffies' symbol
>> directly to vmlinux.lds.S but forgot to change make ifdef/... to
>> cpp macros.
>>
>> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
>
> Thanks for providing a patch!
>
> The assignment of CPPFLAGS was supposed to be
> in arch/mips/kernel/MAkefile.
>
> I fixed this up.
> Please test this patch - I will await testing
> feedback before I submit to Linus.
>
>        Sam
>
>
> From bfc4d46080e26f5806f0aa59e95fd5d284ca1fd4 Mon Sep 17 00:00:00 2001
> From: Manuel Lauss <manuel.lauss@gmail.com>
> Date: Thu, 24 Sep 2009 21:44:24 +0200
> Subject: [PATCH] mips: fix build of vmlinux.lds
>
> Commit 51b563fc93c8cb5bff1d67a0a71c374e4a4ea049 ("arm, cris, mips,
> sparc, powerpc, um, xtensa: fix build with bash 4.0") removed a few
> CPPFLAGS with vital include paths necessary to build vmlinux.lds
> on MIPS, and moved the calculation of the 'jiffies' symbol
> directly to vmlinux.lds.S but forgot to change make ifdef/... to
> cpp macros.
>
> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
> [sam: moved assignment of CPPFLAGS arch/mips/kernel/Makefile]
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Acked-by: Dmitri Vorobiev <dmitri.vorobiev@movial.com>

From anemo@mba.ocn.ne.jp Fri Sep 25 15:57:42 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 25 Sep 2009 15:57:48 +0200 (CEST)
Received: from mba.ocn.ne.jp ([122.28.14.163]:56462 "HELO smtp.mba.ocn.ne.jp"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with SMTP
	id S1492751AbZIYN5m (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 25 Sep 2009 15:57:42 +0200
Received: from localhost (p8215-ipad310funabasi.chiba.ocn.ne.jp [123.217.210.215])
	by smtp.mba.ocn.ne.jp (Postfix) with ESMTP
	id 28CF36F28; Fri, 25 Sep 2009 22:57:32 +0900 (JST)
Date:	Fri, 25 Sep 2009 22:57:33 +0900 (JST)
Message-Id: <20090925.225733.193685723.anemo@mba.ocn.ne.jp>
To:	sshtylyov@ru.mvista.com
Cc:	ralf.roesch@rw-gmbh.de, linux-mips@linux-mips.org, julia@diku.dk
Subject: Re: [PATCH] MIPS: TXx9: Fix error handling / Fix for noenexisting
 gpio_remove.
From:	Atsushi Nemoto <anemo@mba.ocn.ne.jp>
In-Reply-To: <4AB3B3B9.1040804@ru.mvista.com>
References: <1253080880-11123-1-git-send-email-ralf.roesch@rw-gmbh.de>
	<20090917.225259.173376281.anemo@mba.ocn.ne.jp>
	<4AB3B3B9.1040804@ru.mvista.com>
X-Fingerprint: 6ACA 1623 39BD 9A94 9B1A  B746 CA77 FE94 2874 D52F
X-Pgp-Public-Key: http://wwwkeys.pgp.net/pks/lookup?op=get&search=0x2874D52F
X-Mailer: Mew version 5.2 on Emacs 22.2 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Return-Path: <anemo@mba.ocn.ne.jp>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24098
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: anemo@mba.ocn.ne.jp
Precedence: bulk
X-list: linux-mips

On Fri, 18 Sep 2009 20:22:17 +0400, Sergei Shtylyov <sshtylyov@ru.mvista.com> wrote:
> > I don't mind ether way, I just hope keeping bisectability on mainline.
> > Is it too late, (yet another) Ralf ?
> 
>     Well, Ralf B. has already committed Julia's broken patch at 9/14.

Then,
Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

---
Atsushi Nemoto

From mbizon@freebox.fr Fri Sep 25 16:54:46 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 25 Sep 2009 16:54:53 +0200 (CEST)
Received: from smtp6-g21.free.fr ([212.27.42.6]:42313 "EHLO smtp6-g21.free.fr"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493040AbZIYOyq (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 25 Sep 2009 16:54:46 +0200
Received: from smtp6-g21.free.fr (localhost [127.0.0.1])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 6EC06E08051;
	Fri, 25 Sep 2009 16:54:39 +0200 (CEST)
Received: from [213.228.1.107] (sakura.staff.proxad.net [213.228.1.107])
	by smtp6-g21.free.fr (Postfix) with ESMTP id F29C3E08101;
	Fri, 25 Sep 2009 16:54:36 +0200 (CEST)
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
From:	Maxime Bizon <mbizon@freebox.fr>
Reply-To: mbizon@freebox.fr
To:	Wolfram Sang <w.sang@pengutronix.de>
Cc:	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-pcmcia@lists.infradead.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
In-Reply-To: <1253709915.1627.397.camel@sakura.staff.proxad.net>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>
	 <20090923123143.GB3131@pengutronix.de>
	 <1253709915.1627.397.camel@sakura.staff.proxad.net>
Content-Type: text/plain
Organization: Freebox
Date:	Fri, 25 Sep 2009 16:54:36 +0200
Message-Id: <1253890476.1627.468.camel@sakura.staff.proxad.net>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 7bit
Return-Path: <mbizon@freebox.fr>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24099
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mbizon@freebox.fr
Precedence: bulk
X-list: linux-mips


On Wed, 2009-09-23 at 14:45 +0200, Maxime Bizon wrote:

> On Wed, 2009-09-23 at 14:31 +0200, Wolfram Sang wrote:
> 
> > Okay, here is a fast review. If you fix the mentioned points (or give me good
> > reasons why not ;)), then you might add my
> > 
> > Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
> > 
> > I am fine with Ralf picking this up.
> 
> Agreed on all your points and will fix them. Thanks.
> 
> Ralf, please give me a couple of days to fix this and I will send you an
> updated patch.

Here it is:

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>

diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
index cff75de..c146d1e 100644
--- a/arch/mips/bcm63xx/Makefile
+++ b/arch/mips/bcm63xx/Makefile
@@ -1,5 +1,5 @@
 obj-y		+= clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
-		   dev-dsp.o dev-enet.o dev-uart.o
+		   dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
 obj-y		+= boards/
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index d3fdf27..e3e6205 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -24,6 +24,7 @@
 #include <bcm63xx_dev_pci.h>
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_dsp.h>
+#include <bcm63xx_dev_pcmcia.h>
 #include <bcm63xx_dev_uart.h>
 #include <board_bcm963xx.h>
 
@@ -796,6 +797,9 @@ int __init board_register_devices(void)
 
 	bcm63xx_uart_register();
 
+	if (board.has_pccard)
+		bcm63xx_pcmcia_register();
+
 	if (board.has_enet0 &&
 	    !board_get_mac_address(board.enet0.mac_addr))
 		bcm63xx_enet_register(0, &board.enet0);
diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c
new file mode 100644
index 0000000..4fb42ac
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-pcmcia.c
@@ -0,0 +1,135 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <asm/bootinfo.h>
+#include <linux/platform_device.h>
+#include <bcm63xx_cs.h>
+#include <bcm63xx_cpu.h>
+#include <bcm63xx_dev_pcmcia.h>
+#include <bcm63xx_io.h>
+#include <bcm63xx_regs.h>
+
+static struct resource pcmcia_resources[] = {
+	/* pcmcia registers */
+	{
+		.start		= -1, /* filled at runtime */
+		.end		= -1, /* filled at runtime */
+		.flags		= IORESOURCE_MEM,
+	},
+
+	/* pcmcia memory zone resources */
+	{
+		.start		= BCM_PCMCIA_COMMON_BASE_PA,
+		.end		= BCM_PCMCIA_COMMON_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= BCM_PCMCIA_ATTR_BASE_PA,
+		.end		= BCM_PCMCIA_ATTR_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= BCM_PCMCIA_IO_BASE_PA,
+		.end		= BCM_PCMCIA_IO_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+
+	/* PCMCIA irq */
+	{
+		.start		= -1, /* filled at runtime */
+		.flags		= IORESOURCE_IRQ,
+	},
+
+	/* declare PCMCIA IO resource also */
+	{
+		.start		= BCM_PCMCIA_IO_BASE_PA,
+		.end		= BCM_PCMCIA_IO_END_PA,
+		.flags		= IORESOURCE_IO,
+	},
+};
+
+static struct bcm63xx_pcmcia_platform_data pd;
+
+static struct platform_device bcm63xx_pcmcia_device = {
+	.name		= "bcm63xx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(pcmcia_resources),
+	.resource	= pcmcia_resources,
+	.dev		= {
+		.platform_data = &pd,
+	},
+};
+
+static int __init config_pcmcia_cs(unsigned int cs,
+				   u32 base, unsigned int size)
+{
+	int ret;
+
+	ret = bcm63xx_set_cs_status(cs, 0);
+	if (!ret)
+		ret = bcm63xx_set_cs_base(cs, base, size);
+	if (!ret)
+		ret = bcm63xx_set_cs_status(cs, 1);
+	return ret;
+}
+
+static const __initdata unsigned int pcmcia_cs[3][3] = {
+	/* cs, base address, size */
+	{ MPI_CS_PCMCIA_COMMON, BCM_PCMCIA_COMMON_BASE_PA,
+	  BCM_PCMCIA_COMMON_SIZE },
+
+	{ MPI_CS_PCMCIA_ATTR, BCM_PCMCIA_ATTR_BASE_PA,
+	  BCM_PCMCIA_ATTR_SIZE },
+
+	{ MPI_CS_PCMCIA_IO, BCM_PCMCIA_IO_BASE_PA,
+	  BCM_PCMCIA_IO_SIZE },
+};
+
+int __init bcm63xx_pcmcia_register(void)
+{
+	int ret, i;
+
+	if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
+		return 0;
+
+	/* use correct pcmcia ready gpio depending on processor */
+	switch (bcm63xx_get_cpu_id()) {
+	case BCM6348_CPU_ID:
+		pd.ready_gpio = 22;
+		break;
+
+	case BCM6358_CPU_ID:
+		pd.ready_gpio = 18;
+		break;
+
+	default:
+		return -ENODEV;
+	}
+
+	pcmcia_resources[0].start = bcm63xx_regset_address(RSET_PCMCIA);
+	pcmcia_resources[0].end = pcmcia_resources[0].start +
+		RSET_PCMCIA_SIZE - 1;
+	pcmcia_resources[4].start = bcm63xx_get_irq_number(IRQ_PCMCIA);
+
+	/* configure pcmcia chip selects */
+	for (i = 0; i < 3; i++) {
+		ret = config_pcmcia_cs(pcmcia_cs[i][0],
+				       pcmcia_cs[i][1],
+				       pcmcia_cs[i][2]);
+		if (ret)
+			goto out_err;
+	}
+
+	return platform_device_register(&bcm63xx_pcmcia_device);
+
+out_err:
+	printk(KERN_ERR "unable to set pcmcia chip select\n");
+	return ret;
+}
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
new file mode 100644
index 0000000..2beb396
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
@@ -0,0 +1,13 @@
+#ifndef BCM63XX_DEV_PCMCIA_H_
+#define BCM63XX_DEV_PCMCIA_H_
+
+/*
+ * PCMCIA driver platform data
+ */
+struct bcm63xx_pcmcia_platform_data {
+	unsigned int ready_gpio;
+};
+
+int bcm63xx_pcmcia_register(void);
+
+#endif /* BCM63XX_DEV_PCMCIA_H_ */
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index fbf965b..17f38a7 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -192,6 +192,10 @@ config PCMCIA_AU1X00
 	tristate "Au1x00 pcmcia support"
 	depends on SOC_AU1X00 && PCMCIA
 
+config PCMCIA_BCM63XX
+	tristate "bcm63xx pcmcia support"
+	depends on BCM63XX && PCMCIA
+
 config PCMCIA_SA1100
 	tristate "SA1100 support"
 	depends on ARM && ARCH_SA1100 && PCMCIA
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 047394d..1ee57f0 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_PCMCIA_SA1111)			+= sa11xx_core.o sa1111_cs.o
 obj-$(CONFIG_M32R_PCC)				+= m32r_pcc.o
 obj-$(CONFIG_M32R_CFC)				+= m32r_cfc.o
 obj-$(CONFIG_PCMCIA_AU1X00)			+= au1x00_ss.o
+obj-$(CONFIG_PCMCIA_BCM63XX)			+= bcm63xx_pcmcia.o
 obj-$(CONFIG_PCMCIA_VRC4171)			+= vrc4171_card.o
 obj-$(CONFIG_PCMCIA_VRC4173)			+= vrc4173_cardu.o
 obj-$(CONFIG_OMAP_CF)				+= omap_cf.o
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
new file mode 100644
index 0000000..ef186c6
--- /dev/null
+++ b/drivers/pcmcia/bcm63xx_pcmcia.c
@@ -0,0 +1,527 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/timer.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/gpio.h>
+
+#include <bcm63xx_regs.h>
+#include <bcm63xx_io.h>
+#include "bcm63xx_pcmcia.h"
+
+#define PFX	"bcm63xx_pcmcia: "
+
+#ifdef CONFIG_CARDBUS
+/* if cardbus is used, platform device needs reference to actual pci
+ * device */
+static struct pci_dev *bcm63xx_cb_dev;
+#endif
+
+/*
+ * read/write helper for pcmcia regs
+ */
+static inline u32 pcmcia_readl(struct bcm63xx_pcmcia_socket *skt, u32 off)
+{
+	return bcm_readl(skt->base + off);
+}
+
+static inline void pcmcia_writel(struct bcm63xx_pcmcia_socket *skt,
+				 u32 val, u32 off)
+{
+	bcm_writel(val, skt->base + off);
+}
+
+/*
+ * This callback should (re-)initialise the socket, turn on status
+ * interrupts and PCMCIA bus, and wait for power to stabilise so that
+ * the card status signals report correctly.
+ *
+ * Hardware cannot do that.
+ */
+static int bcm63xx_pcmcia_sock_init(struct pcmcia_socket *sock)
+{
+	return 0;
+}
+
+/*
+ * This callback should remove power on the socket, disable IRQs from
+ * the card, turn off status interrupts, and disable the PCMCIA bus.
+ *
+ * Hardware cannot do that.
+ */
+static int bcm63xx_pcmcia_suspend(struct pcmcia_socket *sock)
+{
+	return 0;
+}
+
+/*
+ * Implements the set_socket() operation for the in-kernel PCMCIA
+ * service (formerly SS_SetSocket in Card Services). We more or
+ * less punt all of this work and let the kernel handle the details
+ * of power configuration, reset, &c. We also record the value of
+ * `state' in order to regurgitate it to the PCMCIA core later.
+ */
+static int bcm63xx_pcmcia_set_socket(struct pcmcia_socket *sock,
+				     socket_state_t *state)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	unsigned long flags;
+	u32 val;
+
+	skt = sock->driver_data;
+
+	spin_lock_irqsave(&skt->lock, flags);
+
+	/* note: hardware cannot control socket power, so we will
+	 * always report SS_POWERON */
+
+	/* apply socket reset */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+	if (state->flags & SS_RESET)
+		val |= PCMCIA_C1_RESET_MASK;
+	else
+		val &= ~PCMCIA_C1_RESET_MASK;
+
+	/* reverse reset logic for cardbus card */
+	if (skt->card_detected && (skt->card_type & CARD_CARDBUS))
+		val ^= PCMCIA_C1_RESET_MASK;
+
+	pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+	/* keep requested state for event reporting */
+	skt->requested_state = *state;
+
+	spin_unlock_irqrestore(&skt->lock, flags);
+
+	return 0;
+}
+
+/*
+ * identity cardtype from VS[12] input, CD[12] input while only VS2 is
+ * floating, and CD[12] input while only VS1 is floating
+ */
+enum {
+	IN_VS1 = (1 << 0),
+	IN_VS2 = (1 << 1),
+	IN_CD1_VS2H = (1 << 2),
+	IN_CD2_VS2H = (1 << 3),
+	IN_CD1_VS1H = (1 << 4),
+	IN_CD2_VS1H = (1 << 5),
+};
+
+static const u8 vscd_to_cardtype[] = {
+
+	/* VS1 float, VS2 float */
+	[IN_VS1 | IN_VS2] = (CARD_PCCARD | CARD_5V),
+
+	/* VS1 grounded, VS2 float */
+	[IN_VS2] = (CARD_PCCARD | CARD_5V | CARD_3V),
+
+	/* VS1 grounded, VS2 grounded */
+	[0] = (CARD_PCCARD | CARD_5V | CARD_3V | CARD_XV),
+
+	/* VS1 tied to CD1, VS2 float */
+	[IN_VS1 | IN_VS2 | IN_CD1_VS1H] = (CARD_CARDBUS | CARD_3V),
+
+	/* VS1 grounded, VS2 tied to CD2 */
+	[IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V | CARD_XV),
+
+	/* VS1 tied to CD2, VS2 grounded */
+	[IN_VS1 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_3V | CARD_XV | CARD_YV),
+
+	/* VS1 float, VS2 grounded */
+	[IN_VS1] = (CARD_PCCARD | CARD_XV),
+
+	/* VS1 float, VS2 tied to CD2 */
+	[IN_VS1 | IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V),
+
+	/* VS1 float, VS2 tied to CD1 */
+	[IN_VS1 | IN_VS2 | IN_CD1_VS2H] = (CARD_CARDBUS | CARD_XV | CARD_YV),
+
+	/* VS1 tied to CD2, VS2 float */
+	[IN_VS1 | IN_VS2 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_YV),
+
+	/* VS2 grounded, VS1 is tied to CD1, CD2 is grounded */
+	[IN_VS1 | IN_CD1_VS1H] = 0, /* ignore cardbay */
+};
+
+/*
+ * poll hardware to check card insertion status
+ */
+static unsigned int __get_socket_status(struct bcm63xx_pcmcia_socket *skt)
+{
+	unsigned int stat;
+	u32 val;
+
+	stat = 0;
+
+	/* check CD for card presence */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+
+	if (!(val & PCMCIA_C1_CD1_MASK) && !(val & PCMCIA_C1_CD2_MASK))
+		stat |= SS_DETECT;
+
+	/* if new insertion, detect cardtype */
+	if ((stat & SS_DETECT) && !skt->card_detected) {
+		unsigned int stat = 0;
+
+		/* float VS1, float VS2 */
+		val |= PCMCIA_C1_VS1OE_MASK;
+		val |= PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read VS[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_VS1_MASK) ? IN_VS1 : 0;
+		stat |= (val & PCMCIA_C1_VS2_MASK) ? IN_VS2 : 0;
+
+		/* drive VS1 low, float VS2 */
+		val &= ~PCMCIA_C1_VS1OE_MASK;
+		val |= PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read CD[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS2H : 0;
+		stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS2H : 0;
+
+		/* float VS1, drive VS2 low */
+		val |= PCMCIA_C1_VS1OE_MASK;
+		val &= ~PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read CD[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS1H : 0;
+		stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS1H : 0;
+
+		/* guess cardtype from all this */
+		skt->card_type = vscd_to_cardtype[stat];
+		if (!skt->card_type)
+			dev_err(&skt->socket.dev, "unsupported card type\n");
+
+		/* drive both VS pin to 0 again */
+		val &= ~(PCMCIA_C1_VS1OE_MASK | PCMCIA_C1_VS2OE_MASK);
+
+		/* enable correct logic */
+		val &= ~(PCMCIA_C1_EN_PCMCIA_MASK | PCMCIA_C1_EN_CARDBUS_MASK);
+		if (skt->card_type & CARD_PCCARD)
+			val |= PCMCIA_C1_EN_PCMCIA_MASK;
+		else
+			val |= PCMCIA_C1_EN_CARDBUS_MASK;
+
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+	}
+	skt->card_detected = (stat & SS_DETECT) ? 1 : 0;
+
+	/* report card type/voltage */
+	if (skt->card_type & CARD_CARDBUS)
+		stat |= SS_CARDBUS;
+	if (skt->card_type & CARD_3V)
+		stat |= SS_3VCARD;
+	if (skt->card_type & CARD_XV)
+		stat |= SS_XVCARD;
+	stat |= SS_POWERON;
+
+	if (gpio_get_value(skt->pd->ready_gpio))
+		stat |= SS_READY;
+
+	return stat;
+}
+
+/*
+ * core request to get current socket status
+ */
+static int bcm63xx_pcmcia_get_status(struct pcmcia_socket *sock,
+				     unsigned int *status)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+
+	skt = sock->driver_data;
+
+	spin_lock_bh(&skt->lock);
+	*status = __get_socket_status(skt);
+	spin_unlock_bh(&skt->lock);
+
+	return 0;
+}
+
+/*
+ * socket polling timer callback
+ */
+static void bcm63xx_pcmcia_poll(unsigned long data)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	unsigned int stat, events;
+
+	skt = (struct bcm63xx_pcmcia_socket *)data;
+
+	spin_lock_bh(&skt->lock);
+
+	stat = __get_socket_status(skt);
+
+	/* keep only changed bits, and mask with required one from the
+	 * core */
+	events = (stat ^ skt->old_status) & skt->requested_state.csc_mask;
+	skt->old_status = stat;
+	spin_unlock_bh(&skt->lock);
+
+	if (events)
+		pcmcia_parse_events(&skt->socket, events);
+
+	mod_timer(&skt->timer,
+		  jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
+}
+
+static int bcm63xx_pcmcia_set_io_map(struct pcmcia_socket *sock,
+				     struct pccard_io_map *map)
+{
+	/* this doesn't seem to be called by pcmcia layer if static
+	 * mapping is used */
+	return 0;
+}
+
+static int bcm63xx_pcmcia_set_mem_map(struct pcmcia_socket *sock,
+				      struct pccard_mem_map *map)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct resource *res;
+
+	skt = sock->driver_data;
+	if (map->flags & MAP_ATTRIB)
+		res = skt->attr_res;
+	else
+		res = skt->common_res;
+
+	map->static_start = res->start + map->card_start;
+	return 0;
+}
+
+static struct pccard_operations bcm63xx_pcmcia_operations = {
+	.init			= bcm63xx_pcmcia_sock_init,
+	.suspend		= bcm63xx_pcmcia_suspend,
+	.get_status		= bcm63xx_pcmcia_get_status,
+	.set_socket		= bcm63xx_pcmcia_set_socket,
+	.set_io_map		= bcm63xx_pcmcia_set_io_map,
+	.set_mem_map		= bcm63xx_pcmcia_set_mem_map,
+};
+
+/*
+ * register pcmcia socket to core
+ */
+static int __devinit bcm63xx_drv_pcmcia_probe(struct platform_device *pdev)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct pcmcia_socket *sock;
+	struct resource *res, *irq_res;
+	unsigned int regmem_size = 0, iomem_size = 0;
+	u32 val;
+	int ret;
+
+	skt = kzalloc(sizeof(*skt), GFP_KERNEL);
+	if (!skt)
+		return -ENOMEM;
+	spin_lock_init(&skt->lock);
+	sock = &skt->socket;
+	sock->driver_data = skt;
+
+	/* make sure we have all resources we need */
+	skt->common_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	skt->attr_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	skt->pd = pdev->dev.platform_data;
+	if (!skt->common_res || !skt->attr_res || !irq_res || !skt->pd) {
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/* remap pcmcia registers */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	regmem_size = resource_size(res);
+	if (!request_mem_region(res->start, regmem_size, "bcm63xx_pcmcia")) {
+		ret = -EINVAL;
+		goto err;
+	}
+	skt->reg_res = res;
+
+	skt->base = ioremap(res->start, regmem_size);
+	if (!skt->base) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	/* remap io registers */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+	iomem_size = resource_size(res);
+	skt->io_base = ioremap(res->start, iomem_size);
+	if (!skt->io_base) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	/* resources are static */
+	sock->resource_ops = &pccard_static_ops;
+	sock->ops = &bcm63xx_pcmcia_operations;
+	sock->owner = THIS_MODULE;
+	sock->dev.parent = &pdev->dev;
+	sock->features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
+	sock->io_offset = (unsigned long)skt->io_base;
+	sock->pci_irq = irq_res->start;
+
+#ifdef CONFIG_CARDBUS
+	sock->cb_dev = bcm63xx_cb_dev;
+	if (bcm63xx_cb_dev)
+		sock->features |= SS_CAP_CARDBUS;
+#endif
+
+	/* assume common & attribute memory have the same size */
+	sock->map_size = resource_size(skt->common_res);
+
+	/* initialize polling timer */
+	setup_timer(&skt->timer, bcm63xx_pcmcia_poll, (unsigned long)skt);
+
+	/* initialize  pcmcia  control register,  drive  VS[12] to  0,
+	 * leave CB IDSEL to the old  value since it is set by the PCI
+	 * layer */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+	val &= PCMCIA_C1_CBIDSEL_MASK;
+	val |= PCMCIA_C1_EN_PCMCIA_GPIO_MASK;
+	pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+	/*
+	 * Hardware has only one set of timings registers, not one for
+	 * each memory access type, so we configure them for the
+	 * slowest one: attribute memory.
+	 */
+	val = PCMCIA_C2_DATA16_MASK;
+	val |= 10 << PCMCIA_C2_RWCOUNT_SHIFT;
+	val |= 6 << PCMCIA_C2_INACTIVE_SHIFT;
+	val |= 3 << PCMCIA_C2_SETUP_SHIFT;
+	val |= 3 << PCMCIA_C2_HOLD_SHIFT;
+	pcmcia_writel(skt, val, PCMCIA_C2_REG);
+
+	ret = pcmcia_register_socket(sock);
+	if (ret)
+		goto err;
+
+	/* start polling socket */
+	mod_timer(&skt->timer,
+		  jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
+
+	platform_set_drvdata(pdev, skt);
+	return 0;
+
+err:
+	if (skt->io_base)
+		iounmap(skt->io_base);
+	if (skt->base)
+		iounmap(skt->base);
+	if (skt->reg_res)
+		release_mem_region(skt->reg_res->start, regmem_size);
+	kfree(skt);
+	return ret;
+}
+
+static int __devexit bcm63xx_drv_pcmcia_remove(struct platform_device *pdev)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct resource *res;
+
+	skt = platform_get_drvdata(pdev);
+	del_timer_sync(&skt->timer);
+	iounmap(skt->base);
+	iounmap(skt->io_base);
+	res = skt->reg_res;
+	release_mem_region(res->start, resource_size(res));
+	kfree(skt);
+	return 0;
+}
+
+struct platform_driver bcm63xx_pcmcia_driver = {
+	.probe	= bcm63xx_drv_pcmcia_probe,
+	.remove	= __devexit_p(bcm63xx_drv_pcmcia_remove),
+	.driver	= {
+		.name	= "bcm63xx_pcmcia",
+		.owner  = THIS_MODULE,
+	},
+};
+
+#ifdef CONFIG_CARDBUS
+static int __devinit bcm63xx_cb_probe(struct pci_dev *dev,
+				      const struct pci_device_id *id)
+{
+	/* keep pci device */
+	bcm63xx_cb_dev = dev;
+	return platform_driver_register(&bcm63xx_pcmcia_driver);
+}
+
+static void __devexit bcm63xx_cb_exit(struct pci_dev *dev)
+{
+	platform_driver_unregister(&bcm63xx_pcmcia_driver);
+	bcm63xx_cb_dev = NULL;
+}
+
+static struct pci_device_id bcm63xx_cb_table[] = {
+	{
+		.vendor		= PCI_VENDOR_ID_BROADCOM,
+		.device		= PCI_ANY_ID,
+		.subvendor	= PCI_VENDOR_ID_BROADCOM,
+		.subdevice	= PCI_ANY_ID,
+		.class		= PCI_CLASS_BRIDGE_CARDBUS << 8,
+		.class_mask	= ~0,
+	},
+
+	{ },
+};
+
+MODULE_DEVICE_TABLE(pci, bcm63xx_cb_table);
+
+static struct pci_driver bcm63xx_cardbus_driver = {
+	.name		= "yenta_cardbus",
+	.id_table	= bcm63xx_cb_table,
+	.probe		= bcm63xx_cb_probe,
+	.remove		= __devexit_p(bcm63xx_cb_exit),
+};
+#endif
+
+/*
+ * if cardbus support is enabled, register our platform device after
+ * our fake cardbus bridge has been registered
+ */
+static int __init bcm63xx_pcmcia_init(void)
+{
+#ifdef CONFIG_CARDBUS
+	return pci_register_driver(&bcm63xx_cardbus_driver);
+#else
+	return platform_driver_register(&bcm63xx_pcmcia_driver);
+#endif
+}
+
+static void __exit bcm63xx_pcmcia_exit(void)
+{
+#ifdef CONFIG_CARDBUS
+	return pci_unregister_driver(&bcm63xx_cardbus_driver);
+#else
+	platform_driver_unregister(&bcm63xx_pcmcia_driver);
+#endif
+}
+
+module_init(bcm63xx_pcmcia_init);
+module_exit(bcm63xx_pcmcia_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm63xx Socket Controller");
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.h b/drivers/pcmcia/bcm63xx_pcmcia.h
new file mode 100644
index 0000000..85de866
--- /dev/null
+++ b/drivers/pcmcia/bcm63xx_pcmcia.h
@@ -0,0 +1,65 @@
+#ifndef BCM63XX_PCMCIA_H_
+#define BCM63XX_PCMCIA_H_
+
+#include <linux/types.h>
+#include <linux/timer.h>
+#include <pcmcia/ss.h>
+#include <bcm63xx_dev_pcmcia.h>
+
+/* socket polling rate in ms */
+#define BCM63XX_PCMCIA_POLL_RATE	500
+
+enum {
+	CARD_CARDBUS = (1 << 0),
+
+	CARD_PCCARD = (1 << 1),
+
+	CARD_5V = (1 << 2),
+
+	CARD_3V = (1 << 3),
+
+	CARD_XV = (1 << 4),
+
+	CARD_YV = (1 << 5),
+};
+
+struct bcm63xx_pcmcia_socket {
+	struct pcmcia_socket socket;
+
+	/* platform specific data */
+	struct bcm63xx_pcmcia_platform_data *pd;
+
+	/* all regs access are protected by this spinlock */
+	spinlock_t lock;
+
+	/* pcmcia registers resource */
+	struct resource *reg_res;
+
+	/* base remapped address of registers */
+	void __iomem *base;
+
+	/* whether a card is detected at the moment */
+	int card_detected;
+
+	/* type of detected card (mask of above enum) */
+	u8 card_type;
+
+	/* keep last socket status to implement event reporting */
+	unsigned int old_status;
+
+	/* backup of requested socket state */
+	socket_state_t requested_state;
+
+	/* timer used for socket status polling */
+	struct timer_list timer;
+
+	/* attribute/common memory resources */
+	struct resource *attr_res;
+	struct resource *common_res;
+	struct resource *io_res;
+
+	/* base address of io memory */
+	void __iomem *io_base;
+};
+
+#endif /* BCM63XX_PCMCIA_H_ */
-- 
1.6.0.4



-- 
Maxime



From sshtylyov@ru.mvista.com Fri Sep 25 18:35:50 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 25 Sep 2009 18:35:58 +0200 (CEST)
Received: from h155.mvista.com ([63.81.120.155]:11177 "EHLO imap.sh.mvista.com"
	rhost-flags-OK-FAIL-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1493121AbZIYQfu (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 25 Sep 2009 18:35:50 +0200
Received: from [192.168.11.189] (unknown [10.150.0.9])
	by imap.sh.mvista.com (Postfix) with ESMTP
	id 0374F3EC9; Fri, 25 Sep 2009 09:35:30 -0700 (PDT)
Message-ID: <4ABCF1E7.4010304@ru.mvista.com>
Date:	Fri, 25 Sep 2009 20:37:59 +0400
From:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Organization: MontaVista Software Inc.
User-Agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
X-Accept-Language: ru, en-us, en-gb
MIME-Version: 1.0
To:	mbizon@freebox.fr
Cc:	Wolfram Sang <w.sang@pengutronix.de>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-pcmcia@lists.infradead.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>	 <20090923123143.GB3131@pengutronix.de>	 <1253709915.1627.397.camel@sakura.staff.proxad.net> <1253890476.1627.468.camel@sakura.staff.proxad.net>
In-Reply-To: <1253890476.1627.468.camel@sakura.staff.proxad.net>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Return-Path: <sshtylyov@ru.mvista.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24100
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: sshtylyov@ru.mvista.com
Precedence: bulk
X-list: linux-mips

Hello.

Maxime Bizon wrote:

>>On Wed, 2009-09-23 at 14:31 +0200, Wolfram Sang wrote:

>>>Okay, here is a fast review. If you fix the mentioned points (or give me good
>>>reasons why not ;)), then you might add my

>>>Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>

>>>I am fine with Ralf picking this up.

>>Agreed on all your points and will fix them. Thanks.

>>Ralf, please give me a couple of days to fix this and I will send you an
>>updated patch.

> Here it is:

> Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
> Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>

[...]

> diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c
> new file mode 100644
> index 0000000..4fb42ac
> --- /dev/null
> +++ b/arch/mips/bcm63xx/dev-pcmcia.c
> @@ -0,0 +1,135 @@
> +/*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License.  See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
> + */
> +
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <asm/bootinfo.h>
> +#include <linux/platform_device.h>
> +#include <bcm63xx_cs.h>
> +#include <bcm63xx_cpu.h>
> +#include <bcm63xx_dev_pcmcia.h>
> +#include <bcm63xx_io.h>
> +#include <bcm63xx_regs.h>
> +
> +static struct resource pcmcia_resources[] = {
> +	/* pcmcia registers */
> +	{
> +		.start		= -1, /* filled at runtime */
> +		.end		= -1, /* filled at runtime */

    Then why initialize it?

[...]

> +		.flags		= IORESOURCE_MEM,
> +	},
> +static const __initdata unsigned int pcmcia_cs[3][3] = {
> +	/* cs, base address, size */

    Shouln't this be array of structures instead?

> +	{ MPI_CS_PCMCIA_COMMON, BCM_PCMCIA_COMMON_BASE_PA,
> +	  BCM_PCMCIA_COMMON_SIZE },
> +
> +	{ MPI_CS_PCMCIA_ATTR, BCM_PCMCIA_ATTR_BASE_PA,
> +	  BCM_PCMCIA_ATTR_SIZE },
> +
> +	{ MPI_CS_PCMCIA_IO, BCM_PCMCIA_IO_BASE_PA,
> +	  BCM_PCMCIA_IO_SIZE },
> +};
> +
> +int __init bcm63xx_pcmcia_register(void)
> +{
> +	int ret, i;
> +
> +	if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
> +		return 0;
> +
> +	/* use correct pcmcia ready gpio depending on processor */
> +	switch (bcm63xx_get_cpu_id()) {
> +	case BCM6348_CPU_ID:
> +		pd.ready_gpio = 22;
> +		break;
> +
> +	case BCM6358_CPU_ID:
> +		pd.ready_gpio = 18;
> +		break;

    Is this GPIO selection really chip- and not board-specific?

[...]

> diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
> new file mode 100644
> index 0000000..2beb396
> --- /dev/null
> +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
> @@ -0,0 +1,13 @@
> +#ifndef BCM63XX_DEV_PCMCIA_H_
> +#define BCM63XX_DEV_PCMCIA_H_
> +
> +/*
> + * PCMCIA driver platform data
> + */
> +struct bcm63xx_pcmcia_platform_data {
> +	unsigned int ready_gpio;
> +};
> +
> +int bcm63xx_pcmcia_register(void);
> +
> +#endif /* BCM63XX_DEV_PCMCIA_H_ */
> diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
> index fbf965b..17f38a7 100644
> --- a/drivers/pcmcia/Kconfig
> +++ b/drivers/pcmcia/Kconfig
> @@ -192,6 +192,10 @@ config PCMCIA_AU1X00
>  	tristate "Au1x00 pcmcia support"
>  	depends on SOC_AU1X00 && PCMCIA
>  
> +config PCMCIA_BCM63XX
> +	tristate "bcm63xx pcmcia support"
> +	depends on BCM63XX && PCMCIA
> +
>  config PCMCIA_SA1100
>  	tristate "SA1100 support"
>  	depends on ARM && ARCH_SA1100 && PCMCIA

    I don't think having both board code and the driver in a single patch is 
a good idea. I'd put the driver in its own separate patch...

> diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
> new file mode 100644
> index 0000000..ef186c6
> --- /dev/null
> +++ b/drivers/pcmcia/bcm63xx_pcmcia.c

[...]

> +static struct pci_device_id bcm63xx_cb_table[] = {
> +	{
> +		.vendor		= PCI_VENDOR_ID_BROADCOM,
> +		.device		= PCI_ANY_ID,

    Are you sure you can drive any Broadcom's bridge?

> +		.subvendor	= PCI_VENDOR_ID_BROADCOM,
> +		.subdevice	= PCI_ANY_ID,
> +		.class		= PCI_CLASS_BRIDGE_CARDBUS << 8,
> +		.class_mask	= ~0,
> +	},
> +
> +	{ },
> +};
> +
> +MODULE_DEVICE_TABLE(pci, bcm63xx_cb_table);
> +
> +static struct pci_driver bcm63xx_cardbus_driver = {
> +	.name		= "yenta_cardbus",

    Why it's called the same as 'yenta_cardbus_driver' and not 
"bcm63xx_cardbus"?

> +	.id_table	= bcm63xx_cb_table,
> +	.probe		= bcm63xx_cb_probe,
> +	.remove		= __devexit_p(bcm63xx_cb_exit),
> +};
> +#endif

[...]

> diff --git a/drivers/pcmcia/bcm63xx_pcmcia.h b/drivers/pcmcia/bcm63xx_pcmcia.h
> new file mode 100644
> index 0000000..85de866
> --- /dev/null
> +++ b/drivers/pcmcia/bcm63xx_pcmcia.h
> @@ -0,0 +1,65 @@
> +#ifndef BCM63XX_PCMCIA_H_
> +#define BCM63XX_PCMCIA_H_
> +
> +#include <linux/types.h>
> +#include <linux/timer.h>
> +#include <pcmcia/ss.h>
> +#include <bcm63xx_dev_pcmcia.h>
> +
> +/* socket polling rate in ms */
> +#define BCM63XX_PCMCIA_POLL_RATE	500
> +
> +enum {
> +	CARD_CARDBUS = (1 << 0),
> +
> +	CARD_PCCARD = (1 << 1),
> +
> +	CARD_5V = (1 << 2),
> +
> +	CARD_3V = (1 << 3),
> +
> +	CARD_XV = (1 << 4),
> +
> +	CARD_YV = (1 << 5),

    Why so many empty lines in between?

> +};

WBR, Sergei

From ralf@linux-mips.org Fri Sep 25 22:00:06 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 25 Sep 2009 22:00:15 +0200 (CEST)
Received: from h5.dl5rb.org.uk ([81.2.74.5]:41011 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493376AbZIYUAG (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Fri, 25 Sep 2009 22:00:06 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8PK1N5c030160;
	Fri, 25 Sep 2009 21:01:23 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8PK1MPl030159;
	Fri, 25 Sep 2009 21:01:22 +0100
Date:	Fri, 25 Sep 2009 21:01:22 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Mark Mason <mmason@upwardaccess.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: linux-mips.git broken compiling for smp targets
Message-ID: <20090925200122.GA25773@linux-mips.org>
References: <20090924222719.GA18095@upwardaccess.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20090924222719.GA18095@upwardaccess.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24101
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Thu, Sep 24, 2009 at 03:27:19PM -0700, Mark Mason wrote:

> I'm getting the following compiling for my bcm1480:
> 
>   CALL    scripts/checksyscalls.sh
>   CHK     include/linux/compile.h
>   CC      arch/mips/kernel/smp.o
> arch/mips/kernel/smp.c: In function `arch_send_call_function_single_ipi':
> arch/mips/kernel/smp.c:140: error: incompatible type for argument 1 of indirect function call
> make[1]: *** [arch/mips/kernel/smp.o] Error 1
> make: *** [arch/mips/kernel] Error 2
> 
> Anyone else running into this?

Yes, the code got Rusty.  I fixed that a few hours ago.

  Ralf

From KKylheku@zeugmasystems.com Sat Sep 26 01:06:47 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 26 Sep 2009 01:06:55 +0200 (CEST)
Received: from smtp.zeugmasystems.com ([70.79.96.174]:28828 "EHLO
	zeugmasystems.com" rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org
	with ESMTP id S1493455AbZIYXGr convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 26 Sep 2009 01:06:47 +0200
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 8BIT
Subject: Strange bad accesses in compat_exit_robust_list (2.6.26, n32 ABI).
Date:	Fri, 25 Sep 2009 16:06:37 -0700
Message-ID: <DDFD17CC94A9BD49A82147DDF7D545C501F7053D@exchange.ZeugmaSystems.local>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: Strange bad accesses in compat_exit_robust_list (2.6.26, n32 ABI).
Thread-Index: Aco+NNVJ+M75nEnzTBCs6uWEZaSwkw==
From:	"Kaz Kylheku" <KKylheku@zeugmasystems.com>
To:	<linux-mips@linux-mips.org>
Return-Path: <KKylheku@zeugmasystems.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24102
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: KKylheku@zeugmasystems.com
Precedence: bulk
X-list: linux-mips

Hi all,

We made a strange discovery some time ago. After adding some tracing
printk's
to the compat_exit_robust_list function for all the cases where fetching
the
robust entry fails, we discovered that, from time to time, it's being
reported
for processes that don't even use threads.

[16:20:13.406162] [futex] ("iptables")(pid=2543)
compat_exit_robust_list:unable to fetch robust entry.
uaddr=000000002aad37e0
[16:20:13.587506] device eth0 entered promiscuous mode
[16:20:13.883648] device eth1 entered promiscuous mode
[16:20:15.419965] [futex] ("ifconfig")(pid=2552)
compat_exit_robust_list:unable to fetch robust entry.
uaddr=00000000301d64f0
[16:20:15.497954] [futex] ("ifconfig")(pid=2574)
compat_exit_robust_list:unable to fetch robust entry.
uaddr=00000000301d64f0
[16:20:15.547260] [futex] ("iptables")(pid=2544)
compat_exit_robust_list:unable to fetch robust entry.
uaddr=000000002aad37e0
[16:20:16.002251] eth1: link available: 100base-FD
[00:32:56.240290] [futex] ("gzip")(pid=14397)
compat_exit_robust_list:unable to fetch the next robust entry.
uaddr=0000000000000000
[00:33:06.769279] [futex] ("gzip")(pid=14413)
compat_exit_robust_list:unable to fetch the next robust entry.
uaddr=0000000000000000
[00:33:11.964047] [futex] ("bzip2")(pid=14416)
compat_exit_robust_list:unable to fetch the next robust entry.
uaddr=0000000000000000
[16:41:50.024024] [futex] ("bzip2")(pid=32595)
compat_exit_robust_list:unable to fetch the next robust entry.
uaddr=0000000000000000

Sometimes the pointer to the robust list head is bad (``unable to fetch
robust
entry'').  Sometimes that pointer works, but walking the list is bad
(``unable
to fetch the next robust entry'').

These programs shouldn't even be invoking the compat_set_robust_list
system call, and don't even link to libpthread.so.


From KKylheku@zeugmasystems.com Sat Sep 26 01:11:36 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 26 Sep 2009 01:11:43 +0200 (CEST)
Received: from smtp.zeugmasystems.com ([70.79.96.174]:15783 "EHLO
	zeugmasystems.com" rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org
	with ESMTP id S1493511AbZIYXLg convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 26 Sep 2009 01:11:36 +0200
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 8BIT
Subject: RE: Strange bad accesses in compat_exit_robust_list (2.6.26, n32 ABI).
Date:	Fri, 25 Sep 2009 16:11:30 -0700
Message-ID: <DDFD17CC94A9BD49A82147DDF7D545C501F7053F@exchange.ZeugmaSystems.local>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: Strange bad accesses in compat_exit_robust_list (2.6.26, n32 ABI).
Thread-Index: Aco+NNVJ+M75nEnzTBCs6uWEZaSwkwAAFr7Q
From:	"Kaz Kylheku" <KKylheku@zeugmasystems.com>
To:	<linux-mips@linux-mips.org>
Return-Path: <KKylheku@zeugmasystems.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24103
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: KKylheku@zeugmasystems.com
Precedence: bulk
X-list: linux-mips

Kaz Kylheku wrote:
> Hi all,
> 
> We made a strange discovery some time ago. After adding some tracing
> printk's to the compat_exit_robust_list function for all the cases
> where fetching the
> robust entry fails, we discovered that, from time to time,
> it's being reported
> for processes that don't even use threads.

Hmm. Maybe a syscall is being misrouted? Perhaps user space is calling
some function that ends up routed to the compat_set_robust_list
entry in the syscall table, causing a junk value to be installed
as the robust list. Hmm. But robust mutexes work on our platform;
so glibc does reach the right syscalls when they are intended.

From KKylheku@zeugmasystems.com Sat Sep 26 03:05:41 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 26 Sep 2009 03:05:48 +0200 (CEST)
Received: from smtp.zeugmasystems.com ([70.79.96.174]:32713 "EHLO
	zeugmasystems.com" rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org
	with ESMTP id S1493171AbZIZBFl convert rfc822-to-8bit (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 26 Sep 2009 03:05:41 +0200
X-MimeOLE: Produced By Microsoft Exchange V6.5
Content-class: urn:content-classes:message
MIME-Version: 1.0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 8BIT
Subject: RE: Strange bad accesses in compat_exit_robust_list (2.6.26, n32 ABI).
Date:	Fri, 25 Sep 2009 18:05:30 -0700
Message-ID: <DDFD17CC94A9BD49A82147DDF7D545C501F7056C@exchange.ZeugmaSystems.local>
In-Reply-To: <DDFD17CC94A9BD49A82147DDF7D545C501F7053F@exchange.ZeugmaSystems.local>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: Strange bad accesses in compat_exit_robust_list (2.6.26, n32 ABI).
Thread-Index: Aco+NNVJ+M75nEnzTBCs6uWEZaSwkwAAFr7QAAPRybA=
From:	"Kaz Kylheku" <KKylheku@zeugmasystems.com>
To:	"Kaz Kylheku" <KKylheku@zeugmasystems.com>,
	<linux-mips@linux-mips.org>
Return-Path: <KKylheku@zeugmasystems.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24104
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: KKylheku@zeugmasystems.com
Precedence: bulk
X-list: linux-mips

linux-mips-bounce@linux-mips.org wrote:
> Kaz Kylheku wrote:
>> Hi all,
>> 
>> We made a strange discovery some time ago. After adding some tracing
>> printk's to the compat_exit_robust_list function for all the cases
>> where fetching the robust entry fails, we discovered that, from time
>> to time, 
>> it's being reported
>> for processes that don't even use threads.
> 
> Hmm. Maybe a syscall is being misrouted? Perhaps user space is calling
> some function that ends up routed to the compat_set_robust_list
> entry in the syscall table, causing a junk value to be installed
> as the robust list. Hmm. But robust mutexes work on our platform;
> so glibc does reach the right syscalls when they are intended.

I have another hypothesis.

The execve syscall does not appear to deal with the robust
mutex list at all. A process can set up these robust pointers
and then call execv. It gets a new memory map, but the
flush_old_exec function does not clean up the robust list pointer,
which refers to a virtual address in the old address space.

I just confirmed it in fact.

I have a 100% repro for this problem when I do a 
``tar xjf file.tar.bz2'' on my board.

The tar process calls compat_sys_set_robust_list, and then
the bzip2 process encounters the problem in the compat_exit_robust_list.

But the PID is the same!  The tar process has exec-ed
bzip2, and the bzip2 image inherited bad robust pointers from
the time when it was tar.




From alex@digriz.org.uk Sat Sep 26 14:33:21 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 26 Sep 2009 14:33:29 +0200 (CEST)
Received: from chipmunk.wormnet.eu ([195.195.131.226]:52288 "EHLO
	chipmunk.wormnet.eu" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1492559AbZIZMdV (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sat, 26 Sep 2009 14:33:21 +0200
Received: by chipmunk.wormnet.eu (Postfix, from userid 1000)
	id 356108063D; Sat, 26 Sep 2009 13:33:20 +0100 (BST)
Date:	Sat, 26 Sep 2009 13:33:20 +0100
From:	Alexander Clouter <alex@digriz.org.uk>
To:	Wu Zhangjin <wuzhangjin@gmail.com>
Cc:	linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH -v1] MIPS: add support for gzip/bzip2/lzma compressed
	kernel images
Message-ID: <20090926123320.GJ6085@chipmunk>
References: <1249894154-10982-1-git-send-email-wuzhangjin@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1249894154-10982-1-git-send-email-wuzhangjin@gmail.com>
Organization: diGriz
X-URL:	http://www.digriz.org.uk/
X-JabberID: alex@digriz.org.uk
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <alex@digriz.org.uk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24105
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: alex@digriz.org.uk
Precedence: bulk
X-list: linux-mips

Hi,

* Wu Zhangjin <wuzhangjin@gmail.com> [2009-08-10 16:49:14+0800]:
>
> This patch will help to generate smaller kernel images for linux-MIPS,
> 
> Here is the effect when using lzma:
> 
> $ ls -sh vmlinux
> 7.1M vmlinux
> $ ls -sh arch/mips/boot/compressed/vmlinuz
> 1.5M arch/mips/boot/compressed/vmlinuz
> 
> Have tested the 32bit kernel on Qemu/Malta and 64bit kernel on FuLoong
> Mini PC. both of them work well.
> 
> and this revision incorporates the feedback from Alexander Clouter
> <alex@digriz.org.uk>, he helped to test it on AR7[1] based Linksys
> WAG54Gv2 and gave good suggestion on board-independence.
> 
> NOTE: this should work for the other MIPS-based machines, but I have
> used the command bc in the Makefile to calculate the load address of the
> compressed kernel. I'm not sure this is suitable.  perhaps I need to
> rewrite this part in C program or somebody help to simplify the current
> implementation.
> 
Finally Fleabay'ed a replacement WAG54Gv2 to replace the one I 
bricked to try this new patch.

Works perfectly....I finally can cooked more or less vanilla kernels on 
my board now :)

> Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
>
Tested-by: Alexander Clouter <alex@digriz.org.uk>

Cheers

-- 
Alexander Clouter
.sigmonster says: My computer can beat up your computer.
                  		-- Karl Lehenbauer

From weiyi.huang@gmail.com Sun Sep 27 05:15:09 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 27 Sep 2009 05:15:16 +0200 (CEST)
Received: from mail-pz0-f177.google.com ([209.85.222.177]:54353 "EHLO
	mail-pz0-f177.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1491886AbZI0DPI (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Sun, 27 Sep 2009 05:15:08 +0200
Received: by pzk7 with SMTP id 7so1607109pzk.21
        for <multiple recipients>; Sat, 26 Sep 2009 20:14:59 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=rOYpzImAnvLtpltCXCumCh0LuUcMSZO6DU8Myhj1R60=;
        b=n46unOCi6vrsuAJKM8Oe7h7vUfOFWYpWW9S/E15vF5LAKj+eptu4DkSnfewwJWfGkZ
         MR9IJ72A7Ch65jE+/moXOp1EE0/9oXIYbiadNTdjF3904SPLZKunKB5wT5s7LNjRjv/I
         mQN0z4wOXh1cro/Y6hUBFpC7uzJsjpKdvCc2Y=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=rPgLtLIVXFn8ObZW4bMmK+gWIuLeZ5JpreE1+7skua9VxnOpJrrCJXVPGThawcYd5j
         UgNO8BkSUg3MG076wUDhDVS5F5WSijp8dfpZ+lzhHtMmOVPR9Ks3QxaABRbqGB2kTmM3
         sOxrzLjPnY2/h7ziELsrG3KLiRbogb6cHWwXM=
Received: by 10.115.103.23 with SMTP id f23mr2879321wam.226.1254021299331;
        Sat, 26 Sep 2009 20:14:59 -0700 (PDT)
Received: from localhost.localdomain ([58.212.85.233])
        by mx.google.com with ESMTPS id 23sm1455830pzk.12.2009.09.26.20.14.55
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Sat, 26 Sep 2009 20:14:57 -0700 (PDT)
From:	Huang Weiyi <weiyi.huang@gmail.com>
To:	ralf@linux-mips.org
Cc:	linux-mips@linux-mips.org, Huang Weiyi <weiyi.huang@gmail.com>
Subject: [PATCH 1/5] MIPS: remove duplicated #include
Date:	Sun, 27 Sep 2009 11:14:54 +0800
Message-Id: <1254021294-3832-1-git-send-email-weiyi.huang@gmail.com>
X-Mailer: git-send-email 1.6.1.2
Return-Path: <weiyi.huang@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24106
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: weiyi.huang@gmail.com
Precedence: bulk
X-list: linux-mips

Remove duplicated #include('s) in
  arch/mips/kernel/smp.c

Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>
---
 arch/mips/kernel/smp.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 4eb106c..09e8dcf 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -32,7 +32,6 @@
 #include <linux/cpumask.h>
 #include <linux/cpu.h>
 #include <linux/err.h>
-#include <linux/smp.h>
 
 #include <asm/atomic.h>
 #include <asm/cpu.h>
-- 
1.6.1.3


From ralf@linux-mips.org Mon Sep 28 12:46:58 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 12:47:05 +0200 (CEST)
Received: from p549F514B.dip.t-dialin.net ([84.159.81.75]:52722 "EHLO
	h5.dl5rb.org.uk" rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org
	with ESMTP id S1492439AbZI1Kq6 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 28 Sep 2009 12:46:58 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8SAlXOJ010773;
	Mon, 28 Sep 2009 11:47:33 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8SAlS5t010771;
	Mon, 28 Sep 2009 11:47:28 +0100
Date:	Mon, 28 Sep 2009 11:47:28 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Huang Weiyi <weiyi.huang@gmail.com>
Cc:	linux-mips@linux-mips.org
Subject: Re: [PATCH 1/5] MIPS: remove duplicated #include
Message-ID: <20090928104728.GA3571@linux-mips.org>
References: <1254021294-3832-1-git-send-email-weiyi.huang@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1254021294-3832-1-git-send-email-weiyi.huang@gmail.com>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24107
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Sun, Sep 27, 2009 at 11:14:54AM +0800, Huang Weiyi wrote:

> Remove duplicated #include('s) in
>   arch/mips/kernel/smp.c
> 
> Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>

This is the 3rd identical patch I've received ...

Sorry & thanks anyway!

  Ralf

From mbizon@freebox.fr Mon Sep 28 14:50:17 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 14:50:24 +0200 (CEST)
Received: from smtp6-g21.free.fr ([212.27.42.6]:44032 "EHLO smtp6-g21.free.fr"
	rhost-flags-OK-FAIL-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1492976AbZI1MuR (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 28 Sep 2009 14:50:17 +0200
Received: from smtp6-g21.free.fr (localhost [127.0.0.1])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 4F65BE08119;
	Mon, 28 Sep 2009 14:49:46 +0200 (CEST)
Received: from [213.228.1.107] (sakura.staff.proxad.net [213.228.1.107])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 74768E0805A;
	Mon, 28 Sep 2009 14:49:43 +0200 (CEST)
Subject: [PATCH v3] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
From:	Maxime Bizon <mbizon@freebox.fr>
Reply-To: mbizon@freebox.fr
To:	Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc:	Wolfram Sang <w.sang@pengutronix.de>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-pcmcia@lists.infradead.org, linux-mips@linux-mips.org,
	Ralf Baechle <ralf@linux-mips.org>
In-Reply-To: <4ABCF1E7.4010304@ru.mvista.com>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>
	 <20090923123143.GB3131@pengutronix.de>
	 <1253709915.1627.397.camel@sakura.staff.proxad.net>
	 <1253890476.1627.468.camel@sakura.staff.proxad.net>
	 <4ABCF1E7.4010304@ru.mvista.com>
Content-Type: text/plain
Organization: Freebox
Date:	Mon, 28 Sep 2009 14:49:43 +0200
Message-Id: <1254142183.1627.488.camel@sakura.staff.proxad.net>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 7bit
Return-Path: <mbizon@freebox.fr>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24108
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mbizon@freebox.fr
Precedence: bulk
X-list: linux-mips


On Fri, 2009-09-25 at 20:37 +0400, Sergei Shtylyov wrote:

Hi Sergei,

>     Then why initialize it?

fixed

>     Shouln't this be array of structures instead?

fixed

>     Is this GPIO selection really chip- and not board-specific?

yes

>     I don't think having both board code and the driver in a single patch is 
> a good idea. I'd put the driver in its own separate patch...

Ralf seems ok with merging as-is, next time I'll split board support and
driver I guess.

>     Are you sure you can drive any Broadcom's bridge?

fixed

>     Why it's called the same as 'yenta_cardbus_driver' and not 
> "bcm63xx_cardbus"?

copy/paste, fixed

>     Why so many empty lines in between?

fixed


Updated patch.

Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>

---
 arch/mips/bcm63xx/Makefile                         |    2 +-
 arch/mips/bcm63xx/boards/board_bcm963xx.c          |    4 +
 arch/mips/bcm63xx/dev-pcmcia.c                     |  144 ++++++
 .../include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h  |   13 +
 drivers/pcmcia/Kconfig                             |    4 +
 drivers/pcmcia/Makefile                            |    1 +
 drivers/pcmcia/bcm63xx_pcmcia.c                    |  536 ++++++++++++++++++++
 drivers/pcmcia/bcm63xx_pcmcia.h                    |   60 +++
 8 files changed, 763 insertions(+), 1 deletions(-)
 create mode 100644 arch/mips/bcm63xx/dev-pcmcia.c
 create mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
 create mode 100644 drivers/pcmcia/bcm63xx_pcmcia.c
 create mode 100644 drivers/pcmcia/bcm63xx_pcmcia.h

diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile
index cff75de..c146d1e 100644
--- a/arch/mips/bcm63xx/Makefile
+++ b/arch/mips/bcm63xx/Makefile
@@ -1,5 +1,5 @@
 obj-y		+= clk.o cpu.o cs.o gpio.o irq.o prom.o setup.o timer.o \
-		   dev-dsp.o dev-enet.o dev-uart.o
+		   dev-dsp.o dev-enet.o dev-pcmcia.o dev-uart.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
 obj-y		+= boards/
diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index d3fdf27..e3e6205 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -24,6 +24,7 @@
 #include <bcm63xx_dev_pci.h>
 #include <bcm63xx_dev_enet.h>
 #include <bcm63xx_dev_dsp.h>
+#include <bcm63xx_dev_pcmcia.h>
 #include <bcm63xx_dev_uart.h>
 #include <board_bcm963xx.h>
 
@@ -796,6 +797,9 @@ int __init board_register_devices(void)
 
 	bcm63xx_uart_register();
 
+	if (board.has_pccard)
+		bcm63xx_pcmcia_register();
+
 	if (board.has_enet0 &&
 	    !board_get_mac_address(board.enet0.mac_addr))
 		bcm63xx_enet_register(0, &board.enet0);
diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c
new file mode 100644
index 0000000..de4d917
--- /dev/null
+++ b/arch/mips/bcm63xx/dev-pcmcia.c
@@ -0,0 +1,144 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <asm/bootinfo.h>
+#include <linux/platform_device.h>
+#include <bcm63xx_cs.h>
+#include <bcm63xx_cpu.h>
+#include <bcm63xx_dev_pcmcia.h>
+#include <bcm63xx_io.h>
+#include <bcm63xx_regs.h>
+
+static struct resource pcmcia_resources[] = {
+	/* pcmcia registers */
+	{
+		/* start & end filled at runtime */
+		.flags		= IORESOURCE_MEM,
+	},
+
+	/* pcmcia memory zone resources */
+	{
+		.start		= BCM_PCMCIA_COMMON_BASE_PA,
+		.end		= BCM_PCMCIA_COMMON_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= BCM_PCMCIA_ATTR_BASE_PA,
+		.end		= BCM_PCMCIA_ATTR_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= BCM_PCMCIA_IO_BASE_PA,
+		.end		= BCM_PCMCIA_IO_END_PA,
+		.flags		= IORESOURCE_MEM,
+	},
+
+	/* PCMCIA irq */
+	{
+		/* start filled at runtime */
+		.flags		= IORESOURCE_IRQ,
+	},
+
+	/* declare PCMCIA IO resource also */
+	{
+		.start		= BCM_PCMCIA_IO_BASE_PA,
+		.end		= BCM_PCMCIA_IO_END_PA,
+		.flags		= IORESOURCE_IO,
+	},
+};
+
+static struct bcm63xx_pcmcia_platform_data pd;
+
+static struct platform_device bcm63xx_pcmcia_device = {
+	.name		= "bcm63xx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(pcmcia_resources),
+	.resource	= pcmcia_resources,
+	.dev		= {
+		.platform_data = &pd,
+	},
+};
+
+static int __init config_pcmcia_cs(unsigned int cs,
+				   u32 base, unsigned int size)
+{
+	int ret;
+
+	ret = bcm63xx_set_cs_status(cs, 0);
+	if (!ret)
+		ret = bcm63xx_set_cs_base(cs, base, size);
+	if (!ret)
+		ret = bcm63xx_set_cs_status(cs, 1);
+	return ret;
+}
+
+static const __initdata struct {
+	unsigned int	cs;
+	unsigned int	base;
+	unsigned int	size;
+} pcmcia_cs[3] = {
+	{
+		.cs	= MPI_CS_PCMCIA_COMMON,
+		.base	= BCM_PCMCIA_COMMON_BASE_PA,
+		.size	= BCM_PCMCIA_COMMON_SIZE
+	},
+	{
+		.cs	= MPI_CS_PCMCIA_ATTR,
+		.base	= BCM_PCMCIA_ATTR_BASE_PA,
+		.size	= BCM_PCMCIA_ATTR_SIZE
+	},
+	{
+		.cs	= MPI_CS_PCMCIA_IO,
+		.base	= BCM_PCMCIA_IO_BASE_PA,
+		.size	= BCM_PCMCIA_IO_SIZE
+	},
+};
+
+int __init bcm63xx_pcmcia_register(void)
+{
+	int ret, i;
+
+	if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358())
+		return 0;
+
+	/* use correct pcmcia ready gpio depending on processor */
+	switch (bcm63xx_get_cpu_id()) {
+	case BCM6348_CPU_ID:
+		pd.ready_gpio = 22;
+		break;
+
+	case BCM6358_CPU_ID:
+		pd.ready_gpio = 18;
+		break;
+
+	default:
+		return -ENODEV;
+	}
+
+	pcmcia_resources[0].start = bcm63xx_regset_address(RSET_PCMCIA);
+	pcmcia_resources[0].end = pcmcia_resources[0].start +
+		RSET_PCMCIA_SIZE - 1;
+	pcmcia_resources[4].start = bcm63xx_get_irq_number(IRQ_PCMCIA);
+
+	/* configure pcmcia chip selects */
+	for (i = 0; i < 3; i++) {
+		ret = config_pcmcia_cs(pcmcia_cs[i].cs,
+				       pcmcia_cs[i].base,
+				       pcmcia_cs[i].size);
+		if (ret)
+			goto out_err;
+	}
+
+	return platform_device_register(&bcm63xx_pcmcia_device);
+
+out_err:
+	printk(KERN_ERR "unable to set pcmcia chip select\n");
+	return ret;
+}
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
new file mode 100644
index 0000000..2beb396
--- /dev/null
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h
@@ -0,0 +1,13 @@
+#ifndef BCM63XX_DEV_PCMCIA_H_
+#define BCM63XX_DEV_PCMCIA_H_
+
+/*
+ * PCMCIA driver platform data
+ */
+struct bcm63xx_pcmcia_platform_data {
+	unsigned int ready_gpio;
+};
+
+int bcm63xx_pcmcia_register(void);
+
+#endif /* BCM63XX_DEV_PCMCIA_H_ */
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index fbf965b..17f38a7 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -192,6 +192,10 @@ config PCMCIA_AU1X00
 	tristate "Au1x00 pcmcia support"
 	depends on SOC_AU1X00 && PCMCIA
 
+config PCMCIA_BCM63XX
+	tristate "bcm63xx pcmcia support"
+	depends on BCM63XX && PCMCIA
+
 config PCMCIA_SA1100
 	tristate "SA1100 support"
 	depends on ARM && ARCH_SA1100 && PCMCIA
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 047394d..1ee57f0 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_PCMCIA_SA1111)			+= sa11xx_core.o sa1111_cs.o
 obj-$(CONFIG_M32R_PCC)				+= m32r_pcc.o
 obj-$(CONFIG_M32R_CFC)				+= m32r_cfc.o
 obj-$(CONFIG_PCMCIA_AU1X00)			+= au1x00_ss.o
+obj-$(CONFIG_PCMCIA_BCM63XX)			+= bcm63xx_pcmcia.o
 obj-$(CONFIG_PCMCIA_VRC4171)			+= vrc4171_card.o
 obj-$(CONFIG_PCMCIA_VRC4173)			+= vrc4173_cardu.o
 obj-$(CONFIG_OMAP_CF)				+= omap_cf.o
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c
new file mode 100644
index 0000000..bc88a3b
--- /dev/null
+++ b/drivers/pcmcia/bcm63xx_pcmcia.c
@@ -0,0 +1,536 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/timer.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/gpio.h>
+
+#include <bcm63xx_regs.h>
+#include <bcm63xx_io.h>
+#include "bcm63xx_pcmcia.h"
+
+#define PFX	"bcm63xx_pcmcia: "
+
+#ifdef CONFIG_CARDBUS
+/* if cardbus is used, platform device needs reference to actual pci
+ * device */
+static struct pci_dev *bcm63xx_cb_dev;
+#endif
+
+/*
+ * read/write helper for pcmcia regs
+ */
+static inline u32 pcmcia_readl(struct bcm63xx_pcmcia_socket *skt, u32 off)
+{
+	return bcm_readl(skt->base + off);
+}
+
+static inline void pcmcia_writel(struct bcm63xx_pcmcia_socket *skt,
+				 u32 val, u32 off)
+{
+	bcm_writel(val, skt->base + off);
+}
+
+/*
+ * This callback should (re-)initialise the socket, turn on status
+ * interrupts and PCMCIA bus, and wait for power to stabilise so that
+ * the card status signals report correctly.
+ *
+ * Hardware cannot do that.
+ */
+static int bcm63xx_pcmcia_sock_init(struct pcmcia_socket *sock)
+{
+	return 0;
+}
+
+/*
+ * This callback should remove power on the socket, disable IRQs from
+ * the card, turn off status interrupts, and disable the PCMCIA bus.
+ *
+ * Hardware cannot do that.
+ */
+static int bcm63xx_pcmcia_suspend(struct pcmcia_socket *sock)
+{
+	return 0;
+}
+
+/*
+ * Implements the set_socket() operation for the in-kernel PCMCIA
+ * service (formerly SS_SetSocket in Card Services). We more or
+ * less punt all of this work and let the kernel handle the details
+ * of power configuration, reset, &c. We also record the value of
+ * `state' in order to regurgitate it to the PCMCIA core later.
+ */
+static int bcm63xx_pcmcia_set_socket(struct pcmcia_socket *sock,
+				     socket_state_t *state)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	unsigned long flags;
+	u32 val;
+
+	skt = sock->driver_data;
+
+	spin_lock_irqsave(&skt->lock, flags);
+
+	/* note: hardware cannot control socket power, so we will
+	 * always report SS_POWERON */
+
+	/* apply socket reset */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+	if (state->flags & SS_RESET)
+		val |= PCMCIA_C1_RESET_MASK;
+	else
+		val &= ~PCMCIA_C1_RESET_MASK;
+
+	/* reverse reset logic for cardbus card */
+	if (skt->card_detected && (skt->card_type & CARD_CARDBUS))
+		val ^= PCMCIA_C1_RESET_MASK;
+
+	pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+	/* keep requested state for event reporting */
+	skt->requested_state = *state;
+
+	spin_unlock_irqrestore(&skt->lock, flags);
+
+	return 0;
+}
+
+/*
+ * identity cardtype from VS[12] input, CD[12] input while only VS2 is
+ * floating, and CD[12] input while only VS1 is floating
+ */
+enum {
+	IN_VS1 = (1 << 0),
+	IN_VS2 = (1 << 1),
+	IN_CD1_VS2H = (1 << 2),
+	IN_CD2_VS2H = (1 << 3),
+	IN_CD1_VS1H = (1 << 4),
+	IN_CD2_VS1H = (1 << 5),
+};
+
+static const u8 vscd_to_cardtype[] = {
+
+	/* VS1 float, VS2 float */
+	[IN_VS1 | IN_VS2] = (CARD_PCCARD | CARD_5V),
+
+	/* VS1 grounded, VS2 float */
+	[IN_VS2] = (CARD_PCCARD | CARD_5V | CARD_3V),
+
+	/* VS1 grounded, VS2 grounded */
+	[0] = (CARD_PCCARD | CARD_5V | CARD_3V | CARD_XV),
+
+	/* VS1 tied to CD1, VS2 float */
+	[IN_VS1 | IN_VS2 | IN_CD1_VS1H] = (CARD_CARDBUS | CARD_3V),
+
+	/* VS1 grounded, VS2 tied to CD2 */
+	[IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V | CARD_XV),
+
+	/* VS1 tied to CD2, VS2 grounded */
+	[IN_VS1 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_3V | CARD_XV | CARD_YV),
+
+	/* VS1 float, VS2 grounded */
+	[IN_VS1] = (CARD_PCCARD | CARD_XV),
+
+	/* VS1 float, VS2 tied to CD2 */
+	[IN_VS1 | IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V),
+
+	/* VS1 float, VS2 tied to CD1 */
+	[IN_VS1 | IN_VS2 | IN_CD1_VS2H] = (CARD_CARDBUS | CARD_XV | CARD_YV),
+
+	/* VS1 tied to CD2, VS2 float */
+	[IN_VS1 | IN_VS2 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_YV),
+
+	/* VS2 grounded, VS1 is tied to CD1, CD2 is grounded */
+	[IN_VS1 | IN_CD1_VS1H] = 0, /* ignore cardbay */
+};
+
+/*
+ * poll hardware to check card insertion status
+ */
+static unsigned int __get_socket_status(struct bcm63xx_pcmcia_socket *skt)
+{
+	unsigned int stat;
+	u32 val;
+
+	stat = 0;
+
+	/* check CD for card presence */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+
+	if (!(val & PCMCIA_C1_CD1_MASK) && !(val & PCMCIA_C1_CD2_MASK))
+		stat |= SS_DETECT;
+
+	/* if new insertion, detect cardtype */
+	if ((stat & SS_DETECT) && !skt->card_detected) {
+		unsigned int stat = 0;
+
+		/* float VS1, float VS2 */
+		val |= PCMCIA_C1_VS1OE_MASK;
+		val |= PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read VS[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_VS1_MASK) ? IN_VS1 : 0;
+		stat |= (val & PCMCIA_C1_VS2_MASK) ? IN_VS2 : 0;
+
+		/* drive VS1 low, float VS2 */
+		val &= ~PCMCIA_C1_VS1OE_MASK;
+		val |= PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read CD[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS2H : 0;
+		stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS2H : 0;
+
+		/* float VS1, drive VS2 low */
+		val |= PCMCIA_C1_VS1OE_MASK;
+		val &= ~PCMCIA_C1_VS2OE_MASK;
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+		/* wait for output to stabilize and read CD[12] */
+		udelay(10);
+		val = pcmcia_readl(skt, PCMCIA_C1_REG);
+		stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS1H : 0;
+		stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS1H : 0;
+
+		/* guess cardtype from all this */
+		skt->card_type = vscd_to_cardtype[stat];
+		if (!skt->card_type)
+			dev_err(&skt->socket.dev, "unsupported card type\n");
+
+		/* drive both VS pin to 0 again */
+		val &= ~(PCMCIA_C1_VS1OE_MASK | PCMCIA_C1_VS2OE_MASK);
+
+		/* enable correct logic */
+		val &= ~(PCMCIA_C1_EN_PCMCIA_MASK | PCMCIA_C1_EN_CARDBUS_MASK);
+		if (skt->card_type & CARD_PCCARD)
+			val |= PCMCIA_C1_EN_PCMCIA_MASK;
+		else
+			val |= PCMCIA_C1_EN_CARDBUS_MASK;
+
+		pcmcia_writel(skt, val, PCMCIA_C1_REG);
+	}
+	skt->card_detected = (stat & SS_DETECT) ? 1 : 0;
+
+	/* report card type/voltage */
+	if (skt->card_type & CARD_CARDBUS)
+		stat |= SS_CARDBUS;
+	if (skt->card_type & CARD_3V)
+		stat |= SS_3VCARD;
+	if (skt->card_type & CARD_XV)
+		stat |= SS_XVCARD;
+	stat |= SS_POWERON;
+
+	if (gpio_get_value(skt->pd->ready_gpio))
+		stat |= SS_READY;
+
+	return stat;
+}
+
+/*
+ * core request to get current socket status
+ */
+static int bcm63xx_pcmcia_get_status(struct pcmcia_socket *sock,
+				     unsigned int *status)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+
+	skt = sock->driver_data;
+
+	spin_lock_bh(&skt->lock);
+	*status = __get_socket_status(skt);
+	spin_unlock_bh(&skt->lock);
+
+	return 0;
+}
+
+/*
+ * socket polling timer callback
+ */
+static void bcm63xx_pcmcia_poll(unsigned long data)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	unsigned int stat, events;
+
+	skt = (struct bcm63xx_pcmcia_socket *)data;
+
+	spin_lock_bh(&skt->lock);
+
+	stat = __get_socket_status(skt);
+
+	/* keep only changed bits, and mask with required one from the
+	 * core */
+	events = (stat ^ skt->old_status) & skt->requested_state.csc_mask;
+	skt->old_status = stat;
+	spin_unlock_bh(&skt->lock);
+
+	if (events)
+		pcmcia_parse_events(&skt->socket, events);
+
+	mod_timer(&skt->timer,
+		  jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
+}
+
+static int bcm63xx_pcmcia_set_io_map(struct pcmcia_socket *sock,
+				     struct pccard_io_map *map)
+{
+	/* this doesn't seem to be called by pcmcia layer if static
+	 * mapping is used */
+	return 0;
+}
+
+static int bcm63xx_pcmcia_set_mem_map(struct pcmcia_socket *sock,
+				      struct pccard_mem_map *map)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct resource *res;
+
+	skt = sock->driver_data;
+	if (map->flags & MAP_ATTRIB)
+		res = skt->attr_res;
+	else
+		res = skt->common_res;
+
+	map->static_start = res->start + map->card_start;
+	return 0;
+}
+
+static struct pccard_operations bcm63xx_pcmcia_operations = {
+	.init			= bcm63xx_pcmcia_sock_init,
+	.suspend		= bcm63xx_pcmcia_suspend,
+	.get_status		= bcm63xx_pcmcia_get_status,
+	.set_socket		= bcm63xx_pcmcia_set_socket,
+	.set_io_map		= bcm63xx_pcmcia_set_io_map,
+	.set_mem_map		= bcm63xx_pcmcia_set_mem_map,
+};
+
+/*
+ * register pcmcia socket to core
+ */
+static int __devinit bcm63xx_drv_pcmcia_probe(struct platform_device *pdev)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct pcmcia_socket *sock;
+	struct resource *res, *irq_res;
+	unsigned int regmem_size = 0, iomem_size = 0;
+	u32 val;
+	int ret;
+
+	skt = kzalloc(sizeof(*skt), GFP_KERNEL);
+	if (!skt)
+		return -ENOMEM;
+	spin_lock_init(&skt->lock);
+	sock = &skt->socket;
+	sock->driver_data = skt;
+
+	/* make sure we have all resources we need */
+	skt->common_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	skt->attr_res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	skt->pd = pdev->dev.platform_data;
+	if (!skt->common_res || !skt->attr_res || !irq_res || !skt->pd) {
+		ret = -EINVAL;
+		goto err;
+	}
+
+	/* remap pcmcia registers */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	regmem_size = resource_size(res);
+	if (!request_mem_region(res->start, regmem_size, "bcm63xx_pcmcia")) {
+		ret = -EINVAL;
+		goto err;
+	}
+	skt->reg_res = res;
+
+	skt->base = ioremap(res->start, regmem_size);
+	if (!skt->base) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	/* remap io registers */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+	iomem_size = resource_size(res);
+	skt->io_base = ioremap(res->start, iomem_size);
+	if (!skt->io_base) {
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	/* resources are static */
+	sock->resource_ops = &pccard_static_ops;
+	sock->ops = &bcm63xx_pcmcia_operations;
+	sock->owner = THIS_MODULE;
+	sock->dev.parent = &pdev->dev;
+	sock->features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
+	sock->io_offset = (unsigned long)skt->io_base;
+	sock->pci_irq = irq_res->start;
+
+#ifdef CONFIG_CARDBUS
+	sock->cb_dev = bcm63xx_cb_dev;
+	if (bcm63xx_cb_dev)
+		sock->features |= SS_CAP_CARDBUS;
+#endif
+
+	/* assume common & attribute memory have the same size */
+	sock->map_size = resource_size(skt->common_res);
+
+	/* initialize polling timer */
+	setup_timer(&skt->timer, bcm63xx_pcmcia_poll, (unsigned long)skt);
+
+	/* initialize  pcmcia  control register,  drive  VS[12] to  0,
+	 * leave CB IDSEL to the old  value since it is set by the PCI
+	 * layer */
+	val = pcmcia_readl(skt, PCMCIA_C1_REG);
+	val &= PCMCIA_C1_CBIDSEL_MASK;
+	val |= PCMCIA_C1_EN_PCMCIA_GPIO_MASK;
+	pcmcia_writel(skt, val, PCMCIA_C1_REG);
+
+	/*
+	 * Hardware has only one set of timings registers, not one for
+	 * each memory access type, so we configure them for the
+	 * slowest one: attribute memory.
+	 */
+	val = PCMCIA_C2_DATA16_MASK;
+	val |= 10 << PCMCIA_C2_RWCOUNT_SHIFT;
+	val |= 6 << PCMCIA_C2_INACTIVE_SHIFT;
+	val |= 3 << PCMCIA_C2_SETUP_SHIFT;
+	val |= 3 << PCMCIA_C2_HOLD_SHIFT;
+	pcmcia_writel(skt, val, PCMCIA_C2_REG);
+
+	ret = pcmcia_register_socket(sock);
+	if (ret)
+		goto err;
+
+	/* start polling socket */
+	mod_timer(&skt->timer,
+		  jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE));
+
+	platform_set_drvdata(pdev, skt);
+	return 0;
+
+err:
+	if (skt->io_base)
+		iounmap(skt->io_base);
+	if (skt->base)
+		iounmap(skt->base);
+	if (skt->reg_res)
+		release_mem_region(skt->reg_res->start, regmem_size);
+	kfree(skt);
+	return ret;
+}
+
+static int __devexit bcm63xx_drv_pcmcia_remove(struct platform_device *pdev)
+{
+	struct bcm63xx_pcmcia_socket *skt;
+	struct resource *res;
+
+	skt = platform_get_drvdata(pdev);
+	del_timer_sync(&skt->timer);
+	iounmap(skt->base);
+	iounmap(skt->io_base);
+	res = skt->reg_res;
+	release_mem_region(res->start, resource_size(res));
+	kfree(skt);
+	return 0;
+}
+
+struct platform_driver bcm63xx_pcmcia_driver = {
+	.probe	= bcm63xx_drv_pcmcia_probe,
+	.remove	= __devexit_p(bcm63xx_drv_pcmcia_remove),
+	.driver	= {
+		.name	= "bcm63xx_pcmcia",
+		.owner  = THIS_MODULE,
+	},
+};
+
+#ifdef CONFIG_CARDBUS
+static int __devinit bcm63xx_cb_probe(struct pci_dev *dev,
+				      const struct pci_device_id *id)
+{
+	/* keep pci device */
+	bcm63xx_cb_dev = dev;
+	return platform_driver_register(&bcm63xx_pcmcia_driver);
+}
+
+static void __devexit bcm63xx_cb_exit(struct pci_dev *dev)
+{
+	platform_driver_unregister(&bcm63xx_pcmcia_driver);
+	bcm63xx_cb_dev = NULL;
+}
+
+static struct pci_device_id bcm63xx_cb_table[] = {
+	{
+		.vendor		= PCI_VENDOR_ID_BROADCOM,
+		.device		= BCM6348_CPU_ID,
+		.subvendor	= PCI_VENDOR_ID_BROADCOM,
+		.subdevice	= PCI_ANY_ID,
+		.class		= PCI_CLASS_BRIDGE_CARDBUS << 8,
+		.class_mask	= ~0,
+	},
+
+	{
+		.vendor		= PCI_VENDOR_ID_BROADCOM,
+		.device		= BCM6358_CPU_ID,
+		.subvendor	= PCI_VENDOR_ID_BROADCOM,
+		.subdevice	= PCI_ANY_ID,
+		.class		= PCI_CLASS_BRIDGE_CARDBUS << 8,
+		.class_mask	= ~0,
+	},
+
+	{ },
+};
+
+MODULE_DEVICE_TABLE(pci, bcm63xx_cb_table);
+
+static struct pci_driver bcm63xx_cardbus_driver = {
+	.name		= "bcm63xx_cardbus",
+	.id_table	= bcm63xx_cb_table,
+	.probe		= bcm63xx_cb_probe,
+	.remove		= __devexit_p(bcm63xx_cb_exit),
+};
+#endif
+
+/*
+ * if cardbus support is enabled, register our platform device after
+ * our fake cardbus bridge has been registered
+ */
+static int __init bcm63xx_pcmcia_init(void)
+{
+#ifdef CONFIG_CARDBUS
+	return pci_register_driver(&bcm63xx_cardbus_driver);
+#else
+	return platform_driver_register(&bcm63xx_pcmcia_driver);
+#endif
+}
+
+static void __exit bcm63xx_pcmcia_exit(void)
+{
+#ifdef CONFIG_CARDBUS
+	return pci_unregister_driver(&bcm63xx_cardbus_driver);
+#else
+	platform_driver_unregister(&bcm63xx_pcmcia_driver);
+#endif
+}
+
+module_init(bcm63xx_pcmcia_init);
+module_exit(bcm63xx_pcmcia_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
+MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm63xx Socket Controller");
diff --git a/drivers/pcmcia/bcm63xx_pcmcia.h b/drivers/pcmcia/bcm63xx_pcmcia.h
new file mode 100644
index 0000000..ed95739
--- /dev/null
+++ b/drivers/pcmcia/bcm63xx_pcmcia.h
@@ -0,0 +1,60 @@
+#ifndef BCM63XX_PCMCIA_H_
+#define BCM63XX_PCMCIA_H_
+
+#include <linux/types.h>
+#include <linux/timer.h>
+#include <pcmcia/ss.h>
+#include <bcm63xx_dev_pcmcia.h>
+
+/* socket polling rate in ms */
+#define BCM63XX_PCMCIA_POLL_RATE	500
+
+enum {
+	CARD_CARDBUS = (1 << 0),
+	CARD_PCCARD = (1 << 1),
+	CARD_5V = (1 << 2),
+	CARD_3V = (1 << 3),
+	CARD_XV = (1 << 4),
+	CARD_YV = (1 << 5),
+};
+
+struct bcm63xx_pcmcia_socket {
+	struct pcmcia_socket socket;
+
+	/* platform specific data */
+	struct bcm63xx_pcmcia_platform_data *pd;
+
+	/* all regs access are protected by this spinlock */
+	spinlock_t lock;
+
+	/* pcmcia registers resource */
+	struct resource *reg_res;
+
+	/* base remapped address of registers */
+	void __iomem *base;
+
+	/* whether a card is detected at the moment */
+	int card_detected;
+
+	/* type of detected card (mask of above enum) */
+	u8 card_type;
+
+	/* keep last socket status to implement event reporting */
+	unsigned int old_status;
+
+	/* backup of requested socket state */
+	socket_state_t requested_state;
+
+	/* timer used for socket status polling */
+	struct timer_list timer;
+
+	/* attribute/common memory resources */
+	struct resource *attr_res;
+	struct resource *common_res;
+	struct resource *io_res;
+
+	/* base address of io memory */
+	void __iomem *io_base;
+};
+
+#endif /* BCM63XX_PCMCIA_H_ */
-- 
1.6.0.4


-- 
Maxime



From ralf@linux-mips.org Mon Sep 28 15:20:08 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 15:20:11 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:51622 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1492972AbZI1NUI (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 28 Sep 2009 15:20:08 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8SDLRXe027147;
	Mon, 28 Sep 2009 14:21:27 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8SDLMDD027129;
	Mon, 28 Sep 2009 14:21:22 +0100
Date:	Mon, 28 Sep 2009 14:21:22 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Maxime Bizon <mbizon@freebox.fr>
Cc:	Sergei Shtylyov <sshtylyov@ru.mvista.com>,
	Wolfram Sang <w.sang@pengutronix.de>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	linux-pcmcia@lists.infradead.org, linux-mips@linux-mips.org
Subject: Re: [PATCH v3] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
Message-ID: <20090928132122.GA26272@linux-mips.org>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net> <20090923123143.GB3131@pengutronix.de> <1253709915.1627.397.camel@sakura.staff.proxad.net> <1253890476.1627.468.camel@sakura.staff.proxad.net> <4ABCF1E7.4010304@ru.mvista.com> <1254142183.1627.488.camel@sakura.staff.proxad.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1254142183.1627.488.camel@sakura.staff.proxad.net>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24109
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

On Mon, Sep 28, 2009 at 02:49:43PM +0200, Maxime Bizon wrote:

> > a good idea. I'd put the driver in its own separate patch...
> 
> Ralf seems ok with merging as-is, next time I'll split board support and
> driver I guess.

The patch headers patches which are required by the arch and the driver
bits.  To avoid patch ordering issues that could result from splitting
and then most likely submitting the resulting patches via multiple
maintainers it was the easiest to just submit everything in a single
patch.

  Ralf

From ralf@linux-mips.org Mon Sep 28 15:43:04 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 15:43:07 +0200 (CEST)
Received: from localhost.localdomain ([127.0.0.1]:54942 "EHLO h5.dl5rb.org.uk"
	rhost-flags-OK-OK-OK-FAIL) by ftp.linux-mips.org with ESMTP
	id S1493315AbZI1NnD (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 28 Sep 2009 15:43:03 +0200
Received: from h5.dl5rb.org.uk (localhost.localdomain [127.0.0.1])
	by h5.dl5rb.org.uk (8.14.3/8.14.3) with ESMTP id n8SDiNMj029847;
	Mon, 28 Sep 2009 14:44:23 +0100
Received: (from ralf@localhost)
	by h5.dl5rb.org.uk (8.14.3/8.14.3/Submit) id n8SDiNb1029845;
	Mon, 28 Sep 2009 14:44:23 +0100
Date:	Mon, 28 Sep 2009 14:44:23 +0100
From:	Ralf Baechle <ralf@linux-mips.org>
To:	Maxime Bizon <mbizon@freebox.fr>
Cc:	Greg Kroah-Hartman <gregkh@suse.de>, linux-mips@linux-mips.org
Subject: Re: [PATCH v3] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
Message-ID: <20090928134423.GA29791@linux-mips.org>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net> <20090923123143.GB3131@pengutronix.de> <1253709915.1627.397.camel@sakura.staff.proxad.net> <1253890476.1627.468.camel@sakura.staff.proxad.net> <4ABCF1E7.4010304@ru.mvista.com> <1254142183.1627.488.camel@sakura.staff.proxad.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1254142183.1627.488.camel@sakura.staff.proxad.net>
User-Agent: Mutt/1.5.19 (2009-01-05)
Return-Path: <ralf@linux-mips.org>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24110
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: ralf@linux-mips.org
Precedence: bulk
X-list: linux-mips

Maxim,

so with PCMCIA sorted this leaves only the two USB UHCI / EHCI patches.
What is the status of these?

  Ralf

From manuel.lauss@googlemail.com Mon Sep 28 16:08:58 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 16:09:04 +0200 (CEST)
Received: from mail-bw0-f208.google.com ([209.85.218.208]:55981 "EHLO
	mail-bw0-f208.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1492641AbZI1OI6 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 28 Sep 2009 16:08:58 +0200
Received: by bwz4 with SMTP id 4so3535984bwz.0
        for <multiple recipients>; Mon, 28 Sep 2009 07:08:52 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:mime-version:received:in-reply-to:references
         :date:message-id:subject:from:to:cc:content-type;
        bh=bto3pdl+OfOMAU0j2Xws7LA9ky2ID9dK6FvGxm4Ql70=;
        b=JObWCGYSsEfpaNU+e+a+/XatXrdrsuRoywKU/soYp2e6UXTD5PoaqoLlFkm9SAyqKL
         otSYenOHIk7tF54B/4ueoFEAf/j3+4sXAsiHlnw3sEmfaxGw3A8c6b27hWUmYc68EQHN
         vgUDg3w1aO51DS+J60bQJct1vPvpJszQpxXq0=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :cc:content-type;
        b=FPaC3pgUGi1uVtXaYP0lWN+tfLqqQomUe/RLGkgWCNuQ7eOBY4XInt8/lUpVIuFPPE
         mB/70HM0wVnYWrEIAYrn7oN1JLnWR82GspYcmrIKq+D/BtG+MjUILtiVrhCiMrLB7iLl
         bhbPj4hhbNEBCBoC6Y8u4amnvTRJVJ+L50LpY=
MIME-Version: 1.0
Received: by 10.103.50.28 with SMTP id c28mr1272297muk.17.1254146932571; Mon, 
	28 Sep 2009 07:08:52 -0700 (PDT)
In-Reply-To: <1249894154-10982-1-git-send-email-wuzhangjin@gmail.com>
References: <1249894154-10982-1-git-send-email-wuzhangjin@gmail.com>
Date:	Mon, 28 Sep 2009 16:08:52 +0200
Message-ID: <f861ec6f0909280708o42ceb334u4d33e141b9c51efa@mail.gmail.com>
Subject: Re: [PATCH -v1] MIPS: add support for gzip/bzip2/lzma compressed 
	kernel images
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Wu Zhangjin <wuzhangjin@gmail.com>
Cc:	linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>,
	Alexander Clouter <alex@digriz.org.uk>
Content-Type: text/plain; charset=ISO-8859-1
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24111
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

Hi Wu!

On Mon, Aug 10, 2009 at 10:49 AM, Wu Zhangjin <wuzhangjin@gmail.com> wrote:
> This patch will help to generate smaller kernel images for linux-MIPS,

I just gave it quick spin on my Alchemy boards, works quite well!

For the debug code (dbg.[ch]) I suggest you leave the actual uart-banging
to board code (either in the form of cpp macros or inlined functions)
because most chips either don't have a 16550 compatible uart or (in the
alchemy case) have a 16550 with non-standard register layout.

Thanks you for your work!
        Manuel Lauss

From mbizon@freebox.fr Mon Sep 28 17:08:19 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 17:08:25 +0200 (CEST)
Received: from smtp6-g21.free.fr ([212.27.42.6]:46192 "EHLO smtp6-g21.free.fr"
	rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org with ESMTP
	id S1493415AbZI1PIT (ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 28 Sep 2009 17:08:19 +0200
Received: from smtp6-g21.free.fr (localhost [127.0.0.1])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 5350CE081A6;
	Mon, 28 Sep 2009 17:08:12 +0200 (CEST)
Received: from [213.228.1.107] (sakura.staff.proxad.net [213.228.1.107])
	by smtp6-g21.free.fr (Postfix) with ESMTP id 6A608E080A1;
	Mon, 28 Sep 2009 17:08:09 +0200 (CEST)
Subject: Re: [PATCH v3] MIPS: BCM63xx: Add PCMCIA & Cardbus support.
From:	Maxime Bizon <mbizon@freebox.fr>
Reply-To: mbizon@freebox.fr
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	Greg Kroah-Hartman <gregkh@suse.de>, linux-mips@linux-mips.org
In-Reply-To: <20090928134423.GA29791@linux-mips.org>
References: <1253272891.1627.284.camel@sakura.staff.proxad.net>
	 <20090923123143.GB3131@pengutronix.de>
	 <1253709915.1627.397.camel@sakura.staff.proxad.net>
	 <1253890476.1627.468.camel@sakura.staff.proxad.net>
	 <4ABCF1E7.4010304@ru.mvista.com>
	 <1254142183.1627.488.camel@sakura.staff.proxad.net>
	 <20090928134423.GA29791@linux-mips.org>
Content-Type: text/plain
Organization: Freebox
Date:	Mon, 28 Sep 2009 17:08:09 +0200
Message-Id: <1254150489.1627.503.camel@sakura.staff.proxad.net>
Mime-Version: 1.0
X-Mailer: Evolution 2.26.1 
Content-Transfer-Encoding: 7bit
Return-Path: <mbizon@freebox.fr>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24112
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: mbizon@freebox.fr
Precedence: bulk
X-list: linux-mips


On Mon, 2009-09-28 at 14:44 +0100, Ralf Baechle wrote:

> so with PCMCIA sorted this leaves only the two USB UHCI / EHCI patches.
> What is the status of these?

I got this review at first post:

http://www.spinics.net/lists/mips/msg32240.html

I addressed all comments, beside readl_be/writel_be, which I'm not sure
how to integrate correctly in mips generic code.

-- 
Maxime



From geert.uytterhoeven@gmail.com Mon Sep 28 20:46:21 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 20:46:29 +0200 (CEST)
Received: from mail-pz0-f196.google.com ([209.85.222.196]:54847 "EHLO
	mail-pz0-f196.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493548AbZI1SqV convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Mon, 28 Sep 2009 20:46:21 +0200
Received: by pzk34 with SMTP id 34so2603518pzk.22
        for <multiple recipients>; Mon, 28 Sep 2009 11:46:11 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:mime-version:sender:received:in-reply-to
         :references:date:x-google-sender-auth:message-id:subject:from:to:cc
         :content-type:content-transfer-encoding;
        bh=5HDgAIl5a660DqR9WckDWO+37SnMKsk16R6Qh3k0GCw=;
        b=qCvPqDgY393E/LBXp20ey+1+VX5wvgl7cfUhRyHLcITvBfIFAHp1KK1by3u8KXGndv
         5JzcLmhulJZo72jJdLiwiWZxzDhwCNk4c8sDbTl4wnEniizwHzJmst5UqDOH7FF/lMXh
         56Qp412zwQEqsgzUDnl8i1s0XEaY0QoyZQGFw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=mime-version:sender:in-reply-to:references:date
         :x-google-sender-auth:message-id:subject:from:to:cc:content-type
         :content-transfer-encoding;
        b=GiMSeWOc/gcPQZlcD1Fbv1WkHnB+SSdzNzljGJL4Ze7mcMXtkj2rtaQ8CYySKXm8Hm
         scWXPldoxN3p2XSdkPQ9KIApZLcwbodq/xrpH1I+PD/jZZ44sKxIqK7LnraKWAtWdeO0
         i3tVBfvNxXh9UirW/T/FXiNmzIKacKIKQhfcg=
MIME-Version: 1.0
Received: by 10.143.24.40 with SMTP id b40mr22285wfj.0.1254163571554; Mon, 28 
	Sep 2009 11:46:11 -0700 (PDT)
In-Reply-To: <20090928104728.GA3571@linux-mips.org>
References: <1254021294-3832-1-git-send-email-weiyi.huang@gmail.com>
	 <20090928104728.GA3571@linux-mips.org>
Date:	Mon, 28 Sep 2009 20:46:11 +0200
X-Google-Sender-Auth: f0f0989e8b9fa693
Message-ID: <10f740e80909281146y57b4aa67h5ec69b46fe77b4fd@mail.gmail.com>
Subject: Re: [PATCH 1/5] MIPS: remove duplicated #include
From:	Geert Uytterhoeven <geert@linux-m68k.org>
To:	Ralf Baechle <ralf@linux-mips.org>
Cc:	Huang Weiyi <weiyi.huang@gmail.com>, linux-mips@linux-mips.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8BIT
Return-Path: <geert.uytterhoeven@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24113
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: geert@linux-m68k.org
Precedence: bulk
X-list: linux-mips

On Mon, Sep 28, 2009 at 12:47, Ralf Baechle <ralf@linux-mips.org> wrote:
> On Sun, Sep 27, 2009 at 11:14:54AM +0800, Huang Weiyi wrote:
>
>> Remove duplicated #include('s) in
>> Â  arch/mips/kernel/smp.c
>>
>> Signed-off-by: Huang Weiyi <weiyi.huang@gmail.com>
>
> This is the 3rd identical patch I've received ...

I have the impression people discovered the good old `make includecheck', since
it's been added to `make help' ;-)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

From alex@digriz.org.uk Mon Sep 28 22:17:05 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 28 Sep 2009 22:17:13 +0200 (CEST)
Received: from chipmunk.wormnet.eu ([195.195.131.226]:54011 "EHLO
	chipmunk.wormnet.eu" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1493564AbZI1URF (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Mon, 28 Sep 2009 22:17:05 +0200
Received: by chipmunk.wormnet.eu (Postfix, from userid 1000)
	id D9A808314F; Mon, 28 Sep 2009 21:17:03 +0100 (BST)
Date:	Mon, 28 Sep 2009 21:17:03 +0100
From:	Alexander Clouter <alex@digriz.org.uk>
To:	Wu Zhangjin <wuzhangjin@gmail.com>
Cc:	linux-mips@linux-mips.org, Ralf Baechle <ralf@linux-mips.org>,
	manuel.lauss@googlemail.com
Subject: Re: [PATCH -v1] MIPS: add support for gzip/bzip2/lzma compressed
	kernel images
Message-ID: <20090928201703.GX6085@chipmunk>
References: <1249894154-10982-1-git-send-email-wuzhangjin@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1249894154-10982-1-git-send-email-wuzhangjin@gmail.com>
Organization: diGriz
X-URL:	http://www.digriz.org.uk/
X-JabberID: alex@digriz.org.uk
User-Agent: Mutt/1.5.18 (2008-05-17)
Return-Path: <alex@digriz.org.uk>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24114
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: alex@digriz.org.uk
Precedence: bulk
X-list: linux-mips

Hi,

* Wu Zhangjin <wuzhangjin@gmail.com> [2009-08-10 16:49:14+0800]:
>
> This patch will help to generate smaller kernel images for linux-MIPS,
> 
> [snipped]
> 
> NOTE: this should work for the other MIPS-based machines, but I have
> used the command bc in the Makefile to calculate the load address of the
> compressed kernel. I'm not sure this is suitable.  perhaps I need to
> rewrite this part in C program or somebody help to simplify the current
> implementation.
> 
Remembered you wanted a nicer way to work out the load address so this 
is my best attempt so far....I think it's fine to leave it as shell code 
personally; but I'm not a maintainer :)

> + [snipped]
>
> +# The load address of the compressed kernel, VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
> +VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1)
> +VMLINUX_SIZE := $(shell echo "obase=16;ibase=10;(($(VMLINUX_SIZE)/65536 + 1) * 65536)" | bc | cut -d'.' -f1)
> +VMLINUX_LOAD_ADDRESS = $(shell echo $(LOADADDR) | sed -e "s/0xffffffff//g")
> +VMLINUZ_LOAD_ADDRESS := $(shell echo "obase=16; ibase=16; ($(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE))" | bc)
> +VMLINUZ_LOAD_ADDRESS := 0x$(if $(CONFIG_64BIT),ffffffff,)$(VMLINUZ_LOAD_ADDRESS)
> +LOADADDR := 0x$(if $(CONFIG_64BIT),ffffffff,)$(VMLINUX_LOAD_ADDRESS)
> +
Slightly prettier is to get rid of the 'bc' dependency, a divide and a 
'cut' here and there.

Cheers

--
Alexander Clouter
.sigmonster says: Nice guys finish last.
                                -- Leo Durocher

diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index f9ccd97..e531b28 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -12,11 +12,11 @@
 # Author: Wu Zhangjin <wuzj@lemote.com>
 #
 
-# The load address of the compressed kernel, VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
-VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1)
-VMLINUX_SIZE := $(shell echo "obase=16;ibase=10;(($(VMLINUX_SIZE)/65536 + 1) * 65536)" | bc | cut -d'.' -f1)
-VMLINUX_LOAD_ADDRESS = $(shell echo $(LOADADDR) | sed -e "s/0xffffffff//g")
-VMLINUZ_LOAD_ADDRESS := $(shell echo "obase=16; ibase=16; ($(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE))" | bc)
+# compressed kernel load addr: VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
+VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) | cut -d' ' -f1)
+VMLINUX_SIZE := $(shell echo $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
+VMLINUX_LOAD_ADDRESS = $(shell echo $(LOADADDR) | sed -e 's/0xffffffff//')
+VMLINUZ_LOAD_ADDRESS := $(shell printf %x $$((0x$(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE))))
 VMLINUZ_LOAD_ADDRESS := 0x$(if $(CONFIG_64BIT),ffffffff,)$(VMLINUZ_LOAD_ADDRESS)
 LOADADDR := 0x$(if $(CONFIG_64BIT),ffffffff,)$(VMLINUX_LOAD_ADDRESS)

From manuel.lauss@googlemail.com Tue Sep 29 20:15:29 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 29 Sep 2009 20:15:35 +0200 (CEST)
Received: from mail-fx0-f221.google.com ([209.85.220.221]:62676 "EHLO
	mail-fx0-f221.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493658AbZI2SP3 (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 29 Sep 2009 20:15:29 +0200
Received: by fxm21 with SMTP id 21so1108497fxm.33
        for <linux-mips@linux-mips.org>; Tue, 29 Sep 2009 11:15:23 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=hsJeKQWfzFGTmp//4KDvLCJFI67n7IVBUVxL0LunHrY=;
        b=NQvrk8kk2YeOCFPjfNu9NUURi52agQn20ZxSYAimR42DEFYb9y7X36WK3Hc3wUOz9D
         trgZWTxKEvw3waaDKNoUu1F7PSOzAjbxs+Mm01s6kCYmq1RKzV+OlQYWncEXeYTv1MIE
         jFnFtYeZCLTksNQY0t4EE8e3oZfMGG4qVrfYw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=kNj5sEZxl+vAe42ST3ArBcJgPqFhys6FZBezYjGL3uNrmdwr0i7NX4o+xS3/oFWh2y
         nYHIJfql66fwjQCpX//gSSp1c6ot4YgtJ7nc/tW1vH4/COWALuDS8pQiqAn12Mo4rm+K
         kFfbXMV6zP9OR38y+xcC0GHiV5kH1jeD2kXnM=
Received: by 10.86.41.19 with SMTP id o19mr4457905fgo.45.1254248122921;
        Tue, 29 Sep 2009 11:15:22 -0700 (PDT)
Received: from localhost.localdomain (p5496CA2C.dip.t-dialin.net [84.150.202.44])
        by mx.google.com with ESMTPS id 3sm46061fge.23.2009.09.29.11.15.21
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Tue, 29 Sep 2009 11:15:22 -0700 (PDT)
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Linux-MIPS <linux-mips@linux-mips.org>
Cc:	Manuel Lauss <manuel.lauss@gmail.com>
Subject: [PATCH 0/3] Alchemy: devboards: BCSR abstraction and new PCMCIA socket driver
Date:	Tue, 29 Sep 2009 20:15:11 +0200
Message-Id: <1254248114-4158-1-git-send-email-manuel.lauss@gmail.com>
X-Mailer: git-send-email 1.6.5.rc1
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24115
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

These 3 patches add a small API for the devboard CPLD registers,
collect all board register data in a single place,
and add a first user: a new PCMCIA socket driver for Db1xxx/Pb1xxx.

#1 adds basic devboard register ("BCSR" space) API and converts
   all "bcsr->" invocations to use the new API.
   The API is slower than direct access but adds locking to register
   modify operations, which patch #3 can take advantage of.
#2 generalizes PB1200's CPLD IRQ controller code; DB1300 can use it
   too.
#3 replaces the current devboard PCMCIA socket code.  See patch for
   more details.   While it doesn't really belong to this series
   per-se, it does make use of the functions introduced by #1.


As always, run-tested on the DB1200; although testers for the other
boards are very welcome! (are there any left at all?)

On a related note: Are there any users of the PB1000 left?  Since this
board is so very different from the rest, and noone seems to care
about it (most code related to it doesn't build and I only have Au1200
boards to test) I'm inclined to remove it from the tree altogether.

Thanks!

Manuel Lauss (3):
  Alchemy: devboard register abstraction
  Alchemy: devboards: factor out PB1200 IRQ cascade code.
  Alchemy: new PCMCIA socket driver for devboards.

 arch/mips/alchemy/common/platform.c              |    6 -
 arch/mips/alchemy/common/setup.c                 |    3 +-
 arch/mips/alchemy/devboards/Makefile             |    2 +-
 arch/mips/alchemy/devboards/bcsr.c               |  148 +++++
 arch/mips/alchemy/devboards/db1x00/Makefile      |    3 +-
 arch/mips/alchemy/devboards/db1x00/board_setup.c |   62 ++-
 arch/mips/alchemy/devboards/db1x00/irqmap.c      |   18 +-
 arch/mips/alchemy/devboards/db1x00/platform.c    |  164 ++++++
 arch/mips/alchemy/devboards/pb1100/Makefile      |    3 +-
 arch/mips/alchemy/devboards/pb1100/board_setup.c |    7 +-
 arch/mips/alchemy/devboards/pb1100/platform.c    |   83 +++
 arch/mips/alchemy/devboards/pb1200/board_setup.c |   49 +-
 arch/mips/alchemy/devboards/pb1200/irqmap.c      |   67 +---
 arch/mips/alchemy/devboards/pb1200/platform.c    |  240 ++++++++-
 arch/mips/alchemy/devboards/pb1500/Makefile      |    3 +-
 arch/mips/alchemy/devboards/pb1500/board_setup.c |   10 +-
 arch/mips/alchemy/devboards/pb1500/platform.c    |   83 +++
 arch/mips/alchemy/devboards/pb1550/Makefile      |    3 +-
 arch/mips/alchemy/devboards/pb1550/board_setup.c |   17 +-
 arch/mips/alchemy/devboards/pb1550/platform.c    |  126 +++++
 arch/mips/include/asm/mach-au1x00/au1000.h       |   14 +
 arch/mips/include/asm/mach-db1x00/bcsr.h         |  235 ++++++++
 arch/mips/include/asm/mach-db1x00/db1200.h       |  122 ----
 arch/mips/include/asm/mach-db1x00/db1x00.h       |  100 ----
 arch/mips/include/asm/mach-pb1x00/pb1100.h       |   56 --
 arch/mips/include/asm/mach-pb1x00/pb1200.h       |  121 +----
 arch/mips/include/asm/mach-pb1x00/pb1500.h       |   20 -
 arch/mips/include/asm/mach-pb1x00/pb1550.h       |   96 ----
 drivers/mtd/nand/au1550nd.c                      |    4 +-
 drivers/net/irda/au1k_ir.c                       |   14 +-
 drivers/pcmcia/Kconfig                           |   17 +-
 drivers/pcmcia/Makefile                          |    9 +-
 drivers/pcmcia/au1000_db1x00.c                   |  305 ----------
 drivers/pcmcia/db1xxx_ss.c                       |  649 ++++++++++++++++++++++
 34 files changed, 1860 insertions(+), 999 deletions(-)
 create mode 100644 arch/mips/alchemy/devboards/bcsr.c
 create mode 100644 arch/mips/alchemy/devboards/db1x00/platform.c
 create mode 100644 arch/mips/alchemy/devboards/pb1100/platform.c
 create mode 100644 arch/mips/alchemy/devboards/pb1500/platform.c
 create mode 100644 arch/mips/alchemy/devboards/pb1550/platform.c
 create mode 100644 arch/mips/include/asm/mach-db1x00/bcsr.h
 delete mode 100644 drivers/pcmcia/au1000_db1x00.c
 create mode 100644 drivers/pcmcia/db1xxx_ss.c


From manuel.lauss@googlemail.com Tue Sep 29 20:15:53 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 29 Sep 2009 20:16:00 +0200 (CEST)
Received: from fg-out-1718.google.com ([72.14.220.152]:49488 "EHLO
	fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1493659AbZI2SPa (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 29 Sep 2009 20:15:30 +0200
Received: by fg-out-1718.google.com with SMTP id d23so1694367fga.6
        for <linux-mips@linux-mips.org>; Tue, 29 Sep 2009 11:15:28 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer:in-reply-to:references;
        bh=GQj2XpHL0U9KfMem/DPMTd6qHkGun1+KESZ2BRjB3o4=;
        b=XB6G9LH6lQBkUaMYWqMZ6ojQ8ZFz1zhZ9xLC/8OPu6cfxrEMb3inS2HryCo8fU1V12
         Cks2XhVXsnbtANJeV523dIHO9YaJscT68YLwVoqFIQ/+6rMvY9bvN1ryUtUBisYOu9D7
         JTgmyyLoMKCyEMSQFgjtkhurvzmr4sPG2lyPw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
        b=NTpvcD7X7GvWkCplq/bB2ydzGNTOoYiPyJImptct4fJbN8LQGTqRUA1w0Xt5ZuGWOr
         tWMfcsjf0jd6GaE5zlUN+S3lpB7/Ap3IKAsYbmqkapdD2c3YVZfkvxy/h37o5ZMh7305
         /G+Rczxl83LSh06OvtPHBFQnH8J+l2TL+XHRg=
Received: by 10.86.229.18 with SMTP id b18mr4548465fgh.34.1254248128453;
        Tue, 29 Sep 2009 11:15:28 -0700 (PDT)
Received: from localhost.localdomain (p5496CA2C.dip.t-dialin.net [84.150.202.44])
        by mx.google.com with ESMTPS id 3sm46061fge.23.2009.09.29.11.15.25
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Tue, 29 Sep 2009 11:15:27 -0700 (PDT)
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Linux-MIPS <linux-mips@linux-mips.org>
Cc:	Manuel Lauss <manuel.lauss@gmail.com>,
	linux-pcmcia <linux-pcmcia@lists.infradead.org>
Subject: [PATCH 3/3] Alchemy: new PCMCIA socket driver for devboards.
Date:	Tue, 29 Sep 2009 20:15:14 +0200
Message-Id: <1254248114-4158-4-git-send-email-manuel.lauss@gmail.com>
X-Mailer: git-send-email 1.6.5.rc1
In-Reply-To: <1254248114-4158-3-git-send-email-manuel.lauss@gmail.com>
References: <1254248114-4158-1-git-send-email-manuel.lauss@gmail.com>
 <1254248114-4158-2-git-send-email-manuel.lauss@gmail.com>
 <1254248114-4158-3-git-send-email-manuel.lauss@gmail.com>
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24116
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

New PCMCIA socket driver for all Db/Pb1xxx boards (except Pb1000)
Notable features:
        - it builds for all supported boards!
        - support for carddetect and statuschange (disabled) IRQs.
        - pcmcia socket mem/io/attr areas and irqs passed through
          platform resource information.
        - doesn't freeze system during card insertion/ejection like
          the old one.
	- boardtype is automatically detected using BCSR ID register.

Also add platform device registration and missing interrupts for all
boards supported by this driver.

The PB1000 has different control register scheme and is not supported
by this driver.

Run-tested on Db1200;  however since all of these boards have an
identical PCMCIA setup (at least electrically;  they differ in
IRQs used) I'm fairly confident that it works on them too.

Cc: linux-pcmcia <linux-pcmcia@lists.infradead.org>
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
 arch/mips/alchemy/common/platform.c              |    6 -
 arch/mips/alchemy/common/setup.c                 |    3 +-
 arch/mips/alchemy/devboards/db1x00/Makefile      |    3 +-
 arch/mips/alchemy/devboards/db1x00/irqmap.c      |   18 +-
 arch/mips/alchemy/devboards/db1x00/platform.c    |  164 ++++++
 arch/mips/alchemy/devboards/pb1100/Makefile      |    3 +-
 arch/mips/alchemy/devboards/pb1100/platform.c    |   83 +++
 arch/mips/alchemy/devboards/pb1200/platform.c    |  215 +++++++-
 arch/mips/alchemy/devboards/pb1500/Makefile      |    3 +-
 arch/mips/alchemy/devboards/pb1500/board_setup.c |    3 +
 arch/mips/alchemy/devboards/pb1500/platform.c    |   83 +++
 arch/mips/alchemy/devboards/pb1550/Makefile      |    3 +-
 arch/mips/alchemy/devboards/pb1550/board_setup.c |    6 +
 arch/mips/alchemy/devboards/pb1550/platform.c    |  126 +++++
 arch/mips/include/asm/mach-au1x00/au1000.h       |   14 +
 arch/mips/include/asm/mach-db1x00/db1200.h       |   15 -
 arch/mips/include/asm/mach-db1x00/db1x00.h       |    8 -
 arch/mips/include/asm/mach-pb1x00/pb1100.h       |    7 -
 arch/mips/include/asm/mach-pb1x00/pb1200.h       |   14 -
 arch/mips/include/asm/mach-pb1x00/pb1500.h       |    7 -
 arch/mips/include/asm/mach-pb1x00/pb1550.h       |    7 -
 drivers/pcmcia/Kconfig                           |   17 +-
 drivers/pcmcia/Makefile                          |    9 +-
 drivers/pcmcia/au1000_db1x00.c                   |  307 ----------
 drivers/pcmcia/db1xxx_ss.c                       |  649 ++++++++++++++++++++++
 25 files changed, 1376 insertions(+), 397 deletions(-)
 create mode 100644 arch/mips/alchemy/devboards/db1x00/platform.c
 create mode 100644 arch/mips/alchemy/devboards/pb1100/platform.c
 create mode 100644 arch/mips/alchemy/devboards/pb1500/platform.c
 create mode 100644 arch/mips/alchemy/devboards/pb1550/platform.c
 delete mode 100644 drivers/pcmcia/au1000_db1x00.c
 create mode 100644 drivers/pcmcia/db1xxx_ss.c

diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c
index 117f99f..2b76a57 100644
--- a/arch/mips/alchemy/common/platform.c
+++ b/arch/mips/alchemy/common/platform.c
@@ -308,11 +308,6 @@ static struct platform_device au1200_mmc1_device = {
 #endif /* #ifndef CONFIG_MIPS_DB1200 */
 #endif /* #ifdef CONFIG_SOC_AU1200 */
 
-static struct platform_device au1x00_pcmcia_device = {
-	.name 		= "au1x00-pcmcia",
-	.id 		= 0,
-};
-
 /* All Alchemy demoboards with I2C have this #define in their headers */
 #ifdef SMBUS_PSC_BASE
 static struct resource pbdb_smbus_resources[] = {
@@ -334,7 +329,6 @@ static struct platform_device pbdb_smbus_device = {
 static struct platform_device *au1xxx_platform_devices[] __initdata = {
 	&au1xx0_uart_device,
 	&au1xxx_usb_ohci_device,
-	&au1x00_pcmcia_device,
 #ifdef CONFIG_FB_AU1100
 	&au1100_lcd_device,
 #endif
diff --git a/arch/mips/alchemy/common/setup.c b/arch/mips/alchemy/common/setup.c
index 6184baa..375984e 100644
--- a/arch/mips/alchemy/common/setup.c
+++ b/arch/mips/alchemy/common/setup.c
@@ -107,7 +107,8 @@ phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size)
 	 * The pseudo address we use is 0xF400 0000. Any address over
 	 * 0xF400 0000 is a PCMCIA pseudo address.
 	 */
-	if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF))
+	if ((phys_addr >= PCMCIA_ATTR_PSEUDO_PHYS) &&
+	    (phys_addr < PCMCIA_PSEUDO_END))
 		return (phys_t)(phys_addr << 4);
 
 	/* default nop */
diff --git a/arch/mips/alchemy/devboards/db1x00/Makefile b/arch/mips/alchemy/devboards/db1x00/Makefile
index 432241a..5024d16 100644
--- a/arch/mips/alchemy/devboards/db1x00/Makefile
+++ b/arch/mips/alchemy/devboards/db1x00/Makefile
@@ -5,4 +5,5 @@
 # Makefile for the Alchemy Semiconductor DBAu1xx0 boards.
 #
 
-obj-y := board_setup.o irqmap.o
+obj-y := board_setup.o irqmap.o platform.o
+
diff --git a/arch/mips/alchemy/devboards/db1x00/irqmap.c b/arch/mips/alchemy/devboards/db1x00/irqmap.c
index 0b09025..70b5a9c 100644
--- a/arch/mips/alchemy/devboards/db1x00/irqmap.c
+++ b/arch/mips/alchemy/devboards/db1x00/irqmap.c
@@ -65,23 +65,23 @@ char irq_tab_alchemy[][5] __initdata = {
 
 struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
 
-#ifndef CONFIG_MIPS_MIRAGE
-#ifdef CONFIG_MIPS_DB1550
-	{ AU1000_GPIO_3, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 0 IRQ# */
-	{ AU1000_GPIO_5, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 1 IRQ# */
+#if defined(CONFIG_MIPS_MIRAGE)
+	{ AU1000_GPIO_7,  IRQF_TRIGGER_RISING, 0 }, /* touchscreen pen down */
+#elif defined(CONFIG_MIPS_DB1550)
+	{ AU1000_GPIO_0,  IRQF_TRIGGER_LOW, 0 }, /* PCMCIA CD0# */
+	{ AU1000_GPIO_1,  IRQF_TRIGGER_LOW, 0 }, /* PCMCIA CD1# */
+	{ AU1000_GPIO_3,  IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 0 IRQ# */
+	{ AU1000_GPIO_5,  IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 1 IRQ# */
+	{ AU1500_GPIO_21, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA STSCHG0# */
+	{ AU1500_GPIO_22, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA STSCHG1# */
 #else
 	{ AU1000_GPIO_0, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 0 Fully_Interted# */
 	{ AU1000_GPIO_1, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 0 STSCHG# */
 	{ AU1000_GPIO_2, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 0 IRQ# */
-
 	{ AU1000_GPIO_3, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 1 Fully_Interted# */
 	{ AU1000_GPIO_4, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 1 STSCHG# */
 	{ AU1000_GPIO_5, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card 1 IRQ# */
 #endif
-#else
-	{ AU1000_GPIO_7, IRQF_TRIGGER_RISING, 0 }, /* touchscreen pen down */
-#endif
-
 };
 
 void __init board_init_irq(void)
diff --git a/arch/mips/alchemy/devboards/db1x00/platform.c b/arch/mips/alchemy/devboards/db1x00/platform.c
new file mode 100644
index 0000000..de46243
--- /dev/null
+++ b/arch/mips/alchemy/devboards/db1x00/platform.c
@@ -0,0 +1,164 @@
+/*
+ * DBAu1xxx board platform device registration
+ *
+ * Copyright (C) 2009 Manuel Lauss
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-au1x00/au1xxx.h>
+
+#if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || \
+    defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550)
+#define DB1XXX_HAS_PCMCIA
+#endif
+
+/* DB1xxx PCMCIA interrupt sources:
+ * CD0/1 	GPIO0/3
+ * STSCHG0/1	GPIO1/4
+ * CARD0/1	GPIO2/5
+ * Db1550:	0/1, 21/22, 3/5
+ */
+#ifndef CONFIG_MIPS_DB1550
+/* Db1000, Db1100, Db1500 */
+#define DB1XXX_PCMCIA_CD0	AU1000_GPIO_0
+#define DB1XXX_PCMCIA_STSCHG0	AU1000_GPIO_1
+#define DB1XXX_PCMCIA_CARD0	AU1000_GPIO_2
+#define DB1XXX_PCMCIA_CD1	AU1000_GPIO_3
+#define DB1XXX_PCMCIA_STSCHG1	AU1000_GPIO_4
+#define DB1XXX_PCMCIA_CARD1	AU1000_GPIO_5
+#else
+#define DB1XXX_PCMCIA_CD0	AU1000_GPIO_0
+#define DB1XXX_PCMCIA_STSCHG0	AU1500_GPIO_21
+#define DB1XXX_PCMCIA_CARD0	AU1000_GPIO_3
+#define DB1XXX_PCMCIA_CD1	AU1000_GPIO_1
+#define DB1XXX_PCMCIA_STSCHG1	AU1500_GPIO_22
+#define DB1XXX_PCMCIA_CARD1	AU1000_GPIO_5
+#endif
+
+#ifdef DB1XXX_HAS_PCMCIA
+static struct resource db1xxx_pcmcia0_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x0001000 - 1,
+	},
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1XXX_PCMCIA_CD0,
+		.end	= DB1XXX_PCMCIA_CD0,
+	},
+#if 0 /* more trouble than it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1XXX_PCMCIA_STSCHG0,
+		.end	= DB1XXX_PCMCIA_STSCHG0,
+	},
+#endif
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1XXX_PCMCIA_CARD0,
+		.end	= DB1XXX_PCMCIA_CARD0,
+	},
+};
+
+static struct platform_device db1xxx_pcmcia0_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(db1xxx_pcmcia0_res),
+	.resource	= db1xxx_pcmcia0_res,
+};
+
+/* mem/io resources of 2nd socket at offset 0x00400000 from 1st */
+static struct resource db1xxx_pcmcia1_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00400000,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00440000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS + 0x00400000,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00440000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS + 0x00400000,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x00401000 - 1,
+	},
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1XXX_PCMCIA_CD1,
+		.end	= DB1XXX_PCMCIA_CD1,
+	},
+#if 0 /* more trouble than it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1XXX_PCMCIA_STSCHG1,
+		.end	= DB1XXX_PCMCIA_STSCHG1,
+	},
+#endif
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1XXX_PCMCIA_CARD1,
+		.end	= DB1XXX_PCMCIA_CARD1,
+	},
+};
+
+static struct platform_device db1xxx_pcmcia1_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 1,
+	.num_resources	= ARRAY_SIZE(db1xxx_pcmcia1_res),
+	.resource	= db1xxx_pcmcia1_res,
+};
+#endif
+
+static struct platform_device *db1xxx_devs[] __initdata = {
+#ifdef DB1XXX_HAS_PCMCIA
+	&db1xxx_pcmcia0_dev,
+	&db1xxx_pcmcia1_dev,
+#endif
+};
+
+static int __init db1xxx_dev_init(void)
+{
+	return platform_add_devices(db1xxx_devs, ARRAY_SIZE(db1xxx_devs));
+}
+device_initcall(db1xxx_dev_init);
diff --git a/arch/mips/alchemy/devboards/pb1100/Makefile b/arch/mips/alchemy/devboards/pb1100/Makefile
index c586dd7..60cf5b9 100644
--- a/arch/mips/alchemy/devboards/pb1100/Makefile
+++ b/arch/mips/alchemy/devboards/pb1100/Makefile
@@ -5,4 +5,5 @@
 # Makefile for the Alchemy Semiconductor Pb1100 board.
 #
 
-obj-y := board_setup.o
+obj-y := board_setup.o platform.o
+
diff --git a/arch/mips/alchemy/devboards/pb1100/platform.c b/arch/mips/alchemy/devboards/pb1100/platform.c
new file mode 100644
index 0000000..a579925
--- /dev/null
+++ b/arch/mips/alchemy/devboards/pb1100/platform.c
@@ -0,0 +1,83 @@
+/*
+ * Pb1100 board platform device registration
+ *
+ * Copyright (C) 2009 Manuel Lauss
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-au1x00/au1xxx.h>
+
+/* PCMCIA. single socket, identical to Pb1500 */
+static struct resource pb1100_pcmcia_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x0001000 - 1,
+	},
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_9,
+		.end	= AU1000_GPIO_9,
+	},
+#if 0	/* more trouble than it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_10,
+		.end	= AU1000_GPIO_10,
+	},
+#endif
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_11,
+		.end	= AU1000_GPIO_11,
+	},
+};
+
+static struct platform_device pb1100_pcmcia_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(pb1100_pcmcia_res),
+	.resource	= pb1100_pcmcia_res,
+};
+
+static struct platform_device *pb1100_devs[] __initdata = {
+	&pb1100_pcmcia_dev,
+};
+
+static int __init pb1100_dev_init(void)
+{
+	return platform_add_devices(pb1100_devs, ARRAY_SIZE(pb1100_devs));
+}
+device_initcall(pb1100_dev_init);
diff --git a/arch/mips/alchemy/devboards/pb1200/platform.c b/arch/mips/alchemy/devboards/pb1200/platform.c
index dfdaabf..7abd6a9 100644
--- a/arch/mips/alchemy/devboards/pb1200/platform.c
+++ b/arch/mips/alchemy/devboards/pb1200/platform.c
@@ -163,9 +163,222 @@ static struct platform_device smc91c111_device = {
 	.resource	= smc91c111_resources
 };
 
+/*
+ * PCMCIA socket resources
+ */
+#ifdef CONFIG_MIPS_PB1200
+static struct resource pb1200_pcmcia0_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x0001000 - 1,
+	},
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC0_INT,
+		.end	= PB1200_PC0_INT,
+	},
+#if 0 /* more trouble than what it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC0_STSCHG_INT,
+		.end	= PB1200_PC0_STSCHG_INT,
+	},
+#endif
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC0_INSERT_INT,
+		.end	= PB1200_PC0_INSERT_INT,
+	},
+	{
+		.name	= "eject",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC0_EJECT_INT,
+		.end	= PB1200_PC0_EJECT_INT,
+	},
+};
+
+/* mem/io resources of 2nd socket at offset 0x00800000 from 1st */
+static struct resource pb1200_pcmcia1_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00800000,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00840000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS + 0x00800000,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00840000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS + 0x00800000,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x00801000 - 1,
+	},
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC1_INT,
+		.end	= PB1200_PC1_INT,
+	},
+#if 0	/* too much trouble than what it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC1_STSCHG_INT,
+		.end	= PB1200_PC1_STSCHG_INT,
+	},
+#endif
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC1_INSERT_INT,
+		.end	= PB1200_PC1_INSERT_INT,
+	},
+	{
+		.name	= "eject",
+		.flags	= IORESOURCE_IRQ,
+		.start	= PB1200_PC1_EJECT_INT,
+		.end	= PB1200_PC1_EJECT_INT,
+	},
+};
+
+#else	/* must be DB1200 */
+
+static struct resource pb1200_pcmcia0_res[] = {	/* DB1200 socket 0 */
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x0001000 - 1,
+	},
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC0_INT,
+		.end	= DB1200_PC0_INT,
+	},
+#if 0 /* more trouble than it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC0_STSCHG_INT,
+		.end	= DB1200_PC0_STSCHG_INT,
+	},
+#endif
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC0_INSERT_INT,
+		.end	= DB1200_PC0_INSERT_INT,
+	},
+	{
+		.name	= "eject",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC0_EJECT_INT,
+		.end	= DB1200_PC0_EJECT_INT,
+	},
+};
+
+/* mem/io resources of 2nd socket at offset 0x00400000 from 1st */
+static struct resource pb1200_pcmcia1_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00400000,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00440000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS + 0x00400000,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00440000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS + 0x00400000,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x00401000 - 1,
+	},
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC1_INT,
+		.end	= DB1200_PC1_INT,
+	},
+#if 0 /* more trouble than it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC1_STSCHG_INT,
+		.end	= DB1200_PC1_STSCHG_INT,
+	},
+#endif
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC1_INSERT_INT,
+		.end	= DB1200_PC1_INSERT_INT,
+	},
+	{
+		.name	= "eject",
+		.flags	= IORESOURCE_IRQ,
+		.start	= DB1200_PC1_EJECT_INT,
+		.end	= DB1200_PC1_EJECT_INT,
+	},
+};
+#endif
+
+static struct platform_device pb1200_pcmcia0_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(pb1200_pcmcia0_res),
+	.resource	= pb1200_pcmcia0_res,
+};
+
+static struct platform_device pb1200_pcmcia1_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 1,
+	.num_resources	= ARRAY_SIZE(pb1200_pcmcia1_res),
+	.resource	= pb1200_pcmcia1_res,
+};
+
 static struct platform_device *board_platform_devices[] __initdata = {
 	&ide_device,
-	&smc91c111_device
+	&smc91c111_device,
+	&pb1200_pcmcia0_dev,
+	&pb1200_pcmcia1_dev
 };
 
 static int __init board_register_devices(void)
diff --git a/arch/mips/alchemy/devboards/pb1500/Makefile b/arch/mips/alchemy/devboards/pb1500/Makefile
index 173b419..c29545d 100644
--- a/arch/mips/alchemy/devboards/pb1500/Makefile
+++ b/arch/mips/alchemy/devboards/pb1500/Makefile
@@ -5,4 +5,5 @@
 # Makefile for the Alchemy Semiconductor Pb1500 board.
 #
 
-obj-y := board_setup.o
+obj-y := board_setup.o platform.o
+
diff --git a/arch/mips/alchemy/devboards/pb1500/board_setup.c b/arch/mips/alchemy/devboards/pb1500/board_setup.c
index c5389e5..7439303 100644
--- a/arch/mips/alchemy/devboards/pb1500/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1500/board_setup.c
@@ -41,6 +41,9 @@ char irq_tab_alchemy[][5] __initdata = {
 };
 
 struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
+	{ AU1000_GPIO_9,   IRQF_TRIGGER_LOW, 0 },
+	{ AU1000_GPIO_10,  IRQF_TRIGGER_LOW, 0 },
+	{ AU1000_GPIO_11,  IRQF_TRIGGER_LOW, 0 },
 	{ AU1500_GPIO_204, IRQF_TRIGGER_HIGH, 0 },
 	{ AU1500_GPIO_201, IRQF_TRIGGER_LOW, 0 },
 	{ AU1500_GPIO_202, IRQF_TRIGGER_LOW, 0 },
diff --git a/arch/mips/alchemy/devboards/pb1500/platform.c b/arch/mips/alchemy/devboards/pb1500/platform.c
new file mode 100644
index 0000000..4bd1ee1
--- /dev/null
+++ b/arch/mips/alchemy/devboards/pb1500/platform.c
@@ -0,0 +1,83 @@
+/*
+ * Pb1500 board platform device registration
+ *
+ * Copyright (C) 2009 Manuel Lauss
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-au1x00/au1xxx.h>
+
+/* PCMCIA: single socket, identical to PB1100 */
+static struct resource pb1500_pcmcia_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x0001000 - 1,
+	},
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_9,
+		.end	= AU1000_GPIO_9,
+	},
+#if 0 /* more trouble than it's worth */
+	{
+		.name	= "stschg",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_10,
+		.end	= AU1000_GPIO_10,
+	},
+#endif
+	{
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_11,
+		.end	= AU1000_GPIO_11,
+	},
+};
+
+static struct platform_device pb1500_pcmcia_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(pb1500_pcmcia_res),
+	.resource	= pb1500_pcmcia_res,
+};
+
+static struct platform_device *pb1500_devs[] __initdata = {
+	&pb1500_pcmcia_dev,
+};
+
+static int __init pb1500_dev_init(void)
+{
+	return platform_add_devices(pb1500_devs, ARRAY_SIZE(pb1500_devs));
+}
+device_initcall(pb1500_dev_init);
diff --git a/arch/mips/alchemy/devboards/pb1550/Makefile b/arch/mips/alchemy/devboards/pb1550/Makefile
index cff95bc..86b410b 100644
--- a/arch/mips/alchemy/devboards/pb1550/Makefile
+++ b/arch/mips/alchemy/devboards/pb1550/Makefile
@@ -5,4 +5,5 @@
 # Makefile for the Alchemy Semiconductor Pb1550 board.
 #
 
-obj-y := board_setup.o
+obj-y := board_setup.o platform.o
+
diff --git a/arch/mips/alchemy/devboards/pb1550/board_setup.c b/arch/mips/alchemy/devboards/pb1550/board_setup.c
index af7a1b5..957e3ae 100644
--- a/arch/mips/alchemy/devboards/pb1550/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1550/board_setup.c
@@ -33,6 +33,7 @@
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-pb1x00/pb1550.h>
 #include <asm/mach-db1x00/bcsr.h>
+#include <asm/mach-au1x00/gpio.h>
 
 #include <prom.h>
 
@@ -45,6 +46,7 @@ char irq_tab_alchemy[][5] __initdata = {
 struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
 	{ AU1000_GPIO_0, IRQF_TRIGGER_LOW, 0 },
 	{ AU1000_GPIO_1, IRQF_TRIGGER_LOW, 0 },
+	{ AU1500_GPIO_201_205, IRQF_TRIGGER_LOW, 0 },
 };
 
 const char *get_system_type(void)
@@ -59,6 +61,8 @@ void board_reset(void)
 
 void __init board_init_irq(void)
 {
+	alchemy_gpio2_enable_int(201);
+	alchemy_gpio2_enable_int(202);
 	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
 }
 
@@ -80,6 +84,8 @@ void __init board_setup(void)
 	}
 #endif
 
+	alchemy_gpio2_enable();
+
 	/*
 	 * Enable PSC1 SYNC for AC'97.  Normaly done in audio driver,
 	 * but it is board specific code, so put it here.
diff --git a/arch/mips/alchemy/devboards/pb1550/platform.c b/arch/mips/alchemy/devboards/pb1550/platform.c
new file mode 100644
index 0000000..30170f4
--- /dev/null
+++ b/arch/mips/alchemy/devboards/pb1550/platform.c
@@ -0,0 +1,126 @@
+/*
+ * Pb1550 board platform device registration
+ *
+ * Copyright (C) 2009 Manuel Lauss
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-au1x00/au1000.h>
+#include <asm/mach-pb1x00/pb1550.h>
+
+/* Pb1550, like all others, also has statuschange irqs; however they're
+ * wired up on one of the Au1550's shared GPIO201_205 line, which also
+ * services the PCMCIA card interrupts.  So we ignore statuschange and
+ * use the GPIO201_205 exclusively for card interrupts, since a) pcmcia
+ * drivers are used to shared irqs and b) statuschange isn't really use-
+ * ful anyway.
+ */
+static struct resource pb1550_pcmcia0_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00040000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x0001000 - 1,
+	},
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_0,
+		.end	= AU1000_GPIO_0,
+	},
+	{ /* is GPIO_201, but this one shares an IRQ with 201-205 */
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1500_GPIO_201_205,
+		.end	= AU1500_GPIO_201_205,
+	},
+};
+
+static struct platform_device pb1550_pcmcia0_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(pb1550_pcmcia0_res),
+	.resource	= pb1550_pcmcia0_res,
+};
+
+/* mem/io resources of 2nd socket at offset 0x00800000 from 1st */
+static struct resource pb1550_pcmcia1_res[] = {
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00800000,
+		.end	= PCMCIA_ATTR_PSEUDO_PHYS + 0x00840000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_MEM_PSEUDO_PHYS + 0x00800000,
+		.end	= PCMCIA_MEM_PSEUDO_PHYS + 0x00840000 - 1,
+	},
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= PCMCIA_IO_PSEUDO_PHYS + 0x00800000,
+		.end	= PCMCIA_IO_PSEUDO_PHYS + 0x00801000 - 1,
+	},
+	{
+		.name	= "insert",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1000_GPIO_1,
+		.end	= AU1000_GPIO_1,
+	},
+	{ /* is GPIO_202, but this one shares an IRQ with 201-205 */
+		.name	= "card",
+		.flags	= IORESOURCE_IRQ,
+		.start	= AU1500_GPIO_201_205,
+		.end	= AU1500_GPIO_201_205,
+	},
+};
+
+static struct platform_device pb1550_pcmcia1_dev = {
+	.name		= "db1xxx_pcmcia",
+	.id		= 1,
+	.num_resources	= ARRAY_SIZE(pb1550_pcmcia1_res),
+	.resource	= pb1550_pcmcia1_res,
+};
+
+static struct platform_device *pb1550_devs[] __initdata = {
+	&pb1550_pcmcia0_dev,
+	&pb1550_pcmcia1_dev
+};
+
+static int __init pb1550_dev_init(void)
+{
+	return platform_add_devices(pb1550_devs,
+				    ARRAY_SIZE(pb1550_devs));
+}
+device_initcall(pb1550_dev_init);
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
index 854e95f..df04e91 100644
--- a/arch/mips/include/asm/mach-au1x00/au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -1739,6 +1739,20 @@ enum soc_au1200_ints {
 
 #endif
 
+/*
+ * All Au1xx0 SOCs have a PCMCIA controller.
+ * We setup our 32-bit pseudo addresses to be equal to the
+ * 36-bit addr >> 4, to make it easier to check the address
+ * and fix it.
+ * The PCMCIA socket 0 physical attribute address is 0xF 4000 0000.
+ * The pseudo address we use is 0xF400 0000. Any address over
+ * 0xF400 0000 is a PCMCIA pseudo address.
+ */
+#define PCMCIA_IO_PSEUDO_PHYS	(PCMCIA_IO_PHYS_ADDR >> 4)
+#define PCMCIA_ATTR_PSEUDO_PHYS	(PCMCIA_ATTR_PHYS_ADDR >> 4)
+#define PCMCIA_MEM_PSEUDO_PHYS	(PCMCIA_MEM_PHYS_ADDR >> 4)
+#define PCMCIA_PSEUDO_END	(0xffffffff)
+
 #ifndef _LANGUAGE_ASSEMBLY
 typedef volatile struct {
 	/* 0x0000 */ u32 toytrim;
diff --git a/arch/mips/include/asm/mach-db1x00/db1200.h b/arch/mips/include/asm/mach-db1x00/db1200.h
index 2909b83..1fbcca4 100644
--- a/arch/mips/include/asm/mach-db1x00/db1200.h
+++ b/arch/mips/include/asm/mach-db1x00/db1200.h
@@ -102,21 +102,6 @@ enum external_pb1200_ints {
 	DB1200_INT_END		= DB1200_INT_BEGIN + 15,
 };
 
-
-/*
- * DBAu1200 specific PCMCIA defines for drivers/pcmcia/au1000_db1x00.c
- */
-#define PCMCIA_MAX_SOCK  1
-#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
-
-/* VPP/VCC */
-#define SET_VCC_VPP(VCC, VPP, SLOT) \
-	((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
-
-#define BOARD_PC0_INT	DB1200_PC0_INT
-#define BOARD_PC1_INT	DB1200_PC1_INT
-#define BOARD_CARD_INSERTED(SOCKET) (bcsr_read(BCSR_SIGSTAT) & (1 << (8 + (2 * SOCKET))))
-
 /* NAND chip select */
 #define NAND_CS 1
 
diff --git a/arch/mips/include/asm/mach-db1x00/db1x00.h b/arch/mips/include/asm/mach-db1x00/db1x00.h
index cfa6429..a919dac 100644
--- a/arch/mips/include/asm/mach-db1x00/db1x00.h
+++ b/arch/mips/include/asm/mach-db1x00/db1x00.h
@@ -45,14 +45,6 @@
 
 #endif
 
-/* PCMCIA DBAu1x00 specific defines */
-#define PCMCIA_MAX_SOCK  1
-#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
-
-/* VPP/VCC */
-#define SET_VCC_VPP(VCC, VPP, SLOT)\
-	((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
-
 /*
  * NAND defines
  *
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1100.h b/arch/mips/include/asm/mach-pb1x00/pb1100.h
index f2bf73a..d75fbbd 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1100.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1100.h
@@ -26,11 +26,4 @@
 #ifndef __ASM_PB1100_H
 #define __ASM_PB1100_H
 
-/* PCMCIA Pb1100 specific defines */
-#define PCMCIA_MAX_SOCK  0
-#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
-
-/* VPP/VCC */
-#define SET_VCC_VPP(VCC, VPP) (((VCC) << 2) | ((VPP) << 0))
-
 #endif /* __ASM_PB1100_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1200.h b/arch/mips/include/asm/mach-pb1x00/pb1200.h
index a51512c..07ad170 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1200.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1200.h
@@ -134,20 +134,6 @@ enum external_pb1200_ints {
 	PB1200_INT_END		= PB1200_INT_BEGIN + 15
 };
 
-/*
- * Pb1200 specific PCMCIA defines for drivers/pcmcia/au1000_db1x00.c
- */
-#define PCMCIA_MAX_SOCK  1
-#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
-
-/* VPP/VCC */
-#define SET_VCC_VPP(VCC, VPP, SLOT) \
-	((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
-
-#define BOARD_PC0_INT	PB1200_PC0_INT
-#define BOARD_PC1_INT	PB1200_PC1_INT
-#define BOARD_CARD_INSERTED(SOCKET) (bcsr_read(BCSR_SIGSTAT & (1 << (8 + (2 * SOCKET))))
-
 /* NAND chip select */
 #define NAND_CS 1
 
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1500.h b/arch/mips/include/asm/mach-pb1x00/pb1500.h
index 82431a7..ade9071 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1500.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1500.h
@@ -26,11 +26,4 @@
 #ifndef __ASM_PB1500_H
 #define __ASM_PB1500_H
 
-/* PCMCIA Pb1500 specific defines */
-#define PCMCIA_MAX_SOCK  0
-#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
-
-/* VPP/VCC */
-#define SET_VCC_VPP(VCC, VPP) (((VCC) << 2) | ((VPP) << 0))
-
 #endif /* __ASM_PB1500_H */
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1550.h b/arch/mips/include/asm/mach-pb1x00/pb1550.h
index 306d584..5879641 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1550.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1550.h
@@ -40,13 +40,6 @@
 #define SMBUS_PSC_BASE		PSC2_BASE_ADDR
 #define I2S_PSC_BASE		PSC3_BASE_ADDR
 
-#define PCMCIA_MAX_SOCK  1
-#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
-
-/* VPP/VCC */
-#define SET_VCC_VPP(VCC, VPP, SLOT) \
-	((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
-
 #if defined(CONFIG_MTD_PB1550_BOOT) && defined(CONFIG_MTD_PB1550_USER)
 #define PB1550_BOTH_BANKS
 #elif defined(CONFIG_MTD_PB1550_BOOT) && !defined(CONFIG_MTD_PB1550_USER)
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index fbf965b..58e4277 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -82,7 +82,7 @@ config PCMCIA_IOCTL
 	  If unsure, say Y.
 
 config CARDBUS
-	bool "32-bit CardBus support"	
+	bool "32-bit CardBus support"
 	depends on PCI
 	default y
 	---help---
@@ -105,8 +105,8 @@ config YENTA
 	select PCCARD_NONSTATIC
 	---help---
 	  This option enables support for CardBus host bridges.  Virtually
-	  all modern PCMCIA bridges are CardBus compatible.  A "bridge" is 
-	  the hardware inside your computer that PCMCIA cards are plugged 
+	  all modern PCMCIA bridges are CardBus compatible.  A "bridge" is
+	  the hardware inside your computer that PCMCIA cards are plugged
 	  into.
 
 	  To compile this driver as modules, choose M here: the
@@ -192,6 +192,17 @@ config PCMCIA_AU1X00
 	tristate "Au1x00 pcmcia support"
 	depends on SOC_AU1X00 && PCMCIA
 
+config PCMCIA_ALCHEMY_DEVBOARD
+	tristate "Alchemy Db/Pb1xxx PCMCIA socket services"
+	depends on SOC_AU1X00 && PCMCIA
+	select 64BIT_PHYS_ADDR
+	help
+	  Enable this driver of you want PCMCIA support on your Alchemy
+	  Db1000, Db/Pb1100, Db/Pb1500, Db/Pb1550, Db/Pb1200 board.
+	  NOT suitable for the PB1000!
+
+	  This driver is also available as a module called db1xxx_ss.ko
+
 config PCMCIA_SA1100
 	tristate "SA1100 support"
 	depends on ARM && ARCH_SA1100 && PCMCIA
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 3247828..f188912 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -33,20 +33,13 @@ obj-$(CONFIG_OMAP_CF)				+= omap_cf.o
 obj-$(CONFIG_BFIN_CFPCMCIA)			+= bfin_cf_pcmcia.o
 obj-$(CONFIG_AT91_CF)				+= at91_cf.o
 obj-$(CONFIG_ELECTRA_CF)			+= electra_cf.o
+obj-$(CONFIG_PCMCIA_ALCHEMY_DEVBOARD)		+= db1xxx_ss.o
 
 sa11xx_core-y					+= soc_common.o sa11xx_base.o
 pxa2xx_core-y					+= soc_common.o pxa2xx_base.o
 
 au1x00_ss-y					+= au1000_generic.o
 au1x00_ss-$(CONFIG_MIPS_PB1000)			+= au1000_pb1x00.o
-au1x00_ss-$(CONFIG_MIPS_PB1100)			+= au1000_pb1x00.o
-au1x00_ss-$(CONFIG_MIPS_PB1200)			+= au1000_db1x00.o
-au1x00_ss-$(CONFIG_MIPS_PB1500)			+= au1000_pb1x00.o
-au1x00_ss-$(CONFIG_MIPS_DB1000)			+= au1000_db1x00.o
-au1x00_ss-$(CONFIG_MIPS_DB1100)			+= au1000_db1x00.o
-au1x00_ss-$(CONFIG_MIPS_DB1200)			+= au1000_db1x00.o
-au1x00_ss-$(CONFIG_MIPS_DB1500)			+= au1000_db1x00.o
-au1x00_ss-$(CONFIG_MIPS_DB1550)			+= au1000_db1x00.o
 au1x00_ss-$(CONFIG_MIPS_XXS1500)		+= au1000_xxs1500.o
 
 sa1111_cs-y					+= sa1111_generic.o
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c
deleted file mode 100644
index 6832254..0000000
--- a/drivers/pcmcia/au1000_db1x00.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- *
- * Alchemy Semi Db1x00 boards specific pcmcia routines.
- *
- * Copyright 2002 MontaVista Software Inc.
- * Author: MontaVista Software, Inc.
- *         	ppopov@mvista.com or source@mvista.com
- *
- * Copyright 2004 Pete Popov, updated the driver to 2.6.
- * Followed the sa11xx API and largely copied many of the hardware
- * independent functions.
- *
- * ########################################################################
- *
- *  This program is free software; you can distribute it and/or modify it
- *  under the terms of the GNU General Public License (Version 2) as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * ########################################################################
- *
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/device.h>
-#include <linux/init.h>
-
-#include <asm/irq.h>
-#include <asm/signal.h>
-#include <asm/mach-au1x00/au1000.h>
-
-#if defined(CONFIG_MIPS_DB1200)
-	#include <db1200.h>
-#elif defined(CONFIG_MIPS_PB1200)
-	#include <pb1200.h>
-#else
-	#include <asm/mach-db1x00/db1x00.h>
-#endif
-
-#include <asm/mach-db1x00/bcsr.h>
-#include "au1000_generic.h"
-
-#if 0
-#define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args)
-#else
-#define debug(x,args...)
-#endif
-
-
-struct au1000_pcmcia_socket au1000_pcmcia_socket[PCMCIA_NUM_SOCKS];
-extern int au1x00_pcmcia_socket_probe(struct device *, struct pcmcia_low_level *, int, int);
-
-static int db1x00_pcmcia_hw_init(struct au1000_pcmcia_socket *skt)
-{
-#ifdef CONFIG_MIPS_DB1550
-	skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_3;
-#elif defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
-	skt->irq = skt->nr ? BOARD_PC1_INT : BOARD_PC0_INT;
-#else
-	skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_2;
-#endif
-	return 0;
-}
-
-static void db1x00_pcmcia_shutdown(struct au1000_pcmcia_socket *skt)
-{
-	bcsr_write(BCSR_PCMCIA, 0);	/* turn off power */
-	msleep(2);
-}
-
-static void
-db1x00_pcmcia_socket_state(struct au1000_pcmcia_socket *skt, struct pcmcia_state *state)
-{
-	u32 inserted;
-	unsigned char vs;
-
-	state->ready = 0;
-	state->vs_Xv = 0;
-	state->vs_3v = 0;
-	state->detect = 0;
-
-	switch (skt->nr) {
-	case 0:
-		vs = bcsr_read(BCSR_STATUS) & 0x3;
-#if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
-		inserted = BOARD_CARD_INSERTED(0);
-#else
-		inserted = !(bcsr_read(BCSR_STATUS) & (1 << 4));
-#endif
-		break;
-	case 1:
-		vs = (bcsr_read(BCSR_STATUS) & 0xC) >> 2;
-#if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
-		inserted = BOARD_CARD_INSERTED(1);
-#else
-		inserted = !(bcsr_read(BCSR_STATUS) & (1<<5));
-#endif
-		break;
-	default:/* should never happen */
-		return;
-	}
-
-	if (inserted)
-		debug("db1x00 socket %d: inserted %d, vs %d pcmcia %x\n",
-				skt->nr, inserted, vs, bcsr_read(BCSR_PCMCIA));
-
-	if (inserted) {
-		switch (vs) {
-			case 0:
-			case 2:
-				state->vs_3v=1;
-				break;
-			case 3: /* 5V */
-				break;
-			default:
-				/* return without setting 'detect' */
-				printk(KERN_ERR "db1x00 bad VS (%d)\n",
-						vs);
-		}
-		state->detect = 1;
-		state->ready = 1;
-	}
-	else {
-		/* if the card was previously inserted and then ejected,
-		 * we should turn off power to it
-		 */
-		if ((skt->nr == 0) &&
-		    (bcsr_read(BCSR_PCMCIA) & BCSR_PCMCIA_PC0RST)) {
-			bcsr_mod(BCSR_PCMCIA, BCSR_PCMCIA_PC0RST   |
-					      BCSR_PCMCIA_PC0DRVEN |
-					      BCSR_PCMCIA_PC0VPP   |
-					      BCSR_PCMCIA_PC0VCC, 0);
-			msleep(10);
-		}
-		else if ((skt->nr == 1) &&
-			 (bcsr_read(BCSR_PCMCIA) & BCSR_PCMCIA_PC1RST)) {
-			bcsr_mod(BCSR_PCMCIA, BCSR_PCMCIA_PC1RST   |
-					      BCSR_PCMCIA_PC1DRVEN |
-					      BCSR_PCMCIA_PC1VPP   |
-					      BCSR_PCMCIA_PC1VCC, 0);
-			msleep(10);
-		}
-	}
-
-	state->bvd1=1;
-	state->bvd2=1;
-	state->wrprot=0;
-}
-
-static int
-db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_state_t *state)
-{
-	u16 pwr;
-	int sock = skt->nr;
-
-	debug("config_skt %d Vcc %dV Vpp %dV, reset %d\n",
-			sock, state->Vcc, state->Vpp,
-			state->flags & SS_RESET);
-
-	/* pcmcia reg was set to zero at init time. Be careful when
-	 * initializing a socket not to wipe out the settings of the
-	 * other socket.
-	 */
-	pwr = bcsr_read(BCSR_PCMCIA);
-	pwr &= ~(0xf << sock*8); /* clear voltage settings */
-
-	state->Vpp = 0;
-	switch(state->Vcc){
-		case 0:  /* Vcc 0 */
-			pwr |= SET_VCC_VPP(0,0,sock);
-			break;
-		case 50: /* Vcc 5V */
-			switch(state->Vpp) {
-				case 0:
-					pwr |= SET_VCC_VPP(2,0,sock);
-					break;
-				case 50:
-					pwr |= SET_VCC_VPP(2,1,sock);
-					break;
-				case 12:
-					pwr |= SET_VCC_VPP(2,2,sock);
-					break;
-				case 33:
-				default:
-					pwr |= SET_VCC_VPP(0,0,sock);
-					printk("%s: bad Vcc/Vpp (%d:%d)\n",
-							__func__,
-							state->Vcc,
-							state->Vpp);
-					break;
-			}
-			break;
-		case 33: /* Vcc 3.3V */
-			switch(state->Vpp) {
-				case 0:
-					pwr |= SET_VCC_VPP(1,0,sock);
-					break;
-				case 12:
-					pwr |= SET_VCC_VPP(1,2,sock);
-					break;
-				case 33:
-					pwr |= SET_VCC_VPP(1,1,sock);
-					break;
-				case 50:
-				default:
-					pwr |= SET_VCC_VPP(0,0,sock);
-					printk("%s: bad Vcc/Vpp (%d:%d)\n",
-							__func__,
-							state->Vcc,
-							state->Vpp);
-					break;
-			}
-			break;
-		default: /* what's this ? */
-			pwr |= SET_VCC_VPP(0,0,sock);
-			printk(KERN_ERR "%s: bad Vcc %d\n",
-					__func__, state->Vcc);
-			break;
-	}
-
-	bcsr_write(BCSR_PCMCIA, pwr);
-	msleep(3);
-
-	if (sock == 0) {
-		if (!(state->flags & SS_RESET)) {
-			pwr |= BCSR_PCMCIA_PC0DRVEN;
-			bcsr_write(BCSR_PCMCIA, pwr);
-			msleep(300);
-			pwr |= BCSR_PCMCIA_PC0RST;
-			bcsr_write(BCSR_PCMCIA, pwr);
-			msleep(100);
-		}
-		else {
-			pwr &= ~(BCSR_PCMCIA_PC0RST | BCSR_PCMCIA_PC0DRVEN);
-			bcsr_write(BCSR_PCMCIA, pwr);
-			msleep(100);
-		}
-	}
-	else {
-		if (!(state->flags & SS_RESET)) {
-			pwr |= BCSR_PCMCIA_PC1DRVEN;
-			bcsr_write(BCSR_PCMCIA, pwr);
-			msleep(300);
-			pwr |= BCSR_PCMCIA_PC1RST;
-			bcsr_write(BCSR_PCMCIA, pwr);
-			msleep(100);
-		}
-		else {
-			pwr &= ~(BCSR_PCMCIA_PC1RST | BCSR_PCMCIA_PC1DRVEN);
-			bcsr_write(BCSR_PCMCIA, pwr);
-			msleep(100);
-		}
-	}
-	return 0;
-}
-
-/*
- * Enable card status IRQs on (re-)initialisation.  This can
- * be called at initialisation, power management event, or
- * pcmcia event.
- */
-void db1x00_socket_init(struct au1000_pcmcia_socket *skt)
-{
-	/* nothing to do for now */
-}
-
-/*
- * Disable card status IRQs and PCMCIA bus on suspend.
- */
-void db1x00_socket_suspend(struct au1000_pcmcia_socket *skt)
-{
-	/* nothing to do for now */
-}
-
-struct pcmcia_low_level db1x00_pcmcia_ops = {
-	.owner			= THIS_MODULE,
-
-	.hw_init 		= db1x00_pcmcia_hw_init,
-	.hw_shutdown		= db1x00_pcmcia_shutdown,
-
-	.socket_state		= db1x00_pcmcia_socket_state,
-	.configure_socket	= db1x00_pcmcia_configure_socket,
-
-	.socket_init		= db1x00_socket_init,
-	.socket_suspend		= db1x00_socket_suspend
-};
-
-int au1x_board_init(struct device *dev)
-{
-	int ret = -ENODEV;
-	bcsr_write(BCSR_PCMCIA, 0); /* turn off power, if it's not already off */
-	msleep(2);
-	ret = au1x00_pcmcia_socket_probe(dev, &db1x00_pcmcia_ops, 0, 2);
-	return ret;
-}
diff --git a/drivers/pcmcia/db1xxx_ss.c b/drivers/pcmcia/db1xxx_ss.c
new file mode 100644
index 0000000..349f86c
--- /dev/null
+++ b/drivers/pcmcia/db1xxx_ss.c
@@ -0,0 +1,649 @@
+/*
+ * PCMCIA socket code for the Alchemy Db1xxx/Pb1xxx boards.
+ *
+ * Copyright (c) 2009 Manuel Lauss <manuel.lauss@gmail.com>
+ *
+ */
+
+/* This is a fairly generic PCMCIA socket driver suitable for the
+ * following Alchemy Development boards:
+ *  Db1000, Db/Pb1500, Db/Pb1100, Db/Pb1550, Db/Pb1200.
+ *
+ * The PB1000 is rather ... special... and not yet supported.
+ *
+ * The Db1000 is used as a reference:  Per-socket card-, carddetect- and
+ *  statuschange IRQs connected to SoC GPIOs, control and status register
+ *  bits arranged in per-socket groups in an external PLD.  All boards
+ *  listed here use this layout, including bit positions and meanings.
+ *  Of course there are exceptions in later boards:
+ *
+ *	- Pb1100/Pb1500:  single socket only; voltage key bits VS are
+ *			  at STATUS[5:4] (instead of STATUS[1:0]).
+ *	- Au1550-based:   control regs are at different base address.
+ *	- Au1200-based:   control regs are at different base address,
+ *			  additional card-eject irqs, irqs not gpios!
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/pm.h>
+#include <linux/platform_device.h>
+#include <linux/resource.h>
+#include <linux/spinlock.h>
+
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/ss.h>
+#include <pcmcia/cistpl.h>
+
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/mach-au1x00/au1000.h>
+#include <asm/mach-db1x00/bcsr.h>
+
+#define MEM_MAP_SIZE	0x400000
+#define IO_MAP_SIZE	0x1000
+
+struct db1x_pcmcia_sock {
+	struct pcmcia_socket	socket;
+	int		nr;		/* socket number */
+	void		*virt_io;
+
+	/* the "pseudo" addresses of the PCMCIA space. */
+	unsigned long	phys_io;
+	unsigned long	phys_attr;
+	unsigned long	phys_mem;
+
+	/* previous flags for set_socket() */
+	unsigned int old_flags;
+
+	/* interrupt sources.  Real linux irq numbers, NOT the GPIO pins! */
+	int	insert_irq;	/* default carddetect irq */
+	int	stschg_irq;	/* card-status-change irq */
+	int	card_irq;	/* card irq */
+	int	eject_irq;	/* db1200/pb1200 have these */
+
+#define BOARD_TYPE_DEFAULT	0	/* most Db1x boards */
+#define BOARD_TYPE_DB1200	1	/* IRQs aren't gpios */
+#define BOARD_TYPE_PB1100	2	/* VS bits slightly different */
+	int	board_type;
+};
+
+#define to_db1x_socket(x) container_of(x, struct db1x_pcmcia_sock, socket)
+
+/*
+ * card in socket for DB1200/PB1200:  Check CPLD SigStatus register;
+ * bits 10/12 are 1 if a card is in the socket (0/1)
+ */
+static int db1200_card_inserted(struct db1x_pcmcia_sock *sock)
+{
+	unsigned short sigstat;
+
+	sigstat = bcsr_read(BCSR_SIGSTAT);
+	return sigstat & 1 << (8 + 2 * sock->nr);
+}
+
+/*
+ * Check the carddetect-gpio: if it's low, then there's a card.
+ */
+static int db1000_card_inserted(struct db1x_pcmcia_sock *sock)
+{
+	return !gpio_get_value(irq_to_gpio(sock->insert_irq));
+}
+
+static int db1x_card_inserted(struct db1x_pcmcia_sock *sock)
+{
+	switch (sock->board_type) {
+	case BOARD_TYPE_DB1200:
+		return db1200_card_inserted(sock);
+	default:
+		return db1000_card_inserted(sock);
+	}
+}
+
+/* STSCHG tends to bounce heavily when cards are inserted/ejected.
+ * To avoid this, the interrupt is normally disabled and only enabled
+ * after reset to a card has been de-asserted.
+ */
+static inline void set_stschg(struct db1x_pcmcia_sock *sock, int en)
+{
+	if (sock->stschg_irq != -1) {
+		if (en)
+			enable_irq(sock->stschg_irq);
+		else
+			disable_irq(sock->stschg_irq);
+	}
+}
+
+static irqreturn_t db1000_pcmcia_cdirq(int irq, void *data)
+{
+	struct db1x_pcmcia_sock *sock = data;
+
+	pcmcia_parse_events(&sock->socket, SS_DETECT);
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t db1000_pcmcia_stschgirq(int irq, void *data)
+{
+	struct db1x_pcmcia_sock *sock = data;
+
+	pcmcia_parse_events(&sock->socket, SS_STSCHG);
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t db1200_pcmcia_cdirq(int irq, void *data)
+{
+	struct db1x_pcmcia_sock *sock = data;
+
+	/* Db/Pb1200 have separate per-socket insertion and ejection
+	 * interrupts which stay asserted as long as the card is
+	 * inserted/missing.  The one which caused us to be called
+	 * needs to be disabled and the other one enabled.
+	 */
+	if (irq == sock->insert_irq) {
+		disable_irq_nosync(sock->insert_irq);
+		enable_irq(sock->eject_irq);
+	} else {
+		disable_irq_nosync(sock->eject_irq);
+		enable_irq(sock->insert_irq);
+	}
+
+	pcmcia_parse_events(&sock->socket, SS_DETECT);
+
+	return IRQ_HANDLED;
+}
+
+static int db1x_pcmcia_setup_irqs(struct db1x_pcmcia_sock *sock)
+{
+	int ret;
+	unsigned long flags;
+
+	if (sock->stschg_irq != -1) {
+		ret = request_irq(sock->stschg_irq, db1000_pcmcia_stschgirq,
+				  0, "pcmcia_stschg", sock);
+		if (ret)
+			return ret;
+	}
+
+	/* Db/Pb1200 have separate per-socket insertion and ejection
+	 * interrupts.  The manual says they're supposed to be edge, but
+	 * they ejection/insertion IRQ stay asserted as long as a card
+	 * is missing/inserted.  The IRQ handler disables the one
+	 * which triggered and unmasks its companion, however this can
+	 * cause "unbalanced enable_irq()" messages as it enables the
+	 * one IRQ currently not requested.  So IRQs are disabled until
+	 * both have been requested.
+	 */
+	if (sock->board_type == BOARD_TYPE_DB1200) {
+		local_irq_save(flags);
+
+		ret = request_irq(sock->insert_irq, db1200_pcmcia_cdirq,
+				  IRQF_DISABLED, "pcmcia_insert", sock);
+		if (ret)
+			goto out1;
+
+		ret = request_irq(sock->eject_irq, db1200_pcmcia_cdirq,
+				  IRQF_DISABLED, "pcmcia_eject", sock);
+		if (ret) {
+			free_irq(sock->insert_irq, sock);
+			local_irq_restore(flags);
+			goto out1;
+		}
+
+		/* disable the currently active one */
+		if (db1200_card_inserted(sock))
+			disable_irq_nosync(sock->insert_irq);
+		else
+			disable_irq_nosync(sock->eject_irq);
+
+		local_irq_restore(flags);
+	} else {
+		/* all other (older) Db1x00 boards use a GPIO to show
+		 * card detection status: neat for both-edge irq type.
+		 */
+		set_irq_type(sock->insert_irq, IRQ_TYPE_EDGE_BOTH);
+		ret = request_irq(sock->insert_irq, db1000_pcmcia_cdirq,
+				  0, "pcmcia_carddetect", sock);
+
+		if (ret)
+			goto out1;
+	}
+
+	return 0;	/* all done */
+
+out1:
+	if (sock->stschg_irq != -1)
+		free_irq(sock->stschg_irq, sock);
+
+	return ret;
+}
+
+static void db1x_pcmcia_free_irqs(struct db1x_pcmcia_sock *sock)
+{
+	if (sock->stschg_irq != -1)
+		free_irq(sock->stschg_irq, sock);
+
+	free_irq(sock->insert_irq, sock);
+	if (sock->eject_irq != -1)
+		free_irq(sock->eject_irq, sock);
+}
+
+/*
+ * configure a PCMCIA socket on the Db1x00 series of boards (and
+ * compatibles).
+ *
+ * 2 external registers are involved:
+ *   pcmcia_status (offset 0x04): bits [0:1/2:3]: read card voltage id
+ *   pcmcia_control(offset 0x10):
+ *	bits[0:1] set vcc for card
+ *	bits[2:3] set vpp for card
+ *	bit 4:	enable data buffers
+ *	bit 7:	reset# for card
+ *	add 8 for second socket.
+ */
+static int db1x_pcmcia_configure(struct pcmcia_socket *skt,
+				 struct socket_state_t *state)
+{
+	struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
+	unsigned short cr;
+	unsigned int changed;
+	int v, p, ret;
+
+	/*
+	 * card voltage setup
+	 */
+	cr = bcsr_read(BCSR_PCMCIA);
+	cr &= ~(0xf << (sock->nr * 8));	/* clear voltage settings */
+	v = p = ret = 0;
+
+	switch (state->Vcc) {
+	case 50:
+		++v;
+	case 33:
+		++v;
+	case 0:
+		break;
+	default:
+		printk(KERN_INFO "pcmcia%d unsupported Vcc %d\n",
+			sock->nr, state->Vcc);
+	}
+
+	switch (state->Vpp) {
+	case 12:
+		++p;
+	case 33:
+	case 50:
+		++p;
+	case 0:
+		break;
+	default:
+		printk(KERN_INFO "pcmcia%d unsupported Vpp %d\n",
+			sock->nr, state->Vpp);
+	}
+
+	/* sanity check: Vpp must be 0, 12, or Vcc */
+	if (((state->Vcc == 33) && (state->Vpp == 50)) ||
+	    ((state->Vcc == 50) && (state->Vpp == 33))) {
+		printk(KERN_INFO "pcmcia%d bad Vcc/Vpp combo (%d %d)\n",
+			sock->nr, state->Vcc, state->Vpp);
+		v = p = 0;
+		ret = -EINVAL;
+	}
+
+	/* create new voltage code */
+	cr |= ((v << 2) | p) << (sock->nr * 8);
+
+	changed = state->flags ^ sock->old_flags;
+
+	if (changed & SS_RESET) {
+		if (state->flags & SS_RESET) {
+			set_stschg(sock, 0);
+			/* assert reset, disable io buffers */
+			cr &= ~(1 << (7 + (sock->nr * 8)));
+			cr &= ~(1 << (4 + (sock->nr * 8)));
+		} else {
+			/* de-assert reset, enable io buffers */
+			cr |= 1 << (7 + (sock->nr * 8));
+			cr |= 1 << (4 + (sock->nr * 8));
+		}
+	}
+
+	bcsr_write(BCSR_PCMCIA, cr);
+
+	sock->old_flags = state->flags;
+
+	/* reset was taken away: give card time to initialize properly */
+	if ((changed & SS_RESET) && !(state->flags & SS_RESET)) {
+		msleep(500);
+		set_stschg(sock, 1);
+	}
+
+	return ret;
+}
+
+/* VCC bits at [3:2]/[11:10] */
+#define GET_VCC(cr, socknr)		\
+	((((cr) >> 2) >> ((socknr) * 8)) & 3)
+
+/* VS bits at [0:1]/[3:2] */
+#define GET_VS(sr, socknr)		\
+	(((sr) >> (2 * (socknr))) & 3)
+
+/* reset bits at [7]/[15] */
+#define GET_RESET(cr, socknr)		\
+	((cr) & (1 << (7 + (8 * (socknr)))))
+
+static int db1x_pcmcia_get_status(struct pcmcia_socket *skt,
+				  unsigned int *value)
+{
+	struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
+	unsigned short cr, sr;
+	unsigned int status;
+
+	status = db1x_card_inserted(sock) ? SS_DETECT : 0;
+
+	cr = bcsr_read(BCSR_PCMCIA);
+	sr = bcsr_read(BCSR_STATUS);
+
+	/* PB1100/PB1500: voltage key bits are at [5:4] */
+	if (sock->board_type == BOARD_TYPE_PB1100)
+		sr >>= 4;
+
+	/* determine card type */
+	switch (GET_VS(sr, sock->nr)) {
+	case 0:
+	case 2:
+		status |= SS_3VCARD;	/* 3V card */
+	case 3:
+		break;			/* 5V card: set nothing */
+	default:
+		status |= SS_XVCARD;	/* treated as unsupported in core */
+	}
+
+	/* if Vcc is not zero, we have applied power to a card */
+	status |= GET_VCC(cr, sock->nr) ? SS_POWERON : 0;
+
+	/* reset de-asserted? then we're ready */
+	status |= (GET_RESET(cr, sock->nr)) ? SS_READY : SS_RESET;
+
+	*value = status;
+
+	return 0;
+}
+
+static int db1x_pcmcia_sock_init(struct pcmcia_socket *skt)
+{
+	return 0;
+}
+
+static int db1x_pcmcia_sock_suspend(struct pcmcia_socket *skt)
+{
+	return 0;
+}
+
+static int au1x00_pcmcia_set_io_map(struct pcmcia_socket *skt,
+				    struct pccard_io_map *map)
+{
+	struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
+
+	map->start = (u32)sock->virt_io;
+	map->stop = map->start + IO_MAP_SIZE;
+
+	return 0;
+}
+
+static int au1x00_pcmcia_set_mem_map(struct pcmcia_socket *skt,
+				     struct pccard_mem_map *map)
+{
+	struct db1x_pcmcia_sock *sock = to_db1x_socket(skt);
+
+	if (map->flags & MAP_ATTRIB)
+		map->static_start = sock->phys_attr + map->card_start;
+	else
+		map->static_start = sock->phys_mem + map->card_start;
+
+	return 0;
+}
+
+static struct pccard_operations db1x_pcmcia_operations = {
+	.init			= db1x_pcmcia_sock_init,
+	.suspend		= db1x_pcmcia_sock_suspend,
+	.get_status		= db1x_pcmcia_get_status,
+	.set_socket		= db1x_pcmcia_configure,
+	.set_io_map		= au1x00_pcmcia_set_io_map,
+	.set_mem_map		= au1x00_pcmcia_set_mem_map,
+};
+
+static int __devinit db1x_pcmcia_socket_probe(struct platform_device *pdev)
+{
+	struct db1x_pcmcia_sock *sock;
+	struct resource *r;
+	phys_t physio;
+	int ret, bid;
+
+	sock = kzalloc(sizeof(struct db1x_pcmcia_sock), GFP_KERNEL);
+	if (!sock)
+		return -ENOMEM;
+
+	sock->nr = pdev->id;
+
+	bid = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI));
+	switch (bid) {
+	case BCSR_WHOAMI_PB1500:
+	case BCSR_WHOAMI_PB1500R2:
+	case BCSR_WHOAMI_PB1100:
+		sock->board_type = BOARD_TYPE_PB1100;
+		break;
+	case BCSR_WHOAMI_DB1000 ... BCSR_WHOAMI_PB1550_SDR:
+		sock->board_type = BOARD_TYPE_DEFAULT;
+		break;
+	case BCSR_WHOAMI_PB1200 ... BCSR_WHOAMI_DB1200:
+		sock->board_type = BOARD_TYPE_DB1200;
+		break;
+	default:
+		printk(KERN_INFO "db1xxx-ss: unknown board %d!\n", bid);
+		ret = -ENODEV;
+		goto out0;
+	};
+
+	/*
+	 * gather resources necessary and optional nice-to-haved to
+	 * operate a socket.
+	 * This includes IRQs for Carddetection/ejection, the card
+	 *  itself and optional status change detection.
+	 * Also, the memory areas covered by a socket.  For these
+	 *  we require the 32bit "pseudo" addresses (see the au1000.h
+	 *  header for more information).
+	 */
+
+	/* card: irq assigned to the card itself. */
+	r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "card");
+	sock->card_irq = r ? r->start : 0;
+
+	/* insert: irq which triggers on card insertion/ejection */
+	r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "insert");
+	sock->insert_irq = r ? r->start : -1;
+
+	/* stschg: irq which trigger on card status change (optional) */
+	r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "stschg");
+	sock->stschg_irq = r ? r->start : -1;
+
+	/* eject: irq which triggers on ejection (DB1200/PB1200 only) */
+	r = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "eject");
+	sock->eject_irq = r ? r->start : -1;
+
+	ret = -ENODEV;
+
+	/*
+	 * pseudo-attr:  The 32bit address of the PCMCIA attribute space
+	 * for this socket (usually the 36bit address shifted 4 to the
+	 * right).
+	 */
+	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-attr");
+	if (!r) {
+		printk(KERN_ERR "pcmcia%d has no 'pseudo-attr' resource!\n",
+			sock->nr);
+		goto out0;
+	}
+	sock->phys_attr = r->start;
+
+	/*
+	 * pseudo-mem:  The 32bit address of the PCMCIA memory space for
+	 * this socket (usually the 36bit address shifted 4 to the right)
+	 */
+	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-mem");
+	if (!r) {
+		printk(KERN_ERR "pcmcia%d has no 'pseudo-mem' resource!\n",
+			sock->nr);
+		goto out0;
+	}
+	sock->phys_mem = r->start;
+
+	/*
+	 * pseudo-io:  The 32bit address of the PCMCIA IO space for this
+	 * socket (usually the 36bit address shifted 4 to the right).
+	 */
+	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-io");
+	if (!r) {
+		printk(KERN_ERR "pcmcia%d has no 'pseudo-io' resource!\n",
+			sock->nr);
+		goto out0;
+	}
+	sock->phys_io = r->start;
+
+
+	/* for io must remap the full 36bit address (for reference see
+	 * alchemy/common/setup.c::__fixup_bigphys_addr)
+	 */
+	physio = ((phys_t)sock->phys_io) << 4;
+
+	/*
+	 * PCMCIA client drivers use the inb/outb macros to access
+	 * the IO registers.  Since mips_io_port_base is added
+	 * to the access address of the mips implementation of
+	 * inb/outb, we need to subtract it here because we want
+	 * to access the I/O or MEM address directly, without
+	 * going through this "mips_io_port_base" mechanism.
+	 */
+	sock->virt_io = (void *)(ioremap(physio, IO_MAP_SIZE) -
+				 mips_io_port_base);
+
+	if (!sock->virt_io) {
+		printk(KERN_ERR "pcmcia%d: cannot remap IO area\n",
+			sock->nr);
+		ret = -ENOMEM;
+		goto out0;
+	}
+
+	sock->socket.ops	= &db1x_pcmcia_operations;
+	sock->socket.owner	= THIS_MODULE;
+	sock->socket.pci_irq	= sock->card_irq;
+	sock->socket.features	= SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
+	sock->socket.map_size	= MEM_MAP_SIZE;
+	sock->socket.io_offset	= (unsigned long)sock->virt_io;
+	sock->socket.dev.parent	= &pdev->dev;
+	sock->socket.resource_ops = &pccard_static_ops;
+
+	platform_set_drvdata(pdev, sock);
+
+	ret = db1x_pcmcia_setup_irqs(sock);
+	if (ret) {
+		printk(KERN_ERR "pcmcia%d cannot setup interrupts\n",
+			sock->nr);
+		goto out1;
+	}
+
+	set_stschg(sock, 0);
+
+	ret = pcmcia_register_socket(&sock->socket);
+	if (ret) {
+		printk(KERN_ERR "pcmcia%d failed to register\n", sock->nr);
+		goto out2;
+	}
+
+	printk(KERN_INFO "Alchemy Db/Pb1xxx pcmcia%d @ io/attr/mem %08lx"
+		"(%p) %08lx %08lx  card/insert/stschg/eject irqs @ %d "
+		"%d %d %d\n", sock->nr, sock->phys_io, sock->virt_io,
+		sock->phys_attr, sock->phys_mem, sock->card_irq,
+		sock->insert_irq, sock->stschg_irq, sock->eject_irq);
+
+	return 0;
+
+out2:
+	db1x_pcmcia_free_irqs(sock);
+out1:
+	iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
+out0:
+	kfree(sock);
+	return ret;
+}
+
+static int __devexit db1x_pcmcia_socket_remove(struct platform_device *pdev)
+{
+	struct db1x_pcmcia_sock *sock = platform_get_drvdata(pdev);
+
+	pcmcia_unregister_socket(&sock->socket);
+	db1x_pcmcia_free_irqs(sock);
+	iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
+	kfree(sock);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int db1x_pcmcia_suspend(struct device *dev)
+{
+	/* REVISIT: 2nd parameter is currently ignored but required */
+	return pcmcia_socket_dev_suspend(dev, PMSG_SUSPEND);
+}
+
+static int db1x_pcmcia_resume(struct device *dev)
+{
+	return pcmcia_socket_dev_resume(dev);
+}
+
+static struct dev_pm_ops db1x_pcmcia_pmops = {
+	.resume		= db1x_pcmcia_resume,
+	.suspend	= db1x_pcmcia_suspend,
+};
+
+#define DB1XXX_SS_PMOPS &db1x_pcmcia_pmops
+
+#else
+
+#define DB1XXX_SS_PMOPS NULL
+
+#endif
+
+static struct platform_driver db1x_pcmcia_socket_driver = {
+	.driver	= {
+		.name	= "db1xxx_pcmcia",
+		.owner	= THIS_MODULE,
+		.pm	= DB1XXX_SS_PMOPS
+	},
+	.probe		= db1x_pcmcia_socket_probe,
+	.remove		= __devexit_p(db1x_pcmcia_socket_remove),
+};
+
+int __init db1x_pcmcia_socket_load(void)
+{
+	return platform_driver_register(&db1x_pcmcia_socket_driver);
+}
+
+void  __exit db1x_pcmcia_socket_unload(void)
+{
+	platform_driver_unregister(&db1x_pcmcia_socket_driver);
+}
+
+module_init(db1x_pcmcia_socket_load);
+module_exit(db1x_pcmcia_socket_unload);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("PCMCIA Socket Services for Alchemy Db/Pb1x00 boards");
+MODULE_AUTHOR("Manuel Lauss");
-- 
1.6.5.rc1


From manuel.lauss@googlemail.com Tue Sep 29 20:16:18 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 29 Sep 2009 20:16:24 +0200 (CEST)
Received: from mail-fx0-f221.google.com ([209.85.220.221]:57327 "EHLO
	mail-fx0-f221.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493661AbZI2SPb (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 29 Sep 2009 20:15:31 +0200
Received: by fxm21 with SMTP id 21so1108549fxm.33
        for <linux-mips@linux-mips.org>; Tue, 29 Sep 2009 11:15:26 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer:in-reply-to:references;
        bh=zyQfwi9/o/uhNaUur5fEp9cm0vXD3bnX4E3TRO6w24w=;
        b=dV7k8bwYBfXhYzbDv2NZBsW1zoCCcdLPt+Mh0PNyKHC/imnAqPL8svaIOJdqnexiTJ
         +QuG99h6ZzvDjWfSYU0CcIGX40mrymD3bc6Cc2tUobkfoU45hSzDpobHV8s4Wf9qesxD
         0vK46VsALqbglcI9ybABueXzok8JT2L5Om48w=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
        b=aiQUuLWbAFyeagMZlxQzlTqsXhcZAlQJiLHVScYJLThGD2C9pOkXmcmo97+XznBKls
         zyfI/18ngS6C+KrcFMO5f4dsBvwkhar0Ru3J66kcPKHDYaJ7dzH/GeshlPdCTS6VD2Iy
         8NGj1Jlesckh1onQcE40Mld2XrhkhEZ1ZajjA=
Received: by 10.86.163.5 with SMTP id l5mr4646874fge.3.1254248125855;
        Tue, 29 Sep 2009 11:15:25 -0700 (PDT)
Received: from localhost.localdomain (p5496CA2C.dip.t-dialin.net [84.150.202.44])
        by mx.google.com with ESMTPS id 3sm46061fge.23.2009.09.29.11.15.24
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Tue, 29 Sep 2009 11:15:25 -0700 (PDT)
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Linux-MIPS <linux-mips@linux-mips.org>
Cc:	Manuel Lauss <manuel.lauss@gmail.com>
Subject: [PATCH 2/3] Alchemy: devboards: factor out PB1200 IRQ cascade code.
Date:	Tue, 29 Sep 2009 20:15:13 +0200
Message-Id: <1254248114-4158-3-git-send-email-manuel.lauss@gmail.com>
X-Mailer: git-send-email 1.6.5.rc1
In-Reply-To: <1254248114-4158-2-git-send-email-manuel.lauss@gmail.com>
References: <1254248114-4158-1-git-send-email-manuel.lauss@gmail.com>
 <1254248114-4158-2-git-send-email-manuel.lauss@gmail.com>
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24117
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

Move the PB1200 IRQ cascade code out to the BCSR support code.
Upcoming DB1300 support can use it too.

Tested on DB1200.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
 arch/mips/alchemy/devboards/bcsr.c          |   72 +++++++++++++++++++++++++++
 arch/mips/alchemy/devboards/pb1200/irqmap.c |   71 +--------------------------
 arch/mips/include/asm/mach-db1x00/bcsr.h    |    3 +
 3 files changed, 76 insertions(+), 70 deletions(-)

diff --git a/arch/mips/alchemy/devboards/bcsr.c b/arch/mips/alchemy/devboards/bcsr.c
index 85b7715..3bc4fd2 100644
--- a/arch/mips/alchemy/devboards/bcsr.c
+++ b/arch/mips/alchemy/devboards/bcsr.c
@@ -7,6 +7,7 @@
  * All registers are 16bits wide with 32bit spacing.
  */
 
+#include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/spinlock.h>
 #include <asm/addrspace.h>
@@ -18,6 +19,9 @@ static struct bcsr_reg {
 	spinlock_t lock;
 } bcsr_regs[BCSR_CNT];
 
+static void __iomem *bcsr_virt;	/* KSEG1 addr of BCSR base */
+static int bcsr_csc_base;	/* linux-irq of first cascaded irq */
+
 void __init bcsr_init(unsigned long bcsr1_phys, unsigned long bcsr2_phys)
 {
 	int i;
@@ -25,6 +29,8 @@ void __init bcsr_init(unsigned long bcsr1_phys, unsigned long bcsr2_phys)
 	bcsr1_phys = KSEG1ADDR(CPHYSADDR(bcsr1_phys));
 	bcsr2_phys = KSEG1ADDR(CPHYSADDR(bcsr2_phys));
 
+	bcsr_virt = (void __iomem *)bcsr1_phys;
+
 	for (i = 0; i < BCSR_CNT; i++) {
 		if (i >= BCSR_HEXLEDS)
 			bcsr_regs[i].raddr = (void __iomem *)bcsr2_phys +
@@ -74,3 +80,69 @@ void bcsr_mod(enum bcsr_id reg, unsigned short clr, unsigned short set)
 	spin_unlock_irqrestore(&bcsr_regs[reg].lock, flags);
 }
 EXPORT_SYMBOL_GPL(bcsr_mod);
+
+/*
+ * DB1200/PB1200 CPLD IRQ muxer
+ */
+static void bcsr_csc_handler(unsigned int irq, struct irq_desc *d)
+{
+	unsigned short bisr = __raw_readw(bcsr_virt + BCSR_REG_INTSTAT);
+
+	for ( ; bisr; bisr &= bisr - 1)
+		generic_handle_irq(bcsr_csc_base + __ffs(bisr));
+}
+
+/* NOTE: both the enable and mask bits must be cleared, otherwise the
+ * CPLD generates tons of spurious interrupts (at least on my DB1200).
+ *	-- mlau
+ */
+static void bcsr_irq_mask(unsigned int irq_nr)
+{
+	unsigned short v = 1 << (irq_nr - bcsr_csc_base);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTCLR);
+	__raw_writew(v, bcsr_virt + BCSR_REG_MASKCLR);
+	wmb();
+}
+
+static void bcsr_irq_maskack(unsigned int irq_nr)
+{
+	unsigned short v = 1 << (irq_nr - bcsr_csc_base);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTCLR);
+	__raw_writew(v, bcsr_virt + BCSR_REG_MASKCLR);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTSTAT);	/* ack */
+	wmb();
+}
+
+static void bcsr_irq_unmask(unsigned int irq_nr)
+{
+	unsigned short v = 1 << (irq_nr - bcsr_csc_base);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTSET);
+	__raw_writew(v, bcsr_virt + BCSR_REG_MASKSET);
+	wmb();
+}
+
+static struct irq_chip bcsr_irq_type = {
+	.name		= "CPLD",
+	.mask		= bcsr_irq_mask,
+	.mask_ack	= bcsr_irq_maskack,
+	.unmask		= bcsr_irq_unmask,
+};
+
+void __init bcsr_init_irq(int csc_start, int csc_end, int hook_irq)
+{
+	unsigned int irq;
+
+	/* mask & disable & ack all */
+	__raw_writew(0xffff, bcsr_virt + BCSR_REG_INTCLR);
+	__raw_writew(0xffff, bcsr_virt + BCSR_REG_MASKCLR);
+	__raw_writew(0xffff, bcsr_virt + BCSR_REG_INTSTAT);
+	wmb();
+
+	bcsr_csc_base = csc_start;
+
+	for (irq = csc_start; irq <= csc_end; irq++)
+		set_irq_chip_and_handler_name(irq, &bcsr_irq_type,
+			handle_level_irq, "level");
+
+	set_irq_chained_handler(hook_irq, bcsr_csc_handler);
+}
diff --git a/arch/mips/alchemy/devboards/pb1200/irqmap.c b/arch/mips/alchemy/devboards/pb1200/irqmap.c
index f379b02..3beb804 100644
--- a/arch/mips/alchemy/devboards/pb1200/irqmap.c
+++ b/arch/mips/alchemy/devboards/pb1200/irqmap.c
@@ -45,69 +45,11 @@ struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
 	{ AU1000_GPIO_7, IRQF_TRIGGER_LOW, 0 },
 };
 
-static void __iomem *bcsr_virt;
-
-/*
- * Support for External interrupts on the Pb1200 Development platform.
- */
-
-static void pb1200_cascade_handler(unsigned int irq, struct irq_desc *d)
-{
-	unsigned short bisr = __raw_readw(bcsr_virt + BCSR_REG_INTSTAT);
-
-	for ( ; bisr; bisr &= bisr - 1)
-		generic_handle_irq(PB1200_INT_BEGIN + __ffs(bisr));
-}
-
-/* NOTE: both the enable and mask bits must be cleared, otherwise the
- * CPLD generates tons of spurious interrupts (at least on the DB1200).
- */
-static void pb1200_mask_irq(unsigned int irq_nr)
-{
-	unsigned short v = 1 << (irq_nr - PB1200_INT_BEGIN);
-	__raw_writew(v, bcsr_virt + BCSR_REG_INTCLR);
-	__raw_writew(v, bcsr_virt + BCSR_REG_MASKCLR);
-	wmb();
-}
-
-static void pb1200_maskack_irq(unsigned int irq_nr)
-{
-	unsigned short v = 1 << (irq_nr - PB1200_INT_BEGIN);
-	__raw_writew(v, bcsr_virt + BCSR_REG_INTCLR);
-	__raw_writew(v, bcsr_virt + BCSR_REG_MASKCLR);
-	__raw_writew(v, bcsr_virt + BCSR_REG_INTSTAT);	/* ack */
-	wmb();
-}
-
-static void pb1200_unmask_irq(unsigned int irq_nr)
-{
-	unsigned short v = 1 << (irq_nr - PB1200_INT_BEGIN);
-	__raw_writew(v, bcsr_virt + BCSR_REG_INTSET);
-	__raw_writew(v, bcsr_virt + BCSR_REG_MASKSET);
-	wmb();
-}
-
-static struct irq_chip pb1200_cpld_irq_type = {
-#ifdef CONFIG_MIPS_PB1200
-	.name = "Pb1200 Ext",
-#endif
-#ifdef CONFIG_MIPS_DB1200
-	.name = "Db1200 Ext",
-#endif
-	.mask		= pb1200_mask_irq,
-	.mask_ack	= pb1200_maskack_irq,
-	.unmask		= pb1200_unmask_irq,
-};
-
 void __init board_init_irq(void)
 {
-	unsigned int irq;
-
 	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
 
 #ifdef CONFIG_MIPS_PB1200
-	bcsr_virt = (void __iomem *)KSEG1ADDR(PB1200_BCSR_PHYS_ADDR);
-
 	/* We have a problem with CPLD rev 3. */
 	if (BCSR_WHOAMI_CPLD(bcsr_read(BCSR_WHOAMI)) <= 3) {
 		printk(KERN_ERR "WARNING!!!\n");
@@ -127,18 +69,7 @@ void __init board_init_irq(void)
 		printk(KERN_ERR "WARNING!!!\n");
 		panic("Game over.  Your score is 0.");
 	}
-#else
-	bcsr_virt = (void __iomem *)KSEG1ADDR(DB1200_BCSR_PHYS_ADDR);
 #endif
 
-	/* mask & disable & ack all */
-	bcsr_write(BCSR_INTCLR, 0xffff);
-	bcsr_write(BCSR_MASKCLR, 0xffff);
-	bcsr_write(BCSR_INTSTAT, 0xffff);
-
-	for (irq = PB1200_INT_BEGIN; irq <= PB1200_INT_END; irq++)
-		set_irq_chip_and_handler_name(irq, &pb1200_cpld_irq_type,
-					 handle_level_irq, "level");
-
-	set_irq_chained_handler(AU1000_GPIO_7, pb1200_cascade_handler);
+	bcsr_init_irq(PB1200_INT_BEGIN, PB1200_INT_END, AU1000_GPIO_7);
 }
diff --git a/arch/mips/include/asm/mach-db1x00/bcsr.h b/arch/mips/include/asm/mach-db1x00/bcsr.h
index 3c80dae..a5a12c1 100644
--- a/arch/mips/include/asm/mach-db1x00/bcsr.h
+++ b/arch/mips/include/asm/mach-db1x00/bcsr.h
@@ -229,4 +229,7 @@ void bcsr_write(enum bcsr_id reg, unsigned short val);
 /* modify a register. clear bits set in 'clr', set bits set in 'set' */
 void bcsr_mod(enum bcsr_id reg, unsigned short clr, unsigned short set);
 
+/* install CPLD IRQ demuxer (DB1200/PB1200) */
+void __init bcsr_init_irq(int csc_start, int csc_end, int hook_irq);
+
 #endif
-- 
1.6.5.rc1


From manuel.lauss@googlemail.com Tue Sep 29 20:16:42 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 29 Sep 2009 20:16:48 +0200 (CEST)
Received: from mail-fx0-f221.google.com ([209.85.220.221]:45654 "EHLO
	mail-fx0-f221.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493660AbZI2SPb (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 29 Sep 2009 20:15:31 +0200
Received: by fxm21 with SMTP id 21so1108511fxm.33
        for <linux-mips@linux-mips.org>; Tue, 29 Sep 2009 11:15:25 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer:in-reply-to:references;
        bh=yecj+9GRuvDEEvWy9g/jkIOI7zkHzIl28qyKxP0wk20=;
        b=PeVAiltE27jwAVtQYUWZrrA7tD/o20MIb+nufCX0QzQQ/RSnLgS+D8n8iU99xaxzaJ
         E190MliQQlJ4Su64izXjiG405PeqlZelebCEaGb2Wr1lZT6kzrVIM8L9cjS51yrnos5B
         AzwdelF8HE65sgR8HSklTBXtllp8RUdq1LhXQ=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
        b=asnI6NxB5nIkOV219++kB2yGliEVPZfMRz5O1rTWXVTvJL4catajXec+UxFDKx/fJi
         W10eZ159+iSSgfEyzYt9gfLzC3Tfzb4KcDUaJjTNaXgFsyHsSiCo3ChfW2gFZWI/OfXb
         S0vudDkcTyKHOBO/4w9OxwOU9io6fXyvHiBvg=
Received: by 10.86.22.12 with SMTP id 12mr4435419fgv.69.1254248124895;
        Tue, 29 Sep 2009 11:15:24 -0700 (PDT)
Received: from localhost.localdomain (p5496CA2C.dip.t-dialin.net [84.150.202.44])
        by mx.google.com with ESMTPS id 3sm46061fge.23.2009.09.29.11.15.23
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Tue, 29 Sep 2009 11:15:24 -0700 (PDT)
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Linux-MIPS <linux-mips@linux-mips.org>
Cc:	Manuel Lauss <manuel.lauss@gmail.com>
Subject: [PATCH 1/3] Alchemy: devboard register abstraction
Date:	Tue, 29 Sep 2009 20:15:12 +0200
Message-Id: <1254248114-4158-2-git-send-email-manuel.lauss@gmail.com>
X-Mailer: git-send-email 1.6.5.rc1
In-Reply-To: <1254248114-4158-1-git-send-email-manuel.lauss@gmail.com>
References: <1254248114-4158-1-git-send-email-manuel.lauss@gmail.com>
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24118
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

All Alchemy development boards (except the PB1000) have external CPLDs
with a few registers in them.  They all share an identical register
layout with only a few minor differences in bit functions and base
addresses.  This is useful for drivers which can work across the whole
range of boards (e.g. the PCMCIA socket driver).

This patch adds a primitive facility to initialize and use these
external registers and replaces all occurrences of bcsr->xxx accesses
with calls to the new functions (except for the PB1200 IRQ cascade,
which doesn't work with it).

Run-tested on the DB1200, as far as possible.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
 arch/mips/alchemy/devboards/Makefile             |    2 +-
 arch/mips/alchemy/devboards/bcsr.c               |   76 +++++++
 arch/mips/alchemy/devboards/db1x00/board_setup.c |   62 ++++---
 arch/mips/alchemy/devboards/pb1100/board_setup.c |    7 +-
 arch/mips/alchemy/devboards/pb1200/board_setup.c |   49 +++---
 arch/mips/alchemy/devboards/pb1200/irqmap.c      |   42 +++--
 arch/mips/alchemy/devboards/pb1200/platform.c    |   25 ++--
 arch/mips/alchemy/devboards/pb1500/board_setup.c |    7 +-
 arch/mips/alchemy/devboards/pb1550/board_setup.c |   11 +-
 arch/mips/include/asm/mach-db1x00/bcsr.h         |  232 ++++++++++++++++++++++
 arch/mips/include/asm/mach-db1x00/db1200.h       |  109 +----------
 arch/mips/include/asm/mach-db1x00/db1x00.h       |   92 ---------
 arch/mips/include/asm/mach-pb1x00/pb1100.h       |   49 -----
 arch/mips/include/asm/mach-pb1x00/pb1200.h       |  109 +----------
 arch/mips/include/asm/mach-pb1x00/pb1500.h       |   13 --
 arch/mips/include/asm/mach-pb1x00/pb1550.h       |   89 ---------
 drivers/mtd/nand/au1550nd.c                      |    4 +-
 drivers/net/irda/au1k_ir.c                       |   14 +-
 drivers/pcmcia/au1000_db1x00.c                   |   76 ++++----
 19 files changed, 472 insertions(+), 596 deletions(-)
 create mode 100644 arch/mips/alchemy/devboards/bcsr.c
 create mode 100644 arch/mips/include/asm/mach-db1x00/bcsr.h

diff --git a/arch/mips/alchemy/devboards/Makefile b/arch/mips/alchemy/devboards/Makefile
index 730f9f2..adc6717 100644
--- a/arch/mips/alchemy/devboards/Makefile
+++ b/arch/mips/alchemy/devboards/Makefile
@@ -2,7 +2,7 @@
 # Alchemy Develboards
 #
 
-obj-y += prom.o
+obj-y += prom.o bcsr.o
 obj-$(CONFIG_PM)		+= pm.o
 obj-$(CONFIG_MIPS_PB1000)	+= pb1000/
 obj-$(CONFIG_MIPS_PB1100)	+= pb1100/
diff --git a/arch/mips/alchemy/devboards/bcsr.c b/arch/mips/alchemy/devboards/bcsr.c
new file mode 100644
index 0000000..85b7715
--- /dev/null
+++ b/arch/mips/alchemy/devboards/bcsr.c
@@ -0,0 +1,76 @@
+/*
+ * bcsr.h -- Db1xxx/Pb1xxx Devboard CPLD registers ("BCSR") abstraction.
+ *
+ * All Alchemy development boards (except, of course, the weird PB1000)
+ * have a few registers in a CPLD with standardised layout; they mostly
+ * only differ in base address.
+ * All registers are 16bits wide with 32bit spacing.
+ */
+
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <asm/addrspace.h>
+#include <asm/io.h>
+#include <asm/mach-db1x00/bcsr.h>
+
+static struct bcsr_reg {
+	void __iomem *raddr;
+	spinlock_t lock;
+} bcsr_regs[BCSR_CNT];
+
+void __init bcsr_init(unsigned long bcsr1_phys, unsigned long bcsr2_phys)
+{
+	int i;
+
+	bcsr1_phys = KSEG1ADDR(CPHYSADDR(bcsr1_phys));
+	bcsr2_phys = KSEG1ADDR(CPHYSADDR(bcsr2_phys));
+
+	for (i = 0; i < BCSR_CNT; i++) {
+		if (i >= BCSR_HEXLEDS)
+			bcsr_regs[i].raddr = (void __iomem *)bcsr2_phys +
+					(0x04 * (i - BCSR_HEXLEDS));
+		else
+			bcsr_regs[i].raddr = (void __iomem *)bcsr1_phys +
+					(0x04 * i);
+
+		spin_lock_init(&bcsr_regs[i].lock);
+	}
+}
+
+unsigned short bcsr_read(enum bcsr_id reg)
+{
+	unsigned short r;
+	unsigned long flags;
+
+	spin_lock_irqsave(&bcsr_regs[reg].lock, flags);
+	r = __raw_readw(bcsr_regs[reg].raddr);
+	spin_unlock_irqrestore(&bcsr_regs[reg].lock, flags);
+	return r;
+}
+EXPORT_SYMBOL_GPL(bcsr_read);
+
+void bcsr_write(enum bcsr_id reg, unsigned short val)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&bcsr_regs[reg].lock, flags);
+	__raw_writew(val, bcsr_regs[reg].raddr);
+	wmb();
+	spin_unlock_irqrestore(&bcsr_regs[reg].lock, flags);
+}
+EXPORT_SYMBOL_GPL(bcsr_write);
+
+void bcsr_mod(enum bcsr_id reg, unsigned short clr, unsigned short set)
+{
+	unsigned short r;
+	unsigned long flags;
+
+	spin_lock_irqsave(&bcsr_regs[reg].lock, flags);
+	r = __raw_readw(bcsr_regs[reg].raddr);
+	r &= ~clr;
+	r |= set;
+	__raw_writew(r, bcsr_regs[reg].raddr);
+	wmb();
+	spin_unlock_irqrestore(&bcsr_regs[reg].lock, flags);
+}
+EXPORT_SYMBOL_GPL(bcsr_mod);
diff --git a/arch/mips/alchemy/devboards/db1x00/board_setup.c b/arch/mips/alchemy/devboards/db1x00/board_setup.c
index de30d8e..e713390 100644
--- a/arch/mips/alchemy/devboards/db1x00/board_setup.c
+++ b/arch/mips/alchemy/devboards/db1x00/board_setup.c
@@ -32,12 +32,10 @@
 
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-db1x00/db1x00.h>
+#include <asm/mach-db1x00/bcsr.h>
 
 #include <prom.h>
 
-
-static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
-
 const char *get_system_type(void)
 {
 #ifdef CONFIG_MIPS_BOSPORUS
@@ -49,15 +47,43 @@ const char *get_system_type(void)
 
 void board_reset(void)
 {
-	/* Hit BCSR.SW_RESET[RESET] */
-	bcsr->swreset = 0x0000;
+	bcsr_write(BCSR_SYSTEM, 0);
 }
 
 void __init board_setup(void)
 {
+	unsigned long bcsr1, bcsr2;
 	u32 pin_func = 0;
 	char *argptr;
 
+	bcsr1 = DB1000_BCSR_PHYS_ADDR;
+	bcsr2 = DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS;
+
+#ifdef CONFIG_MIPS_DB1000
+	printk(KERN_INFO "AMD Alchemy Au1000/Db1000 Board\n");
+#endif
+#ifdef CONFIG_MIPS_DB1500
+	printk(KERN_INFO "AMD Alchemy Au1500/Db1500 Board\n");
+#endif
+#ifdef CONFIG_MIPS_DB1100
+	printk(KERN_INFO "AMD Alchemy Au1100/Db1100 Board\n");
+#endif
+#ifdef CONFIG_MIPS_BOSPORUS
+	printk(KERN_INFO "AMD Alchemy Bosporus Board\n");
+#endif
+#ifdef CONFIG_MIPS_MIRAGE
+	printk(KERN_INFO "AMD Alchemy Mirage Board\n");
+#endif
+#ifdef CONFIG_MIPS_DB1550
+	printk(KERN_INFO "AMD Alchemy Au1550/Db1550 Board\n");
+
+	bcsr1 = DB1550_BCSR_PHYS_ADDR;
+	bcsr2 = DB1550_BCSR_PHYS_ADDR + DB1550_BCSR_HEXLED_OFS;
+#endif
+
+	/* initialize board register space */
+	bcsr_init(bcsr1, bcsr2);
+
 	argptr = prom_getcmdline();
 #ifdef CONFIG_SERIAL_8250_CONSOLE
 	argptr = strstr(argptr, "console=");
@@ -89,11 +115,10 @@ void __init board_setup(void)
 	pin_func = au_readl(SYS_PINFUNC) | SYS_PF_IRF;
 	au_writel(pin_func, SYS_PINFUNC);
 	/* Power off until the driver is in use */
-	bcsr->resets &= ~BCSR_RESETS_IRDA_MODE_MASK;
-	bcsr->resets |=  BCSR_RESETS_IRDA_MODE_OFF;
-	au_sync();
+	bcsr_mod(BCSR_RESETS, BCSR_RESETS_IRDA_MODE_MASK,
+				BCSR_RESETS_IRDA_MODE_OFF);
 #endif
-	bcsr->pcmcia = 0x0000; /* turn off PCMCIA power */
+	bcsr_write(BCSR_PCMCIA, 0);	/* turn off PCMCIA power */
 
 	/* Enable GPIO[31:0] inputs */
 	alchemy_gpio1_input_enable();
@@ -123,23 +148,4 @@ void __init board_setup(void)
 #endif
 
 	au_sync();
-
-#ifdef CONFIG_MIPS_DB1000
-	printk(KERN_INFO "AMD Alchemy Au1000/Db1000 Board\n");
-#endif
-#ifdef CONFIG_MIPS_DB1500
-	printk(KERN_INFO "AMD Alchemy Au1500/Db1500 Board\n");
-#endif
-#ifdef CONFIG_MIPS_DB1100
-	printk(KERN_INFO "AMD Alchemy Au1100/Db1100 Board\n");
-#endif
-#ifdef CONFIG_MIPS_BOSPORUS
-	printk(KERN_INFO "AMD Alchemy Bosporus Board\n");
-#endif
-#ifdef CONFIG_MIPS_MIRAGE
-	printk(KERN_INFO "AMD Alchemy Mirage Board\n");
-#endif
-#ifdef CONFIG_MIPS_DB1550
-	printk(KERN_INFO "AMD Alchemy Au1550/Db1550 Board\n");
-#endif
 }
diff --git a/arch/mips/alchemy/devboards/pb1100/board_setup.c b/arch/mips/alchemy/devboards/pb1100/board_setup.c
index 6126308..eb749fb 100644
--- a/arch/mips/alchemy/devboards/pb1100/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1100/board_setup.c
@@ -30,6 +30,7 @@
 
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-pb1x00/pb1100.h>
+#include <asm/mach-db1x00/bcsr.h>
 
 #include <prom.h>
 
@@ -49,8 +50,7 @@ const char *get_system_type(void)
 
 void board_reset(void)
 {
-	/* Hit BCSR.RST_VDDI[SOFT_RESET] */
-	au_writel(0x00000000, PB1100_RST_VDDI);
+	bcsr_write(BCSR_SYSTEM, 0);
 }
 
 void __init board_init_irq(void)
@@ -63,6 +63,9 @@ void __init board_setup(void)
 	volatile void __iomem *base = (volatile void __iomem *)0xac000000UL;
 	char *argptr;
 
+	bcsr_init(DB1000_BCSR_PHYS_ADDR,
+		  DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS);
+
 	argptr = prom_getcmdline();
 #ifdef CONFIG_SERIAL_8250_CONSOLE
 	argptr = strstr(argptr, "console=");
diff --git a/arch/mips/alchemy/devboards/pb1200/board_setup.c b/arch/mips/alchemy/devboards/pb1200/board_setup.c
index 94e6b7e..db56380 100644
--- a/arch/mips/alchemy/devboards/pb1200/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1200/board_setup.c
@@ -27,6 +27,8 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 
+#include <asm/mach-db1x00/bcsr.h>
+
 #include <prom.h>
 #include <au1xxx.h>
 
@@ -38,14 +40,25 @@ const char *get_system_type(void)
 
 void board_reset(void)
 {
-	bcsr->resets = 0;
-	bcsr->system = 0;
+	bcsr_write(BCSR_RESETS, 0);
+	bcsr_write(BCSR_SYSTEM, 0);
 }
 
 void __init board_setup(void)
 {
 	char *argptr;
 
+#ifdef CONFIG_MIPS_PB1200
+	printk(KERN_INFO "AMD Alchemy Pb1200 Board\n");
+	bcsr_init(PB1200_BCSR_PHYS_ADDR,
+		  PB1200_BCSR_PHYS_ADDR + PB1200_BCSR_HEXLED_OFS);
+#endif
+#ifdef CONFIG_MIPS_DB1200
+	printk(KERN_INFO "AMD Alchemy Db1200 Board\n");
+	bcsr_init(DB1200_BCSR_PHYS_ADDR,
+		  DB1200_BCSR_PHYS_ADDR + DB1200_BCSR_HEXLED_OFS);
+#endif
+
 	argptr = prom_getcmdline();
 #ifdef CONFIG_SERIAL_8250_CONSOLE
 	argptr = strstr(argptr, "console=");
@@ -82,7 +95,7 @@ void __init board_setup(void)
 		u32 pin_func;
 
 		/* Select SMBus in CPLD */
-		bcsr->resets &= ~BCSR_RESETS_PCS0MUX;
+		bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC0MUX, 0);
 
 		pin_func = au_readl(SYS_PINFUNC);
 		au_sync();
@@ -116,38 +129,24 @@ void __init board_setup(void)
 
 	/*
 	 * The Pb1200 development board uses external MUX for PSC0 to
-	 * support SMB/SPI. bcsr->resets bit 12: 0=SMB 1=SPI
+	 * support SMB/SPI. bcsr_resets bit 12: 0=SMB 1=SPI
 	 */
 #ifdef CONFIG_I2C_AU1550
-	bcsr->resets &= ~BCSR_RESETS_PCS0MUX;
+	bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC0MUX, 0);
 #endif
 	au_sync();
-
-#ifdef CONFIG_MIPS_PB1200
-	printk(KERN_INFO "AMD Alchemy Pb1200 Board\n");
-#endif
-#ifdef CONFIG_MIPS_DB1200
-	printk(KERN_INFO "AMD Alchemy Db1200 Board\n");
-#endif
 }
 
 int board_au1200fb_panel(void)
 {
-	BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
-	int p;
-
-	p = bcsr->switches;
-	p >>= 8;
-	p &= 0x0F;
-	return p;
+	return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
 }
 
 int board_au1200fb_panel_init(void)
 {
 	/* Apply power */
-	BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
-
-	bcsr->board |= BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | BCSR_BOARD_LCDBL;
+	bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
+				BCSR_BOARD_LCDBL);
 	/* printk(KERN_DEBUG "board_au1200fb_panel_init()\n"); */
 	return 0;
 }
@@ -155,10 +154,8 @@ int board_au1200fb_panel_init(void)
 int board_au1200fb_panel_shutdown(void)
 {
 	/* Remove power */
-	BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
-
-	bcsr->board &= ~(BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
-			 BCSR_BOARD_LCDBL);
+	bcsr_mod(BCSR_BOARD, BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
+			     BCSR_BOARD_LCDBL, 0);
 	/* printk(KERN_DEBUG "board_au1200fb_panel_shutdown()\n"); */
 	return 0;
 }
diff --git a/arch/mips/alchemy/devboards/pb1200/irqmap.c b/arch/mips/alchemy/devboards/pb1200/irqmap.c
index fe47498..f379b02 100644
--- a/arch/mips/alchemy/devboards/pb1200/irqmap.c
+++ b/arch/mips/alchemy/devboards/pb1200/irqmap.c
@@ -38,11 +38,14 @@
 #define PB1200_INT_END DB1200_INT_END
 #endif
 
+#include <asm/mach-db1x00/bcsr.h>
+
 struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
 	/* This is external interrupt cascade */
 	{ AU1000_GPIO_7, IRQF_TRIGGER_LOW, 0 },
 };
 
+static void __iomem *bcsr_virt;
 
 /*
  * Support for External interrupts on the Pb1200 Development platform.
@@ -50,7 +53,7 @@ struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
 
 static void pb1200_cascade_handler(unsigned int irq, struct irq_desc *d)
 {
-	unsigned short bisr = bcsr->int_status;
+	unsigned short bisr = __raw_readw(bcsr_virt + BCSR_REG_INTSTAT);
 
 	for ( ; bisr; bisr &= bisr - 1)
 		generic_handle_irq(PB1200_INT_BEGIN + __ffs(bisr));
@@ -61,24 +64,27 @@ static void pb1200_cascade_handler(unsigned int irq, struct irq_desc *d)
  */
 static void pb1200_mask_irq(unsigned int irq_nr)
 {
-	bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
-	bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
-	au_sync();
+	unsigned short v = 1 << (irq_nr - PB1200_INT_BEGIN);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTCLR);
+	__raw_writew(v, bcsr_virt + BCSR_REG_MASKCLR);
+	wmb();
 }
 
 static void pb1200_maskack_irq(unsigned int irq_nr)
 {
-	bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
-	bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
-	bcsr->int_status = 1 << (irq_nr - PB1200_INT_BEGIN);	/* ack */
-	au_sync();
+	unsigned short v = 1 << (irq_nr - PB1200_INT_BEGIN);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTCLR);
+	__raw_writew(v, bcsr_virt + BCSR_REG_MASKCLR);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTSTAT);	/* ack */
+	wmb();
 }
 
 static void pb1200_unmask_irq(unsigned int irq_nr)
 {
-	bcsr->intset = 1 << (irq_nr - PB1200_INT_BEGIN);
-	bcsr->intset_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
-	au_sync();
+	unsigned short v = 1 << (irq_nr - PB1200_INT_BEGIN);
+	__raw_writew(v, bcsr_virt + BCSR_REG_INTSET);
+	__raw_writew(v, bcsr_virt + BCSR_REG_MASKSET);
+	wmb();
 }
 
 static struct irq_chip pb1200_cpld_irq_type = {
@@ -100,8 +106,10 @@ void __init board_init_irq(void)
 	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
 
 #ifdef CONFIG_MIPS_PB1200
+	bcsr_virt = (void __iomem *)KSEG1ADDR(PB1200_BCSR_PHYS_ADDR);
+
 	/* We have a problem with CPLD rev 3. */
-	if (((bcsr->whoami & BCSR_WHOAMI_CPLD) >> 4) <= 3) {
+	if (BCSR_WHOAMI_CPLD(bcsr_read(BCSR_WHOAMI)) <= 3) {
 		printk(KERN_ERR "WARNING!!!\n");
 		printk(KERN_ERR "WARNING!!!\n");
 		printk(KERN_ERR "WARNING!!!\n");
@@ -119,12 +127,14 @@ void __init board_init_irq(void)
 		printk(KERN_ERR "WARNING!!!\n");
 		panic("Game over.  Your score is 0.");
 	}
+#else
+	bcsr_virt = (void __iomem *)KSEG1ADDR(DB1200_BCSR_PHYS_ADDR);
 #endif
+
 	/* mask & disable & ack all */
-	bcsr->intclr_mask = 0xffff;
-	bcsr->intclr = 0xffff;
-	bcsr->int_status = 0xffff;
-	au_sync();
+	bcsr_write(BCSR_INTCLR, 0xffff);
+	bcsr_write(BCSR_MASKCLR, 0xffff);
+	bcsr_write(BCSR_INTSTAT, 0xffff);
 
 	for (irq = PB1200_INT_BEGIN; irq <= PB1200_INT_END; irq++)
 		set_irq_chip_and_handler_name(irq, &pb1200_cpld_irq_type,
diff --git a/arch/mips/alchemy/devboards/pb1200/platform.c b/arch/mips/alchemy/devboards/pb1200/platform.c
index b93dff4..dfdaabf 100644
--- a/arch/mips/alchemy/devboards/pb1200/platform.c
+++ b/arch/mips/alchemy/devboards/pb1200/platform.c
@@ -26,27 +26,28 @@
 
 #include <asm/mach-au1x00/au1xxx.h>
 #include <asm/mach-au1x00/au1100_mmc.h>
+#include <asm/mach-db1x00/bcsr.h>
 
 static int mmc_activity;
 
 static void pb1200mmc0_set_power(void *mmc_host, int state)
 {
 	if (state)
-		bcsr->board |= BCSR_BOARD_SD0PWR;
+		bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR);
 	else
-		bcsr->board &= ~BCSR_BOARD_SD0PWR;
+		bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0);
 
-	au_sync_delay(1);
+	msleep(1);
 }
 
 static int pb1200mmc0_card_readonly(void *mmc_host)
 {
-	return (bcsr->status & BCSR_STATUS_SD0WP) ? 1 : 0;
+	return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 1 : 0;
 }
 
 static int pb1200mmc0_card_inserted(void *mmc_host)
 {
-	return (bcsr->sig_status & BCSR_INT_SD0INSERT) ? 1 : 0;
+	return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) ? 1 : 0;
 }
 
 static void pb1200_mmcled_set(struct led_classdev *led,
@@ -54,10 +55,10 @@ static void pb1200_mmcled_set(struct led_classdev *led,
 {
 	if (brightness != LED_OFF) {
 		if (++mmc_activity == 1)
-			bcsr->disk_leds &= ~(1 << 8);
+			bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
 	} else {
 		if (--mmc_activity == 0)
-			bcsr->disk_leds |= (1 << 8);
+			bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
 	}
 }
 
@@ -69,21 +70,21 @@ static struct led_classdev pb1200mmc_led = {
 static void pb1200mmc1_set_power(void *mmc_host, int state)
 {
 	if (state)
-		bcsr->board |= BCSR_BOARD_SD1PWR;
+		bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD1PWR);
 	else
-		bcsr->board &= ~BCSR_BOARD_SD1PWR;
+		bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD1PWR, 0);
 
-	au_sync_delay(1);
+	msleep(1);
 }
 
 static int pb1200mmc1_card_readonly(void *mmc_host)
 {
-	return (bcsr->status & BCSR_STATUS_SD1WP) ? 1 : 0;
+	return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD1WP) ? 1 : 0;
 }
 
 static int pb1200mmc1_card_inserted(void *mmc_host)
 {
-	return (bcsr->sig_status & BCSR_INT_SD1INSERT) ? 1 : 0;
+	return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT) ? 1 : 0;
 }
 #endif
 
diff --git a/arch/mips/alchemy/devboards/pb1500/board_setup.c b/arch/mips/alchemy/devboards/pb1500/board_setup.c
index d7a5656..c5389e5 100644
--- a/arch/mips/alchemy/devboards/pb1500/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1500/board_setup.c
@@ -30,6 +30,7 @@
 
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-pb1x00/pb1500.h>
+#include <asm/mach-db1x00/bcsr.h>
 
 #include <prom.h>
 
@@ -55,8 +56,7 @@ const char *get_system_type(void)
 
 void board_reset(void)
 {
-	/* Hit BCSR.RST_VDDI[SOFT_RESET] */
-	au_writel(0x00000000, PB1500_RST_VDDI);
+	bcsr_write(BCSR_SYSTEM, 0);
 }
 
 void __init board_init_irq(void)
@@ -70,6 +70,9 @@ void __init board_setup(void)
 	u32 sys_freqctrl, sys_clksrc;
 	char *argptr;
 
+	bcsr_init(DB1000_BCSR_PHYS_ADDR,
+		  DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS);
+
 	argptr = prom_getcmdline();
 #ifdef CONFIG_SERIAL_8250_CONSOLE
 	argptr = strstr(argptr, "console=");
diff --git a/arch/mips/alchemy/devboards/pb1550/board_setup.c b/arch/mips/alchemy/devboards/pb1550/board_setup.c
index b6e9e7d..af7a1b5 100644
--- a/arch/mips/alchemy/devboards/pb1550/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1550/board_setup.c
@@ -32,6 +32,7 @@
 
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-pb1x00/pb1550.h>
+#include <asm/mach-db1x00/bcsr.h>
 
 #include <prom.h>
 
@@ -53,8 +54,7 @@ const char *get_system_type(void)
 
 void board_reset(void)
 {
-	/* Hit BCSR.SYSTEM[RESET] */
-	au_writew(au_readw(0xAF00001C) & ~BCSR_SYSTEM_RESET, 0xAF00001C);
+	bcsr_write(BCSR_SYSTEM, 0);
 }
 
 void __init board_init_irq(void)
@@ -66,6 +66,10 @@ void __init board_setup(void)
 {
 	u32 pin_func;
 
+	bcsr_init(PB1550_BCSR_PHYS_ADDR,
+		  PB1550_BCSR_PHYS_ADDR + PB1550_BCSR_HEXLED_OFS);
+
+
 #ifdef CONFIG_SERIAL_8250_CONSOLE
 	char *argptr;
 	argptr = prom_getcmdline();
@@ -85,8 +89,7 @@ void __init board_setup(void)
 	pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1;
 	au_writel(pin_func, SYS_PINFUNC);
 
-	au_writel(0, (u32)bcsr | 0x10); /* turn off PCMCIA power */
-	au_sync();
+	bcsr_write(BCSR_PCMCIA, 0);	/* turn off PCMCIA power */
 
 	printk(KERN_INFO "AMD Alchemy Pb1550 Board\n");
 }
diff --git a/arch/mips/include/asm/mach-db1x00/bcsr.h b/arch/mips/include/asm/mach-db1x00/bcsr.h
new file mode 100644
index 0000000..3c80dae
--- /dev/null
+++ b/arch/mips/include/asm/mach-db1x00/bcsr.h
@@ -0,0 +1,232 @@
+/*
+ * bcsr.h -- Db1xxx/Pb1xxx Devboard CPLD registers ("BCSR") abstraction.
+ *
+ * All Alchemy development boards (except, of course, the weird PB1000)
+ * have a few registers in a CPLD with standardised layout; they mostly
+ * only differ in base address and bit meanings in the RESETS and BOARD
+ * registers.
+ *
+ * All data taken from the official AMD board documentation sheets.
+ */
+
+#ifndef _DB1XXX_BCSR_H_
+#define _DB1XXX_BCSR_H_
+
+
+/* BCSR base addresses on various boards */
+
+/* DB1000, DB1100, DB1500, PB1100, PB1500 */
+#define DB1000_BCSR_PHYS_ADDR	0x0E000000
+#define DB1000_BCSR_HEXLED_OFS	0x01000000
+
+#define DB1550_BCSR_PHYS_ADDR	0x0F000000
+#define DB1550_BCSR_HEXLED_OFS	0x00400000
+
+#define PB1550_BCSR_PHYS_ADDR	0x0F000000
+#define PB1550_BCSR_HEXLED_OFS	0x00800000
+
+#define DB1200_BCSR_PHYS_ADDR	0x19800000
+#define DB1200_BCSR_HEXLED_OFS	0x00400000
+
+#define PB1200_BCSR_PHYS_ADDR	0x0D800000
+#define PB1200_BCSR_HEXLED_OFS	0x00400000
+
+
+enum bcsr_id {
+	/* BCSR base 1 */
+	BCSR_WHOAMI	= 0,
+	BCSR_STATUS,
+	BCSR_SWITCHES,
+	BCSR_RESETS,
+	BCSR_PCMCIA,
+	BCSR_BOARD,
+	BCSR_LEDS,
+	BCSR_SYSTEM,
+	/* Au1200/1300 based boards */
+	BCSR_INTCLR,
+	BCSR_INTSET,
+	BCSR_MASKCLR,
+	BCSR_MASKSET,
+	BCSR_SIGSTAT,
+	BCSR_INTSTAT,
+
+	/* BCSR base 2 */
+	BCSR_HEXLEDS,
+	BCSR_RSVD1,
+	BCSR_HEXCLEAR,
+
+	BCSR_CNT,
+};
+
+/* register offsets, valid for all Db1xxx/Pb1xxx boards */
+#define BCSR_REG_WHOAMI		0x00
+#define BCSR_REG_STATUS		0x04
+#define BCSR_REG_SWITCHES	0x08
+#define BCSR_REG_RESETS		0x0c
+#define BCSR_REG_PCMCIA		0x10
+#define BCSR_REG_BOARD		0x14
+#define BCSR_REG_LEDS		0x18
+#define BCSR_REG_SYSTEM		0x1c
+/* Au1200/Au1300 based boards: CPLD IRQ muxer */
+#define BCSR_REG_INTCLR		0x20
+#define BCSR_REG_INTSET		0x24
+#define BCSR_REG_MASKCLR	0x28
+#define BCSR_REG_MASKSET	0x2c
+#define BCSR_REG_SIGSTAT	0x30
+#define BCSR_REG_INTSTAT	0x34
+
+/* hexled control, offset from BCSR base 2 */
+#define BCSR_REG_HEXLEDS	0x00
+#define BCSR_REG_HEXCLEAR	0x08
+
+/*
+ * Register Bits and Pieces.
+ */
+#define BCSR_WHOAMI_DCID(x)		((x) & 0xf)
+#define BCSR_WHOAMI_CPLD(x)		(((x) >> 4) & 0xf)
+#define BCSR_WHOAMI_BOARD(x)		(((x) >> 8) & 0xf)
+
+/* register "WHOAMI" bits 11:8 identify the board */
+enum bcsr_whoami_boards {
+	BCSR_WHOAMI_PB1500 = 1,
+	BCSR_WHOAMI_PB1500R2,
+	BCSR_WHOAMI_PB1100,
+	BCSR_WHOAMI_DB1000,
+	BCSR_WHOAMI_DB1100,
+	BCSR_WHOAMI_DB1500,
+	BCSR_WHOAMI_DB1550,
+	BCSR_WHOAMI_PB1550_DDR,
+	BCSR_WHOAMI_PB1550 = BCSR_WHOAMI_PB1550_DDR,
+	BCSR_WHOAMI_PB1550_SDR,
+	BCSR_WHOAMI_PB1200_DDR1,
+	BCSR_WHOAMI_PB1200 = BCSR_WHOAMI_PB1200_DDR1,
+	BCSR_WHOAMI_PB1200_DDR2,
+	BCSR_WHOAMI_DB1200,
+};
+
+/* STATUS reg.  Unless otherwise noted, theyre valid on all boards.
+ * PB1200 = DB1200.
+ */
+#define BCSR_STATUS_PC0VS		0x0003
+#define BCSR_STATUS_PC1VS		0x000C
+#define BCSR_STATUS_PC0FI		0x0010
+#define BCSR_STATUS_PC1FI		0x0020
+#define BCSR_STATUS_PB1550_SWAPBOOT	0x0040
+#define BCSR_STATUS_SRAMWIDTH		0x0080
+#define BCSR_STATUS_FLASHBUSY		0x0100
+#define BCSR_STATUS_ROMBUSY		0x0400
+#define BCSR_STATUS_SD0WP		0x0400	/* DB1200 */
+#define BCSR_STATUS_SD1WP		0x0800
+#define BCSR_STATUS_USBOTGID		0x0800	/* PB/DB1550 */
+#define BCSR_STATUS_DB1000_SWAPBOOT	0x2000
+#define BCSR_STATUS_DB1200_SWAPBOOT	0x0040	/* DB1200 */
+#define BCSR_STATUS_IDECBLID		0x0200	/* DB1200 */
+#define BCSR_STATUS_DB1200_U0RXD	0x1000	/* DB1200 */
+#define BCSR_STATUS_DB1299_U1RXD	0x2000	/* DB1200 */
+#define BCSR_STATUS_FLASHDEN		0xC000
+#define BCSR_STATUS_DB1550_U0RXD	0x1000	/* DB1550 */
+#define BCSR_STATUS_DB1550_U3RXD	0x2000	/* DB1550 */
+#define BCSR_STATUS_PB1550_U0RXD	0x1000	/* PB1550 */
+#define BCSR_STATUS_PB1550_U1RXD	0x2000	/* PB1550 */
+#define BCSR_STATUS_PB1550_U3RXD	0x8000	/* PB1550 */
+
+
+/* DB/PB1000,1100,1500,1550 */
+#define BCSR_RESETS_PHY0		0x0001
+#define BCSR_RESETS_PHY1		0x0002
+#define BCSR_RESETS_DC			0x0004
+#define BCSR_RESETS_FIR_SEL		0x2000
+#define BCSR_RESETS_IRDA_MODE_MASK	0xC000
+#define BCSR_RESETS_IRDA_MODE_FULL	0x0000
+#define BCSR_RESETS_PB1550_WSCFSM	0x2000
+#define BCSR_RESETS_IRDA_MODE_OFF	0x4000
+#define BCSR_RESETS_IRDA_MODE_2_3	0x8000
+#define BCSR_RESETS_IRDA_MODE_1_3	0xC000
+#define BCSR_RESETS_DMAREQ		0x8000	/* PB1550 */
+
+#define BCSR_BOARD_PCIM66EN		0x0001
+#define BCSR_BOARD_SD0PWR		0x0040
+#define BCSR_BOARD_SD1PWR		0x0080
+#define BCSR_BOARD_PCIM33		0x0100
+#define BCSR_BOARD_PCIEXTARB		0x0200
+#define BCSR_BOARD_GPIO200RST		0x0400
+#define BCSR_BOARD_PCICLKOUT		0x0800
+#define BCSR_BOARD_PCICFG		0x1000
+#define BCSR_BOARD_SPISEL		0x4000	/* PB/DB1550 */
+#define BCSR_BOARD_SD0WP		0x4000
+#define BCSR_BOARD_SD1WP		0x8000
+
+
+/* DB/PB1200 */
+#define BCSR_RESETS_ETH			0x0001
+#define BCSR_RESETS_CAMERA		0x0002
+#define BCSR_RESETS_DC			0x0004
+#define BCSR_RESETS_IDE			0x0008
+#define BCSR_RESETS_TV			0x0010	/* DB1200 */
+/* Not resets but in the same register */
+#define BCSR_RESETS_PWMR1MUX		0x0800	/* DB1200 */
+#define BCSR_RESETS_PB1200_WSCFSM	0x0800	/* PB1200 */
+#define BCSR_RESETS_PSC0MUX		0x1000
+#define BCSR_RESETS_PSC1MUX		0x2000
+#define BCSR_RESETS_SPISEL		0x4000
+#define BCSR_RESETS_SD1MUX		0x8000	/* PB1200 */
+
+#define BCSR_BOARD_LCDVEE		0x0001
+#define BCSR_BOARD_LCDVDD		0x0002
+#define BCSR_BOARD_LCDBL		0x0004
+#define BCSR_BOARD_CAMSNAP		0x0010
+#define BCSR_BOARD_CAMPWR		0x0020
+#define BCSR_BOARD_SD0PWR		0x0040
+
+
+#define BCSR_SWITCHES_DIP		0x00FF
+#define BCSR_SWITCHES_DIP_1		0x0080
+#define BCSR_SWITCHES_DIP_2		0x0040
+#define BCSR_SWITCHES_DIP_3		0x0020
+#define BCSR_SWITCHES_DIP_4		0x0010
+#define BCSR_SWITCHES_DIP_5		0x0008
+#define BCSR_SWITCHES_DIP_6		0x0004
+#define BCSR_SWITCHES_DIP_7		0x0002
+#define BCSR_SWITCHES_DIP_8		0x0001
+#define BCSR_SWITCHES_ROTARY		0x0F00
+
+
+#define BCSR_PCMCIA_PC0VPP		0x0003
+#define BCSR_PCMCIA_PC0VCC		0x000C
+#define BCSR_PCMCIA_PC0DRVEN		0x0010
+#define BCSR_PCMCIA_PC0RST		0x0080
+#define BCSR_PCMCIA_PC1VPP		0x0300
+#define BCSR_PCMCIA_PC1VCC		0x0C00
+#define BCSR_PCMCIA_PC1DRVEN		0x1000
+#define BCSR_PCMCIA_PC1RST		0x8000
+
+
+#define BCSR_LEDS_DECIMALS		0x0003
+#define BCSR_LEDS_LED0			0x0100
+#define BCSR_LEDS_LED1			0x0200
+#define BCSR_LEDS_LED2			0x0400
+#define BCSR_LEDS_LED3			0x0800
+
+
+#define BCSR_SYSTEM_RESET		0x8000	/* clear to reset */
+#define BCSR_SYSTEM_PWROFF		0x4000	/* set to power off */
+#define BCSR_SYSTEM_VDDI		0x001F	/* PB1xxx boards */
+
+
+
+
+/* initialize BCSR for a board. Provide the PHYSICAL addresses of both
+ * BCSR spaces.
+ */
+void __init bcsr_init(unsigned long bcsr1_phys, unsigned long bcsr2_phys);
+
+/* read a board register */
+unsigned short bcsr_read(enum bcsr_id reg);
+
+/* write to a board register */
+void bcsr_write(enum bcsr_id reg, unsigned short val);
+
+/* modify a register. clear bits set in 'clr', set bits set in 'set' */
+void bcsr_mod(enum bcsr_id reg, unsigned short clr, unsigned short set);
+
+#endif
diff --git a/arch/mips/include/asm/mach-db1x00/db1200.h b/arch/mips/include/asm/mach-db1x00/db1200.h
index 27f2610..2909b83 100644
--- a/arch/mips/include/asm/mach-db1x00/db1200.h
+++ b/arch/mips/include/asm/mach-db1x00/db1200.h
@@ -45,113 +45,6 @@
 #define AC97_PSC_BASE		PSC1_BASE_ADDR
 #define I2S_PSC_BASE		PSC1_BASE_ADDR
 
-#define BCSR_KSEG1_ADDR 	0xB9800000
-
-typedef volatile struct
-{
-	/*00*/	u16 whoami;
-		u16 reserved0;
-	/*04*/	u16 status;
-		u16 reserved1;
-	/*08*/	u16 switches;
-		u16 reserved2;
-	/*0C*/	u16 resets;
-		u16 reserved3;
-
-	/*10*/	u16 pcmcia;
-		u16 reserved4;
-	/*14*/	u16 board;
-		u16 reserved5;
-	/*18*/	u16 disk_leds;
-		u16 reserved6;
-	/*1C*/	u16 system;
-		u16 reserved7;
-
-	/*20*/	u16 intclr;
-		u16 reserved8;
-	/*24*/	u16 intset;
-		u16 reserved9;
-	/*28*/	u16 intclr_mask;
-		u16 reserved10;
-	/*2C*/	u16 intset_mask;
-		u16 reserved11;
-
-	/*30*/	u16 sig_status;
-		u16 reserved12;
-	/*34*/	u16 int_status;
-		u16 reserved13;
-	/*38*/	u16 reserved14;
-		u16 reserved15;
-	/*3C*/	u16 reserved16;
-		u16 reserved17;
-
-} BCSR;
-
-static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
-
-/*
- * Register bit definitions for the BCSRs
- */
-#define BCSR_WHOAMI_DCID	0x000F
-#define BCSR_WHOAMI_CPLD	0x00F0
-#define BCSR_WHOAMI_BOARD	0x0F00
-
-#define BCSR_STATUS_PCMCIA0VS	0x0003
-#define BCSR_STATUS_PCMCIA1VS	0x000C
-#define BCSR_STATUS_SWAPBOOT	0x0040
-#define BCSR_STATUS_FLASHBUSY	0x0100
-#define BCSR_STATUS_IDECBLID	0x0200
-#define BCSR_STATUS_SD0WP	0x0400
-#define BCSR_STATUS_U0RXD	0x1000
-#define BCSR_STATUS_U1RXD	0x2000
-
-#define BCSR_SWITCHES_OCTAL	0x00FF
-#define BCSR_SWITCHES_DIP_1	0x0080
-#define BCSR_SWITCHES_DIP_2	0x0040
-#define BCSR_SWITCHES_DIP_3	0x0020
-#define BCSR_SWITCHES_DIP_4	0x0010
-#define BCSR_SWITCHES_DIP_5	0x0008
-#define BCSR_SWITCHES_DIP_6	0x0004
-#define BCSR_SWITCHES_DIP_7	0x0002
-#define BCSR_SWITCHES_DIP_8	0x0001
-#define BCSR_SWITCHES_ROTARY	0x0F00
-
-#define BCSR_RESETS_ETH		0x0001
-#define BCSR_RESETS_CAMERA	0x0002
-#define BCSR_RESETS_DC		0x0004
-#define BCSR_RESETS_IDE		0x0008
-#define BCSR_RESETS_TV		0x0010
-/* Not resets but in the same register */
-#define BCSR_RESETS_PWMR1MUX	0x0800
-#define BCSR_RESETS_PCS0MUX	0x1000
-#define BCSR_RESETS_PCS1MUX	0x2000
-#define BCSR_RESETS_SPISEL	0x4000
-
-#define BCSR_PCMCIA_PC0VPP	0x0003
-#define BCSR_PCMCIA_PC0VCC	0x000C
-#define BCSR_PCMCIA_PC0DRVEN	0x0010
-#define BCSR_PCMCIA_PC0RST	0x0080
-#define BCSR_PCMCIA_PC1VPP	0x0300
-#define BCSR_PCMCIA_PC1VCC	0x0C00
-#define BCSR_PCMCIA_PC1DRVEN	0x1000
-#define BCSR_PCMCIA_PC1RST	0x8000
-
-#define BCSR_BOARD_LCDVEE	0x0001
-#define BCSR_BOARD_LCDVDD	0x0002
-#define BCSR_BOARD_LCDBL	0x0004
-#define BCSR_BOARD_CAMSNAP	0x0010
-#define BCSR_BOARD_CAMPWR	0x0020
-#define BCSR_BOARD_SD0PWR	0x0040
-
-#define BCSR_LEDS_DECIMALS	0x0003
-#define BCSR_LEDS_LED0		0x0100
-#define BCSR_LEDS_LED1		0x0200
-#define BCSR_LEDS_LED2		0x0400
-#define BCSR_LEDS_LED3		0x0800
-
-#define BCSR_SYSTEM_POWEROFF	0x4000
-#define BCSR_SYSTEM_RESET	0x8000
-
 /* Bit positions for the different interrupt sources */
 #define BCSR_INT_IDE		0x0001
 #define BCSR_INT_ETH		0x0002
@@ -222,7 +115,7 @@ enum external_pb1200_ints {
 
 #define BOARD_PC0_INT	DB1200_PC0_INT
 #define BOARD_PC1_INT	DB1200_PC1_INT
-#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1 << (8 + (2 * SOCKET)))
+#define BOARD_CARD_INSERTED(SOCKET) (bcsr_read(BCSR_SIGSTAT) & (1 << (8 + (2 * SOCKET))))
 
 /* NAND chip select */
 #define NAND_CS 1
diff --git a/arch/mips/include/asm/mach-db1x00/db1x00.h b/arch/mips/include/asm/mach-db1x00/db1x00.h
index 1a515b8..cfa6429 100644
--- a/arch/mips/include/asm/mach-db1x00/db1x00.h
+++ b/arch/mips/include/asm/mach-db1x00/db1x00.h
@@ -41,102 +41,10 @@
 #define SMBUS_PSC_BASE		PSC2_BASE_ADDR
 #define I2S_PSC_BASE		PSC3_BASE_ADDR
 
-#define BCSR_KSEG1_ADDR 	0xAF000000
 #define NAND_PHYS_ADDR		0x20000000
 
-#else
-#define BCSR_KSEG1_ADDR 0xAE000000
 #endif
 
-/*
- * Overlay data structure of the DBAu1x00 board registers.
- * Registers are located at physical 0E0000xx, KSEG1 0xAE0000xx.
- */
-typedef volatile struct
-{
-	/*00*/	unsigned short whoami;
-	unsigned short reserved0;
-	/*04*/	unsigned short status;
-	unsigned short reserved1;
-	/*08*/	unsigned short switches;
-	unsigned short reserved2;
-	/*0C*/	unsigned short resets;
-	unsigned short reserved3;
-	/*10*/	unsigned short pcmcia;
-	unsigned short reserved4;
-	/*14*/	unsigned short specific;
-	unsigned short reserved5;
-	/*18*/	unsigned short leds;
-	unsigned short reserved6;
-	/*1C*/	unsigned short swreset;
-	unsigned short reserved7;
-
-} BCSR;
-
-
-/*
- * Register/mask bit definitions for the BCSRs
- */
-#define BCSR_WHOAMI_DCID		0x000F
-#define BCSR_WHOAMI_CPLD		0x00F0
-#define BCSR_WHOAMI_BOARD		0x0F00
-
-#define BCSR_STATUS_PC0VS		0x0003
-#define BCSR_STATUS_PC1VS		0x000C
-#define BCSR_STATUS_PC0FI		0x0010
-#define BCSR_STATUS_PC1FI		0x0020
-#define BCSR_STATUS_FLASHBUSY		0x0100
-#define BCSR_STATUS_ROMBUSY		0x0400
-#define BCSR_STATUS_SWAPBOOT		0x2000
-#define BCSR_STATUS_FLASHDEN		0xC000
-
-#define BCSR_SWITCHES_DIP		0x00FF
-#define BCSR_SWITCHES_DIP_1		0x0080
-#define BCSR_SWITCHES_DIP_2		0x0040
-#define BCSR_SWITCHES_DIP_3		0x0020
-#define BCSR_SWITCHES_DIP_4		0x0010
-#define BCSR_SWITCHES_DIP_5		0x0008
-#define BCSR_SWITCHES_DIP_6		0x0004
-#define BCSR_SWITCHES_DIP_7		0x0002
-#define BCSR_SWITCHES_DIP_8		0x0001
-#define BCSR_SWITCHES_ROTARY		0x0F00
-
-#define BCSR_RESETS_PHY0		0x0001
-#define BCSR_RESETS_PHY1		0x0002
-#define BCSR_RESETS_DC			0x0004
-#define BCSR_RESETS_FIR_SEL		0x2000
-#define BCSR_RESETS_IRDA_MODE_MASK	0xC000
-#define BCSR_RESETS_IRDA_MODE_FULL	0x0000
-#define BCSR_RESETS_IRDA_MODE_OFF	0x4000
-#define BCSR_RESETS_IRDA_MODE_2_3	0x8000
-#define BCSR_RESETS_IRDA_MODE_1_3	0xC000
-
-#define BCSR_PCMCIA_PC0VPP		0x0003
-#define BCSR_PCMCIA_PC0VCC		0x000C
-#define BCSR_PCMCIA_PC0DRVEN		0x0010
-#define BCSR_PCMCIA_PC0RST		0x0080
-#define BCSR_PCMCIA_PC1VPP		0x0300
-#define BCSR_PCMCIA_PC1VCC		0x0C00
-#define BCSR_PCMCIA_PC1DRVEN		0x1000
-#define BCSR_PCMCIA_PC1RST		0x8000
-
-#define BCSR_BOARD_PCIM66EN		0x0001
-#define BCSR_BOARD_SD0_PWR		0x0040
-#define BCSR_BOARD_SD1_PWR		0x0080
-#define BCSR_BOARD_PCIM33		0x0100
-#define BCSR_BOARD_GPIO200RST		0x0400
-#define BCSR_BOARD_PCICFG		0x1000
-#define BCSR_BOARD_SD0_WP		0x4000
-#define BCSR_BOARD_SD1_WP		0x8000
-
-#define BCSR_LEDS_DECIMALS		0x0003
-#define BCSR_LEDS_LED0			0x0100
-#define BCSR_LEDS_LED1			0x0200
-#define BCSR_LEDS_LED2			0x0400
-#define BCSR_LEDS_LED3			0x0800
-
-#define BCSR_SWRESET_RESET		0x0080
-
 /* PCMCIA DBAu1x00 specific defines */
 #define PCMCIA_MAX_SOCK  1
 #define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1100.h b/arch/mips/include/asm/mach-pb1x00/pb1100.h
index b1a60f1..f2bf73a 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1100.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1100.h
@@ -26,55 +26,6 @@
 #ifndef __ASM_PB1100_H
 #define __ASM_PB1100_H
 
-#define PB1100_IDENT		0xAE000000
-#define BOARD_STATUS_REG	0xAE000004
-#  define PB1100_ROM_SEL	(1 << 15)
-#  define PB1100_ROM_SIZ	(1 << 14)
-#  define PB1100_SWAP_BOOT	(1 << 13)
-#  define PB1100_FLASH_WP	(1 << 12)
-#  define PB1100_ROM_H_STS	(1 << 11)
-#  define PB1100_ROM_L_STS	(1 << 10)
-#  define PB1100_FLASH_H_STS	(1 << 9)
-#  define PB1100_FLASH_L_STS	(1 << 8)
-#  define PB1100_SRAM_SIZ	(1 << 7)
-#  define PB1100_TSC_BUSY	(1 << 6)
-#  define PB1100_PCMCIA_VS_MASK (3 << 4)
-#  define PB1100_RS232_CD	(1 << 3)
-#  define PB1100_RS232_CTS	(1 << 2)
-#  define PB1100_RS232_DSR	(1 << 1)
-#  define PB1100_RS232_RI	(1 << 0)
-
-#define PB1100_IRDA_RS232	0xAE00000C
-#  define PB1100_IRDA_FULL	(0 << 14)	/* full power		*/
-#  define PB1100_IRDA_SHUTDOWN	(1 << 14)
-#  define PB1100_IRDA_TT	(2 << 14)	/* 2/3 power		*/
-#  define PB1100_IRDA_OT	(3 << 14)	/* 1/3 power		*/
-#  define PB1100_IRDA_FIR	(1 << 13)
-
-#define PCMCIA_BOARD_REG	0xAE000010
-#  define PB1100_SD_WP1_RO	(1 << 15)	/* read only		*/
-#  define PB1100_SD_WP0_RO	(1 << 14)	/* read only		*/
-#  define PB1100_SD_PWR1	(1 << 11)	/* applies power to SD1 */
-#  define PB1100_SD_PWR0	(1 << 10)	/* applies power to SD0 */
-#  define PB1100_SEL_SD_CONN1	(1 << 9)
-#  define PB1100_SEL_SD_CONN0	(1 << 8)
-#  define PC_DEASSERT_RST	(1 << 7)
-#  define PC_DRV_EN		(1 << 4)
-
-#define PB1100_G_CONTROL	0xAE000014	/* graphics control	*/
-
-#define PB1100_RST_VDDI 	0xAE00001C
-#  define PB1100_SOFT_RESET	(1 << 15)	/* clear to reset the board */
-#  define PB1100_VDDI_MASK	0x1F
-
-#define PB1100_LEDS		0xAE000018
-
-/*
- * 11:8 is 4 discreet LEDs. Clearing a bit illuminates the LED.
- * 7:0  is the LED Display's decimal points.
- */
-#define PB1100_HEX_LED		0xAE000018
-
 /* PCMCIA Pb1100 specific defines */
 #define PCMCIA_MAX_SOCK  0
 #define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1200.h b/arch/mips/include/asm/mach-pb1x00/pb1200.h
index c8618df..a51512c 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1200.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1200.h
@@ -43,113 +43,8 @@
  * Refer to board documentation.
  */
 #define AC97_PSC_BASE       PSC1_BASE_ADDR
-#define I2S_PSC_BASE		PSC1_BASE_ADDR
+#define I2S_PSC_BASE	PSC1_BASE_ADDR
 
-#define BCSR_KSEG1_ADDR 0xAD800000
-
-typedef volatile struct
-{
-	/*00*/	u16 whoami;
-		u16 reserved0;
-	/*04*/	u16 status;
-		u16 reserved1;
-	/*08*/	u16 switches;
-		u16 reserved2;
-	/*0C*/	u16 resets;
-		u16 reserved3;
-
-	/*10*/	u16 pcmcia;
-		u16 reserved4;
-	/*14*/	u16 board;
-		u16 reserved5;
-	/*18*/	u16 disk_leds;
-		u16 reserved6;
-	/*1C*/	u16 system;
-		u16 reserved7;
-
-	/*20*/	u16 intclr;
-		u16 reserved8;
-	/*24*/	u16 intset;
-		u16 reserved9;
-	/*28*/	u16 intclr_mask;
-		u16 reserved10;
-	/*2C*/	u16 intset_mask;
-		u16 reserved11;
-
-	/*30*/	u16 sig_status;
-		u16 reserved12;
-	/*34*/	u16 int_status;
-		u16 reserved13;
-	/*38*/	u16 reserved14;
-		u16 reserved15;
-	/*3C*/	u16 reserved16;
-		u16 reserved17;
-
-} BCSR;
-
-static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
-
-/*
- * Register bit definitions for the BCSRs
- */
-#define BCSR_WHOAMI_DCID	0x000F
-#define BCSR_WHOAMI_CPLD	0x00F0
-#define BCSR_WHOAMI_BOARD	0x0F00
-
-#define BCSR_STATUS_PCMCIA0VS	0x0003
-#define BCSR_STATUS_PCMCIA1VS	0x000C
-#define BCSR_STATUS_SWAPBOOT	0x0040
-#define BCSR_STATUS_FLASHBUSY	0x0100
-#define BCSR_STATUS_IDECBLID	0x0200
-#define BCSR_STATUS_SD0WP	0x0400
-#define BCSR_STATUS_SD1WP	0x0800
-#define BCSR_STATUS_U0RXD	0x1000
-#define BCSR_STATUS_U1RXD	0x2000
-
-#define BCSR_SWITCHES_OCTAL	0x00FF
-#define BCSR_SWITCHES_DIP_1	0x0080
-#define BCSR_SWITCHES_DIP_2	0x0040
-#define BCSR_SWITCHES_DIP_3	0x0020
-#define BCSR_SWITCHES_DIP_4	0x0010
-#define BCSR_SWITCHES_DIP_5	0x0008
-#define BCSR_SWITCHES_DIP_6	0x0004
-#define BCSR_SWITCHES_DIP_7	0x0002
-#define BCSR_SWITCHES_DIP_8	0x0001
-#define BCSR_SWITCHES_ROTARY	0x0F00
-
-#define BCSR_RESETS_ETH		0x0001
-#define BCSR_RESETS_CAMERA	0x0002
-#define BCSR_RESETS_DC		0x0004
-#define BCSR_RESETS_IDE		0x0008
-/* not resets but in the same register */
-#define BCSR_RESETS_WSCFSM	0x0800
-#define BCSR_RESETS_PCS0MUX	0x1000
-#define BCSR_RESETS_PCS1MUX	0x2000
-#define BCSR_RESETS_SPISEL	0x4000
-#define BCSR_RESETS_SD1MUX	0x8000
-
-#define BCSR_PCMCIA_PC0VPP	0x0003
-#define BCSR_PCMCIA_PC0VCC	0x000C
-#define BCSR_PCMCIA_PC0DRVEN	0x0010
-#define BCSR_PCMCIA_PC0RST	0x0080
-#define BCSR_PCMCIA_PC1VPP	0x0300
-#define BCSR_PCMCIA_PC1VCC	0x0C00
-#define BCSR_PCMCIA_PC1DRVEN	0x1000
-#define BCSR_PCMCIA_PC1RST	0x8000
-
-#define BCSR_BOARD_LCDVEE	0x0001
-#define BCSR_BOARD_LCDVDD	0x0002
-#define BCSR_BOARD_LCDBL	0x0004
-#define BCSR_BOARD_CAMSNAP	0x0010
-#define BCSR_BOARD_CAMPWR	0x0020
-#define BCSR_BOARD_SD0PWR	0x0040
-#define BCSR_BOARD_SD1PWR	0x0080
-
-#define BCSR_LEDS_DECIMALS	0x00FF
-#define BCSR_LEDS_LED0		0x0100
-#define BCSR_LEDS_LED1		0x0200
-#define BCSR_LEDS_LED2		0x0400
-#define BCSR_LEDS_LED3		0x0800
 
 #define BCSR_SYSTEM_VDDI	0x001F
 #define BCSR_SYSTEM_POWEROFF	0x4000
@@ -251,7 +146,7 @@ enum external_pb1200_ints {
 
 #define BOARD_PC0_INT	PB1200_PC0_INT
 #define BOARD_PC1_INT	PB1200_PC1_INT
-#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1 << (8 + (2 * SOCKET)))
+#define BOARD_CARD_INSERTED(SOCKET) (bcsr_read(BCSR_SIGSTAT & (1 << (8 + (2 * SOCKET))))
 
 /* NAND chip select */
 #define NAND_CS 1
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1500.h b/arch/mips/include/asm/mach-pb1x00/pb1500.h
index da51a2e..82431a7 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1500.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1500.h
@@ -26,19 +26,6 @@
 #ifndef __ASM_PB1500_H
 #define __ASM_PB1500_H
 
-#define IDENT_BOARD_REG 	0xAE000000
-#define BOARD_STATUS_REG	0xAE000004
-#define PCI_BOARD_REG		0xAE000010
-#define PCMCIA_BOARD_REG	0xAE000010
-#  define PC_DEASSERT_RST	      0x80
-#  define PC_DRV_EN		      0x10
-#define PB1500_G_CONTROL	0xAE000014
-#define PB1500_RST_VDDI 	0xAE00001C
-#define PB1500_LEDS		0xAE000018
-
-#define PB1500_HEX_LED		0xAF000004
-#define PB1500_HEX_LED_BLANK	0xAF000008
-
 /* PCMCIA Pb1500 specific defines */
 #define PCMCIA_MAX_SOCK  0
 #define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1550.h b/arch/mips/include/asm/mach-pb1x00/pb1550.h
index 6704a11..306d584 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1550.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1550.h
@@ -40,95 +40,6 @@
 #define SMBUS_PSC_BASE		PSC2_BASE_ADDR
 #define I2S_PSC_BASE		PSC3_BASE_ADDR
 
-#define BCSR_PHYS_ADDR 0xAF000000
-
-typedef volatile struct
-{
-	/*00*/	u16 whoami;
-		u16 reserved0;
-	/*04*/	u16 status;
-		u16 reserved1;
-	/*08*/	u16 switches;
-		u16 reserved2;
-	/*0C*/	u16 resets;
-		u16 reserved3;
-	/*10*/	u16 pcmcia;
-		u16 reserved4;
-	/*14*/	u16 pci;
-		u16 reserved5;
-	/*18*/	u16 leds;
-		u16 reserved6;
-	/*1C*/	u16 system;
-		u16 reserved7;
-
-} BCSR;
-
-static BCSR * const bcsr = (BCSR *)BCSR_PHYS_ADDR;
-
-/*
- * Register bit definitions for the BCSRs
- */
-#define BCSR_WHOAMI_DCID	0x000F
-#define BCSR_WHOAMI_CPLD	0x00F0
-#define BCSR_WHOAMI_BOARD	0x0F00
-
-#define BCSR_STATUS_PCMCIA0VS	0x0003
-#define BCSR_STATUS_PCMCIA1VS	0x000C
-#define BCSR_STATUS_PCMCIA0FI	0x0010
-#define BCSR_STATUS_PCMCIA1FI	0x0020
-#define BCSR_STATUS_SWAPBOOT	0x0040
-#define BCSR_STATUS_SRAMWIDTH	0x0080
-#define BCSR_STATUS_FLASHBUSY	0x0100
-#define BCSR_STATUS_ROMBUSY	0x0200
-#define BCSR_STATUS_USBOTGID	0x0800
-#define BCSR_STATUS_U0RXD	0x1000
-#define BCSR_STATUS_U1RXD	0x2000
-#define BCSR_STATUS_U3RXD	0x8000
-
-#define BCSR_SWITCHES_OCTAL	0x00FF
-#define BCSR_SWITCHES_DIP_1	0x0080
-#define BCSR_SWITCHES_DIP_2	0x0040
-#define BCSR_SWITCHES_DIP_3	0x0020
-#define BCSR_SWITCHES_DIP_4	0x0010
-#define BCSR_SWITCHES_DIP_5	0x0008
-#define BCSR_SWITCHES_DIP_6	0x0004
-#define BCSR_SWITCHES_DIP_7	0x0002
-#define BCSR_SWITCHES_DIP_8	0x0001
-#define BCSR_SWITCHES_ROTARY	0x0F00
-
-#define BCSR_RESETS_PHY0	0x0001
-#define BCSR_RESETS_PHY1	0x0002
-#define BCSR_RESETS_DC		0x0004
-#define BCSR_RESETS_WSC		0x2000
-#define BCSR_RESETS_SPISEL	0x4000
-#define BCSR_RESETS_DMAREQ	0x8000
-
-#define BCSR_PCMCIA_PC0VPP	0x0003
-#define BCSR_PCMCIA_PC0VCC	0x000C
-#define BCSR_PCMCIA_PC0DRVEN	0x0010
-#define BCSR_PCMCIA_PC0RST	0x0080
-#define BCSR_PCMCIA_PC1VPP	0x0300
-#define BCSR_PCMCIA_PC1VCC	0x0C00
-#define BCSR_PCMCIA_PC1DRVEN	0x1000
-#define BCSR_PCMCIA_PC1RST	0x8000
-
-#define BCSR_PCI_M66EN		0x0001
-#define BCSR_PCI_M33		0x0100
-#define BCSR_PCI_EXTERNARB	0x0200
-#define BCSR_PCI_GPIO200RST	0x0400
-#define BCSR_PCI_CLKOUT		0x0800
-#define BCSR_PCI_CFGHOST	0x1000
-
-#define BCSR_LEDS_DECIMALS	0x00FF
-#define BCSR_LEDS_LED0		0x0100
-#define BCSR_LEDS_LED1		0x0200
-#define BCSR_LEDS_LED2		0x0400
-#define BCSR_LEDS_LED3		0x0800
-
-#define BCSR_SYSTEM_VDDI	0x001F
-#define BCSR_SYSTEM_POWEROFF	0x4000
-#define BCSR_SYSTEM_RESET	0x8000
-
 #define PCMCIA_MAX_SOCK  1
 #define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
 
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index 92c334f..43d46e4 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -19,6 +19,7 @@
 #include <asm/io.h>
 
 #include <asm/mach-au1x00/au1xxx.h>
+#include <asm/mach-db1x00/bcsr.h>
 
 /*
  * MTD structure for NAND controller
@@ -475,7 +476,8 @@ static int __init au1xxx_nand_init(void)
 	/* set gpio206 high */
 	au_writel(au_readl(GPIO2_DIR) & ~(1 << 6), GPIO2_DIR);
 
-	boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) | ((bcsr->status >> 6) & 0x1);
+	boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) | ((bcsr_read(BCSR_STATUS) >> 6) & 0x1);
+
 	switch (boot_swapboot) {
 	case 0:
 	case 2:
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index eb42468..955f04e 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -36,6 +36,7 @@
 #include <asm/pb1000.h>
 #elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100)
 #include <asm/db1x00.h>
+#include <asm/mach-db1x00/bcsr.h>
 #else 
 #error au1k_ir: unsupported board
 #endif
@@ -66,10 +67,6 @@ static char version[] __devinitdata =
 
 #define RUN_AT(x) (jiffies + (x))
 
-#if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100)
-static BCSR * const bcsr = (BCSR *)0xAE000000;
-#endif
-
 static DEFINE_SPINLOCK(ir_lock);
 
 /*
@@ -282,9 +279,8 @@ static int au1k_irda_net_init(struct net_device *dev)
 
 #if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100)
 	/* power on */
-	bcsr->resets &= ~BCSR_RESETS_IRDA_MODE_MASK;
-	bcsr->resets |= BCSR_RESETS_IRDA_MODE_FULL;
-	au_sync();
+	bcsr_mod(BCSR_RESETS, BCSR_RESETS_IRDA_MODE_MASK,
+			      BCSR_RESETS_IRDA_MODE_FULL);
 #endif
 
 	return 0;
@@ -720,14 +716,14 @@ au1k_irda_set_speed(struct net_device *dev, int speed)
 
 	if (speed == 4000000) {
 #if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100)
-		bcsr->resets |= BCSR_RESETS_FIR_SEL;
+		bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_FIR_SEL);
 #else /* Pb1000 and Pb1100 */
 		writel(1<<13, CPLD_AUX1);
 #endif
 	}
 	else {
 #if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100)
-		bcsr->resets &= ~BCSR_RESETS_FIR_SEL;
+		bcsr_mod(BCSR_RESETS, BCSR_RESETS_FIR_SEL, 0);
 #else /* Pb1000 and Pb1100 */
 		writel(readl(CPLD_AUX1) & ~(1<<13), CPLD_AUX1);
 #endif
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c
index c78d77f..6832254 100644
--- a/drivers/pcmcia/au1000_db1x00.c
+++ b/drivers/pcmcia/au1000_db1x00.c
@@ -47,9 +47,9 @@
 	#include <pb1200.h>
 #else
 	#include <asm/mach-db1x00/db1x00.h>
-	static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
 #endif
 
+#include <asm/mach-db1x00/bcsr.h>
 #include "au1000_generic.h"
 
 #if 0
@@ -76,8 +76,8 @@ static int db1x00_pcmcia_hw_init(struct au1000_pcmcia_socket *skt)
 
 static void db1x00_pcmcia_shutdown(struct au1000_pcmcia_socket *skt)
 {
-	bcsr->pcmcia = 0; /* turn off power */
-	au_sync_delay(2);
+	bcsr_write(BCSR_PCMCIA, 0);	/* turn off power */
+	msleep(2);
 }
 
 static void
@@ -93,19 +93,19 @@ db1x00_pcmcia_socket_state(struct au1000_pcmcia_socket *skt, struct pcmcia_state
 
 	switch (skt->nr) {
 	case 0:
-		vs = bcsr->status & 0x3;
+		vs = bcsr_read(BCSR_STATUS) & 0x3;
 #if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
 		inserted = BOARD_CARD_INSERTED(0);
 #else
-		inserted = !(bcsr->status & (1<<4));
+		inserted = !(bcsr_read(BCSR_STATUS) & (1 << 4));
 #endif
 		break;
 	case 1:
-		vs = (bcsr->status & 0xC)>>2;
+		vs = (bcsr_read(BCSR_STATUS) & 0xC) >> 2;
 #if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
 		inserted = BOARD_CARD_INSERTED(1);
 #else
-		inserted = !(bcsr->status & (1<<5));
+		inserted = !(bcsr_read(BCSR_STATUS) & (1<<5));
 #endif
 		break;
 	default:/* should never happen */
@@ -114,7 +114,7 @@ db1x00_pcmcia_socket_state(struct au1000_pcmcia_socket *skt, struct pcmcia_state
 
 	if (inserted)
 		debug("db1x00 socket %d: inserted %d, vs %d pcmcia %x\n",
-				skt->nr, inserted, vs, bcsr->pcmcia);
+				skt->nr, inserted, vs, bcsr_read(BCSR_PCMCIA));
 
 	if (inserted) {
 		switch (vs) {
@@ -136,19 +136,21 @@ db1x00_pcmcia_socket_state(struct au1000_pcmcia_socket *skt, struct pcmcia_state
 		/* if the card was previously inserted and then ejected,
 		 * we should turn off power to it
 		 */
-		if ((skt->nr == 0) && (bcsr->pcmcia & BCSR_PCMCIA_PC0RST)) {
-			bcsr->pcmcia &= ~(BCSR_PCMCIA_PC0RST |
-					BCSR_PCMCIA_PC0DRVEN |
-					BCSR_PCMCIA_PC0VPP |
-					BCSR_PCMCIA_PC0VCC);
-			au_sync_delay(10);
+		if ((skt->nr == 0) &&
+		    (bcsr_read(BCSR_PCMCIA) & BCSR_PCMCIA_PC0RST)) {
+			bcsr_mod(BCSR_PCMCIA, BCSR_PCMCIA_PC0RST   |
+					      BCSR_PCMCIA_PC0DRVEN |
+					      BCSR_PCMCIA_PC0VPP   |
+					      BCSR_PCMCIA_PC0VCC, 0);
+			msleep(10);
 		}
-		else if ((skt->nr == 1) && bcsr->pcmcia & BCSR_PCMCIA_PC1RST) {
-			bcsr->pcmcia &= ~(BCSR_PCMCIA_PC1RST |
-					BCSR_PCMCIA_PC1DRVEN |
-					BCSR_PCMCIA_PC1VPP |
-					BCSR_PCMCIA_PC1VCC);
-			au_sync_delay(10);
+		else if ((skt->nr == 1) &&
+			 (bcsr_read(BCSR_PCMCIA) & BCSR_PCMCIA_PC1RST)) {
+			bcsr_mod(BCSR_PCMCIA, BCSR_PCMCIA_PC1RST   |
+					      BCSR_PCMCIA_PC1DRVEN |
+					      BCSR_PCMCIA_PC1VPP   |
+					      BCSR_PCMCIA_PC1VCC, 0);
+			msleep(10);
 		}
 	}
 
@@ -171,7 +173,7 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s
 	 * initializing a socket not to wipe out the settings of the
 	 * other socket.
 	 */
-	pwr = bcsr->pcmcia;
+	pwr = bcsr_read(BCSR_PCMCIA);
 	pwr &= ~(0xf << sock*8); /* clear voltage settings */
 
 	state->Vpp = 0;
@@ -228,37 +230,37 @@ db1x00_pcmcia_configure_socket(struct au1000_pcmcia_socket *skt, struct socket_s
 			break;
 	}
 
-	bcsr->pcmcia = pwr;
-	au_sync_delay(300);
+	bcsr_write(BCSR_PCMCIA, pwr);
+	msleep(3);
 
 	if (sock == 0) {
 		if (!(state->flags & SS_RESET)) {
 			pwr |= BCSR_PCMCIA_PC0DRVEN;
-			bcsr->pcmcia = pwr;
-			au_sync_delay(300);
+			bcsr_write(BCSR_PCMCIA, pwr);
+			msleep(300);
 			pwr |= BCSR_PCMCIA_PC0RST;
-			bcsr->pcmcia = pwr;
-			au_sync_delay(100);
+			bcsr_write(BCSR_PCMCIA, pwr);
+			msleep(100);
 		}
 		else {
 			pwr &= ~(BCSR_PCMCIA_PC0RST | BCSR_PCMCIA_PC0DRVEN);
-			bcsr->pcmcia = pwr;
-			au_sync_delay(100);
+			bcsr_write(BCSR_PCMCIA, pwr);
+			msleep(100);
 		}
 	}
 	else {
 		if (!(state->flags & SS_RESET)) {
 			pwr |= BCSR_PCMCIA_PC1DRVEN;
-			bcsr->pcmcia = pwr;
-			au_sync_delay(300);
+			bcsr_write(BCSR_PCMCIA, pwr);
+			msleep(300);
 			pwr |= BCSR_PCMCIA_PC1RST;
-			bcsr->pcmcia = pwr;
-			au_sync_delay(100);
+			bcsr_write(BCSR_PCMCIA, pwr);
+			msleep(100);
 		}
 		else {
 			pwr &= ~(BCSR_PCMCIA_PC1RST | BCSR_PCMCIA_PC1DRVEN);
-			bcsr->pcmcia = pwr;
-			au_sync_delay(100);
+			bcsr_write(BCSR_PCMCIA, pwr);
+			msleep(100);
 		}
 	}
 	return 0;
@@ -298,8 +300,8 @@ struct pcmcia_low_level db1x00_pcmcia_ops = {
 int au1x_board_init(struct device *dev)
 {
 	int ret = -ENODEV;
-	bcsr->pcmcia = 0; /* turn off power, if it's not already off */
-	au_sync_delay(2);
+	bcsr_write(BCSR_PCMCIA, 0); /* turn off power, if it's not already off */
+	msleep(2);
 	ret = au1x00_pcmcia_socket_probe(dev, &db1x00_pcmcia_ops, 0, 2);
 	return ret;
 }
-- 
1.6.5.rc1


From manuel.lauss@googlemail.com Tue Sep 29 20:50:44 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 29 Sep 2009 20:50:50 +0200 (CEST)
Received: from fg-out-1718.google.com ([72.14.220.158]:56487 "EHLO
	fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by ftp.linux-mips.org
	with ESMTP id S1493672AbZI2Suo (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Tue, 29 Sep 2009 20:50:44 +0200
Received: by fg-out-1718.google.com with SMTP id e21so1032723fga.6
        for <linux-mips@linux-mips.org>; Tue, 29 Sep 2009 11:50:40 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=chwiPF1GgyowEfe63jOZZiPCUJeiGmtOL3t86BcLUo4=;
        b=caTfLMBggRuxcc1570fBT7hB6jMEHH5H6SFeVt+sHNgH1piZC9aXN/8irZqkQNrk32
         VgQNv27lstck4jOSDACQ8fg6CNtwCV8OrS+xMLmYauGXypAb/GxTaIY5PETGldX6ju9h
         SeoQLlVmUv1+vyma0PlRFDfZSA3vIK5TpjPHw=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=gV2+h6jL7rBCx1ayyVkvfQpx5t0HWSsEu0+TtY8OsvUDeAfVdjGbEqPQky5Wgaz1f/
         S8jyxDwiU5i1lq5BC4PjWCJOiVLH8hRxy6HbWiNgpyOQv5wmLFgdUU5ML8XDLbHICioV
         FQE51dADBS69mayzftw+nFRh1mT7o6KwZPllU=
Received: by 10.86.169.3 with SMTP id r3mr4604847fge.15.1254250240620;
        Tue, 29 Sep 2009 11:50:40 -0700 (PDT)
Received: from localhost.localdomain (p5496CA2C.dip.t-dialin.net [84.150.202.44])
        by mx.google.com with ESMTPS id e20sm277978fga.4.2009.09.29.11.50.38
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Tue, 29 Sep 2009 11:50:39 -0700 (PDT)
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	linux-pcmcia <linux-pcmcia@lists.infradead.org>
Cc:	Linux-MIPS <linux-mips@linux-mips.org>,
	Manuel Lauss <manuel.lauss@gmail.com>,
	Florian Fainelli <florian@openwrt.org>
Subject: [PATCH] Alchemy: XXS1500 PCMCIA driver rewrite
Date:	Tue, 29 Sep 2009 20:50:36 +0200
Message-Id: <1254250236-18130-1-git-send-email-manuel.lauss@gmail.com>
X-Mailer: git-send-email 1.6.5.rc1
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24119
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

Rewritten XXS1500 PCMCIA socket driver, standalone (doesn't
depend on au1000_generic.c) and added carddetect IRQ support.

Cc: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
Against latest linus-git, compile-tested only.
CC'ing Florian, he might still have a testsystem.

 arch/mips/alchemy/xxs1500/Makefile      |    2 +-
 arch/mips/alchemy/xxs1500/board_setup.c |   16 --
 arch/mips/alchemy/xxs1500/platform.c    |   63 ++++++
 drivers/pcmcia/Kconfig                  |   10 +
 drivers/pcmcia/Makefile                 |    3 +-
 drivers/pcmcia/au1000_xxs1500.c         |  188 ----------------
 drivers/pcmcia/xxs1500_ss.c             |  357 +++++++++++++++++++++++++++++++
 7 files changed, 433 insertions(+), 206 deletions(-)
 create mode 100644 arch/mips/alchemy/xxs1500/platform.c
 delete mode 100644 drivers/pcmcia/au1000_xxs1500.c
 create mode 100644 drivers/pcmcia/xxs1500_ss.c

diff --git a/arch/mips/alchemy/xxs1500/Makefile b/arch/mips/alchemy/xxs1500/Makefile
index db3c526..3a79a90 100644
--- a/arch/mips/alchemy/xxs1500/Makefile
+++ b/arch/mips/alchemy/xxs1500/Makefile
@@ -5,4 +5,4 @@
 # Makefile for MyCable XXS1500 board.
 #
 
-lib-y := init.o board_setup.o irqmap.o
+lib-y := init.o board_setup.o irqmap.o platform.o
diff --git a/arch/mips/alchemy/xxs1500/board_setup.c b/arch/mips/alchemy/xxs1500/board_setup.c
index 4de2d48..6d6de53 100644
--- a/arch/mips/alchemy/xxs1500/board_setup.c
+++ b/arch/mips/alchemy/xxs1500/board_setup.c
@@ -68,22 +68,6 @@ void __init board_setup(void)
 	/* Enable DTR = USB power up */
 	au_writel(0x01, UART3_ADDR + UART_MCR); /* UART_MCR_DTR is 0x01??? */
 
-#ifdef CONFIG_PCMCIA_XXS1500
-	/* GPIO 0, 1, and 4 are inputs */
-	alchemy_gpio_direction_input(0);
-	alchemy_gpio_direction_input(1);
-	alchemy_gpio_direction_input(4);
-
-	/* GPIO2 208/9/10/11 are inputs */
-	alchemy_gpio_direction_input(208);
-	alchemy_gpio_direction_input(209);
-	alchemy_gpio_direction_input(210);
-	alchemy_gpio_direction_input(211);
-
-	/* Turn off power */
-	alchemy_gpio_direction_output(214, 0);
-#endif
-
 #ifdef CONFIG_PCI
 #if defined(__MIPSEB__)
 	au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG);
diff --git a/arch/mips/alchemy/xxs1500/platform.c b/arch/mips/alchemy/xxs1500/platform.c
new file mode 100644
index 0000000..9edbdfd
--- /dev/null
+++ b/arch/mips/alchemy/xxs1500/platform.c
@@ -0,0 +1,63 @@
+/*
+ * XXS1500 board platform device registration
+ *
+ * Copyright (C) 2009 Manuel Lauss
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-au1x00/au1000.h>
+
+static struct resource xxs1500_pcmcia_res[] = {
+	{
+		.name	= "pseudo-io",
+		.flags	= IORESOURCE_MEM,
+		.start	= 0xF0000000,
+		.end	= 0xF0040000 - 1,
+	},
+	{
+		.name	= "pseudo-attr",
+		.flags	= IORESOURCE_MEM,
+		.start	= 0xF4000000,
+		.end	= 0xF4040000 - 1,
+	},
+	{
+		.name	= "pseudo-mem",
+		.flags	= IORESOURCE_MEM,
+		.start	= 0xF8000000,
+		.end	= 0xF8040000 - 1,
+	},
+};
+
+static struct platform_device xxs1500_pcmcia_dev = {
+	.name		= "xxs1500_pcmcia",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(xxs1500_pcmcia_res),
+	.resource	= xxs1500_pcmcia_res,
+};
+
+static struct platform_device *xxs1500_devs[] __initdata = {
+	&xxs1500_pcmcia_dev,
+};
+
+static int __init xxs1500_dev_init(void)
+{
+	return platform_add_devices(xxs1500_devs,
+				    ARRAY_SIZE(xxs1500_devs));
+}
+device_initcall(xxs1500_dev_init);
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index fbf965b..c094108 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -192,6 +192,16 @@ config PCMCIA_AU1X00
 	tristate "Au1x00 pcmcia support"
 	depends on SOC_AU1X00 && PCMCIA
 
+config PCMCIA_XXS1500
+	tristate "MyCable XXS1500 PCMCIA socket support"
+	depends on PCMCIA && MIPS_XXS1500
+	select 64BIT_PHYS_ADDR
+	help
+	  Support for the PCMCIA/CF socket interface on MyCable XXS1500
+	  systems.
+
+	  This driver is also available as a module called xxs1500_ss.ko
+
 config PCMCIA_SA1100
 	tristate "SA1100 support"
 	depends on ARM && ARCH_SA1100 && PCMCIA
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 3247828..95433f7 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -47,7 +47,6 @@ au1x00_ss-$(CONFIG_MIPS_DB1100)			+= au1000_db1x00.o
 au1x00_ss-$(CONFIG_MIPS_DB1200)			+= au1000_db1x00.o
 au1x00_ss-$(CONFIG_MIPS_DB1500)			+= au1000_db1x00.o
 au1x00_ss-$(CONFIG_MIPS_DB1550)			+= au1000_db1x00.o
-au1x00_ss-$(CONFIG_MIPS_XXS1500)		+= au1000_xxs1500.o
 
 sa1111_cs-y					+= sa1111_generic.o
 sa1111_cs-$(CONFIG_ASSABET_NEPONSET)		+= sa1100_neponset.o
@@ -77,3 +76,5 @@ pxa2xx-obj-$(CONFIG_MACH_E740)			+= pxa2xx_e740.o
 pxa2xx-obj-$(CONFIG_MACH_STARGATE2)		+= pxa2xx_stargate2.o
 
 obj-$(CONFIG_PCMCIA_PXA2XX)			+= pxa2xx_core.o $(pxa2xx-obj-y)
+
+obj-$(CONFIG_PCMCIA_XXS1500)			+= xxs1500_ss.o
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c
deleted file mode 100644
index b43d47b..0000000
--- a/drivers/pcmcia/au1000_xxs1500.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- *
- * MyCable board specific pcmcia routines.
- *
- * Copyright 2003 MontaVista Software Inc.
- * Author: Pete Popov, MontaVista Software, Inc.
- *         	ppopov@mvista.com or source@mvista.com
- *
- * ########################################################################
- *
- *  This program is free software; you can distribute it and/or modify it
- *  under the terms of the GNU General Public License (Version 2) as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope it will be useful, but WITHOUT
- *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- *  for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * ########################################################################
- *
- *
- */
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/ioport.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/mm.h>
-#include <linux/proc_fs.h>
-#include <linux/types.h>
-
-#include <pcmcia/cs_types.h>
-#include <pcmcia/cs.h>
-#include <pcmcia/ss.h>
-#include <pcmcia/cistpl.h>
-#include <pcmcia/bus_ops.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/system.h>
-
-#include <asm/au1000.h>
-#include <asm/au1000_pcmcia.h>
-
-#define PCMCIA_MAX_SOCK		0
-#define PCMCIA_NUM_SOCKS	(PCMCIA_MAX_SOCK + 1)
-#define PCMCIA_IRQ		AU1000_GPIO_4
-
-#if 0
-#define DEBUG(x, args...)	printk(__func__ ": " x, ##args)
-#else
-#define DEBUG(x,args...)
-#endif
-
-static int xxs1500_pcmcia_init(struct pcmcia_init *init)
-{
-	return PCMCIA_NUM_SOCKS;
-}
-
-static int xxs1500_pcmcia_shutdown(void)
-{
-	/* turn off power */
-	au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30),
-			GPIO2_OUTPUT);
-	au_sync_delay(100);
-
-	/* assert reset */
-	au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20),
-			GPIO2_OUTPUT);
-	au_sync_delay(100);
-	return 0;
-}
-
-
-static int
-xxs1500_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
-{
-	u32 inserted; u32 vs;
-	unsigned long gpio, gpio2;
-
-	if(sock > PCMCIA_MAX_SOCK) return -1;
-
-	gpio = au_readl(SYS_PINSTATERD);
-	gpio2 = au_readl(GPIO2_PINSTATE);
-
-	vs = gpio2 & ((1<<8) | (1<<9));
-	inserted = (!(gpio & 0x1) && !(gpio & 0x2));
-
-	state->ready = 0;
-	state->vs_Xv = 0;
-	state->vs_3v = 0;
-	state->detect = 0;
-
-	if (inserted) {
-		switch (vs) {
-			case 0:
-			case 1:
-			case 2:
-				state->vs_3v=1;
-				break;
-			case 3: /* 5V */
-			default:
-				/* return without setting 'detect' */
-				printk(KERN_ERR "au1x00_cs: unsupported VS\n",
-						vs);
-				return;
-		}
-		state->detect = 1;
-	}
-
-	if (state->detect) {
-		state->ready = 1;
-	}
-
-	state->bvd1= gpio2 & (1<<10);
-	state->bvd2 = gpio2 & (1<<11);
-	state->wrprot=0;
-	return 1;
-}
-
-
-static int xxs1500_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
-{
-
-	if(info->sock > PCMCIA_MAX_SOCK) return -1;
-	info->irq = PCMCIA_IRQ;
-	return 0;
-}
-
-
-static int
-xxs1500_pcmcia_configure_socket(const struct pcmcia_configure *configure)
-{
-
-	if(configure->sock > PCMCIA_MAX_SOCK) return -1;
-
-	DEBUG("Vcc %dV Vpp %dV, reset %d\n",
-			configure->vcc, configure->vpp, configure->reset);
-
-	switch(configure->vcc){
-		case 33: /* Vcc 3.3V */
-			/* turn on power */
-			DEBUG("turn on power\n");
-			au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<14))|(1<<30),
-					GPIO2_OUTPUT);
-			au_sync_delay(100);
-			break;
-		case 50: /* Vcc 5V */
-		default: /* what's this ? */
-			printk(KERN_ERR "au1x00_cs: unsupported VCC\n");
-		case 0:  /* Vcc 0 */
-			/* turn off power */
-			au_sync_delay(100);
-			au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30),
-					GPIO2_OUTPUT);
-			break;
-	}
-
-	if (!configure->reset) {
-		DEBUG("deassert reset\n");
-		au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<4))|(1<<20),
-				GPIO2_OUTPUT);
-		au_sync_delay(100);
-		au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<5))|(1<<21),
-				GPIO2_OUTPUT);
-	}
-	else {
-		DEBUG("assert reset\n");
-		au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20),
-				GPIO2_OUTPUT);
-	}
-	au_sync_delay(100);
-	return 0;
-}
-
-struct pcmcia_low_level xxs1500_pcmcia_ops = {
-	xxs1500_pcmcia_init,
-	xxs1500_pcmcia_shutdown,
-	xxs1500_pcmcia_socket_state,
-	xxs1500_pcmcia_get_irq_info,
-	xxs1500_pcmcia_configure_socket
-};
diff --git a/drivers/pcmcia/xxs1500_ss.c b/drivers/pcmcia/xxs1500_ss.c
new file mode 100644
index 0000000..4e36930
--- /dev/null
+++ b/drivers/pcmcia/xxs1500_ss.c
@@ -0,0 +1,357 @@
+/*
+ * PCMCIA socket code for the MyCable XXS1500 system.
+ *
+ * Copyright (c) 2009 Manuel Lauss <manuel.lauss@gmail.com>
+ *
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/resource.h>
+#include <linux/spinlock.h>
+
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/ss.h>
+#include <pcmcia/cistpl.h>
+
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/mach-au1x00/au1000.h>
+
+#define MEM_MAP_SIZE	0x400000
+#define IO_MAP_SIZE	0x1000
+
+
+/*
+ * 3.3V cards only; all interfacing is done via gpios:
+ *
+ * 0/1:  carddetect (00 = card present, xx = huh)
+ * 4:	 card irq
+ * 204:  reset (high-act)
+ * 205:  buffer enable (low-act)
+ * 208/209: card voltage key (00,01,10,11)
+ * 210:  battwarn
+ * 211:  batdead
+ * 214:  power (low-act)
+ */
+#define GPIO_CDA	0
+#define GPIO_CDB	1
+#define GPIO_CARDIRQ	4
+#define GPIO_RESET	204
+#define GPIO_OUTEN	205
+#define GPIO_VSL	208
+#define GPIO_VSH	209
+#define GPIO_BATTDEAD	210
+#define GPIO_BATTWARN	211
+#define GPIO_POWER	214
+
+struct xxs1500_pcmcia_sock {
+	struct pcmcia_socket	socket;
+	void		*virt_io;
+
+	/* the "pseudo" addresses of the PCMCIA space. */
+	unsigned long	phys_io;
+	unsigned long	phys_attr;
+	unsigned long	phys_mem;
+
+	/* previous flags for set_socket() */
+	unsigned int old_flags;
+};
+
+#define to_xxs_socket(x) container_of(x, struct xxs1500_pcmcia_sock, socket)
+
+static irqreturn_t cdirq(int irq, void *data)
+{
+	struct xxs1500_pcmcia_sock *sock = data;
+
+	pcmcia_parse_events(&sock->socket, SS_DETECT);
+
+	return IRQ_HANDLED;
+}
+
+static int xxs1500_pcmcia_configure(struct pcmcia_socket *skt,
+				    struct socket_state_t *state)
+{
+	struct xxs1500_pcmcia_sock *sock = to_xxs_socket(skt);
+	unsigned int changed;
+
+	/* power control */
+	switch (state->Vcc) {
+	case 0:
+		gpio_set_value(GPIO_POWER, 1);	/* power off */
+		break;
+	case 33:
+		gpio_set_value(GPIO_POWER, 0);	/* power on */
+		break;
+	case 50:
+	default:
+		return -EINVAL;
+	}
+
+	changed = state->flags ^ sock->old_flags;
+
+	if (changed & SS_RESET) {
+		if (state->flags & SS_RESET) {
+			gpio_set_value(GPIO_RESET, 1);	/* assert reset */
+			gpio_set_value(GPIO_OUTEN, 1);	/* buffers off */
+		} else {
+			gpio_set_value(GPIO_RESET, 0);	/* deassert reset */
+			gpio_set_value(GPIO_OUTEN, 0);	/* buffers on */
+			msleep(500);
+		}
+	}
+
+	sock->old_flags = state->flags;
+
+	return 0;
+}
+
+static int xxs1500_pcmcia_get_status(struct pcmcia_socket *skt,
+				     unsigned int *value)
+{
+	unsigned int status;
+	int i;
+
+	status = 0;
+
+	/* check carddetects: GPIO[0:1] must both be low */
+	if (!gpio_get_value(GPIO_CDA) && !gpio_get_value(GPIO_CDB))
+		status |= SS_DETECT;
+
+	/* determine card voltage: GPIO[208:209] binary value */
+	i = (!!gpio_get_value(GPIO_VSL)) | ((!!gpio_get_value(GPIO_VSH)) << 1);
+
+	switch (i) {
+	case 0:
+	case 1:
+	case 2:
+		status |= SS_3VCARD;	/* 3V card */
+		break;
+	case 3:				/* 5V card, unsupported */
+	default:
+		status |= SS_XVCARD;	/* treated as unsupported in core */
+	}
+
+	/* GPIO214: low active power switch */
+	status |= gpio_get_value(GPIO_POWER) ? 0 : SS_POWERON;
+
+	/* GPIO204: high-active reset line */
+	status |= gpio_get_value(GPIO_RESET) ? SS_RESET : SS_READY;
+
+	/* other stuff */
+	status |= gpio_get_value(GPIO_BATTDEAD) ? 0 : SS_BATDEAD;
+	status |= gpio_get_value(GPIO_BATTWARN) ? 0 : SS_BATWARN;
+
+	*value = status;
+
+	return 0;
+}
+
+static int xxs1500_pcmcia_sock_init(struct pcmcia_socket *skt)
+{
+	gpio_direction_input(GPIO_CDA);
+	gpio_direction_input(GPIO_CDB);
+	gpio_direction_input(GPIO_VSL);
+	gpio_direction_input(GPIO_VSH);
+	gpio_direction_input(GPIO_BATTDEAD);
+	gpio_direction_input(GPIO_BATTWARN);
+	gpio_direction_output(GPIO_RESET, 1);	/* assert reset */
+	gpio_direction_output(GPIO_OUTEN, 1);	/* disable buffers */
+	gpio_direction_output(GPIO_POWER, 1);	/* power off */
+
+	return 0;
+}
+
+static int xxs1500_pcmcia_sock_suspend(struct pcmcia_socket *skt)
+{
+	return 0;
+}
+
+static int au1x00_pcmcia_set_io_map(struct pcmcia_socket *skt,
+				    struct pccard_io_map *map)
+{
+	struct xxs1500_pcmcia_sock *sock = to_xxs_socket(skt);
+
+	map->start = (u32)sock->virt_io;
+	map->stop = map->start + IO_MAP_SIZE;
+
+	return 0;
+}
+
+static int au1x00_pcmcia_set_mem_map(struct pcmcia_socket *skt,
+				     struct pccard_mem_map *map)
+{
+	struct xxs1500_pcmcia_sock *sock = to_xxs_socket(skt);
+
+	if (map->flags & MAP_ATTRIB)
+		map->static_start = sock->phys_attr + map->card_start;
+	else
+		map->static_start = sock->phys_mem + map->card_start;
+
+	return 0;
+}
+
+static struct pccard_operations xxs1500_pcmcia_operations = {
+	.init			= xxs1500_pcmcia_sock_init,
+	.suspend		= xxs1500_pcmcia_sock_suspend,
+	.get_status		= xxs1500_pcmcia_get_status,
+	.set_socket		= xxs1500_pcmcia_configure,
+	.set_io_map		= au1x00_pcmcia_set_io_map,
+	.set_mem_map		= au1x00_pcmcia_set_mem_map,
+};
+
+static int __devinit xxs1500_pcmcia_probe(struct platform_device *pdev)
+{
+	struct xxs1500_pcmcia_sock *sock;
+	struct resource *r;
+	phys_t physio;
+	int ret, irq;
+
+	sock = kzalloc(sizeof(struct xxs1500_pcmcia_sock), GFP_KERNEL);
+	if (!sock)
+		return -ENOMEM;
+
+	ret = -ENODEV;
+
+	/*
+	 * pseudo-attr:  The 32bit address of the PCMCIA attribute space
+	 * for this socket (usually the 36bit address shifted 4 to the
+	 * right).
+	 */
+	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-attr");
+	if (!r) {
+		dev_err(&pdev->dev, "missing 'pseudo-attr' resource!\n");
+		goto out0;
+	}
+	sock->phys_attr = r->start;
+
+	/*
+	 * pseudo-mem:  The 32bit address of the PCMCIA memory space for
+	 * this socket (usually the 36bit address shifted 4 to the right)
+	 */
+	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-mem");
+	if (!r) {
+		dev_err(&pdev->dev, "missing 'pseudo-mem' resource!\n");
+		goto out0;
+	}
+	sock->phys_mem = r->start;
+
+	/*
+	 * pseudo-io:  The 32bit address of the PCMCIA IO space for this
+	 * socket (usually the 36bit address shifted 4 to the right).
+	 */
+	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-io");
+	if (!r) {
+		dev_err(&pdev->dev, "missing 'pseudo-io' resource!\n");
+		goto out0;
+	}
+	sock->phys_io = r->start;
+
+
+	/* for io must remap the full 36bit address (for reference see
+	 * alchemy/common/setup.c::__fixup_bigphys_addr)
+	 */
+	physio = ((phys_t)sock->phys_io) << 4;
+
+	/*
+	 * PCMCIA client drivers use the inb/outb macros to access
+	 * the IO registers.  Since mips_io_port_base is added
+	 * to the access address of the mips implementation of
+	 * inb/outb, we need to subtract it here because we want
+	 * to access the I/O or MEM address directly, without
+	 * going through this "mips_io_port_base" mechanism.
+	 */
+	sock->virt_io = (void *)(ioremap(physio, IO_MAP_SIZE) -
+				 mips_io_port_base);
+
+	if (!sock->virt_io) {
+		dev_err(&pdev->dev, "cannot remap IO area\n");
+		ret = -ENOMEM;
+		goto out0;
+	}
+
+	sock->socket.ops	= &xxs1500_pcmcia_operations;
+	sock->socket.owner	= THIS_MODULE;
+	sock->socket.pci_irq	= gpio_to_irq(GPIO_CARDIRQ);
+	sock->socket.features	= SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
+	sock->socket.map_size	= MEM_MAP_SIZE;
+	sock->socket.io_offset	= (unsigned long)sock->virt_io;
+	sock->socket.dev.parent	= &pdev->dev;
+	sock->socket.resource_ops = &pccard_static_ops;
+
+	platform_set_drvdata(pdev, sock);
+
+	/* setup carddetect irq: use one of the 2 GPIOs as an
+	 * edge detector.
+	 */
+	irq = gpio_to_irq(GPIO_CDA);
+	set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
+	ret = request_irq(irq, cdirq, 0, "pcmcia_carddetect", sock);
+	if (ret) {
+		dev_err(&pdev->dev, "cannot setup cd irq\n");
+		goto out1;
+	}
+
+	ret = pcmcia_register_socket(&sock->socket);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to register\n");
+		goto out2;
+	}
+
+	printk(KERN_INFO "MyCable XXS1500 PCMCIA socket services\n");
+
+	return 0;
+
+out2:
+	free_irq(gpio_to_irq(GPIO_CDA), sock);
+out1:
+	iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
+out0:
+	kfree(sock);
+	return ret;
+}
+
+static int __devexit xxs1500_pcmcia_remove(struct platform_device *pdev)
+{
+	struct xxs1500_pcmcia_sock *sock = platform_get_drvdata(pdev);
+
+	pcmcia_unregister_socket(&sock->socket);
+	free_irq(gpio_to_irq(GPIO_CDA), sock);
+	iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
+	kfree(sock);
+
+	return 0;
+}
+
+static struct platform_driver xxs1500_pcmcia_socket_driver = {
+	.driver	= {
+		.name	= "xxs1500_pcmcia",
+		.owner	= THIS_MODULE,
+	},
+	.probe		= xxs1500_pcmcia_probe,
+	.remove		= __devexit_p(xxs1500_pcmcia_remove),
+};
+
+int __init xxs1500_pcmcia_socket_load(void)
+{
+	return platform_driver_register(&xxs1500_pcmcia_socket_driver);
+}
+
+void  __exit xxs1500_pcmcia_socket_unload(void)
+{
+	platform_driver_unregister(&xxs1500_pcmcia_socket_driver);
+}
+
+module_init(xxs1500_pcmcia_socket_load);
+module_exit(xxs1500_pcmcia_socket_unload);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("PCMCIA Socket Services for MyCable XXS1500 systems");
+MODULE_AUTHOR("Manuel Lauss");
-- 
1.6.5.rc1


From f.fainelli@gmail.com Tue Sep 29 21:46:49 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 29 Sep 2009 21:46:54 +0200 (CEST)
Received: from mail-ew0-f207.google.com ([209.85.219.207]:53566 "EHLO
	mail-ew0-f207.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493651AbZI2Tqt convert rfc822-to-8bit
	(ORCPT <rfc822;linux-mips@linux-mips.org>);
	Tue, 29 Sep 2009 21:46:49 +0200
Received: by ewy3 with SMTP id 3so5471837ewy.33
        for <linux-mips@linux-mips.org>; Tue, 29 Sep 2009 12:46:41 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:sender:from:reply-to:to
         :subject:date:user-agent:cc:references:in-reply-to:mime-version
         :content-type:content-transfer-encoding:message-id;
        bh=fVPfCC3zOiAyYIUb+Tp8fjqU1A38fwFL3vjju3DVBlw=;
        b=Fk6RsNNurhBk5u3unLONteu00RYAwyEQh2zvWEwkPTssSJZkZVQdprkKhuY9UHUbf7
         jD7VZMn9mtnRI5i5xFC0Vttg2id+0RbNTdFHRMM5cFGiBeqFW/IgOEA/oBsskxVB39cZ
         /zgS2EYDMtnAPZ4Y0Si3NoVT/J7wivJ6U+ejs=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=sender:from:reply-to:to:subject:date:user-agent:cc:references
         :in-reply-to:mime-version:content-type:content-transfer-encoding
         :message-id;
        b=wMrTYCTVOlg8Or+JmhK+RRi4zVQjlfgM52Odml8HFcMqGL1SZIPgqxVhXyTU9wYYY7
         zHpd8FQLd2/5Kx3m0w1DQiYxtHQ+fUTDNCalT8N5LyXebAK9nm1mrzyXt7VsI6+Y92pD
         wrYakUI3HQUmYtEx2aZNasSte149yltnQFc78=
Received: by 10.210.9.5 with SMTP id 5mr5012641ebi.78.1254253601138;
        Tue, 29 Sep 2009 12:46:41 -0700 (PDT)
Received: from lenovo.localnet (147.59.76-86.rev.gaoland.net [86.76.59.147])
        by mx.google.com with ESMTPS id 7sm17709eyb.12.2009.09.29.12.46.39
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Tue, 29 Sep 2009 12:46:40 -0700 (PDT)
From:	Florian Fainelli <florian@openwrt.org>
Reply-To: Florian Fainelli <florian@openwrt.org>
To:	Manuel Lauss <manuel.lauss@googlemail.com>
Subject: Re: [PATCH] Alchemy: XXS1500 PCMCIA driver rewrite
Date:	Tue, 29 Sep 2009 21:46:37 +0200
User-Agent: KMail/1.12.1 (Linux/2.6.29-2-686; KDE/4.3.1; i686; ; )
Cc:	"linux-pcmcia" <linux-pcmcia@lists.infradead.org>,
	"Linux-MIPS" <linux-mips@linux-mips.org>,
	Manuel Lauss <manuel.lauss@gmail.com>
References: <1254250236-18130-1-git-send-email-manuel.lauss@gmail.com>
In-Reply-To: <1254250236-18130-1-git-send-email-manuel.lauss@gmail.com>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="utf-8"
Content-Transfer-Encoding: 8BIT
Message-Id: <200909292146.38542.florian@openwrt.org>
Return-Path: <f.fainelli@gmail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24120
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: florian@openwrt.org
Precedence: bulk
X-list: linux-mips

Hi Manuel,

Le mardi 29 septembre 2009 20:50:36, Manuel Lauss a Ã©crit :
> Rewritten XXS1500 PCMCIA socket driver, standalone (doesn't
> depend on au1000_generic.c) and added carddetect IRQ support.

Thanks for CC'ing me, will make my best to test this driver, soon.

> 
> Cc: Florian Fainelli <florian@openwrt.org>
> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
> ---
> Against latest linus-git, compile-tested only.
> CC'ing Florian, he might still have a testsystem.
> 
>  arch/mips/alchemy/xxs1500/Makefile      |    2 +-
>  arch/mips/alchemy/xxs1500/board_setup.c |   16 --
>  arch/mips/alchemy/xxs1500/platform.c    |   63 ++++++
>  drivers/pcmcia/Kconfig                  |   10 +
>  drivers/pcmcia/Makefile                 |    3 +-
>  drivers/pcmcia/au1000_xxs1500.c         |  188 ----------------
>  drivers/pcmcia/xxs1500_ss.c             |  357
>  +++++++++++++++++++++++++++++++ 7 files changed, 433 insertions(+), 206
>  deletions(-)
>  create mode 100644 arch/mips/alchemy/xxs1500/platform.c
>  delete mode 100644 drivers/pcmcia/au1000_xxs1500.c
>  create mode 100644 drivers/pcmcia/xxs1500_ss.c
> 
> diff --git a/arch/mips/alchemy/xxs1500/Makefile
>  b/arch/mips/alchemy/xxs1500/Makefile index db3c526..3a79a90 100644
> --- a/arch/mips/alchemy/xxs1500/Makefile
> +++ b/arch/mips/alchemy/xxs1500/Makefile
> @@ -5,4 +5,4 @@
>  # Makefile for MyCable XXS1500 board.
>  #
> 
> -lib-y := init.o board_setup.o irqmap.o
> +lib-y := init.o board_setup.o irqmap.o platform.o
> diff --git a/arch/mips/alchemy/xxs1500/board_setup.c
>  b/arch/mips/alchemy/xxs1500/board_setup.c index 4de2d48..6d6de53 100644
> --- a/arch/mips/alchemy/xxs1500/board_setup.c
> +++ b/arch/mips/alchemy/xxs1500/board_setup.c
> @@ -68,22 +68,6 @@ void __init board_setup(void)
>  	/* Enable DTR = USB power up */
>  	au_writel(0x01, UART3_ADDR + UART_MCR); /* UART_MCR_DTR is 0x01??? */
> 
> -#ifdef CONFIG_PCMCIA_XXS1500
> -	/* GPIO 0, 1, and 4 are inputs */
> -	alchemy_gpio_direction_input(0);
> -	alchemy_gpio_direction_input(1);
> -	alchemy_gpio_direction_input(4);
> -
> -	/* GPIO2 208/9/10/11 are inputs */
> -	alchemy_gpio_direction_input(208);
> -	alchemy_gpio_direction_input(209);
> -	alchemy_gpio_direction_input(210);
> -	alchemy_gpio_direction_input(211);
> -
> -	/* Turn off power */
> -	alchemy_gpio_direction_output(214, 0);
> -#endif
> -
>  #ifdef CONFIG_PCI
>  #if defined(__MIPSEB__)
>  	au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG);
> diff --git a/arch/mips/alchemy/xxs1500/platform.c
>  b/arch/mips/alchemy/xxs1500/platform.c new file mode 100644
> index 0000000..9edbdfd
> --- /dev/null
> +++ b/arch/mips/alchemy/xxs1500/platform.c
> @@ -0,0 +1,63 @@
> +/*
> + * XXS1500 board platform device registration
> + *
> + * Copyright (C) 2009 Manuel Lauss
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
>  USA + */
> +
> +#include <linux/init.h>
> +#include <linux/platform_device.h>
> +
> +#include <asm/mach-au1x00/au1000.h>
> +
> +static struct resource xxs1500_pcmcia_res[] = {
> +	{
> +		.name	= "pseudo-io",
> +		.flags	= IORESOURCE_MEM,
> +		.start	= 0xF0000000,
> +		.end	= 0xF0040000 - 1,
> +	},
> +	{
> +		.name	= "pseudo-attr",
> +		.flags	= IORESOURCE_MEM,
> +		.start	= 0xF4000000,
> +		.end	= 0xF4040000 - 1,
> +	},
> +	{
> +		.name	= "pseudo-mem",
> +		.flags	= IORESOURCE_MEM,
> +		.start	= 0xF8000000,
> +		.end	= 0xF8040000 - 1,
> +	},
> +};
> +
> +static struct platform_device xxs1500_pcmcia_dev = {
> +	.name		= "xxs1500_pcmcia",
> +	.id		= -1,
> +	.num_resources	= ARRAY_SIZE(xxs1500_pcmcia_res),
> +	.resource	= xxs1500_pcmcia_res,
> +};
> +
> +static struct platform_device *xxs1500_devs[] __initdata = {
> +	&xxs1500_pcmcia_dev,
> +};
> +
> +static int __init xxs1500_dev_init(void)
> +{
> +	return platform_add_devices(xxs1500_devs,
> +				    ARRAY_SIZE(xxs1500_devs));
> +}
> +device_initcall(xxs1500_dev_init);
> diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
> index fbf965b..c094108 100644
> --- a/drivers/pcmcia/Kconfig
> +++ b/drivers/pcmcia/Kconfig
> @@ -192,6 +192,16 @@ config PCMCIA_AU1X00
>  	tristate "Au1x00 pcmcia support"
>  	depends on SOC_AU1X00 && PCMCIA
> 
> +config PCMCIA_XXS1500
> +	tristate "MyCable XXS1500 PCMCIA socket support"
> +	depends on PCMCIA && MIPS_XXS1500
> +	select 64BIT_PHYS_ADDR
> +	help
> +	  Support for the PCMCIA/CF socket interface on MyCable XXS1500
> +	  systems.
> +
> +	  This driver is also available as a module called xxs1500_ss.ko
> +
>  config PCMCIA_SA1100
>  	tristate "SA1100 support"
>  	depends on ARM && ARCH_SA1100 && PCMCIA
> diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
> index 3247828..95433f7 100644
> --- a/drivers/pcmcia/Makefile
> +++ b/drivers/pcmcia/Makefile
> @@ -47,7 +47,6 @@ au1x00_ss-$(CONFIG_MIPS_DB1100)			+= au1000_db1x00.o
>  au1x00_ss-$(CONFIG_MIPS_DB1200)			+= au1000_db1x00.o
>  au1x00_ss-$(CONFIG_MIPS_DB1500)			+= au1000_db1x00.o
>  au1x00_ss-$(CONFIG_MIPS_DB1550)			+= au1000_db1x00.o
> -au1x00_ss-$(CONFIG_MIPS_XXS1500)		+= au1000_xxs1500.o
> 
>  sa1111_cs-y					+= sa1111_generic.o
>  sa1111_cs-$(CONFIG_ASSABET_NEPONSET)		+= sa1100_neponset.o
> @@ -77,3 +76,5 @@ pxa2xx-obj-$(CONFIG_MACH_E740)			+= pxa2xx_e740.o
>  pxa2xx-obj-$(CONFIG_MACH_STARGATE2)		+= pxa2xx_stargate2.o
> 
>  obj-$(CONFIG_PCMCIA_PXA2XX)			+= pxa2xx_core.o $(pxa2xx-obj-y)
> +
> +obj-$(CONFIG_PCMCIA_XXS1500)			+= xxs1500_ss.o
> diff --git a/drivers/pcmcia/au1000_xxs1500.c
>  b/drivers/pcmcia/au1000_xxs1500.c deleted file mode 100644
> index b43d47b..0000000
> --- a/drivers/pcmcia/au1000_xxs1500.c
> +++ /dev/null
> @@ -1,188 +0,0 @@
> -/*
> - *
> - * MyCable board specific pcmcia routines.
> - *
> - * Copyright 2003 MontaVista Software Inc.
> - * Author: Pete Popov, MontaVista Software, Inc.
> - *         	ppopov@mvista.com or source@mvista.com
> - *
> - *
>  ######################################################################## -
>  *
> - *  This program is free software; you can distribute it and/or modify it
> - *  under the terms of the GNU General Public License (Version 2) as
> - *  published by the Free Software Foundation.
> - *
> - *  This program is distributed in the hope it will be useful, but WITHOUT
> - *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> - *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> - *  for more details.
> - *
> - *  You should have received a copy of the GNU General Public License
>  along - *  with this program; if not, write to the Free Software
>  Foundation, Inc., - *  59 Temple Place - Suite 330, Boston MA 02111-1307,
>  USA.
> - *
> - *
>  ######################################################################## -
>  *
> - *
> - */
> -#include <linux/module.h>
> -#include <linux/init.h>
> -#include <linux/delay.h>
> -#include <linux/ioport.h>
> -#include <linux/kernel.h>
> -#include <linux/timer.h>
> -#include <linux/mm.h>
> -#include <linux/proc_fs.h>
> -#include <linux/types.h>
> -
> -#include <pcmcia/cs_types.h>
> -#include <pcmcia/cs.h>
> -#include <pcmcia/ss.h>
> -#include <pcmcia/cistpl.h>
> -#include <pcmcia/bus_ops.h>
> -
> -#include <asm/io.h>
> -#include <asm/irq.h>
> -#include <asm/system.h>
> -
> -#include <asm/au1000.h>
> -#include <asm/au1000_pcmcia.h>
> -
> -#define PCMCIA_MAX_SOCK		0
> -#define PCMCIA_NUM_SOCKS	(PCMCIA_MAX_SOCK + 1)
> -#define PCMCIA_IRQ		AU1000_GPIO_4
> -
> -#if 0
> -#define DEBUG(x, args...)	printk(__func__ ": " x, ##args)
> -#else
> -#define DEBUG(x,args...)
> -#endif
> -
> -static int xxs1500_pcmcia_init(struct pcmcia_init *init)
> -{
> -	return PCMCIA_NUM_SOCKS;
> -}
> -
> -static int xxs1500_pcmcia_shutdown(void)
> -{
> -	/* turn off power */
> -	au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30),
> -			GPIO2_OUTPUT);
> -	au_sync_delay(100);
> -
> -	/* assert reset */
> -	au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20),
> -			GPIO2_OUTPUT);
> -	au_sync_delay(100);
> -	return 0;
> -}
> -
> -
> -static int
> -xxs1500_pcmcia_socket_state(unsigned sock, struct pcmcia_state *state)
> -{
> -	u32 inserted; u32 vs;
> -	unsigned long gpio, gpio2;
> -
> -	if(sock > PCMCIA_MAX_SOCK) return -1;
> -
> -	gpio = au_readl(SYS_PINSTATERD);
> -	gpio2 = au_readl(GPIO2_PINSTATE);
> -
> -	vs = gpio2 & ((1<<8) | (1<<9));
> -	inserted = (!(gpio & 0x1) && !(gpio & 0x2));
> -
> -	state->ready = 0;
> -	state->vs_Xv = 0;
> -	state->vs_3v = 0;
> -	state->detect = 0;
> -
> -	if (inserted) {
> -		switch (vs) {
> -			case 0:
> -			case 1:
> -			case 2:
> -				state->vs_3v=1;
> -				break;
> -			case 3: /* 5V */
> -			default:
> -				/* return without setting 'detect' */
> -				printk(KERN_ERR "au1x00_cs: unsupported VS\n",
> -						vs);
> -				return;
> -		}
> -		state->detect = 1;
> -	}
> -
> -	if (state->detect) {
> -		state->ready = 1;
> -	}
> -
> -	state->bvd1= gpio2 & (1<<10);
> -	state->bvd2 = gpio2 & (1<<11);
> -	state->wrprot=0;
> -	return 1;
> -}
> -
> -
> -static int xxs1500_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
> -{
> -
> -	if(info->sock > PCMCIA_MAX_SOCK) return -1;
> -	info->irq = PCMCIA_IRQ;
> -	return 0;
> -}
> -
> -
> -static int
> -xxs1500_pcmcia_configure_socket(const struct pcmcia_configure *configure)
> -{
> -
> -	if(configure->sock > PCMCIA_MAX_SOCK) return -1;
> -
> -	DEBUG("Vcc %dV Vpp %dV, reset %d\n",
> -			configure->vcc, configure->vpp, configure->reset);
> -
> -	switch(configure->vcc){
> -		case 33: /* Vcc 3.3V */
> -			/* turn on power */
> -			DEBUG("turn on power\n");
> -			au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<14))|(1<<30),
> -					GPIO2_OUTPUT);
> -			au_sync_delay(100);
> -			break;
> -		case 50: /* Vcc 5V */
> -		default: /* what's this ? */
> -			printk(KERN_ERR "au1x00_cs: unsupported VCC\n");
> -		case 0:  /* Vcc 0 */
> -			/* turn off power */
> -			au_sync_delay(100);
> -			au_writel(au_readl(GPIO2_PINSTATE) | (1<<14)|(1<<30),
> -					GPIO2_OUTPUT);
> -			break;
> -	}
> -
> -	if (!configure->reset) {
> -		DEBUG("deassert reset\n");
> -		au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<4))|(1<<20),
> -				GPIO2_OUTPUT);
> -		au_sync_delay(100);
> -		au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<5))|(1<<21),
> -				GPIO2_OUTPUT);
> -	}
> -	else {
> -		DEBUG("assert reset\n");
> -		au_writel(au_readl(GPIO2_PINSTATE) | (1<<4)|(1<<20),
> -				GPIO2_OUTPUT);
> -	}
> -	au_sync_delay(100);
> -	return 0;
> -}
> -
> -struct pcmcia_low_level xxs1500_pcmcia_ops = {
> -	xxs1500_pcmcia_init,
> -	xxs1500_pcmcia_shutdown,
> -	xxs1500_pcmcia_socket_state,
> -	xxs1500_pcmcia_get_irq_info,
> -	xxs1500_pcmcia_configure_socket
> -};
> diff --git a/drivers/pcmcia/xxs1500_ss.c b/drivers/pcmcia/xxs1500_ss.c
> new file mode 100644
> index 0000000..4e36930
> --- /dev/null
> +++ b/drivers/pcmcia/xxs1500_ss.c
> @@ -0,0 +1,357 @@
> +/*
> + * PCMCIA socket code for the MyCable XXS1500 system.
> + *
> + * Copyright (c) 2009 Manuel Lauss <manuel.lauss@gmail.com>
> + *
> + */
> +
> +#include <linux/delay.h>
> +#include <linux/gpio.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/ioport.h>
> +#include <linux/mm.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm.h>
> +#include <linux/resource.h>
> +#include <linux/spinlock.h>
> +
> +#include <pcmcia/cs_types.h>
> +#include <pcmcia/cs.h>
> +#include <pcmcia/ss.h>
> +#include <pcmcia/cistpl.h>
> +
> +#include <asm/irq.h>
> +#include <asm/system.h>
> +#include <asm/mach-au1x00/au1000.h>
> +
> +#define MEM_MAP_SIZE	0x400000
> +#define IO_MAP_SIZE	0x1000
> +
> +
> +/*
> + * 3.3V cards only; all interfacing is done via gpios:
> + *
> + * 0/1:  carddetect (00 = card present, xx = huh)
> + * 4:	 card irq
> + * 204:  reset (high-act)
> + * 205:  buffer enable (low-act)
> + * 208/209: card voltage key (00,01,10,11)
> + * 210:  battwarn
> + * 211:  batdead
> + * 214:  power (low-act)
> + */
> +#define GPIO_CDA	0
> +#define GPIO_CDB	1
> +#define GPIO_CARDIRQ	4
> +#define GPIO_RESET	204
> +#define GPIO_OUTEN	205
> +#define GPIO_VSL	208
> +#define GPIO_VSH	209
> +#define GPIO_BATTDEAD	210
> +#define GPIO_BATTWARN	211
> +#define GPIO_POWER	214
> +
> +struct xxs1500_pcmcia_sock {
> +	struct pcmcia_socket	socket;
> +	void		*virt_io;
> +
> +	/* the "pseudo" addresses of the PCMCIA space. */
> +	unsigned long	phys_io;
> +	unsigned long	phys_attr;
> +	unsigned long	phys_mem;
> +
> +	/* previous flags for set_socket() */
> +	unsigned int old_flags;
> +};
> +
> +#define to_xxs_socket(x) container_of(x, struct xxs1500_pcmcia_sock,
>  socket) +
> +static irqreturn_t cdirq(int irq, void *data)
> +{
> +	struct xxs1500_pcmcia_sock *sock = data;
> +
> +	pcmcia_parse_events(&sock->socket, SS_DETECT);
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static int xxs1500_pcmcia_configure(struct pcmcia_socket *skt,
> +				    struct socket_state_t *state)
> +{
> +	struct xxs1500_pcmcia_sock *sock = to_xxs_socket(skt);
> +	unsigned int changed;
> +
> +	/* power control */
> +	switch (state->Vcc) {
> +	case 0:
> +		gpio_set_value(GPIO_POWER, 1);	/* power off */
> +		break;
> +	case 33:
> +		gpio_set_value(GPIO_POWER, 0);	/* power on */
> +		break;
> +	case 50:
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	changed = state->flags ^ sock->old_flags;
> +
> +	if (changed & SS_RESET) {
> +		if (state->flags & SS_RESET) {
> +			gpio_set_value(GPIO_RESET, 1);	/* assert reset */
> +			gpio_set_value(GPIO_OUTEN, 1);	/* buffers off */
> +		} else {
> +			gpio_set_value(GPIO_RESET, 0);	/* deassert reset */
> +			gpio_set_value(GPIO_OUTEN, 0);	/* buffers on */
> +			msleep(500);
> +		}
> +	}
> +
> +	sock->old_flags = state->flags;
> +
> +	return 0;
> +}
> +
> +static int xxs1500_pcmcia_get_status(struct pcmcia_socket *skt,
> +				     unsigned int *value)
> +{
> +	unsigned int status;
> +	int i;
> +
> +	status = 0;
> +
> +	/* check carddetects: GPIO[0:1] must both be low */
> +	if (!gpio_get_value(GPIO_CDA) && !gpio_get_value(GPIO_CDB))
> +		status |= SS_DETECT;
> +
> +	/* determine card voltage: GPIO[208:209] binary value */
> +	i = (!!gpio_get_value(GPIO_VSL)) | ((!!gpio_get_value(GPIO_VSH)) << 1);
> +
> +	switch (i) {
> +	case 0:
> +	case 1:
> +	case 2:
> +		status |= SS_3VCARD;	/* 3V card */
> +		break;
> +	case 3:				/* 5V card, unsupported */
> +	default:
> +		status |= SS_XVCARD;	/* treated as unsupported in core */
> +	}
> +
> +	/* GPIO214: low active power switch */
> +	status |= gpio_get_value(GPIO_POWER) ? 0 : SS_POWERON;
> +
> +	/* GPIO204: high-active reset line */
> +	status |= gpio_get_value(GPIO_RESET) ? SS_RESET : SS_READY;
> +
> +	/* other stuff */
> +	status |= gpio_get_value(GPIO_BATTDEAD) ? 0 : SS_BATDEAD;
> +	status |= gpio_get_value(GPIO_BATTWARN) ? 0 : SS_BATWARN;
> +
> +	*value = status;
> +
> +	return 0;
> +}
> +
> +static int xxs1500_pcmcia_sock_init(struct pcmcia_socket *skt)
> +{
> +	gpio_direction_input(GPIO_CDA);
> +	gpio_direction_input(GPIO_CDB);
> +	gpio_direction_input(GPIO_VSL);
> +	gpio_direction_input(GPIO_VSH);
> +	gpio_direction_input(GPIO_BATTDEAD);
> +	gpio_direction_input(GPIO_BATTWARN);
> +	gpio_direction_output(GPIO_RESET, 1);	/* assert reset */
> +	gpio_direction_output(GPIO_OUTEN, 1);	/* disable buffers */
> +	gpio_direction_output(GPIO_POWER, 1);	/* power off */
> +
> +	return 0;
> +}
> +
> +static int xxs1500_pcmcia_sock_suspend(struct pcmcia_socket *skt)
> +{
> +	return 0;
> +}
> +
> +static int au1x00_pcmcia_set_io_map(struct pcmcia_socket *skt,
> +				    struct pccard_io_map *map)
> +{
> +	struct xxs1500_pcmcia_sock *sock = to_xxs_socket(skt);
> +
> +	map->start = (u32)sock->virt_io;
> +	map->stop = map->start + IO_MAP_SIZE;
> +
> +	return 0;
> +}
> +
> +static int au1x00_pcmcia_set_mem_map(struct pcmcia_socket *skt,
> +				     struct pccard_mem_map *map)
> +{
> +	struct xxs1500_pcmcia_sock *sock = to_xxs_socket(skt);
> +
> +	if (map->flags & MAP_ATTRIB)
> +		map->static_start = sock->phys_attr + map->card_start;
> +	else
> +		map->static_start = sock->phys_mem + map->card_start;
> +
> +	return 0;
> +}
> +
> +static struct pccard_operations xxs1500_pcmcia_operations = {
> +	.init			= xxs1500_pcmcia_sock_init,
> +	.suspend		= xxs1500_pcmcia_sock_suspend,
> +	.get_status		= xxs1500_pcmcia_get_status,
> +	.set_socket		= xxs1500_pcmcia_configure,
> +	.set_io_map		= au1x00_pcmcia_set_io_map,
> +	.set_mem_map		= au1x00_pcmcia_set_mem_map,
> +};
> +
> +static int __devinit xxs1500_pcmcia_probe(struct platform_device *pdev)
> +{
> +	struct xxs1500_pcmcia_sock *sock;
> +	struct resource *r;
> +	phys_t physio;
> +	int ret, irq;
> +
> +	sock = kzalloc(sizeof(struct xxs1500_pcmcia_sock), GFP_KERNEL);
> +	if (!sock)
> +		return -ENOMEM;
> +
> +	ret = -ENODEV;
> +
> +	/*
> +	 * pseudo-attr:  The 32bit address of the PCMCIA attribute space
> +	 * for this socket (usually the 36bit address shifted 4 to the
> +	 * right).
> +	 */
> +	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-attr");
> +	if (!r) {
> +		dev_err(&pdev->dev, "missing 'pseudo-attr' resource!\n");
> +		goto out0;
> +	}
> +	sock->phys_attr = r->start;
> +
> +	/*
> +	 * pseudo-mem:  The 32bit address of the PCMCIA memory space for
> +	 * this socket (usually the 36bit address shifted 4 to the right)
> +	 */
> +	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-mem");
> +	if (!r) {
> +		dev_err(&pdev->dev, "missing 'pseudo-mem' resource!\n");
> +		goto out0;
> +	}
> +	sock->phys_mem = r->start;
> +
> +	/*
> +	 * pseudo-io:  The 32bit address of the PCMCIA IO space for this
> +	 * socket (usually the 36bit address shifted 4 to the right).
> +	 */
> +	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pseudo-io");
> +	if (!r) {
> +		dev_err(&pdev->dev, "missing 'pseudo-io' resource!\n");
> +		goto out0;
> +	}
> +	sock->phys_io = r->start;
> +
> +
> +	/* for io must remap the full 36bit address (for reference see
> +	 * alchemy/common/setup.c::__fixup_bigphys_addr)
> +	 */
> +	physio = ((phys_t)sock->phys_io) << 4;
> +
> +	/*
> +	 * PCMCIA client drivers use the inb/outb macros to access
> +	 * the IO registers.  Since mips_io_port_base is added
> +	 * to the access address of the mips implementation of
> +	 * inb/outb, we need to subtract it here because we want
> +	 * to access the I/O or MEM address directly, without
> +	 * going through this "mips_io_port_base" mechanism.
> +	 */
> +	sock->virt_io = (void *)(ioremap(physio, IO_MAP_SIZE) -
> +				 mips_io_port_base);
> +
> +	if (!sock->virt_io) {
> +		dev_err(&pdev->dev, "cannot remap IO area\n");
> +		ret = -ENOMEM;
> +		goto out0;
> +	}
> +
> +	sock->socket.ops	= &xxs1500_pcmcia_operations;
> +	sock->socket.owner	= THIS_MODULE;
> +	sock->socket.pci_irq	= gpio_to_irq(GPIO_CARDIRQ);
> +	sock->socket.features	= SS_CAP_STATIC_MAP | SS_CAP_PCCARD;
> +	sock->socket.map_size	= MEM_MAP_SIZE;
> +	sock->socket.io_offset	= (unsigned long)sock->virt_io;
> +	sock->socket.dev.parent	= &pdev->dev;
> +	sock->socket.resource_ops = &pccard_static_ops;
> +
> +	platform_set_drvdata(pdev, sock);
> +
> +	/* setup carddetect irq: use one of the 2 GPIOs as an
> +	 * edge detector.
> +	 */
> +	irq = gpio_to_irq(GPIO_CDA);
> +	set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
> +	ret = request_irq(irq, cdirq, 0, "pcmcia_carddetect", sock);
> +	if (ret) {
> +		dev_err(&pdev->dev, "cannot setup cd irq\n");
> +		goto out1;
> +	}
> +
> +	ret = pcmcia_register_socket(&sock->socket);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to register\n");
> +		goto out2;
> +	}
> +
> +	printk(KERN_INFO "MyCable XXS1500 PCMCIA socket services\n");
> +
> +	return 0;
> +
> +out2:
> +	free_irq(gpio_to_irq(GPIO_CDA), sock);
> +out1:
> +	iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
> +out0:
> +	kfree(sock);
> +	return ret;
> +}
> +
> +static int __devexit xxs1500_pcmcia_remove(struct platform_device *pdev)
> +{
> +	struct xxs1500_pcmcia_sock *sock = platform_get_drvdata(pdev);
> +
> +	pcmcia_unregister_socket(&sock->socket);
> +	free_irq(gpio_to_irq(GPIO_CDA), sock);
> +	iounmap((void *)(sock->virt_io + (u32)mips_io_port_base));
> +	kfree(sock);
> +
> +	return 0;
> +}
> +
> +static struct platform_driver xxs1500_pcmcia_socket_driver = {
> +	.driver	= {
> +		.name	= "xxs1500_pcmcia",
> +		.owner	= THIS_MODULE,
> +	},
> +	.probe		= xxs1500_pcmcia_probe,
> +	.remove		= __devexit_p(xxs1500_pcmcia_remove),
> +};
> +
> +int __init xxs1500_pcmcia_socket_load(void)
> +{
> +	return platform_driver_register(&xxs1500_pcmcia_socket_driver);
> +}
> +
> +void  __exit xxs1500_pcmcia_socket_unload(void)
> +{
> +	platform_driver_unregister(&xxs1500_pcmcia_socket_driver);
> +}
> +
> +module_init(xxs1500_pcmcia_socket_load);
> +module_exit(xxs1500_pcmcia_socket_unload);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("PCMCIA Socket Services for MyCable XXS1500 systems");
> +MODULE_AUTHOR("Manuel Lauss");
> 

-- 
Best regards, Florian Fainelli
Email: florian@openwrt.org
Web: http://openwrt.org
IRC: [florian] on irc.freenode.net
-------------------------------

From manuel.lauss@googlemail.com Wed Sep 30 19:12:33 2009
Received: with ECARTIS (v1.0.0; list linux-mips); Wed, 30 Sep 2009 19:12:39 +0200 (CEST)
Received: from mail-bw0-f208.google.com ([209.85.218.208]:59025 "EHLO
	mail-bw0-f208.google.com" rhost-flags-OK-OK-OK-OK)
	by ftp.linux-mips.org with ESMTP id S1493725AbZI3RMd (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Wed, 30 Sep 2009 19:12:33 +0200
Received: by bwz4 with SMTP id 4so5300931bwz.0
        for <linux-mips@linux-mips.org>; Wed, 30 Sep 2009 10:12:28 -0700 (PDT)
DKIM-Signature:	v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=gamma;
        h=domainkey-signature:received:received:from:to:cc:subject:date
         :message-id:x-mailer;
        bh=uxlKQxj+5J+EUwai0fRBIbfD3xE4UlGVtwbSIVjIlQw=;
        b=X/3Sf0DD7A12j9V6Om7m5f49/raJsrkSNdD4MFMIJ08qDiAYWtKyC5M8aNCcL8ffTw
         AEILwXff3VQJ1uy484S+QRtUsnErYIEIYFCCJxNnu1K1nM1hNaLAdPWg0LRujFSXvhIt
         XTbdqu6OtpTbCbEaHcEMSZ/kJvQLilzJyWIw0=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=googlemail.com; s=gamma;
        h=from:to:cc:subject:date:message-id:x-mailer;
        b=HDHC82GHDcqHHJuO072Ww5dhAHD5YHKMqFg78Gh+88UOupF6FrmAxkCBot9yP57Z8B
         dMO4/pzrnqM1uVS7g8y1X/Xf9OG47UJsUzKv0UNeHZm2AEFdc7teo/23HYJj8RKYEIPB
         qn7wJCklyaUtRJgHsNs2WCcplIMLvfdPyAeIA=
Received: by 10.204.10.130 with SMTP id p2mr53692bkp.56.1254330748008;
        Wed, 30 Sep 2009 10:12:28 -0700 (PDT)
Received: from localhost.localdomain (p5496F673.dip.t-dialin.net [84.150.246.115])
        by mx.google.com with ESMTPS id 12sm7925455fks.8.2009.09.30.10.12.26
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Wed, 30 Sep 2009 10:12:27 -0700 (PDT)
From:	Manuel Lauss <manuel.lauss@googlemail.com>
To:	Linux-MIPS <linux-mips@linux-mips.org>
Cc:	Manuel Lauss <manuel.lauss@gmail.com>
Subject: [PATCH] Alchemy: IRQ updates
Date:	Wed, 30 Sep 2009 19:12:25 +0200
Message-Id: <1254330745-20836-1-git-send-email-manuel.lauss@gmail.com>
X-Mailer: git-send-email 1.6.5.rc1
Return-Path: <manuel.lauss@googlemail.com>
X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0)
X-Orcpt: rfc822;linux-mips@linux-mips.org
Original-Recipient: rfc822;linux-mips@linux-mips.org
X-archive-position: 24121
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: manuel.lauss@googlemail.com
Precedence: bulk
X-list: linux-mips

remove board_init_irq():  On all in-kernel boards it is sufficient to
initialize board interrupts in an arch_initcall.

Hide the au1xxx_irqmap structure and associated calls from public
view;  boards initialize irqs by calling the appropriate linux
irq functions.

The small irqmap.c files have been folded into board_setup files.

Run-tested on DB1200; compile-tested on all other affected boards.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
Applies on top of the "BCSR+PCMCIA" patches I sent a day ago;  may
conflict in xxs1500/Makefile if xxs1500-pcmcia patch is applied.

Please apply, I'd like to get this in before adding new devboards!

 arch/mips/alchemy/common/irq.c                   |   15 ++--
 arch/mips/alchemy/devboards/db1x00/Makefile      |    2 +-
 arch/mips/alchemy/devboards/db1x00/board_setup.c |   55 ++++++++++++++++
 arch/mips/alchemy/devboards/pb1000/board_setup.c |   17 ++---
 arch/mips/alchemy/devboards/pb1100/board_setup.c |   24 +++----
 arch/mips/alchemy/devboards/pb1200/Makefile      |    2 +-
 arch/mips/alchemy/devboards/pb1200/board_setup.c |   48 +++++++++++++-
 arch/mips/alchemy/devboards/pb1200/irqmap.c      |   75 ----------------------
 arch/mips/alchemy/devboards/pb1500/board_setup.c |   32 +++++-----
 arch/mips/alchemy/devboards/pb1550/board_setup.c |   25 ++++----
 arch/mips/alchemy/mtx-1/Makefile                 |    2 +-
 arch/mips/alchemy/mtx-1/board_setup.c            |   24 +++++++
 arch/mips/alchemy/mtx-1/irqmap.c                 |   56 ----------------
 arch/mips/alchemy/xxs1500/Makefile               |    2 +-
 arch/mips/alchemy/xxs1500/board_setup.c          |   21 ++++++
 arch/mips/alchemy/xxs1500/irqmap.c               |   52 ---------------
 arch/mips/include/asm/mach-au1x00/au1000.h       |   15 ----
 arch/mips/include/asm/mach-db1x00/db1200.h       |    1 +
 arch/mips/include/asm/mach-pb1x00/pb1200.h       |    1 +
 19 files changed, 205 insertions(+), 264 deletions(-)
 delete mode 100644 arch/mips/alchemy/devboards/pb1200/irqmap.c
 delete mode 100644 arch/mips/alchemy/mtx-1/irqmap.c
 delete mode 100644 arch/mips/alchemy/xxs1500/irqmap.c

diff --git a/arch/mips/alchemy/common/irq.c b/arch/mips/alchemy/common/irq.c
index c88c821..cd264b1 100644
--- a/arch/mips/alchemy/common/irq.c
+++ b/arch/mips/alchemy/common/irq.c
@@ -40,8 +40,11 @@
 static int au1x_ic_settype(unsigned int irq, unsigned int flow_type);
 
 /* per-processor fixed function irqs */
-struct au1xxx_irqmap au1xxx_ic0_map[] __initdata = {
-
+struct au1xxx_irqmap {
+	int im_irq;
+	int im_type;
+	int im_request;
+} au1xxx_ic0_map[] __initdata = {
 #if defined(CONFIG_SOC_AU1000)
 	{ AU1000_UART0_INT, IRQ_TYPE_LEVEL_HIGH, 0 },
 	{ AU1000_UART1_INT, IRQ_TYPE_LEVEL_HIGH, 0 },
@@ -529,7 +532,7 @@ spurious:
 }
 
 /* setup edge/level and assign request 0/1 */
-void __init au1xxx_setup_irqmap(struct au1xxx_irqmap *map, int count)
+static void __init setup_irqmap(struct au1xxx_irqmap *map, int count)
 {
 	unsigned int bit, irq_nr;
 
@@ -601,11 +604,7 @@ void __init arch_init_irq(void)
 	/*
 	 * Initialize IC0, which is fixed per processor.
 	 */
-	au1xxx_setup_irqmap(au1xxx_ic0_map, ARRAY_SIZE(au1xxx_ic0_map));
-
-	/* Boards can register additional (GPIO-based) IRQs.
-	*/
-	board_init_irq();
+	setup_irqmap(au1xxx_ic0_map, ARRAY_SIZE(au1xxx_ic0_map));
 
 	set_c0_status(IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3);
 }
diff --git a/arch/mips/alchemy/devboards/db1x00/Makefile b/arch/mips/alchemy/devboards/db1x00/Makefile
index 5024d16..4e30fc8 100644
--- a/arch/mips/alchemy/devboards/db1x00/Makefile
+++ b/arch/mips/alchemy/devboards/db1x00/Makefile
@@ -5,5 +5,5 @@
 # Makefile for the Alchemy Semiconductor DBAu1xx0 boards.
 #
 
-obj-y := board_setup.o irqmap.o platform.o
+obj-y := board_setup.o platform.o
 
diff --git a/arch/mips/alchemy/devboards/db1x00/board_setup.c b/arch/mips/alchemy/devboards/db1x00/board_setup.c
index e713390..1fd246b 100644
--- a/arch/mips/alchemy/devboards/db1x00/board_setup.c
+++ b/arch/mips/alchemy/devboards/db1x00/board_setup.c
@@ -29,6 +29,7 @@
 
 #include <linux/gpio.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-db1x00/db1x00.h>
@@ -36,6 +37,37 @@
 
 #include <prom.h>
 
+#ifdef CONFIG_MIPS_DB1500
+char irq_tab_alchemy[][5] __initdata = {
+	[12] = { -1, INTA, INTX, INTX, INTX }, /* IDSEL 12 - HPT371   */
+	[13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot */
+};
+#endif
+
+#ifdef CONFIG_MIPS_BOSPORUS
+char irq_tab_alchemy[][5] __initdata = {
+	[11] = { -1, INTA, INTB, INTX, INTX }, /* IDSEL 11 - miniPCI  */
+	[12] = { -1, INTA, INTX, INTX, INTX }, /* IDSEL 12 - SN1741   */
+	[13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot */
+};
+#endif
+
+#ifdef CONFIG_MIPS_MIRAGE
+char irq_tab_alchemy[][5] __initdata = {
+	[11] = { -1, INTD, INTX, INTX, INTX }, /* IDSEL 11 - SMI VGX */
+	[12] = { -1, INTX, INTX, INTC, INTX }, /* IDSEL 12 - PNX1300 */
+	[13] = { -1, INTA, INTB, INTX, INTX }, /* IDSEL 13 - miniPCI */
+};
+#endif
+
+#ifdef CONFIG_MIPS_DB1550
+char irq_tab_alchemy[][5] __initdata = {
+	[11] = { -1, INTC, INTX, INTX, INTX }, /* IDSEL 11 - on-board HPT371 */
+	[12] = { -1, INTB, INTC, INTD, INTA }, /* IDSEL 12 - PCI slot 2 (left) */
+	[13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot 1 (right) */
+};
+#endif
+
 const char *get_system_type(void)
 {
 #ifdef CONFIG_MIPS_BOSPORUS
@@ -149,3 +181,26 @@ void __init board_setup(void)
 
 	au_sync();
 }
+
+static int __init db1x00_init_irq(void)
+{
+#if defined(CONFIG_MIPS_MIRAGE)
+	set_irq_type(AU1000_GPIO_7, IRQF_TRIGGER_RISING); /* TS pendown */
+#elif defined(CONFIG_MIPS_DB1550)
+	set_irq_type(AU1000_GPIO_0, IRQF_TRIGGER_LOW);	/* CD0# */
+	set_irq_type(AU1000_GPIO_1, IRQF_TRIGGER_LOW);	/* CD1# */
+	set_irq_type(AU1000_GPIO_3, IRQF_TRIGGER_LOW);	/* CARD0# */
+	set_irq_type(AU1000_GPIO_5, IRQF_TRIGGER_LOW);	/* CARD1# */
+	set_irq_type(AU1500_GPIO_21, IRQF_TRIGGER_LOW);	/* STSCHG0# */
+	set_irq_type(AU1500_GPIO_22, IRQF_TRIGGER_LOW);	/* STSCHG1# */
+#else
+	set_irq_type(AU1000_GPIO_0, IRQF_TRIGGER_LOW);	/* CD0# */
+	set_irq_type(AU1000_GPIO_3, IRQF_TRIGGER_LOW);	/* CD1# */
+	set_irq_type(AU1000_GPIO_2, IRQF_TRIGGER_LOW);	/* CARD0# */
+	set_irq_type(AU1000_GPIO_5, IRQF_TRIGGER_LOW);	/* CARD1# */
+	set_irq_type(AU1000_GPIO_1, IRQF_TRIGGER_LOW);	/* STSCHG0# */
+	set_irq_type(AU1000_GPIO_4, IRQF_TRIGGER_LOW);	/* STSCHG1# */
+#endif
+	return 0;
+}
+arch_initcall(db1x00_init_irq);
diff --git a/arch/mips/alchemy/devboards/pb1000/board_setup.c b/arch/mips/alchemy/devboards/pb1000/board_setup.c
index cd27354..f1cafea 100644
--- a/arch/mips/alchemy/devboards/pb1000/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1000/board_setup.c
@@ -32,11 +32,6 @@
 #include <prom.h>
 
 
-struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
-	{ AU1000_GPIO_15, IRQF_TRIGGER_LOW, 0 },
-};
-
-
 const char *get_system_type(void)
 {
 	return "Alchemy Pb1000";
@@ -46,11 +41,6 @@ void board_reset(void)
 {
 }
 
-void __init board_init_irq(void)
-{
-	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
-}
-
 void __init board_setup(void)
 {
 	u32 pin_func, static_cfg0;
@@ -193,3 +183,10 @@ void __init board_setup(void)
 		break;
 	}
 }
+
+static int __init pb1000_init_irq(void)
+{
+	set_irq_type(AU1000_GPIO_15, IRQF_TRIGGER_LOW);
+	return 0;
+}
+arch_initcall(pb1000_init_irq);
diff --git a/arch/mips/alchemy/devboards/pb1100/board_setup.c b/arch/mips/alchemy/devboards/pb1100/board_setup.c
index eb749fb..aad424a 100644
--- a/arch/mips/alchemy/devboards/pb1100/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1100/board_setup.c
@@ -35,14 +35,6 @@
 #include <prom.h>
 
 
-struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
-	{ AU1000_GPIO_9,  IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card Fully_Inserted# */
-	{ AU1000_GPIO_10, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card STSCHG# */
-	{ AU1000_GPIO_11, IRQF_TRIGGER_LOW, 0 }, /* PCMCIA Card IRQ# */
-	{ AU1000_GPIO_13, IRQF_TRIGGER_LOW, 0 }, /* DC_IRQ# */
-};
-
-
 const char *get_system_type(void)
 {
 	return "Alchemy Pb1100";
@@ -53,11 +45,6 @@ void board_reset(void)
 	bcsr_write(BCSR_SYSTEM, 0);
 }
 
-void __init board_init_irq(void)
-{
-	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
-}
-
 void __init board_setup(void)
 {
 	volatile void __iomem *base = (volatile void __iomem *)0xac000000UL;
@@ -158,3 +145,14 @@ void __init board_setup(void)
 		au_sync();
 	}
 }
+
+static int __init pb1100_init_irq(void)
+{
+	set_irq_type(AU1000_GPIO_9,  IRQF_TRIGGER_LOW);	/* PCCD# */
+	set_irq_type(AU1000_GPIO_10, IRQF_TRIGGER_LOW); /* PCSTSCHG# */
+	set_irq_type(AU1000_GPIO_11, IRQF_TRIGGER_LOW); /* PCCard# */
+	set_irq_type(AU1000_GPIO_13, IRQF_TRIGGER_LOW); /* DC_IRQ# */
+
+	return 0;
+}
+arch_initcall(pb1100_init_irq);
diff --git a/arch/mips/alchemy/devboards/pb1200/Makefile b/arch/mips/alchemy/devboards/pb1200/Makefile
index c8c3a99..2ea9b02 100644
--- a/arch/mips/alchemy/devboards/pb1200/Makefile
+++ b/arch/mips/alchemy/devboards/pb1200/Makefile
@@ -2,6 +2,6 @@
 # Makefile for the Alchemy Semiconductor Pb1200/DBAu1200 boards.
 #
 
-obj-y := board_setup.o irqmap.o platform.o
+obj-y := board_setup.o platform.o
 
 EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/alchemy/devboards/pb1200/board_setup.c b/arch/mips/alchemy/devboards/pb1200/board_setup.c
index db56380..76aa652 100644
--- a/arch/mips/alchemy/devboards/pb1200/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1200/board_setup.c
@@ -25,13 +25,25 @@
  */
 
 #include <linux/init.h>
+#include <linux/interrupt.h>
 #include <linux/sched.h>
 
+#include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-db1x00/bcsr.h>
 
-#include <prom.h>
-#include <au1xxx.h>
+#ifdef CONFIG_MIPS_PB1200
+#include <asm/mach-pb1x00/pb1200.h>
+#endif
+
+#ifdef CONFIG_MIPS_DB1200
+#include <asm/mach-db1x00/db1200.h>
+#define PB1200_INT_BEGIN DB1200_INT_BEGIN
+#define PB1200_INT_END DB1200_INT_END
+#endif
 
+#include <asm/mach-db1x00/bcsr.h>
+
+#include <prom.h>
 
 const char *get_system_type(void)
 {
@@ -137,6 +149,38 @@ void __init board_setup(void)
 	au_sync();
 }
 
+static int __init pb1200_init_irq(void)
+{
+#ifdef CONFIG_MIPS_PB1200
+	/* We have a problem with CPLD rev 3. */
+	if (BCSR_WHOAMI_CPLD(bcsr_read(BCSR_WHOAMI)) <= 3) {
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n");
+		printk(KERN_ERR "updated to latest revision. This software will\n");
+		printk(KERN_ERR "not work on anything less than CPLD rev 4.\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		printk(KERN_ERR "WARNING!!!\n");
+		panic("Game over.  Your score is 0.");
+	}
+#endif
+
+	set_irq_type(AU1000_GPIO_7, IRQF_TRIGGER_LOW);
+	bcsr_init_irq(PB1200_INT_BEGIN, PB1200_INT_END, AU1000_GPIO_7);
+
+	return 0;
+}
+arch_initcall(pb1200_init_irq);
+
+
 int board_au1200fb_panel(void)
 {
 	return (bcsr_read(BCSR_SWITCHES) >> 8) & 0x0f;
diff --git a/arch/mips/alchemy/devboards/pb1200/irqmap.c b/arch/mips/alchemy/devboards/pb1200/irqmap.c
deleted file mode 100644
index 3beb804..0000000
--- a/arch/mips/alchemy/devboards/pb1200/irqmap.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * BRIEF MODULE DESCRIPTION
- *	Au1xxx irq map table
- *
- *  This program is free software; you can redistribute	 it and/or modify it
- *  under  the terms of	 the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the	License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED	  ``AS	IS'' AND   ANY	EXPRESS OR IMPLIED
- *  WARRANTIES,	  INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO	EVENT  SHALL   THE AUTHOR  BE	 LIABLE FOR ANY	  DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED	  TO, PROCUREMENT OF  SUBSTITUTE GOODS	OR SERVICES; LOSS OF
- *  USE, DATA,	OR PROFITS; OR	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN	 CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/init.h>
-#include <linux/interrupt.h>
-
-#include <asm/mach-au1x00/au1000.h>
-
-#ifdef CONFIG_MIPS_PB1200
-#include <asm/mach-pb1x00/pb1200.h>
-#endif
-
-#ifdef CONFIG_MIPS_DB1200
-#include <asm/mach-db1x00/db1200.h>
-#define PB1200_INT_BEGIN DB1200_INT_BEGIN
-#define PB1200_INT_END DB1200_INT_END
-#endif
-
-#include <asm/mach-db1x00/bcsr.h>
-
-struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
-	/* This is external interrupt cascade */
-	{ AU1000_GPIO_7, IRQF_TRIGGER_LOW, 0 },
-};
-
-void __init board_init_irq(void)
-{
-	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
-
-#ifdef CONFIG_MIPS_PB1200
-	/* We have a problem with CPLD rev 3. */
-	if (BCSR_WHOAMI_CPLD(bcsr_read(BCSR_WHOAMI)) <= 3) {
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n");
-		printk(KERN_ERR "updated to latest revision. This software will\n");
-		printk(KERN_ERR "not work on anything less than CPLD rev 4.\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		printk(KERN_ERR "WARNING!!!\n");
-		panic("Game over.  Your score is 0.");
-	}
-#endif
-
-	bcsr_init_irq(PB1200_INT_BEGIN, PB1200_INT_END, AU1000_GPIO_7);
-}
diff --git a/arch/mips/alchemy/devboards/pb1500/board_setup.c b/arch/mips/alchemy/devboards/pb1500/board_setup.c
index 7439303..543885d 100644
--- a/arch/mips/alchemy/devboards/pb1500/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1500/board_setup.c
@@ -40,17 +40,6 @@ char irq_tab_alchemy[][5] __initdata = {
 	[13] = { -1, INTA, INTB, INTC, INTD },   /* IDSEL 13 - PCI slot */
 };
 
-struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
-	{ AU1000_GPIO_9,   IRQF_TRIGGER_LOW, 0 },
-	{ AU1000_GPIO_10,  IRQF_TRIGGER_LOW, 0 },
-	{ AU1000_GPIO_11,  IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_204, IRQF_TRIGGER_HIGH, 0 },
-	{ AU1500_GPIO_201, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_202, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_203, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_205, IRQF_TRIGGER_LOW, 0 },
-};
-
 
 const char *get_system_type(void)
 {
@@ -62,11 +51,6 @@ void board_reset(void)
 	bcsr_write(BCSR_SYSTEM, 0);
 }
 
-void __init board_init_irq(void)
-{
-	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
-}
-
 void __init board_setup(void)
 {
 	u32 pin_func;
@@ -169,3 +153,19 @@ void __init board_setup(void)
 		au_sync();
 	}
 }
+
+static int __init pb1500_init_irq(void)
+{
+	set_irq_type(AU1000_GPIO_9,  IRQF_TRIGGER_LOW);	/* PCCD# */
+	set_irq_type(AU1000_GPIO_10, IRQF_TRIGGER_LOW);	/* PCSTSCHG# */
+	set_irq_type(AU1000_GPIO_11, IRQF_TRIGGER_LOW);	/* CARD# */
+
+	set_irq_type(AU1500_GPIO_204, IRQF_TRIGGER_HIGH);
+	set_irq_type(AU1500_GPIO_201, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_202, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_203, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_205, IRQF_TRIGGER_LOW);
+
+	return 0;
+}
+arch_initcall(pb1500_init_irq);
diff --git a/arch/mips/alchemy/devboards/pb1550/board_setup.c b/arch/mips/alchemy/devboards/pb1550/board_setup.c
index 957e3ae..34bc59e 100644
--- a/arch/mips/alchemy/devboards/pb1550/board_setup.c
+++ b/arch/mips/alchemy/devboards/pb1550/board_setup.c
@@ -43,12 +43,6 @@ char irq_tab_alchemy[][5] __initdata = {
 	[13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot 1 (right) */
 };
 
-struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
-	{ AU1000_GPIO_0, IRQF_TRIGGER_LOW, 0 },
-	{ AU1000_GPIO_1, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_201_205, IRQF_TRIGGER_LOW, 0 },
-};
-
 const char *get_system_type(void)
 {
 	return "Alchemy Pb1550";
@@ -59,13 +53,6 @@ void board_reset(void)
 	bcsr_write(BCSR_SYSTEM, 0);
 }
 
-void __init board_init_irq(void)
-{
-	alchemy_gpio2_enable_int(201);
-	alchemy_gpio2_enable_int(202);
-	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
-}
-
 void __init board_setup(void)
 {
 	u32 pin_func;
@@ -99,3 +86,15 @@ void __init board_setup(void)
 
 	printk(KERN_INFO "AMD Alchemy Pb1550 Board\n");
 }
+
+static int __init pb1550_init_irq(void)
+{
+	set_irq_type(AU1000_GPIO_0, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1000_GPIO_1, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_201_205, IRQF_TRIGGER_LOW);
+	alchemy_gpio2_enable_int(201);
+	alchemy_gpio2_enable_int(202);
+
+	return 0;
+}
+arch_initcall(pb1550_init_irq);
diff --git a/arch/mips/alchemy/mtx-1/Makefile b/arch/mips/alchemy/mtx-1/Makefile
index 7c67b3d..4a53815 100644
--- a/arch/mips/alchemy/mtx-1/Makefile
+++ b/arch/mips/alchemy/mtx-1/Makefile
@@ -6,7 +6,7 @@
 # Makefile for 4G Systems MTX-1 board.
 #
 
-lib-y := init.o board_setup.o irqmap.o
+lib-y := init.o board_setup.o
 obj-y := platform.o
 
 EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/alchemy/mtx-1/board_setup.c b/arch/mips/alchemy/mtx-1/board_setup.c
index cc32c69..568492c 100644
--- a/arch/mips/alchemy/mtx-1/board_setup.c
+++ b/arch/mips/alchemy/mtx-1/board_setup.c
@@ -30,11 +30,23 @@
 
 #include <linux/gpio.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 
 #include <asm/mach-au1x00/au1000.h>
 
 #include <prom.h>
 
+char irq_tab_alchemy[][5] __initdata = {
+	[0] = { -1, INTA, INTA, INTX, INTX }, /* IDSEL 00 - AdapterA-Slot0 (top) */
+	[1] = { -1, INTB, INTA, INTX, INTX }, /* IDSEL 01 - AdapterA-Slot1 (bottom) */
+	[2] = { -1, INTC, INTD, INTX, INTX }, /* IDSEL 02 - AdapterB-Slot0 (top) */
+	[3] = { -1, INTD, INTC, INTX, INTX }, /* IDSEL 03 - AdapterB-Slot1 (bottom) */
+	[4] = { -1, INTA, INTB, INTX, INTX }, /* IDSEL 04 - AdapterC-Slot0 (top) */
+	[5] = { -1, INTB, INTA, INTX, INTX }, /* IDSEL 05 - AdapterC-Slot1 (bottom) */
+	[6] = { -1, INTC, INTD, INTX, INTX }, /* IDSEL 06 - AdapterD-Slot0 (top) */
+	[7] = { -1, INTD, INTC, INTX, INTX }, /* IDSEL 07 - AdapterD-Slot1 (bottom) */
+};
+
 extern int (*board_pci_idsel)(unsigned int devsel, int assert);
 int mtx1_pci_idsel(unsigned int devsel, int assert);
 
@@ -110,3 +122,15 @@ mtx1_pci_idsel(unsigned int devsel, int assert)
 	au_sync_udelay(1);
 	return 1;
 }
+
+static int __init mtx1_init_irq(void)
+{
+	set_irq_type(AU1500_GPIO_204, IRQF_TRIGGER_HIGH);
+	set_irq_type(AU1500_GPIO_201, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_202, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_203, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_205, IRQF_TRIGGER_LOW);
+
+	return 0;
+}
+arch_initcall(mtx1_init_irq);
diff --git a/arch/mips/alchemy/mtx-1/irqmap.c b/arch/mips/alchemy/mtx-1/irqmap.c
deleted file mode 100644
index f1ab12a..0000000
--- a/arch/mips/alchemy/mtx-1/irqmap.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * BRIEF MODULE DESCRIPTION
- *	Au1xxx irq map table
- *
- * Copyright 2003 Embedded Edge, LLC
- *		dan@embeddededge.com
- *
- *  This program is free software; you can redistribute	 it and/or modify it
- *  under  the terms of	 the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the	License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED	  ``AS	IS'' AND   ANY	EXPRESS OR IMPLIED
- *  WARRANTIES,	  INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO	EVENT  SHALL   THE AUTHOR  BE	 LIABLE FOR ANY	  DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED	  TO, PROCUREMENT OF  SUBSTITUTE GOODS	OR SERVICES; LOSS OF
- *  USE, DATA,	OR PROFITS; OR	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN	 CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <asm/mach-au1x00/au1000.h>
-
-char irq_tab_alchemy[][5] __initdata = {
-	[0] = { -1, INTA, INTA, INTX, INTX }, /* IDSEL 00 - AdapterA-Slot0 (top) */
-	[1] = { -1, INTB, INTA, INTX, INTX }, /* IDSEL 01 - AdapterA-Slot1 (bottom) */
-	[2] = { -1, INTC, INTD, INTX, INTX }, /* IDSEL 02 - AdapterB-Slot0 (top) */
-	[3] = { -1, INTD, INTC, INTX, INTX }, /* IDSEL 03 - AdapterB-Slot1 (bottom) */
-	[4] = { -1, INTA, INTB, INTX, INTX }, /* IDSEL 04 - AdapterC-Slot0 (top) */
-	[5] = { -1, INTB, INTA, INTX, INTX }, /* IDSEL 05 - AdapterC-Slot1 (bottom) */
-	[6] = { -1, INTC, INTD, INTX, INTX }, /* IDSEL 06 - AdapterD-Slot0 (top) */
-	[7] = { -1, INTD, INTC, INTX, INTX }, /* IDSEL 07 - AdapterD-Slot1 (bottom) */
-};
-
-struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
-       { AU1500_GPIO_204, IRQF_TRIGGER_HIGH, 0 },
-       { AU1500_GPIO_201, IRQF_TRIGGER_LOW, 0 },
-       { AU1500_GPIO_202, IRQF_TRIGGER_LOW, 0 },
-       { AU1500_GPIO_203, IRQF_TRIGGER_LOW, 0 },
-       { AU1500_GPIO_205, IRQF_TRIGGER_LOW, 0 },
-};
-
-
-void __init board_init_irq(void)
-{
-	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
-}
diff --git a/arch/mips/alchemy/xxs1500/Makefile b/arch/mips/alchemy/xxs1500/Makefile
index db3c526..545d8f5 100644
--- a/arch/mips/alchemy/xxs1500/Makefile
+++ b/arch/mips/alchemy/xxs1500/Makefile
@@ -5,4 +5,4 @@
 # Makefile for MyCable XXS1500 board.
 #
 
-lib-y := init.o board_setup.o irqmap.o
+lib-y := init.o board_setup.o
diff --git a/arch/mips/alchemy/xxs1500/board_setup.c b/arch/mips/alchemy/xxs1500/board_setup.c
index 4de2d48..cad14f8 100644
--- a/arch/mips/alchemy/xxs1500/board_setup.c
+++ b/arch/mips/alchemy/xxs1500/board_setup.c
@@ -25,6 +25,7 @@
 
 #include <linux/gpio.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
 #include <linux/delay.h>
 
 #include <asm/mach-au1x00/au1000.h>
@@ -92,3 +93,23 @@ void __init board_setup(void)
 #endif
 #endif
 }
+
+static int __init xxs1500_init_irq(void)
+{
+	set_irq_type(AU1500_GPIO_204, IRQF_TRIGGER_HIGH);
+	set_irq_type(AU1500_GPIO_201, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_202, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_203, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_205, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1500_GPIO_207, IRQF_TRIGGER_LOW);
+
+	set_irq_type(AU1000_GPIO_0, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1000_GPIO_1, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1000_GPIO_2, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1000_GPIO_3, IRQF_TRIGGER_LOW);
+	set_irq_type(AU1000_GPIO_4, IRQF_TRIGGER_LOW); /* CF interrupt */
+	set_irq_type(AU1000_GPIO_5, IRQF_TRIGGER_LOW);
+
+	return 0;
+}
+arch_initcall(xxs1500_init_irq);
diff --git a/arch/mips/alchemy/xxs1500/irqmap.c b/arch/mips/alchemy/xxs1500/irqmap.c
deleted file mode 100644
index 0f0f301..0000000
--- a/arch/mips/alchemy/xxs1500/irqmap.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * BRIEF MODULE DESCRIPTION
- *	Au1xxx irq map table
- *
- * Copyright 2003 Embedded Edge, LLC
- *		dan@embeddededge.com
- *
- *  This program is free software; you can redistribute	 it and/or modify it
- *  under  the terms of	 the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the	License, or (at your
- *  option) any later version.
- *
- *  THIS  SOFTWARE  IS PROVIDED	  ``AS	IS'' AND   ANY	EXPRESS OR IMPLIED
- *  WARRANTIES,	  INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
- *  NO	EVENT  SHALL   THE AUTHOR  BE	 LIABLE FOR ANY	  DIRECT, INDIRECT,
- *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- *  NOT LIMITED	  TO, PROCUREMENT OF  SUBSTITUTE GOODS	OR SERVICES; LOSS OF
- *  USE, DATA,	OR PROFITS; OR	BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- *  ANY THEORY OF LIABILITY, WHETHER IN	 CONTRACT, STRICT LIABILITY, OR TORT
- *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <asm/mach-au1x00/au1000.h>
-
-struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
-	{ AU1500_GPIO_204, IRQF_TRIGGER_HIGH, 0 },
-	{ AU1500_GPIO_201, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_202, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_203, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_205, IRQF_TRIGGER_LOW, 0 },
-	{ AU1500_GPIO_207, IRQF_TRIGGER_LOW, 0 },
-
-	{ AU1000_GPIO_0, IRQF_TRIGGER_LOW, 0 },
-	{ AU1000_GPIO_1, IRQF_TRIGGER_LOW, 0 },
-	{ AU1000_GPIO_2, IRQF_TRIGGER_LOW, 0 },
-	{ AU1000_GPIO_3, IRQF_TRIGGER_LOW, 0 },
-	{ AU1000_GPIO_4, IRQF_TRIGGER_LOW, 0 }, /* CF interrupt */
-	{ AU1000_GPIO_5, IRQF_TRIGGER_LOW, 0 },
-};
-
-void __init board_init_irq(void)
-{
-	au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
-}
diff --git a/arch/mips/include/asm/mach-au1x00/au1000.h b/arch/mips/include/asm/mach-au1x00/au1000.h
index df04e91..fceeca8 100644
--- a/arch/mips/include/asm/mach-au1x00/au1000.h
+++ b/arch/mips/include/asm/mach-au1x00/au1000.h
@@ -143,21 +143,6 @@ void au_sleep(void);
 void save_au1xxx_intctl(void);
 void restore_au1xxx_intctl(void);
 
-/*
- * Every board describes its IRQ mapping with this table.
- */
-struct au1xxx_irqmap {
-	int	im_irq;
-	int	im_type;
-	int	im_request;
-};
-
-/* core calls this function to let boards initialize other IRQ sources */
-void board_init_irq(void);
-
-/* boards call this to register additional (GPIO) interrupts */
-void au1xxx_setup_irqmap(struct au1xxx_irqmap *map, int count);
-
 #endif /* !defined (_LANGUAGE_ASSEMBLY) */
 
 /*
diff --git a/arch/mips/include/asm/mach-db1x00/db1200.h b/arch/mips/include/asm/mach-db1x00/db1200.h
index 1fbcca4..52b1d84 100644
--- a/arch/mips/include/asm/mach-db1x00/db1200.h
+++ b/arch/mips/include/asm/mach-db1x00/db1200.h
@@ -25,6 +25,7 @@
 #define __ASM_DB1200_H
 
 #include <linux/types.h>
+#include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-au1x00/au1xxx_psc.h>
 
 #define DBDMA_AC97_TX_CHAN	DSCR_CMD0_PSC1_TX
diff --git a/arch/mips/include/asm/mach-pb1x00/pb1200.h b/arch/mips/include/asm/mach-pb1x00/pb1200.h
index 07ad170..962eb55 100644
--- a/arch/mips/include/asm/mach-pb1x00/pb1200.h
+++ b/arch/mips/include/asm/mach-pb1x00/pb1200.h
@@ -25,6 +25,7 @@
 #define __ASM_PB1200_H
 
 #include <linux/types.h>
+#include <asm/mach-au1x00/au1000.h>
 #include <asm/mach-au1x00/au1xxx_psc.h>
 
 #define DBDMA_AC97_TX_CHAN	DSCR_CMD0_PSC1_TX
-- 
1.6.5.rc1


