Merge remote-tracking branch 'regulator/topic/max8952' into v3.9-rc8
[linux-2.6-block.git] / arch / arm / mach-ep93xx / include / mach / uncompress.h
CommitLineData
e7736d47 1/*
a09e64fb 2 * arch/arm/mach-ep93xx/include/mach/uncompress.h
e7736d47
LB
3 *
4 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
5 *
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 (at
9 * your option) any later version.
10 */
11
a09e64fb 12#include <mach/ep93xx-regs.h>
e7736d47
LB
13
14static unsigned char __raw_readb(unsigned int ptr)
15{
16 return *((volatile unsigned char *)ptr);
17}
18
c9b4470e
LB
19static unsigned int __raw_readl(unsigned int ptr)
20{
21 return *((volatile unsigned int *)ptr);
22}
23
e7736d47
LB
24static void __raw_writeb(unsigned char value, unsigned int ptr)
25{
26 *((volatile unsigned char *)ptr) = value;
27}
28
c9b4470e
LB
29static void __raw_writel(unsigned int value, unsigned int ptr)
30{
31 *((volatile unsigned int *)ptr) = value;
32}
33
92e88aa7
HS
34#if defined(CONFIG_EP93XX_EARLY_UART1)
35#define UART_BASE EP93XX_UART1_PHYS_BASE
36#elif defined(CONFIG_EP93XX_EARLY_UART2)
37#define UART_BASE EP93XX_UART2_PHYS_BASE
38#elif defined(CONFIG_EP93XX_EARLY_UART3)
39#define UART_BASE EP93XX_UART3_PHYS_BASE
40#else
41#define UART_BASE EP93XX_UART1_PHYS_BASE
42#endif
43
44#define PHYS_UART_DATA (UART_BASE + 0x00)
45#define PHYS_UART_FLAG (UART_BASE + 0x18)
46#define UART_FLAG_TXFF 0x20
e7736d47 47
a081568d 48static inline void putc(int c)
e7736d47 49{
605c357b
HS
50 int i;
51
52 for (i = 0; i < 10000; i++) {
53 /* Transmit fifo not full? */
54 if (!(__raw_readb(PHYS_UART_FLAG) & UART_FLAG_TXFF))
55 break;
56 }
e7736d47 57
92e88aa7 58 __raw_writeb(c, PHYS_UART_DATA);
e7736d47
LB
59}
60
a081568d 61static inline void flush(void)
e7736d47 62{
e7736d47
LB
63}
64
c9b4470e
LB
65
66/*
67 * Some bootloaders don't turn off DMA from the ethernet MAC before
68 * jumping to linux, which means that we might end up with bits of RX
69 * status and packet data scribbled over the uncompressed kernel image.
70 * Work around this by resetting the ethernet MAC before we uncompress.
71 */
72#define PHYS_ETH_SELF_CTL 0x80010020
73#define ETH_SELF_CTL_RESET 0x00000001
74
75static void ethernet_reset(void)
76{
77 unsigned int v;
78
79 /* Reset the ethernet MAC. */
80 v = __raw_readl(PHYS_ETH_SELF_CTL);
81 __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
82
83 /* Wait for reset to finish. */
84 while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
85 ;
86}
87
88
89static void arch_decomp_setup(void)
90{
91 ethernet_reset();
92}