cpm_common.c 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Common CPM code
  3. *
  4. * Author: Scott Wood <scottwood@freescale.com>
  5. *
  6. * Copyright 2007 Freescale Semiconductor, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of version 2 of the GNU General Public License as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <asm/udbg.h>
  14. #include <asm/io.h>
  15. #include <asm/system.h>
  16. #include <mm/mmu_decl.h>
  17. #ifdef CONFIG_PPC_EARLY_DEBUG_CPM
  18. static u32 __iomem *cpm_udbg_txdesc =
  19. (u32 __iomem __force *)CONFIG_PPC_EARLY_DEBUG_CPM_ADDR;
  20. static void udbg_putc_cpm(char c)
  21. {
  22. u8 __iomem *txbuf = (u8 __iomem __force *)in_be32(&cpm_udbg_txdesc[1]);
  23. if (c == '\n')
  24. udbg_putc('\r');
  25. while (in_be32(&cpm_udbg_txdesc[0]) & 0x80000000)
  26. ;
  27. out_8(txbuf, c);
  28. out_be32(&cpm_udbg_txdesc[0], 0xa0000001);
  29. }
  30. void __init udbg_init_cpm(void)
  31. {
  32. if (cpm_udbg_txdesc) {
  33. #ifdef CONFIG_CPM2
  34. setbat(1, 0xf0000000, 0xf0000000, 1024*1024, _PAGE_IO);
  35. #endif
  36. udbg_putc = udbg_putc_cpm;
  37. }
  38. }
  39. #endif