1 /* This file is part of the program GDB, the GNU debugger.
3 Copyright (C) 1998 Free Software Foundation, Inc.
4 Contributed by Cygnus Solutions.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 mn103ser - mn103002 serial devices 0, 1 and 2.
33 Implements the mn103002 serial interfaces as described in the
39 reg = <serial-addr> <serial-size>
47 /* The serial devices' registers' address block */
49 struct mn103ser_block
{
56 enum serial_register_types
{
76 struct mn103ser_block block
;
79 /* output port ID's */
92 static const struct hw_port_descriptor mn103ser_ports
[] = {
94 { "serial-0-receive", SERIAL0_RECEIVE
, 0, output_port
, },
95 { "serial-0-transmit", SERIAL0_SEND
, 0, output_port
, },
96 { "serial-1-receive", SERIAL1_RECEIVE
, 0, output_port
, },
97 { "serial-1-transmit", SERIAL1_SEND
, 0, output_port
, },
98 { "serial-2-receive", SERIAL2_RECEIVE
, 0, output_port
, },
99 { "serial-2-transmit", SERIAL2_SEND
, 0, output_port
, },
106 /* Finish off the partially created hw device. Attach our local
107 callbacks. Wire up our port names etc */
109 static hw_io_read_buffer_method mn103ser_io_read_buffer
;
110 static hw_io_write_buffer_method mn103ser_io_write_buffer
;
113 attach_mn103ser_regs (struct hw
*me
,
114 struct mn103ser
*serial
)
116 unsigned_word attach_address
;
118 unsigned attach_size
;
119 reg_property_spec reg
;
121 if (hw_find_property (me
, "reg") == NULL
)
122 hw_abort (me
, "Missing \"reg\" property");
124 if (!hw_find_reg_array_property (me
, "reg", 0, ®
))
125 hw_abort (me
, "\"reg\" property must contain three addr/size entries");
126 hw_unit_address_to_attach_address (hw_parent (me
),
131 serial
->block
.base
= attach_address
;
132 hw_unit_size_to_attach_size (hw_parent (me
),
135 serial
->block
.bound
= attach_address
+ (attach_size
- 1);
136 hw_attach_address (hw_parent (me
),
138 attach_space
, attach_address
, attach_size
,
143 mn103ser_finish (struct hw
*me
)
145 struct mn103ser
*serial
;
148 serial
= HW_ZALLOC (me
, struct mn103ser
);
149 set_hw_data (me
, serial
);
150 set_hw_io_read_buffer (me
, mn103ser_io_read_buffer
);
151 set_hw_io_write_buffer (me
, mn103ser_io_write_buffer
);
152 set_hw_ports (me
, mn103ser_ports
);
154 /* Attach ourself to our parent bus */
155 attach_mn103ser_regs (me
, serial
);
157 /* Initialize the serial device registers. */
164 decode_addr (struct hw
*me
,
165 struct mn103ser
*serial
,
166 unsigned_word address
)
168 unsigned_word offset
;
169 offset
= address
- serial
->block
.base
;
173 case 0x00: return SC0CTR
;
174 case 0x04: return SC0ICR
;
175 case 0x08: return SC0TXB
;
176 case 0x09: return SC0RXB
;
177 case 0x0C: return SC0STR
;
178 case 0x10: return SC1CTR
;
179 case 0x14: return SC1ICR
;
180 case 0x18: return SC1TXB
;
181 case 0x19: return SC1RXB
;
182 case 0x1C: return SC1STR
;
183 case 0x20: return SC2CTR
;
184 case 0x24: return SC2ICR
;
185 case 0x28: return SC2TXB
;
186 case 0x29: return SC2RXB
;
187 case 0x2C: return SC2STR
;
190 hw_abort (me
, "bad address");
197 read_control_reg (struct hw
*me
,
198 struct mn103ser
*serial
,
207 read_intmode_reg (struct hw
*me
,
208 struct mn103ser
*serial
,
217 read_txb (struct hw
*me
,
218 struct mn103ser
*serial
,
227 read_rxb (struct hw
*me
,
228 struct mn103ser
*serial
,
237 read_status_reg (struct hw
*me
,
238 struct mn103ser
*serial
,
247 mn103ser_io_read_buffer (struct hw
*me
,
253 struct mn103ser
*serial
= hw_data (me
);
254 enum serial_register_types serial_reg
;
255 HW_TRACE ((me
, "read 0x%08lx %d", (long) base
, (int) nr_bytes
));
257 serial_reg
= decode_addr (me
, serial
, base
);
260 /* control registers */
264 read_control_reg(me
, serial
, base
, dest
, nr_bytes
);
267 /* interrupt mode registers */
271 read_intmode_reg(me
, serial
, base
, dest
, nr_bytes
);
274 /* transmission buffers */
278 read_txb(me
, serial
, base
, dest
, nr_bytes
);
281 /* reception buffers */
285 read_rxb(me
, serial
, base
, dest
, nr_bytes
);
288 /* status registers */
292 read_status_reg(me
, serial
, base
, dest
, nr_bytes
);
296 hw_abort(me
, "invalid address");
304 write_control_reg (struct hw
*me
,
305 struct mn103ser
*serial
,
314 write_intmode_reg (struct hw
*me
,
315 struct mn103ser
*serial
,
324 write_txb (struct hw
*me
,
325 struct mn103ser
*serial
,
334 write_rxb (struct hw
*me
,
335 struct mn103ser
*serial
,
344 write_status_reg (struct hw
*me
,
345 struct mn103ser
*serial
,
354 mn103ser_io_write_buffer (struct hw
*me
,
360 struct mn103ser
*serial
= hw_data (me
);
361 enum serial_register_types serial_reg
;
362 HW_TRACE ((me
, "write 0x%08lx %d", (long) base
, (int) nr_bytes
));
364 serial_reg
= decode_addr (me
, serial
, base
);
367 /* control registers */
371 write_control_reg(me
, serial
, base
, source
, nr_bytes
);
374 /* interrupt mode registers */
378 write_intmode_reg(me
, serial
, base
, source
, nr_bytes
);
381 /* transmission buffers */
385 write_txb(me
, serial
, base
, source
, nr_bytes
);
388 /* reception buffers */
392 write_rxb(me
, serial
, base
, source
, nr_bytes
);
395 /* status registers */
399 write_status_reg(me
, serial
, base
, source
, nr_bytes
);
403 hw_abort(me
, "invalid address");
410 const struct hw_descriptor dv_mn103ser_descriptor
[] = {
411 { "mn103ser", mn103ser_finish
, },