OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [or32/] [kernel/] [dbgport.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  linux/arch/or32/kernel/dbgport.c
3
 *
4
 *  or32 version
5
 *    author(s): Simon Srot (srot@opencores.org)
6
 *
7
 *  changes:
8
 *  18. 11. 2003: Matjaz Breskvar (phoenix@opencores.org)
9
 *    initial port to or32 architecture
10
 *
11
 */
12
 
13
#include <linux/kernel.h> 
14
#include <linux/init.h>
15
#include <linux/major.h>
16
#include <linux/console.h>
17
#include <linux/serial_reg.h>
18
#include <asm/system.h>
19
#include <asm/board.h>
20
 
21
#define BASE_BAUD_OR1K ( SYS_CLK / 16 )
22
 
23
#define REG8(x) (*(volatile unsigned char *)(x))
24
 
25
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
26
#define WAIT_FOR_XMITR \
27
 do { \
28
       lsr = REG8(UART_BASE_ADD + UART_LSR); \
29
 } while ((lsr & BOTH_EMPTY) != BOTH_EMPTY)
30
 
31
kdev_t or32_console_device(struct console *c)
32
{
33
        return MKDEV(TTY_MAJOR, 64 + c->index);
34
}
35
 
36
int or32_console_setup(struct console *co, char *options)
37
{
38
 
39
        int devisor;
40
 
41
        /* Reset receiver and transmiter */
42
        REG8(UART_BASE_ADD + UART_FCR) = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT;
43
 
44
        /* Disable all interrupts */
45
        REG8(UART_BASE_ADD + UART_IER) = 0x00;
46
 
47
        /* Set 8 bit char, 1 stop bit, no parity */
48
        REG8(UART_BASE_ADD + UART_LCR) = UART_LCR_WLEN8 & ~(UART_LCR_STOP | UART_LCR_PARITY);
49
 
50
        /* Set baud rate */
51
        devisor = BASE_BAUD_OR1K/OR32_CONSOLE_BAUD;
52
        REG8(UART_BASE_ADD + UART_LCR) |= UART_LCR_DLAB;
53
        REG8(UART_BASE_ADD + UART_DLL) = devisor & 0x000000ff;
54
        REG8(UART_BASE_ADD + UART_DLM) = (devisor >> 8) & 0x000000ff;
55
        REG8(UART_BASE_ADD + UART_LCR) &= ~(UART_LCR_DLAB);
56
 
57
        return 0;
58
}
59
 
60
 
61
void or32_console_write(struct console *co, const char *buf, unsigned int len)
62
{
63
 
64
        char c;
65
        unsigned char ier, lsr;
66
        unsigned long flags;
67
 
68
        extern void putc(char);
69
 
70
        save_flags(flags);
71
        cli();
72
 
73
        ier = REG8(UART_BASE_ADD + UART_IER);
74
        REG8(UART_BASE_ADD + UART_IER) = 0x00;
75
 
76
        for (; len; len--, buf++) {
77
                c = *buf;
78
 
79
                WAIT_FOR_XMITR;
80
                REG8(UART_BASE_ADD + UART_TX) = c;
81
 
82
                if (c == '\n') {
83
                        WAIT_FOR_XMITR;
84
                        REG8(UART_BASE_ADD + UART_TX) = '\r';
85
                }
86
        }
87
 
88
        WAIT_FOR_XMITR;
89
        REG8(UART_BASE_ADD + UART_IER) = ier;
90
 
91
        /* Dummy read to clear all pending interrupt */
92
        REG8(UART_BASE_ADD + UART_IIR);
93
        REG8(UART_BASE_ADD + UART_LSR);
94
 
95
        restore_flags(flags);
96
 
97
        return;
98
}
99
 
100
static struct console or32_console = {
101
        name:    "ttyS",
102
        write:   or32_console_write,
103
        device:  or32_console_device,
104
        unblank: NULL,
105
        setup:   or32_console_setup,
106
        flags:   CON_PRINTBUFFER,
107
        index:   -1,
108
        cflag:   0,
109
        next:    NULL
110
};
111
 
112
void __init init_or32_console(void)
113
{
114
        register_console(&or32_console);
115
}
116
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.