summaryrefslogtreecommitdiff
path: root/common/include/asm/arch/uncompress.h
blob: ae1ec6f43e0946790c7566a7be3b6fc097904522 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 *  include/asm/arch/uncompress.h
 *
 *  Copyright (C) 2012 MStar Semiconductor.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
#ifndef __ASM_ARCH_UNCOMPRESS_H
#define __ASM_ARCH_UNCOMPRESS_H

#include <linux/version.h>
#include <asm/arch/hardware.h>
#include <asm/arch/wdt.h>

#define TRANSMIT_REGISTER           (*(volatile unsigned char *)(ARM_UART1_BASE+0x00))
#define LINE_STATUS_REGISTER        (*(volatile unsigned char *)(ARM_UART1_BASE+0x14))

#define LSR_THRE                    (0x20) // THR empty

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
/*
 * This does not append a newline
 */
static inline void putc(int c)
{
    while (!(LINE_STATUS_REGISTER & LSR_THRE))
        barrier();

    TRANSMIT_REGISTER = c;

    if (c == '\n')
    {
        while (!(LINE_STATUS_REGISTER & LSR_THRE))
            barrier();

        TRANSMIT_REGISTER = '\r';
    }
}
#else
/*
 * The following code assumes the serial port has already been
 * initialized by the bootloader.  We search for the first enabled
 * port in the most probable order.  If you didn't setup a port in
 * your bootloader then nothing will appear (which might be desired).
 *
 * This does not append a newline
 */
static void putstr(const char *s)
{
#ifdef CONFIG_SERIAL_CORE_CONSOLE
    while (*s) {

        while (!(LINE_STATUS_REGISTER & LSR_THRE))
            barrier();

        TRANSMIT_REGISTER = *s;

        if (*s == '\n')
        {
            while (!(LINE_STATUS_REGISTER & LSR_THRE))
                barrier();

            TRANSMIT_REGISTER = '\r';
        }
        s++;
    }
#endif // CONFIG_SERIAL_CORE_CONSOLE
}
#endif /* LINUX_2_6_25 */

static inline void flush(void)
{
}

/*
 * nothing to do
 */
#define arch_decomp_setup()

#define arch_decomp_wdog()      \
{ \
    WDT_CRR_PA = WDT_BF(CR, WDT_CR_VAL); \
}

#endif /* __ASM_ARCH_UNCOMPRESS_H */