debug-uart-ld20.c 845 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
  4. */
  5. #include <config.h>
  6. #include <linux/kernel.h>
  7. #include <linux/io.h>
  8. #include "../sc64-regs.h"
  9. #include "../sg-regs.h"
  10. #include "debug-uart.h"
  11. #define UNIPHIER_LD20_UART_CLK 58820000
  12. unsigned int uniphier_ld20_debug_uart_init(void)
  13. {
  14. u32 tmp;
  15. sg_set_iectrl(54); /* TXD0 */
  16. sg_set_iectrl(58); /* TXD1 */
  17. sg_set_iectrl(90); /* TXD2 */
  18. sg_set_iectrl(94); /* TXD3 */
  19. sg_set_pinsel(54, 0, 8, 4); /* TXD0 -> TXD0 */
  20. sg_set_pinsel(58, 1, 8, 4); /* SPITXD1 -> TXD1 */
  21. sg_set_pinsel(90, 1, 8, 4); /* PC0WE -> TXD2 */
  22. sg_set_pinsel(94, 1, 8, 4); /* PCD00 -> TXD3 */
  23. tmp = readl(SC_CLKCTRL4);
  24. tmp |= SC_CLKCTRL4_PERI;
  25. writel(tmp, SC_CLKCTRL4);
  26. return DIV_ROUND_CLOSEST(UNIPHIER_LD20_UART_CLK, 16 * CONFIG_BAUDRATE);
  27. }