debug-uart.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <debug_uart.h>
  8. #include <linux/io.h>
  9. #include <linux/serial_reg.h>
  10. #include "../soc-info.h"
  11. #include "debug-uart.h"
  12. #define UNIPHIER_UART_TX 0x00
  13. #define UNIPHIER_UART_LCR_MCR 0x10
  14. #define UNIPHIER_UART_LSR 0x14
  15. #define UNIPHIER_UART_LDR 0x24
  16. static void _debug_uart_putc(int c)
  17. {
  18. void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE;
  19. while (!(readl(base + UNIPHIER_UART_LSR) & UART_LSR_THRE))
  20. ;
  21. writel(c, base + UNIPHIER_UART_TX);
  22. }
  23. void _debug_uart_init(void)
  24. {
  25. void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE;
  26. unsigned int divisor;
  27. switch (uniphier_get_soc_type()) {
  28. #if defined(CONFIG_ARCH_UNIPHIER_SLD3)
  29. case SOC_UNIPHIER_SLD3:
  30. divisor = uniphier_sld3_debug_uart_init();
  31. break;
  32. #endif
  33. #if defined(CONFIG_ARCH_UNIPHIER_LD4)
  34. case SOC_UNIPHIER_LD4:
  35. divisor = uniphier_ld4_debug_uart_init();
  36. break;
  37. #endif
  38. #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
  39. case SOC_UNIPHIER_PRO4:
  40. divisor = uniphier_pro4_debug_uart_init();
  41. break;
  42. #endif
  43. #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
  44. case SOC_UNIPHIER_SLD8:
  45. divisor = uniphier_sld8_debug_uart_init();
  46. break;
  47. #endif
  48. #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
  49. case SOC_UNIPHIER_PRO5:
  50. divisor = uniphier_pro5_debug_uart_init();
  51. break;
  52. #endif
  53. #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
  54. case SOC_UNIPHIER_PXS2:
  55. divisor = uniphier_pxs2_debug_uart_init();
  56. break;
  57. #endif
  58. #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
  59. case SOC_UNIPHIER_LD6B:
  60. divisor = uniphier_ld6b_debug_uart_init();
  61. break;
  62. #endif
  63. #if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
  64. case SOC_UNIPHIER_LD11:
  65. case SOC_UNIPHIER_LD20:
  66. divisor = uniphier_ld20_debug_uart_init();
  67. break;
  68. #endif
  69. default:
  70. return;
  71. }
  72. writel(UART_LCR_WLEN8 << 8, base + UNIPHIER_UART_LCR_MCR);
  73. writel(divisor, base + UNIPHIER_UART_LDR);
  74. }
  75. DEBUG_UART_FUNCS