uart.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * IBM ASM Service Processor Device Driver
  4. *
  5. * Copyright (C) IBM Corporation, 2004
  6. *
  7. * Author: Max Asböck <amax@us.ibm.com>
  8. */
  9. #include <linux/termios.h>
  10. #include <linux/tty.h>
  11. #include <linux/serial_core.h>
  12. #include <linux/serial_reg.h>
  13. #include <linux/serial_8250.h>
  14. #include "ibmasm.h"
  15. #include "lowlevel.h"
  16. void ibmasm_register_uart(struct service_processor *sp)
  17. {
  18. struct uart_8250_port uart;
  19. void __iomem *iomem_base;
  20. iomem_base = sp->base_address + SCOUT_COM_B_BASE;
  21. /* read the uart scratch register to determine if the UART
  22. * is dedicated to the service processor or if the OS can use it
  23. */
  24. if (0 == readl(iomem_base + UART_SCR)) {
  25. dev_info(sp->dev, "IBM SP UART not registered, owned by service processor\n");
  26. sp->serial_line = -1;
  27. return;
  28. }
  29. memset(&uart, 0, sizeof(uart));
  30. uart.port.irq = sp->irq;
  31. uart.port.uartclk = 3686400;
  32. uart.port.flags = UPF_SHARE_IRQ;
  33. uart.port.iotype = UPIO_MEM;
  34. uart.port.membase = iomem_base;
  35. sp->serial_line = serial8250_register_8250_port(&uart);
  36. if (sp->serial_line < 0) {
  37. dev_err(sp->dev, "Failed to register serial port\n");
  38. return;
  39. }
  40. enable_uart_interrupts(sp->base_address);
  41. }
  42. void ibmasm_unregister_uart(struct service_processor *sp)
  43. {
  44. if (sp->serial_line < 0)
  45. return;
  46. disable_uart_interrupts(sp->base_address);
  47. serial8250_unregister_port(sp->serial_line);
  48. }