From: Brian Cavagnolo Date: Tue, 1 Jun 2010 11:42:29 -0700 Subject: [U-Boot] [PATCH 2/3] add serial driver for pollux CPU In-Reply-To: <1275417750-10020-1-git-send-email-brian@cozybit.com> References: <1275417750-10020-1-git-send-email-brian@cozybit.com> Message-ID: <1275417750-10020-2-git-send-email-brian@cozybit.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Signed-off-by: Brian Cavagnolo Signed-off-by: Andrey Yurovsky --- drivers/serial/Makefile | 1 + drivers/serial/serial_pollux.c | 116 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 0 deletions(-) create mode 100644 drivers/serial/serial_pollux.c diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index c731bfb..87efd15 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -56,6 +56,7 @@ COBJS-$(CONFIG_S3C44B0_SERIAL) += serial_s3c44b0.o COBJS-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o COBJS-$(CONFIG_SCIF_CONSOLE) += serial_sh.o COBJS-$(CONFIG_USB_TTY) += usbtty.o +COBJS-$(CONFIG_POLLUX_SERIAL) += serial_pollux.o COBJS := $(sort $(COBJS-y)) SRCS := $(COBJS:.o=.c) diff --git a/drivers/serial/serial_pollux.c b/drivers/serial/serial_pollux.c new file mode 100644 index 0000000..62229dd --- /dev/null +++ b/drivers/serial/serial_pollux.c @@ -0,0 +1,116 @@ +/* (C) Copyright 2010 cozybit, Inc. + * Brian Cavagnolo + * + * (C) Copyright 2007 Leapfrog, Inc. + * Andrey Yurovsky" + * + * 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 +#include +#include + +#ifndef CONFIG_CONSOLE_UART_BASE +#error "Please define CONFIG_CONSOLE_UART_BASE to a suitable UARTx_BASE" +#endif +#define UART_BASE CONFIG_CONSOLE_UART_BASE + +DECLARE_GLOBAL_DATA_PTR; + +#define DEFAULT_BRD 1 +void serial_setbrg (void) +{ + int baudrate, brd; + + if ((baudrate = gd->baudrate) <= 0) + baudrate = CONFIG_BAUDRATE; + + /* we expect that the board-specific code set up the clock source such + * that a BRD of 1 corresponds to a baudrate of 115200 bps. We use + * this fact to calculate the BRD for any baudrate. We add one bit of + * precision to the division so we can round to the best BRD. + */ + brd = ((((115200 << 1)*(DEFAULT_BRD + 1)/baudrate) + 1) >> 1) - 1; + REG16(UART_BASE + BRD) = brd; +} + +int serial_init (void) +{ + /* expect that board-specific init has setup clock source */ + + /* disable UART clock */ + REG32(UART_BASE + UARTCLKENB) &= ~(1<