m32r_sio.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/m32r/boot/compressed/m32r_sio.c
  4. *
  5. * 2003-02-12: Takeo Takahashi
  6. * 2006-11-30: OPSPUT support by Kazuhiro Inaoka
  7. *
  8. */
  9. #include <asm/processor.h>
  10. static void m32r_putc(char c);
  11. static int puts(const char *s)
  12. {
  13. char c;
  14. while ((c = *s++))
  15. m32r_putc(c);
  16. return 0;
  17. }
  18. #if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_OPSPUT)
  19. #include <asm/m32r.h>
  20. #include <asm/io.h>
  21. #define USE_FPGA_MAP 0
  22. #if USE_FPGA_MAP
  23. /*
  24. * fpga configuration program uses MMU, and define map as same as
  25. * M32104 uT-Engine board.
  26. */
  27. #define BOOT_SIO0STS (volatile unsigned short *)(0x02c00000 + 0x20006)
  28. #define BOOT_SIO0TXB (volatile unsigned short *)(0x02c00000 + 0x2000c)
  29. #else
  30. #undef PLD_BASE
  31. #if defined(CONFIG_PLAT_OPSPUT)
  32. #define PLD_BASE 0x1cc00000
  33. #else
  34. #define PLD_BASE 0xa4c00000
  35. #endif
  36. #define BOOT_SIO0STS PLD_ESIO0STS
  37. #define BOOT_SIO0TXB PLD_ESIO0TXB
  38. #endif
  39. static void m32r_putc(char c)
  40. {
  41. while ((*BOOT_SIO0STS & 0x3) != 0x3)
  42. cpu_relax();
  43. if (c == '\n') {
  44. *BOOT_SIO0TXB = '\r';
  45. while ((*BOOT_SIO0STS & 0x3) != 0x3)
  46. cpu_relax();
  47. }
  48. *BOOT_SIO0TXB = c;
  49. }
  50. #else /* !(CONFIG_PLAT_M32700UT) */
  51. #if defined(CONFIG_PLAT_MAPPI2)
  52. #define SIO0STS (volatile unsigned short *)(0xa0efd000 + 14)
  53. #define SIO0TXB (volatile unsigned short *)(0xa0efd000 + 30)
  54. #else
  55. #define SIO0STS (volatile unsigned short *)(0x00efd000 + 14)
  56. #define SIO0TXB (volatile unsigned short *)(0x00efd000 + 30)
  57. #endif
  58. static void m32r_putc(char c)
  59. {
  60. while ((*SIO0STS & 0x1) == 0)
  61. cpu_relax();
  62. if (c == '\n') {
  63. *SIO0TXB = '\r';
  64. while ((*SIO0STS & 0x1) == 0)
  65. cpu_relax();
  66. }
  67. *SIO0TXB = c;
  68. }
  69. #endif