fdt_serial_uart8250.c 935 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #include <sbi_utils/fdt/fdt_helper.h>
  10. #include <sbi_utils/serial/fdt_serial.h>
  11. #include <sbi_utils/serial/uart8250.h>
  12. static int serial_uart8250_init(void *fdt, int nodeoff,
  13. const struct fdt_match *match)
  14. {
  15. int rc;
  16. struct platform_uart_data uart;
  17. rc = fdt_parse_uart8250_node(fdt, nodeoff, &uart);
  18. if (rc)
  19. return rc;
  20. return uart8250_init(uart.addr, uart.freq, uart.baud,
  21. uart.reg_shift, uart.reg_io_width);
  22. }
  23. static const struct fdt_match serial_uart8250_match[] = {
  24. { .compatible = "ns16550" },
  25. { .compatible = "ns16550a" },
  26. { .compatible = "snps,dw-apb-uart" },
  27. { },
  28. };
  29. struct fdt_serial fdt_serial_uart8250 = {
  30. .match_table = serial_uart8250_match,
  31. .init = serial_uart8250_init,
  32. .getc = uart8250_getc,
  33. .putc = uart8250_putc
  34. };