Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1 | /* |
Jovi Zhang | 99edb3d | 2011-03-30 05:30:41 -0400 | [diff] [blame] | 2 | * Driver for msm7k serial device and console |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2007 Google, Inc. |
| 5 | * Author: Robert Love <rlove@google.com> |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 6 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 7 | * |
| 8 | * This software is licensed under the terms of the GNU General Public |
| 9 | * License version 2, as published by the Free Software Foundation, and |
| 10 | * may be copied, distributed, and modified under those terms. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #if defined(CONFIG_SERIAL_MSM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) |
| 19 | # define SUPPORT_SYSRQ |
| 20 | #endif |
| 21 | |
David Brown | cfdad2a | 2011-08-04 01:55:24 -0700 | [diff] [blame] | 22 | #include <linux/atomic.h> |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 23 | #include <linux/hrtimer.h> |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/io.h> |
| 26 | #include <linux/ioport.h> |
| 27 | #include <linux/irq.h> |
| 28 | #include <linux/init.h> |
| 29 | #include <linux/console.h> |
| 30 | #include <linux/tty.h> |
| 31 | #include <linux/tty_flip.h> |
| 32 | #include <linux/serial_core.h> |
| 33 | #include <linux/serial.h> |
| 34 | #include <linux/clk.h> |
| 35 | #include <linux/platform_device.h> |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 36 | #include <linux/delay.h> |
David Brown | cfdad2a | 2011-08-04 01:55:24 -0700 | [diff] [blame] | 37 | #include <linux/of.h> |
| 38 | #include <linux/of_device.h> |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 39 | |
| 40 | #include "msm_serial.h" |
| 41 | |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 42 | enum { |
| 43 | UARTDM_1P1 = 1, |
| 44 | UARTDM_1P2, |
| 45 | UARTDM_1P3, |
| 46 | UARTDM_1P4, |
| 47 | }; |
| 48 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 49 | struct msm_port { |
| 50 | struct uart_port uart; |
| 51 | char name[16]; |
| 52 | struct clk *clk; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 53 | struct clk *pclk; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 54 | unsigned int imr; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 55 | int is_uartdm; |
| 56 | unsigned int old_snap_state; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 57 | }; |
| 58 | |
Stephen Boyd | 4a5662d | 2013-07-24 11:37:28 -0700 | [diff] [blame] | 59 | static inline void wait_for_xmitr(struct uart_port *port) |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 60 | { |
Stephen Boyd | 4a5662d | 2013-07-24 11:37:28 -0700 | [diff] [blame] | 61 | while (!(msm_read(port, UART_SR) & UART_SR_TX_EMPTY)) { |
| 62 | if (msm_read(port, UART_ISR) & UART_ISR_TX_READY) |
| 63 | break; |
| 64 | udelay(1); |
| 65 | } |
| 66 | msm_write(port, UART_CR_CMD_RESET_TX_READY, UART_CR); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 67 | } |
| 68 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 69 | static void msm_stop_tx(struct uart_port *port) |
| 70 | { |
| 71 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 72 | |
| 73 | msm_port->imr &= ~UART_IMR_TXLEV; |
| 74 | msm_write(port, msm_port->imr, UART_IMR); |
| 75 | } |
| 76 | |
| 77 | static void msm_start_tx(struct uart_port *port) |
| 78 | { |
| 79 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 80 | |
| 81 | msm_port->imr |= UART_IMR_TXLEV; |
| 82 | msm_write(port, msm_port->imr, UART_IMR); |
| 83 | } |
| 84 | |
| 85 | static void msm_stop_rx(struct uart_port *port) |
| 86 | { |
| 87 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 88 | |
| 89 | msm_port->imr &= ~(UART_IMR_RXLEV | UART_IMR_RXSTALE); |
| 90 | msm_write(port, msm_port->imr, UART_IMR); |
| 91 | } |
| 92 | |
| 93 | static void msm_enable_ms(struct uart_port *port) |
| 94 | { |
| 95 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 96 | |
| 97 | msm_port->imr |= UART_IMR_DELTA_CTS; |
| 98 | msm_write(port, msm_port->imr, UART_IMR); |
| 99 | } |
| 100 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 101 | static void handle_rx_dm(struct uart_port *port, unsigned int misr) |
| 102 | { |
Jiri Slaby | 92a19f9 | 2013-01-03 15:53:03 +0100 | [diff] [blame] | 103 | struct tty_port *tport = &port->state->port; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 104 | unsigned int sr; |
| 105 | int count = 0; |
| 106 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 107 | |
| 108 | if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { |
| 109 | port->icount.overrun++; |
Jiri Slaby | 92a19f9 | 2013-01-03 15:53:03 +0100 | [diff] [blame] | 110 | tty_insert_flip_char(tport, 0, TTY_OVERRUN); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 111 | msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); |
| 112 | } |
| 113 | |
| 114 | if (misr & UART_IMR_RXSTALE) { |
| 115 | count = msm_read(port, UARTDM_RX_TOTAL_SNAP) - |
| 116 | msm_port->old_snap_state; |
| 117 | msm_port->old_snap_state = 0; |
| 118 | } else { |
| 119 | count = 4 * (msm_read(port, UART_RFWR)); |
| 120 | msm_port->old_snap_state += count; |
| 121 | } |
| 122 | |
| 123 | /* TODO: Precise error reporting */ |
| 124 | |
| 125 | port->icount.rx += count; |
| 126 | |
| 127 | while (count > 0) { |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 128 | unsigned char buf[4]; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 129 | |
| 130 | sr = msm_read(port, UART_SR); |
| 131 | if ((sr & UART_SR_RX_READY) == 0) { |
| 132 | msm_port->old_snap_state -= count; |
| 133 | break; |
| 134 | } |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 135 | ioread32_rep(port->membase + UARTDM_RF, buf, 1); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 136 | if (sr & UART_SR_RX_BREAK) { |
| 137 | port->icount.brk++; |
| 138 | if (uart_handle_break(port)) |
| 139 | continue; |
| 140 | } else if (sr & UART_SR_PAR_FRAME_ERR) |
| 141 | port->icount.frame++; |
| 142 | |
| 143 | /* TODO: handle sysrq */ |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 144 | tty_insert_flip_string(tport, buf, min(count, 4)); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 145 | count -= 4; |
| 146 | } |
| 147 | |
Viresh Kumar | f77232d | 2013-08-19 20:14:20 +0530 | [diff] [blame] | 148 | spin_unlock(&port->lock); |
Jiri Slaby | 2e124b4 | 2013-01-03 15:53:06 +0100 | [diff] [blame] | 149 | tty_flip_buffer_push(tport); |
Viresh Kumar | f77232d | 2013-08-19 20:14:20 +0530 | [diff] [blame] | 150 | spin_lock(&port->lock); |
| 151 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 152 | if (misr & (UART_IMR_RXSTALE)) |
| 153 | msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); |
| 154 | msm_write(port, 0xFFFFFF, UARTDM_DMRX); |
| 155 | msm_write(port, UART_CR_CMD_STALE_EVENT_ENABLE, UART_CR); |
| 156 | } |
| 157 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 158 | static void handle_rx(struct uart_port *port) |
| 159 | { |
Jiri Slaby | 92a19f9 | 2013-01-03 15:53:03 +0100 | [diff] [blame] | 160 | struct tty_port *tport = &port->state->port; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 161 | unsigned int sr; |
| 162 | |
| 163 | /* |
| 164 | * Handle overrun. My understanding of the hardware is that overrun |
| 165 | * is not tied to the RX buffer, so we handle the case out of band. |
| 166 | */ |
| 167 | if ((msm_read(port, UART_SR) & UART_SR_OVERRUN)) { |
| 168 | port->icount.overrun++; |
Jiri Slaby | 92a19f9 | 2013-01-03 15:53:03 +0100 | [diff] [blame] | 169 | tty_insert_flip_char(tport, 0, TTY_OVERRUN); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 170 | msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); |
| 171 | } |
| 172 | |
| 173 | /* and now the main RX loop */ |
| 174 | while ((sr = msm_read(port, UART_SR)) & UART_SR_RX_READY) { |
| 175 | unsigned int c; |
| 176 | char flag = TTY_NORMAL; |
| 177 | |
| 178 | c = msm_read(port, UART_RF); |
| 179 | |
| 180 | if (sr & UART_SR_RX_BREAK) { |
| 181 | port->icount.brk++; |
| 182 | if (uart_handle_break(port)) |
| 183 | continue; |
| 184 | } else if (sr & UART_SR_PAR_FRAME_ERR) { |
| 185 | port->icount.frame++; |
| 186 | } else { |
| 187 | port->icount.rx++; |
| 188 | } |
| 189 | |
| 190 | /* Mask conditions we're ignorning. */ |
| 191 | sr &= port->read_status_mask; |
| 192 | |
Kiran Padwal | ddea392 | 2014-08-05 13:21:59 +0530 | [diff] [blame^] | 193 | if (sr & UART_SR_RX_BREAK) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 194 | flag = TTY_BREAK; |
Kiran Padwal | ddea392 | 2014-08-05 13:21:59 +0530 | [diff] [blame^] | 195 | else if (sr & UART_SR_PAR_FRAME_ERR) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 196 | flag = TTY_FRAME; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 197 | |
| 198 | if (!uart_handle_sysrq_char(port, c)) |
Jiri Slaby | 92a19f9 | 2013-01-03 15:53:03 +0100 | [diff] [blame] | 199 | tty_insert_flip_char(tport, c, flag); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 200 | } |
| 201 | |
Viresh Kumar | f77232d | 2013-08-19 20:14:20 +0530 | [diff] [blame] | 202 | spin_unlock(&port->lock); |
Jiri Slaby | 2e124b4 | 2013-01-03 15:53:06 +0100 | [diff] [blame] | 203 | tty_flip_buffer_push(tport); |
Viresh Kumar | f77232d | 2013-08-19 20:14:20 +0530 | [diff] [blame] | 204 | spin_lock(&port->lock); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 205 | } |
| 206 | |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 207 | static void reset_dm_count(struct uart_port *port, int count) |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 208 | { |
Stephen Boyd | 4a5662d | 2013-07-24 11:37:28 -0700 | [diff] [blame] | 209 | wait_for_xmitr(port); |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 210 | msm_write(port, count, UARTDM_NCF_TX); |
Stephen Boyd | 4a5662d | 2013-07-24 11:37:28 -0700 | [diff] [blame] | 211 | msm_read(port, UARTDM_NCF_TX); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 212 | } |
| 213 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 214 | static void handle_tx(struct uart_port *port) |
| 215 | { |
Alan Cox | ebd2c8f | 2009-09-19 13:13:28 -0700 | [diff] [blame] | 216 | struct circ_buf *xmit = &port->state->xmit; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 217 | struct msm_port *msm_port = UART_TO_MSM(port); |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 218 | unsigned int tx_count, num_chars; |
| 219 | unsigned int tf_pointer = 0; |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 220 | void __iomem *tf; |
| 221 | |
| 222 | if (msm_port->is_uartdm) |
| 223 | tf = port->membase + UARTDM_TF; |
| 224 | else |
| 225 | tf = port->membase + UART_TF; |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 226 | |
| 227 | tx_count = uart_circ_chars_pending(xmit); |
| 228 | tx_count = min3(tx_count, (unsigned int)UART_XMIT_SIZE - xmit->tail, |
| 229 | port->fifosize); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 230 | |
| 231 | if (port->x_char) { |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 232 | if (msm_port->is_uartdm) |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 233 | reset_dm_count(port, tx_count + 1); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 234 | |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 235 | iowrite8_rep(tf, &port->x_char, 1); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 236 | port->icount.tx++; |
| 237 | port->x_char = 0; |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 238 | } else if (tx_count && msm_port->is_uartdm) { |
| 239 | reset_dm_count(port, tx_count); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 240 | } |
| 241 | |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 242 | while (tf_pointer < tx_count) { |
| 243 | int i; |
| 244 | char buf[4] = { 0 }; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 245 | |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 246 | if (!(msm_read(port, UART_SR) & UART_SR_TX_READY)) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 247 | break; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 248 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 249 | if (msm_port->is_uartdm) |
Jingoo Han | 4f749f2 | 2013-08-08 17:38:20 +0900 | [diff] [blame] | 250 | num_chars = min(tx_count - tf_pointer, |
| 251 | (unsigned int)sizeof(buf)); |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 252 | else |
| 253 | num_chars = 1; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 254 | |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 255 | for (i = 0; i < num_chars; i++) { |
| 256 | buf[i] = xmit->buf[xmit->tail + i]; |
| 257 | port->icount.tx++; |
| 258 | } |
| 259 | |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 260 | iowrite32_rep(tf, buf, 1); |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 261 | xmit->tail = (xmit->tail + num_chars) & (UART_XMIT_SIZE - 1); |
| 262 | tf_pointer += num_chars; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 263 | } |
| 264 | |
Stephen Boyd | 17fae28 | 2013-07-24 11:37:31 -0700 | [diff] [blame] | 265 | /* disable tx interrupts if nothing more to send */ |
| 266 | if (uart_circ_empty(xmit)) |
| 267 | msm_stop_tx(port); |
| 268 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 269 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
| 270 | uart_write_wakeup(port); |
| 271 | } |
| 272 | |
| 273 | static void handle_delta_cts(struct uart_port *port) |
| 274 | { |
| 275 | msm_write(port, UART_CR_CMD_RESET_CTS, UART_CR); |
| 276 | port->icount.cts++; |
Alan Cox | bdc04e3 | 2009-09-19 13:13:31 -0700 | [diff] [blame] | 277 | wake_up_interruptible(&port->state->port.delta_msr_wait); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static irqreturn_t msm_irq(int irq, void *dev_id) |
| 281 | { |
| 282 | struct uart_port *port = dev_id; |
| 283 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 284 | unsigned int misr; |
| 285 | |
| 286 | spin_lock(&port->lock); |
| 287 | misr = msm_read(port, UART_MISR); |
| 288 | msm_write(port, 0, UART_IMR); /* disable interrupt */ |
| 289 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 290 | if (misr & (UART_IMR_RXLEV | UART_IMR_RXSTALE)) { |
| 291 | if (msm_port->is_uartdm) |
| 292 | handle_rx_dm(port, misr); |
| 293 | else |
| 294 | handle_rx(port); |
| 295 | } |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 296 | if (misr & UART_IMR_TXLEV) |
| 297 | handle_tx(port); |
| 298 | if (misr & UART_IMR_DELTA_CTS) |
| 299 | handle_delta_cts(port); |
| 300 | |
| 301 | msm_write(port, msm_port->imr, UART_IMR); /* restore interrupt */ |
| 302 | spin_unlock(&port->lock); |
| 303 | |
| 304 | return IRQ_HANDLED; |
| 305 | } |
| 306 | |
| 307 | static unsigned int msm_tx_empty(struct uart_port *port) |
| 308 | { |
| 309 | return (msm_read(port, UART_SR) & UART_SR_TX_EMPTY) ? TIOCSER_TEMT : 0; |
| 310 | } |
| 311 | |
| 312 | static unsigned int msm_get_mctrl(struct uart_port *port) |
| 313 | { |
| 314 | return TIOCM_CAR | TIOCM_CTS | TIOCM_DSR | TIOCM_RTS; |
| 315 | } |
| 316 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 317 | |
| 318 | static void msm_reset(struct uart_port *port) |
| 319 | { |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 320 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 321 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 322 | /* reset everything */ |
| 323 | msm_write(port, UART_CR_CMD_RESET_RX, UART_CR); |
| 324 | msm_write(port, UART_CR_CMD_RESET_TX, UART_CR); |
| 325 | msm_write(port, UART_CR_CMD_RESET_ERR, UART_CR); |
| 326 | msm_write(port, UART_CR_CMD_RESET_BREAK_INT, UART_CR); |
| 327 | msm_write(port, UART_CR_CMD_RESET_CTS, UART_CR); |
| 328 | msm_write(port, UART_CR_CMD_SET_RFR, UART_CR); |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 329 | |
| 330 | /* Disable DM modes */ |
| 331 | if (msm_port->is_uartdm) |
| 332 | msm_write(port, 0, UARTDM_DMEN); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 333 | } |
| 334 | |
Stephen Boyd | f8fb952 | 2013-07-24 11:37:29 -0700 | [diff] [blame] | 335 | static void msm_set_mctrl(struct uart_port *port, unsigned int mctrl) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 336 | { |
| 337 | unsigned int mr; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 338 | mr = msm_read(port, UART_MR1); |
| 339 | |
| 340 | if (!(mctrl & TIOCM_RTS)) { |
| 341 | mr &= ~UART_MR1_RX_RDY_CTL; |
| 342 | msm_write(port, mr, UART_MR1); |
| 343 | msm_write(port, UART_CR_CMD_RESET_RFR, UART_CR); |
| 344 | } else { |
| 345 | mr |= UART_MR1_RX_RDY_CTL; |
| 346 | msm_write(port, mr, UART_MR1); |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | static void msm_break_ctl(struct uart_port *port, int break_ctl) |
| 351 | { |
| 352 | if (break_ctl) |
| 353 | msm_write(port, UART_CR_CMD_START_BREAK, UART_CR); |
| 354 | else |
| 355 | msm_write(port, UART_CR_CMD_STOP_BREAK, UART_CR); |
| 356 | } |
| 357 | |
Stephen Boyd | 6909dad | 2013-07-24 11:37:30 -0700 | [diff] [blame] | 358 | struct msm_baud_map { |
| 359 | u16 divisor; |
| 360 | u8 code; |
| 361 | u8 rxstale; |
| 362 | }; |
| 363 | |
| 364 | static const struct msm_baud_map * |
| 365 | msm_find_best_baud(struct uart_port *port, unsigned int baud) |
| 366 | { |
| 367 | unsigned int i, divisor; |
| 368 | const struct msm_baud_map *entry; |
| 369 | static const struct msm_baud_map table[] = { |
| 370 | { 1536, 0x00, 1 }, |
| 371 | { 768, 0x11, 1 }, |
| 372 | { 384, 0x22, 1 }, |
| 373 | { 192, 0x33, 1 }, |
| 374 | { 96, 0x44, 1 }, |
| 375 | { 48, 0x55, 1 }, |
| 376 | { 32, 0x66, 1 }, |
| 377 | { 24, 0x77, 1 }, |
| 378 | { 16, 0x88, 1 }, |
| 379 | { 12, 0x99, 6 }, |
| 380 | { 8, 0xaa, 6 }, |
| 381 | { 6, 0xbb, 6 }, |
| 382 | { 4, 0xcc, 6 }, |
| 383 | { 3, 0xdd, 8 }, |
| 384 | { 2, 0xee, 16 }, |
| 385 | { 1, 0xff, 31 }, |
| 386 | }; |
| 387 | |
| 388 | divisor = uart_get_divisor(port, baud); |
| 389 | |
| 390 | for (i = 0, entry = table; i < ARRAY_SIZE(table); i++, entry++) |
| 391 | if (entry->divisor <= divisor) |
| 392 | break; |
| 393 | |
| 394 | return entry; /* Default to smallest divider */ |
| 395 | } |
| 396 | |
Alan Cox | 44da59e | 2009-06-22 18:43:18 +0100 | [diff] [blame] | 397 | static int msm_set_baud_rate(struct uart_port *port, unsigned int baud) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 398 | { |
Stephen Boyd | 6909dad | 2013-07-24 11:37:30 -0700 | [diff] [blame] | 399 | unsigned int rxstale, watermark; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 400 | struct msm_port *msm_port = UART_TO_MSM(port); |
Stephen Boyd | 6909dad | 2013-07-24 11:37:30 -0700 | [diff] [blame] | 401 | const struct msm_baud_map *entry; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 402 | |
Stephen Boyd | 6909dad | 2013-07-24 11:37:30 -0700 | [diff] [blame] | 403 | entry = msm_find_best_baud(port, baud); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 404 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 405 | if (msm_port->is_uartdm) |
| 406 | msm_write(port, UART_CR_CMD_RESET_RX, UART_CR); |
| 407 | |
Stephen Boyd | 6909dad | 2013-07-24 11:37:30 -0700 | [diff] [blame] | 408 | msm_write(port, entry->code, UART_CSR); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 409 | |
| 410 | /* RX stale watermark */ |
Stephen Boyd | 6909dad | 2013-07-24 11:37:30 -0700 | [diff] [blame] | 411 | rxstale = entry->rxstale; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 412 | watermark = UART_IPR_STALE_LSB & rxstale; |
| 413 | watermark |= UART_IPR_RXSTALE_LAST; |
| 414 | watermark |= UART_IPR_STALE_TIMEOUT_MSB & (rxstale << 2); |
| 415 | msm_write(port, watermark, UART_IPR); |
| 416 | |
| 417 | /* set RX watermark */ |
| 418 | watermark = (port->fifosize * 3) / 4; |
| 419 | msm_write(port, watermark, UART_RFWR); |
| 420 | |
| 421 | /* set TX watermark */ |
| 422 | msm_write(port, 10, UART_TFWR); |
Alan Cox | 44da59e | 2009-06-22 18:43:18 +0100 | [diff] [blame] | 423 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 424 | if (msm_port->is_uartdm) { |
| 425 | msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); |
| 426 | msm_write(port, 0xFFFFFF, UARTDM_DMRX); |
| 427 | msm_write(port, UART_CR_CMD_STALE_EVENT_ENABLE, UART_CR); |
| 428 | } |
| 429 | |
Alan Cox | 44da59e | 2009-06-22 18:43:18 +0100 | [diff] [blame] | 430 | return baud; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 431 | } |
| 432 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 433 | |
| 434 | static void msm_init_clock(struct uart_port *port) |
| 435 | { |
| 436 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 437 | |
Stephen Boyd | f98cf83 | 2013-06-17 10:43:08 -0700 | [diff] [blame] | 438 | clk_prepare_enable(msm_port->clk); |
Stephen Boyd | bfaddb7 | 2013-08-20 23:48:02 -0700 | [diff] [blame] | 439 | clk_prepare_enable(msm_port->pclk); |
Abhijeet Dharmapurikar | 18c79d7 | 2010-05-20 15:20:23 -0700 | [diff] [blame] | 440 | msm_serial_set_mnd_regs(port); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 441 | } |
| 442 | |
| 443 | static int msm_startup(struct uart_port *port) |
| 444 | { |
| 445 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 446 | unsigned int data, rfr_level; |
| 447 | int ret; |
| 448 | |
| 449 | snprintf(msm_port->name, sizeof(msm_port->name), |
| 450 | "msm_serial%d", port->line); |
| 451 | |
| 452 | ret = request_irq(port->irq, msm_irq, IRQF_TRIGGER_HIGH, |
| 453 | msm_port->name, port); |
| 454 | if (unlikely(ret)) |
| 455 | return ret; |
| 456 | |
| 457 | msm_init_clock(port); |
| 458 | |
| 459 | if (likely(port->fifosize > 12)) |
| 460 | rfr_level = port->fifosize - 12; |
| 461 | else |
| 462 | rfr_level = port->fifosize; |
| 463 | |
| 464 | /* set automatic RFR level */ |
| 465 | data = msm_read(port, UART_MR1); |
| 466 | data &= ~UART_MR1_AUTO_RFR_LEVEL1; |
| 467 | data &= ~UART_MR1_AUTO_RFR_LEVEL0; |
| 468 | data |= UART_MR1_AUTO_RFR_LEVEL1 & (rfr_level << 2); |
| 469 | data |= UART_MR1_AUTO_RFR_LEVEL0 & rfr_level; |
| 470 | msm_write(port, data, UART_MR1); |
| 471 | |
| 472 | /* make sure that RXSTALE count is non-zero */ |
| 473 | data = msm_read(port, UART_IPR); |
| 474 | if (unlikely(!data)) { |
| 475 | data |= UART_IPR_RXSTALE_LAST; |
| 476 | data |= UART_IPR_STALE_LSB; |
| 477 | msm_write(port, data, UART_IPR); |
| 478 | } |
| 479 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 480 | data = 0; |
| 481 | if (!port->cons || (port->cons && !(port->cons->flags & CON_ENABLED))) { |
| 482 | msm_write(port, UART_CR_CMD_PROTECTION_EN, UART_CR); |
| 483 | msm_reset(port); |
| 484 | data = UART_CR_TX_ENABLE; |
| 485 | } |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 486 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 487 | data |= UART_CR_RX_ENABLE; |
| 488 | msm_write(port, data, UART_CR); /* enable TX & RX */ |
| 489 | |
| 490 | /* Make sure IPR is not 0 to start with*/ |
| 491 | if (msm_port->is_uartdm) |
| 492 | msm_write(port, UART_IPR_STALE_LSB, UART_IPR); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 493 | |
| 494 | /* turn on RX and CTS interrupts */ |
| 495 | msm_port->imr = UART_IMR_RXLEV | UART_IMR_RXSTALE | |
| 496 | UART_IMR_CURRENT_CTS; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 497 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 498 | if (msm_port->is_uartdm) { |
| 499 | msm_write(port, 0xFFFFFF, UARTDM_DMRX); |
| 500 | msm_write(port, UART_CR_CMD_RESET_STALE_INT, UART_CR); |
| 501 | msm_write(port, UART_CR_CMD_STALE_EVENT_ENABLE, UART_CR); |
| 502 | } |
| 503 | |
| 504 | msm_write(port, msm_port->imr, UART_IMR); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | static void msm_shutdown(struct uart_port *port) |
| 509 | { |
| 510 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 511 | |
| 512 | msm_port->imr = 0; |
| 513 | msm_write(port, 0, UART_IMR); /* disable interrupts */ |
| 514 | |
Stephen Boyd | f98cf83 | 2013-06-17 10:43:08 -0700 | [diff] [blame] | 515 | clk_disable_unprepare(msm_port->clk); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 516 | |
| 517 | free_irq(port->irq, port); |
| 518 | } |
| 519 | |
| 520 | static void msm_set_termios(struct uart_port *port, struct ktermios *termios, |
| 521 | struct ktermios *old) |
| 522 | { |
| 523 | unsigned long flags; |
| 524 | unsigned int baud, mr; |
| 525 | |
| 526 | spin_lock_irqsave(&port->lock, flags); |
| 527 | |
| 528 | /* calculate and set baud rate */ |
| 529 | baud = uart_get_baud_rate(port, termios, old, 300, 115200); |
Alan Cox | 44da59e | 2009-06-22 18:43:18 +0100 | [diff] [blame] | 530 | baud = msm_set_baud_rate(port, baud); |
| 531 | if (tty_termios_baud_rate(termios)) |
| 532 | tty_termios_encode_baud_rate(termios, baud, baud); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 533 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 534 | /* calculate parity */ |
| 535 | mr = msm_read(port, UART_MR2); |
| 536 | mr &= ~UART_MR2_PARITY_MODE; |
| 537 | if (termios->c_cflag & PARENB) { |
| 538 | if (termios->c_cflag & PARODD) |
| 539 | mr |= UART_MR2_PARITY_MODE_ODD; |
| 540 | else if (termios->c_cflag & CMSPAR) |
| 541 | mr |= UART_MR2_PARITY_MODE_SPACE; |
| 542 | else |
| 543 | mr |= UART_MR2_PARITY_MODE_EVEN; |
| 544 | } |
| 545 | |
| 546 | /* calculate bits per char */ |
| 547 | mr &= ~UART_MR2_BITS_PER_CHAR; |
| 548 | switch (termios->c_cflag & CSIZE) { |
| 549 | case CS5: |
| 550 | mr |= UART_MR2_BITS_PER_CHAR_5; |
| 551 | break; |
| 552 | case CS6: |
| 553 | mr |= UART_MR2_BITS_PER_CHAR_6; |
| 554 | break; |
| 555 | case CS7: |
| 556 | mr |= UART_MR2_BITS_PER_CHAR_7; |
| 557 | break; |
| 558 | case CS8: |
| 559 | default: |
| 560 | mr |= UART_MR2_BITS_PER_CHAR_8; |
| 561 | break; |
| 562 | } |
| 563 | |
| 564 | /* calculate stop bits */ |
| 565 | mr &= ~(UART_MR2_STOP_BIT_LEN_ONE | UART_MR2_STOP_BIT_LEN_TWO); |
| 566 | if (termios->c_cflag & CSTOPB) |
| 567 | mr |= UART_MR2_STOP_BIT_LEN_TWO; |
| 568 | else |
| 569 | mr |= UART_MR2_STOP_BIT_LEN_ONE; |
| 570 | |
| 571 | /* set parity, bits per char, and stop bit */ |
| 572 | msm_write(port, mr, UART_MR2); |
| 573 | |
| 574 | /* calculate and set hardware flow control */ |
| 575 | mr = msm_read(port, UART_MR1); |
| 576 | mr &= ~(UART_MR1_CTS_CTL | UART_MR1_RX_RDY_CTL); |
| 577 | if (termios->c_cflag & CRTSCTS) { |
| 578 | mr |= UART_MR1_CTS_CTL; |
| 579 | mr |= UART_MR1_RX_RDY_CTL; |
| 580 | } |
| 581 | msm_write(port, mr, UART_MR1); |
| 582 | |
| 583 | /* Configure status bits to ignore based on termio flags. */ |
| 584 | port->read_status_mask = 0; |
| 585 | if (termios->c_iflag & INPCK) |
| 586 | port->read_status_mask |= UART_SR_PAR_FRAME_ERR; |
Peter Hurley | ef8b9dd | 2014-06-16 08:10:41 -0400 | [diff] [blame] | 587 | if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK)) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 588 | port->read_status_mask |= UART_SR_RX_BREAK; |
| 589 | |
| 590 | uart_update_timeout(port, termios->c_cflag, baud); |
| 591 | |
| 592 | spin_unlock_irqrestore(&port->lock, flags); |
| 593 | } |
| 594 | |
| 595 | static const char *msm_type(struct uart_port *port) |
| 596 | { |
| 597 | return "MSM"; |
| 598 | } |
| 599 | |
| 600 | static void msm_release_port(struct uart_port *port) |
| 601 | { |
| 602 | struct platform_device *pdev = to_platform_device(port->dev); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 603 | struct resource *uart_resource; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 604 | resource_size_t size; |
| 605 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 606 | uart_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 607 | if (unlikely(!uart_resource)) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 608 | return; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 609 | size = resource_size(uart_resource); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 610 | |
| 611 | release_mem_region(port->mapbase, size); |
| 612 | iounmap(port->membase); |
| 613 | port->membase = NULL; |
| 614 | } |
| 615 | |
| 616 | static int msm_request_port(struct uart_port *port) |
| 617 | { |
| 618 | struct platform_device *pdev = to_platform_device(port->dev); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 619 | struct resource *uart_resource; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 620 | resource_size_t size; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 621 | int ret; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 622 | |
David Brown | 886a451 | 2011-08-02 09:02:49 -0700 | [diff] [blame] | 623 | uart_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 624 | if (unlikely(!uart_resource)) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 625 | return -ENXIO; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 626 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 627 | size = resource_size(uart_resource); |
| 628 | |
| 629 | if (!request_mem_region(port->mapbase, size, "msm_serial")) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 630 | return -EBUSY; |
| 631 | |
| 632 | port->membase = ioremap(port->mapbase, size); |
| 633 | if (!port->membase) { |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 634 | ret = -EBUSY; |
| 635 | goto fail_release_port; |
| 636 | } |
| 637 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 638 | return 0; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 639 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 640 | fail_release_port: |
| 641 | release_mem_region(port->mapbase, size); |
| 642 | return ret; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | static void msm_config_port(struct uart_port *port, int flags) |
| 646 | { |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 647 | int ret; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 648 | if (flags & UART_CONFIG_TYPE) { |
| 649 | port->type = PORT_MSM; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 650 | ret = msm_request_port(port); |
| 651 | if (ret) |
| 652 | return; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 653 | } |
| 654 | } |
| 655 | |
| 656 | static int msm_verify_port(struct uart_port *port, struct serial_struct *ser) |
| 657 | { |
| 658 | if (unlikely(ser->type != PORT_UNKNOWN && ser->type != PORT_MSM)) |
| 659 | return -EINVAL; |
| 660 | if (unlikely(port->irq != ser->irq)) |
| 661 | return -EINVAL; |
| 662 | return 0; |
| 663 | } |
| 664 | |
| 665 | static void msm_power(struct uart_port *port, unsigned int state, |
| 666 | unsigned int oldstate) |
| 667 | { |
| 668 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 669 | |
| 670 | switch (state) { |
| 671 | case 0: |
Stephen Boyd | f98cf83 | 2013-06-17 10:43:08 -0700 | [diff] [blame] | 672 | clk_prepare_enable(msm_port->clk); |
Stephen Boyd | bfaddb7 | 2013-08-20 23:48:02 -0700 | [diff] [blame] | 673 | clk_prepare_enable(msm_port->pclk); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 674 | break; |
| 675 | case 3: |
Stephen Boyd | f98cf83 | 2013-06-17 10:43:08 -0700 | [diff] [blame] | 676 | clk_disable_unprepare(msm_port->clk); |
Stephen Boyd | bfaddb7 | 2013-08-20 23:48:02 -0700 | [diff] [blame] | 677 | clk_disable_unprepare(msm_port->pclk); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 678 | break; |
| 679 | default: |
| 680 | printk(KERN_ERR "msm_serial: Unknown PM state %d\n", state); |
| 681 | } |
| 682 | } |
| 683 | |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 684 | #ifdef CONFIG_CONSOLE_POLL |
| 685 | static int msm_poll_init(struct uart_port *port) |
| 686 | { |
| 687 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 688 | |
| 689 | /* Enable single character mode on RX FIFO */ |
| 690 | if (msm_port->is_uartdm >= UARTDM_1P4) |
| 691 | msm_write(port, UARTDM_DMEN_RX_SC_ENABLE, UARTDM_DMEN); |
| 692 | |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | static int msm_poll_get_char_single(struct uart_port *port) |
| 697 | { |
| 698 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 699 | unsigned int rf_reg = msm_port->is_uartdm ? UARTDM_RF : UART_RF; |
| 700 | |
| 701 | if (!(msm_read(port, UART_SR) & UART_SR_RX_READY)) |
| 702 | return NO_POLL_CHAR; |
| 703 | else |
| 704 | return msm_read(port, rf_reg) & 0xff; |
| 705 | } |
| 706 | |
| 707 | static int msm_poll_get_char_dm_1p3(struct uart_port *port) |
| 708 | { |
| 709 | int c; |
| 710 | static u32 slop; |
| 711 | static int count; |
| 712 | unsigned char *sp = (unsigned char *)&slop; |
| 713 | |
| 714 | /* Check if a previous read had more than one char */ |
| 715 | if (count) { |
| 716 | c = sp[sizeof(slop) - count]; |
| 717 | count--; |
| 718 | /* Or if FIFO is empty */ |
| 719 | } else if (!(msm_read(port, UART_SR) & UART_SR_RX_READY)) { |
| 720 | /* |
| 721 | * If RX packing buffer has less than a word, force stale to |
| 722 | * push contents into RX FIFO |
| 723 | */ |
| 724 | count = msm_read(port, UARTDM_RXFS); |
| 725 | count = (count >> UARTDM_RXFS_BUF_SHIFT) & UARTDM_RXFS_BUF_MASK; |
| 726 | if (count) { |
| 727 | msm_write(port, UART_CR_CMD_FORCE_STALE, UART_CR); |
| 728 | slop = msm_read(port, UARTDM_RF); |
| 729 | c = sp[0]; |
| 730 | count--; |
| 731 | } else { |
| 732 | c = NO_POLL_CHAR; |
| 733 | } |
| 734 | /* FIFO has a word */ |
| 735 | } else { |
| 736 | slop = msm_read(port, UARTDM_RF); |
| 737 | c = sp[0]; |
| 738 | count = sizeof(slop) - 1; |
| 739 | } |
| 740 | |
| 741 | return c; |
| 742 | } |
| 743 | |
| 744 | static int msm_poll_get_char(struct uart_port *port) |
| 745 | { |
| 746 | u32 imr; |
| 747 | int c; |
| 748 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 749 | |
| 750 | /* Disable all interrupts */ |
| 751 | imr = msm_read(port, UART_IMR); |
| 752 | msm_write(port, 0, UART_IMR); |
| 753 | |
| 754 | if (msm_port->is_uartdm == UARTDM_1P3) |
| 755 | c = msm_poll_get_char_dm_1p3(port); |
| 756 | else |
| 757 | c = msm_poll_get_char_single(port); |
| 758 | |
| 759 | /* Enable interrupts */ |
| 760 | msm_write(port, imr, UART_IMR); |
| 761 | |
| 762 | return c; |
| 763 | } |
| 764 | |
| 765 | static void msm_poll_put_char(struct uart_port *port, unsigned char c) |
| 766 | { |
| 767 | u32 imr; |
| 768 | struct msm_port *msm_port = UART_TO_MSM(port); |
| 769 | |
| 770 | /* Disable all interrupts */ |
| 771 | imr = msm_read(port, UART_IMR); |
| 772 | msm_write(port, 0, UART_IMR); |
| 773 | |
| 774 | if (msm_port->is_uartdm) |
| 775 | reset_dm_count(port, 1); |
| 776 | |
| 777 | /* Wait until FIFO is empty */ |
| 778 | while (!(msm_read(port, UART_SR) & UART_SR_TX_READY)) |
| 779 | cpu_relax(); |
| 780 | |
| 781 | /* Write a character */ |
| 782 | msm_write(port, c, msm_port->is_uartdm ? UARTDM_TF : UART_TF); |
| 783 | |
| 784 | /* Wait until FIFO is empty */ |
| 785 | while (!(msm_read(port, UART_SR) & UART_SR_TX_READY)) |
| 786 | cpu_relax(); |
| 787 | |
| 788 | /* Enable interrupts */ |
| 789 | msm_write(port, imr, UART_IMR); |
| 790 | |
| 791 | return; |
| 792 | } |
| 793 | #endif |
| 794 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 795 | static struct uart_ops msm_uart_pops = { |
| 796 | .tx_empty = msm_tx_empty, |
| 797 | .set_mctrl = msm_set_mctrl, |
| 798 | .get_mctrl = msm_get_mctrl, |
| 799 | .stop_tx = msm_stop_tx, |
| 800 | .start_tx = msm_start_tx, |
| 801 | .stop_rx = msm_stop_rx, |
| 802 | .enable_ms = msm_enable_ms, |
| 803 | .break_ctl = msm_break_ctl, |
| 804 | .startup = msm_startup, |
| 805 | .shutdown = msm_shutdown, |
| 806 | .set_termios = msm_set_termios, |
| 807 | .type = msm_type, |
| 808 | .release_port = msm_release_port, |
| 809 | .request_port = msm_request_port, |
| 810 | .config_port = msm_config_port, |
| 811 | .verify_port = msm_verify_port, |
| 812 | .pm = msm_power, |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 813 | #ifdef CONFIG_CONSOLE_POLL |
| 814 | .poll_init = msm_poll_init, |
| 815 | .poll_get_char = msm_poll_get_char, |
| 816 | .poll_put_char = msm_poll_put_char, |
| 817 | #endif |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 818 | }; |
| 819 | |
| 820 | static struct msm_port msm_uart_ports[] = { |
| 821 | { |
| 822 | .uart = { |
| 823 | .iotype = UPIO_MEM, |
| 824 | .ops = &msm_uart_pops, |
| 825 | .flags = UPF_BOOT_AUTOCONF, |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 826 | .fifosize = 64, |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 827 | .line = 0, |
| 828 | }, |
| 829 | }, |
| 830 | { |
| 831 | .uart = { |
| 832 | .iotype = UPIO_MEM, |
| 833 | .ops = &msm_uart_pops, |
| 834 | .flags = UPF_BOOT_AUTOCONF, |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 835 | .fifosize = 64, |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 836 | .line = 1, |
| 837 | }, |
| 838 | }, |
| 839 | { |
| 840 | .uart = { |
| 841 | .iotype = UPIO_MEM, |
| 842 | .ops = &msm_uart_pops, |
| 843 | .flags = UPF_BOOT_AUTOCONF, |
| 844 | .fifosize = 64, |
| 845 | .line = 2, |
| 846 | }, |
| 847 | }, |
| 848 | }; |
| 849 | |
| 850 | #define UART_NR ARRAY_SIZE(msm_uart_ports) |
| 851 | |
| 852 | static inline struct uart_port *get_port_from_line(unsigned int line) |
| 853 | { |
| 854 | return &msm_uart_ports[line].uart; |
| 855 | } |
| 856 | |
| 857 | #ifdef CONFIG_SERIAL_MSM_CONSOLE |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 858 | static void msm_console_write(struct console *co, const char *s, |
| 859 | unsigned int count) |
| 860 | { |
Stephen Boyd | a3957e8 | 2013-08-20 23:48:06 -0700 | [diff] [blame] | 861 | int i; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 862 | struct uart_port *port; |
| 863 | struct msm_port *msm_port; |
Stephen Boyd | a3957e8 | 2013-08-20 23:48:06 -0700 | [diff] [blame] | 864 | int num_newlines = 0; |
| 865 | bool replaced = false; |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 866 | void __iomem *tf; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 867 | |
| 868 | BUG_ON(co->index < 0 || co->index >= UART_NR); |
| 869 | |
| 870 | port = get_port_from_line(co->index); |
| 871 | msm_port = UART_TO_MSM(port); |
| 872 | |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 873 | if (msm_port->is_uartdm) |
| 874 | tf = port->membase + UARTDM_TF; |
| 875 | else |
| 876 | tf = port->membase + UART_TF; |
| 877 | |
Stephen Boyd | a3957e8 | 2013-08-20 23:48:06 -0700 | [diff] [blame] | 878 | /* Account for newlines that will get a carriage return added */ |
| 879 | for (i = 0; i < count; i++) |
| 880 | if (s[i] == '\n') |
| 881 | num_newlines++; |
| 882 | count += num_newlines; |
| 883 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 884 | spin_lock(&port->lock); |
Stephen Boyd | a3957e8 | 2013-08-20 23:48:06 -0700 | [diff] [blame] | 885 | if (msm_port->is_uartdm) |
| 886 | reset_dm_count(port, count); |
| 887 | |
| 888 | i = 0; |
| 889 | while (i < count) { |
| 890 | int j; |
| 891 | unsigned int num_chars; |
| 892 | char buf[4] = { 0 }; |
Stephen Boyd | a3957e8 | 2013-08-20 23:48:06 -0700 | [diff] [blame] | 893 | |
| 894 | if (msm_port->is_uartdm) |
| 895 | num_chars = min(count - i, (unsigned int)sizeof(buf)); |
| 896 | else |
| 897 | num_chars = 1; |
| 898 | |
| 899 | for (j = 0; j < num_chars; j++) { |
| 900 | char c = *s; |
| 901 | |
| 902 | if (c == '\n' && !replaced) { |
| 903 | buf[j] = '\r'; |
| 904 | j++; |
| 905 | replaced = true; |
| 906 | } |
| 907 | if (j < num_chars) { |
| 908 | buf[j] = c; |
| 909 | s++; |
| 910 | replaced = false; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | while (!(msm_read(port, UART_SR) & UART_SR_TX_READY)) |
| 915 | cpu_relax(); |
| 916 | |
Stephen Boyd | 6825242 | 2014-06-30 14:54:01 -0700 | [diff] [blame] | 917 | iowrite32_rep(tf, buf, 1); |
Stephen Boyd | a3957e8 | 2013-08-20 23:48:06 -0700 | [diff] [blame] | 918 | i += num_chars; |
| 919 | } |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 920 | spin_unlock(&port->lock); |
| 921 | } |
| 922 | |
| 923 | static int __init msm_console_setup(struct console *co, char *options) |
| 924 | { |
| 925 | struct uart_port *port; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 926 | struct msm_port *msm_port; |
Rickard Strandqvist | 2b844ad | 2014-06-01 15:38:24 +0200 | [diff] [blame] | 927 | int baud = 0, flow, bits, parity; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 928 | |
| 929 | if (unlikely(co->index >= UART_NR || co->index < 0)) |
| 930 | return -ENXIO; |
| 931 | |
| 932 | port = get_port_from_line(co->index); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 933 | msm_port = UART_TO_MSM(port); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 934 | |
| 935 | if (unlikely(!port->membase)) |
| 936 | return -ENXIO; |
| 937 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 938 | msm_init_clock(port); |
| 939 | |
| 940 | if (options) |
| 941 | uart_parse_options(options, &baud, &parity, &bits, &flow); |
| 942 | |
| 943 | bits = 8; |
| 944 | parity = 'n'; |
| 945 | flow = 'n'; |
| 946 | msm_write(port, UART_MR2_BITS_PER_CHAR_8 | UART_MR2_STOP_BIT_LEN_ONE, |
| 947 | UART_MR2); /* 8N1 */ |
| 948 | |
| 949 | if (baud < 300 || baud > 115200) |
| 950 | baud = 115200; |
| 951 | msm_set_baud_rate(port, baud); |
| 952 | |
| 953 | msm_reset(port); |
| 954 | |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 955 | if (msm_port->is_uartdm) { |
| 956 | msm_write(port, UART_CR_CMD_PROTECTION_EN, UART_CR); |
| 957 | msm_write(port, UART_CR_TX_ENABLE, UART_CR); |
| 958 | } |
| 959 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 960 | printk(KERN_INFO "msm_serial: console setup on port #%d\n", port->line); |
| 961 | |
| 962 | return uart_set_options(port, co, baud, parity, bits, flow); |
| 963 | } |
| 964 | |
| 965 | static struct uart_driver msm_uart_driver; |
| 966 | |
| 967 | static struct console msm_console = { |
| 968 | .name = "ttyMSM", |
| 969 | .write = msm_console_write, |
| 970 | .device = uart_console_device, |
| 971 | .setup = msm_console_setup, |
| 972 | .flags = CON_PRINTBUFFER, |
| 973 | .index = -1, |
| 974 | .data = &msm_uart_driver, |
| 975 | }; |
| 976 | |
| 977 | #define MSM_CONSOLE (&msm_console) |
| 978 | |
| 979 | #else |
| 980 | #define MSM_CONSOLE NULL |
| 981 | #endif |
| 982 | |
| 983 | static struct uart_driver msm_uart_driver = { |
| 984 | .owner = THIS_MODULE, |
| 985 | .driver_name = "msm_serial", |
| 986 | .dev_name = "ttyMSM", |
| 987 | .nr = UART_NR, |
| 988 | .cons = MSM_CONSOLE, |
| 989 | }; |
| 990 | |
David Brown | cfdad2a | 2011-08-04 01:55:24 -0700 | [diff] [blame] | 991 | static atomic_t msm_uart_next_id = ATOMIC_INIT(0); |
| 992 | |
Stephen Boyd | c3b5d3b | 2013-08-20 23:48:04 -0700 | [diff] [blame] | 993 | static const struct of_device_id msm_uartdm_table[] = { |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 994 | { .compatible = "qcom,msm-uartdm-v1.1", .data = (void *)UARTDM_1P1 }, |
| 995 | { .compatible = "qcom,msm-uartdm-v1.2", .data = (void *)UARTDM_1P2 }, |
| 996 | { .compatible = "qcom,msm-uartdm-v1.3", .data = (void *)UARTDM_1P3 }, |
| 997 | { .compatible = "qcom,msm-uartdm-v1.4", .data = (void *)UARTDM_1P4 }, |
Stephen Boyd | c3b5d3b | 2013-08-20 23:48:04 -0700 | [diff] [blame] | 998 | { } |
| 999 | }; |
| 1000 | |
Kumar Gala | 4cc2946 | 2014-06-03 15:13:22 -0500 | [diff] [blame] | 1001 | static int msm_serial_probe(struct platform_device *pdev) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1002 | { |
| 1003 | struct msm_port *msm_port; |
| 1004 | struct resource *resource; |
| 1005 | struct uart_port *port; |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 1006 | const struct of_device_id *id; |
Roel Kluin | 1e09175 | 2009-12-21 16:26:49 -0800 | [diff] [blame] | 1007 | int irq; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1008 | |
David Brown | cfdad2a | 2011-08-04 01:55:24 -0700 | [diff] [blame] | 1009 | if (pdev->id == -1) |
| 1010 | pdev->id = atomic_inc_return(&msm_uart_next_id) - 1; |
| 1011 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1012 | if (unlikely(pdev->id < 0 || pdev->id >= UART_NR)) |
| 1013 | return -ENXIO; |
| 1014 | |
| 1015 | printk(KERN_INFO "msm_serial: detected port #%d\n", pdev->id); |
| 1016 | |
| 1017 | port = get_port_from_line(pdev->id); |
| 1018 | port->dev = &pdev->dev; |
| 1019 | msm_port = UART_TO_MSM(port); |
| 1020 | |
Stephen Boyd | f7e54d7 | 2014-01-14 12:34:55 -0800 | [diff] [blame] | 1021 | id = of_match_device(msm_uartdm_table, &pdev->dev); |
| 1022 | if (id) |
| 1023 | msm_port->is_uartdm = (unsigned long)id->data; |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 1024 | else |
| 1025 | msm_port->is_uartdm = 0; |
| 1026 | |
Stephen Boyd | bfaddb7 | 2013-08-20 23:48:02 -0700 | [diff] [blame] | 1027 | msm_port->clk = devm_clk_get(&pdev->dev, "core"); |
Stephen Boyd | 519b371 | 2013-06-17 10:43:09 -0700 | [diff] [blame] | 1028 | if (IS_ERR(msm_port->clk)) |
| 1029 | return PTR_ERR(msm_port->clk); |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 1030 | |
Stephen Boyd | 519b371 | 2013-06-17 10:43:09 -0700 | [diff] [blame] | 1031 | if (msm_port->is_uartdm) { |
Stephen Boyd | bfaddb7 | 2013-08-20 23:48:02 -0700 | [diff] [blame] | 1032 | msm_port->pclk = devm_clk_get(&pdev->dev, "iface"); |
Stephen Boyd | 519b371 | 2013-06-17 10:43:09 -0700 | [diff] [blame] | 1033 | if (IS_ERR(msm_port->pclk)) |
| 1034 | return PTR_ERR(msm_port->pclk); |
| 1035 | |
David Brown | 7b6031a | 2012-09-07 14:45:03 -0700 | [diff] [blame] | 1036 | clk_set_rate(msm_port->clk, 1843200); |
Stephen Boyd | 519b371 | 2013-06-17 10:43:09 -0700 | [diff] [blame] | 1037 | } |
Stepan Moskovchenko | ec8f29e | 2010-12-21 12:38:05 -0800 | [diff] [blame] | 1038 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1039 | port->uartclk = clk_get_rate(msm_port->clk); |
Abhijeet Dharmapurikar | 18c79d7 | 2010-05-20 15:20:23 -0700 | [diff] [blame] | 1040 | printk(KERN_INFO "uartclk = %d\n", port->uartclk); |
| 1041 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1042 | |
David Brown | 886a451 | 2011-08-02 09:02:49 -0700 | [diff] [blame] | 1043 | resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1044 | if (unlikely(!resource)) |
| 1045 | return -ENXIO; |
| 1046 | port->mapbase = resource->start; |
| 1047 | |
Roel Kluin | 1e09175 | 2009-12-21 16:26:49 -0800 | [diff] [blame] | 1048 | irq = platform_get_irq(pdev, 0); |
| 1049 | if (unlikely(irq < 0)) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1050 | return -ENXIO; |
Roel Kluin | 1e09175 | 2009-12-21 16:26:49 -0800 | [diff] [blame] | 1051 | port->irq = irq; |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1052 | |
| 1053 | platform_set_drvdata(pdev, port); |
| 1054 | |
| 1055 | return uart_add_one_port(&msm_uart_driver, port); |
| 1056 | } |
| 1057 | |
Bill Pemberton | ae8d8a1 | 2012-11-19 13:26:18 -0500 | [diff] [blame] | 1058 | static int msm_serial_remove(struct platform_device *pdev) |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1059 | { |
Stephen Boyd | 519b371 | 2013-06-17 10:43:09 -0700 | [diff] [blame] | 1060 | struct uart_port *port = platform_get_drvdata(pdev); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1061 | |
Stephen Boyd | 519b371 | 2013-06-17 10:43:09 -0700 | [diff] [blame] | 1062 | uart_remove_one_port(&msm_uart_driver, port); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1063 | |
| 1064 | return 0; |
| 1065 | } |
| 1066 | |
Kiran Padwal | af30053 | 2014-07-23 15:56:26 +0530 | [diff] [blame] | 1067 | static const struct of_device_id msm_match_table[] = { |
David Brown | cfdad2a | 2011-08-04 01:55:24 -0700 | [diff] [blame] | 1068 | { .compatible = "qcom,msm-uart" }, |
Stephen Boyd | c3b5d3b | 2013-08-20 23:48:04 -0700 | [diff] [blame] | 1069 | { .compatible = "qcom,msm-uartdm" }, |
David Brown | cfdad2a | 2011-08-04 01:55:24 -0700 | [diff] [blame] | 1070 | {} |
| 1071 | }; |
| 1072 | |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1073 | static struct platform_driver msm_platform_driver = { |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1074 | .remove = msm_serial_remove, |
Andy Gross | 31964ff | 2014-04-24 11:31:22 -0500 | [diff] [blame] | 1075 | .probe = msm_serial_probe, |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1076 | .driver = { |
| 1077 | .name = "msm_serial", |
| 1078 | .owner = THIS_MODULE, |
David Brown | cfdad2a | 2011-08-04 01:55:24 -0700 | [diff] [blame] | 1079 | .of_match_table = msm_match_table, |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1080 | }, |
| 1081 | }; |
| 1082 | |
| 1083 | static int __init msm_serial_init(void) |
| 1084 | { |
| 1085 | int ret; |
| 1086 | |
| 1087 | ret = uart_register_driver(&msm_uart_driver); |
| 1088 | if (unlikely(ret)) |
| 1089 | return ret; |
| 1090 | |
Andy Gross | 31964ff | 2014-04-24 11:31:22 -0500 | [diff] [blame] | 1091 | ret = platform_driver_register(&msm_platform_driver); |
Robert Love | 04896a7 | 2009-06-22 18:43:11 +0100 | [diff] [blame] | 1092 | if (unlikely(ret)) |
| 1093 | uart_unregister_driver(&msm_uart_driver); |
| 1094 | |
| 1095 | printk(KERN_INFO "msm_serial: driver initialized\n"); |
| 1096 | |
| 1097 | return ret; |
| 1098 | } |
| 1099 | |
| 1100 | static void __exit msm_serial_exit(void) |
| 1101 | { |
| 1102 | #ifdef CONFIG_SERIAL_MSM_CONSOLE |
| 1103 | unregister_console(&msm_console); |
| 1104 | #endif |
| 1105 | platform_driver_unregister(&msm_platform_driver); |
| 1106 | uart_unregister_driver(&msm_uart_driver); |
| 1107 | } |
| 1108 | |
| 1109 | module_init(msm_serial_init); |
| 1110 | module_exit(msm_serial_exit); |
| 1111 | |
| 1112 | MODULE_AUTHOR("Robert Love <rlove@google.com>"); |
| 1113 | MODULE_DESCRIPTION("Driver for msm7x serial device"); |
| 1114 | MODULE_LICENSE("GPL"); |