[PATCH 6/9] clean-serial-c-into-drivers.patch

Andy Green andy at openmoko.com
Tue Aug 19 16:56:32 CEST 2008


Move serial.c into drivers/serial-s3c24xx.c and qi-serial.h into include/serial-s3c24xx.h
making things a bit cleaner for being s3c24xx-specific.  This needed a lot of meddling
additionally, ending up with a new puts() callback that belongs in the board structure
and removal of the debug uart member, since the puts() action was the only user.

Also change serial init API name and function to only fix to 115kbps and adapt to
PCLK.

Signed-off-by: Andy Green <andy at openmoko.com>
---

 include/ports-s3c24xx.h           |   41 ++++++++++++++
 include/qi-serial.h               |  111 -------------------------------------
 include/qi.h                      |    3 -
 include/serial-s3c24xx.h          |   72 ++++++++++++++++++++++++
 src/drivers/i2c-bitbang-s3c24xx.c |    1 
 src/drivers/serial-s3c24xx.c      |   77 ++++++++++++++++++++++++++
 src/gta02/gta02.c                 |   15 ++++-
 src/gta03/gta03.c                 |   19 ++++++
 src/nand_read.c                   |   20 +------
 src/qi.lds                        |   12 ++--
 src/serial.c                      |   76 -------------------------
 src/utils.c                       |   14 ++---
 12 files changed, 236 insertions(+), 225 deletions(-)
 create mode 100644 include/ports-s3c24xx.h
 delete mode 100644 include/qi-serial.h
 create mode 100644 include/serial-s3c24xx.h
 create mode 100644 src/drivers/serial-s3c24xx.c
 delete mode 100644 src/serial.c

