Skip to contentSkip to conversation

Change x86 to use CONFIG_SERIAL_MULTI

RFC PATCH New Graeme Russ 1 participant 1 message Oct 23, 2009

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Change x86 to use CONFIG_SERIAL_MULTI

The fact that cpu/i386 has contained a serial driver has been a pet peeve of mine for some time. I was just going to move it into lib_i386, but decided that migrating to SERIAL_MULTI was probably the better option since there is already a 16550 driver which is SERIAL_MULTI compatible and my board has no less than five serial ports.

My only concern is that the 16550 driver is a memory-mapped driver, while the x86 arch uses port-mapping. I've hacked the driver to use port-mapping for x86 and it works fine.

Looking at the driver though, I think it should be using memory accessor functions (readb, writeb) to prevent gcc optimisations doing funny things as the writing of commands to the 16550 is very order dependent.

Should I instead define some macros that allow easy selection of inb/outb versus readb/writeb based on arch?

Regards,

Graeme

---
 board/eNET/eNET.c        |    3 +-
 common/serial.c          |    3 +-
 cpu/i386/Makefile        |    2 +-
 drivers/serial/ns16550.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++
 include/configs/eNET.h   |   25 +++++++++++++++++----
 include/serial.h         |    3 +-
 lib_i386/board.c         |    4 +++
 7 files changed, 83 insertions(+), 9 deletions(-)
board/eNET/eNET.c +2 -1
index baf7c95..03bca00 100644
@@ -111,8 +111,9 @@ int board_early_init_f(void)
 	sc520_mmcr->romcs1ctl = 0x0615;
 	sc520_mmcr->romcs2ctl = 0x0615;
 
-	sc520_mmcr->adddecctl = 0x02;
+	sc520_mmcr->adddecctl = 0x00;
 	sc520_mmcr->uart1ctl = 0x07;
+	sc520_mmcr->uart2ctl = 0x07;
 	sc520_mmcr->sysarbctl = 0x06;
 	sc520_mmcr->sysarbmenb = 0x0003;
 
common/serial.c +2 -1
index b4db46b..0c88416 100644
@@ -41,7 +41,8 @@ struct serial_device *__default_serial_console (void)
 #elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
    || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) \
    || defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC83xx) \
-   || defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
+   || defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) \
+   || defined(CONFIG_SYS_SC520)
 #if defined(CONFIG_CONS_INDEX) && defined(CONFIG_SYS_NS16550_SERIAL)
 #if (CONFIG_CONS_INDEX==1)
 	return &eserial1_device;
cpu/i386/Makefile +1 -1
index c658c6e..bb0a48f 100644
@@ -29,7 +29,7 @@ include $(TOPDIR)/config.mk
 LIB	= $(obj)lib$(CPU).a
 
 START	= start.o start16.o resetvec.o
-COBJS	= serial.o interrupts.o cpu.o
+COBJS	= interrupts.o cpu.o
 
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
drivers/serial/ns16550.c +52 -0

109 lines not on this page · raw message

include/configs/eNET.h +20 -5
index 6a68bf4..971840f 100644
@@ -21,6 +21,7 @@
  * MA 02111-1307 USA
  */
 
+#include <asm/ibmpc.h>
 /*
  * board/config.h - configuration options, board specific
  */
@@ -55,6 +56,25 @@
 #undef CONFIG_HW_WATCHDOG
 
  /*-----------------------------------------------------------------------
+  * Serial Configuration
+  */
+#define CONFIG_SERIAL_MULTI
+#undef CONFIG_SERIAL_SOFTWARE_FIFO
+#define CONFIG_CONS_INDEX		1
+#define CONFIG_SYS_NS16550
+#define CONFIG_SYS_NS16550_SERIAL
+#define CONFIG_SYS_NS16550_REG_SIZE	1
+#define CONFIG_SYS_NS16550_CLK		1843200
+#define CONFIG_BAUDRATE			9600
+#define CONFIG_SYS_BAUDRATE_TABLE	\
+	{300, 600, 1200, 2400, 4800, 9600, 19200, 38400,115200}
+
+#define CONFIG_SYS_NS16550_COM1		UART0_BASE
+#define CONFIG_SYS_NS16550_COM2		UART1_BASE
+#define CONFIG_SYS_NS16550_COM3		(0x1000 + UART0_BASE)
+#define CONFIG_SYS_NS16550_COM4		(0x1000 + UART1_BASE)
+
+ /*-----------------------------------------------------------------------
   * Video Configuration
   */
 #undef CONFIG_VIDEO			/* No Video Hardware */
@@ -65,8 +85,6 @@
  */
 #define CONFIG_SYS_MALLOC_LEN	(CONFIG_ENV_SIZE + 128*1024)
 
-#define CONFIG_BAUDRATE		9600
-
 /*-----------------------------------------------------------------------
  * Command line configuration.
  */
@@ -123,9 +141,6 @@
 
 #define	CONFIG_SYS_HZ			1024		/* incrementer freq: 1kHz */
 
-						/* valid baudrates */
-#define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200 }
-
 /*-----------------------------------------------------------------------
  * SDRAM Configuration
  */
include/serial.h +2 -1
index 821b583..daaa0c2 100644
@@ -25,7 +25,8 @@ extern struct serial_device * default_serial_console (void);
 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) || \
     defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_405EX) || \
     defined(CONFIG_MPC5xxx) || defined(CONFIG_MPC83xx) || \
-    defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
+    defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) || \
+    defined(CONFIG_SYS_SC520)
 extern struct serial_device serial0_device;
 extern struct serial_device serial1_device;
 #if defined(CONFIG_SYS_NS16550_SERIAL)
lib_i386/board.c +4 -0
index f3b6348..9becae5 100644
@@ -37,6 +37,7 @@
 #include <malloc.h>
 #include <net.h>
 #include <ide.h>
+#include <serial.h>
 #include <asm/u-boot-i386.h>
 #include <elf.h>
 
@@ -268,6 +269,9 @@ void board_init_r(gd_t *id, ulong ram_start)
 	}
 	show_boot_progress(0x23);
 
+#ifdef CONFIG_SERIAL_MULTI
+	serial_initialize();
+#endif
 	/* configure available FLASH banks */
 	size = flash_init();
 	display_flash_config(size);
Signature · 1 line
1.6.4.1.174.g32f4c