uncompress.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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(int 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 inline void flush(void)
  42. {
  43. }
  44. /*
  45. * Some bootloaders don't turn off DMA from the ethernet MAC before
  46. * jumping to linux, which means that we might end up with bits of RX
  47. * status and packet data scribbled over the uncompressed kernel image.
  48. * Work around this by resetting the ethernet MAC before we uncompress.
  49. */
  50. #define PHYS_ETH_SELF_CTL 0x80010020
  51. #define ETH_SELF_CTL_RESET 0x00000001
  52. static void ethernet_reset(void)
  53. {
  54. unsigned int v;
  55. /* Reset the ethernet MAC. */
  56. v = __raw_readl(PHYS_ETH_SELF_CTL);
  57. __raw_writel(v | ETH_SELF_CTL_RESET, PHYS_ETH_SELF_CTL);
  58. /* Wait for reset to finish. */
  59. while (__raw_readl(PHYS_ETH_SELF_CTL) & ETH_SELF_CTL_RESET)
  60. ;
  61. }
  62. static void arch_decomp_setup(void)
  63. {
  64. ethernet_reset();
  65. }
  66. #define arch_decomp_wdog()