Received: from milmhbs1.lsil.com (147.145.21.209) by coscas01.lsi.com
 (172.21.36.60) with Microsoft SMTP Server id 8.1.393.1; Sun, 31 Jan 2010
 13:09:33 -0700
Received: from mail1.lsil.com (mail1.lsil.com [147.145.40.21])	by
 milmhbs1.lsil.com (8.12.11/8.12.11) with ESMTP id o0VK9P5c029108	for
 <andy.sharp@lsi.com>; Sun, 31 Jan 2010 12:09:25 -0800
Received: from psmtp.com (na3sys009amx171.postini.com [74.125.149.97])	by
 mail1.lsil.com (8.12.11/8.12.11) with SMTP id o0VK9NjZ024835	for
 <andy.sharp@lsi.com>; Sun, 31 Jan 2010 12:09:24 -0800 (PST)
Received: from source ([78.24.191.182]) by na3sys009amx171.postini.com
 ([74.125.148.14]) with SMTP;	Sun, 31 Jan 2010 14:09:24 CST
Received: from localhost.localdomain ([127.0.0.1]:60593 "EHLO
        eddie.linux-mips.org" rhost-flags-OK-OK-OK-FAIL)        by
 eddie.linux-mips.org with ESMTP id S1493120Ab0AaUJU (ORCPT
        <rfc822;andy.sharp@lsi.com>); Sun, 31 Jan 2010 21:09:20 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Sun, 31 Jan 2010 21:09:02
 +0100 (CET)
Received: from lo.gmane.org ([80.91.229.12]:52941 "EHLO lo.gmane.org"
        rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP        id
 S1493112Ab0AaUId (ORCPT <rfc822;linux-mips@linux-mips.org>);        Sun, 31
 Jan 2010 21:08:33 +0100
Received: from list by lo.gmane.org with local (Exim 4.69)
        (envelope-from <sgi-linux-mips@m.gmane.org>)        id
 1Nbg5t-0006Iu-PP        for linux-mips@linux-mips.org; Sun, 31 Jan 2010
 21:08:29 +0100
Received: from chipmunk.wormnet.eu ([195.195.131.226])        by
 main.gmane.org with esmtp (Gmexim 0.1 (Debian))        id 1AlnuQ-0007hv-00
        for <linux-mips@linux-mips.org>; Sun, 31 Jan 2010 21:08:29 +0100
Received: from alex by chipmunk.wormnet.eu with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00        for <linux-mips@linux-mips.org>; Sun, 31
 Jan 2010 21:08:29 +0100
From: Alexander Clouter <alex@digriz.org.uk>
To: "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Sun, 31 Jan 2010 12:39:57 -0700
Subject: [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more durable
Thread-Topic: [PATCH 3/3] MIPS: AR7 make ar7_register_devices much more
 durable
Thread-Index: AcqisU5pMX93b4QKSMueM/0sB7e8Eg==
Message-ID: <dt2h37-ch6.ln1@chipmunk.wormnet.eu>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Anonymous
X-MS-Exchange-Organization-AuthSource: coscas01.lsi.com
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-scanned-by: MIMEDefang 2.39
errors-to: linux-mips-bounce@linux-mips.org
x-pstn-levels: (S:95.37927/99.90000 CV:99.9000 FC:95.5390 LC:95.5390
 R:95.9108 P:95.9108 M:97.0282 C:98.6951 )
x-pstn-settings: 3 (1.0000:1.0000) s cv gt3 gt2 gt1 r p m c 
x-pstn-addresses: from <alex@digriz.org.uk> [22/1] 
x-pstn-neptune: 0/0/0.00/0
user-agent: tin/1.9.3-20080506 ("Dalintober") (UNIX)
 (Linux/2.6.26-2-sparc64-smp (sparc64))
x-complaints-to: usenet@ger.gmane.org
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

MIPS: AR7 make ar7_register_devices much more durable

Signed-off-by: Alexander Clouter <alex@digriz.org.uk>
---
 arch/mips/ar7/platform.c |  157 +++++++++++++++++++++++++-----------------=
----
 1 files changed, 86 insertions(+), 71 deletions(-)

diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 65facec..e654e73 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -529,115 +529,130 @@ static struct platform_device ar7_wdt =3D {
 /*************************************************************************=
****
  * Init
  *************************************************************************=
***/
-static int __init ar7_register_devices(void)
+static int __init ar7_register_uarts(void)
 {
-	u16 chip_id;
-	int res;
-	u32 *bootcr, val;
 #ifdef CONFIG_SERIAL_8250
-	static struct uart_port uart_port[2] __initdata;
+	static struct uart_port uart_port __initdata;
 	struct clk *bus_clk;
+	int res;
=20
-	memset(uart_port, 0, sizeof(struct uart_port) * 2);
-
+	memset(&uart_port, 0, sizeof(struct uart_port));
+=20
 	bus_clk =3D clk_get(NULL, "bus");
 	if (IS_ERR(bus_clk))
 		panic("unable to get bus clk\n");
-
-	uart_port[0].type	=3D PORT_16550A;
-	uart_port[0].line	=3D 0;
-	uart_port[0].irq	=3D AR7_IRQ_UART0;
-	uart_port[0].uartclk	=3D clk_get_rate(bus_clk) / 2;
-	uart_port[0].iotype	=3D UPIO_MEM32;
-	uart_port[0].mapbase	=3D AR7_REGS_UART0;
-	uart_port[0].membase	=3D ioremap(uart_port[0].mapbase, 256);
-	uart_port[0].regshift	=3D 2;
-	res =3D early_serial_setup(&uart_port[0]);
+=20
+	uart_port.type		=3D PORT_16550A;
+	uart_port.uartclk	=3D clk_get_rate(bus_clk) / 2;
+	uart_port.iotype	=3D UPIO_MEM32;
+	uart_port.regshift	=3D 2;
+
+	uart_port.line		=3D 0;
+	uart_port.irq		=3D AR7_IRQ_UART0;
+	uart_port.mapbase	=3D AR7_REGS_UART0;
+	uart_port.membase	=3D ioremap(uart_port.mapbase, 256);
+
+	res =3D early_serial_setup(&uart_port);
 	if (res)
 		return res;
-
+=20
 	/* Only TNETD73xx have a second serial port */
 	if (ar7_has_second_uart()) {
-		uart_port[1].type	=3D PORT_16550A;
-		uart_port[1].line	=3D 1;
-		uart_port[1].irq	=3D AR7_IRQ_UART1;
-		uart_port[1].uartclk	=3D clk_get_rate(bus_clk) / 2;
-		uart_port[1].iotype	=3D UPIO_MEM32;
-		uart_port[1].mapbase	=3D UR8_REGS_UART1;
-		uart_port[1].membase 	=3D ioremap(uart_port[1].mapbase, 256);
-		uart_port[1].regshift	=3D 2;
-		res =3D early_serial_setup(&uart_port[1]);
+		uart_port.line		=3D 1;
+		uart_port.irq		=3D AR7_IRQ_UART1;
+		uart_port.mapbase	=3D UR8_REGS_UART1;
+		uart_port.membase	=3D ioremap(uart_port.mapbase, 256);
+
+		res =3D early_serial_setup(&uart_port);
 		if (res)
 			return res;
-	}
-#endif /* CONFIG_SERIAL_8250 */
+ 	}
+#endif
+
+	return 0;
+}
+
+static int __init ar7_register_devices(void)
+{
+	void __iomem *bootcr;
+	u32 val;
+	u16 chip_id;
+	int res;
+
+	res =3D ar7_register_uarts();
+	if (res)
+		printk(KERN_ERR "unable to setup uart(s): %d\n", res);
+
 	res =3D platform_device_register(&physmap_flash);
 	if (res)
-		return res;
+		printk(KERN_WARNING "unable to register physmap-flash: %d\n", res);
=20
 	ar7_device_disable(vlynq_low_data.reset_bit);
 	res =3D platform_device_register(&vlynq_low);
 	if (res)
-		return res;
+		printk(KERN_WARNING "unable to register vlynq-low: %d\n", res);
=20
 	if (ar7_has_high_vlynq()) {
 		ar7_device_disable(vlynq_high_data.reset_bit);
 		res =3D platform_device_register(&vlynq_high);
 		if (res)
-			return res;
+			printk(KERN_WARNING "unable to register vlynq-high: %d\n", res);
 	}
=20
 	if (ar7_has_high_cpmac()) {
-		res =3D fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status);
-		if (res && res !=3D -ENODEV)
-			return res;
-		cpmac_get_mac(1, cpmac_high_data.dev_addr);
-		res =3D platform_device_register(&cpmac_high);
-		if (res)
-			return res;
-	} else {
+		if (!res) {
+			cpmac_get_mac(1, cpmac_high_data.dev_addr);
+
+			res =3D platform_device_register(&cpmac_high);
+			if (res)
+				printk(KERN_WARNING "unable to register cpmac-high: %d\n", res);
+		} else
+			printk(KERN_WARNING "unable to add cpmac-high phy: %d\n", res);
+	} else
 		cpmac_low_data.phy_mask =3D 0xffffffff;
-	}
=20
 	res =3D fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status);
-	if (res && res !=3D -ENODEV)
-		return res;
-
-	cpmac_get_mac(0, cpmac_low_data.dev_addr);
-	res =3D platform_device_register(&cpmac_low);
-	if (res)
-		return res;
+	if (!res) {
+		cpmac_get_mac(0, cpmac_low_data.dev_addr);
+		res =3D platform_device_register(&cpmac_low);
+		if (res)
+			printk(KERN_WARNING "unable to register cpmac-low: %d\n", res);
+	} else
+		printk(KERN_WARNING "unable to add cpmac-low phy: %d\n", res);
=20
 	detect_leds();
 	res =3D platform_device_register(&ar7_gpio_leds);
 	if (res)
-		return res;
+		printk(KERN_WARNING "unable to register leds: %d\n", res);
=20
 	res =3D platform_device_register(&ar7_udc);
-
-	chip_id =3D ar7_chip_id();
-	switch (chip_id) {
-	case AR7_CHIP_7100:
-	case AR7_CHIP_7200:
-		ar7_wdt_res.start =3D AR7_REGS_WDT;
-		break;
-	case AR7_CHIP_7300:
-		ar7_wdt_res.start =3D UR8_REGS_WDT;
-		break;
-	default:
-		break;
-	}
-
-	ar7_wdt_res.end =3D ar7_wdt_res.start + 0x20;
-
-	bootcr =3D (u32 *)ioremap_nocache(AR7_REGS_DCL, 4);
-	val =3D *bootcr;
-	iounmap(bootcr);
+	if (res)
+		printk(KERN_WARNING "unable to register usb slave: %d\n", res);
=20
 	/* Register watchdog only if enabled in hardware */
-	if (val & AR7_WDT_HW_ENA)
-		res =3D platform_device_register(&ar7_wdt);
+	bootcr =3D ioremap_nocache(AR7_REGS_DCL, 4);
+	val =3D readl(bootcr);
+ 	iounmap(bootcr);
+	if (val & AR7_WDT_HW_ENA) {
+		chip_id =3D ar7_chip_id();
+		switch (chip_id) {
+		case AR7_CHIP_7100:
+		case AR7_CHIP_7200:
+			ar7_wdt_res.start =3D AR7_REGS_WDT;
+			break;
+		case AR7_CHIP_7300:
+			ar7_wdt_res.start =3D UR8_REGS_WDT;
+			break;
+		default:
+			break;
+		}
+
+		ar7_wdt_res.end =3D ar7_wdt_res.start + 0x20;
+ 		res =3D platform_device_register(&ar7_wdt);
+		if (res)
+			printk(KERN_WARNING "unable to register watchdog: %d\n", res);
+	}
=20
-	return res;
+	return 0;
 }
 arch_initcall(ar7_register_devices);
--=20
1.6.6