diff --git a/include/ports-s3c24xx.h b/include/ports-s3c24xx.h
new file mode 100644
index 0000000..e784d85
--- /dev/null
+++ b/include/ports-s3c24xx.h
@@ -0,0 +1,41 @@
+#ifndef __PORTS_S3C24XX_H__
+#define __PORTS_S3C24XX_H__
+
+
+// I/O PORT
+#define rGPACON			(*(volatile unsigned *)0x56000000)
+#define rGPADAT			(*(volatile unsigned *)0x56000004)
+
+#define rGPBCON			(*(volatile unsigned *)0x56000010)
+#define rGPBDAT			(*(volatile unsigned *)0x56000014)
+#define rGPBUP			(*(volatile unsigned *)0x56000018)
+
+#define rGPCCON			(*(volatile unsigned *)0x56000020)
+#define rGPCDAT			(*(volatile unsigned *)0x56000024)
+#define rGPCUP			(*(volatile unsigned *)0x56000028)
+
+#define rGPDCON			(*(volatile unsigned *)0x56000030)
+#define rGPDDAT			(*(volatile unsigned *)0x56000034)
+#define rGPDUP			(*(volatile unsigned *)0x56000038)
+
+#define rGPECON			(*(volatile unsigned *)0x56000040)
+#define rGPEDAT			(*(volatile unsigned *)0x56000044)
+#define rGPEUP			(*(volatile unsigned *)0x56000048)
+
+#define rGPFCON			(*(volatile unsigned *)0x56000050)
+#define rGPFDAT			(*(volatile unsigned *)0x56000054)
+#define rGPFUP			(*(volatile unsigned *)0x56000058)
+
+#define rGPGCON			(*(volatile unsigned *)0x56000060)
+#define rGPGDAT			(*(volatile unsigned *)0x56000064)
+#define rGPGUP			(*(volatile unsigned *)0x56000068)
+
+#define rGPHCON			(*(volatile unsigned *)0x56000070)
+#define rGPHDAT			(*(volatile unsigned *)0x56000074)
+#define rGPHUP			(*(volatile unsigned *)0x56000078)
+
+#define rGPJCON    			(*(volatile unsigned *)0x560000d0)	//Port J control
+#define rGPJDAT   			(*(volatile unsigned *)0x560000d4)	//Port J data
+#define rGPJUP			(*(volatile unsigned *)0x560000d8)	//Port J data
+
+#endif
diff --git a/include/qi-serial.h b/include/qi-serial.h
deleted file mode 100644
index d674178..0000000
--- a/include/qi-serial.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * (C) Copyright 2007 OpenMoko, Inc.
- * Author: xiangfu liu <xiangfu at openmoko.org>
- *
- * Configuation settings for the FIC Neo GTA02 Linux GSM phone
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-
-#ifndef __SERIAL_H__
-#define __SERIAL_H__
-
-#define UART0	    0
-#define UART1	    1
-#define UART2	    2
-
-#define rGPHCON     (*(volatile unsigned *)0x56000070)	/*UART 0 Line control*/
-
-#define rULCON0     (*(volatile unsigned *)0x50000000)	/*UART 0 Line control*/
-#define rUCON0      (*(volatile unsigned *)0x50000004)	/*UART 0 Control*/
-#define rUFCON0     (*(volatile unsigned *)0x50000008)	/*UART 0 FIFO control*/
-#define rUMCON0     (*(volatile unsigned *)0x5000000c)	/*UART 0 Modem control*/
-#define rUTRSTAT0   (*(volatile unsigned *)0x50000010)	/*UART 0 Tx/Rx status*/
-#define rUERSTAT0   (*(volatile unsigned *)0x50000014)	/*UART 0 Rx error status*/
-#define rUFSTAT0    (*(volatile unsigned *)0x50000018)	/*UART 0 FIFO status*/
-#define rUMSTAT0    (*(volatile unsigned *)0x5000001c)	/*UART 0 Modem status*/
-#define rUBRDIV0    (*(volatile unsigned *)0x50000028)	/*UART 0 Baud rate divisor*/
-
-#define rULCON1     (*(volatile unsigned *)0x50004000)	/*UART 1 Line control*/
-#define rUCON1      (*(volatile unsigned *)0x50004004)	/*UART 1 Control*/
-#define rUFCON1     (*(volatile unsigned *)0x50004008)	/*UART 1 FIFO control*/
-#define rUMCON1     (*(volatile unsigned *)0x5000400c)	/*UART 1 Modem control*/
-#define rUTRSTAT1   (*(volatile unsigned *)0x50004010)	/*UART 1 Tx/Rx status*/
-#define rUERSTAT1   (*(volatile unsigned *)0x50004014)	/*UART 1 Rx error status*/
-#define rUFSTAT1    (*(volatile unsigned *)0x50004018)	/*UART 1 FIFO status*/
-#define rUMSTAT1    (*(volatile unsigned *)0x5000401c)	/*UART 1 Modem status*/
-#define rUBRDIV1    (*(volatile unsigned *)0x50004028)	/*UART 1 Baud rate divisor*/
-
-#define rULCON2     (*(volatile unsigned *)0x50008000)	/*UART 2 Line control*/
-#define rUCON2      (*(volatile unsigned *)0x50008004)	/*UART 2 Control*/
-#define rUFCON2     (*(volatile unsigned *)0x50008008)	/*UART 2 FIFO control*/
-#define rUTRSTAT2   (*(volatile unsigned *)0x50008010)	/*UART 2 Tx/Rx status*/
-#define rUERSTAT2   (*(volatile unsigned *)0x50008014)	/*UART 2 Rx error status*/
-#define rUFSTAT2    (*(volatile unsigned *)0x50008018)	/*UART 2 FIFO status*/
-#define rUBRDIV2    (*(volatile unsigned *)0x50008028)	/*UART 2 Baud rate divisor*/
-
-#define WrUTXH0(ch) (*(volatile unsigned char *)0x50000020)=(unsigned char)(ch)
-#define RdURXH0()   (*(volatile unsigned char *)0x50000024)
-#define WrUTXH1(ch) (*(volatile unsigned char *)0x50004020)=(unsigned char)(ch)
-#define RdURXH1()   (*(volatile unsigned char *)0x50004024)
-#define WrUTXH2(ch) (*(volatile unsigned char *)0x50008020)=(unsigned char)(ch)
-#define RdURXH2()   (*(volatile unsigned char *)0x50008024)
-
-
-
-// I/O PORT 
-#define rGPACON			(*(volatile unsigned *)0x56000000)
-#define rGPADAT			(*(volatile unsigned *)0x56000004)
-
-#define rGPBCON			(*(volatile unsigned *)0x56000010)
-#define rGPBDAT			(*(volatile unsigned *)0x56000014)
-#define rGPBUP			(*(volatile unsigned *)0x56000018)
-
-#define rGPCCON			(*(volatile unsigned *)0x56000020)
-#define rGPCDAT			(*(volatile unsigned *)0x56000024)
-#define rGPCUP			(*(volatile unsigned *)0x56000028)
-
-#define rGPDCON			(*(volatile unsigned *)0x56000030)
-#define rGPDDAT			(*(volatile unsigned *)0x56000034)
-#define rGPDUP			(*(volatile unsigned *)0x56000038)
-
-#define rGPECON			(*(volatile unsigned *)0x56000040)
-#define rGPEDAT			(*(volatile unsigned *)0x56000044)
-#define rGPEUP			(*(volatile unsigned *)0x56000048)
-
-#define rGPFCON			(*(volatile unsigned *)0x56000050)
-#define rGPFDAT			(*(volatile unsigned *)0x56000054)
-#define rGPFUP			(*(volatile unsigned *)0x56000058)
-
-#define rGPGCON			(*(volatile unsigned *)0x56000060)
-#define rGPGDAT			(*(volatile unsigned *)0x56000064)
-#define rGPGUP			(*(volatile unsigned *)0x56000068)
-
-#define rGPHCON			(*(volatile unsigned *)0x56000070)
-#define rGPHDAT			(*(volatile unsigned *)0x56000074)
-#define rGPHUP			(*(volatile unsigned *)0x56000078)
-
-#define rGPJCON    			(*(volatile unsigned *)0x560000d0)	//Port J control
-#define rGPJDAT   			(*(volatile unsigned *)0x560000d4)	//Port J data
-#define rGPJUP			(*(volatile unsigned *)0x560000d8)	//Port J data
-
-void serial_init(const int uart, const int ubrdiv_val);
-void serial_putc(const int uart, const char c);
-int printk(const char *fmt, ...);
-int puts(const char *string);
-
-#endif
diff --git a/include/qi.h b/include/qi.h
index c4094d0..b168ae7 100644
--- a/include/qi.h
+++ b/include/qi.h
@@ -22,7 +22,6 @@
 #define __QI_H__
 
 #include <stdarg.h>
