summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorwdenk <wdenk>2004-08-01 22:48:16 +0000
committerwdenk <wdenk>2004-08-01 22:48:16 +0000
commit281e00a3be453a169d854f824a460359d10f92bb (patch)
tree43dab398f1d6f601bb44df108427f7e0c611d68d /common
parentcfca5e604d5692f081cc1a9185ca5dc6dc77599d (diff)
downloadu-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.zip
u-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.tar.gz
u-boot-imx-281e00a3be453a169d854f824a460359d10f92bb.tar.bz2
* Code cleanup
* Patch by Sascha Hauer, 28 Jun: - add generic support for Motorola i.MX architecture - add support for mx1ads, mx1fs2 and scb9328 boards * Patches by Marc Leeman, 23 Jul 2004: - Add define for the PCI/Memory Buffer Configuration Register - corrected comments in cpu/mpc824x/cpu_init.c * Add support for multiple serial interfaces (for example to allow modem dial-in / dial-out)
Diffstat (limited to 'common')
-rw-r--r--common/Makefile2
-rw-r--r--common/cmd_bmp.c9
-rw-r--r--common/cmd_nvedit.c6
-rw-r--r--common/devices.c4
-rw-r--r--common/serial.c196
5 files changed, 212 insertions, 5 deletions
diff --git a/common/Makefile b/common/Makefile
index 4a36673..943da5e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -45,7 +45,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o \
env_nand.o env_dataflash.o env_flash.o env_eeprom.o env_nvram.o env_nowhere.o exports.o \
flash.o fpga.o \
hush.o kgdb.o lists.o lynxkdi.o memsize.o miiphybb.o miiphyutil.o \
- s_record.o soft_i2c.o soft_spi.o spartan2.o \
+ s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o \
usb.o usb_kbd.o usb_storage.o \
virtex2.o xilinx.o circbuf.o
diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c
index c1d4c0b..3a97133 100644
--- a/common/cmd_bmp.c
+++ b/common/cmd_bmp.c
@@ -123,14 +123,15 @@ static int bmp_info(ulong addr)
*/
static int bmp_display(ulong addr, int x, int y)
{
-#ifdef CONFIG_LCD
- extern int lcd_display_bitmap (ulong, int, int);
+#if defined(CONFIG_LCD)
+ extern int lcd_display_bitmap (ulong, int, int);
return (lcd_display_bitmap (addr, x, y));
-#endif
-#ifdef CONFIG_VIDEO
+#elif defined(CONFIG_VIDEO)
extern int video_display_bitmap (ulong, int, int);
return (video_display_bitmap (addr, x, y));
+#else
+# error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO
#endif
}
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index aaf6de9..3510561 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -43,6 +43,7 @@
#include <command.h>
#include <environment.h>
#include <watchdog.h>
+#include <serial.h>
#include <linux/stddef.h>
#include <asm/byteorder.h>
#if (CONFIG_COMMANDS & CFG_CMD_NET)
@@ -216,6 +217,11 @@ int _do_setenv (int flag, int argc, char *argv[])
/* Try assigning specified device */
if (console_assign (console, argv[2]) < 0)
return 1;
+
+#ifdef CONFIG_SERIAL_MULTI
+ if (serial_assign (argv[2]) < 0)
+ return 1;
+#endif
}
/*
diff --git a/common/devices.c b/common/devices.c
index 7c85952..b37c99a 100644
--- a/common/devices.c
+++ b/common/devices.c
@@ -26,6 +26,7 @@
#include <stdarg.h>
#include <malloc.h>
#include <devices.h>
+#include <serial.h>
#ifdef CONFIG_LOGBUFFER
#include <logbuff.h>
#endif
@@ -194,6 +195,9 @@ int devices_init (void)
drv_logbuff_init ();
#endif
drv_system_init ();
+#ifdef CONFIG_SERIAL_MULTI
+ serial_devices_init ();
+#endif
#ifdef CONFIG_USB_TTY
drv_usbtty_init ();
#endif
diff --git a/common/serial.c b/common/serial.c
new file mode 100644
index 0000000..f89bb0a
--- /dev/null
+++ b/common/serial.c
@@ -0,0 +1,196 @@
+/*
+ * (C) Copyright 2004
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 <common.h>
+#include <serial.h>
+#include <devices.h>
+
+#if defined(CONFIG_SERIAL_MULTI)
+
+static struct serial_device *serial_devices = NULL;
+static struct serial_device *serial_current = NULL;
+
+#ifndef CONFIG_LWMON
+struct serial_device * default_serial_console (void)
+{
+#if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2)
+ return &serial_smc_device;
+#elif defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) \
+ || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
+ return &serial_scc_device;
+#else
+#error No default console
+#endif
+}
+#endif
+
+static int serial_register(struct serial_device* dev)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+
+ dev->init += gd->reloc_off;
+ dev->setbrg += gd->reloc_off;
+ dev->getc += gd->reloc_off;
+ dev->tstc += gd->reloc_off;
+ dev->putc += gd->reloc_off;
+ dev->puts += gd->reloc_off;
+
+ dev->next = serial_devices;
+ serial_devices = dev;
+
+ return 0;
+}
+
+void serial_initialize(void)
+{
+#if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2)
+ serial_register(&serial_smc_device);
+#endif
+#if defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) \
+ || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
+ serial_register(&serial_scc_device);
+#endif
+
+ serial_assign(default_serial_console()->name);
+}
+
+void serial_devices_init(void)
+{
+ device_t dev;
+ struct serial_device *s = serial_devices;
+
+ while (s)
+ {
+ memset (&dev, 0, sizeof (dev));
+
+ strcpy (dev.name, s->name);
+ dev.flags = DEV_FLAGS_OUTPUT | DEV_FLAGS_INPUT;
+
+ dev.start = s->init;
+ dev.putc = s->putc;
+ dev.puts = s->puts;
+ dev.getc = s->getc;
+ dev.tstc = s->tstc;
+
+ device_register (&dev);
+
+ s = s->next;
+ }
+}
+
+int serial_assign(char * name)
+{
+ struct serial_device *s;
+
+ for (s = serial_devices; s; s = s->next)
+ {
+ if (strcmp(s->name, name) == 0)
+ {
+ serial_current = s;
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+void serial_reinit_all(void)
+{
+ struct serial_device *s;
+
+ for (s = serial_devices; s; s = s->next)
+ {
+ s->init();
+ }
+}
+
+int serial_init(void)
+{
+ if (!serial_current)
+ {
+ struct serial_device *dev = default_serial_console();
+ return dev->init();
+ }
+
+ return serial_current->init();
+}
+
+void serial_setbrg(void)
+{
+ if (!serial_current)
+ {
+ struct serial_device *dev = default_serial_console();
+ dev->setbrg();
+ return;
+ }
+
+ serial_current->setbrg();
+}
+
+int serial_getc(void)
+{
+ if (!serial_current)
+ {
+ struct serial_device *dev = default_serial_console();
+ return dev->getc();
+ }
+
+ return serial_current->getc();
+}
+
+int serial_tstc(void)
+{
+ if (!serial_current)
+ {
+ struct serial_device *dev = default_serial_console();
+ return dev->tstc();
+ }
+
+ return serial_current->tstc();
+}
+
+void serial_putc(const char c)
+{
+ if (!serial_current)
+ {
+ struct serial_device *dev = default_serial_console();
+ dev->putc(c);
+ return;
+ }
+
+ serial_current->putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ if (!serial_current)
+ {
+ struct serial_device *dev = default_serial_console();
+ dev->puts(s);
+ return;
+ }
+
+ serial_current->puts(s);
+}
+
+#endif /* CONFIG_SERIAL_MULTI */