2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* IBM ASM Service Processor Device Driver
|
|
|
|
*
|
|
|
|
* Copyright (C) IBM Corporation, 2004
|
|
|
|
*
|
2011-12-30 06:09:01 +08:00
|
|
|
* Author: Max Asböck <amax@us.ibm.com>
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/termios.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/serial_core.h>
|
|
|
|
#include <linux/serial_reg.h>
|
2005-09-08 04:37:00 +08:00
|
|
|
#include <linux/serial_8250.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "ibmasm.h"
|
|
|
|
#include "lowlevel.h"
|
|
|
|
|
|
|
|
|
|
|
|
void ibmasm_register_uart(struct service_processor *sp)
|
|
|
|
{
|
2012-07-18 00:06:20 +08:00
|
|
|
struct uart_8250_port uart;
|
2005-04-17 06:20:36 +08:00
|
|
|
void __iomem *iomem_base;
|
|
|
|
|
|
|
|
iomem_base = sp->base_address + SCOUT_COM_B_BASE;
|
|
|
|
|
|
|
|
/* read the uart scratch register to determine if the UART
|
|
|
|
* is dedicated to the service processor or if the OS can use it
|
|
|
|
*/
|
|
|
|
if (0 == readl(iomem_base + UART_SCR)) {
|
|
|
|
dev_info(sp->dev, "IBM SP UART not registered, owned by service processor\n");
|
|
|
|
sp->serial_line = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-18 00:06:20 +08:00
|
|
|
memset(&uart, 0, sizeof(uart));
|
|
|
|
uart.port.irq = sp->irq;
|
|
|
|
uart.port.uartclk = 3686400;
|
|
|
|
uart.port.flags = UPF_SHARE_IRQ;
|
|
|
|
uart.port.iotype = UPIO_MEM;
|
|
|
|
uart.port.membase = iomem_base;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-07-18 00:06:20 +08:00
|
|
|
sp->serial_line = serial8250_register_8250_port(&uart);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (sp->serial_line < 0) {
|
|
|
|
dev_err(sp->dev, "Failed to register serial port\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
enable_uart_interrupts(sp->base_address);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibmasm_unregister_uart(struct service_processor *sp)
|
|
|
|
{
|
|
|
|
if (sp->serial_line < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
disable_uart_interrupts(sp->base_address);
|
2005-09-08 04:37:00 +08:00
|
|
|
serial8250_unregister_port(sp->serial_line);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|