]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - arch/ppc/syslib/mv64x60_dbg.c
fa5b2e45e0ca54cc52b6a748ca67e6efaac0c105
[linux-3.10.git] / arch / ppc / syslib / mv64x60_dbg.c
1 /*
2  * arch/ppc/syslib/mv64x60_dbg.c
3  *
4  * KGDB and progress routines for the Marvell/Galileo MV64x60 (Discovery).
5  *
6  * Author: Mark A. Greer <mgreer@mvista.com>
7  *
8  * 2003 (c) MontaVista Software, Inc.  This file is licensed under
9  * the terms of the GNU General Public License version 2.  This program
10  * is licensed "as is" without any warranty of any kind, whether express
11  * or implied.
12  */
13
14 /*
15  *****************************************************************************
16  *
17  *      Low-level MPSC/UART I/O routines
18  *
19  *****************************************************************************
20  */
21
22
23 #include <linux/config.h>
24 #include <linux/irq.h>
25 #include <asm/delay.h>
26 #include <asm/mv64x60.h>
27 #include <asm/machdep.h>
28
29
30 #if defined(CONFIG_SERIAL_TEXT_DEBUG)
31
32 #define MPSC_CHR_1      0x000c
33 #define MPSC_CHR_2      0x0010
34
35 static struct mv64x60_handle    mv64x60_dbg_bh;
36
37 void
38 mv64x60_progress_init(u32 base)
39 {
40         mv64x60_dbg_bh.v_base = base;
41         return;
42 }
43
44 static void
45 mv64x60_polled_putc(int chan, char c)
46 {
47         u32     offset;
48
49         if (chan == 0)
50                 offset = 0x8000;
51         else
52                 offset = 0x9000;
53
54         mv64x60_write(&mv64x60_dbg_bh, offset + MPSC_CHR_1, (u32)c);
55         mv64x60_write(&mv64x60_dbg_bh, offset + MPSC_CHR_2, 0x200);
56         udelay(2000);
57 }
58
59 void
60 mv64x60_mpsc_progress(char *s, unsigned short hex)
61 {
62         volatile char   c;
63
64         mv64x60_polled_putc(0, '\r');
65
66         while ((c = *s++) != 0)
67                 mv64x60_polled_putc(0, c);
68
69         mv64x60_polled_putc(0, '\n');
70         mv64x60_polled_putc(0, '\r');
71
72         return;
73 }
74 #endif  /* CONFIG_SERIAL_TEXT_DEBUG */
75
76
77 #if defined(CONFIG_KGDB)
78
79 #if defined(CONFIG_KGDB_TTYS0)
80 #define KGDB_PORT 0
81 #elif defined(CONFIG_KGDB_TTYS1)
82 #define KGDB_PORT 1
83 #else
84 #error "Invalid kgdb_tty port"
85 #endif
86
87 void
88 putDebugChar(unsigned char c)
89 {
90         mv64x60_polled_putc(KGDB_PORT, (char)c);
91 }
92
93 int
94 getDebugChar(void)
95 {
96         unsigned char   c;
97
98         while (!mv64x60_polled_getc(KGDB_PORT, &c));
99         return (int)c;
100 }
101
102 void
103 putDebugString(char* str)
104 {
105         while (*str != '\0') {
106                 putDebugChar(*str);
107                 str++;
108         }
109         putDebugChar('\r');
110         return;
111 }
112
113 void
114 kgdb_interruptible(int enable)
115 {
116 }
117
118 void
119 kgdb_map_scc(void)
120 {
121         if (ppc_md.early_serial_map)
122                 ppc_md.early_serial_map();
123 }
124 #endif  /* CONFIG_KGDB */