serial: 8250: Convert timers to use timer_setup()
[linux-block.git] / drivers / tty / serial / 8250 / 8250_core.c
CommitLineData
1da177e4 1/*
b6830f6d 2 * Universal/legacy driver for 8250/16550-type serial ports
1da177e4
LT
3 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 *
6 * Copyright (C) 2001 Russell King.
7 *
b6830f6d
PH
8 * Supports: ISA-compatible 8250/16550 ports
9 * PNP 8250/16550 ports
10 * early_serial_setup() ports
11 * userspace-configurable "phantom" ports
12 * "serial8250" platform devices
13 * serial8250_register_8250_port() ports
14 *
1da177e4
LT
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
1da177e4 19 */
1da177e4 20
1da177e4
LT
21#include <linux/module.h>
22#include <linux/moduleparam.h>
23#include <linux/ioport.h>
24#include <linux/init.h>
25#include <linux/console.h>
26#include <linux/sysrq.h>
1da177e4 27#include <linux/delay.h>
d052d1be 28#include <linux/platform_device.h>
1da177e4 29#include <linux/tty.h>
cd3ecad1 30#include <linux/ratelimit.h>
1da177e4 31#include <linux/tty_flip.h>
1da177e4
LT
32#include <linux/serial.h>
33#include <linux/serial_8250.h>
78512ece 34#include <linux/nmi.h>
f392ecfa 35#include <linux/mutex.h>
5a0e3ad6 36#include <linux/slab.h>
0b4af1d9 37#include <linux/uaccess.h>
d74d5d1b 38#include <linux/pm_runtime.h>
2584cf83 39#include <linux/io.h>
6816383a
PG
40#ifdef CONFIG_SPARC
41#include <linux/sunserialcore.h>
42#endif
1da177e4 43
1da177e4
LT
44#include <asm/irq.h>
45
46#include "8250.h"
47
48/*
49 * Configuration:
40663cc7 50 * share_irqs - whether we pass IRQF_SHARED to request_irq(). This option
1da177e4
LT
51 * is unsafe when used on edge-triggered interrupts.
52 */
408b664a 53static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
1da177e4 54
a61c2d78
DJ
55static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS;
56
8440838b
DM
57static struct uart_driver serial8250_reg;
58
d41a4b51
CE
59static unsigned int skip_txen_test; /* force skip of txen test at init time */
60
e7328ae1 61#define PASS_LIMIT 512
1da177e4 62
a4ed1e41 63#include <asm/serial.h>
1da177e4
LT
64/*
65 * SERIAL_PORT_DFNS tells us about built-in ports that have no
66 * standard enumeration mechanism. Platforms that can find all
67 * serial ports via mechanisms like ACPI or PCI need not supply it.
68 */
69#ifndef SERIAL_PORT_DFNS
70#define SERIAL_PORT_DFNS
71#endif
72
cb3592be 73static const struct old_serial_port old_serial_port[] = {
1da177e4
LT
74 SERIAL_PORT_DFNS /* defined in asm/serial.h */
75};
76
026d02a2 77#define UART_NR CONFIG_SERIAL_8250_NR_UARTS
1da177e4
LT
78
79#ifdef CONFIG_SERIAL_8250_RSA
80
81#define PORT_RSA_MAX 4
82static unsigned long probe_rsa[PORT_RSA_MAX];
83static unsigned int probe_rsa_count;
84#endif /* CONFIG_SERIAL_8250_RSA */
85
1da177e4 86struct irq_info {
25db8ad5
AC
87 struct hlist_node node;
88 int irq;
89 spinlock_t lock; /* Protects list not the hash */
1da177e4
LT
90 struct list_head *head;
91};
92
25db8ad5
AC
93#define NR_IRQ_HASH 32 /* Can be adjusted later */
94static struct hlist_head irq_lists[NR_IRQ_HASH];
95static DEFINE_MUTEX(hash_mutex); /* Used to walk the hash */
1da177e4
LT
96
97/*
b6830f6d
PH
98 * This is the serial driver's interrupt routine.
99 *
100 * Arjan thinks the old way was overly complex, so it got simplified.
101 * Alan disagrees, saying that need the complexity to handle the weird
102 * nature of ISA shared interrupts. (This is a special exception.)
103 *
104 * In order to handle ISA shared interrupts properly, we need to check
105 * that all ports have been serviced, and therefore the ISA interrupt
106 * line has been de-asserted.
107 *
108 * This means we need to loop through all ports. checking that they
109 * don't have an interrupt pending.
1da177e4 110 */
b6830f6d 111static irqreturn_t serial8250_interrupt(int irq, void *dev_id)
7d6a07d1 112{
b6830f6d
PH
113 struct irq_info *i = dev_id;
114 struct list_head *l, *end = NULL;
115 int pass_counter = 0, handled = 0;
7d6a07d1 116
934014d5 117 pr_debug("%s(%d): start\n", __func__, irq);
583d28e9 118
b6830f6d 119 spin_lock(&i->lock);
cc419fa0 120
b6830f6d
PH
121 l = i->head;
122 do {
123 struct uart_8250_port *up;
124 struct uart_port *port;
cc419fa0 125
b6830f6d
PH
126 up = list_entry(l, struct uart_8250_port, list);
127 port = &up->port;
1da177e4 128
b6830f6d
PH
129 if (port->handle_irq(port)) {
130 handled = 1;
131 end = NULL;
132 } else if (end == NULL)
133 end = l;
1da177e4 134
b6830f6d 135 l = l->next;
1da177e4 136
b6830f6d
PH
137 if (l == i->head && pass_counter++ > PASS_LIMIT) {
138 /* If we hit this, we're dead. */
139 printk_ratelimited(KERN_ERR
140 "serial8250: too much work for irq%d\n", irq);
141 break;
142 }
143 } while (l != end);
c627f2ce 144
b6830f6d 145 spin_unlock(&i->lock);
12bf3f24 146
934014d5 147 pr_debug("%s(%d): end\n", __func__, irq);
1da177e4 148
b6830f6d 149 return IRQ_RETVAL(handled);
40b36daa
AW
150}
151
1da177e4 152/*
b6830f6d
PH
153 * To support ISA shared interrupts, we need to have one interrupt
154 * handler that ensures that the IRQ line has been deasserted
155 * before returning. Failing to do this will result in the IRQ
156 * line being stuck active, and, since ISA irqs are edge triggered,
157 * no more IRQs will be seen.
1da177e4 158 */
b6830f6d 159static void serial_do_unlink(struct irq_info *i, struct uart_8250_port *up)
1da177e4 160{
b6830f6d 161 spin_lock_irq(&i->lock);
1da177e4 162
b6830f6d
PH
163 if (!list_empty(i->head)) {
164 if (i->head == &up->list)
165 i->head = i->head->next;
166 list_del(&up->list);
167 } else {
168 BUG_ON(i->head != &up->list);
169 i->head = NULL;
170 }
171 spin_unlock_irq(&i->lock);
172 /* List empty so throw away the hash node */
173 if (i->head == NULL) {
174 hlist_del(&i->node);
175 kfree(i);
1da177e4
LT
176 }
177}
178
b6830f6d 179static int serial_link_irq_chain(struct uart_8250_port *up)
0ad372b9 180{
b6830f6d
PH
181 struct hlist_head *h;
182 struct hlist_node *n;
183 struct irq_info *i;
184 int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? IRQF_SHARED : 0;
0ad372b9 185
b6830f6d 186 mutex_lock(&hash_mutex);
d74d5d1b 187
b6830f6d 188 h = &irq_lists[up->port.irq % NR_IRQ_HASH];
d74d5d1b 189
b6830f6d
PH
190 hlist_for_each(n, h) {
191 i = hlist_entry(n, struct irq_info, node);
192 if (i->irq == up->port.irq)
193 break;
194 }
d74d5d1b 195
b6830f6d
PH
196 if (n == NULL) {
197 i = kzalloc(sizeof(struct irq_info), GFP_KERNEL);
198 if (i == NULL) {
199 mutex_unlock(&hash_mutex);
200 return -ENOMEM;
201 }
202 spin_lock_init(&i->lock);
203 i->irq = up->port.irq;
204 hlist_add_head(&i->node, h);
205 }
206 mutex_unlock(&hash_mutex);
d74d5d1b 207
b6830f6d 208 spin_lock_irq(&i->lock);
d74d5d1b 209
b6830f6d
PH
210 if (i->head) {
211 list_add(&up->list, i->head);
212 spin_unlock_irq(&i->lock);
d74d5d1b 213
b6830f6d
PH
214 ret = 0;
215 } else {
216 INIT_LIST_HEAD(&up->list);
217 i->head = &up->list;
218 spin_unlock_irq(&i->lock);
219 irq_flags |= up->port.irqflags;
220 ret = request_irq(up->port.irq, serial8250_interrupt,
b2c663d1 221 irq_flags, up->port.name, i);
b6830f6d
PH
222 if (ret < 0)
223 serial_do_unlink(i, up);
224 }
d74d5d1b 225
b6830f6d 226 return ret;
d74d5d1b
SAS
227}
228
b6830f6d 229static void serial_unlink_irq_chain(struct uart_8250_port *up)
1da177e4 230{
dc96efb7 231 /*
b6830f6d
PH
232 * yes, some broken gcc emit "warning: 'i' may be used uninitialized"
233 * but no, we are not going to take a patch that assigns NULL below.
dc96efb7 234 */
b6830f6d
PH
235 struct irq_info *i;
236 struct hlist_node *n;
237 struct hlist_head *h;
1da177e4 238
b6830f6d 239 mutex_lock(&hash_mutex);
1da177e4 240
b6830f6d 241 h = &irq_lists[up->port.irq % NR_IRQ_HASH];
1da177e4 242
b6830f6d
PH
243 hlist_for_each(n, h) {
244 i = hlist_entry(n, struct irq_info, node);
245 if (i->irq == up->port.irq)
246 break;
1da177e4
LT
247 }
248
b6830f6d
PH
249 BUG_ON(n == NULL);
250 BUG_ON(i->head == NULL);
1da177e4 251
b6830f6d
PH
252 if (list_empty(i->head))
253 free_irq(up->port.irq, i);
1da177e4 254
b6830f6d
PH
255 serial_do_unlink(i, up);
256 mutex_unlock(&hash_mutex);
1da177e4
LT
257}
258
259/*
b6830f6d
PH
260 * This function is used to handle ports that do not have an
261 * interrupt. This doesn't work very well for 16450's, but gives
262 * barely passable results for a 16550A. (Although at the expense
263 * of much CPU overhead).
1da177e4 264 */
7c335645 265static void serial8250_timeout(struct timer_list *t)
1da177e4 266{
7c335645 267 struct uart_8250_port *up = from_timer(up, t, timer);
1da177e4 268
b6830f6d
PH
269 up->port.handle_irq(&up->port);
270 mod_timer(&up->timer, jiffies + uart_poll_timeout(&up->port));
271}
1da177e4 272
7c335645 273static void serial8250_backup_timeout(struct timer_list *t)
0ec3f585 274{
7c335645 275 struct uart_8250_port *up = from_timer(up, t, timer);
b6830f6d 276 unsigned int iir, ier = 0, lsr;
0ec3f585 277 unsigned long flags;
1da177e4 278
b6830f6d 279 spin_lock_irqsave(&up->port.lock, flags);
45a7bd63 280
1da177e4 281 /*
b6830f6d
PH
282 * Must disable interrupts or else we risk racing with the interrupt
283 * based handler.
1da177e4 284 */
b6830f6d
PH
285 if (up->port.irq) {
286 ier = serial_in(up, UART_IER);
287 serial_out(up, UART_IER, 0);
1da177e4 288 }
235dae5d 289
b6830f6d 290 iir = serial_in(up, UART_IIR);
1da177e4 291
b6830f6d
PH
292 /*
293 * This should be a safe test for anyone who doesn't trust the
294 * IIR bits on their UART, but it's specifically designed for
295 * the "Diva" UART used on the management processor on many HP
296 * ia64 and parisc boxes.
297 */
298 lsr = serial_in(up, UART_LSR);
299 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
300 if ((iir & UART_IIR_NO_INT) && (up->ier & UART_IER_THRI) &&
301 (!uart_circ_empty(&up->port.state->xmit) || up->port.x_char) &&
302 (lsr & UART_LSR_THRE)) {
303 iir &= ~(UART_IIR_ID | UART_IIR_NO_INT);
304 iir |= UART_IIR_THRI;
cab68f89 305 }
c161afe9 306
b6830f6d
PH
307 if (!(iir & UART_IIR_NO_INT))
308 serial8250_tx_chars(up);
1da177e4 309
b6830f6d
PH
310 if (up->port.irq)
311 serial_out(up, UART_IER, ier);
1da177e4 312
b6830f6d 313 spin_unlock_irqrestore(&up->port.lock, flags);
54ec52b6 314
b6830f6d
PH
315 /* Standard timer interval plus 0.2s to keep the port running */
316 mod_timer(&up->timer,
317 jiffies + uart_poll_timeout(&up->port) + HZ / 5);
f2eda27d
RK
318}
319
b6830f6d 320static int univ8250_setup_irq(struct uart_8250_port *up)
1da177e4 321{
dfe42443 322 struct uart_port *port = &up->port;
b6830f6d 323 int retval = 0;
1da177e4 324
b6830f6d
PH
325 /*
326 * The above check will only give an accurate result the first time
327 * the port is opened so this value needs to be preserved.
328 */
329 if (up->bugs & UART_BUG_THRE) {
330 pr_debug("ttyS%d - using backup timer\n", serial_index(port));
1da177e4 331
7c335645 332 up->timer.function = (TIMER_FUNC_TYPE)serial8250_backup_timeout;
b6830f6d
PH
333 mod_timer(&up->timer, jiffies +
334 uart_poll_timeout(port) + HZ / 5);
335 }
1da177e4 336
b6830f6d
PH
337 /*
338 * If the "interrupt" for this port doesn't correspond with any
339 * hardware interrupt, we use a timer-based system. The original
340 * driver used to do this with IRQ0.
341 */
342 if (!port->irq) {
b6830f6d
PH
343 mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
344 } else
345 retval = serial_link_irq_chain(up);
1da177e4 346
b6830f6d 347 return retval;
1da177e4
LT
348}
349
b6830f6d 350static void univ8250_release_irq(struct uart_8250_port *up)
1da177e4 351{
dfe42443 352 struct uart_port *port = &up->port;
1da177e4 353
b6830f6d 354 del_timer_sync(&up->timer);
7c335645 355 up->timer.function = (TIMER_FUNC_TYPE)serial8250_timeout;
b6830f6d
PH
356 if (port->irq)
357 serial_unlink_irq_chain(up);
1da177e4
LT
358}
359
cd52b759 360#ifdef CONFIG_SERIAL_8250_RSA
1da177e4
LT
361static int serial8250_request_rsa_resource(struct uart_8250_port *up)
362{
363 unsigned long start = UART_RSA_BASE << up->port.regshift;
364 unsigned int size = 8 << up->port.regshift;
dfe42443 365 struct uart_port *port = &up->port;
0b30d668 366 int ret = -EINVAL;
1da177e4 367
dfe42443 368 switch (port->iotype) {
1da177e4
LT
369 case UPIO_HUB6:
370 case UPIO_PORT:
dfe42443 371 start += port->iobase;
0b30d668
SS
372 if (request_region(start, size, "serial-rsa"))
373 ret = 0;
374 else
1da177e4
LT
375 ret = -EBUSY;
376 break;
377 }
378
379 return ret;
380}
381
382static void serial8250_release_rsa_resource(struct uart_8250_port *up)
383{
384 unsigned long offset = UART_RSA_BASE << up->port.regshift;
385 unsigned int size = 8 << up->port.regshift;
dfe42443 386 struct uart_port *port = &up->port;
1da177e4 387
dfe42443 388 switch (port->iotype) {
1da177e4
LT
389 case UPIO_HUB6:
390 case UPIO_PORT:
dfe42443 391 release_region(port->iobase + offset, size);
1da177e4
LT
392 break;
393 }
394}
cd52b759 395#endif
1da177e4 396
40375393
PH
397static const struct uart_ops *base_ops;
398static struct uart_ops univ8250_port_ops;
399
a4416cd1
PH
400static const struct uart_8250_ops univ8250_driver_ops = {
401 .setup_irq = univ8250_setup_irq,
402 .release_irq = univ8250_release_irq,
403};
404
1da177e4
LT
405static struct uart_8250_port serial8250_ports[UART_NR];
406
ae14a795
SAS
407/**
408 * serial8250_get_port - retrieve struct uart_8250_port
409 * @line: serial line number
410 *
411 * This function retrieves struct uart_8250_port for the specific line.
412 * This struct *must* *not* be used to perform a 8250 or serial core operation
413 * which is not accessible otherwise. Its only purpose is to make the struct
414 * accessible to the runtime-pm callbacks for context suspend/restore.
415 * The lock assumption made here is none because runtime-pm suspend/resume
416 * callbacks should not be invoked if there is any operation performed on the
417 * port.
418 */
419struct uart_8250_port *serial8250_get_port(int line)
420{
421 return &serial8250_ports[line];
422}
423EXPORT_SYMBOL_GPL(serial8250_get_port);
424
af7f3743 425static void (*serial8250_isa_config)(int port, struct uart_port *up,
98838d95 426 u32 *capabilities);
af7f3743
AC
427
428void serial8250_set_isa_configurator(
98838d95 429 void (*v)(int port, struct uart_port *up, u32 *capabilities))
af7f3743
AC
430{
431 serial8250_isa_config = v;
432}
433EXPORT_SYMBOL(serial8250_set_isa_configurator);
434
40375393
PH
435#ifdef CONFIG_SERIAL_8250_RSA
436
437static void univ8250_config_port(struct uart_port *port, int flags)
438{
439 struct uart_8250_port *up = up_to_u8250p(port);
440
441 up->probe &= ~UART_PROBE_RSA;
442 if (port->type == PORT_RSA) {
443 if (serial8250_request_rsa_resource(up) == 0)
444 up->probe |= UART_PROBE_RSA;
445 } else if (flags & UART_CONFIG_TYPE) {
446 int i;
447
448 for (i = 0; i < probe_rsa_count; i++) {
449 if (probe_rsa[i] == up->port.iobase) {
450 if (serial8250_request_rsa_resource(up) == 0)
451 up->probe |= UART_PROBE_RSA;
452 break;
453 }
454 }
455 }
456
457 base_ops->config_port(port, flags);
458
459 if (port->type != PORT_RSA && up->probe & UART_PROBE_RSA)
460 serial8250_release_rsa_resource(up);
461}
462
463static int univ8250_request_port(struct uart_port *port)
464{
465 struct uart_8250_port *up = up_to_u8250p(port);
466 int ret;
467
468 ret = base_ops->request_port(port);
469 if (ret == 0 && port->type == PORT_RSA) {
470 ret = serial8250_request_rsa_resource(up);
471 if (ret < 0)
472 base_ops->release_port(port);
473 }
474
475 return ret;
476}
477
478static void univ8250_release_port(struct uart_port *port)
479{
480 struct uart_8250_port *up = up_to_u8250p(port);
481
482 if (port->type == PORT_RSA)
483 serial8250_release_rsa_resource(up);
484 base_ops->release_port(port);
485}
486
487static void univ8250_rsa_support(struct uart_ops *ops)
488{
489 ops->config_port = univ8250_config_port;
490 ops->request_port = univ8250_request_port;
491 ops->release_port = univ8250_release_port;
492}
493
494#else
495#define univ8250_rsa_support(x) do { } while (0)
496#endif /* CONFIG_SERIAL_8250_RSA */
497
c7ac15ce
AS
498static inline void serial8250_apply_quirks(struct uart_8250_port *up)
499{
500 up->port.quirks |= skip_txen_test ? UPQ_NO_TXEN_TEST : 0;
501}
502
1da177e4
LT
503static void __init serial8250_isa_init_ports(void)
504{
505 struct uart_8250_port *up;
506 static int first = 1;
4c0ebb80 507 int i, irqflag = 0;
1da177e4
LT
508
509 if (!first)
510 return;
511 first = 0;
512
835d844d
SY
513 if (nr_uarts > UART_NR)
514 nr_uarts = UART_NR;
515
317a6842 516 for (i = 0; i < nr_uarts; i++) {
1da177e4 517 struct uart_8250_port *up = &serial8250_ports[i];
dfe42443 518 struct uart_port *port = &up->port;
1da177e4 519
dfe42443 520 port->line = i;
0a16e2c1 521 serial8250_init_port(up);
40375393
PH
522 if (!base_ops)
523 base_ops = port->ops;
524 port->ops = &univ8250_port_ops;
1da177e4 525
7c335645 526 timer_setup(&up->timer, serial8250_timeout, 0);
1da177e4 527
a4416cd1
PH
528 up->ops = &univ8250_driver_ops;
529
1da177e4
LT
530 /*
531 * ALPHA_KLUDGE_MCR needs to be killed.
532 */
533 up->mcr_mask = ~ALPHA_KLUDGE_MCR;
534 up->mcr_force = ALPHA_KLUDGE_MCR;
1da177e4
LT
535 }
536
40375393
PH
537 /* chain base port ops to support Remote Supervisor Adapter */
538 univ8250_port_ops = *base_ops;
539 univ8250_rsa_support(&univ8250_port_ops);
540
4c0ebb80
AGR
541 if (share_irqs)
542 irqflag = IRQF_SHARED;
543
44454bcd 544 for (i = 0, up = serial8250_ports;
a61c2d78 545 i < ARRAY_SIZE(old_serial_port) && i < nr_uarts;
1da177e4 546 i++, up++) {
dfe42443
PG
547 struct uart_port *port = &up->port;
548
549 port->iobase = old_serial_port[i].port;
550 port->irq = irq_canonicalize(old_serial_port[i].irq);
b0f8aed2 551 port->irqflags = 0;
dfe42443
PG
552 port->uartclk = old_serial_port[i].baud_base * 16;
553 port->flags = old_serial_port[i].flags;
b0f8aed2 554 port->hub6 = 0;
dfe42443
PG
555 port->membase = old_serial_port[i].iomem_base;
556 port->iotype = old_serial_port[i].io_type;
557 port->regshift = old_serial_port[i].iomem_reg_shift;
1a53e079
PH
558 serial8250_set_defaults(up);
559
dfe42443 560 port->irqflags |= irqflag;
af7f3743
AC
561 if (serial8250_isa_config != NULL)
562 serial8250_isa_config(i, &up->port, &up->capabilities);
1da177e4
LT
563 }
564}
565
566static void __init
567serial8250_register_ports(struct uart_driver *drv, struct device *dev)
568{
569 int i;
570
b8e7e40a
AC
571 for (i = 0; i < nr_uarts; i++) {
572 struct uart_8250_port *up = &serial8250_ports[i];
b8e7e40a 573
e4fda3a0
MS
574 if (up->port.type == PORT_8250_CIR)
575 continue;
576
835d844d
SY
577 if (up->port.dev)
578 continue;
1da177e4
LT
579
580 up->port.dev = dev;
b5d228cc 581
c7ac15ce 582 serial8250_apply_quirks(up);
1da177e4
LT
583 uart_add_one_port(drv, &up->port);
584 }
585}
586
587#ifdef CONFIG_SERIAL_8250_CONSOLE
588
6e281571
PH
589static void univ8250_console_write(struct console *co, const char *s,
590 unsigned int count)
591{
592 struct uart_8250_port *up = &serial8250_ports[co->index];
593
594 serial8250_console_write(up, s, count);
595}
596
6e281571
PH
597static int univ8250_console_setup(struct console *co, char *options)
598{
87515772 599 struct uart_port *port;
d70a7b16 600 int retval;
6e281571 601
1da177e4
LT
602 /*
603 * Check whether an invalid uart number has been specified, and
604 * if so, search for the first available port that does have
605 * console support.
606 */
317a6842 607 if (co->index >= nr_uarts)
1da177e4 608 co->index = 0;
87515772 609 port = &serial8250_ports[co->index].port;
6e281571 610 /* link port to console */
87515772 611 port->cons = co;
1da177e4 612
d70a7b16
PH
613 retval = serial8250_console_setup(port, options, false);
614 if (retval != 0)
615 port->cons = NULL;
616 return retval;
1da177e4
LT
617}
618
c7cef0a8 619/**
6e281571 620 * univ8250_console_match - non-standard console matching
c7cef0a8
PH
621 * @co: registering console
622 * @name: name from console command line
623 * @idx: index from console command line
624 * @options: ptr to option string from console command line
625 *
626 * Only attempts to match console command lines of the form:
bd94c407 627 * console=uart[8250],io|mmio|mmio16|mmio32,<addr>[,<options>]
ca782f16 628 * console=uart[8250],0x<addr>[,<options>]
c7cef0a8
PH
629 * This form is used to register an initial earlycon boot console and
630 * replace it with the serial8250_console at 8250 driver init.
631 *
632 * Performs console setup for a match (as required by interface)
ca782f16 633 * If no <options> are specified, then assume the h/w is already setup.
c7cef0a8
PH
634 *
635 * Returns 0 if console matches; otherwise non-zero to use default matching
636 */
6e281571
PH
637static int univ8250_console_match(struct console *co, char *name, int idx,
638 char *options)
18a8bd94 639{
c7cef0a8
PH
640 char match[] = "uart"; /* 8250-specific earlycon name */
641 unsigned char iotype;
46e36683 642 resource_size_t addr;
c7cef0a8
PH
643 int i;
644
645 if (strncmp(name, match, 4) != 0)
646 return -ENODEV;
647
648 if (uart_parse_earlycon(options, &iotype, &addr, &options))
649 return -ENODEV;
650
651 /* try to match the port specified on the command line */
652 for (i = 0; i < nr_uarts; i++) {
653 struct uart_port *port = &serial8250_ports[i].port;
654
655 if (port->iotype != iotype)
656 continue;
bd94c407
MY
657 if ((iotype == UPIO_MEM || iotype == UPIO_MEM16 ||
658 iotype == UPIO_MEM32 || iotype == UPIO_MEM32BE)
659 && (port->mapbase != addr))
c7cef0a8
PH
660 continue;
661 if (iotype == UPIO_PORT && port->iobase != addr)
662 continue;
663
664 co->index = i;
87515772
PH
665 port->cons = co;
666 return serial8250_console_setup(port, options, true);
c7cef0a8
PH
667 }
668
669 return -ENODEV;
18a8bd94
YL
670}
671
6e281571 672static struct console univ8250_console = {
1da177e4 673 .name = "ttyS",
6e281571 674 .write = univ8250_console_write,
1da177e4 675 .device = uart_console_device,
6e281571
PH
676 .setup = univ8250_console_setup,
677 .match = univ8250_console_match,
6741f551 678 .flags = CON_PRINTBUFFER | CON_ANYTIME,
1da177e4
LT
679 .index = -1,
680 .data = &serial8250_reg,
681};
682
6e281571 683static int __init univ8250_console_init(void)
1da177e4 684{
59cfc45f
JK
685 if (nr_uarts == 0)
686 return -ENODEV;
687
1da177e4 688 serial8250_isa_init_ports();
6e281571 689 register_console(&univ8250_console);
1da177e4
LT
690 return 0;
691}
6e281571 692console_initcall(univ8250_console_init);
1da177e4 693
149a44cc 694#define SERIAL8250_CONSOLE (&univ8250_console)
1da177e4
LT
695#else
696#define SERIAL8250_CONSOLE NULL
697#endif
698
699static struct uart_driver serial8250_reg = {
700 .owner = THIS_MODULE,
701 .driver_name = "serial",
1da177e4
LT
702 .dev_name = "ttyS",
703 .major = TTY_MAJOR,
704 .minor = 64,
1da177e4
LT
705 .cons = SERIAL8250_CONSOLE,
706};
707
d856c666
RK
708/*
709 * early_serial_setup - early registration for 8250 ports
710 *
711 * Setup an 8250 port structure prior to console initialisation. Use
712 * after console initialisation will cause undefined behaviour.
713 */
1da177e4
LT
714int __init early_serial_setup(struct uart_port *port)
715{
b430428a
DD
716 struct uart_port *p;
717
59cfc45f 718 if (port->line >= ARRAY_SIZE(serial8250_ports) || nr_uarts == 0)
1da177e4
LT
719 return -ENODEV;
720
721 serial8250_isa_init_ports();
b430428a
DD
722 p = &serial8250_ports[port->line].port;
723 p->iobase = port->iobase;
724 p->membase = port->membase;
725 p->irq = port->irq;
1c2f0493 726 p->irqflags = port->irqflags;
b430428a
DD
727 p->uartclk = port->uartclk;
728 p->fifosize = port->fifosize;
729 p->regshift = port->regshift;
730 p->iotype = port->iotype;
731 p->flags = port->flags;
732 p->mapbase = port->mapbase;
ee97d0e3 733 p->mapsize = port->mapsize;
b430428a 734 p->private_data = port->private_data;
125c97d8
HD
735 p->type = port->type;
736 p->line = port->line;
7d6a07d1 737
1a53e079
PH
738 serial8250_set_defaults(up_to_u8250p(p));
739
7d6a07d1
DD
740 if (port->serial_in)
741 p->serial_in = port->serial_in;
742 if (port->serial_out)
743 p->serial_out = port->serial_out;
583d28e9
JI
744 if (port->handle_irq)
745 p->handle_irq = port->handle_irq;
7d6a07d1 746
1da177e4
LT
747 return 0;
748}
749
750/**
751 * serial8250_suspend_port - suspend one serial port
752 * @line: serial line number
1da177e4
LT
753 *
754 * Suspend one serial port.
755 */
756void serial8250_suspend_port(int line)
757{
4516d50a
PH
758 struct uart_8250_port *up = &serial8250_ports[line];
759 struct uart_port *port = &up->port;
760
761 if (!console_suspend_enabled && uart_console(port) &&
762 port->type != PORT_8250) {
763 unsigned char canary = 0xa5;
764 serial_out(up, UART_SCR, canary);
f01a0bd8
PH
765 if (serial_in(up, UART_SCR) == canary)
766 up->canary = canary;
4516d50a
PH
767 }
768
769 uart_suspend_port(&serial8250_reg, port);
1da177e4 770}
b34f9faf 771EXPORT_SYMBOL(serial8250_suspend_port);
1da177e4
LT
772
773/**
774 * serial8250_resume_port - resume one serial port
775 * @line: serial line number
1da177e4
LT
776 *
777 * Resume one serial port.
778 */
779void serial8250_resume_port(int line)
780{
b5b82df6 781 struct uart_8250_port *up = &serial8250_ports[line];
dfe42443 782 struct uart_port *port = &up->port;
b5b82df6 783
4516d50a
PH
784 up->canary = 0;
785
b5b82df6 786 if (up->capabilities & UART_NATSEMI) {
b5b82df6 787 /* Ensure it's still in high speed mode */
4fd996a1 788 serial_port_out(port, UART_LCR, 0xE0);
b5b82df6 789
0d0389e5 790 ns16550a_goto_highspeed(up);
b5b82df6 791
4fd996a1 792 serial_port_out(port, UART_LCR, 0);
dfe42443 793 port->uartclk = 921600*16;
b5b82df6 794 }
dfe42443 795 uart_resume_port(&serial8250_reg, port);
1da177e4 796}
b34f9faf 797EXPORT_SYMBOL(serial8250_resume_port);
1da177e4
LT
798
799/*
800 * Register a set of serial devices attached to a platform device. The
801 * list is terminated with a zero flags entry, which means we expect
802 * all entries to have at least UPF_BOOT_AUTOCONF set.
803 */
9671f099 804static int serial8250_probe(struct platform_device *dev)
1da177e4 805{
574de559 806 struct plat_serial8250_port *p = dev_get_platdata(&dev->dev);
2655a2c7 807 struct uart_8250_port uart;
4c0ebb80 808 int ret, i, irqflag = 0;
1da177e4 809
2655a2c7 810 memset(&uart, 0, sizeof(uart));
1da177e4 811
4c0ebb80
AGR
812 if (share_irqs)
813 irqflag = IRQF_SHARED;
814
ec9f47cd 815 for (i = 0; p && p->flags != 0; p++, i++) {
2655a2c7
AC
816 uart.port.iobase = p->iobase;
817 uart.port.membase = p->membase;
818 uart.port.irq = p->irq;
819 uart.port.irqflags = p->irqflags;
820 uart.port.uartclk = p->uartclk;
821 uart.port.regshift = p->regshift;
822 uart.port.iotype = p->iotype;
823 uart.port.flags = p->flags;
824 uart.port.mapbase = p->mapbase;
825 uart.port.hub6 = p->hub6;
826 uart.port.private_data = p->private_data;
827 uart.port.type = p->type;
828 uart.port.serial_in = p->serial_in;
829 uart.port.serial_out = p->serial_out;
830 uart.port.handle_irq = p->handle_irq;
831 uart.port.handle_break = p->handle_break;
832 uart.port.set_termios = p->set_termios;
db405a8f 833 uart.port.set_ldisc = p->set_ldisc;
144ef5c2 834 uart.port.get_mctrl = p->get_mctrl;
2655a2c7
AC
835 uart.port.pm = p->pm;
836 uart.port.dev = &dev->dev;
837 uart.port.irqflags |= irqflag;
838 ret = serial8250_register_8250_port(&uart);
ec9f47cd 839 if (ret < 0) {
3ae5eaec 840 dev_err(&dev->dev, "unable to register port at index %d "
4f640efb
JB
841 "(IO%lx MEM%llx IRQ%d): %d\n", i,
842 p->iobase, (unsigned long long)p->mapbase,
843 p->irq, ret);
ec9f47cd 844 }
1da177e4
LT
845 }
846 return 0;
847}
848
849/*
850 * Remove serial ports registered against a platform device.
851 */
ae8d8a14 852static int serial8250_remove(struct platform_device *dev)
1da177e4
LT
853{
854 int i;
855
317a6842 856 for (i = 0; i < nr_uarts; i++) {
1da177e4
LT
857 struct uart_8250_port *up = &serial8250_ports[i];
858
3ae5eaec 859 if (up->port.dev == &dev->dev)
1da177e4
LT
860 serial8250_unregister_port(i);
861 }
862 return 0;
863}
864
3ae5eaec 865static int serial8250_suspend(struct platform_device *dev, pm_message_t state)
1da177e4
LT
866{
867 int i;
868
1da177e4
LT
869 for (i = 0; i < UART_NR; i++) {
870 struct uart_8250_port *up = &serial8250_ports[i];
871
3ae5eaec 872 if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
1da177e4
LT
873 uart_suspend_port(&serial8250_reg, &up->port);
874 }
875
876 return 0;
877}
878
3ae5eaec 879static int serial8250_resume(struct platform_device *dev)
1da177e4
LT
880{
881 int i;
882
1da177e4
LT
883 for (i = 0; i < UART_NR; i++) {
884 struct uart_8250_port *up = &serial8250_ports[i];
885
3ae5eaec 886 if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
b5b82df6 887 serial8250_resume_port(i);
1da177e4
LT
888 }
889
890 return 0;
891}
892
3ae5eaec 893static struct platform_driver serial8250_isa_driver = {
1da177e4 894 .probe = serial8250_probe,
2d47b716 895 .remove = serial8250_remove,
1da177e4
LT
896 .suspend = serial8250_suspend,
897 .resume = serial8250_resume,
3ae5eaec
RK
898 .driver = {
899 .name = "serial8250",
900 },
1da177e4
LT
901};
902
903/*
904 * This "device" covers _all_ ISA 8250-compatible serial devices listed
905 * in the table in include/asm/serial.h
906 */
907static struct platform_device *serial8250_isa_devs;
908
909/*
2655a2c7 910 * serial8250_register_8250_port and serial8250_unregister_port allows for
1da177e4
LT
911 * 16x50 serial ports to be configured at run-time, to support PCMCIA
912 * modems and PCI multiport cards.
913 */
f392ecfa 914static DEFINE_MUTEX(serial_mutex);
1da177e4
LT
915
916static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *port)
917{
918 int i;
919
920 /*
921 * First, find a port entry which matches.
922 */
317a6842 923 for (i = 0; i < nr_uarts; i++)
1da177e4
LT
924 if (uart_match_port(&serial8250_ports[i].port, port))
925 return &serial8250_ports[i];
926
59b3e898
SAS
927 /* try line number first if still available */
928 i = port->line;
929 if (i < nr_uarts && serial8250_ports[i].port.type == PORT_UNKNOWN &&
930 serial8250_ports[i].port.iobase == 0)
931 return &serial8250_ports[i];
1da177e4
LT
932 /*
933 * We didn't find a matching entry, so look for the first
934 * free entry. We look for one which hasn't been previously
935 * used (indicated by zero iobase).
936 */
317a6842 937 for (i = 0; i < nr_uarts; i++)
1da177e4
LT
938 if (serial8250_ports[i].port.type == PORT_UNKNOWN &&
939 serial8250_ports[i].port.iobase == 0)
940 return &serial8250_ports[i];
941
942 /*
943 * That also failed. Last resort is to find any entry which
944 * doesn't have a real port associated with it.
945 */
317a6842 946 for (i = 0; i < nr_uarts; i++)
1da177e4
LT
947 if (serial8250_ports[i].port.type == PORT_UNKNOWN)
948 return &serial8250_ports[i];
949
950 return NULL;
951}
952
953/**
f73fa05b 954 * serial8250_register_8250_port - register a serial port
58bcd332 955 * @up: serial port template
1da177e4
LT
956 *
957 * Configure the serial port specified by the request. If the
958 * port exists and is in use, it is hung up and unregistered
959 * first.
960 *
961 * The port is then probed and if necessary the IRQ is autodetected
962 * If this fails an error is returned.
963 *
964 * On success the port is ready to use and the line number is returned.
965 */
f73fa05b 966int serial8250_register_8250_port(struct uart_8250_port *up)
1da177e4
LT
967{
968 struct uart_8250_port *uart;
969 int ret = -ENOSPC;
970
f73fa05b 971 if (up->port.uartclk == 0)
1da177e4
LT
972 return -EINVAL;
973
f392ecfa 974 mutex_lock(&serial_mutex);
1da177e4 975
f73fa05b 976 uart = serial8250_find_match_or_unused(&up->port);
65ecc9c0 977 if (uart && uart->port.type != PORT_8250_CIR) {
835d844d
SY
978 if (uart->port.dev)
979 uart_remove_one_port(&serial8250_reg, &uart->port);
1da177e4 980
f73fa05b
MD
981 uart->port.iobase = up->port.iobase;
982 uart->port.membase = up->port.membase;
983 uart->port.irq = up->port.irq;
984 uart->port.irqflags = up->port.irqflags;
985 uart->port.uartclk = up->port.uartclk;
986 uart->port.fifosize = up->port.fifosize;
987 uart->port.regshift = up->port.regshift;
988 uart->port.iotype = up->port.iotype;
989 uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF;
a2d33d87 990 uart->bugs = up->bugs;
f73fa05b 991 uart->port.mapbase = up->port.mapbase;
ee97d0e3 992 uart->port.mapsize = up->port.mapsize;
f73fa05b 993 uart->port.private_data = up->port.private_data;
9660497c
HK
994 uart->tx_loadsz = up->tx_loadsz;
995 uart->capabilities = up->capabilities;
234abab1
SAS
996 uart->port.throttle = up->port.throttle;
997 uart->port.unthrottle = up->port.unthrottle;
46c55b4b
RRD
998 uart->port.rs485_config = up->port.rs485_config;
999 uart->port.rs485 = up->port.rs485;
d53e1428 1000 uart->dma = up->dma;
9660497c 1001
6a3f45dc
HK
1002 /* Take tx_loadsz from fifosize if it wasn't set separately */
1003 if (uart->port.fifosize && !uart->tx_loadsz)
1004 uart->tx_loadsz = uart->port.fifosize;
1005
f73fa05b
MD
1006 if (up->port.dev)
1007 uart->port.dev = up->port.dev;
1008
1009 if (up->port.flags & UPF_FIXED_TYPE)
afd483bd 1010 uart->port.type = up->port.type;
8e23fcc8 1011
1a53e079
PH
1012 serial8250_set_defaults(uart);
1013
7d6a07d1 1014 /* Possibly override default I/O functions. */
f73fa05b
MD
1015 if (up->port.serial_in)
1016 uart->port.serial_in = up->port.serial_in;
1017 if (up->port.serial_out)
1018 uart->port.serial_out = up->port.serial_out;
1019 if (up->port.handle_irq)
1020 uart->port.handle_irq = up->port.handle_irq;
235dae5d 1021 /* Possibly override set_termios call */
f73fa05b
MD
1022 if (up->port.set_termios)
1023 uart->port.set_termios = up->port.set_termios;
db405a8f
EB
1024 if (up->port.set_ldisc)
1025 uart->port.set_ldisc = up->port.set_ldisc;
144ef5c2
WAZ
1026 if (up->port.get_mctrl)
1027 uart->port.get_mctrl = up->port.get_mctrl;
4bf4ea9d
PH
1028 if (up->port.set_mctrl)
1029 uart->port.set_mctrl = up->port.set_mctrl;
b99b121b
SAS
1030 if (up->port.startup)
1031 uart->port.startup = up->port.startup;
1032 if (up->port.shutdown)
1033 uart->port.shutdown = up->port.shutdown;
f73fa05b
MD
1034 if (up->port.pm)
1035 uart->port.pm = up->port.pm;
1036 if (up->port.handle_break)
1037 uart->port.handle_break = up->port.handle_break;
1038 if (up->dl_read)
1039 uart->dl_read = up->dl_read;
1040 if (up->dl_write)
1041 uart->dl_write = up->dl_write;
1da177e4 1042
9527b82a
SY
1043 if (uart->port.type != PORT_8250_CIR) {
1044 if (serial8250_isa_config != NULL)
1045 serial8250_isa_config(0, &uart->port,
1046 &uart->capabilities);
1047
cf0a1579 1048 serial8250_apply_quirks(uart);
9527b82a
SY
1049 ret = uart_add_one_port(&serial8250_reg,
1050 &uart->port);
1051 if (ret == 0)
1052 ret = uart->port.line;
1053 } else {
1054 dev_info(uart->port.dev,
1055 "skipping CIR port at 0x%lx / 0x%llx, IRQ %d\n",
1056 uart->port.iobase,
1057 (unsigned long long)uart->port.mapbase,
1058 uart->port.irq);
af7f3743 1059
9527b82a
SY
1060 ret = 0;
1061 }
1da177e4 1062 }
f392ecfa 1063 mutex_unlock(&serial_mutex);
1da177e4
LT
1064
1065 return ret;
1066}
f73fa05b
MD
1067EXPORT_SYMBOL(serial8250_register_8250_port);
1068
1da177e4
LT
1069/**
1070 * serial8250_unregister_port - remove a 16x50 serial port at runtime
1071 * @line: serial line number
1072 *
1073 * Remove one serial port. This may not be called from interrupt
1074 * context. We hand the port back to the our control.
1075 */
1076void serial8250_unregister_port(int line)
1077{
1078 struct uart_8250_port *uart = &serial8250_ports[line];
1079
f392ecfa 1080 mutex_lock(&serial_mutex);
bf2a0be4
MK
1081
1082 if (uart->em485) {
1083 unsigned long flags;
1084
1085 spin_lock_irqsave(&uart->port.lock, flags);
1086 serial8250_em485_destroy(uart);
1087 spin_unlock_irqrestore(&uart->port.lock, flags);
1088 }
1089
1da177e4
LT
1090 uart_remove_one_port(&serial8250_reg, &uart->port);
1091 if (serial8250_isa_devs) {
1092 uart->port.flags &= ~UPF_BOOT_AUTOCONF;
1093 uart->port.type = PORT_UNKNOWN;
1094 uart->port.dev = &serial8250_isa_devs->dev;
5db496b9 1095 uart->capabilities = 0;
c7ac15ce 1096 serial8250_apply_quirks(uart);
1da177e4
LT
1097 uart_add_one_port(&serial8250_reg, &uart->port);
1098 } else {
1099 uart->port.dev = NULL;
1100 }
f392ecfa 1101 mutex_unlock(&serial_mutex);
1da177e4
LT
1102}
1103EXPORT_SYMBOL(serial8250_unregister_port);
1104
1105static int __init serial8250_init(void)
1106{
25db8ad5 1107 int ret;
1da177e4 1108
59cfc45f
JK
1109 if (nr_uarts == 0)
1110 return -ENODEV;
1111
835d844d 1112 serial8250_isa_init_ports();
a61c2d78 1113
9f59fbf0
PR
1114 pr_info("Serial: 8250/16550 driver, %d ports, IRQ sharing %sabled\n",
1115 nr_uarts, share_irqs ? "en" : "dis");
1da177e4 1116
b70ac771
DM
1117#ifdef CONFIG_SPARC
1118 ret = sunserial_register_minors(&serial8250_reg, UART_NR);
1119#else
1120 serial8250_reg.nr = UART_NR;
1da177e4 1121 ret = uart_register_driver(&serial8250_reg);
b70ac771 1122#endif
1da177e4
LT
1123 if (ret)
1124 goto out;
1125
835d844d
SY
1126 ret = serial8250_pnp_init();
1127 if (ret)
1128 goto unreg_uart_drv;
1129
7493a314
DT
1130 serial8250_isa_devs = platform_device_alloc("serial8250",
1131 PLAT8250_DEV_LEGACY);
1132 if (!serial8250_isa_devs) {
1133 ret = -ENOMEM;
835d844d 1134 goto unreg_pnp;
1da177e4
LT
1135 }
1136
7493a314
DT
1137 ret = platform_device_add(serial8250_isa_devs);
1138 if (ret)
1139 goto put_dev;
1140
1da177e4
LT
1141 serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev);
1142
bc965a7f
RK
1143 ret = platform_driver_register(&serial8250_isa_driver);
1144 if (ret == 0)
1145 goto out;
1da177e4 1146
bc965a7f 1147 platform_device_del(serial8250_isa_devs);
25db8ad5 1148put_dev:
7493a314 1149 platform_device_put(serial8250_isa_devs);
835d844d
SY
1150unreg_pnp:
1151 serial8250_pnp_exit();
25db8ad5 1152unreg_uart_drv:
b70ac771
DM
1153#ifdef CONFIG_SPARC
1154 sunserial_unregister_minors(&serial8250_reg, UART_NR);
1155#else
1da177e4 1156 uart_unregister_driver(&serial8250_reg);
b70ac771 1157#endif
25db8ad5 1158out:
1da177e4
LT
1159 return ret;
1160}
1161
1162static void __exit serial8250_exit(void)
1163{
1164 struct platform_device *isa_dev = serial8250_isa_devs;
1165
1166 /*
1167 * This tells serial8250_unregister_port() not to re-register
1168 * the ports (thereby making serial8250_isa_driver permanently
1169 * in use.)
1170 */
1171 serial8250_isa_devs = NULL;
1172
3ae5eaec 1173 platform_driver_unregister(&serial8250_isa_driver);
1da177e4
LT
1174 platform_device_unregister(isa_dev);
1175
835d844d
SY
1176 serial8250_pnp_exit();
1177
b70ac771
DM
1178#ifdef CONFIG_SPARC
1179 sunserial_unregister_minors(&serial8250_reg, UART_NR);
1180#else
1da177e4 1181 uart_unregister_driver(&serial8250_reg);
b70ac771 1182#endif
1da177e4
LT
1183}
1184
1185module_init(serial8250_init);
1186module_exit(serial8250_exit);
1187
1da177e4 1188MODULE_LICENSE("GPL");
d87a6d95 1189MODULE_DESCRIPTION("Generic 8250/16x50 serial driver");
1da177e4 1190
3b60daf8 1191module_param_hw(share_irqs, uint, other, 0644);
90ad7c44 1192MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices (unsafe)");
1da177e4 1193
a61c2d78
DJ
1194module_param(nr_uarts, uint, 0644);
1195MODULE_PARM_DESC(nr_uarts, "Maximum number of UARTs supported. (1-" __MODULE_STRING(CONFIG_SERIAL_8250_NR_UARTS) ")");
1196
d41a4b51
CE
1197module_param(skip_txen_test, uint, 0644);
1198MODULE_PARM_DESC(skip_txen_test, "Skip checking for the TXEN bug at init time");
1199
1da177e4 1200#ifdef CONFIG_SERIAL_8250_RSA
3b60daf8 1201module_param_hw_array(probe_rsa, ulong, ioport, &probe_rsa_count, 0444);
1da177e4
LT
1202MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA");
1203#endif
1204MODULE_ALIAS_CHARDEV_MAJOR(TTY_MAJOR);
f2b8dfd9 1205
9326b047 1206#ifdef CONFIG_SERIAL_8250_DEPRECATED_OPTIONS
f2b8dfd9
JB
1207#ifndef MODULE
1208/* This module was renamed to 8250_core in 3.7. Keep the old "8250" name
1209 * working as well for the module options so we don't break people. We
1210 * need to keep the names identical and the convenient macros will happily
1211 * refuse to let us do that by failing the build with redefinition errors
1212 * of global variables. So we stick them inside a dummy function to avoid
1213 * those conflicts. The options still get parsed, and the redefined
1214 * MODULE_PARAM_PREFIX lets us keep the "8250." syntax alive.
1215 *
1216 * This is hacky. I'm sorry.
1217 */
1218static void __used s8250_options(void)
1219{
1220#undef MODULE_PARAM_PREFIX
9196d8ac 1221#define MODULE_PARAM_PREFIX "8250_core."
f2b8dfd9
JB
1222
1223 module_param_cb(share_irqs, &param_ops_uint, &share_irqs, 0644);
1224 module_param_cb(nr_uarts, &param_ops_uint, &nr_uarts, 0644);
1225 module_param_cb(skip_txen_test, &param_ops_uint, &skip_txen_test, 0644);
1226#ifdef CONFIG_SERIAL_8250_RSA
1227 __module_param_call(MODULE_PARAM_PREFIX, probe_rsa,
1228 &param_array_ops, .arr = &__param_arr_probe_rsa,
91f9d330 1229 0444, -1, 0);
f2b8dfd9
JB
1230#endif
1231}
1232#else
9196d8ac 1233MODULE_ALIAS("8250_core");
f2b8dfd9 1234#endif
f2b8dfd9 1235#endif