uart.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * IBM ASM Service Processor Device Driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright (C) IBM Corporation, 2004
  19. *
  20. * Author: Max Asböck <amax@us.ibm.com>
  21. *
  22. */
  23. #include <linux/termios.h>
  24. #include <linux/tty.h>
  25. #include <linux/serial_core.h>
  26. #include <linux/serial_reg.h>
  27. #include <linux/serial_8250.h>
  28. #include "ibmasm.h"
  29. #include "lowlevel.h"
  30. void ibmasm_register_uart(struct service_processor *sp)
  31. {
  32. struct uart_8250_port uart;
  33. void __iomem *iomem_base;
  34. iomem_base = sp->base_address + SCOUT_COM_B_BASE;
  35. /* read the uart scratch register to determine if the UART
  36. * is dedicated to the service processor or if the OS can use it
  37. */
  38. if (0 == readl(iomem_base + UART_SCR)) {
  39. dev_info(sp->dev, "IBM SP UART not registered, owned by service processor\n");
  40. sp->serial_line = -1;
  41. return;
  42. }
  43. memset(&uart, 0, sizeof(uart));
  44. uart.port.irq = sp->irq;
  45. uart.port.uartclk = 3686400;
  46. uart.port.flags = UPF_SHARE_IRQ;
  47. uart.port.iotype = UPIO_MEM;
  48. uart.port.membase = iomem_base;
  49. sp->serial_line = serial8250_register_8250_port(&uart);
  50. if (sp->serial_line < 0) {
  51. dev_err(sp->dev, "Failed to register serial port\n");
  52. return;
  53. }
  54. enable_uart_interrupts(sp->base_address);
  55. }
  56. void ibmasm_unregister_uart(struct service_processor *sp)
  57. {
  58. if (sp->serial_line < 0)
  59. return;
  60. disable_uart_interrupts(sp->base_address);
  61. serial8250_unregister_port(sp->serial_line);
  62. }