2 * Copyright (C) 2003, Axis Communications AB.
5 #include <linux/console.h>
6 #include <linux/init.h>
7 #include <asm/system.h>
8 #include <hwregs/reg_rdwr.h>
9 #include <hwregs/reg_map.h>
10 #include <hwregs/ser_defs.h>
11 #include <hwregs/dma_defs.h>
12 #include <asm/arch/mach/pinmux.h>
17 unsigned long instance;
19 unsigned long baudrate;
24 struct dbg_port ports[] =
58 #if CONFIG_ETRAX_SERIAL_PORTS == 5
69 static struct dbg_port *port =
70 #if defined(CONFIG_ETRAX_DEBUG_PORT0)
72 #elif defined(CONFIG_ETRAX_DEBUG_PORT1)
74 #elif defined(CONFIG_ETRAX_DEBUG_PORT2)
76 #elif defined(CONFIG_ETRAX_DEBUG_PORT3)
78 #elif defined(CONFIG_ETRAX_DEBUG_PORT4)
84 #ifdef CONFIG_ETRAX_KGDB
85 static struct dbg_port *kgdb_port =
86 #if defined(CONFIG_ETRAX_KGDB_PORT0)
88 #elif defined(CONFIG_ETRAX_KGDB_PORT1)
90 #elif defined(CONFIG_ETRAX_KGDB_PORT2)
92 #elif defined(CONFIG_ETRAX_KGDB_PORT3)
94 #elif defined(CONFIG_ETRAX_KGDB_PORT4)
102 start_port(struct dbg_port* p)
112 crisv32_pinmux_alloc_fixed(pinmux_ser1);
113 else if (p->nbr == 2)
114 crisv32_pinmux_alloc_fixed(pinmux_ser2);
115 else if (p->nbr == 3)
116 crisv32_pinmux_alloc_fixed(pinmux_ser3);
117 #if CONFIG_ETRAX_SERIAL_PORTS == 5
118 else if (p->nbr == 4)
119 crisv32_pinmux_alloc_fixed(pinmux_ser4);
122 /* Set up serial port registers */
123 reg_ser_rw_tr_ctrl tr_ctrl = {0};
124 reg_ser_rw_tr_dma_en tr_dma_en = {0};
126 reg_ser_rw_rec_ctrl rec_ctrl = {0};
127 reg_ser_rw_tr_baud_div tr_baud_div = {0};
128 reg_ser_rw_rec_baud_div rec_baud_div = {0};
130 tr_ctrl.base_freq = rec_ctrl.base_freq = regk_ser_f29_493;
131 tr_dma_en.en = rec_ctrl.dma_mode = regk_ser_no;
132 tr_baud_div.div = rec_baud_div.div = 29493000 / p->baudrate / 8;
133 tr_ctrl.en = rec_ctrl.en = 1;
135 if (p->parity == 'O')
137 tr_ctrl.par_en = regk_ser_yes;
138 tr_ctrl.par = regk_ser_odd;
139 rec_ctrl.par_en = regk_ser_yes;
140 rec_ctrl.par = regk_ser_odd;
142 else if (p->parity == 'E')
144 tr_ctrl.par_en = regk_ser_yes;
145 tr_ctrl.par = regk_ser_even;
146 rec_ctrl.par_en = regk_ser_yes;
147 rec_ctrl.par = regk_ser_odd;
152 tr_ctrl.data_bits = regk_ser_bits7;
153 rec_ctrl.data_bits = regk_ser_bits7;
156 REG_WR (ser, p->instance, rw_tr_baud_div, tr_baud_div);
157 REG_WR (ser, p->instance, rw_rec_baud_div, rec_baud_div);
158 REG_WR (ser, p->instance, rw_tr_dma_en, tr_dma_en);
159 REG_WR (ser, p->instance, rw_tr_ctrl, tr_ctrl);
160 REG_WR (ser, p->instance, rw_rec_ctrl, rec_ctrl);
163 #ifdef CONFIG_ETRAX_KGDB
164 /* Use polling to get a single character from the kernel debug port */
168 reg_ser_rs_stat_din stat;
169 reg_ser_rw_ack_intr ack_intr = { 0 };
172 stat = REG_RD(ser, kgdb_port->instance, rs_stat_din);
175 /* Ack the data_avail interrupt. */
177 REG_WR(ser, kgdb_port->instance, rw_ack_intr, ack_intr);
182 /* Use polling to put a single character to the kernel debug port */
184 putDebugChar(int val)
186 reg_ser_r_stat_din stat;
188 stat = REG_RD(ser, kgdb_port->instance, r_stat_din);
189 } while (!stat.tr_rdy);
190 REG_WR_INT(ser, kgdb_port->instance, rw_dout, val);
192 #endif /* CONFIG_ETRAX_KGDB */
194 /* Register console for printk's, etc. */
196 init_etrax_debug(void)
200 #ifdef CONFIG_ETRAX_KGDB
201 start_port(kgdb_port);
202 #endif /* CONFIG_ETRAX_KGDB */