diff options
author | Gabe Black <gabeblack@google.com> | 2011-06-08 20:46:13 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2011-08-29 10:39:24 -0700 |
commit | 84fc604a7a2ea412bd738f54731d6649c70f93ec (patch) | |
tree | 768dc150b1ae5edca87cb03fa8e44f7d898ae42a | |
parent | 01d1f9a370e1917b772023a2501acebc72ee6ab5 (diff) |
Add support for the OXPCIe 952 serial port.
Add support for the OXPCIe 952 serial port card.
BUG=chrome-os-partner:3895
TEST=Configured u-boot to use this serial card, built u-boot, built coreboot
with it as a payload, flashed to an Alex system with this card installed,
booted it and interacted with it over the serial connection.
Change-Id: I0f154c5faac3ae1f30d1a8489cc05e103bf4a3e6
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: http://gerrit.chromium.org/gerrit/2367
Reviewed-by: Gabe Black <gabeblack@chromium.org>
Tested-by: Gabe Black <gabeblack@chromium.org>
-rw-r--r-- | common/serial.c | 8 | ||||
-rw-r--r-- | drivers/serial/Makefile | 1 | ||||
-rw-r--r-- | drivers/serial/oxpcie952.c | 96 | ||||
-rw-r--r-- | drivers/serial/serial.c | 3 | ||||
-rw-r--r-- | include/serial.h | 17 |
5 files changed, 123 insertions, 2 deletions
diff --git a/common/serial.c b/common/serial.c index eb076a0c0ec..c5d9a384124 100644 --- a/common/serial.c +++ b/common/serial.c @@ -1,4 +1,5 @@ /* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. * (C) Copyright 2004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * @@ -47,7 +48,9 @@ struct serial_device *__default_serial_console (void) || defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) \ || defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) \ || defined(CONFIG_TEGRA2) || defined(CONFIG_SYS_COREBOOT) -#if defined(CONFIG_CONS_INDEX) && defined(CONFIG_SYS_NS16550_SERIAL) +#if defined(CONFIG_SYS_COREBOOT) && defined(CONFIG_SYS_OXPCIE952) + return &oxpcie952_device; +#elif defined(CONFIG_CONS_INDEX) && defined(CONFIG_SYS_NS16550_SERIAL) #if (CONFIG_CONS_INDEX==1) return &eserial1_device; #elif (CONFIG_CONS_INDEX==2) @@ -146,6 +149,9 @@ void serial_initialize (void) serial_register(&eserial4_device); #endif #endif /* CONFIG_SYS_NS16550_SERIAL */ +#if defined(CONFIG_SYS_OXPCIE952) + serial_register(&oxpcie952_device); +#endif #if defined (CONFIG_FFUART) serial_register(&serial_ffuart_device); #endif diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 6e96d7addcb..fba1cb6ab10 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -47,6 +47,7 @@ COBJS-$(CONFIG_LH7A40X_SERIAL) += serial_lh7a40x.o COBJS-$(CONFIG_MAX3100_SERIAL) += serial_max3100.o COBJS-$(CONFIG_MXC_UART) += serial_mxc.o COBJS-$(CONFIG_NETARM_SERIAL) += serial_netarm.o +COBJS-$(CONFIG_SYS_OXPCIE952) += oxpcie952.o COBJS-$(CONFIG_PL010_SERIAL) += serial_pl01x.o COBJS-$(CONFIG_PL011_SERIAL) += serial_pl01x.o COBJS-$(CONFIG_PXA_SERIAL) += serial_pxa.o diff --git a/drivers/serial/oxpcie952.c b/drivers/serial/oxpcie952.c new file mode 100644 index 00000000000..5f1d2842d3e --- /dev/null +++ b/drivers/serial/oxpcie952.c @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * + * 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 + * + * OXPCIe 952 support + */ + +#include <common.h> +#include <config.h> +#include <linux/types.h> +#include <serial.h> +#include <asm/io.h> +#include <ns16550.h> + +DECLARE_GLOBAL_DATA_PTR; + +static int OXPCIe952_init(void); +static int OXPCIe952_uninit(void); +static void OXPCIe952_setbrg(void); +static int OXPCIe952_getc(void); +static int OXPCIe952_tstc(void); +static void OXPCIe952_putc(const char c); +static void OXPCIe952_puts(const char *s); + +struct serial_device oxpcie952_device = { + "oxpcie952_0", + "OXUART0", + OXPCIe952_init, + OXPCIe952_uninit, + OXPCIe952_setbrg, + OXPCIe952_getc, + OXPCIe952_tstc, + OXPCIe952_putc, + OXPCIe952_puts, + NULL +}; + +static struct NS16550 *uart = (struct NS16550 *)(uintptr_t)(0xe0401000); + +static int OXPCIe952_init(void) +{ + return 0; +} + +static int OXPCIe952_uninit(void) +{ + return 0; +} + +static void OXPCIe952_setbrg(void) +{ +} + +static int OXPCIe952_havechar(void) +{ + return readb(&uart->lsr) & UART_LSR_DR; +} + +static int OXPCIe952_getc(void) +{ + while (!OXPCIe952_havechar()); + return (int)readb(&uart->rbr); +} + +static int OXPCIe952_tstc(void) +{ + return OXPCIe952_havechar(); +} + +static void OXPCIe952_putc(const char c) +{ + if (c == '\n') { + OXPCIe952_putc('\r'); + } + while ((readb(&uart->lsr) & UART_LSR_THRE) == 0); + writeb(c, &uart->rbr); +} + +static void OXPCIe952_puts(const char *s) +{ + while (*s) OXPCIe952_putc(*s++); +} diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 49b2591dbc5..3f0cf277100 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -1,4 +1,5 @@ /* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. * (C) Copyright 2000 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com. * @@ -35,6 +36,8 @@ #include <asm/arch/armada100.h> #elif defined(CONFIG_PANTHEON) #include <asm/arch/pantheon.h> +#elif defined(CONFIG_OXPCIE952) +#include <oxpcie952.h> #endif #if defined (CONFIG_SERIAL_MULTI) diff --git a/include/serial.h b/include/serial.h index 318cbdb8477..1d161980b96 100644 --- a/include/serial.h +++ b/include/serial.h @@ -28,7 +28,7 @@ extern struct serial_device * default_serial_console (void); defined(CONFIG_MB86R0x) || defined(CONFIG_MPC5xxx) || \ defined(CONFIG_MPC83xx) || defined(CONFIG_MPC85xx) || \ defined(CONFIG_MPC86xx) || defined(CONFIG_SYS_SC520) || \ - defined(CONFIG_TEGRA2) || defined(CONFIG_SYS_COREBOOT) + defined(CONFIG_TEGRA2) extern struct serial_device serial0_device; extern struct serial_device serial1_device; #if defined(CONFIG_SYS_NS16550_SERIAL) @@ -40,6 +40,21 @@ extern struct serial_device eserial4_device; #endif +#if defined(CONFIG_SYS_COREBOOT) +#if defined(CONFIG_SYS_NS16550_SERIAL) +extern struct serial_device serial0_device; +#endif +#if defined(CONFIG_SERIAL_MULTI) +extern struct serial_device eserial1_device; +extern struct serial_device eserial2_device; +extern struct serial_device eserial3_device; +extern struct serial_device eserial4_device; +#endif +#if defined(CONFIG_SYS_OXPCIE952) +extern struct serial_device oxpcie952_device; +#endif +#endif + #if defined(CONFIG_MPC512X) extern struct serial_device serial1_device; extern struct serial_device serial3_device; |