Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * IBM ASM Service Processor Device Driver |
| 5 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Copyright (C) IBM Corporation, 2004 |
| 7 | * |
Al Viro | d36b691 | 2011-12-29 17:09:01 -0500 | [diff] [blame] | 8 | * Author: Max Asböck <amax@us.ibm.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <linux/termios.h> |
| 12 | #include <linux/tty.h> |
| 13 | #include <linux/serial_core.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/serial_reg.h> |
Max Asbock | 66172d2 | 2005-09-07 21:37:00 +0100 | [diff] [blame] | 15 | #include <linux/serial_8250.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include "ibmasm.h" |
| 17 | #include "lowlevel.h" |
| 18 | |
| 19 | |
| 20 | void ibmasm_register_uart(struct service_processor *sp) |
| 21 | { |
Alan Cox | ce7240e | 2012-07-17 17:06:20 +0100 | [diff] [blame] | 22 | struct uart_8250_port uart; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | void __iomem *iomem_base; |
| 24 | |
| 25 | iomem_base = sp->base_address + SCOUT_COM_B_BASE; |
| 26 | |
| 27 | /* read the uart scratch register to determine if the UART |
| 28 | * is dedicated to the service processor or if the OS can use it |
| 29 | */ |
| 30 | if (0 == readl(iomem_base + UART_SCR)) { |
| 31 | dev_info(sp->dev, "IBM SP UART not registered, owned by service processor\n"); |
| 32 | sp->serial_line = -1; |
| 33 | return; |
| 34 | } |
| 35 | |
Alan Cox | ce7240e | 2012-07-17 17:06:20 +0100 | [diff] [blame] | 36 | memset(&uart, 0, sizeof(uart)); |
| 37 | uart.port.irq = sp->irq; |
| 38 | uart.port.uartclk = 3686400; |
| 39 | uart.port.flags = UPF_SHARE_IRQ; |
| 40 | uart.port.iotype = UPIO_MEM; |
| 41 | uart.port.membase = iomem_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Alan Cox | ce7240e | 2012-07-17 17:06:20 +0100 | [diff] [blame] | 43 | sp->serial_line = serial8250_register_8250_port(&uart); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | if (sp->serial_line < 0) { |
| 45 | dev_err(sp->dev, "Failed to register serial port\n"); |
| 46 | return; |
| 47 | } |
| 48 | enable_uart_interrupts(sp->base_address); |
| 49 | } |
| 50 | |
| 51 | void ibmasm_unregister_uart(struct service_processor *sp) |
| 52 | { |
| 53 | if (sp->serial_line < 0) |
| 54 | return; |
| 55 | |
| 56 | disable_uart_interrupts(sp->base_address); |
Max Asbock | 66172d2 | 2005-09-07 21:37:00 +0100 | [diff] [blame] | 57 | serial8250_unregister_port(sp->serial_line); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |