isight_firmware: Avoid crash on loading invalid firmware
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / mips / sibyte / swarm / dbg_io.c
blobb97ae30484826af212162302037af128509de313
1 /*
2 * kgdb debug routines for SiByte boards.
4 * Copyright (C) 2001 MontaVista Software Inc.
5 * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
14 /* -------------------- BEGINNING OF CONFIG --------------------- */
16 #include <linux/delay.h>
17 #include <asm/io.h>
18 #include <asm/sibyte/sb1250.h>
19 #include <asm/sibyte/sb1250_regs.h>
20 #include <asm/sibyte/sb1250_uart.h>
21 #include <asm/sibyte/sb1250_int.h>
22 #include <asm/addrspace.h>
25 * We use the second serial port for kgdb traffic.
26 * 115200, 8, N, 1.
29 #define BAUD_RATE 115200
30 #define CLK_DIVISOR V_DUART_BAUD_RATE(BAUD_RATE)
31 #define DATA_BITS V_DUART_BITS_PER_CHAR_8 /* or 7 */
32 #define PARITY V_DUART_PARITY_MODE_NONE /* or even */
33 #define STOP_BITS M_DUART_STOP_BIT_LEN_1 /* or 2 */
35 static int duart_initialized = 0; /* 0: need to be init'ed by kgdb */
37 /* -------------------- END OF CONFIG --------------------- */
38 extern int kgdb_port;
40 #define duart_out(reg, val) csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port, reg)))
41 #define duart_in(reg) csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port, reg)))
43 void putDebugChar(unsigned char c);
44 unsigned char getDebugChar(void);
45 static void
46 duart_init(int clk_divisor, int data, int parity, int stop)
48 duart_out(R_DUART_MODE_REG_1, data | parity);
49 duart_out(R_DUART_MODE_REG_2, stop);
50 duart_out(R_DUART_CLK_SEL, clk_divisor);
52 duart_out(R_DUART_CMD, M_DUART_RX_EN | M_DUART_TX_EN); /* enable rx and tx */
55 void
56 putDebugChar(unsigned char c)
58 if (!duart_initialized) {
59 duart_initialized = 1;
60 duart_init(CLK_DIVISOR, DATA_BITS, PARITY, STOP_BITS);
62 while ((duart_in(R_DUART_STATUS) & M_DUART_TX_RDY) == 0);
63 duart_out(R_DUART_TX_HOLD, c);
66 unsigned char
67 getDebugChar(void)
69 if (!duart_initialized) {
70 duart_initialized = 1;
71 duart_init(CLK_DIVISOR, DATA_BITS, PARITY, STOP_BITS);
73 while ((duart_in(R_DUART_STATUS) & M_DUART_RX_RDY) == 0) ;
74 return duart_in(R_DUART_RX_HOLD);