Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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