uncompress.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  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. #include <asm/arch/ep93xx-regs.h>
  12. static unsigned char __raw_readb(unsigned int ptr)
  13. {
  14. return *((volatile unsigned char *)ptr);
  15. }
  16. static unsigned int __raw_readl(unsigned int ptr)
  17. {
  18. return *((volatile unsigned int *)ptr);
  19. }
  20. static void __raw_writeb(unsigned char value, unsigned int ptr)
  21. {
  22. *((volatile unsigned char *)ptr) = value;
  23. }
  24. static void __raw_writel(unsigned int value, unsigned int ptr)
  25. {
  26. *((volatile unsigned int *)ptr) = value;
  27. }
  28. #define PHYS_UART1_DATA 0x808c0000
  29. #define PHYS_UART1_FLAG 0x808c0018
  30. #define UART1_FLAG_TXFF 0x20
  31. static __inline__ void putc(char c)
  32. {
  33. int i;
  34. for (i = 0; i < 1000; i++) {
  35. /* Transmit fifo not full? */
  36. if (!(__raw_readb(PHYS_UART1_FLAG) & UART1_FLAG_TXFF))
  37. break;
  38. }
  39. __raw_writeb(c, PHYS_UART1_DATA);
  40. }
  41. static void putstr(const char *s)
  42. {
  43. while (*s) {
  44. putc(*s);
  45. if (*s == '\n')
  46. putc('\r');
  47. s++;
  48. }
  49. }
  50. /*
  51. * Some bootloaders don't turn off DMA from the ethernet MAC before
  52. * jumping to linux, which means that we might end up with bits of RX
  53. * status and packet data scribbled over the uncompressed kernel image.
  54. * Work around this by resetting the ethernet MAC before we uncompress.
  55. */
  56. #define PHYS_ETH_SELF_CTL 0x80010020
  57. #define ETH_SELF_CTL_RESET 0x00000001
  58. static void ethernet_reset(void)
  59. {
  60. unsigned int v;
  61. /* Reset the ethernet MAC. */
  62. v = __raw_readl(PHYS_ETH_SELF_CTL);
  63. __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
  64. /* Wait for reset to finish. */
  65. while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
  66. ;
  67. }
  68. static void arch_decomp_setup(void)
  69. {
  70. ethernet_reset();
  71. }
  72. #define arch_decomp_wdog()