debug-uart.c 1.8 KB

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