~ubuntu-branches/ubuntu/maverick/uboot-imx/maverick

« back to all changes in this revision

Viewing changes to board/omap3/zoom2/zoom2_serial.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2010-01-06 09:28:25 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100106092825-q8o7x811035syh8k
Tags: 2009.08-0ubuntu1
* move to new upstream (2009.08)
* move to new freescale patchset for the 2009.08 release
* remove README.nios_CONFIG_SYS_NIOS_CPU from debian/docs, 
  this is not shipped upstream anymore
* update 1000_fix_gcc_4.4_compability.patch to apply to the new code
* Makefile target is now mx51_bbg_config, update rules accordingly
* switch everything to to3 (including the binary package)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2009 Wind River Systems, Inc.
 
3
 * Tom Rix <Tom.Rix@windriver.com>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License as
 
7
 * published by the Free Software Foundation; either version 2 of
 
8
 * the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 
18
 * MA 02111-1307 USA
 
19
 *
 
20
 * This file was adapted from cpu/mpc5xxx/serial.c
 
21
 *
 
22
 */
 
23
 
 
24
#include <common.h>
 
25
#include <serial.h>
 
26
#include <ns16550.h>
 
27
#include <asm/arch/cpu.h>
 
28
#include "zoom2_serial.h"
 
29
 
 
30
int quad_init_dev (unsigned long base)
 
31
{
 
32
        /*
 
33
         * The Quad UART is on the debug board.
 
34
         * Check if the debug board is attached before using the UART
 
35
         */
 
36
        if (zoom2_debug_board_connected ()) {
 
37
                NS16550_t com_port = (NS16550_t) base;
 
38
                int baud_divisor = CONFIG_SYS_NS16550_CLK / 16 /
 
39
                        CONFIG_BAUDRATE;
 
40
 
 
41
                /*
 
42
                 * Zoom2 has a board specific initialization of its UART.
 
43
                 * This generic initialization has been copied from
 
44
                 * drivers/serial/ns16550.c. The macros have been expanded.
 
45
                 *
 
46
                 * Do the following instead of
 
47
                 *
 
48
                 * NS16550_init (com_port, clock_divisor);
 
49
                 */
 
50
                com_port->ier = 0x00;
 
51
 
 
52
                /*
 
53
                 * On Zoom2 board Set pre-scalar to 1
 
54
                 * CLKSEL is GND => MCR[7] is 1 => preslr is 4
 
55
                 * So change the prescl to 1
 
56
                 */
 
57
                com_port->lcr = 0xBF;
 
58
                com_port->fcr |= 0x10;
 
59
                com_port->mcr &= 0x7F;
 
60
 
 
61
                /* This is generic ns16550.c setup */
 
62
                com_port->lcr = UART_LCR_BKSE | UART_LCR_8N1;
 
63
                com_port->dll = 0;
 
64
                com_port->dlm = 0;
 
65
                com_port->lcr = UART_LCR_8N1;
 
66
                com_port->mcr = UART_MCR_DTR | UART_MCR_RTS;
 
67
                com_port->fcr = UART_FCR_FIFO_EN | UART_FCR_RXSR |
 
68
                        UART_FCR_TXSR;
 
69
                com_port->lcr = UART_LCR_BKSE | UART_LCR_8N1;
 
70
                com_port->dll = baud_divisor & 0xff;
 
71
                com_port->dlm = (baud_divisor >> 8) & 0xff;
 
72
                com_port->lcr = UART_LCR_8N1;
 
73
        }
 
74
        /*
 
75
         * We have to lie here, otherwise the board init code will hang
 
76
         * on the check
 
77
         */
 
78
        return 0;
 
79
}
 
80
 
 
81
void quad_putc_dev (unsigned long base, const char c)
 
82
{
 
83
        if (zoom2_debug_board_connected ()) {
 
84
 
 
85
                if (c == '\n')
 
86
                        quad_putc_dev (base, '\r');
 
87
 
 
88
                NS16550_putc ((NS16550_t) base, c);
 
89
        }
 
90
}
 
91
 
 
92
void quad_puts_dev (unsigned long base, const char *s)
 
93
{
 
94
        if (zoom2_debug_board_connected ()) {
 
95
                while ((s != NULL) && (*s != '\0'))
 
96
                        quad_putc_dev (base, *s++);
 
97
        }
 
98
}
 
99
 
 
100
int quad_getc_dev (unsigned long base)
 
101
{
 
102
        if (zoom2_debug_board_connected ())
 
103
                return NS16550_getc ((NS16550_t) base);
 
104
        else
 
105
                return 0;
 
106
}
 
107
 
 
108
int quad_tstc_dev (unsigned long base)
 
109
{
 
110
        if (zoom2_debug_board_connected ())
 
111
                return NS16550_tstc ((NS16550_t) base);
 
112
        else
 
113
                return 0;
 
114
}
 
115
 
 
116
void quad_setbrg_dev (unsigned long base)
 
117
{
 
118
        if (zoom2_debug_board_connected ()) {
 
119
 
 
120
                int clock_divisor = CONFIG_SYS_NS16550_CLK / 16 /
 
121
                        CONFIG_BAUDRATE;
 
122
 
 
123
                NS16550_reinit ((NS16550_t) base, clock_divisor);
 
124
        }
 
125
}
 
126
 
 
127
QUAD_INIT (0)
 
128
QUAD_INIT (1)
 
129
QUAD_INIT (2)
 
130
QUAD_INIT (3)