early_printk.c 813 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
  7. */
  8. #include <linux/cpu.h>
  9. #include <lantiq_soc.h>
  10. #define ASC_BUF 1024
  11. #define LTQ_ASC_FSTAT ((u32 *)(LTQ_EARLY_ASC + 0x0048))
  12. #ifdef __BIG_ENDIAN
  13. #define LTQ_ASC_TBUF ((u32 *)(LTQ_EARLY_ASC + 0x0020 + 3))
  14. #else
  15. #define LTQ_ASC_TBUF ((u32 *)(LTQ_EARLY_ASC + 0x0020))
  16. #endif
  17. #define TXMASK 0x3F00
  18. #define TXOFFSET 8
  19. void prom_putchar(char c)
  20. {
  21. unsigned long flags;
  22. local_irq_save(flags);
  23. do { } while ((ltq_r32(LTQ_ASC_FSTAT) & TXMASK) >> TXOFFSET);
  24. if (c == '\n')
  25. ltq_w8('\r', LTQ_ASC_TBUF);
  26. ltq_w8(c, LTQ_ASC_TBUF);
  27. local_irq_restore(flags);
  28. }