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