-#include <qi-serial.h>
 #include <qi-ctype.h>
 
 #define u32 unsigned int
@@ -62,7 +61,6 @@ struct board_variant {
 
 struct board_api {
 	const char * name;
-	int debug_serial_port;
 	int linux_machine_id;
 	unsigned long linux_mem_start;
 	unsigned long linux_mem_size;
@@ -70,6 +68,7 @@ struct board_api {
 	const struct board_variant const * (*get_board_variant)(void);
 	int (*is_this_board)(void);
 	void (*port_init)(void);
+	void (*putc)(char);
 	struct kernel_source kernel_source[8];
 };
 
diff --git a/include/serial-s3c24xx.h b/include/serial-s3c24xx.h
new file mode 100644
index 0000000..6209401
--- /dev/null
+++ b/include/serial-s3c24xx.h
@@ -0,0 +1,72 @@
+/*
+ * (C) Copyright 2007 OpenMoko, Inc.
+ * Author: xiangfu liu <xiangfu at openmoko.org>
+ *
+ * Configuation settings for the FIC Neo GTA02 Linux GSM phone
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#ifndef __SERIAL_S3C24XX_H__
+#define __SERIAL_S3C24XX_H__
+
+#define UART0	    0
+#define UART1	    1
+#define UART2	    2
+
+#define rGPHCON     (*(volatile unsigned *)0x56000070)	/*UART 0 Line control*/
+
+#define rULCON0     (*(volatile unsigned *)0x50000000)	/*UART 0 Line control*/
+#define rUCON0      (*(volatile unsigned *)0x50000004)	/*UART 0 Control*/
+#define rUFCON0     (*(volatile unsigned *)0x50000008)	/*UART 0 FIFO control*/
+#define rUMCON0     (*(volatile unsigned *)0x5000000c)	/*UART 0 Modem control*/
+#define rUTRSTAT0   (*(volatile unsigned *)0x50000010)	/*UART 0 Tx/Rx status*/
+#define rUERSTAT0   (*(volatile unsigned *)0x50000014)	/*UART 0 Rx error status*/
+#define rUFSTAT0    (*(volatile unsigned *)0x50000018)	/*UART 0 FIFO status*/
+#define rUMSTAT0    (*(volatile unsigned *)0x5000001c)	/*UART 0 Modem status*/
+#define rUBRDIV0    (*(volatile unsigned *)0x50000028)	/*UART 0 Baud rate divisor*/
+
+#define rULCON1     (*(volatile unsigned *)0x50004000)	/*UART 1 Line control*/
+#define rUCON1      (*(volatile unsigned *)0x50004004)	/*UART 1 Control*/
+#define rUFCON1     (*(volatile unsigned *)0x50004008)	/*UART 1 FIFO control*/
+#define rUMCON1     (*(volatile unsigned *)0x5000400c)	/*UART 1 Modem control*/
+#define rUTRSTAT1   (*(volatile unsigned *)0x50004010)	/*UART 1 Tx/Rx status*/
+#define rUERSTAT1   (*(volatile unsigned *)0x50004014)	/*UART 1 Rx error status*/
+#define rUFSTAT1    (*(volatile unsigned *)0x50004018)	/*UART 1 FIFO status*/
+#define rUMSTAT1    (*(volatile unsigned *)0x5000401c)	/*UART 1 Modem status*/
+#define rUBRDIV1    (*(volatile unsigned *)0x50004028)	/*UART 1 Baud rate divisor*/
+
+#define rULCON2     (*(volatile unsigned *)0x50008000)	/*UART 2 Line control*/
+#define rUCON2      (*(volatile unsigned *)0x50008004)	/*UART 2 Control*/
+#define rUFCON2     (*(volatile unsigned *)0x50008008)	/*UART 2 FIFO control*/
+#define rUTRSTAT2   (*(volatile unsigned *)0x50008010)	/*UART 2 Tx/Rx status*/
+#define rUERSTAT2   (*(volatile unsigned *)0x50008014)	/*UART 2 Rx error status*/
+#define rUFSTAT2    (*(volatile unsigned *)0x50008018)	/*UART 2 FIFO status*/
+#define rUBRDIV2    (*(volatile unsigned *)0x50008028)	/*UART 2 Baud rate divisor*/
+
+#define WrUTXH0(ch) (*(volatile unsigned char *)0x50000020)=(unsigned char)(ch)
+#define RdURXH0()   (*(volatile unsigned char *)0x50000024)
+#define WrUTXH1(ch) (*(volatile unsigned char *)0x50004020)=(unsigned char)(ch)
+#define RdURXH1()   (*(volatile unsigned char *)0x50004024)
+#define WrUTXH2(ch) (*(volatile unsigned char *)0x50008020)=(unsigned char)(ch)
+#define RdURXH2()   (*(volatile unsigned char *)0x50008024)
+
+extern void serial_init_115200_s3c24xx(const int uart, const int pclk_MHz);
+extern void serial_putc_s3c24xx(const int uart, const char c);
+extern int puts(const char *string);
+
+#endif
diff --git a/src/drivers/i2c-bitbang-s3c24xx.c b/src/drivers/i2c-bitbang-s3c24xx.c
index 353dedc..f71dfc4 100644
--- a/src/drivers/i2c-bitbang-s3c24xx.c
+++ b/src/drivers/i2c-bitbang-s3c24xx.c
@@ -23,6 +23,7 @@
 
 #include <qi.h>
 #include <i2c-bitbang.h>
+#include <ports-s3c24xx.h>
 
 static char i2c_read_sda_s3c24xx(void)
 {
diff --git a/src/drivers/serial-s3c24xx.c b/src/drivers/serial-s3c24xx.c
new file mode 100644
index 0000000..206f0a1
--- /dev/null
+++ b/src/drivers/serial-s3c24xx.c
@@ -0,0 +1,77 @@
+/*
+ * (C) Copyright 2007 OpenMoko, Inc.
+ * Author: xiangfu liu <xiangfu at openmoko.org>
+ *
+ * Configuation settings for the FIC Neo GTA02 Linux GSM phone
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <qi.h>
+#include <serial-s3c24xx.h>
+
+void serial_init_115200_s3c24xx(const int uart, const int pclk_MHz)
+{
+	int div = (((54 * pclk_MHz) + (pclk_MHz / 2)) / 100) -1;
+	switch(uart)
+	{
+	case UART0:
+		rULCON0 = 0x3;
+		rUCON0 = 0x245;
+		rUFCON0 = 0x0;
+		rUMCON0 = 0x0;
+		rUBRDIV0 = div;
+		break;
+	case UART1:
+		rULCON1 = 0x3;
+		rUCON1 = 0x245;
+		rUFCON1 = 0x0;
+		rUMCON1 = 0x0;
+		rUBRDIV1 = div;
+		break;
+	case UART2:
+		rULCON2 = 0x3;
+		rUCON2 = 0x245;
+		rUFCON2 = 0x1;
+		rUBRDIV2 = div;
+		break;
+	default:
+		break;
+	}
+}
+/*
+ * Output a single byte to the serial port.
+ */
+void serial_putc_s3c24xx(const int uart, const char c)
+{
+	switch(uart)
+	{
+	case UART0:
+		while ( !( rUTRSTAT0 & 0x2 ) );
+		WrUTXH0(c);
+		break;
+	case UART1:
+		while ( !( rUTRSTAT1 & 0x2 ) );
+		WrUTXH1(c);
+		break;
+	case UART2:
+		while ( !( rUTRSTAT2 & 0x2 ) );
+		WrUTXH2(c);
+		break;
+	default:
+		break;
+	}
+}
diff --git a/src/gta02/gta02.c b/src/gta02/gta02.c
index 17c7338..6a2516d 100644
--- a/src/gta02/gta02.c
+++ b/src/gta02/gta02.c
@@ -25,8 +25,12 @@
 
 #include <qi.h>
 #include <neo_gta02.h>
+#include <serial-s3c24xx.h>
+#include <ports-s3c24xx.h>
 #include <i2c-bitbang-s3c24xx.h>
 
+#define GTA02_DEBUG_UART 2
+
 #define PCF50633_I2C_ADS 0x73
 
 static const struct board_variant board_variants[] = {
@@ -180,11 +184,11 @@ void port_init_gta02(void)
 		"nop\n"\
 		"nop\n"\
 		"nop\n"\
- );
+	);
 	/* configure MPLL */
 	*MPLLCON = ((42 << 12) + (1 << 4) + 0);
 
-	serial_init(UART2, (((54 * 50) + 50) / 100) -1);
+	serial_init_115200_s3c24xx(GTA02_DEBUG_UART, 50 /* 50MHz PCLK */);
 }
 
 /**
@@ -254,13 +258,17 @@ const struct board_variant const * get_board_variant_gta02(void)
 	return &board_variants[gta02_get_pcb_revision()];
 }
 
+static void putc_gta02(char c)
+{
+	serial_putc_s3c24xx(GTA02_DEBUG_UART, c);
+}
+
 /*
  * our API for bootloader on this machine
  */
 
 const struct board_api board_api_gta02 = {
 	.name = "Freerunner / GTA02",
-	.debug_serial_port = 2,
 	.linux_machine_id = 1304,
 	.linux_mem_start = 0x30000000,
 	.linux_mem_size = (128 * 1024 * 1024),
@@ -268,6 +276,7 @@ const struct board_api board_api_gta02 = {
 	.get_board_variant = get_board_variant_gta02,
 	.is_this_board = is_this_board_gta02,
 	.port_init = port_init_gta02,
+	.putc = putc_gta02,
 	/* these are the ways we could boot GTA02 in order to try */
 	.kernel_source = {
 		[0] = {
diff --git a/src/gta03/gta03.c b/src/gta03/gta03.c
index 1a2c00b..1738856 100644
--- a/src/gta03/gta03.c
+++ b/src/gta03/gta03.c
@@ -1,5 +1,13 @@
 #include <qi.h>
 #include <neo_gta03.h>
+#include <serial-s3c24xx.h>
+#include <ports-s3c24xx.h>
+#include <i2c-bitbang-s3c24xx.h>
+
+#define GTA03_DEBUG_UART 2
+
+#define PCF50633_I2C_ADS 0x73
+
 
 static const struct board_variant board_variants[] = {
 	[0] = {
@@ -108,7 +116,7 @@ void port_init_gta03(void)
 	rGPJCON = 0x02AAAAAA;
 	rGPJUP = 0x1FFFF;
 
-	serial_init(UART2, 0x11);
+	serial_init_115200_s3c24xx(GTA03_DEBUG_UART, 33 /*MHz PCLK */);
 }
 
 /**
@@ -161,12 +169,18 @@ int is_this_board_gta03(void)
 	/* FIXME: find something gta03 specific */
 	return 1;
 }
+
+static void putc_gta03(char c)
+{
+	serial_putc_s3c24xx(GTA03_DEBUG_UART, c);
+}
+
+
 /*
  * our API for bootloader on this machine
  */
 const struct board_api board_api_gta03 = {
 	.name = "GTA03",
-	.debug_serial_port = 2,
 	.linux_machine_id = 1808,
 	.linux_mem_start = 0x30000000,
 	.linux_mem_size = (128 * 1024 * 1024),
@@ -174,6 +188,7 @@ const struct board_api board_api_gta03 = {
 	.get_board_variant = get_board_variant_gta03,
 	.is_this_board = is_this_board_gta03,
 	.port_init = port_init_gta03,
+	.putc = putc_gta03,
 	/* these are the ways we could boot GTA03 in order to try */
 	.kernel_source = {
 		[0] = {
diff --git a/src/nand_read.c b/src/nand_read.c
index 6351173..94bf839 100644
--- a/src/nand_read.c
+++ b/src/nand_read.c
@@ -71,13 +71,6 @@ static int is_bad_block(unsigned long i)
 	NFCMD = NAND_CMD_READSTART;
 	nand_wait();
 	data = (NFDATA & 0xff);
-#ifdef DEBUG
-	serial_putc(2, '$');
-	serial_putc(2, '0');
-	serial_putc(2, 'x');
-	print32((unsigned int)data);
-	serial_putc(2, ' ');
-#endif
 
 	if (data != 0xff)
 		return 1;
@@ -138,20 +131,11 @@ int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)
 		if ((i & (NAND_BLOCK_SIZE - 1)) == 0) {
 			if (is_bad_block(i) ||
 					is_bad_block(i + NAND_PAGE_SIZE)) {
-				serial_putc(2, '!');
-				serial_putc(2, '0');
-				serial_putc(2, 'x');
-				print32((unsigned int)i);
-				serial_putc(2, ' ');
-
 				i += NAND_BLOCK_SIZE;
 				size += NAND_BLOCK_SIZE;
-				if (bad_count++ == 4) {
-					serial_putc(2, '+');
-					serial_putc(2, '\n');
+				if (bad_count++ == 4)
 					return -1;
-				}
-				serial_putc(2, '\n');
+
 				continue;
 			}
 		}
diff --git a/src/qi.lds b/src/qi.lds
index 29ec63f..bdc1d2c 100644
--- a/src/qi.lds
+++ b/src/qi.lds
@@ -37,12 +37,12 @@ SECTIONS
 	. = ALIGN(4);
 	.text      :
 	{
-	  src/start.o		(.text .rodata* .data)
-	  src/lowlevel_init.o	(.text .rodata* .data)
-	  src/start_qi.o	(.text .rodata* .data)
-	  src/blink_led.o	(.text .rodata* .data)
-	  src/nand_read.o	(.text .rodata* .data)
-	  src/serial.o		(.text .rodata* .data)
+	  src/start.o			(.text .rodata* .data)
+	  src/lowlevel_init.o		(.text .rodata* .data)
+	  src/start_qi.o		(.text .rodata* .data)
+	  src/blink_led.o		(.text .rodata* .data)
+	  src/nand_read.o		(.text .rodata* .data)
+	  src/drivers/serial-s3c24xx.o	(.text .rodata* .data)
 	}
 
 	. = ALIGN(4);
diff --git a/src/serial.c b/src/serial.c
deleted file mode 100644
index 61b4762..0000000
--- a/src/serial.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * (C) Copyright 2007 OpenMoko, Inc.
- * Author: xiangfu liu <xiangfu at openmoko.org>
- *
- * Configuation settings for the FIC Neo GTA02 Linux GSM phone
- *
- * 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., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <qi.h>
-#include "blink_led.h"
-
-void serial_init (const int uart, const int ubrdiv_val)
-{
-	switch(uart)
-	{
-	case UART0:
-		rULCON0 = 0x3;
-		rUCON0 = 0x245;
-		rUFCON0 = 0x0;
-		rUMCON0 = 0x0;
-		rUBRDIV0 = ubrdiv_val;
-		break;
-	case UART1:
-		rULCON1 = 0x3;
-		rUCON1 = 0x245;
-		rUFCON1 = 0x0;
-		rUMCON1 = 0x0;
-		rUBRDIV1 = ubrdiv_val;
-		break;
-	case UART2:
-		rULCON2 = 0x3;
-		rUCON2 = 0x245;
-		rUFCON2 = 0x1;
-		rUBRDIV2 = ubrdiv_val;
-		break;
-	default:
-		break;
-	}
-}
-/*
- * Output a single byte to the serial port.
- */
-void serial_putc (const int uart, const char c)
-{
-	switch(uart)
-	{
-	case UART0:
-		while ( !( rUTRSTAT0 & 0x2 ) );
-		WrUTXH0(c);
-		break;
-	case UART1:
-		while ( !( rUTRSTAT1 & 0x2 ) );
-		WrUTXH1(c);
-		break;
-	case UART2:
-		while ( !( rUTRSTAT2 & 0x2 ) );
-		WrUTXH2(c);
-		break;
-	default:
-		break;
-	}
-}
diff --git a/src/utils.c b/src/utils.c
index ccc14b4..5c945a8 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -57,7 +57,7 @@ unsigned int _ntohl(unsigned int n) {
 int puts(const char *string)
 {
 	while (*string)
-		serial_putc(this_board->debug_serial_port, *string++);
+		this_board->putc(*string++);
 
 	return 1;
 }
@@ -66,9 +66,9 @@ int puts(const char *string)
 void printnybble(unsigned char n)
 {
 	if (n < 10)
-		serial_putc(this_board->debug_serial_port, '0' + n);
+		this_board->putc('0' + n);
 	else
-		serial_putc(this_board->debug_serial_port, 'a' + n - 10);
+		this_board->putc('a' + n - 10);
 }
 
 void printhex(unsigned char n)
@@ -91,13 +91,13 @@ void hexdump(unsigned char *start, int len)
 
 	while (len > 0) {
 		print32((int)start);
-		serial_putc(this_board->debug_serial_port, ':');
-		serial_putc(this_board->debug_serial_port, ' ');
+		this_board->putc(':');
+		this_board->putc(' ');
 		for (n = 0; n < 16; n++) {
 			printhex(*start++);
-			serial_putc(this_board->debug_serial_port, ' ');
+			this_board->putc(' ');
 		}
-		serial_putc(this_board->debug_serial_port, '\n');
+		this_board->putc('\n');
 		len -= 16;
 	}
 }




More information about the openmoko-kernel mailing list