Hi Sascha,<br><br><div class="gmail_quote">2011/6/6 Sascha Hauer <span dir="ltr"><<a href="mailto:s.hauer@pengutronix.de">s.hauer@pengutronix.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Franck,<br>
<div class="im"><br>
On Sat, Jun 04, 2011 at 09:29:29PM +0200, <a href="mailto:franck.jullien@gmail.com">franck.jullien@gmail.com</a> wrote:<br>
> From: Franck Jullien <<a href="mailto:franck.jullien@gmail.com">franck.jullien@gmail.com</a>><br>
><br>
> Add ALtera JTAG UART driver.<br>
><br>
> Signed-off-by: Franck Jullien <<a href="mailto:franck.jullien@gmail.com">franck.jullien@gmail.com</a>><br>
> ---<br>
> drivers/serial/Kconfig | 10 +++<br>
> drivers/serial/Makefile | 1 +<br>
> drivers/serial/serial_altera_jtag.c | 106 +++++++++++++++++++++++++++++++++++<br>
> 3 files changed, 117 insertions(+), 0 deletions(-)<br>
> create mode 100644 drivers/serial/serial_altera_jtag.c<br>
><br>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig<br>
> index 9e05f4b..c8f9ecd 100644<br>
> --- a/drivers/serial/Kconfig<br>
> +++ b/drivers/serial/Kconfig<br>
> @@ -48,6 +48,16 @@ config DRIVER_SERIAL_ALTERA<br>
> default y<br>
> bool "Altera serial driver"<br>
><br>
> +config DRIVER_SERIAL_ALTERA_JTAG<br>
> + depends on NIOS2<br>
> + default n<br>
> + bool "Altera JTAG serial driver"<br>
> +<br>
> +config ALTERA_JTAG_UART_BYPASS<br>
> + depends on DRIVER_SERIAL_ALTERA_JTAG<br>
> + default y<br>
> + bool "Don't block on serial putc if JTAG is not connected"<br>
<br>
</div>Is there a reason to block on putc if JTAG is not connected? Without<br>
strong reasons I think this option should be removed.<br>
<br></blockquote><div><br></div><div>Well, there is not....I copied this from u-boot but I never used this feature.</div><div>You're right, I'll remove it.</div><div><br></div><div>Franck.</div><div><br></div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Sascha<br>
<div><div></div><div class="h5"><br>
> +<br>
> config DRIVER_SERIAL_NS16550<br>
> default n<br>
> bool "NS16550 serial driver"<br>
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile<br>
> index df9e705..8b56d15 100644<br>
> --- a/drivers/serial/Makefile<br>
> +++ b/drivers/serial/Makefile<br>
> @@ -17,3 +17,4 @@ obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial_ns16550.o<br>
> obj-$(CONFIG_DRIVER_SERIAL_PL010) += serial_pl010.o<br>
> obj-$(CONFIG_DRIVER_SERIAL_S3C24X0) += serial_s3c24x0.o<br>
> obj-$(CONFIG_DRIVER_SERIAL_ALTERA) += serial_altera.o<br>
> +obj-$(CONFIG_DRIVER_SERIAL_ALTERA_JTAG) += serial_altera_jtag.o<br>
> diff --git a/drivers/serial/serial_altera_jtag.c b/drivers/serial/serial_altera_jtag.c<br>
> new file mode 100644<br>
> index 0000000..70bc5a9<br>
> --- /dev/null<br>
> +++ b/drivers/serial/serial_altera_jtag.c<br>
> @@ -0,0 +1,106 @@<br>
> +/*<br>
> + * (C) Copyright 2004, Psyent Corporation <<a href="http://www.psyent.com" target="_blank">www.psyent.com</a>><br>
> + * Scott McNutt <<a href="mailto:smcnutt@psyent.com">smcnutt@psyent.com</a>><br>
> + *<br>
> + * (C) Copyright 2011 - Franck JULLIEN <<a href="mailto:elec4fun@gmail.com">elec4fun@gmail.com</a>><br>
> + *<br>
> + * See file CREDITS for list of people who contributed to this<br>
> + * project.<br>
> + *<br>
> + * This program is free software; you can redistribute it and/or<br>
> + * modify it under the terms of the GNU General Public License as<br>
> + * published by the Free Software Foundation; either version 2 of<br>
> + * the License, or (at your option) any later version.<br>
> + *<br>
> + * This program is distributed in the hope that it will be useful,<br>
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
> + * GNU General Public License for more details.<br>
> + *<br>
> + * You should have received a copy of the GNU General Public License<br>
> + * along with this program; if not, write to the Free Software<br>
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,<br>
> + * MA 02111-1307 USA<br>
> + */<br>
> +<br>
> +#include <common.h><br>
> +#include <driver.h><br>
> +#include <init.h><br>
> +#include <malloc.h><br>
> +#include <asm/io.h><br>
> +#include <asm/nios2-io.h><br>
> +<br>
> +static int altera_serial_jtag_setbaudrate(struct console_device *cdev, int baudrate)<br>
> +{<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static void altera_serial_jtag_putc(struct console_device *cdev, char c)<br>
> +{<br>
> + struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base;<br>
> + uint32_t st;<br>
> +<br>
> + while (1) {<br>
> + st = readl(&jtag->control);<br>
> + if (NIOS_JTAG_WSPACE(st))<br>
> + break;<br>
> +#ifdef CONFIG_ALTERA_JTAG_UART_BYPASS<br>
> + if (!(st & NIOS_JTAG_AC)) /* no connection */<br>
> + return;<br>
> +#endif<br>
> + }<br>
> +<br>
> + writel(c, &jtag->data);<br>
> +}<br>
> +<br>
> +static int altera_serial_jtag_tstc(struct console_device *cdev)<br>
> +{<br>
> + struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base;<br>
> +<br>
> + return readl(&jtag->control) & NIOS_JTAG_RRDY;<br>
> +}<br>
> +<br>
> +static int altera_serial_jtag_getc(struct console_device *cdev)<br>
> +{<br>
> + struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base;<br>
> + uint32_t val;<br>
> +<br>
> + while (1) {<br>
> + val = readl(&jtag->data);<br>
> + if (val & NIOS_JTAG_RVALID)<br>
> + break;<br>
> + }<br>
> +<br>
> + return val & 0xFF;<br>
> +}<br>
> +<br>
> +static int altera_serial_jtag_probe(struct device_d *dev) {<br>
> +<br>
> + struct console_device *cdev;<br>
> +<br>
> + cdev = malloc(sizeof(struct console_device));<br>
> + dev->type_data = cdev;<br>
> + cdev->dev = dev;<br>
> + cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;<br>
> + cdev->tstc = altera_serial_jtag_tstc;<br>
> + cdev->putc = altera_serial_jtag_putc;<br>
> + cdev->getc = altera_serial_jtag_getc;<br>
> + cdev->setbrg = altera_serial_jtag_setbaudrate;<br>
> +<br>
> + console_register(cdev);<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static struct driver_d altera_serial_jtag_driver = {<br>
> + .name = "altera_serial_jtag",<br>
> + .probe = altera_serial_jtag_probe,<br>
> +};<br>
> +<br>
> +static int altera_serial_jtag_init(void)<br>
> +{<br>
> + return register_driver(&altera_serial_jtag_driver);<br>
> +}<br>
> +<br>
> +console_initcall(altera_serial_jtag_init);<br>
> +<br>
> --<br>
> 1.7.0.4<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> barebox mailing list<br>
> <a href="mailto:barebox@lists.infradead.org">barebox@lists.infradead.org</a><br>
> <a href="http://lists.infradead.org/mailman/listinfo/barebox" target="_blank">http://lists.infradead.org/mailman/listinfo/barebox</a><br>
><br>
<font color="#888888"><br>
--<br>
Pengutronix e.K. | |<br>
Industrial Linux Solutions | <a href="http://www.pengutronix.de/" target="_blank">http://www.pengutronix.de/</a> |<br>
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |<br>
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |<br>
</font></blockquote></div><br>