diff options
author | Franck Jullien <franck.jullien@gmail.com> | 2011-06-06 22:20:31 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-06-10 09:32:27 +0200 |
commit | 9d64e1f21d46722ccbdde5dbc87ad8908f2e32b6 (patch) | |
tree | 565511dfd52b2d83d3dfd4e5f87123cf3be60000 /drivers/serial/serial_altera_jtag.c | |
parent | cbf46b2dad492d24280b3a7ce4f5bcad16b06e10 (diff) | |
download | barebox-9d64e1f21d46722ccbdde5dbc87ad8908f2e32b6.tar.gz barebox-9d64e1f21d46722ccbdde5dbc87ad8908f2e32b6.tar.xz |
Add Altera JTAG UART driver
Add Altera JTAG UART driver
I removed the CONFIG_ALTERA_JTAG_UART_BYPASS.
Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/serial/serial_altera_jtag.c')
-rw-r--r-- | drivers/serial/serial_altera_jtag.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/drivers/serial/serial_altera_jtag.c b/drivers/serial/serial_altera_jtag.c new file mode 100644 index 0000000000..322f9e9324 --- /dev/null +++ b/drivers/serial/serial_altera_jtag.c @@ -0,0 +1,101 @@ +/* + * (C) Copyright 2004, Psyent Corporation <www.psyent.com> + * Scott McNutt <smcnutt@psyent.com> + * + * (C) Copyright 2011 - Franck JULLIEN <elec4fun@gmail.com> + * + * 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 <driver.h> +#include <init.h> +#include <malloc.h> +#include <asm/io.h> +#include <asm/nios2-io.h> + +static int altera_serial_jtag_setbaudrate(struct console_device *cdev, int baudrate) +{ + return 0; +} + +static void altera_serial_jtag_putc(struct console_device *cdev, char c) +{ + struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base; + uint32_t st; + + while (1) { + st = readl(&jtag->control); + if (NIOS_JTAG_WSPACE(st)) + break; + } + + writel(c, &jtag->data); +} + +static int altera_serial_jtag_tstc(struct console_device *cdev) +{ + struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base; + + return readl(&jtag->control) & NIOS_JTAG_RRDY; +} + +static int altera_serial_jtag_getc(struct console_device *cdev) +{ + struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base; + uint32_t val; + + while (1) { + val = readl(&jtag->data); + if (val & NIOS_JTAG_RVALID) + break; + } + + return val & 0xFF; +} + +static int altera_serial_jtag_probe(struct device_d *dev) { + + struct console_device *cdev; + + cdev = malloc(sizeof(struct console_device)); + dev->type_data = cdev; + cdev->dev = dev; + cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR; + cdev->tstc = altera_serial_jtag_tstc; + cdev->putc = altera_serial_jtag_putc; + cdev->getc = altera_serial_jtag_getc; + cdev->setbrg = altera_serial_jtag_setbaudrate; + + console_register(cdev); + + return 0; +} + +static struct driver_d altera_serial_jtag_driver = { + .name = "altera_serial_jtag", + .probe = altera_serial_jtag_probe, +}; + +static int altera_serial_jtag_init(void) +{ + return register_driver(&altera_serial_jtag_driver); +} + +console_initcall(altera_serial_jtag_init); |