Received: from mail.onstor.com (66.201.51.107) by exch1.onstor.net
 (10.0.0.225) with Microsoft SMTP Server id 8.1.311.2; Thu, 15 Jan 2009
 06:39:51 -0800
Received: from dalesmta2-1.messageone.com ([129.41.169.249]) by
 mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);	 Thu, 15 Jan 2009
 06:39:50 -0800
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])	by
 dalesmta2-1.messageone.com (8.13.8/8.13.8) with ESMTP id n0FEdoTC004016	for
 <andy.sharp@onstor.com>; Thu, 15 Jan 2009 08:39:50 -0600
Received: from localhost.localdomain ([127.0.0.1]:456 "EHLO
 ftp.linux-mips.org")	by ftp.linux-mips.org with ESMTP id S21365936AbZAOOjL
 (ORCPT	<rfc822;andy.sharp@onstor.com>); Thu, 15 Jan 2009 14:39:11 +0000
Received: with ECARTIS (v1.0.0; list linux-mips); Thu, 15 Jan 2009 14:38:54
 +0000 (GMT)
Received: from orbit.nwl.cc ([91.121.169.95]:24014 "EHLO mail.nwl.cc")	by
 ftp.linux-mips.org with ESMTP id S21365139AbZAOOiv (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Thu, 15 Jan 2009 14:38:51 +0000
Received: from base (localhost [127.0.0.1])	by mail.nwl.cc (Postfix) with
 ESMTP id 5F0CF4043837;	Thu, 15 Jan 2009 15:38:46 +0100 (CET)
From: Phil Sutter <n0-1@freewrt.org>
To: Linux-Mips List <linux-mips@linux-mips.org>
CC: "florian@openwrt.org" <florian@openwrt.org>, "ralf@linux-mips.org"
	<ralf@linux-mips.org>, "ddaney@caviumnetworks.com"
	<ddaney@caviumnetworks.com>
Sender: "linux-mips-bounce@linux-mips.org" <linux-mips-bounce@linux-mips.org>
Date: Thu, 15 Jan 2009 06:38:38 -0800
Subject: [PATCH] MIPS: rb532: detect uart type, add platform device
Thread-Topic: [PATCH] MIPS: rb532: detect uart type, add platform device
Thread-Index: Acl3Hx/qwWXmJ56zSYy7isOFwiVt9A==
Message-ID: <20090115143846.5F0CF4043837@mail.nwl.cc>
Accept-Language: en-US
Content-Language: en-US
X-MS-Exchange-Organization-AuthAs: Internal
X-MS-Exchange-Organization-AuthMechanism: 0b
X-MS-Exchange-Organization-AuthSource: exch1.onstor.net
X-MS-Has-Attach:
X-Auto-Response-Suppress: All
X-MS-TNEF-Correlator:
x-originalarrivaltime: 15 Jan 2009 14:39:51.0235 (UTC)
 FILETIME=[1F76F130:01C9771F]
errors-to: linux-mips-bounce@linux-mips.org
x-ems-proccessed: 2K3Xl1OQTInXD6xxuA8z3Q==
x-ems-stamp: tB/hCB7g8dlDKDFA6z+FdQ==
x-messageone-virus-version: vendor=fsecure
 engine=4.65.7400:2.4.4,1.2.40,4.0.164
 definitions=2009-01-15_04:2009-01-08,2009-01-15,2009-01-15 signatures=0
x-messageone-virus-scanned: Clean
x-messageone-envelope-sender: linux-mips-bounce@linux-mips.org
x-messageone-spam-details: rule=m773emszm_notspam policy=m773emszm score=0
 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam
 adjust=0 reason=mlx engine=3.1.0-0810130000 definitions=main-0901150070
x-messageone-spam-score: 0
x-messageone-spam-bar:
x-list: linux-mips
x-archive-position: 21747
x-ecartis-version: Ecartis v1.0.0
x-original-sender: n0-1@freewrt.org
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

Auto-detection works just fine, so use it instead of specifying the type
manually. Also define a platform device for the uart, as suggested by
David Daney.

Signed-off-by: Phil Sutter <n0-1@freewrt.org>
---
 arch/mips/rb532/devices.c |   26 ++++++++++++++++++++++++++
 arch/mips/rb532/serial.c  |    2 +-
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
index c1c2918..9b6b744 100644
--- a/arch/mips/rb532/devices.c
+++ b/arch/mips/rb532/devices.c
@@ -24,6 +24,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/serial_8250.h>
=20
 #include <asm/bootinfo.h>
=20
@@ -39,6 +40,8 @@
 #define ETH0_RX_DMA_ADDR  (DMA0_BASE_ADDR + 0 * DMA_CHAN_OFFSET)
 #define ETH0_TX_DMA_ADDR  (DMA0_BASE_ADDR + 1 * DMA_CHAN_OFFSET)
=20
+extern unsigned int idt_cpu_freq;
+
 static struct resource korina_dev0_res[] =3D {
 	{
 		.name =3D "korina_regs",
@@ -214,12 +217,32 @@ static struct platform_device rb532_wdt =3D {
 	.num_resources	=3D ARRAY_SIZE(rb532_wdt_res),
 };
=20
+static struct plat_serial8250_port rb532_uart_res[] =3D {
+	{
+		.membase	=3D (char *)KSEG1ADDR(REGBASE + UART0BASE),
+		.irq		=3D UART0_IRQ,
+		.regshift	=3D 2,
+		.iotype		=3D UPIO_MEM,
+		.flags		=3D UPF_BOOT_AUTOCONF,
+	},
+	{
+		.flags		=3D 0,
+	}
+};
+
+static struct platform_device rb532_uart =3D {
+	.name              =3D "serial8250",
+	.id                =3D PLAT8250_DEV_PLATFORM,
+	.dev.platform_data =3D &rb532_uart_res,
+};
+
 static struct platform_device *rb532_devs[] =3D {
 	&korina_dev0,
 	&nand_slot0,
 	&cf_slot0,
 	&rb532_led,
 	&rb532_button,
+	&rb532_uart,
 	&rb532_wdt
 };
=20
@@ -294,6 +317,9 @@ static int __init plat_setup_devices(void)
 	/* Initialise the NAND device */
 	rb532_nand_setup();
=20
+	/* set the uart clock to the current cpu frequency */
+	rb532_uart_res[0].uartclk =3D idt_cpu_freq;
+
 	return platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs));
 }
=20
diff --git a/arch/mips/rb532/serial.c b/arch/mips/rb532/serial.c
index 3e0d7ec..00ed19f 100644
--- a/arch/mips/rb532/serial.c
+++ b/arch/mips/rb532/serial.c
@@ -36,7 +36,7 @@
 extern unsigned int idt_cpu_freq;
=20
 static struct uart_port rb532_uart =3D {
-	.type =3D PORT_16550A,
+	.flags =3D UPF_BOOT_AUTOCONF,
 	.line =3D 0,
 	.irq =3D UART0_IRQ,
 	.iotype =3D UPIO_MEM,
--=20
1.5.6.4


