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