2 * Copyright (C) 2003, Axis Communications AB.
5 #include <linux/console.h>
6 #include <linux/init.h>
7 #include <hwregs/reg_rdwr.h>
8 #include <hwregs/reg_map.h>
9 #include <hwregs/ser_defs.h>
10 #include <hwregs/dma_defs.h>
11 #include <mach/pinmux.h>
16 unsigned long instance;
18 unsigned long baudrate;
23 struct dbg_port ports[] =
57 #if CONFIG_ETRAX_SERIAL_PORTS == 5
68 static struct dbg_port *port =
69 #if defined(CONFIG_ETRAX_DEBUG_PORT0)
71 #elif defined(CONFIG_ETRAX_DEBUG_PORT1)
73 #elif defined(CONFIG_ETRAX_DEBUG_PORT2)
75 #elif defined(CONFIG_ETRAX_DEBUG_PORT3)
77 #elif defined(CONFIG_ETRAX_DEBUG_PORT4)
83 #ifdef CONFIG_ETRAX_KGDB
84 static struct dbg_port *kgdb_port =
85 #if defined(CONFIG_ETRAX_KGDB_PORT0)
87 #elif defined(CONFIG_ETRAX_KGDB_PORT1)
89 #elif defined(CONFIG_ETRAX_KGDB_PORT2)
91 #elif defined(CONFIG_ETRAX_KGDB_PORT3)
93 #elif defined(CONFIG_ETRAX_KGDB_PORT4)
101 start_port(struct dbg_port* p)
111 crisv32_pinmux_alloc_fixed(pinmux_ser1);
112 else if (p->nbr == 2)
113 crisv32_pinmux_alloc_fixed(pinmux_ser2);
114 else if (p->nbr == 3)
115 crisv32_pinmux_alloc_fixed(pinmux_ser3);
116 #if CONFIG_ETRAX_SERIAL_PORTS == 5
117 else if (p->nbr == 4)
118 crisv32_pinmux_alloc_fixed(pinmux_ser4);
121 /* Set up serial port registers */
122 reg_ser_rw_tr_ctrl tr_ctrl = {0};
123 reg_ser_rw_tr_dma_en tr_dma_en = {0};
125 reg_ser_rw_rec_ctrl rec_ctrl = {0};
126 reg_ser_rw_tr_baud_div tr_baud_div = {0};
127 reg_ser_rw_rec_baud_div rec_baud_div = {0};
129 tr_ctrl.base_freq = rec_ctrl.base_freq = regk_ser_f29_493;
130 tr_dma_en.en = rec_ctrl.dma_mode = regk_ser_no;
131 tr_baud_div.div = rec_baud_div.div = 29493000 / p->baudrate / 8;
132 tr_ctrl.en = rec_ctrl.en = 1;
134 if (p->parity == 'O')
136 tr_ctrl.par_en = regk_ser_yes;
137 tr_ctrl.par = regk_ser_odd;
138 rec_ctrl.par_en = regk_ser_yes;
139 rec_ctrl.par = regk_ser_odd;
141 else if (p->parity == 'E')
143 tr_ctrl.par_en = regk_ser_yes;
144 tr_ctrl.par = regk_ser_even;
145 rec_ctrl.par_en = regk_ser_yes;
146 rec_ctrl.par = regk_ser_odd;
151 tr_ctrl.data_bits = regk_ser_bits7;
152 rec_ctrl.data_bits = regk_ser_bits7;
155 REG_WR (ser, p->instance, rw_tr_baud_div, tr_baud_div);
156 REG_WR (ser, p->instance, rw_rec_baud_div, rec_baud_div);
157 REG_WR (ser, p->instance, rw_tr_dma_en, tr_dma_en);
158 REG_WR (ser, p->instance, rw_tr_ctrl, tr_ctrl);
159 REG_WR (ser, p->instance, rw_rec_ctrl, rec_ctrl);
162 #ifdef CONFIG_ETRAX_KGDB
163 /* Use polling to get a single character from the kernel debug port */
167 reg_ser_rs_stat_din stat;
168 reg_ser_rw_ack_intr ack_intr = { 0 };
171 stat = REG_RD(ser, kgdb_port->instance, rs_stat_din);
174 /* Ack the data_avail interrupt. */
176 REG_WR(ser, kgdb_port->instance, rw_ack_intr, ack_intr);
181 /* Use polling to put a single character to the kernel debug port */
183 putDebugChar(int val)
185 reg_ser_r_stat_din stat;
187 stat = REG_RD(ser, kgdb_port->instance, r_stat_din);
188 } while (!stat.tr_rdy);
189 REG_WR_INT(ser, kgdb_port->instance, rw_dout, val);
191 #endif /* CONFIG_ETRAX_KGDB */
193 /* Register console for printk's, etc. */
195 init_etrax_debug(void)
199 #ifdef CONFIG_ETRAX_KGDB
200 start_port(kgdb_port);
201 #endif /* CONFIG_ETRAX_KGDB */