blob: 2171082d4fc59d3a024f760c9dda637c9313872b [file] [log] [blame]
Lennert Buytenheke7736d42006-03-20 17:10:13 +00001/*
2 * linux/include/asm-arm/arch-ep93xx/uncompress.h
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
12#include <asm/arch/ep93xx-regs.h>
13
14static unsigned char __raw_readb(unsigned int ptr)
15{
16 return *((volatile unsigned char *)ptr);
17}
18
Lennert Buytenhekc9b44702006-03-26 21:40:27 +010019static unsigned int __raw_readl(unsigned int ptr)
20{
21 return *((volatile unsigned int *)ptr);
22}
23
Lennert Buytenheke7736d42006-03-20 17:10:13 +000024static void __raw_writeb(unsigned char value, unsigned int ptr)
25{
26 *((volatile unsigned char *)ptr) = value;
27}
28
Lennert Buytenhekc9b44702006-03-26 21:40:27 +010029static void __raw_writel(unsigned int value, unsigned int ptr)
30{
31 *((volatile unsigned int *)ptr) = value;
32}
33
Lennert Buytenheke7736d42006-03-20 17:10:13 +000034
35#define PHYS_UART1_DATA 0x808c0000
36#define PHYS_UART1_FLAG 0x808c0018
37#define UART1_FLAG_TXFF 0x20
38
39static __inline__ void putc(char c)
40{
41 int i;
42
43 for (i = 0; i < 1000; i++) {
44 /* Transmit fifo not full? */
45 if (!(__raw_readb(PHYS_UART1_FLAG) & UART1_FLAG_TXFF))
46 break;
47 }
48
49 __raw_writeb(c, PHYS_UART1_DATA);
50}
51
52static void putstr(const char *s)
53{
54 while (*s) {
55 putc(*s);
56 if (*s == '\n')
57 putc('\r');
58 s++;
59 }
60}
61
Lennert Buytenhekc9b44702006-03-26 21:40:27 +010062
63/*
64 * Some bootloaders don't turn off DMA from the ethernet MAC before
65 * jumping to linux, which means that we might end up with bits of RX
66 * status and packet data scribbled over the uncompressed kernel image.
67 * Work around this by resetting the ethernet MAC before we uncompress.
68 */
69#define PHYS_ETH_SELF_CTL 0x80010020
70#define ETH_SELF_CTL_RESET 0x00000001
71
72static void ethernet_reset(void)
73{
74 unsigned int v;
75
76 /* Reset the ethernet MAC. */
77 v = __raw_readl(PHYS_ETH_SELF_CTL);
78 __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
79
80 /* Wait for reset to finish. */
81 while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
82 ;
83}
84
85
86static void arch_decomp_setup(void)
87{
88 ethernet_reset();
89}
90
Lennert Buytenheke7736d42006-03-20 17:10:13 +000091#define arch_decomp_wdog()