uncompress.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * arch/arm/mach-ep93xx/include/mach/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 <mach/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. #if defined(CONFIG_EP93XX_EARLY_UART1)
  29. #define UART_BASE EP93XX_UART1_PHYS_BASE
  30. #elif defined(CONFIG_EP93XX_EARLY_UART2)
  31. #define UART_BASE EP93XX_UART2_PHYS_BASE
  32. #elif defined(CONFIG_EP93XX_EARLY_UART3)
  33. #define UART_BASE EP93XX_UART3_PHYS_BASE
  34. #else
  35. #define UART_BASE EP93XX_UART1_PHYS_BASE
  36. #endif
  37. #define PHYS_UART_DATA (UART_BASE + 0x00)
  38. #define PHYS_UART_FLAG (UART_BASE + 0x18)
  39. #define UART_FLAG_TXFF 0x20
  40. static inline void putc(int c)
  41. {
  42. int i;
  43. for (i = 0; i < 1000; i++) {
  44. /* Transmit fifo not full? */
  45. if (!(__raw_readb(PHYS_UART_FLAG) & UART_FLAG_TXFF))
  46. break;
  47. }
  48. __raw_writeb(c, PHYS_UART_DATA);
  49. }
  50. static inline void flush(void)
  51. {
  52. }
  53. /*
  54. * Some bootloaders don't turn off DMA from the ethernet MAC before
  55. * jumping to linux, which means that we might end up with bits of RX
  56. * status and packet data scribbled over the uncompressed kernel image.
  57. * Work around this by resetting the ethernet MAC before we uncompress.
  58. */
  59. #define PHYS_ETH_SELF_CTL 0x80010020
  60. #define ETH_SELF_CTL_RESET 0x00000001
  61. static void ethernet_reset(void)
  62. {
  63. unsigned int v;
  64. /* Reset the ethernet MAC. */
  65. v = __raw_readl(PHYS_ETH_SELF_CTL);
  66. __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
  67. /* Wait for reset to finish. */
  68. while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
  69. ;
  70. }
  71. static void arch_decomp_setup(void)
  72. {
  73. ethernet_reset();
  74. }
  75. #define arch_decomp_wdog()