2 * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3 * Scott McNutt <smcnutt@psyent.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <linux/compiler.h>
31 DECLARE_GLOBAL_DATA_PTR
;
33 /*------------------------------------------------------------------
34 * JTAG acts as the serial port
35 *-----------------------------------------------------------------*/
36 static nios_jtag_t
*jtag
= (nios_jtag_t
*)CONFIG_SYS_NIOS_CONSOLE
;
38 static void altera_jtag_serial_setbrg(void)
42 static int altera_jtag_serial_init(void)
47 static void altera_jtag_serial_putc(char c
)
50 unsigned st
= readl(&jtag
->control
);
51 if (NIOS_JTAG_WSPACE(st
))
53 #ifdef CONFIG_ALTERA_JTAG_UART_BYPASS
54 if (!(st
& NIOS_JTAG_AC
)) /* no connection */
59 writel ((unsigned char)c
, &jtag
->data
);
62 static int altera_jtag_serial_tstc(void)
64 return ( readl (&jtag
->control
) & NIOS_JTAG_RRDY
);
67 static int altera_jtag_serial_getc(void)
74 val
= readl (&jtag
->data
);
75 if (val
& NIOS_JTAG_RVALID
)
82 static struct serial_device altera_jtag_serial_drv
= {
83 .name
= "altera_jtag_uart",
84 .start
= altera_jtag_serial_init
,
86 .setbrg
= altera_jtag_serial_setbrg
,
87 .putc
= altera_jtag_serial_putc
,
88 .puts
= default_serial_puts
,
89 .getc
= altera_jtag_serial_getc
,
90 .tstc
= altera_jtag_serial_tstc
,
93 void altera_jtag_serial_initialize(void)
95 serial_register(&altera_jtag_serial_drv
);
98 __weak
struct serial_device
*default_serial_console(void)
100 return &altera_jtag_serial_drv
;