aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/68328serial.c2
-rw-r--r--drivers/tty/serial/8250/8250.c98
-rw-r--r--drivers/tty/serial/8250/8250.h36
-rw-r--r--drivers/tty/serial/8250/8250_acorn.c6
-rw-r--r--drivers/tty/serial/8250/8250_dw.c31
-rw-r--r--drivers/tty/serial/8250/8250_early.c46
-rw-r--r--drivers/tty/serial/8250/8250_em.c8
-rw-r--r--drivers/tty/serial/8250/8250_hp300.c10
-rw-r--r--drivers/tty/serial/8250/8250_pci.c352
-rw-r--r--drivers/tty/serial/8250/8250_pnp.c14
-rw-r--r--drivers/tty/serial/Kconfig48
-rw-r--r--drivers/tty/serial/Makefile1
-rw-r--r--drivers/tty/serial/altera_jtaguart.c6
-rw-r--r--drivers/tty/serial/altera_uart.c6
-rw-r--r--drivers/tty/serial/amba-pl011.c25
-rw-r--r--drivers/tty/serial/apbuart.c2
-rw-r--r--drivers/tty/serial/ar933x_uart.c96
-rw-r--r--drivers/tty/serial/arc_uart.c746
-rw-r--r--drivers/tty/serial/atmel_serial.c10
-rw-r--r--drivers/tty/serial/bcm63xx_uart.c6
-rw-r--r--drivers/tty/serial/bfin_sport_uart.c6
-rw-r--r--drivers/tty/serial/bfin_uart.c20
-rw-r--r--drivers/tty/serial/clps711x.c595
-rw-r--r--drivers/tty/serial/cpm_uart/cpm_uart_core.c4
-rw-r--r--drivers/tty/serial/efm32-uart.c6
-rw-r--r--drivers/tty/serial/icom.c14
-rw-r--r--drivers/tty/serial/ifx6x60.c168
-rw-r--r--drivers/tty/serial/ifx6x60.h2
-rw-r--r--drivers/tty/serial/ioc3_serial.c2
-rw-r--r--drivers/tty/serial/jsm/jsm.h8
-rw-r--r--drivers/tty/serial/jsm/jsm_driver.c9
-rw-r--r--drivers/tty/serial/jsm/jsm_neo.c116
-rw-r--r--drivers/tty/serial/jsm/jsm_tty.c104
-rw-r--r--drivers/tty/serial/kgdb_nmi.c2
-rw-r--r--drivers/tty/serial/lpc32xx_hs.c6
-rw-r--r--drivers/tty/serial/max3100.c6
-rw-r--r--drivers/tty/serial/max310x.c11
-rw-r--r--drivers/tty/serial/mcf.c6
-rw-r--r--drivers/tty/serial/mfd.c7
-rw-r--r--drivers/tty/serial/mpc52xx_uart.c2
-rw-r--r--drivers/tty/serial/mrst_max3110.c6
-rw-r--r--drivers/tty/serial/msm_serial.c2
-rw-r--r--drivers/tty/serial/msm_serial_hs.c8
-rw-r--r--drivers/tty/serial/mux.c6
-rw-r--r--drivers/tty/serial/mxs-auart.c376
-rw-r--r--drivers/tty/serial/of_serial.c38
-rw-r--r--drivers/tty/serial/omap-serial.c30
-rw-r--r--drivers/tty/serial/pch_uart.c4
-rw-r--r--drivers/tty/serial/pxa.c55
-rw-r--r--drivers/tty/serial/sa1100.c2
-rw-r--r--drivers/tty/serial/samsung.c46
-rw-r--r--drivers/tty/serial/sc26xx.c6
-rw-r--r--drivers/tty/serial/sccnxp.c6
-rw-r--r--drivers/tty/serial/serial_core.c186
-rw-r--r--drivers/tty/serial/serial_txx9.c16
-rw-r--r--drivers/tty/serial/sh-sci.c154
-rw-r--r--drivers/tty/serial/sirfsoc_uart.c4
-rw-r--r--drivers/tty/serial/sunhv.c6
-rw-r--r--drivers/tty/serial/sunsab.c8
-rw-r--r--drivers/tty/serial/sunsu.c10
-rw-r--r--drivers/tty/serial/sunzilog.c14
-rw-r--r--drivers/tty/serial/timbuart.c6
-rw-r--r--drivers/tty/serial/uartlite.c14
-rw-r--r--drivers/tty/serial/vr41xx_siu.c8
-rw-r--r--drivers/tty/serial/vt8500_serial.c14
-rw-r--r--drivers/tty/serial/xilinx_uartps.c15
66 files changed, 2791 insertions, 892 deletions
diff --git a/drivers/tty/serial/68328serial.c b/drivers/tty/serial/68328serial.c
index 66c38a3f74c..f99a84526f8 100644
--- a/drivers/tty/serial/68328serial.c
+++ b/drivers/tty/serial/68328serial.c
@@ -1225,6 +1225,8 @@ rs68328_init(void)
1225 1225
1226 if (tty_register_driver(serial_driver)) { 1226 if (tty_register_driver(serial_driver)) {
1227 put_tty_driver(serial_driver); 1227 put_tty_driver(serial_driver);
1228 for (i = 0; i < NR_PORTS; i++)
1229 tty_port_destroy(&m68k_soft[i].tport);
1228 printk(KERN_ERR "Couldn't register serial driver\n"); 1230 printk(KERN_ERR "Couldn't register serial driver\n");
1229 return -ENOMEM; 1231 return -ENOMEM;
1230 } 1232 }
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 3ba4234592b..d085e3a8ec0 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -280,7 +280,17 @@ static const struct serial8250_config uart_config[] = {
280 .fifo_size = 64, 280 .fifo_size = 64,
281 .tx_loadsz = 64, 281 .tx_loadsz = 64,
282 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, 282 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
283 .flags = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR, 283 .flags = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR |
284 UART_CAP_SLEEP,
285 },
286 [PORT_XR17V35X] = {
287 .name = "XR17V35X",
288 .fifo_size = 256,
289 .tx_loadsz = 256,
290 .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_11 |
291 UART_FCR_T_TRIG_11,
292 .flags = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR |
293 UART_CAP_SLEEP,
284 }, 294 },
285 [PORT_LPC3220] = { 295 [PORT_LPC3220] = {
286 .name = "LPC3220", 296 .name = "LPC3220",
@@ -455,6 +465,7 @@ static void io_serial_out(struct uart_port *p, int offset, int value)
455} 465}
456 466
457static int serial8250_default_handle_irq(struct uart_port *port); 467static int serial8250_default_handle_irq(struct uart_port *port);
468static int exar_handle_irq(struct uart_port *port);
458 469
459static void set_io_from_upio(struct uart_port *p) 470static void set_io_from_upio(struct uart_port *p)
460{ 471{
@@ -574,6 +585,19 @@ EXPORT_SYMBOL_GPL(serial8250_clear_and_reinit_fifos);
574 */ 585 */
575static void serial8250_set_sleep(struct uart_8250_port *p, int sleep) 586static void serial8250_set_sleep(struct uart_8250_port *p, int sleep)
576{ 587{
588 /*
589 * Exar UARTs have a SLEEP register that enables or disables
590 * each UART to enter sleep mode separately. On the XR17V35x the
591 * register is accessible to each UART at the UART_EXAR_SLEEP
592 * offset but the UART channel may only write to the corresponding
593 * bit.
594 */
595 if ((p->port.type == PORT_XR17V35X) ||
596 (p->port.type == PORT_XR17D15X)) {
597 serial_out(p, UART_EXAR_SLEEP, 0xff);
598 return;
599 }
600
577 if (p->capabilities & UART_CAP_SLEEP) { 601 if (p->capabilities & UART_CAP_SLEEP) {
578 if (p->capabilities & UART_CAP_EFR) { 602 if (p->capabilities & UART_CAP_EFR) {
579 serial_out(p, UART_LCR, UART_LCR_CONF_MODE_B); 603 serial_out(p, UART_LCR, UART_LCR_CONF_MODE_B);
@@ -882,6 +906,27 @@ static void autoconfig_16550a(struct uart_8250_port *up)
882 up->capabilities |= UART_CAP_FIFO; 906 up->capabilities |= UART_CAP_FIFO;
883 907
884 /* 908 /*
909 * XR17V35x UARTs have an extra divisor register, DLD
910 * that gets enabled with when DLAB is set which will
911 * cause the device to incorrectly match and assign
912 * port type to PORT_16650. The EFR for this UART is
913 * found at offset 0x09. Instead check the Deice ID (DVID)
914 * register for a 2, 4 or 8 port UART.
915 */
916 if (up->port.flags & UPF_EXAR_EFR) {
917 status1 = serial_in(up, UART_EXAR_DVID);
918 if (status1 == 0x82 || status1 == 0x84 || status1 == 0x88) {
919 DEBUG_AUTOCONF("Exar XR17V35x ");
920 up->port.type = PORT_XR17V35X;
921 up->capabilities |= UART_CAP_AFE | UART_CAP_EFR |
922 UART_CAP_SLEEP;
923
924 return;
925 }
926
927 }
928
929 /*
885 * Check for presence of the EFR when DLAB is set. 930 * Check for presence of the EFR when DLAB is set.
886 * Only ST16C650V1 UARTs pass this test. 931 * Only ST16C650V1 UARTs pass this test.
887 */ 932 */
@@ -1013,8 +1058,12 @@ static void autoconfig_16550a(struct uart_8250_port *up)
1013 * Exar uarts have EFR in a weird location 1058 * Exar uarts have EFR in a weird location
1014 */ 1059 */
1015 if (up->port.flags & UPF_EXAR_EFR) { 1060 if (up->port.flags & UPF_EXAR_EFR) {
1061 DEBUG_AUTOCONF("Exar XR17D15x ");
1016 up->port.type = PORT_XR17D15X; 1062 up->port.type = PORT_XR17D15X;
1017 up->capabilities |= UART_CAP_AFE | UART_CAP_EFR; 1063 up->capabilities |= UART_CAP_AFE | UART_CAP_EFR |
1064 UART_CAP_SLEEP;
1065
1066 return;
1018 } 1067 }
1019 1068
1020 /* 1069 /*
@@ -1516,6 +1565,31 @@ static int serial8250_default_handle_irq(struct uart_port *port)
1516} 1565}
1517 1566
1518/* 1567/*
1568 * These Exar UARTs have an extra interrupt indicator that could
1569 * fire for a few unimplemented interrupts. One of which is a
1570 * wakeup event when coming out of sleep. Put this here just
1571 * to be on the safe side that these interrupts don't go unhandled.
1572 */
1573static int exar_handle_irq(struct uart_port *port)
1574{
1575 unsigned char int0, int1, int2, int3;
1576 unsigned int iir = serial_port_in(port, UART_IIR);
1577 int ret;
1578
1579 ret = serial8250_handle_irq(port, iir);
1580
1581 if ((port->type == PORT_XR17V35X) ||
1582 (port->type == PORT_XR17D15X)) {
1583 int0 = serial_port_in(port, 0x80);
1584 int1 = serial_port_in(port, 0x81);
1585 int2 = serial_port_in(port, 0x82);
1586 int3 = serial_port_in(port, 0x83);
1587 }
1588
1589 return ret;
1590}
1591
1592/*
1519 * This is the serial driver's interrupt routine. 1593 * This is the serial driver's interrupt routine.
1520 * 1594 *
1521 * Arjan thinks the old way was overly complex, so it got simplified. 1595 * Arjan thinks the old way was overly complex, so it got simplified.
@@ -2349,16 +2423,14 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2349 serial_port_out(port, UART_EFR, efr); 2423 serial_port_out(port, UART_EFR, efr);
2350 } 2424 }
2351 2425
2352#ifdef CONFIG_ARCH_OMAP1
2353 /* Workaround to enable 115200 baud on OMAP1510 internal ports */ 2426 /* Workaround to enable 115200 baud on OMAP1510 internal ports */
2354 if (cpu_is_omap1510() && is_omap_port(up)) { 2427 if (is_omap1510_8250(up)) {
2355 if (baud == 115200) { 2428 if (baud == 115200) {
2356 quot = 1; 2429 quot = 1;
2357 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 1); 2430 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 1);
2358 } else 2431 } else
2359 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 0); 2432 serial_port_out(port, UART_OMAP_OSC_12M_SEL, 0);
2360 } 2433 }
2361#endif
2362 2434
2363 /* 2435 /*
2364 * For NatSemi, switch to bank 2 not bank 1, to avoid resetting EXCR2, 2436 * For NatSemi, switch to bank 2 not bank 1, to avoid resetting EXCR2,
@@ -2439,10 +2511,9 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt)
2439{ 2511{
2440 if (pt->port.iotype == UPIO_AU) 2512 if (pt->port.iotype == UPIO_AU)
2441 return 0x1000; 2513 return 0x1000;
2442#ifdef CONFIG_ARCH_OMAP1 2514 if (is_omap1_8250(pt))
2443 if (is_omap_port(pt))
2444 return 0x16 << pt->port.regshift; 2515 return 0x16 << pt->port.regshift;
2445#endif 2516
2446 return 8 << pt->port.regshift; 2517 return 8 << pt->port.regshift;
2447} 2518}
2448 2519
@@ -2617,6 +2688,11 @@ static void serial8250_config_port(struct uart_port *port, int flags)
2617 serial8250_release_rsa_resource(up); 2688 serial8250_release_rsa_resource(up);
2618 if (port->type == PORT_UNKNOWN) 2689 if (port->type == PORT_UNKNOWN)
2619 serial8250_release_std_resource(up); 2690 serial8250_release_std_resource(up);
2691
2692 /* Fixme: probably not the best place for this */
2693 if ((port->type == PORT_XR17V35X) ||
2694 (port->type == PORT_XR17D15X))
2695 port->handle_irq = exar_handle_irq;
2620} 2696}
2621 2697
2622static int 2698static int
@@ -2992,7 +3068,7 @@ void serial8250_resume_port(int line)
2992 * list is terminated with a zero flags entry, which means we expect 3068 * list is terminated with a zero flags entry, which means we expect
2993 * all entries to have at least UPF_BOOT_AUTOCONF set. 3069 * all entries to have at least UPF_BOOT_AUTOCONF set.
2994 */ 3070 */
2995static int __devinit serial8250_probe(struct platform_device *dev) 3071static int serial8250_probe(struct platform_device *dev)
2996{ 3072{
2997 struct plat_serial8250_port *p = dev->dev.platform_data; 3073 struct plat_serial8250_port *p = dev->dev.platform_data;
2998 struct uart_8250_port uart; 3074 struct uart_8250_port uart;
@@ -3038,7 +3114,7 @@ static int __devinit serial8250_probe(struct platform_device *dev)
3038/* 3114/*
3039 * Remove serial ports registered against a platform device. 3115 * Remove serial ports registered against a platform device.
3040 */ 3116 */
3041static int __devexit serial8250_remove(struct platform_device *dev) 3117static int serial8250_remove(struct platform_device *dev)
3042{ 3118{
3043 int i; 3119 int i;
3044 3120
@@ -3081,7 +3157,7 @@ static int serial8250_resume(struct platform_device *dev)
3081 3157
3082static struct platform_driver serial8250_isa_driver = { 3158static struct platform_driver serial8250_isa_driver = {
3083 .probe = serial8250_probe, 3159 .probe = serial8250_probe,
3084 .remove = __devexit_p(serial8250_remove), 3160 .remove = serial8250_remove,
3085 .suspend = serial8250_suspend, 3161 .suspend = serial8250_suspend,
3086 .resume = serial8250_resume, 3162 .resume = serial8250_resume,
3087 .driver = { 3163 .driver = {
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 5a76f9c8d36..3b4ea84898c 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -106,3 +106,39 @@ static inline int serial8250_pnp_init(void) { return 0; }
106static inline void serial8250_pnp_exit(void) { } 106static inline void serial8250_pnp_exit(void) { }
107#endif 107#endif
108 108
109#ifdef CONFIG_ARCH_OMAP1
110static inline int is_omap1_8250(struct uart_8250_port *pt)
111{
112 int res;
113
114 switch (pt->port.mapbase) {
115 case OMAP1_UART1_BASE:
116 case OMAP1_UART2_BASE:
117 case OMAP1_UART3_BASE:
118 res = 1;
119 break;
120 default:
121 res = 0;
122 break;
123 }
124
125 return res;
126}
127
128static inline int is_omap1510_8250(struct uart_8250_port *pt)
129{
130 if (!cpu_is_omap1510())
131 return 0;
132
133 return is_omap1_8250(pt);
134}
135#else
136static inline int is_omap1_8250(struct uart_8250_port *pt)
137{
138 return 0;
139}
140static inline int is_omap1510_8250(struct uart_8250_port *pt)
141{
142 return 0;
143}
144#endif
diff --git a/drivers/tty/serial/8250/8250_acorn.c b/drivers/tty/serial/8250/8250_acorn.c
index 857498312a9..549aa07c0d2 100644
--- a/drivers/tty/serial/8250/8250_acorn.c
+++ b/drivers/tty/serial/8250/8250_acorn.c
@@ -38,7 +38,7 @@ struct serial_card_info {
38 void __iomem *vaddr; 38 void __iomem *vaddr;
39}; 39};
40 40
41static int __devinit 41static int
42serial_card_probe(struct expansion_card *ec, const struct ecard_id *id) 42serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
43{ 43{
44 struct serial_card_info *info; 44 struct serial_card_info *info;
@@ -80,7 +80,7 @@ serial_card_probe(struct expansion_card *ec, const struct ecard_id *id)
80 return 0; 80 return 0;
81} 81}
82 82
83static void __devexit serial_card_remove(struct expansion_card *ec) 83static void serial_card_remove(struct expansion_card *ec)
84{ 84{
85 struct serial_card_info *info = ecard_get_drvdata(ec); 85 struct serial_card_info *info = ecard_get_drvdata(ec);
86 int i; 86 int i;
@@ -116,7 +116,7 @@ static const struct ecard_id serial_cids[] = {
116 116
117static struct ecard_driver serial_card_driver = { 117static struct ecard_driver serial_card_driver = {
118 .probe = serial_card_probe, 118 .probe = serial_card_probe,
119 .remove = __devexit_p(serial_card_remove), 119 .remove = serial_card_remove,
120 .id_table = serial_cids, 120 .id_table = serial_cids,
121 .drv = { 121 .drv = {
122 .name = "8250_acorn", 122 .name = "8250_acorn",
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index c3b2ec0c8c0..1d0dba2d562 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -87,7 +87,7 @@ static int dw8250_handle_irq(struct uart_port *p)
87 return 0; 87 return 0;
88} 88}
89 89
90static int __devinit dw8250_probe(struct platform_device *pdev) 90static int dw8250_probe(struct platform_device *pdev)
91{ 91{
92 struct uart_8250_port uart = {}; 92 struct uart_8250_port uart = {};
93 struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 93 struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -152,7 +152,7 @@ static int __devinit dw8250_probe(struct platform_device *pdev)
152 return 0; 152 return 0;
153} 153}
154 154
155static int __devexit dw8250_remove(struct platform_device *pdev) 155static int dw8250_remove(struct platform_device *pdev)
156{ 156{
157 struct dw8250_data *data = platform_get_drvdata(pdev); 157 struct dw8250_data *data = platform_get_drvdata(pdev);
158 158
@@ -161,6 +161,29 @@ static int __devexit dw8250_remove(struct platform_device *pdev)
161 return 0; 161 return 0;
162} 162}
163 163
164#ifdef CONFIG_PM
165static int dw8250_suspend(struct platform_device *pdev, pm_message_t state)
166{
167 struct dw8250_data *data = platform_get_drvdata(pdev);
168
169 serial8250_suspend_port(data->line);
170
171 return 0;
172}
173
174static int dw8250_resume(struct platform_device *pdev)
175{
176 struct dw8250_data *data = platform_get_drvdata(pdev);
177
178 serial8250_resume_port(data->line);
179
180 return 0;
181}
182#else
183#define dw8250_suspend NULL
184#define dw8250_resume NULL
185#endif /* CONFIG_PM */
186
164static const struct of_device_id dw8250_match[] = { 187static const struct of_device_id dw8250_match[] = {
165 { .compatible = "snps,dw-apb-uart" }, 188 { .compatible = "snps,dw-apb-uart" },
166 { /* Sentinel */ } 189 { /* Sentinel */ }
@@ -174,7 +197,9 @@ static struct platform_driver dw8250_platform_driver = {
174 .of_match_table = dw8250_match, 197 .of_match_table = dw8250_match,
175 }, 198 },
176 .probe = dw8250_probe, 199 .probe = dw8250_probe,
177 .remove = __devexit_p(dw8250_remove), 200 .remove = dw8250_remove,
201 .suspend = dw8250_suspend,
202 .resume = dw8250_resume,
178}; 203};
179 204
180module_platform_driver(dw8250_platform_driver); 205module_platform_driver(dw8250_platform_driver);
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index eaafb98debe..f53a7db4350 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -48,7 +48,7 @@ struct early_serial8250_device {
48 48
49static struct early_serial8250_device early_device; 49static struct early_serial8250_device early_device;
50 50
51static unsigned int __init serial_in(struct uart_port *port, int offset) 51unsigned int __weak __init serial8250_early_in(struct uart_port *port, int offset)
52{ 52{
53 switch (port->iotype) { 53 switch (port->iotype) {
54 case UPIO_MEM: 54 case UPIO_MEM:
@@ -62,7 +62,7 @@ static unsigned int __init serial_in(struct uart_port *port, int offset)
62 } 62 }
63} 63}
64 64
65static void __init serial_out(struct uart_port *port, int offset, int value) 65void __weak __init serial8250_early_out(struct uart_port *port, int offset, int value)
66{ 66{
67 switch (port->iotype) { 67 switch (port->iotype) {
68 case UPIO_MEM: 68 case UPIO_MEM:
@@ -84,7 +84,7 @@ static void __init wait_for_xmitr(struct uart_port *port)
84 unsigned int status; 84 unsigned int status;
85 85
86 for (;;) { 86 for (;;) {
87 status = serial_in(port, UART_LSR); 87 status = serial8250_early_in(port, UART_LSR);
88 if ((status & BOTH_EMPTY) == BOTH_EMPTY) 88 if ((status & BOTH_EMPTY) == BOTH_EMPTY)
89 return; 89 return;
90 cpu_relax(); 90 cpu_relax();
@@ -94,7 +94,7 @@ static void __init wait_for_xmitr(struct uart_port *port)
94static void __init serial_putc(struct uart_port *port, int c) 94static void __init serial_putc(struct uart_port *port, int c)
95{ 95{
96 wait_for_xmitr(port); 96 wait_for_xmitr(port);
97 serial_out(port, UART_TX, c); 97 serial8250_early_out(port, UART_TX, c);
98} 98}
99 99
100static void __init early_serial8250_write(struct console *console, 100static void __init early_serial8250_write(struct console *console,
@@ -104,14 +104,14 @@ static void __init early_serial8250_write(struct console *console,
104 unsigned int ier; 104 unsigned int ier;
105 105
106 /* Save the IER and disable interrupts */ 106 /* Save the IER and disable interrupts */
107 ier = serial_in(port, UART_IER); 107 ier = serial8250_early_in(port, UART_IER);
108 serial_out(port, UART_IER, 0); 108 serial8250_early_out(port, UART_IER, 0);
109 109
110 uart_console_write(port, s, count, serial_putc); 110 uart_console_write(port, s, count, serial_putc);
111 111
112 /* Wait for transmitter to become empty and restore the IER */ 112 /* Wait for transmitter to become empty and restore the IER */
113 wait_for_xmitr(port); 113 wait_for_xmitr(port);
114 serial_out(port, UART_IER, ier); 114 serial8250_early_out(port, UART_IER, ier);
115} 115}
116 116
117static unsigned int __init probe_baud(struct uart_port *port) 117static unsigned int __init probe_baud(struct uart_port *port)
@@ -119,11 +119,11 @@ static unsigned int __init probe_baud(struct uart_port *port)
119 unsigned char lcr, dll, dlm; 119 unsigned char lcr, dll, dlm;
120 unsigned int quot; 120 unsigned int quot;
121 121
122 lcr = serial_in(port, UART_LCR); 122 lcr = serial8250_early_in(port, UART_LCR);
123 serial_out(port, UART_LCR, lcr | UART_LCR_DLAB); 123 serial8250_early_out(port, UART_LCR, lcr | UART_LCR_DLAB);
124 dll = serial_in(port, UART_DLL); 124 dll = serial8250_early_in(port, UART_DLL);
125 dlm = serial_in(port, UART_DLM); 125 dlm = serial8250_early_in(port, UART_DLM);
126 serial_out(port, UART_LCR, lcr); 126 serial8250_early_out(port, UART_LCR, lcr);
127 127
128 quot = (dlm << 8) | dll; 128 quot = (dlm << 8) | dll;
129 return (port->uartclk / 16) / quot; 129 return (port->uartclk / 16) / quot;
@@ -135,17 +135,17 @@ static void __init init_port(struct early_serial8250_device *device)
135 unsigned int divisor; 135 unsigned int divisor;
136 unsigned char c; 136 unsigned char c;
137 137
138 serial_out(port, UART_LCR, 0x3); /* 8n1 */ 138 serial8250_early_out(port, UART_LCR, 0x3); /* 8n1 */
139 serial_out(port, UART_IER, 0); /* no interrupt */ 139 serial8250_early_out(port, UART_IER, 0); /* no interrupt */
140 serial_out(port, UART_FCR, 0); /* no fifo */ 140 serial8250_early_out(port, UART_FCR, 0); /* no fifo */
141 serial_out(port, UART_MCR, 0x3); /* DTR + RTS */ 141 serial8250_early_out(port, UART_MCR, 0x3); /* DTR + RTS */
142 142
143 divisor = port->uartclk / (16 * device->baud); 143 divisor = DIV_ROUND_CLOSEST(port->uartclk, 16 * device->baud);
144 c = serial_in(port, UART_LCR); 144 c = serial8250_early_in(port, UART_LCR);
145 serial_out(port, UART_LCR, c | UART_LCR_DLAB); 145 serial8250_early_out(port, UART_LCR, c | UART_LCR_DLAB);
146 serial_out(port, UART_DLL, divisor & 0xff); 146 serial8250_early_out(port, UART_DLL, divisor & 0xff);
147 serial_out(port, UART_DLM, (divisor >> 8) & 0xff); 147 serial8250_early_out(port, UART_DLM, (divisor >> 8) & 0xff);
148 serial_out(port, UART_LCR, c & ~UART_LCR_DLAB); 148 serial8250_early_out(port, UART_LCR, c & ~UART_LCR_DLAB);
149} 149}
150 150
151static int __init parse_options(struct early_serial8250_device *device, 151static int __init parse_options(struct early_serial8250_device *device,
diff --git a/drivers/tty/serial/8250/8250_em.c b/drivers/tty/serial/8250/8250_em.c
index 3a0363e7f3a..916cc19fbbd 100644
--- a/drivers/tty/serial/8250/8250_em.c
+++ b/drivers/tty/serial/8250/8250_em.c
@@ -89,7 +89,7 @@ static void serial8250_em_serial_dl_write(struct uart_8250_port *up, int value)
89 serial_out(up, UART_DLM_EM, value >> 8 & 0xff); 89 serial_out(up, UART_DLM_EM, value >> 8 & 0xff);
90} 90}
91 91
92static int __devinit serial8250_em_probe(struct platform_device *pdev) 92static int serial8250_em_probe(struct platform_device *pdev)
93{ 93{
94 struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 94 struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
95 struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 95 struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -152,7 +152,7 @@ static int __devinit serial8250_em_probe(struct platform_device *pdev)
152 return ret; 152 return ret;
153} 153}
154 154
155static int __devexit serial8250_em_remove(struct platform_device *pdev) 155static int serial8250_em_remove(struct platform_device *pdev)
156{ 156{
157 struct serial8250_em_priv *priv = platform_get_drvdata(pdev); 157 struct serial8250_em_priv *priv = platform_get_drvdata(pdev);
158 158
@@ -163,7 +163,7 @@ static int __devexit serial8250_em_remove(struct platform_device *pdev)
163 return 0; 163 return 0;
164} 164}
165 165
166static const struct of_device_id serial8250_em_dt_ids[] __devinitconst = { 166static const struct of_device_id serial8250_em_dt_ids[] = {
167 { .compatible = "renesas,em-uart", }, 167 { .compatible = "renesas,em-uart", },
168 {}, 168 {},
169}; 169};
@@ -176,7 +176,7 @@ static struct platform_driver serial8250_em_platform_driver = {
176 .owner = THIS_MODULE, 176 .owner = THIS_MODULE,
177 }, 177 },
178 .probe = serial8250_em_probe, 178 .probe = serial8250_em_probe,
179 .remove = __devexit_p(serial8250_em_remove), 179 .remove = serial8250_em_remove,
180}; 180};
181 181
182module_platform_driver(serial8250_em_platform_driver); 182module_platform_driver(serial8250_em_platform_driver);
diff --git a/drivers/tty/serial/8250/8250_hp300.c b/drivers/tty/serial/8250/8250_hp300.c
index f3d0edf4664..5bdaf271d39 100644
--- a/drivers/tty/serial/8250/8250_hp300.c
+++ b/drivers/tty/serial/8250/8250_hp300.c
@@ -36,9 +36,9 @@ static struct hp300_port *hp300_ports;
36 36
37#ifdef CONFIG_HPDCA 37#ifdef CONFIG_HPDCA
38 38
39static int __devinit hpdca_init_one(struct dio_dev *d, 39static int hpdca_init_one(struct dio_dev *d,
40 const struct dio_device_id *ent); 40 const struct dio_device_id *ent);
41static void __devexit hpdca_remove_one(struct dio_dev *d); 41static void hpdca_remove_one(struct dio_dev *d);
42 42
43static struct dio_device_id hpdca_dio_tbl[] = { 43static struct dio_device_id hpdca_dio_tbl[] = {
44 { DIO_ID_DCA0 }, 44 { DIO_ID_DCA0 },
@@ -52,7 +52,7 @@ static struct dio_driver hpdca_driver = {
52 .name = "hpdca", 52 .name = "hpdca",
53 .id_table = hpdca_dio_tbl, 53 .id_table = hpdca_dio_tbl,
54 .probe = hpdca_init_one, 54 .probe = hpdca_init_one,
55 .remove = __devexit_p(hpdca_remove_one), 55 .remove = hpdca_remove_one,
56}; 56};
57 57
58#endif 58#endif
@@ -159,7 +159,7 @@ int __init hp300_setup_serial_console(void)
159#endif /* CONFIG_SERIAL_8250_CONSOLE */ 159#endif /* CONFIG_SERIAL_8250_CONSOLE */
160 160
161#ifdef CONFIG_HPDCA 161#ifdef CONFIG_HPDCA
162static int __devinit hpdca_init_one(struct dio_dev *d, 162static int hpdca_init_one(struct dio_dev *d,
163 const struct dio_device_id *ent) 163 const struct dio_device_id *ent)
164{ 164{
165 struct uart_8250_port uart; 165 struct uart_8250_port uart;
@@ -288,7 +288,7 @@ static int __init hp300_8250_init(void)
288} 288}
289 289
290#ifdef CONFIG_HPDCA 290#ifdef CONFIG_HPDCA
291static void __devexit hpdca_remove_one(struct dio_dev *d) 291static void hpdca_remove_one(struct dio_dev *d)
292{ 292{
293 int line; 293 int line;
294 294
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 17b7d26abf4..26b9dc012ed 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -288,7 +288,7 @@ static int pci_plx9050_init(struct pci_dev *dev)
288 return 0; 288 return 0;
289} 289}
290 290
291static void __devexit pci_plx9050_exit(struct pci_dev *dev) 291static void pci_plx9050_exit(struct pci_dev *dev)
292{ 292{
293 u8 __iomem *p; 293 u8 __iomem *p;
294 294
@@ -313,7 +313,7 @@ static void __devexit pci_plx9050_exit(struct pci_dev *dev)
313#define NI8420_INT_ENABLE_REG 0x38 313#define NI8420_INT_ENABLE_REG 0x38
314#define NI8420_INT_ENABLE_BIT 0x2000 314#define NI8420_INT_ENABLE_BIT 0x2000
315 315
316static void __devexit pci_ni8420_exit(struct pci_dev *dev) 316static void pci_ni8420_exit(struct pci_dev *dev)
317{ 317{
318 void __iomem *p; 318 void __iomem *p;
319 unsigned long base, len; 319 unsigned long base, len;
@@ -345,7 +345,7 @@ static void __devexit pci_ni8420_exit(struct pci_dev *dev)
345 345
346#define MITE_LCIMR2_CLR_CPU_IE (1 << 30) 346#define MITE_LCIMR2_CLR_CPU_IE (1 << 30)
347 347
348static void __devexit pci_ni8430_exit(struct pci_dev *dev) 348static void pci_ni8430_exit(struct pci_dev *dev)
349{ 349{
350 void __iomem *p; 350 void __iomem *p;
351 unsigned long base, len; 351 unsigned long base, len;
@@ -422,7 +422,7 @@ static int sbs_init(struct pci_dev *dev)
422 * Disables the global interrupt of PMC-OctalPro 422 * Disables the global interrupt of PMC-OctalPro
423 */ 423 */
424 424
425static void __devexit sbs_exit(struct pci_dev *dev) 425static void sbs_exit(struct pci_dev *dev)
426{ 426{
427 u8 __iomem *p; 427 u8 __iomem *p;
428 428
@@ -991,7 +991,7 @@ static int pci_ite887x_init(struct pci_dev *dev)
991 return ret; 991 return ret;
992} 992}
993 993
994static void __devexit pci_ite887x_exit(struct pci_dev *dev) 994static void pci_ite887x_exit(struct pci_dev *dev)
995{ 995{
996 u32 ioport; 996 u32 ioport;
997 /* the ioport is bit 0-15 in POSIO0R */ 997 /* the ioport is bit 0-15 in POSIO0R */
@@ -1068,7 +1068,7 @@ ce4100_serial_setup(struct serial_private *priv,
1068{ 1068{
1069 int ret; 1069 int ret;
1070 1070
1071 ret = setup_port(priv, port, 0, 0, board->reg_shift); 1071 ret = setup_port(priv, port, idx, 0, board->reg_shift);
1072 port->port.iotype = UPIO_MEM32; 1072 port->port.iotype = UPIO_MEM32;
1073 port->port.type = PORT_XSCALE; 1073 port->port.type = PORT_XSCALE;
1074 port->port.flags = (port->port.flags | UPF_FIXED_PORT | UPF_FIXED_TYPE); 1074 port->port.flags = (port->port.flags | UPF_FIXED_PORT | UPF_FIXED_TYPE);
@@ -1165,6 +1165,94 @@ pci_xr17c154_setup(struct serial_private *priv,
1165} 1165}
1166 1166
1167static int 1167static int
1168pci_xr17v35x_setup(struct serial_private *priv,
1169 const struct pciserial_board *board,
1170 struct uart_8250_port *port, int idx)
1171{
1172 u8 __iomem *p;
1173
1174 p = pci_ioremap_bar(priv->dev, 0);
1175 if (p == NULL)
1176 return -ENOMEM;
1177
1178 port->port.flags |= UPF_EXAR_EFR;
1179
1180 /*
1181 * Setup Multipurpose Input/Output pins.
1182 */
1183 if (idx == 0) {
1184 writeb(0x00, p + 0x8f); /*MPIOINT[7:0]*/
1185 writeb(0x00, p + 0x90); /*MPIOLVL[7:0]*/
1186 writeb(0x00, p + 0x91); /*MPIO3T[7:0]*/
1187 writeb(0x00, p + 0x92); /*MPIOINV[7:0]*/
1188 writeb(0x00, p + 0x93); /*MPIOSEL[7:0]*/
1189 writeb(0x00, p + 0x94); /*MPIOOD[7:0]*/
1190 writeb(0x00, p + 0x95); /*MPIOINT[15:8]*/
1191 writeb(0x00, p + 0x96); /*MPIOLVL[15:8]*/
1192 writeb(0x00, p + 0x97); /*MPIO3T[15:8]*/
1193 writeb(0x00, p + 0x98); /*MPIOINV[15:8]*/
1194 writeb(0x00, p + 0x99); /*MPIOSEL[15:8]*/
1195 writeb(0x00, p + 0x9a); /*MPIOOD[15:8]*/
1196 }
1197 writeb(0x00, p + UART_EXAR_8XMODE);
1198 writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
1199 writeb(128, p + UART_EXAR_TXTRG);
1200 writeb(128, p + UART_EXAR_RXTRG);
1201 iounmap(p);
1202
1203 return pci_default_setup(priv, board, port, idx);
1204}
1205
1206#define PCI_DEVICE_ID_COMMTECH_4222PCI335 0x0004
1207#define PCI_DEVICE_ID_COMMTECH_4224PCI335 0x0002
1208#define PCI_DEVICE_ID_COMMTECH_2324PCI335 0x000a
1209#define PCI_DEVICE_ID_COMMTECH_2328PCI335 0x000b
1210
1211static int
1212pci_fastcom335_setup(struct serial_private *priv,
1213 const struct pciserial_board *board,
1214 struct uart_8250_port *port, int idx)
1215{
1216 u8 __iomem *p;
1217
1218 p = pci_ioremap_bar(priv->dev, 0);
1219 if (p == NULL)
1220 return -ENOMEM;
1221
1222 port->port.flags |= UPF_EXAR_EFR;
1223
1224 /*
1225 * Setup Multipurpose Input/Output pins.
1226 */
1227 if (idx == 0) {
1228 switch (priv->dev->device) {
1229 case PCI_DEVICE_ID_COMMTECH_4222PCI335:
1230 case PCI_DEVICE_ID_COMMTECH_4224PCI335:
1231 writeb(0x78, p + 0x90); /* MPIOLVL[7:0] */
1232 writeb(0x00, p + 0x92); /* MPIOINV[7:0] */
1233 writeb(0x00, p + 0x93); /* MPIOSEL[7:0] */
1234 break;
1235 case PCI_DEVICE_ID_COMMTECH_2324PCI335:
1236 case PCI_DEVICE_ID_COMMTECH_2328PCI335:
1237 writeb(0x00, p + 0x90); /* MPIOLVL[7:0] */
1238 writeb(0xc0, p + 0x92); /* MPIOINV[7:0] */
1239 writeb(0xc0, p + 0x93); /* MPIOSEL[7:0] */
1240 break;
1241 }
1242 writeb(0x00, p + 0x8f); /* MPIOINT[7:0] */
1243 writeb(0x00, p + 0x91); /* MPIO3T[7:0] */
1244 writeb(0x00, p + 0x94); /* MPIOOD[7:0] */
1245 }
1246 writeb(0x00, p + UART_EXAR_8XMODE);
1247 writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
1248 writeb(32, p + UART_EXAR_TXTRG);
1249 writeb(32, p + UART_EXAR_RXTRG);
1250 iounmap(p);
1251
1252 return pci_default_setup(priv, board, port, idx);
1253}
1254
1255static int
1168pci_wch_ch353_setup(struct serial_private *priv, 1256pci_wch_ch353_setup(struct serial_private *priv,
1169 const struct pciserial_board *board, 1257 const struct pciserial_board *board,
1170 struct uart_8250_port *port, int idx) 1258 struct uart_8250_port *port, int idx)
@@ -1213,6 +1301,10 @@ pci_wch_ch353_setup(struct serial_private *priv,
1213#define PCI_VENDOR_ID_AGESTAR 0x5372 1301#define PCI_VENDOR_ID_AGESTAR 0x5372
1214#define PCI_DEVICE_ID_AGESTAR_9375 0x6872 1302#define PCI_DEVICE_ID_AGESTAR_9375 0x6872
1215#define PCI_VENDOR_ID_ASIX 0x9710 1303#define PCI_VENDOR_ID_ASIX 0x9710
1304#define PCI_DEVICE_ID_COMMTECH_4222PCIE 0x0019
1305#define PCI_DEVICE_ID_COMMTECH_4224PCIE 0x0020
1306#define PCI_DEVICE_ID_COMMTECH_4228PCIE 0x0021
1307
1216 1308
1217/* Unknown vendors/cards - this should not be in linux/pci_ids.h */ 1309/* Unknown vendors/cards - this should not be in linux/pci_ids.h */
1218#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584 1310#define PCI_SUBDEVICE_ID_UNKNOWN_0x1584 0x1584
@@ -1314,7 +1406,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1314 .subdevice = PCI_ANY_ID, 1406 .subdevice = PCI_ANY_ID,
1315 .init = pci_ite887x_init, 1407 .init = pci_ite887x_init,
1316 .setup = pci_default_setup, 1408 .setup = pci_default_setup,
1317 .exit = __devexit_p(pci_ite887x_exit), 1409 .exit = pci_ite887x_exit,
1318 }, 1410 },
1319 /* 1411 /*
1320 * National Instruments 1412 * National Instruments
@@ -1326,7 +1418,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1326 .subdevice = PCI_ANY_ID, 1418 .subdevice = PCI_ANY_ID,
1327 .init = pci_ni8420_init, 1419 .init = pci_ni8420_init,
1328 .setup = pci_default_setup, 1420 .setup = pci_default_setup,
1329 .exit = __devexit_p(pci_ni8420_exit), 1421 .exit = pci_ni8420_exit,
1330 }, 1422 },
1331 { 1423 {
1332 .vendor = PCI_VENDOR_ID_NI, 1424 .vendor = PCI_VENDOR_ID_NI,
@@ -1335,7 +1427,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1335 .subdevice = PCI_ANY_ID, 1427 .subdevice = PCI_ANY_ID,
1336 .init = pci_ni8420_init, 1428 .init = pci_ni8420_init,
1337 .setup = pci_default_setup, 1429 .setup = pci_default_setup,
1338 .exit = __devexit_p(pci_ni8420_exit), 1430 .exit = pci_ni8420_exit,
1339 }, 1431 },
1340 { 1432 {
1341 .vendor = PCI_VENDOR_ID_NI, 1433 .vendor = PCI_VENDOR_ID_NI,
@@ -1344,7 +1436,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1344 .subdevice = PCI_ANY_ID, 1436 .subdevice = PCI_ANY_ID,
1345 .init = pci_ni8420_init, 1437 .init = pci_ni8420_init,
1346 .setup = pci_default_setup, 1438 .setup = pci_default_setup,
1347 .exit = __devexit_p(pci_ni8420_exit), 1439 .exit = pci_ni8420_exit,
1348 }, 1440 },
1349 { 1441 {
1350 .vendor = PCI_VENDOR_ID_NI, 1442 .vendor = PCI_VENDOR_ID_NI,
@@ -1353,7 +1445,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1353 .subdevice = PCI_ANY_ID, 1445 .subdevice = PCI_ANY_ID,
1354 .init = pci_ni8420_init, 1446 .init = pci_ni8420_init,
1355 .setup = pci_default_setup, 1447 .setup = pci_default_setup,
1356 .exit = __devexit_p(pci_ni8420_exit), 1448 .exit = pci_ni8420_exit,
1357 }, 1449 },
1358 { 1450 {
1359 .vendor = PCI_VENDOR_ID_NI, 1451 .vendor = PCI_VENDOR_ID_NI,
@@ -1362,7 +1454,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1362 .subdevice = PCI_ANY_ID, 1454 .subdevice = PCI_ANY_ID,
1363 .init = pci_ni8420_init, 1455 .init = pci_ni8420_init,
1364 .setup = pci_default_setup, 1456 .setup = pci_default_setup,
1365 .exit = __devexit_p(pci_ni8420_exit), 1457 .exit = pci_ni8420_exit,
1366 }, 1458 },
1367 { 1459 {
1368 .vendor = PCI_VENDOR_ID_NI, 1460 .vendor = PCI_VENDOR_ID_NI,
@@ -1371,7 +1463,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1371 .subdevice = PCI_ANY_ID, 1463 .subdevice = PCI_ANY_ID,
1372 .init = pci_ni8420_init, 1464 .init = pci_ni8420_init,
1373 .setup = pci_default_setup, 1465 .setup = pci_default_setup,
1374 .exit = __devexit_p(pci_ni8420_exit), 1466 .exit = pci_ni8420_exit,
1375 }, 1467 },
1376 { 1468 {
1377 .vendor = PCI_VENDOR_ID_NI, 1469 .vendor = PCI_VENDOR_ID_NI,
@@ -1380,7 +1472,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1380 .subdevice = PCI_ANY_ID, 1472 .subdevice = PCI_ANY_ID,
1381 .init = pci_ni8420_init, 1473 .init = pci_ni8420_init,
1382 .setup = pci_default_setup, 1474 .setup = pci_default_setup,
1383 .exit = __devexit_p(pci_ni8420_exit), 1475 .exit = pci_ni8420_exit,
1384 }, 1476 },
1385 { 1477 {
1386 .vendor = PCI_VENDOR_ID_NI, 1478 .vendor = PCI_VENDOR_ID_NI,
@@ -1389,7 +1481,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1389 .subdevice = PCI_ANY_ID, 1481 .subdevice = PCI_ANY_ID,
1390 .init = pci_ni8420_init, 1482 .init = pci_ni8420_init,
1391 .setup = pci_default_setup, 1483 .setup = pci_default_setup,
1392 .exit = __devexit_p(pci_ni8420_exit), 1484 .exit = pci_ni8420_exit,
1393 }, 1485 },
1394 { 1486 {
1395 .vendor = PCI_VENDOR_ID_NI, 1487 .vendor = PCI_VENDOR_ID_NI,
@@ -1398,7 +1490,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1398 .subdevice = PCI_ANY_ID, 1490 .subdevice = PCI_ANY_ID,
1399 .init = pci_ni8420_init, 1491 .init = pci_ni8420_init,
1400 .setup = pci_default_setup, 1492 .setup = pci_default_setup,
1401 .exit = __devexit_p(pci_ni8420_exit), 1493 .exit = pci_ni8420_exit,
1402 }, 1494 },
1403 { 1495 {
1404 .vendor = PCI_VENDOR_ID_NI, 1496 .vendor = PCI_VENDOR_ID_NI,
@@ -1407,7 +1499,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1407 .subdevice = PCI_ANY_ID, 1499 .subdevice = PCI_ANY_ID,
1408 .init = pci_ni8420_init, 1500 .init = pci_ni8420_init,
1409 .setup = pci_default_setup, 1501 .setup = pci_default_setup,
1410 .exit = __devexit_p(pci_ni8420_exit), 1502 .exit = pci_ni8420_exit,
1411 }, 1503 },
1412 { 1504 {
1413 .vendor = PCI_VENDOR_ID_NI, 1505 .vendor = PCI_VENDOR_ID_NI,
@@ -1416,7 +1508,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1416 .subdevice = PCI_ANY_ID, 1508 .subdevice = PCI_ANY_ID,
1417 .init = pci_ni8420_init, 1509 .init = pci_ni8420_init,
1418 .setup = pci_default_setup, 1510 .setup = pci_default_setup,
1419 .exit = __devexit_p(pci_ni8420_exit), 1511 .exit = pci_ni8420_exit,
1420 }, 1512 },
1421 { 1513 {
1422 .vendor = PCI_VENDOR_ID_NI, 1514 .vendor = PCI_VENDOR_ID_NI,
@@ -1425,7 +1517,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1425 .subdevice = PCI_ANY_ID, 1517 .subdevice = PCI_ANY_ID,
1426 .init = pci_ni8420_init, 1518 .init = pci_ni8420_init,
1427 .setup = pci_default_setup, 1519 .setup = pci_default_setup,
1428 .exit = __devexit_p(pci_ni8420_exit), 1520 .exit = pci_ni8420_exit,
1429 }, 1521 },
1430 { 1522 {
1431 .vendor = PCI_VENDOR_ID_NI, 1523 .vendor = PCI_VENDOR_ID_NI,
@@ -1434,7 +1526,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1434 .subdevice = PCI_ANY_ID, 1526 .subdevice = PCI_ANY_ID,
1435 .init = pci_ni8430_init, 1527 .init = pci_ni8430_init,
1436 .setup = pci_ni8430_setup, 1528 .setup = pci_ni8430_setup,
1437 .exit = __devexit_p(pci_ni8430_exit), 1529 .exit = pci_ni8430_exit,
1438 }, 1530 },
1439 /* 1531 /*
1440 * Panacom 1532 * Panacom
@@ -1446,7 +1538,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1446 .subdevice = PCI_ANY_ID, 1538 .subdevice = PCI_ANY_ID,
1447 .init = pci_plx9050_init, 1539 .init = pci_plx9050_init,
1448 .setup = pci_default_setup, 1540 .setup = pci_default_setup,
1449 .exit = __devexit_p(pci_plx9050_exit), 1541 .exit = pci_plx9050_exit,
1450 }, 1542 },
1451 { 1543 {
1452 .vendor = PCI_VENDOR_ID_PANACOM, 1544 .vendor = PCI_VENDOR_ID_PANACOM,
@@ -1455,7 +1547,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1455 .subdevice = PCI_ANY_ID, 1547 .subdevice = PCI_ANY_ID,
1456 .init = pci_plx9050_init, 1548 .init = pci_plx9050_init,
1457 .setup = pci_default_setup, 1549 .setup = pci_default_setup,
1458 .exit = __devexit_p(pci_plx9050_exit), 1550 .exit = pci_plx9050_exit,
1459 }, 1551 },
1460 /* 1552 /*
1461 * PLX 1553 * PLX
@@ -1474,7 +1566,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1474 .subdevice = PCI_SUBDEVICE_ID_EXSYS_4055, 1566 .subdevice = PCI_SUBDEVICE_ID_EXSYS_4055,
1475 .init = pci_plx9050_init, 1567 .init = pci_plx9050_init,
1476 .setup = pci_default_setup, 1568 .setup = pci_default_setup,
1477 .exit = __devexit_p(pci_plx9050_exit), 1569 .exit = pci_plx9050_exit,
1478 }, 1570 },
1479 { 1571 {
1480 .vendor = PCI_VENDOR_ID_PLX, 1572 .vendor = PCI_VENDOR_ID_PLX,
@@ -1483,7 +1575,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1483 .subdevice = PCI_SUBDEVICE_ID_KEYSPAN_SX2, 1575 .subdevice = PCI_SUBDEVICE_ID_KEYSPAN_SX2,
1484 .init = pci_plx9050_init, 1576 .init = pci_plx9050_init,
1485 .setup = pci_default_setup, 1577 .setup = pci_default_setup,
1486 .exit = __devexit_p(pci_plx9050_exit), 1578 .exit = pci_plx9050_exit,
1487 }, 1579 },
1488 { 1580 {
1489 .vendor = PCI_VENDOR_ID_PLX, 1581 .vendor = PCI_VENDOR_ID_PLX,
@@ -1492,7 +1584,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1492 .subdevice = PCI_SUBDEVICE_ID_UNKNOWN_0x1584, 1584 .subdevice = PCI_SUBDEVICE_ID_UNKNOWN_0x1584,
1493 .init = pci_plx9050_init, 1585 .init = pci_plx9050_init,
1494 .setup = pci_default_setup, 1586 .setup = pci_default_setup,
1495 .exit = __devexit_p(pci_plx9050_exit), 1587 .exit = pci_plx9050_exit,
1496 }, 1588 },
1497 { 1589 {
1498 .vendor = PCI_VENDOR_ID_PLX, 1590 .vendor = PCI_VENDOR_ID_PLX,
@@ -1501,7 +1593,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1501 .subdevice = PCI_DEVICE_ID_PLX_ROMULUS, 1593 .subdevice = PCI_DEVICE_ID_PLX_ROMULUS,
1502 .init = pci_plx9050_init, 1594 .init = pci_plx9050_init,
1503 .setup = pci_default_setup, 1595 .setup = pci_default_setup,
1504 .exit = __devexit_p(pci_plx9050_exit), 1596 .exit = pci_plx9050_exit,
1505 }, 1597 },
1506 /* 1598 /*
1507 * SBS Technologies, Inc., PMC-OCTALPRO 232 1599 * SBS Technologies, Inc., PMC-OCTALPRO 232
@@ -1513,7 +1605,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1513 .subdevice = PCI_SUBDEVICE_ID_OCTPRO232, 1605 .subdevice = PCI_SUBDEVICE_ID_OCTPRO232,
1514 .init = sbs_init, 1606 .init = sbs_init,
1515 .setup = sbs_setup, 1607 .setup = sbs_setup,
1516 .exit = __devexit_p(sbs_exit), 1608 .exit = sbs_exit,
1517 }, 1609 },
1518 /* 1610 /*
1519 * SBS Technologies, Inc., PMC-OCTALPRO 422 1611 * SBS Technologies, Inc., PMC-OCTALPRO 422
@@ -1525,7 +1617,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1525 .subdevice = PCI_SUBDEVICE_ID_OCTPRO422, 1617 .subdevice = PCI_SUBDEVICE_ID_OCTPRO422,
1526 .init = sbs_init, 1618 .init = sbs_init,
1527 .setup = sbs_setup, 1619 .setup = sbs_setup,
1528 .exit = __devexit_p(sbs_exit), 1620 .exit = sbs_exit,
1529 }, 1621 },
1530 /* 1622 /*
1531 * SBS Technologies, Inc., P-Octal 232 1623 * SBS Technologies, Inc., P-Octal 232
@@ -1537,7 +1629,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1537 .subdevice = PCI_SUBDEVICE_ID_POCTAL232, 1629 .subdevice = PCI_SUBDEVICE_ID_POCTAL232,
1538 .init = sbs_init, 1630 .init = sbs_init,
1539 .setup = sbs_setup, 1631 .setup = sbs_setup,
1540 .exit = __devexit_p(sbs_exit), 1632 .exit = sbs_exit,
1541 }, 1633 },
1542 /* 1634 /*
1543 * SBS Technologies, Inc., P-Octal 422 1635 * SBS Technologies, Inc., P-Octal 422
@@ -1549,7 +1641,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1549 .subdevice = PCI_SUBDEVICE_ID_POCTAL422, 1641 .subdevice = PCI_SUBDEVICE_ID_POCTAL422,
1550 .init = sbs_init, 1642 .init = sbs_init,
1551 .setup = sbs_setup, 1643 .setup = sbs_setup,
1552 .exit = __devexit_p(sbs_exit), 1644 .exit = sbs_exit,
1553 }, 1645 },
1554 /* 1646 /*
1555 * SIIG cards - these may be called via parport_serial 1647 * SIIG cards - these may be called via parport_serial
@@ -1622,6 +1714,27 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1622 .subdevice = PCI_ANY_ID, 1714 .subdevice = PCI_ANY_ID,
1623 .setup = pci_xr17c154_setup, 1715 .setup = pci_xr17c154_setup,
1624 }, 1716 },
1717 {
1718 .vendor = PCI_VENDOR_ID_EXAR,
1719 .device = PCI_DEVICE_ID_EXAR_XR17V352,
1720 .subvendor = PCI_ANY_ID,
1721 .subdevice = PCI_ANY_ID,
1722 .setup = pci_xr17v35x_setup,
1723 },
1724 {
1725 .vendor = PCI_VENDOR_ID_EXAR,
1726 .device = PCI_DEVICE_ID_EXAR_XR17V354,
1727 .subvendor = PCI_ANY_ID,
1728 .subdevice = PCI_ANY_ID,
1729 .setup = pci_xr17v35x_setup,
1730 },
1731 {
1732 .vendor = PCI_VENDOR_ID_EXAR,
1733 .device = PCI_DEVICE_ID_EXAR_XR17V358,
1734 .subvendor = PCI_ANY_ID,
1735 .subdevice = PCI_ANY_ID,
1736 .setup = pci_xr17v35x_setup,
1737 },
1625 /* 1738 /*
1626 * Xircom cards 1739 * Xircom cards
1627 */ 1740 */
@@ -1788,6 +1901,59 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
1788 .setup = pci_asix_setup, 1901 .setup = pci_asix_setup,
1789 }, 1902 },
1790 /* 1903 /*
1904 * Commtech, Inc. Fastcom adapters
1905 *
1906 */
1907 {
1908 .vendor = PCI_VENDOR_ID_COMMTECH,
1909 .device = PCI_DEVICE_ID_COMMTECH_4222PCI335,
1910 .subvendor = PCI_ANY_ID,
1911 .subdevice = PCI_ANY_ID,
1912 .setup = pci_fastcom335_setup,
1913 },
1914 {
1915 .vendor = PCI_VENDOR_ID_COMMTECH,
1916 .device = PCI_DEVICE_ID_COMMTECH_4224PCI335,
1917 .subvendor = PCI_ANY_ID,
1918 .subdevice = PCI_ANY_ID,
1919 .setup = pci_fastcom335_setup,
1920 },
1921 {
1922 .vendor = PCI_VENDOR_ID_COMMTECH,
1923 .device = PCI_DEVICE_ID_COMMTECH_2324PCI335,
1924 .subvendor = PCI_ANY_ID,
1925 .subdevice = PCI_ANY_ID,
1926 .setup = pci_fastcom335_setup,
1927 },
1928 {
1929 .vendor = PCI_VENDOR_ID_COMMTECH,
1930 .device = PCI_DEVICE_ID_COMMTECH_2328PCI335,
1931 .subvendor = PCI_ANY_ID,
1932 .subdevice = PCI_ANY_ID,
1933 .setup = pci_fastcom335_setup,
1934 },
1935 {
1936 .vendor = PCI_VENDOR_ID_COMMTECH,
1937 .device = PCI_DEVICE_ID_COMMTECH_4222PCIE,
1938 .subvendor = PCI_ANY_ID,
1939 .subdevice = PCI_ANY_ID,
1940 .setup = pci_xr17v35x_setup,
1941 },
1942 {
1943 .vendor = PCI_VENDOR_ID_COMMTECH,
1944 .device = PCI_DEVICE_ID_COMMTECH_4224PCIE,
1945 .subvendor = PCI_ANY_ID,
1946 .subdevice = PCI_ANY_ID,
1947 .setup = pci_xr17v35x_setup,
1948 },
1949 {
1950 .vendor = PCI_VENDOR_ID_COMMTECH,
1951 .device = PCI_DEVICE_ID_COMMTECH_4228PCIE,
1952 .subvendor = PCI_ANY_ID,
1953 .subdevice = PCI_ANY_ID,
1954 .setup = pci_xr17v35x_setup,
1955 },
1956 /*
1791 * Default "match everything" terminator entry 1957 * Default "match everything" terminator entry
1792 */ 1958 */
1793 { 1959 {
@@ -1863,6 +2029,10 @@ enum pci_board_num_t {
1863 2029
1864 pbn_b0_4_1152000, 2030 pbn_b0_4_1152000,
1865 2031
2032 pbn_b0_2_1152000_200,
2033 pbn_b0_4_1152000_200,
2034 pbn_b0_8_1152000_200,
2035
1866 pbn_b0_2_1843200, 2036 pbn_b0_2_1843200,
1867 pbn_b0_4_1843200, 2037 pbn_b0_4_1843200,
1868 2038
@@ -1962,6 +2132,9 @@ enum pci_board_num_t {
1962 pbn_exar_XR17C152, 2132 pbn_exar_XR17C152,
1963 pbn_exar_XR17C154, 2133 pbn_exar_XR17C154,
1964 pbn_exar_XR17C158, 2134 pbn_exar_XR17C158,
2135 pbn_exar_XR17V352,
2136 pbn_exar_XR17V354,
2137 pbn_exar_XR17V358,
1965 pbn_exar_ibm_saturn, 2138 pbn_exar_ibm_saturn,
1966 pbn_pasemi_1682M, 2139 pbn_pasemi_1682M,
1967 pbn_ni8430_2, 2140 pbn_ni8430_2,
@@ -1987,7 +2160,7 @@ enum pci_board_num_t {
1987 * see first lines of serial_in() and serial_out() in 8250.c 2160 * see first lines of serial_in() and serial_out() in 8250.c
1988*/ 2161*/
1989 2162
1990static struct pciserial_board pci_boards[] __devinitdata = { 2163static struct pciserial_board pci_boards[] = {
1991 [pbn_default] = { 2164 [pbn_default] = {
1992 .flags = FL_BASE0, 2165 .flags = FL_BASE0,
1993 .num_ports = 1, 2166 .num_ports = 1,
@@ -2057,6 +2230,27 @@ static struct pciserial_board pci_boards[] __devinitdata = {
2057 .uart_offset = 8, 2230 .uart_offset = 8,
2058 }, 2231 },
2059 2232
2233 [pbn_b0_2_1152000_200] = {
2234 .flags = FL_BASE0,
2235 .num_ports = 2,
2236 .base_baud = 1152000,
2237 .uart_offset = 0x200,
2238 },
2239
2240 [pbn_b0_4_1152000_200] = {
2241 .flags = FL_BASE0,
2242 .num_ports = 4,
2243 .base_baud = 1152000,
2244 .uart_offset = 0x200,
2245 },
2246
2247 [pbn_b0_8_1152000_200] = {
2248 .flags = FL_BASE0,
2249 .num_ports = 2,
2250 .base_baud = 1152000,
2251 .uart_offset = 0x200,
2252 },
2253
2060 [pbn_b0_2_1843200] = { 2254 [pbn_b0_2_1843200] = {
2061 .flags = FL_BASE0, 2255 .flags = FL_BASE0,
2062 .num_ports = 2, 2256 .num_ports = 2,
@@ -2580,6 +2774,30 @@ static struct pciserial_board pci_boards[] __devinitdata = {
2580 .base_baud = 921600, 2774 .base_baud = 921600,
2581 .uart_offset = 0x200, 2775 .uart_offset = 0x200,
2582 }, 2776 },
2777 [pbn_exar_XR17V352] = {
2778 .flags = FL_BASE0,
2779 .num_ports = 2,
2780 .base_baud = 7812500,
2781 .uart_offset = 0x400,
2782 .reg_shift = 0,
2783 .first_offset = 0,
2784 },
2785 [pbn_exar_XR17V354] = {
2786 .flags = FL_BASE0,
2787 .num_ports = 4,
2788 .base_baud = 7812500,
2789 .uart_offset = 0x400,
2790 .reg_shift = 0,
2791 .first_offset = 0,
2792 },
2793 [pbn_exar_XR17V358] = {
2794 .flags = FL_BASE0,
2795 .num_ports = 8,
2796 .base_baud = 7812500,
2797 .uart_offset = 0x400,
2798 .reg_shift = 0,
2799 .first_offset = 0,
2800 },
2583 [pbn_exar_ibm_saturn] = { 2801 [pbn_exar_ibm_saturn] = {
2584 .flags = FL_BASE0, 2802 .flags = FL_BASE0,
2585 .num_ports = 1, 2803 .num_ports = 1,
@@ -2658,8 +2876,8 @@ static struct pciserial_board pci_boards[] __devinitdata = {
2658 .first_offset = 0x1000, 2876 .first_offset = 0x1000,
2659 }, 2877 },
2660 [pbn_ce4100_1_115200] = { 2878 [pbn_ce4100_1_115200] = {
2661 .flags = FL_BASE0, 2879 .flags = FL_BASE_BARS,
2662 .num_ports = 1, 2880 .num_ports = 2,
2663 .base_baud = 921600, 2881 .base_baud = 921600,
2664 .reg_shift = 2, 2882 .reg_shift = 2,
2665 }, 2883 },
@@ -2691,7 +2909,7 @@ static const struct pci_device_id blacklist[] = {
2691 * guess what the configuration might be, based on the pitiful PCI 2909 * guess what the configuration might be, based on the pitiful PCI
2692 * serial specs. Returns 0 on success, 1 on failure. 2910 * serial specs. Returns 0 on success, 1 on failure.
2693 */ 2911 */
2694static int __devinit 2912static int
2695serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) 2913serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board)
2696{ 2914{
2697 const struct pci_device_id *bldev; 2915 const struct pci_device_id *bldev;
@@ -2917,7 +3135,7 @@ EXPORT_SYMBOL_GPL(pciserial_resume_ports);
2917 * Probe one serial board. Unfortunately, there is no rhyme nor reason 3135 * Probe one serial board. Unfortunately, there is no rhyme nor reason
2918 * to the arrangement of serial ports on a PCI card. 3136 * to the arrangement of serial ports on a PCI card.
2919 */ 3137 */
2920static int __devinit 3138static int
2921pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) 3139pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
2922{ 3140{
2923 struct pci_serial_quirk *quirk; 3141 struct pci_serial_quirk *quirk;
@@ -2988,7 +3206,7 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
2988 return rc; 3206 return rc;
2989} 3207}
2990 3208
2991static void __devexit pciserial_remove_one(struct pci_dev *dev) 3209static void pciserial_remove_one(struct pci_dev *dev)
2992{ 3210{
2993 struct serial_private *priv = pci_get_drvdata(dev); 3211 struct serial_private *priv = pci_get_drvdata(dev);
2994 3212
@@ -3826,6 +4044,21 @@ static struct pci_device_id serial_pci_tbl[] = {
3826 PCI_ANY_ID, PCI_ANY_ID, 4044 PCI_ANY_ID, PCI_ANY_ID,
3827 0, 4045 0,
3828 0, pbn_exar_XR17C158 }, 4046 0, pbn_exar_XR17C158 },
4047 /*
4048 * Exar Corp. XR17V35[248] Dual/Quad/Octal PCIe UARTs
4049 */
4050 { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17V352,
4051 PCI_ANY_ID, PCI_ANY_ID,
4052 0,
4053 0, pbn_exar_XR17V352 },
4054 { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17V354,
4055 PCI_ANY_ID, PCI_ANY_ID,
4056 0,
4057 0, pbn_exar_XR17V354 },
4058 { PCI_VENDOR_ID_EXAR, PCI_DEVICE_ID_EXAR_XR17V358,
4059 PCI_ANY_ID, PCI_ANY_ID,
4060 0,
4061 0, pbn_exar_XR17V358 },
3829 4062
3830 /* 4063 /*
3831 * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke) 4064 * Topic TP560 Data/Fax/Voice 56k modem (reported by Evan Clarke)
@@ -4257,6 +4490,38 @@ static struct pci_device_id serial_pci_tbl[] = {
4257 0, 0, pbn_b0_bt_2_115200 }, 4490 0, 0, pbn_b0_bt_2_115200 },
4258 4491
4259 /* 4492 /*
4493 * Commtech, Inc. Fastcom adapters
4494 */
4495 { PCI_VENDOR_ID_COMMTECH, PCI_DEVICE_ID_COMMTECH_4222PCI335,
4496 PCI_ANY_ID, PCI_ANY_ID,
4497 0,
4498 0, pbn_b0_2_1152000_200 },
4499 { PCI_VENDOR_ID_COMMTECH, PCI_DEVICE_ID_COMMTECH_4224PCI335,
4500 PCI_ANY_ID, PCI_ANY_ID,
4501 0,
4502 0, pbn_b0_4_1152000_200 },
4503 { PCI_VENDOR_ID_COMMTECH, PCI_DEVICE_ID_COMMTECH_2324PCI335,
4504 PCI_ANY_ID, PCI_ANY_ID,
4505 0,
4506 0, pbn_b0_4_1152000_200 },
4507 { PCI_VENDOR_ID_COMMTECH, PCI_DEVICE_ID_COMMTECH_2328PCI335,
4508 PCI_ANY_ID, PCI_ANY_ID,
4509 0,
4510 0, pbn_b0_8_1152000_200 },
4511 { PCI_VENDOR_ID_COMMTECH, PCI_DEVICE_ID_COMMTECH_4222PCIE,
4512 PCI_ANY_ID, PCI_ANY_ID,
4513 0,
4514 0, pbn_exar_XR17V352 },
4515 { PCI_VENDOR_ID_COMMTECH, PCI_DEVICE_ID_COMMTECH_4224PCIE,
4516 PCI_ANY_ID, PCI_ANY_ID,
4517 0,
4518 0, pbn_exar_XR17V354 },
4519 { PCI_VENDOR_ID_COMMTECH, PCI_DEVICE_ID_COMMTECH_4228PCIE,
4520 PCI_ANY_ID, PCI_ANY_ID,
4521 0,
4522 0, pbn_exar_XR17V358 },
4523
4524 /*
4260 * These entries match devices with class COMMUNICATION_SERIAL, 4525 * These entries match devices with class COMMUNICATION_SERIAL,
4261 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL 4526 * COMMUNICATION_MODEM or COMMUNICATION_MULTISERIAL
4262 */ 4527 */
@@ -4323,7 +4588,7 @@ static const struct pci_error_handlers serial8250_err_handler = {
4323static struct pci_driver serial_pci_driver = { 4588static struct pci_driver serial_pci_driver = {
4324 .name = "serial", 4589 .name = "serial",
4325 .probe = pciserial_init_one, 4590 .probe = pciserial_init_one,
4326 .remove = __devexit_p(pciserial_remove_one), 4591 .remove = pciserial_remove_one,
4327#ifdef CONFIG_PM 4592#ifdef CONFIG_PM
4328 .suspend = pciserial_suspend_one, 4593 .suspend = pciserial_suspend_one,
4329 .resume = pciserial_resume_one, 4594 .resume = pciserial_resume_one,
@@ -4332,18 +4597,7 @@ static struct pci_driver serial_pci_driver = {
4332 .err_handler = &serial8250_err_handler, 4597 .err_handler = &serial8250_err_handler,
4333}; 4598};
4334 4599
4335static int __init serial8250_pci_init(void) 4600module_pci_driver(serial_pci_driver);
4336{
4337 return pci_register_driver(&serial_pci_driver);
4338}
4339
4340static void __exit serial8250_pci_exit(void)
4341{
4342 pci_unregister_driver(&serial_pci_driver);
4343}
4344
4345module_init(serial8250_pci_init);
4346module_exit(serial8250_pci_exit);
4347 4601
4348MODULE_LICENSE("GPL"); 4602MODULE_LICENSE("GPL");
4349MODULE_DESCRIPTION("Generic 8250/16x50 PCI serial probe module"); 4603MODULE_DESCRIPTION("Generic 8250/16x50 PCI serial probe module");
diff --git a/drivers/tty/serial/8250/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index f8ee25001dd..35d9ab95c5c 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -370,14 +370,14 @@ static const struct pnp_device_id pnp_dev_table[] = {
370 370
371MODULE_DEVICE_TABLE(pnp, pnp_dev_table); 371MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
372 372
373static char *modem_names[] __devinitdata = { 373static char *modem_names[] = {
374 "MODEM", "Modem", "modem", "FAX", "Fax", "fax", 374 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
375 "56K", "56k", "K56", "33.6", "28.8", "14.4", 375 "56K", "56k", "K56", "33.6", "28.8", "14.4",
376 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400", 376 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
377 "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL 377 "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
378}; 378};
379 379
380static int __devinit check_name(char *name) 380static int check_name(char *name)
381{ 381{
382 char **tmp; 382 char **tmp;
383 383
@@ -388,7 +388,7 @@ static int __devinit check_name(char *name)
388 return 0; 388 return 0;
389} 389}
390 390
391static int __devinit check_resources(struct pnp_dev *dev) 391static int check_resources(struct pnp_dev *dev)
392{ 392{
393 resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8}; 393 resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
394 int i; 394 int i;
@@ -412,7 +412,7 @@ static int __devinit check_resources(struct pnp_dev *dev)
412 * PnP modems, alternatively we must hardcode all modems in pnp_devices[] 412 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
413 * table. 413 * table.
414 */ 414 */
415static int __devinit serial_pnp_guess_board(struct pnp_dev *dev) 415static int serial_pnp_guess_board(struct pnp_dev *dev)
416{ 416{
417 if (!(check_name(pnp_dev_name(dev)) || 417 if (!(check_name(pnp_dev_name(dev)) ||
418 (dev->card && check_name(dev->card->name)))) 418 (dev->card && check_name(dev->card->name))))
@@ -424,7 +424,7 @@ static int __devinit serial_pnp_guess_board(struct pnp_dev *dev)
424 return -ENODEV; 424 return -ENODEV;
425} 425}
426 426
427static int __devinit 427static int
428serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id) 428serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
429{ 429{
430 struct uart_8250_port uart; 430 struct uart_8250_port uart;
@@ -476,7 +476,7 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
476 return 0; 476 return 0;
477} 477}
478 478
479static void __devexit serial_pnp_remove(struct pnp_dev *dev) 479static void serial_pnp_remove(struct pnp_dev *dev)
480{ 480{
481 long line = (long)pnp_get_drvdata(dev); 481 long line = (long)pnp_get_drvdata(dev);
482 if (line) 482 if (line)
@@ -511,7 +511,7 @@ static int serial_pnp_resume(struct pnp_dev *dev)
511static struct pnp_driver serial_pnp_driver = { 511static struct pnp_driver serial_pnp_driver = {
512 .name = "serial", 512 .name = "serial",
513 .probe = serial_pnp_probe, 513 .probe = serial_pnp_probe,
514 .remove = __devexit_p(serial_pnp_remove), 514 .remove = serial_pnp_remove,
515 .suspend = serial_pnp_suspend, 515 .suspend = serial_pnp_suspend,
516 .resume = serial_pnp_resume, 516 .resume = serial_pnp_resume,
517 .id_table = pnp_dev_table, 517 .id_table = pnp_dev_table,
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 2a53be5f010..59c23d03810 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -93,7 +93,7 @@ config SERIAL_SB1250_DUART_CONSOLE
93 93
94config SERIAL_ATMEL 94config SERIAL_ATMEL
95 bool "AT91 / AT32 on-chip serial port support" 95 bool "AT91 / AT32 on-chip serial port support"
96 depends on (ARM && ARCH_AT91) || AVR32 96 depends on ARCH_AT91 || AVR32
97 select SERIAL_CORE 97 select SERIAL_CORE
98 help 98 help
99 This enables the driver for the on-chip UARTs of the Atmel 99 This enables the driver for the on-chip UARTs of the Atmel
@@ -198,7 +198,7 @@ config SERIAL_CLPS711X_CONSOLE
198 198
199config SERIAL_SAMSUNG 199config SERIAL_SAMSUNG
200 tristate "Samsung SoC serial support" 200 tristate "Samsung SoC serial support"
201 depends on ARM && PLAT_SAMSUNG 201 depends on PLAT_SAMSUNG
202 select SERIAL_CORE 202 select SERIAL_CORE
203 help 203 help
204 Support for the on-chip UARTs on the Samsung S3C24XX series CPUs, 204 Support for the on-chip UARTs on the Samsung S3C24XX series CPUs,
@@ -208,14 +208,14 @@ config SERIAL_SAMSUNG
208 208
209config SERIAL_SAMSUNG_UARTS_4 209config SERIAL_SAMSUNG_UARTS_4
210 bool 210 bool
211 depends on ARM && PLAT_SAMSUNG 211 depends on PLAT_SAMSUNG
212 default y if !(CPU_S3C2410 || SERIAL_S3C2412 || CPU_S3C2440 || CPU_S3C2442) 212 default y if !(CPU_S3C2410 || SERIAL_S3C2412 || CPU_S3C2440 || CPU_S3C2442)
213 help 213 help
214 Internal node for the common case of 4 Samsung compatible UARTs 214 Internal node for the common case of 4 Samsung compatible UARTs
215 215
216config SERIAL_SAMSUNG_UARTS 216config SERIAL_SAMSUNG_UARTS
217 int 217 int
218 depends on ARM && PLAT_SAMSUNG 218 depends on PLAT_SAMSUNG
219 default 6 if ARCH_S5P6450 219 default 6 if ARCH_S5P6450
220 default 4 if SERIAL_SAMSUNG_UARTS_4 || CPU_S3C2416 220 default 4 if SERIAL_SAMSUNG_UARTS_4 || CPU_S3C2416
221 default 3 221 default 3
@@ -249,7 +249,7 @@ config SERIAL_SAMSUNG_CONSOLE
249 249
250config SERIAL_SIRFSOC 250config SERIAL_SIRFSOC
251 tristate "SiRF SoC Platform Serial port support" 251 tristate "SiRF SoC Platform Serial port support"
252 depends on ARM && ARCH_PRIMA2 252 depends on ARCH_PRIMA2
253 select SERIAL_CORE 253 select SERIAL_CORE
254 help 254 help
255 Support for the on-chip UART on the CSR SiRFprimaII series, 255 Support for the on-chip UART on the CSR SiRFprimaII series,
@@ -347,7 +347,7 @@ config SERIAL_ZS_CONSOLE
347 347
348config SERIAL_21285 348config SERIAL_21285
349 tristate "DC21285 serial port support" 349 tristate "DC21285 serial port support"
350 depends on ARM && FOOTBRIDGE 350 depends on FOOTBRIDGE
351 select SERIAL_CORE 351 select SERIAL_CORE
352 help 352 help
353 If you have a machine based on a 21285 (Footbridge) StrongARM(R)/ 353 If you have a machine based on a 21285 (Footbridge) StrongARM(R)/
@@ -371,7 +371,7 @@ config SERIAL_21285_CONSOLE
371 371
372config SERIAL_MPSC 372config SERIAL_MPSC
373 bool "Marvell MPSC serial port support" 373 bool "Marvell MPSC serial port support"
374 depends on PPC32 && MV64X60 374 depends on MV64X60
375 select SERIAL_CORE 375 select SERIAL_CORE
376 help 376 help
377 Say Y here if you want to use the Marvell MPSC serial controller. 377 Say Y here if you want to use the Marvell MPSC serial controller.
@@ -408,7 +408,7 @@ config SERIAL_PXA_CONSOLE
408 408
409config SERIAL_SA1100 409config SERIAL_SA1100
410 bool "SA1100 serial port support" 410 bool "SA1100 serial port support"
411 depends on ARM && ARCH_SA1100 411 depends on ARCH_SA1100
412 select SERIAL_CORE 412 select SERIAL_CORE
413 help 413 help
414 If you have a machine based on a SA1100/SA1110 StrongARM(R) CPU you 414 If you have a machine based on a SA1100/SA1110 StrongARM(R) CPU you
@@ -716,7 +716,7 @@ config SERIAL_SH_SCI_DMA
716 716
717config SERIAL_PNX8XXX 717config SERIAL_PNX8XXX
718 bool "Enable PNX8XXX SoCs' UART Support" 718 bool "Enable PNX8XXX SoCs' UART Support"
719 depends on MIPS && (SOC_PNX8550 || SOC_PNX833X) 719 depends on SOC_PNX8550 || SOC_PNX833X
720 select SERIAL_CORE 720 select SERIAL_CORE
721 help 721 help
722 If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330 722 If you have a MIPS-based Philips SoC such as PNX8550 or PNX8330
@@ -1013,7 +1013,7 @@ config SERIAL_SGI_IOC3
1013 1013
1014config SERIAL_MSM 1014config SERIAL_MSM
1015 bool "MSM on-chip serial port support" 1015 bool "MSM on-chip serial port support"
1016 depends on ARM && ARCH_MSM 1016 depends on ARCH_MSM
1017 select SERIAL_CORE 1017 select SERIAL_CORE
1018 1018
1019config SERIAL_MSM_CONSOLE 1019config SERIAL_MSM_CONSOLE
@@ -1035,7 +1035,7 @@ config SERIAL_MSM_HS
1035 1035
1036config SERIAL_VT8500 1036config SERIAL_VT8500
1037 bool "VIA VT8500 on-chip serial port support" 1037 bool "VIA VT8500 on-chip serial port support"
1038 depends on ARM && ARCH_VT8500 1038 depends on ARCH_VT8500
1039 select SERIAL_CORE 1039 select SERIAL_CORE
1040 1040
1041config SERIAL_VT8500_CONSOLE 1041config SERIAL_VT8500_CONSOLE
@@ -1045,7 +1045,7 @@ config SERIAL_VT8500_CONSOLE
1045 1045
1046config SERIAL_NETX 1046config SERIAL_NETX
1047 tristate "NetX serial port support" 1047 tristate "NetX serial port support"
1048 depends on ARM && ARCH_NETX 1048 depends on ARCH_NETX
1049 select SERIAL_CORE 1049 select SERIAL_CORE
1050 help 1050 help
1051 If you have a machine based on a Hilscher NetX SoC you 1051 If you have a machine based on a Hilscher NetX SoC you
@@ -1376,6 +1376,7 @@ config SERIAL_MXS_AUART_CONSOLE
1376 1376
1377config SERIAL_XILINX_PS_UART 1377config SERIAL_XILINX_PS_UART
1378 tristate "Xilinx PS UART support" 1378 tristate "Xilinx PS UART support"
1379 depends on OF
1379 select SERIAL_CORE 1380 select SERIAL_CORE
1380 help 1381 help
1381 This driver supports the Xilinx PS UART port. 1382 This driver supports the Xilinx PS UART port.
@@ -1423,4 +1424,27 @@ config SERIAL_EFM32_UART_CONSOLE
1423 depends on SERIAL_EFM32_UART=y 1424 depends on SERIAL_EFM32_UART=y
1424 select SERIAL_CORE_CONSOLE 1425 select SERIAL_CORE_CONSOLE
1425 1426
1427config SERIAL_ARC
1428 tristate "ARC UART driver support"
1429 select SERIAL_CORE
1430 help
1431 Driver for on-chip UART for ARC(Synopsys) for the legacy
1432 FPGA Boards (ML50x/ARCAngel4)
1433
1434config SERIAL_ARC_CONSOLE
1435 bool "Console on ARC UART"
1436 depends on SERIAL_ARC=y
1437 select SERIAL_CORE_CONSOLE
1438 help
1439 Enable system Console on ARC UART
1440
1441config SERIAL_ARC_NR_PORTS
1442 int "Number of ARC UART ports"
1443 depends on SERIAL_ARC
1444 range 1 3
1445 default "1"
1446 help
1447 Set this to the number of serial ports you want the driver
1448 to support.
1449
1426endmenu 1450endmenu
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index 4f694dafa71..df1b998c436 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o
82obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o 82obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o
83obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o 83obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o
84obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o 84obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o
85obj-$(CONFIG_SERIAL_ARC) += arc_uart.o
diff --git a/drivers/tty/serial/altera_jtaguart.c b/drivers/tty/serial/altera_jtaguart.c
index 530181e49f6..872f14ae43d 100644
--- a/drivers/tty/serial/altera_jtaguart.c
+++ b/drivers/tty/serial/altera_jtaguart.c
@@ -406,7 +406,7 @@ static struct uart_driver altera_jtaguart_driver = {
406 .cons = ALTERA_JTAGUART_CONSOLE, 406 .cons = ALTERA_JTAGUART_CONSOLE,
407}; 407};
408 408
409static int __devinit altera_jtaguart_probe(struct platform_device *pdev) 409static int altera_jtaguart_probe(struct platform_device *pdev)
410{ 410{
411 struct altera_jtaguart_platform_uart *platp = pdev->dev.platform_data; 411 struct altera_jtaguart_platform_uart *platp = pdev->dev.platform_data;
412 struct uart_port *port; 412 struct uart_port *port;
@@ -453,7 +453,7 @@ static int __devinit altera_jtaguart_probe(struct platform_device *pdev)
453 return 0; 453 return 0;
454} 454}
455 455
456static int __devexit altera_jtaguart_remove(struct platform_device *pdev) 456static int altera_jtaguart_remove(struct platform_device *pdev)
457{ 457{
458 struct uart_port *port; 458 struct uart_port *port;
459 int i = pdev->id; 459 int i = pdev->id;
@@ -477,7 +477,7 @@ MODULE_DEVICE_TABLE(of, altera_jtaguart_match);
477 477
478static struct platform_driver altera_jtaguart_platform_driver = { 478static struct platform_driver altera_jtaguart_platform_driver = {
479 .probe = altera_jtaguart_probe, 479 .probe = altera_jtaguart_probe,
480 .remove = __devexit_p(altera_jtaguart_remove), 480 .remove = altera_jtaguart_remove,
481 .driver = { 481 .driver = {
482 .name = DRV_NAME, 482 .name = DRV_NAME,
483 .owner = THIS_MODULE, 483 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c
index 15d80b9fb30..684a0808e1c 100644
--- a/drivers/tty/serial/altera_uart.c
+++ b/drivers/tty/serial/altera_uart.c
@@ -532,7 +532,7 @@ static int altera_uart_get_of_uartclk(struct platform_device *pdev,
532} 532}
533#endif /* CONFIG_OF */ 533#endif /* CONFIG_OF */
534 534
535static int __devinit altera_uart_probe(struct platform_device *pdev) 535static int altera_uart_probe(struct platform_device *pdev)
536{ 536{
537 struct altera_uart_platform_uart *platp = pdev->dev.platform_data; 537 struct altera_uart_platform_uart *platp = pdev->dev.platform_data;
538 struct uart_port *port; 538 struct uart_port *port;
@@ -598,7 +598,7 @@ static int __devinit altera_uart_probe(struct platform_device *pdev)
598 return 0; 598 return 0;
599} 599}
600 600
601static int __devexit altera_uart_remove(struct platform_device *pdev) 601static int altera_uart_remove(struct platform_device *pdev)
602{ 602{
603 struct uart_port *port = platform_get_drvdata(pdev); 603 struct uart_port *port = platform_get_drvdata(pdev);
604 604
@@ -621,7 +621,7 @@ MODULE_DEVICE_TABLE(of, altera_uart_match);
621 621
622static struct platform_driver altera_uart_platform_driver = { 622static struct platform_driver altera_uart_platform_driver = {
623 .probe = altera_uart_probe, 623 .probe = altera_uart_probe,
624 .remove = __devexit_p(altera_uart_remove), 624 .remove = altera_uart_remove,
625 .driver = { 625 .driver = {
626 .name = DRV_NAME, 626 .name = DRV_NAME,
627 .owner = THIS_MODULE, 627 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index d7e1edec50b..7fca4022a8b 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -56,8 +56,7 @@
56#include <linux/of_device.h> 56#include <linux/of_device.h>
57#include <linux/pinctrl/consumer.h> 57#include <linux/pinctrl/consumer.h>
58#include <linux/sizes.h> 58#include <linux/sizes.h>
59 59#include <linux/io.h>
60#include <asm/io.h>
61 60
62#define UART_NR 14 61#define UART_NR 14
63 62
@@ -1973,7 +1972,8 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1973 goto out; 1972 goto out;
1974 } 1973 }
1975 1974
1976 uap = kzalloc(sizeof(struct uart_amba_port), GFP_KERNEL); 1975 uap = devm_kzalloc(&dev->dev, sizeof(struct uart_amba_port),
1976 GFP_KERNEL);
1977 if (uap == NULL) { 1977 if (uap == NULL) {
1978 ret = -ENOMEM; 1978 ret = -ENOMEM;
1979 goto out; 1979 goto out;
@@ -1981,16 +1981,17 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
1981 1981
1982 i = pl011_probe_dt_alias(i, &dev->dev); 1982 i = pl011_probe_dt_alias(i, &dev->dev);
1983 1983
1984 base = ioremap(dev->res.start, resource_size(&dev->res)); 1984 base = devm_ioremap(&dev->dev, dev->res.start,
1985 resource_size(&dev->res));
1985 if (!base) { 1986 if (!base) {
1986 ret = -ENOMEM; 1987 ret = -ENOMEM;
1987 goto free; 1988 goto out;
1988 } 1989 }
1989 1990
1990 uap->pinctrl = devm_pinctrl_get(&dev->dev); 1991 uap->pinctrl = devm_pinctrl_get(&dev->dev);
1991 if (IS_ERR(uap->pinctrl)) { 1992 if (IS_ERR(uap->pinctrl)) {
1992 ret = PTR_ERR(uap->pinctrl); 1993 ret = PTR_ERR(uap->pinctrl);
1993 goto unmap; 1994 goto out;
1994 } 1995 }
1995 uap->pins_default = pinctrl_lookup_state(uap->pinctrl, 1996 uap->pins_default = pinctrl_lookup_state(uap->pinctrl,
1996 PINCTRL_STATE_DEFAULT); 1997 PINCTRL_STATE_DEFAULT);
@@ -2002,10 +2003,10 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2002 if (IS_ERR(uap->pins_sleep)) 2003 if (IS_ERR(uap->pins_sleep))
2003 dev_dbg(&dev->dev, "could not get sleep pinstate\n"); 2004 dev_dbg(&dev->dev, "could not get sleep pinstate\n");
2004 2005
2005 uap->clk = clk_get(&dev->dev, NULL); 2006 uap->clk = devm_clk_get(&dev->dev, NULL);
2006 if (IS_ERR(uap->clk)) { 2007 if (IS_ERR(uap->clk)) {
2007 ret = PTR_ERR(uap->clk); 2008 ret = PTR_ERR(uap->clk);
2008 goto unmap; 2009 goto out;
2009 } 2010 }
2010 2011
2011 uap->vendor = vendor; 2012 uap->vendor = vendor;
@@ -2038,11 +2039,6 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
2038 amba_set_drvdata(dev, NULL); 2039 amba_set_drvdata(dev, NULL);
2039 amba_ports[i] = NULL; 2040 amba_ports[i] = NULL;
2040 pl011_dma_remove(uap); 2041 pl011_dma_remove(uap);
2041 clk_put(uap->clk);
2042 unmap:
2043 iounmap(base);
2044 free:
2045 kfree(uap);
2046 } 2042 }
2047 out: 2043 out:
2048 return ret; 2044 return ret;
@@ -2062,9 +2058,6 @@ static int pl011_remove(struct amba_device *dev)
2062 amba_ports[i] = NULL; 2058 amba_ports[i] = NULL;
2063 2059
2064 pl011_dma_remove(uap); 2060 pl011_dma_remove(uap);
2065 iounmap(uap->port.membase);
2066 clk_put(uap->clk);
2067 kfree(uap);
2068 return 0; 2061 return 0;
2069} 2062}
2070 2063
diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c
index 7162f70d926..59ae2b53e76 100644
--- a/drivers/tty/serial/apbuart.c
+++ b/drivers/tty/serial/apbuart.c
@@ -554,7 +554,7 @@ static struct uart_driver grlib_apbuart_driver = {
554/* OF Platform Driver */ 554/* OF Platform Driver */
555/* ======================================================================== */ 555/* ======================================================================== */
556 556
557static int __devinit apbuart_probe(struct platform_device *op) 557static int apbuart_probe(struct platform_device *op)
558{ 558{
559 int i; 559 int i;
560 struct uart_port *port = NULL; 560 struct uart_port *port = NULL;
diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index e4f60e2b87f..505c490c0b4 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -25,11 +25,19 @@
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/irq.h> 26#include <linux/irq.h>
27 27
28#include <asm/div64.h>
29
28#include <asm/mach-ath79/ar933x_uart.h> 30#include <asm/mach-ath79/ar933x_uart.h>
29#include <asm/mach-ath79/ar933x_uart_platform.h> 31#include <asm/mach-ath79/ar933x_uart_platform.h>
30 32
31#define DRIVER_NAME "ar933x-uart" 33#define DRIVER_NAME "ar933x-uart"
32 34
35#define AR933X_UART_MAX_SCALE 0xff
36#define AR933X_UART_MAX_STEP 0xffff
37
38#define AR933X_UART_MIN_BAUD 300
39#define AR933X_UART_MAX_BAUD 3000000
40
33#define AR933X_DUMMY_STATUS_RD 0x01 41#define AR933X_DUMMY_STATUS_RD 0x01
34 42
35static struct uart_driver ar933x_uart_driver; 43static struct uart_driver ar933x_uart_driver;
@@ -37,6 +45,8 @@ static struct uart_driver ar933x_uart_driver;
37struct ar933x_uart_port { 45struct ar933x_uart_port {
38 struct uart_port port; 46 struct uart_port port;
39 unsigned int ier; /* shadow Interrupt Enable Register */ 47 unsigned int ier; /* shadow Interrupt Enable Register */
48 unsigned int min_baud;
49 unsigned int max_baud;
40}; 50};
41 51
42static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, 52static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up,
@@ -162,6 +172,57 @@ static void ar933x_uart_enable_ms(struct uart_port *port)
162{ 172{
163} 173}
164 174
175/*
176 * baudrate = (clk / (scale + 1)) * (step * (1 / 2^17))
177 */
178static unsigned long ar933x_uart_get_baud(unsigned int clk,
179 unsigned int scale,
180 unsigned int step)
181{
182 u64 t;
183 u32 div;
184
185 div = (2 << 16) * (scale + 1);
186 t = clk;
187 t *= step;
188 t += (div / 2);
189 do_div(t, div);
190
191 return t;
192}
193
194static void ar933x_uart_get_scale_step(unsigned int clk,
195 unsigned int baud,
196 unsigned int *scale,
197 unsigned int *step)
198{
199 unsigned int tscale;
200 long min_diff;
201
202 *scale = 0;
203 *step = 0;
204
205 min_diff = baud;
206 for (tscale = 0; tscale < AR933X_UART_MAX_SCALE; tscale++) {
207 u64 tstep;
208 int diff;
209
210 tstep = baud * (tscale + 1);
211 tstep *= (2 << 16);
212 do_div(tstep, clk);
213
214 if (tstep > AR933X_UART_MAX_STEP)
215 break;
216
217 diff = abs(ar933x_uart_get_baud(clk, tscale, tstep) - baud);
218 if (diff < min_diff) {
219 min_diff = diff;
220 *scale = tscale;
221 *step = tstep;
222 }
223 }
224}
225
165static void ar933x_uart_set_termios(struct uart_port *port, 226static void ar933x_uart_set_termios(struct uart_port *port,
166 struct ktermios *new, 227 struct ktermios *new,
167 struct ktermios *old) 228 struct ktermios *old)
@@ -169,7 +230,7 @@ static void ar933x_uart_set_termios(struct uart_port *port,
169 struct ar933x_uart_port *up = (struct ar933x_uart_port *) port; 230 struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
170 unsigned int cs; 231 unsigned int cs;
171 unsigned long flags; 232 unsigned long flags;
172 unsigned int baud, scale; 233 unsigned int baud, scale, step;
173 234
174 /* Only CS8 is supported */ 235 /* Only CS8 is supported */
175 new->c_cflag &= ~CSIZE; 236 new->c_cflag &= ~CSIZE;
@@ -191,8 +252,8 @@ static void ar933x_uart_set_termios(struct uart_port *port,
191 /* Mark/space parity is not supported */ 252 /* Mark/space parity is not supported */
192 new->c_cflag &= ~CMSPAR; 253 new->c_cflag &= ~CMSPAR;
193 254
194 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); 255 baud = uart_get_baud_rate(port, new, old, up->min_baud, up->max_baud);
195 scale = (port->uartclk / (16 * baud)) - 1; 256 ar933x_uart_get_scale_step(port->uartclk, baud, &scale, &step);
196 257
197 /* 258 /*
198 * Ok, we're now changing the port state. Do it with 259 * Ok, we're now changing the port state. Do it with
@@ -200,6 +261,10 @@ static void ar933x_uart_set_termios(struct uart_port *port,
200 */ 261 */
201 spin_lock_irqsave(&up->port.lock, flags); 262 spin_lock_irqsave(&up->port.lock, flags);
202 263
264 /* disable the UART */
265 ar933x_uart_rmw_clear(up, AR933X_UART_CS_REG,
266 AR933X_UART_CS_IF_MODE_M << AR933X_UART_CS_IF_MODE_S);
267
203 /* Update the per-port timeout. */ 268 /* Update the per-port timeout. */
204 uart_update_timeout(port, new->c_cflag, baud); 269 uart_update_timeout(port, new->c_cflag, baud);
205 270
@@ -210,7 +275,7 @@ static void ar933x_uart_set_termios(struct uart_port *port,
210 up->port.ignore_status_mask |= AR933X_DUMMY_STATUS_RD; 275 up->port.ignore_status_mask |= AR933X_DUMMY_STATUS_RD;
211 276
212 ar933x_uart_write(up, AR933X_UART_CLOCK_REG, 277 ar933x_uart_write(up, AR933X_UART_CLOCK_REG,
213 scale << AR933X_UART_CLOCK_SCALE_S | 8192); 278 scale << AR933X_UART_CLOCK_SCALE_S | step);
214 279
215 /* setup configuration register */ 280 /* setup configuration register */
216 ar933x_uart_rmw(up, AR933X_UART_CS_REG, AR933X_UART_CS_PARITY_M, cs); 281 ar933x_uart_rmw(up, AR933X_UART_CS_REG, AR933X_UART_CS_PARITY_M, cs);
@@ -219,6 +284,11 @@ static void ar933x_uart_set_termios(struct uart_port *port,
219 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, 284 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG,
220 AR933X_UART_CS_HOST_INT_EN); 285 AR933X_UART_CS_HOST_INT_EN);
221 286
287 /* reenable the UART */
288 ar933x_uart_rmw(up, AR933X_UART_CS_REG,
289 AR933X_UART_CS_IF_MODE_M << AR933X_UART_CS_IF_MODE_S,
290 AR933X_UART_CS_IF_MODE_DCE << AR933X_UART_CS_IF_MODE_S);
291
222 spin_unlock_irqrestore(&up->port.lock, flags); 292 spin_unlock_irqrestore(&up->port.lock, flags);
223 293
224 if (tty_termios_baud_rate(new)) 294 if (tty_termios_baud_rate(new))
@@ -401,6 +471,8 @@ static void ar933x_uart_config_port(struct uart_port *port, int flags)
401static int ar933x_uart_verify_port(struct uart_port *port, 471static int ar933x_uart_verify_port(struct uart_port *port,
402 struct serial_struct *ser) 472 struct serial_struct *ser)
403{ 473{
474 struct ar933x_uart_port *up = (struct ar933x_uart_port *) port;
475
404 if (ser->type != PORT_UNKNOWN && 476 if (ser->type != PORT_UNKNOWN &&
405 ser->type != PORT_AR933X) 477 ser->type != PORT_AR933X)
406 return -EINVAL; 478 return -EINVAL;
@@ -408,7 +480,8 @@ static int ar933x_uart_verify_port(struct uart_port *port,
408 if (ser->irq < 0 || ser->irq >= NR_IRQS) 480 if (ser->irq < 0 || ser->irq >= NR_IRQS)
409 return -EINVAL; 481 return -EINVAL;
410 482
411 if (ser->baud_base < 28800) 483 if (ser->baud_base < up->min_baud ||
484 ser->baud_base > up->max_baud)
412 return -EINVAL; 485 return -EINVAL;
413 486
414 return 0; 487 return 0;
@@ -554,13 +627,14 @@ static struct uart_driver ar933x_uart_driver = {
554 .cons = AR933X_SERIAL_CONSOLE, 627 .cons = AR933X_SERIAL_CONSOLE,
555}; 628};
556 629
557static int __devinit ar933x_uart_probe(struct platform_device *pdev) 630static int ar933x_uart_probe(struct platform_device *pdev)
558{ 631{
559 struct ar933x_uart_platform_data *pdata; 632 struct ar933x_uart_platform_data *pdata;
560 struct ar933x_uart_port *up; 633 struct ar933x_uart_port *up;
561 struct uart_port *port; 634 struct uart_port *port;
562 struct resource *mem_res; 635 struct resource *mem_res;
563 struct resource *irq_res; 636 struct resource *irq_res;
637 unsigned int baud;
564 int id; 638 int id;
565 int ret; 639 int ret;
566 640
@@ -611,6 +685,12 @@ static int __devinit ar933x_uart_probe(struct platform_device *pdev)
611 port->fifosize = AR933X_UART_FIFO_SIZE; 685 port->fifosize = AR933X_UART_FIFO_SIZE;
612 port->ops = &ar933x_uart_ops; 686 port->ops = &ar933x_uart_ops;
613 687
688 baud = ar933x_uart_get_baud(port->uartclk, AR933X_UART_MAX_SCALE, 1);
689 up->min_baud = max_t(unsigned int, baud, AR933X_UART_MIN_BAUD);
690
691 baud = ar933x_uart_get_baud(port->uartclk, 0, AR933X_UART_MAX_STEP);
692 up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD);
693
614 ar933x_uart_add_console_port(up); 694 ar933x_uart_add_console_port(up);
615 695
616 ret = uart_add_one_port(&ar933x_uart_driver, &up->port); 696 ret = uart_add_one_port(&ar933x_uart_driver, &up->port);
@@ -627,7 +707,7 @@ err_free_up:
627 return ret; 707 return ret;
628} 708}
629 709
630static int __devexit ar933x_uart_remove(struct platform_device *pdev) 710static int ar933x_uart_remove(struct platform_device *pdev)
631{ 711{
632 struct ar933x_uart_port *up; 712 struct ar933x_uart_port *up;
633 713
@@ -645,7 +725,7 @@ static int __devexit ar933x_uart_remove(struct platform_device *pdev)
645 725
646static struct platform_driver ar933x_uart_platform_driver = { 726static struct platform_driver ar933x_uart_platform_driver = {
647 .probe = ar933x_uart_probe, 727 .probe = ar933x_uart_probe,
648 .remove = __devexit_p(ar933x_uart_remove), 728 .remove = ar933x_uart_remove,
649 .driver = { 729 .driver = {
650 .name = DRIVER_NAME, 730 .name = DRIVER_NAME,
651 .owner = THIS_MODULE, 731 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
new file mode 100644
index 00000000000..3e0b3fac6a0
--- /dev/null
+++ b/drivers/tty/serial/arc_uart.c
@@ -0,0 +1,746 @@
1/*
2 * ARC On-Chip(fpga) UART Driver
3 *
4 * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com)
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * vineetg: July 10th 2012
11 * -Decoupled the driver from arch/arc
12 * +Using platform_get_resource() for irq/membase (thx to bfin_uart.c)
13 * +Using early_platform_xxx() for early console (thx to mach-shmobile/xxx)
14 *
15 * Vineetg: Aug 21st 2010
16 * -Is uart_tx_stopped() not done in tty write path as it has already been
17 * taken care of, in serial core
18 *
19 * Vineetg: Aug 18th 2010
20 * -New Serial Core based ARC UART driver
21 * -Derived largely from blackfin driver albiet with some major tweaks
22 *
23 * TODO:
24 * -check if sysreq works
25 */
26
27#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
28#define SUPPORT_SYSRQ
29#endif
30
31#include <linux/module.h>
32#include <linux/serial.h>
33#include <linux/console.h>
34#include <linux/sysrq.h>
35#include <linux/platform_device.h>
36#include <linux/tty.h>
37#include <linux/tty_flip.h>
38#include <linux/serial_core.h>
39#include <linux/io.h>
40
41/*************************************
42 * ARC UART Hardware Specs
43 ************************************/
44#define ARC_UART_TX_FIFO_SIZE 1
45
46/*
47 * UART Register set (this is not a Standards Compliant IP)
48 * Also each reg is Word aligned, but only 8 bits wide
49 */
50#define R_ID0 0
51#define R_ID1 4
52#define R_ID2 8
53#define R_ID3 12
54#define R_DATA 16
55#define R_STS 20
56#define R_BAUDL 24
57#define R_BAUDH 28
58
59/* Bits for UART Status Reg (R/W) */
60#define RXIENB 0x04 /* Receive Interrupt Enable */
61#define TXIENB 0x40 /* Transmit Interrupt Enable */
62
63#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */
64#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */
65
66#define RXFULL 0x08 /* Receive FIFO full */
67#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */
68
69#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */
70#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */
71
72/* Uart bit fiddling helpers: lowest level */
73#define RBASE(uart, reg) (uart->port.membase + reg)
74#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r))
75#define UART_REG_GET(u, r) readb(RBASE(u, r))
76
77#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v))
78#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v))
79
80/* Uart bit fiddling helpers: API level */
81#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val)
82#define UART_GET_DATA(uart) UART_REG_GET(uart, R_DATA)
83
84#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val)
85#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val)
86
87#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val)
88#define UART_GET_STATUS(uart) UART_REG_GET(uart, R_STS)
89
90#define UART_ALL_IRQ_DISABLE(uart) UART_REG_CLR(uart, R_STS, RXIENB|TXIENB)
91#define UART_RX_IRQ_DISABLE(uart) UART_REG_CLR(uart, R_STS, RXIENB)
92#define UART_TX_IRQ_DISABLE(uart) UART_REG_CLR(uart, R_STS, TXIENB)
93
94#define UART_ALL_IRQ_ENABLE(uart) UART_REG_OR(uart, R_STS, RXIENB|TXIENB)
95#define UART_RX_IRQ_ENABLE(uart) UART_REG_OR(uart, R_STS, RXIENB)
96#define UART_TX_IRQ_ENABLE(uart) UART_REG_OR(uart, R_STS, TXIENB)
97
98#define ARC_SERIAL_DEV_NAME "ttyARC"
99
100struct arc_uart_port {
101 struct uart_port port;
102 unsigned long baud;
103 int is_emulated; /* H/w vs. Instruction Set Simulator */
104};
105
106#define to_arc_port(uport) container_of(uport, struct arc_uart_port, port)
107
108static struct arc_uart_port arc_uart_ports[CONFIG_SERIAL_ARC_NR_PORTS];
109
110#ifdef CONFIG_SERIAL_ARC_CONSOLE
111static struct console arc_console;
112#endif
113
114#define DRIVER_NAME "arc-uart"
115
116static struct uart_driver arc_uart_driver = {
117 .owner = THIS_MODULE,
118 .driver_name = DRIVER_NAME,
119 .dev_name = ARC_SERIAL_DEV_NAME,
120 .major = 0,
121 .minor = 0,
122 .nr = CONFIG_SERIAL_ARC_NR_PORTS,
123#ifdef CONFIG_SERIAL_ARC_CONSOLE
124 .cons = &arc_console,
125#endif
126};
127
128static void arc_serial_stop_rx(struct uart_port *port)
129{
130 struct arc_uart_port *uart = to_arc_port(port);
131
132 UART_RX_IRQ_DISABLE(uart);
133}
134
135static void arc_serial_stop_tx(struct uart_port *port)
136{
137 struct arc_uart_port *uart = to_arc_port(port);
138
139 while (!(UART_GET_STATUS(uart) & TXEMPTY))
140 cpu_relax();
141
142 UART_TX_IRQ_DISABLE(uart);
143}
144
145/*
146 * Return TIOCSER_TEMT when transmitter is not busy.
147 */
148static unsigned int arc_serial_tx_empty(struct uart_port *port)
149{
150 struct arc_uart_port *uart = to_arc_port(port);
151 unsigned int stat;
152
153 stat = UART_GET_STATUS(uart);
154 if (stat & TXEMPTY)
155 return TIOCSER_TEMT;
156
157 return 0;
158}
159
160/*
161 * Driver internal routine, used by both tty(serial core) as well as tx-isr
162 * -Called under spinlock in either cases
163 * -also tty->stopped / tty->hw_stopped has already been checked
164 * = by uart_start( ) before calling us
165 * = tx_ist checks that too before calling
166 */
167static void arc_serial_tx_chars(struct arc_uart_port *uart)
168{
169 struct circ_buf *xmit = &uart->port.state->xmit;
170 int sent = 0;
171 unsigned char ch;
172
173 if (unlikely(uart->port.x_char)) {
174 UART_SET_DATA(uart, uart->port.x_char);
175 uart->port.icount.tx++;
176 uart->port.x_char = 0;
177 sent = 1;
178 } else if (xmit->tail != xmit->head) { /* TODO: uart_circ_empty */
179 ch = xmit->buf[xmit->tail];
180 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
181 uart->port.icount.tx++;
182 while (!(UART_GET_STATUS(uart) & TXEMPTY))
183 cpu_relax();
184 UART_SET_DATA(uart, ch);
185 sent = 1;
186 }
187
188 /*
189 * If num chars in xmit buffer are too few, ask tty layer for more.
190 * By Hard ISR to schedule processing in software interrupt part
191 */
192 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
193 uart_write_wakeup(&uart->port);
194
195 if (sent)
196 UART_TX_IRQ_ENABLE(uart);
197}
198
199/*
200 * port is locked and interrupts are disabled
201 * uart_start( ) calls us under the port spinlock irqsave
202 */
203static void arc_serial_start_tx(struct uart_port *port)
204{
205 struct arc_uart_port *uart = to_arc_port(port);
206
207 arc_serial_tx_chars(uart);
208}
209
210static void arc_serial_rx_chars(struct arc_uart_port *uart)
211{
212 struct tty_struct *tty = tty_port_tty_get(&uart->port.state->port);
213 unsigned int status, ch, flg = 0;
214
215 if (!tty)
216 return;
217
218 /*
219 * UART has 4 deep RX-FIFO. Driver's recongnition of this fact
220 * is very subtle. Here's how ...
221 * Upon getting a RX-Intr, such that RX-EMPTY=0, meaning data available,
222 * driver reads the DATA Reg and keeps doing that in a loop, until
223 * RX-EMPTY=1. Multiple chars being avail, with a single Interrupt,
224 * before RX-EMPTY=0, implies some sort of buffering going on in the
225 * controller, which is indeed the Rx-FIFO.
226 */
227 while (!((status = UART_GET_STATUS(uart)) & RXEMPTY)) {
228
229 ch = UART_GET_DATA(uart);
230 uart->port.icount.rx++;
231
232 if (unlikely(status & (RXOERR | RXFERR))) {
233 if (status & RXOERR) {
234 uart->port.icount.overrun++;
235 flg = TTY_OVERRUN;
236 UART_CLR_STATUS(uart, RXOERR);
237 }
238
239 if (status & RXFERR) {
240 uart->port.icount.frame++;
241 flg = TTY_FRAME;
242 UART_CLR_STATUS(uart, RXFERR);
243 }
244 } else
245 flg = TTY_NORMAL;
246
247 if (unlikely(uart_handle_sysrq_char(&uart->port, ch)))
248 goto done;
249
250 uart_insert_char(&uart->port, status, RXOERR, ch, flg);
251
252done:
253 tty_flip_buffer_push(tty);
254 }
255
256 tty_kref_put(tty);
257}
258
259/*
260 * A note on the Interrupt handling state machine of this driver
261 *
262 * kernel printk writes funnel thru the console driver framework and in order
263 * to keep things simple as well as efficient, it writes to UART in polled
264 * mode, in one shot, and exits.
265 *
266 * OTOH, Userland output (via tty layer), uses interrupt based writes as there
267 * can be undeterministic delay between char writes.
268 *
269 * Thus Rx-interrupts are always enabled, while tx-interrupts are by default
270 * disabled.
271 *
272 * When tty has some data to send out, serial core calls driver's start_tx
273 * which
274 * -checks-if-tty-buffer-has-char-to-send
275 * -writes-data-to-uart
276 * -enable-tx-intr
277 *
278 * Once data bits are pushed out, controller raises the Tx-room-avail-Interrupt.
279 * The first thing Tx ISR does is disable further Tx interrupts (as this could
280 * be the last char to send, before settling down into the quiet polled mode).
281 * It then calls the exact routine used by tty layer write to send out any
282 * more char in tty buffer. In case of sending, it re-enables Tx-intr. In case
283 * of no data, it remains disabled.
284 * This is how the transmit state machine is dynamically switched on/off
285 */
286
287static irqreturn_t arc_serial_isr(int irq, void *dev_id)
288{
289 struct arc_uart_port *uart = dev_id;
290 unsigned int status;
291
292 status = UART_GET_STATUS(uart);
293
294 /*
295 * Single IRQ for both Rx (data available) Tx (room available) Interrupt
296 * notifications from the UART Controller.
297 * To demultiplex between the two, we check the relevant bits
298 */
299 if ((status & RXIENB) && !(status & RXEMPTY)) {
300
301 /* already in ISR, no need of xx_irqsave */
302 spin_lock(&uart->port.lock);
303 arc_serial_rx_chars(uart);
304 spin_unlock(&uart->port.lock);
305 }
306
307 if ((status & TXIENB) && (status & TXEMPTY)) {
308
309 /* Unconditionally disable further Tx-Interrupts.
310 * will be enabled by tx_chars() if needed.
311 */
312 UART_TX_IRQ_DISABLE(uart);
313
314 spin_lock(&uart->port.lock);
315
316 if (!uart_tx_stopped(&uart->port))
317 arc_serial_tx_chars(uart);
318
319 spin_unlock(&uart->port.lock);
320 }
321
322 return IRQ_HANDLED;
323}
324
325static unsigned int arc_serial_get_mctrl(struct uart_port *port)
326{
327 /*
328 * Pretend we have a Modem status reg and following bits are
329 * always set, to satify the serial core state machine
330 * (DSR) Data Set Ready
331 * (CTS) Clear To Send
332 * (CAR) Carrier Detect
333 */
334 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
335}
336
337static void arc_serial_set_mctrl(struct uart_port *port, unsigned int mctrl)
338{
339 /* MCR not present */
340}
341
342/* Enable Modem Status Interrupts */
343
344static void arc_serial_enable_ms(struct uart_port *port)
345{
346 /* MSR not present */
347}
348
349static void arc_serial_break_ctl(struct uart_port *port, int break_state)
350{
351 /* ARC UART doesn't support sending Break signal */
352}
353
354static int arc_serial_startup(struct uart_port *port)
355{
356 struct arc_uart_port *uart = to_arc_port(port);
357
358 /* Before we hook up the ISR, Disable all UART Interrupts */
359 UART_ALL_IRQ_DISABLE(uart);
360
361 if (request_irq(uart->port.irq, arc_serial_isr, 0, "arc uart rx-tx",
362 uart)) {
363 dev_warn(uart->port.dev, "Unable to attach ARC UART intr\n");
364 return -EBUSY;
365 }
366
367 UART_RX_IRQ_ENABLE(uart); /* Only Rx IRQ enabled to begin with */
368
369 return 0;
370}
371
372/* This is not really needed */
373static void arc_serial_shutdown(struct uart_port *port)
374{
375 struct arc_uart_port *uart = to_arc_port(port);
376 free_irq(uart->port.irq, uart);
377}
378
379static void
380arc_serial_set_termios(struct uart_port *port, struct ktermios *new,
381 struct ktermios *old)
382{
383 struct arc_uart_port *uart = to_arc_port(port);
384 unsigned int baud, uartl, uarth, hw_val;
385 unsigned long flags;
386
387 /*
388 * Use the generic handler so that any specially encoded baud rates
389 * such as SPD_xx flags or "%B0" can be handled
390 * Max Baud I suppose will not be more than current 115K * 4
391 * Formula for ARC UART is: hw-val = ((CLK/(BAUD*4)) -1)
392 * spread over two 8-bit registers
393 */
394 baud = uart_get_baud_rate(port, new, old, 0, 460800);
395
396 hw_val = port->uartclk / (uart->baud * 4) - 1;
397 uartl = hw_val & 0xFF;
398 uarth = (hw_val >> 8) & 0xFF;
399
400 /*
401 * UART ISS(Instruction Set simulator) emulation has a subtle bug:
402 * A existing value of Baudh = 0 is used as a indication to startup
403 * it's internal state machine.
404 * Thus if baudh is set to 0, 2 times, it chokes.
405 * This happens with BAUD=115200 and the formaula above
406 * Until that is fixed, when running on ISS, we will set baudh to !0
407 */
408 if (uart->is_emulated)
409 uarth = 1;
410
411 spin_lock_irqsave(&port->lock, flags);
412
413 UART_ALL_IRQ_DISABLE(uart);
414
415 UART_SET_BAUDL(uart, uartl);
416 UART_SET_BAUDH(uart, uarth);
417
418 UART_RX_IRQ_ENABLE(uart);
419
420 /*
421 * UART doesn't support Parity/Hardware Flow Control;
422 * Only supports 8N1 character size
423 */
424 new->c_cflag &= ~(CMSPAR|CRTSCTS|CSIZE);
425 new->c_cflag |= CS8;
426
427 if (old)
428 tty_termios_copy_hw(new, old);
429
430 /* Don't rewrite B0 */
431 if (tty_termios_baud_rate(new))
432 tty_termios_encode_baud_rate(new, baud, baud);
433
434 uart_update_timeout(port, new->c_cflag, baud);
435
436 spin_unlock_irqrestore(&port->lock, flags);
437}
438
439static const char *arc_serial_type(struct uart_port *port)
440{
441 struct arc_uart_port *uart = to_arc_port(port);
442
443 return uart->port.type == PORT_ARC ? DRIVER_NAME : NULL;
444}
445
446static void arc_serial_release_port(struct uart_port *port)
447{
448}
449
450static int arc_serial_request_port(struct uart_port *port)
451{
452 return 0;
453}
454
455/*
456 * Verify the new serial_struct (for TIOCSSERIAL).
457 */
458static int
459arc_serial_verify_port(struct uart_port *port, struct serial_struct *ser)
460{
461 if (port->type != PORT_UNKNOWN && ser->type != PORT_ARC)
462 return -EINVAL;
463
464 return 0;
465}
466
467/*
468 * Configure/autoconfigure the port.
469 */
470static void arc_serial_config_port(struct uart_port *port, int flags)
471{
472 struct arc_uart_port *uart = to_arc_port(port);
473
474 if (flags & UART_CONFIG_TYPE)
475 uart->port.type = PORT_ARC;
476}
477
478#if defined(CONFIG_CONSOLE_POLL) || defined(CONFIG_SERIAL_ARC_CONSOLE)
479
480static void arc_serial_poll_putchar(struct uart_port *port, unsigned char chr)
481{
482 struct arc_uart_port *uart = to_arc_port(port);
483
484 while (!(UART_GET_STATUS(uart) & TXEMPTY))
485 cpu_relax();
486
487 UART_SET_DATA(uart, chr);
488}
489#endif
490
491#ifdef CONFIG_CONSOLE_POLL
492static int arc_serial_poll_getchar(struct uart_port *port)
493{
494 struct arc_uart_port *uart = to_arc_port(port);
495 unsigned char chr;
496
497 while (!(UART_GET_STATUS(uart) & RXEMPTY))
498 cpu_relax();
499
500 chr = UART_GET_DATA(uart);
501 return chr;
502}
503#endif
504
505static struct uart_ops arc_serial_pops = {
506 .tx_empty = arc_serial_tx_empty,
507 .set_mctrl = arc_serial_set_mctrl,
508 .get_mctrl = arc_serial_get_mctrl,
509 .stop_tx = arc_serial_stop_tx,
510 .start_tx = arc_serial_start_tx,
511 .stop_rx = arc_serial_stop_rx,
512 .enable_ms = arc_serial_enable_ms,
513 .break_ctl = arc_serial_break_ctl,
514 .startup = arc_serial_startup,
515 .shutdown = arc_serial_shutdown,
516 .set_termios = arc_serial_set_termios,
517 .type = arc_serial_type,
518 .release_port = arc_serial_release_port,
519 .request_port = arc_serial_request_port,
520 .config_port = arc_serial_config_port,
521 .verify_port = arc_serial_verify_port,
522#ifdef CONFIG_CONSOLE_POLL
523 .poll_put_char = arc_serial_poll_putchar,
524 .poll_get_char = arc_serial_poll_getchar,
525#endif
526};
527
528static int
529arc_uart_init_one(struct platform_device *pdev, struct arc_uart_port *uart)
530{
531 struct resource *res, *res2;
532 unsigned long *plat_data;
533
534 if (pdev->id < 0 || pdev->id >= CONFIG_SERIAL_ARC_NR_PORTS) {
535 dev_err(&pdev->dev, "Wrong uart platform device id.\n");
536 return -ENOENT;
537 }
538
539 plat_data = ((unsigned long *)(pdev->dev.platform_data));
540 uart->baud = plat_data[0];
541
542 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
543 if (!res)
544 return -ENODEV;
545
546 res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
547 if (!res2)
548 return -ENODEV;
549
550 uart->port.mapbase = res->start;
551 uart->port.membase = ioremap_nocache(res->start, resource_size(res));
552 if (!uart->port.membase)
553 /* No point of dev_err since UART itself is hosed here */
554 return -ENXIO;
555
556 uart->port.irq = res2->start;
557 uart->port.dev = &pdev->dev;
558 uart->port.iotype = UPIO_MEM;
559 uart->port.flags = UPF_BOOT_AUTOCONF;
560 uart->port.line = pdev->id;
561 uart->port.ops = &arc_serial_pops;
562
563 uart->port.uartclk = plat_data[1];
564 uart->port.fifosize = ARC_UART_TX_FIFO_SIZE;
565
566 /*
567 * uart_insert_char( ) uses it in decideding whether to ignore a
568 * char or not. Explicitly setting it here, removes the subtelty
569 */
570 uart->port.ignore_status_mask = 0;
571
572 /* Real Hardware vs. emulated to work around a bug */
573 uart->is_emulated = !!plat_data[2];
574
575 return 0;
576}
577
578#ifdef CONFIG_SERIAL_ARC_CONSOLE
579
580static int arc_serial_console_setup(struct console *co, char *options)
581{
582 struct uart_port *port;
583 int baud = 115200;
584 int bits = 8;
585 int parity = 'n';
586 int flow = 'n';
587
588 if (co->index < 0 || co->index >= CONFIG_SERIAL_ARC_NR_PORTS)
589 return -ENODEV;
590
591 /*
592 * The uart port backing the console (e.g. ttyARC1) might not have been
593 * init yet. If so, defer the console setup to after the port.
594 */
595 port = &arc_uart_ports[co->index].port;
596 if (!port->membase)
597 return -ENODEV;
598
599 if (options)
600 uart_parse_options(options, &baud, &parity, &bits, &flow);
601
602 /*
603 * Serial core will call port->ops->set_termios( )
604 * which will set the baud reg
605 */
606 return uart_set_options(port, co, baud, parity, bits, flow);
607}
608
609static void arc_serial_console_putchar(struct uart_port *port, int ch)
610{
611 arc_serial_poll_putchar(port, (unsigned char)ch);
612}
613
614/*
615 * Interrupts are disabled on entering
616 */
617static void arc_serial_console_write(struct console *co, const char *s,
618 unsigned int count)
619{
620 struct uart_port *port = &arc_uart_ports[co->index].port;
621 unsigned long flags;
622
623 spin_lock_irqsave(&port->lock, flags);
624 uart_console_write(port, s, count, arc_serial_console_putchar);
625 spin_unlock_irqrestore(&port->lock, flags);
626}
627
628static struct console arc_console = {
629 .name = ARC_SERIAL_DEV_NAME,
630 .write = arc_serial_console_write,
631 .device = uart_console_device,
632 .setup = arc_serial_console_setup,
633 .flags = CON_PRINTBUFFER,
634 .index = -1,
635 .data = &arc_uart_driver
636};
637
638static __init void early_serial_write(struct console *con, const char *s,
639 unsigned int n)
640{
641 struct uart_port *port = &arc_uart_ports[con->index].port;
642 unsigned int i;
643
644 for (i = 0; i < n; i++, s++) {
645 if (*s == '\n')
646 arc_serial_poll_putchar(port, '\r');
647 arc_serial_poll_putchar(port, *s);
648 }
649}
650
651static struct __initdata console arc_early_serial_console = {
652 .name = "early_ARCuart",
653 .write = early_serial_write,
654 .flags = CON_PRINTBUFFER | CON_BOOT,
655 .index = -1
656};
657
658static int arc_serial_probe_earlyprintk(struct platform_device *pdev)
659{
660 arc_early_serial_console.index = pdev->id;
661
662 arc_uart_init_one(pdev, &arc_uart_ports[pdev->id]);
663
664 arc_serial_console_setup(&arc_early_serial_console, NULL);
665
666 register_console(&arc_early_serial_console);
667 return 0;
668}
669#else
670static int arc_serial_probe_earlyprintk(struct platform_device *pdev)
671{
672 return -ENODEV;
673}
674#endif /* CONFIG_SERIAL_ARC_CONSOLE */
675
676static int arc_serial_probe(struct platform_device *pdev)
677{
678 struct arc_uart_port *uart;
679 int rc;
680
681 if (is_early_platform_device(pdev))
682 return arc_serial_probe_earlyprintk(pdev);
683
684 uart = &arc_uart_ports[pdev->id];
685 rc = arc_uart_init_one(pdev, uart);
686 if (rc)
687 return rc;
688
689 return uart_add_one_port(&arc_uart_driver, &uart->port);
690}
691
692static int arc_serial_remove(struct platform_device *pdev)
693{
694 /* This will never be called */
695 return 0;
696}
697
698static struct platform_driver arc_platform_driver = {
699 .probe = arc_serial_probe,
700 .remove = arc_serial_remove,
701 .driver = {
702 .name = DRIVER_NAME,
703 .owner = THIS_MODULE,
704 },
705};
706
707#ifdef CONFIG_SERIAL_ARC_CONSOLE
708/*
709 * Register an early platform driver of "earlyprintk" class.
710 * ARCH platform code installs the driver and probes the early devices
711 * The installation could rely on user specifying earlyprintk=xyx in cmd line
712 * or it could be done independently, for all "earlyprintk" class drivers.
713 * [see arch/arc/plat-arcfpga/platform.c]
714 */
715early_platform_init("earlyprintk", &arc_platform_driver);
716
717#endif /* CONFIG_SERIAL_ARC_CONSOLE */
718
719static int __init arc_serial_init(void)
720{
721 int ret;
722
723 ret = uart_register_driver(&arc_uart_driver);
724 if (ret)
725 return ret;
726
727 ret = platform_driver_register(&arc_platform_driver);
728 if (ret)
729 uart_unregister_driver(&arc_uart_driver);
730
731 return ret;
732}
733
734static void __exit arc_serial_exit(void)
735{
736 platform_driver_unregister(&arc_platform_driver);
737 uart_unregister_driver(&arc_uart_driver);
738}
739
740module_init(arc_serial_init);
741module_exit(arc_serial_exit);
742
743MODULE_LICENSE("GPL");
744MODULE_ALIAS("plat-arcfpga/uart");
745MODULE_AUTHOR("Vineet Gupta");
746MODULE_DESCRIPTION("ARC(Synopsys) On-Chip(fpga) serial driver");
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 65f891be12d..b95886c1198 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1424,7 +1424,7 @@ static struct uart_ops atmel_pops = {
1424#endif 1424#endif
1425}; 1425};
1426 1426
1427static void __devinit atmel_of_init_port(struct atmel_uart_port *atmel_port, 1427static void atmel_of_init_port(struct atmel_uart_port *atmel_port,
1428 struct device_node *np) 1428 struct device_node *np)
1429{ 1429{
1430 u32 rs485_delay[2]; 1430 u32 rs485_delay[2];
@@ -1459,7 +1459,7 @@ static void __devinit atmel_of_init_port(struct atmel_uart_port *atmel_port,
1459/* 1459/*
1460 * Configure the port from the platform device resource info. 1460 * Configure the port from the platform device resource info.
1461 */ 1461 */
1462static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port, 1462static void atmel_init_port(struct atmel_uart_port *atmel_port,
1463 struct platform_device *pdev) 1463 struct platform_device *pdev)
1464{ 1464{
1465 struct uart_port *port = &atmel_port->uart; 1465 struct uart_port *port = &atmel_port->uart;
@@ -1767,7 +1767,7 @@ static int atmel_serial_resume(struct platform_device *pdev)
1767#define atmel_serial_resume NULL 1767#define atmel_serial_resume NULL
1768#endif 1768#endif
1769 1769
1770static int __devinit atmel_serial_probe(struct platform_device *pdev) 1770static int atmel_serial_probe(struct platform_device *pdev)
1771{ 1771{
1772 struct atmel_uart_port *port; 1772 struct atmel_uart_port *port;
1773 struct device_node *np = pdev->dev.of_node; 1773 struct device_node *np = pdev->dev.of_node;
@@ -1859,7 +1859,7 @@ err:
1859 return ret; 1859 return ret;
1860} 1860}
1861 1861
1862static int __devexit atmel_serial_remove(struct platform_device *pdev) 1862static int atmel_serial_remove(struct platform_device *pdev)
1863{ 1863{
1864 struct uart_port *port = platform_get_drvdata(pdev); 1864 struct uart_port *port = platform_get_drvdata(pdev);
1865 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1865 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
@@ -1884,7 +1884,7 @@ static int __devexit atmel_serial_remove(struct platform_device *pdev)
1884 1884
1885static struct platform_driver atmel_serial_driver = { 1885static struct platform_driver atmel_serial_driver = {
1886 .probe = atmel_serial_probe, 1886 .probe = atmel_serial_probe,
1887 .remove = __devexit_p(atmel_serial_remove), 1887 .remove = atmel_serial_remove,
1888 .suspend = atmel_serial_suspend, 1888 .suspend = atmel_serial_suspend,
1889 .resume = atmel_serial_resume, 1889 .resume = atmel_serial_resume,
1890 .driver = { 1890 .driver = {
diff --git a/drivers/tty/serial/bcm63xx_uart.c b/drivers/tty/serial/bcm63xx_uart.c
index c0b68b9cad9..c76a226080f 100644
--- a/drivers/tty/serial/bcm63xx_uart.c
+++ b/drivers/tty/serial/bcm63xx_uart.c
@@ -801,7 +801,7 @@ static struct uart_driver bcm_uart_driver = {
801/* 801/*
802 * platform driver probe/remove callback 802 * platform driver probe/remove callback
803 */ 803 */
804static int __devinit bcm_uart_probe(struct platform_device *pdev) 804static int bcm_uart_probe(struct platform_device *pdev)
805{ 805{
806 struct resource *res_mem, *res_irq; 806 struct resource *res_mem, *res_irq;
807 struct uart_port *port; 807 struct uart_port *port;
@@ -848,7 +848,7 @@ static int __devinit bcm_uart_probe(struct platform_device *pdev)
848 return 0; 848 return 0;
849} 849}
850 850
851static int __devexit bcm_uart_remove(struct platform_device *pdev) 851static int bcm_uart_remove(struct platform_device *pdev)
852{ 852{
853 struct uart_port *port; 853 struct uart_port *port;
854 854
@@ -865,7 +865,7 @@ static int __devexit bcm_uart_remove(struct platform_device *pdev)
865 */ 865 */
866static struct platform_driver bcm_uart_platform_driver = { 866static struct platform_driver bcm_uart_platform_driver = {
867 .probe = bcm_uart_probe, 867 .probe = bcm_uart_probe,
868 .remove = __devexit_p(bcm_uart_remove), 868 .remove = bcm_uart_remove,
869 .driver = { 869 .driver = {
870 .owner = THIS_MODULE, 870 .owner = THIS_MODULE,
871 .name = "bcm63xx_uart", 871 .name = "bcm63xx_uart",
diff --git a/drivers/tty/serial/bfin_sport_uart.c b/drivers/tty/serial/bfin_sport_uart.c
index 7fbc3a08f10..f5d117379b6 100644
--- a/drivers/tty/serial/bfin_sport_uart.c
+++ b/drivers/tty/serial/bfin_sport_uart.c
@@ -740,7 +740,7 @@ static struct dev_pm_ops bfin_sport_uart_dev_pm_ops = {
740}; 740};
741#endif 741#endif
742 742
743static int __devinit sport_uart_probe(struct platform_device *pdev) 743static int sport_uart_probe(struct platform_device *pdev)
744{ 744{
745 struct resource *res; 745 struct resource *res;
746 struct sport_uart_port *sport; 746 struct sport_uart_port *sport;
@@ -850,7 +850,7 @@ out_error_free_mem:
850 return ret; 850 return ret;
851} 851}
852 852
853static int __devexit sport_uart_remove(struct platform_device *pdev) 853static int sport_uart_remove(struct platform_device *pdev)
854{ 854{
855 struct sport_uart_port *sport = platform_get_drvdata(pdev); 855 struct sport_uart_port *sport = platform_get_drvdata(pdev);
856 856
@@ -871,7 +871,7 @@ static int __devexit sport_uart_remove(struct platform_device *pdev)
871 871
872static struct platform_driver sport_uart_driver = { 872static struct platform_driver sport_uart_driver = {
873 .probe = sport_uart_probe, 873 .probe = sport_uart_probe,
874 .remove = __devexit_p(sport_uart_remove), 874 .remove = sport_uart_remove,
875 .driver = { 875 .driver = {
876 .name = DRV_NAME, 876 .name = DRV_NAME,
877#ifdef CONFIG_PM 877#ifdef CONFIG_PM
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index 9242d56ba26..e6a008f4939 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -477,9 +477,9 @@ static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
477void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart) 477void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
478{ 478{
479 int x_pos, pos; 479 int x_pos, pos;
480 unsigned long flags;
480 481
481 dma_disable_irq_nosync(uart->rx_dma_channel); 482 spin_lock_irqsave(&uart->rx_lock, flags);
482 spin_lock_bh(&uart->rx_lock);
483 483
484 /* 2D DMA RX buffer ring is used. Because curr_y_count and 484 /* 2D DMA RX buffer ring is used. Because curr_y_count and
485 * curr_x_count can't be read as an atomic operation, 485 * curr_x_count can't be read as an atomic operation,
@@ -510,8 +510,7 @@ void bfin_serial_rx_dma_timeout(struct bfin_serial_port *uart)
510 uart->rx_dma_buf.tail = uart->rx_dma_buf.head; 510 uart->rx_dma_buf.tail = uart->rx_dma_buf.head;
511 } 511 }
512 512
513 spin_unlock_bh(&uart->rx_lock); 513 spin_unlock_irqrestore(&uart->rx_lock, flags);
514 dma_enable_irq(uart->rx_dma_channel);
515 514
516 mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES); 515 mod_timer(&(uart->rx_dma_timer), jiffies + DMA_RX_FLUSH_JIFFIES);
517} 516}
@@ -800,6 +799,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
800 unsigned long flags; 799 unsigned long flags;
801 unsigned int baud, quot; 800 unsigned int baud, quot;
802 unsigned int ier, lcr = 0; 801 unsigned int ier, lcr = 0;
802 unsigned long timeout;
803 803
804 switch (termios->c_cflag & CSIZE) { 804 switch (termios->c_cflag & CSIZE) {
805 case CS8: 805 case CS8:
@@ -869,6 +869,14 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
869 869
870 UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15); 870 UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);
871 871
872 /* Wait till the transfer buffer is empty */
873 timeout = jiffies + msecs_to_jiffies(10);
874 while (UART_GET_GCTL(uart) & UCEN && !(UART_GET_LSR(uart) & TEMT))
875 if (time_after(jiffies, timeout)) {
876 dev_warn(port->dev, "timeout waiting for TX buffer empty\n");
877 break;
878 }
879
872 /* Disable UART */ 880 /* Disable UART */
873 ier = UART_GET_IER(uart); 881 ier = UART_GET_IER(uart);
874 UART_PUT_GCTL(uart, UART_GET_GCTL(uart) & ~UCEN); 882 UART_PUT_GCTL(uart, UART_GET_GCTL(uart) & ~UCEN);
@@ -1390,7 +1398,7 @@ out_error_free_mem:
1390 return ret; 1398 return ret;
1391} 1399}
1392 1400
1393static int __devexit bfin_serial_remove(struct platform_device *pdev) 1401static int bfin_serial_remove(struct platform_device *pdev)
1394{ 1402{
1395 struct bfin_serial_port *uart = platform_get_drvdata(pdev); 1403 struct bfin_serial_port *uart = platform_get_drvdata(pdev);
1396 1404
@@ -1410,7 +1418,7 @@ static int __devexit bfin_serial_remove(struct platform_device *pdev)
1410 1418
1411static struct platform_driver bfin_serial_driver = { 1419static struct platform_driver bfin_serial_driver = {
1412 .probe = bfin_serial_probe, 1420 .probe = bfin_serial_probe,
1413 .remove = __devexit_p(bfin_serial_remove), 1421 .remove = bfin_serial_remove,
1414 .suspend = bfin_serial_suspend, 1422 .suspend = bfin_serial_suspend,
1415 .resume = bfin_serial_resume, 1423 .resume = bfin_serial_resume,
1416 .driver = { 1424 .driver = {
diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c
index d0f719fafc8..3fd2526d121 100644
--- a/drivers/tty/serial/clps711x.c
+++ b/drivers/tty/serial/clps711x.c
@@ -10,15 +10,6 @@
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version. 12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 13 */
23 14
24#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 15#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
@@ -26,172 +17,169 @@
26#endif 17#endif
27 18
28#include <linux/module.h> 19#include <linux/module.h>
29#include <linux/ioport.h>
30#include <linux/init.h>
31#include <linux/console.h>
32#include <linux/sysrq.h>
33#include <linux/spinlock.h>
34#include <linux/device.h> 20#include <linux/device.h>
35#include <linux/tty.h> 21#include <linux/console.h>
36#include <linux/tty_flip.h>
37#include <linux/serial_core.h> 22#include <linux/serial_core.h>
38#include <linux/serial.h> 23#include <linux/serial.h>
39#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/clk.h>
26#include <linux/tty.h>
27#include <linux/tty_flip.h>
28#include <linux/ioport.h>
29#include <linux/platform_device.h>
40 30
41#include <mach/hardware.h> 31#include <mach/hardware.h>
42#include <asm/irq.h>
43
44#define UART_NR 2
45
46#define SERIAL_CLPS711X_MAJOR 204
47#define SERIAL_CLPS711X_MINOR 40
48#define SERIAL_CLPS711X_NR UART_NR
49
50/*
51 * We use the relevant SYSCON register as a base address for these ports.
52 */
53#define UBRLCR(port) ((port)->iobase + UBRLCR1 - SYSCON1)
54#define UARTDR(port) ((port)->iobase + UARTDR1 - SYSCON1)
55#define SYSFLG(port) ((port)->iobase + SYSFLG1 - SYSCON1)
56#define SYSCON(port) ((port)->iobase + SYSCON1 - SYSCON1)
57
58#define TX_IRQ(port) ((port)->irq)
59#define RX_IRQ(port) ((port)->irq + 1)
60 32
61#define UART_ANY_ERR (UARTDR_FRMERR | UARTDR_PARERR | UARTDR_OVERR) 33#define UART_CLPS711X_NAME "uart-clps711x"
62 34#define UART_CLPS711X_NR 2
63#define tx_enabled(port) ((port)->unused[0]) 35#define UART_CLPS711X_MAJOR 204
36#define UART_CLPS711X_MINOR 40
37
38#define UBRLCR(port) ((port)->line ? UBRLCR2 : UBRLCR1)
39#define UARTDR(port) ((port)->line ? UARTDR2 : UARTDR1)
40#define SYSFLG(port) ((port)->line ? SYSFLG2 : SYSFLG1)
41#define SYSCON(port) ((port)->line ? SYSCON2 : SYSCON1)
42#define TX_IRQ(port) ((port)->line ? IRQ_UTXINT2 : IRQ_UTXINT1)
43#define RX_IRQ(port) ((port)->line ? IRQ_URXINT2 : IRQ_URXINT1)
44
45struct clps711x_port {
46 struct uart_driver uart;
47 struct clk *uart_clk;
48 struct uart_port port[UART_CLPS711X_NR];
49 int tx_enabled[UART_CLPS711X_NR];
50#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
51 struct console console;
52#endif
53};
64 54
65static void clps711xuart_stop_tx(struct uart_port *port) 55static void uart_clps711x_stop_tx(struct uart_port *port)
66{ 56{
67 if (tx_enabled(port)) { 57 struct clps711x_port *s = dev_get_drvdata(port->dev);
58
59 if (s->tx_enabled[port->line]) {
68 disable_irq(TX_IRQ(port)); 60 disable_irq(TX_IRQ(port));
69 tx_enabled(port) = 0; 61 s->tx_enabled[port->line] = 0;
70 } 62 }
71} 63}
72 64
73static void clps711xuart_start_tx(struct uart_port *port) 65static void uart_clps711x_start_tx(struct uart_port *port)
74{ 66{
75 if (!tx_enabled(port)) { 67 struct clps711x_port *s = dev_get_drvdata(port->dev);
68
69 if (!s->tx_enabled[port->line]) {
76 enable_irq(TX_IRQ(port)); 70 enable_irq(TX_IRQ(port));
77 tx_enabled(port) = 1; 71 s->tx_enabled[port->line] = 1;
78 } 72 }
79} 73}
80 74
81static void clps711xuart_stop_rx(struct uart_port *port) 75static void uart_clps711x_stop_rx(struct uart_port *port)
82{ 76{
83 disable_irq(RX_IRQ(port)); 77 disable_irq(RX_IRQ(port));
84} 78}
85 79
86static void clps711xuart_enable_ms(struct uart_port *port) 80static void uart_clps711x_enable_ms(struct uart_port *port)
87{ 81{
82 /* Do nothing */
88} 83}
89 84
90static irqreturn_t clps711xuart_int_rx(int irq, void *dev_id) 85static irqreturn_t uart_clps711x_int_rx(int irq, void *dev_id)
91{ 86{
92 struct uart_port *port = dev_id; 87 struct uart_port *port = dev_id;
93 struct tty_struct *tty = port->state->port.tty; 88 struct tty_struct *tty = tty_port_tty_get(&port->state->port);
94 unsigned int status, ch, flg; 89 unsigned int status, ch, flg;
95 90
96 status = clps_readl(SYSFLG(port)); 91 if (!tty)
97 while (!(status & SYSFLG_URXFE)) { 92 return IRQ_HANDLED;
98 ch = clps_readl(UARTDR(port));
99 93
100 port->icount.rx++; 94 for (;;) {
95 status = clps_readl(SYSFLG(port));
96 if (status & SYSFLG_URXFE)
97 break;
98
99 ch = clps_readw(UARTDR(port));
100 status = ch & (UARTDR_FRMERR | UARTDR_PARERR | UARTDR_OVERR);
101 ch &= 0xff;
101 102
103 port->icount.rx++;
102 flg = TTY_NORMAL; 104 flg = TTY_NORMAL;
103 105
104 /* 106 if (unlikely(status)) {
105 * Note that the error handling code is 107 if (status & UARTDR_PARERR)
106 * out of the main execution path
107 */
108 if (unlikely(ch & UART_ANY_ERR)) {
109 if (ch & UARTDR_PARERR)
110 port->icount.parity++; 108 port->icount.parity++;
111 else if (ch & UARTDR_FRMERR) 109 else if (status & UARTDR_FRMERR)
112 port->icount.frame++; 110 port->icount.frame++;
113 if (ch & UARTDR_OVERR) 111 else if (status & UARTDR_OVERR)
114 port->icount.overrun++; 112 port->icount.overrun++;
115 113
116 ch &= port->read_status_mask; 114 status &= port->read_status_mask;
117 115
118 if (ch & UARTDR_PARERR) 116 if (status & UARTDR_PARERR)
119 flg = TTY_PARITY; 117 flg = TTY_PARITY;
120 else if (ch & UARTDR_FRMERR) 118 else if (status & UARTDR_FRMERR)
121 flg = TTY_FRAME; 119 flg = TTY_FRAME;
122 120 else if (status & UARTDR_OVERR)
123#ifdef SUPPORT_SYSRQ 121 flg = TTY_OVERRUN;
124 port->sysrq = 0;
125#endif
126 } 122 }
127 123
128 if (uart_handle_sysrq_char(port, ch)) 124 if (uart_handle_sysrq_char(port, ch))
129 goto ignore_char; 125 continue;
130 126
131 /* 127 if (status & port->ignore_status_mask)
132 * CHECK: does overrun affect the current character? 128 continue;
133 * ASSUMPTION: it does not.
134 */
135 uart_insert_char(port, ch, UARTDR_OVERR, ch, flg);
136 129
137 ignore_char: 130 uart_insert_char(port, status, UARTDR_OVERR, ch, flg);
138 status = clps_readl(SYSFLG(port));
139 } 131 }
132
140 tty_flip_buffer_push(tty); 133 tty_flip_buffer_push(tty);
134
135 tty_kref_put(tty);
136
141 return IRQ_HANDLED; 137 return IRQ_HANDLED;
142} 138}
143 139
144static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id) 140static irqreturn_t uart_clps711x_int_tx(int irq, void *dev_id)
145{ 141{
146 struct uart_port *port = dev_id; 142 struct uart_port *port = dev_id;
143 struct clps711x_port *s = dev_get_drvdata(port->dev);
147 struct circ_buf *xmit = &port->state->xmit; 144 struct circ_buf *xmit = &port->state->xmit;
148 int count;
149 145
150 if (port->x_char) { 146 if (port->x_char) {
151 clps_writel(port->x_char, UARTDR(port)); 147 clps_writew(port->x_char, UARTDR(port));
152 port->icount.tx++; 148 port->icount.tx++;
153 port->x_char = 0; 149 port->x_char = 0;
154 return IRQ_HANDLED; 150 return IRQ_HANDLED;
155 } 151 }
156 152
157 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) 153 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
158 goto disable_tx_irq; 154 disable_irq_nosync(TX_IRQ(port));
155 s->tx_enabled[port->line] = 0;
156 return IRQ_HANDLED;
157 }
159 158
160 count = port->fifosize >> 1; 159 while (!uart_circ_empty(xmit)) {
161 do { 160 clps_writew(xmit->buf[xmit->tail], UARTDR(port));
162 clps_writel(xmit->buf[xmit->tail], UARTDR(port));
163 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 161 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
164 port->icount.tx++; 162 port->icount.tx++;
165 if (uart_circ_empty(xmit)) 163 if (clps_readl(SYSFLG(port) & SYSFLG_UTXFF))
166 break; 164 break;
167 } while (--count > 0); 165 }
168 166
169 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 167 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
170 uart_write_wakeup(port); 168 uart_write_wakeup(port);
171 169
172 if (uart_circ_empty(xmit)) {
173 disable_tx_irq:
174 disable_irq_nosync(TX_IRQ(port));
175 tx_enabled(port) = 0;
176 }
177
178 return IRQ_HANDLED; 170 return IRQ_HANDLED;
179} 171}
180 172
181static unsigned int clps711xuart_tx_empty(struct uart_port *port) 173static unsigned int uart_clps711x_tx_empty(struct uart_port *port)
182{ 174{
183 unsigned int status = clps_readl(SYSFLG(port)); 175 return (clps_readl(SYSFLG(port) & SYSFLG_UBUSY)) ? 0 : TIOCSER_TEMT;
184 return status & SYSFLG_UBUSY ? 0 : TIOCSER_TEMT;
185} 176}
186 177
187static unsigned int clps711xuart_get_mctrl(struct uart_port *port) 178static unsigned int uart_clps711x_get_mctrl(struct uart_port *port)
188{ 179{
189 unsigned int port_addr; 180 unsigned int status, result = 0;
190 unsigned int result = 0;
191 unsigned int status;
192 181
193 port_addr = SYSFLG(port); 182 if (port->line == 0) {
194 if (port_addr == SYSFLG1) {
195 status = clps_readl(SYSFLG1); 183 status = clps_readl(SYSFLG1);
196 if (status & SYSFLG1_DCD) 184 if (status & SYSFLG1_DCD)
197 result |= TIOCM_CAR; 185 result |= TIOCM_CAR;
@@ -199,104 +187,86 @@ static unsigned int clps711xuart_get_mctrl(struct uart_port *port)
199 result |= TIOCM_DSR; 187 result |= TIOCM_DSR;
200 if (status & SYSFLG1_CTS) 188 if (status & SYSFLG1_CTS)
201 result |= TIOCM_CTS; 189 result |= TIOCM_CTS;
202 } 190 } else
191 result = TIOCM_DSR | TIOCM_CTS | TIOCM_CAR;
203 192
204 return result; 193 return result;
205} 194}
206 195
207static void 196static void uart_clps711x_set_mctrl(struct uart_port *port, unsigned int mctrl)
208clps711xuart_set_mctrl_null(struct uart_port *port, unsigned int mctrl)
209{ 197{
198 /* Do nothing */
210} 199}
211 200
212static void clps711xuart_break_ctl(struct uart_port *port, int break_state) 201static void uart_clps711x_break_ctl(struct uart_port *port, int break_state)
213{ 202{
214 unsigned long flags; 203 unsigned long flags;
215 unsigned int ubrlcr; 204 unsigned int ubrlcr;
216 205
217 spin_lock_irqsave(&port->lock, flags); 206 spin_lock_irqsave(&port->lock, flags);
207
218 ubrlcr = clps_readl(UBRLCR(port)); 208 ubrlcr = clps_readl(UBRLCR(port));
219 if (break_state == -1) 209 if (break_state)
220 ubrlcr |= UBRLCR_BREAK; 210 ubrlcr |= UBRLCR_BREAK;
221 else 211 else
222 ubrlcr &= ~UBRLCR_BREAK; 212 ubrlcr &= ~UBRLCR_BREAK;
223 clps_writel(ubrlcr, UBRLCR(port)); 213 clps_writel(ubrlcr, UBRLCR(port));
214
224 spin_unlock_irqrestore(&port->lock, flags); 215 spin_unlock_irqrestore(&port->lock, flags);
225} 216}
226 217
227static int clps711xuart_startup(struct uart_port *port) 218static int uart_clps711x_startup(struct uart_port *port)
228{ 219{
229 unsigned int syscon; 220 struct clps711x_port *s = dev_get_drvdata(port->dev);
230 int retval; 221 int ret;
231 222
232 tx_enabled(port) = 1; 223 s->tx_enabled[port->line] = 1;
233 224 /* Allocate the IRQs */
234 /* 225 ret = devm_request_irq(port->dev, TX_IRQ(port), uart_clps711x_int_tx,
235 * Allocate the IRQs 226 0, UART_CLPS711X_NAME " TX", port);
236 */ 227 if (ret)
237 retval = request_irq(TX_IRQ(port), clps711xuart_int_tx, 0, 228 return ret;
238 "clps711xuart_tx", port); 229
239 if (retval) 230 ret = devm_request_irq(port->dev, RX_IRQ(port), uart_clps711x_int_rx,
240 return retval; 231 0, UART_CLPS711X_NAME " RX", port);
241 232 if (ret) {
242 retval = request_irq(RX_IRQ(port), clps711xuart_int_rx, 0, 233 devm_free_irq(port->dev, TX_IRQ(port), port);
243 "clps711xuart_rx", port); 234 return ret;
244 if (retval) {
245 free_irq(TX_IRQ(port), port);
246 return retval;
247 } 235 }
248 236
249 /* 237 /* Disable break */
250 * enable the port 238 clps_writel(clps_readl(UBRLCR(port)) & ~UBRLCR_BREAK, UBRLCR(port));
251 */ 239
252 syscon = clps_readl(SYSCON(port)); 240 /* Enable the port */
253 syscon |= SYSCON_UARTEN; 241 clps_writel(clps_readl(SYSCON(port)) | SYSCON_UARTEN, SYSCON(port));
254 clps_writel(syscon, SYSCON(port));
255 242
256 return 0; 243 return 0;
257} 244}
258 245
259static void clps711xuart_shutdown(struct uart_port *port) 246static void uart_clps711x_shutdown(struct uart_port *port)
260{ 247{
261 unsigned int ubrlcr, syscon; 248 /* Free the interrupts */
249 devm_free_irq(port->dev, TX_IRQ(port), port);
250 devm_free_irq(port->dev, RX_IRQ(port), port);
262 251
263 /* 252 /* Disable the port */
264 * Free the interrupt 253 clps_writel(clps_readl(SYSCON(port)) & ~SYSCON_UARTEN, SYSCON(port));
265 */
266 free_irq(TX_IRQ(port), port); /* TX interrupt */
267 free_irq(RX_IRQ(port), port); /* RX interrupt */
268
269 /*
270 * disable the port
271 */
272 syscon = clps_readl(SYSCON(port));
273 syscon &= ~SYSCON_UARTEN;
274 clps_writel(syscon, SYSCON(port));
275
276 /*
277 * disable break condition and fifos
278 */
279 ubrlcr = clps_readl(UBRLCR(port));
280 ubrlcr &= ~(UBRLCR_FIFOEN | UBRLCR_BREAK);
281 clps_writel(ubrlcr, UBRLCR(port));
282} 254}
283 255
284static void 256static void uart_clps711x_set_termios(struct uart_port *port,
285clps711xuart_set_termios(struct uart_port *port, struct ktermios *termios, 257 struct ktermios *termios,
286 struct ktermios *old) 258 struct ktermios *old)
287{ 259{
288 unsigned int ubrlcr, baud, quot; 260 unsigned int ubrlcr, baud, quot;
289 unsigned long flags; 261 unsigned long flags;
290 262
291 /* 263 /* Mask termios capabilities we don't support */
292 * We don't implement CREAD. 264 termios->c_cflag &= ~CMSPAR;
293 */ 265 termios->c_iflag &= ~(BRKINT | IGNBRK);
294 termios->c_cflag |= CREAD;
295 266
296 /* 267 /* Ask the core to calculate the divisor for us */
297 * Ask the core to calculate the divisor for us. 268 baud = uart_get_baud_rate(port, termios, old, port->uartclk / 4096,
298 */ 269 port->uartclk / 16);
299 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
300 quot = uart_get_divisor(port, baud); 270 quot = uart_get_divisor(port, baud);
301 271
302 switch (termios->c_cflag & CSIZE) { 272 switch (termios->c_cflag & CSIZE) {
@@ -309,160 +279,117 @@ clps711xuart_set_termios(struct uart_port *port, struct ktermios *termios,
309 case CS7: 279 case CS7:
310 ubrlcr = UBRLCR_WRDLEN7; 280 ubrlcr = UBRLCR_WRDLEN7;
311 break; 281 break;
312 default: // CS8 282 case CS8:
283 default:
313 ubrlcr = UBRLCR_WRDLEN8; 284 ubrlcr = UBRLCR_WRDLEN8;
314 break; 285 break;
315 } 286 }
287
316 if (termios->c_cflag & CSTOPB) 288 if (termios->c_cflag & CSTOPB)
317 ubrlcr |= UBRLCR_XSTOP; 289 ubrlcr |= UBRLCR_XSTOP;
290
318 if (termios->c_cflag & PARENB) { 291 if (termios->c_cflag & PARENB) {
319 ubrlcr |= UBRLCR_PRTEN; 292 ubrlcr |= UBRLCR_PRTEN;
320 if (!(termios->c_cflag & PARODD)) 293 if (!(termios->c_cflag & PARODD))
321 ubrlcr |= UBRLCR_EVENPRT; 294 ubrlcr |= UBRLCR_EVENPRT;
322 } 295 }
323 if (port->fifosize > 1)
324 ubrlcr |= UBRLCR_FIFOEN;
325 296
326 spin_lock_irqsave(&port->lock, flags); 297 /* Enable FIFO */
298 ubrlcr |= UBRLCR_FIFOEN;
327 299
328 /* 300 spin_lock_irqsave(&port->lock, flags);
329 * Update the per-port timeout.
330 */
331 uart_update_timeout(port, termios->c_cflag, baud);
332 301
302 /* Set read status mask */
333 port->read_status_mask = UARTDR_OVERR; 303 port->read_status_mask = UARTDR_OVERR;
334 if (termios->c_iflag & INPCK) 304 if (termios->c_iflag & INPCK)
335 port->read_status_mask |= UARTDR_PARERR | UARTDR_FRMERR; 305 port->read_status_mask |= UARTDR_PARERR | UARTDR_FRMERR;
336 306
337 /* 307 /* Set status ignore mask */
338 * Characters to ignore
339 */
340 port->ignore_status_mask = 0; 308 port->ignore_status_mask = 0;
341 if (termios->c_iflag & IGNPAR) 309 if (!(termios->c_cflag & CREAD))
342 port->ignore_status_mask |= UARTDR_FRMERR | UARTDR_PARERR; 310 port->ignore_status_mask |= UARTDR_OVERR | UARTDR_PARERR |
343 if (termios->c_iflag & IGNBRK) { 311 UARTDR_FRMERR;
344 /*
345 * If we're ignoring parity and break indicators,
346 * ignore overruns to (for real raw support).
347 */
348 if (termios->c_iflag & IGNPAR)
349 port->ignore_status_mask |= UARTDR_OVERR;
350 }
351 312
352 quot -= 1; 313 uart_update_timeout(port, termios->c_cflag, baud);
353 314
354 clps_writel(ubrlcr | quot, UBRLCR(port)); 315 clps_writel(ubrlcr | (quot - 1), UBRLCR(port));
355 316
356 spin_unlock_irqrestore(&port->lock, flags); 317 spin_unlock_irqrestore(&port->lock, flags);
357} 318}
358 319
359static const char *clps711xuart_type(struct uart_port *port) 320static const char *uart_clps711x_type(struct uart_port *port)
360{ 321{
361 return port->type == PORT_CLPS711X ? "CLPS711x" : NULL; 322 return (port->type == PORT_CLPS711X) ? "CLPS711X" : NULL;
362} 323}
363 324
364/* 325static void uart_clps711x_config_port(struct uart_port *port, int flags)
365 * Configure/autoconfigure the port.
366 */
367static void clps711xuart_config_port(struct uart_port *port, int flags)
368{ 326{
369 if (flags & UART_CONFIG_TYPE) 327 if (flags & UART_CONFIG_TYPE)
370 port->type = PORT_CLPS711X; 328 port->type = PORT_CLPS711X;
371} 329}
372 330
373static void clps711xuart_release_port(struct uart_port *port) 331static void uart_clps711x_release_port(struct uart_port *port)
374{ 332{
333 /* Do nothing */
375} 334}
376 335
377static int clps711xuart_request_port(struct uart_port *port) 336static int uart_clps711x_request_port(struct uart_port *port)
378{ 337{
338 /* Do nothing */
379 return 0; 339 return 0;
380} 340}
381 341
382static struct uart_ops clps711x_pops = { 342static const struct uart_ops uart_clps711x_ops = {
383 .tx_empty = clps711xuart_tx_empty, 343 .tx_empty = uart_clps711x_tx_empty,
384 .set_mctrl = clps711xuart_set_mctrl_null, 344 .set_mctrl = uart_clps711x_set_mctrl,
385 .get_mctrl = clps711xuart_get_mctrl, 345 .get_mctrl = uart_clps711x_get_mctrl,
386 .stop_tx = clps711xuart_stop_tx, 346 .stop_tx = uart_clps711x_stop_tx,
387 .start_tx = clps711xuart_start_tx, 347 .start_tx = uart_clps711x_start_tx,
388 .stop_rx = clps711xuart_stop_rx, 348 .stop_rx = uart_clps711x_stop_rx,
389 .enable_ms = clps711xuart_enable_ms, 349 .enable_ms = uart_clps711x_enable_ms,
390 .break_ctl = clps711xuart_break_ctl, 350 .break_ctl = uart_clps711x_break_ctl,
391 .startup = clps711xuart_startup, 351 .startup = uart_clps711x_startup,
392 .shutdown = clps711xuart_shutdown, 352 .shutdown = uart_clps711x_shutdown,
393 .set_termios = clps711xuart_set_termios, 353 .set_termios = uart_clps711x_set_termios,
394 .type = clps711xuart_type, 354 .type = uart_clps711x_type,
395 .config_port = clps711xuart_config_port, 355 .config_port = uart_clps711x_config_port,
396 .release_port = clps711xuart_release_port, 356 .release_port = uart_clps711x_release_port,
397 .request_port = clps711xuart_request_port, 357 .request_port = uart_clps711x_request_port,
398};
399
400static struct uart_port clps711x_ports[UART_NR] = {
401 {
402 .iobase = SYSCON1,
403 .irq = IRQ_UTXINT1, /* IRQ_URXINT1, IRQ_UMSINT */
404 .uartclk = 3686400,
405 .fifosize = 16,
406 .ops = &clps711x_pops,
407 .line = 0,
408 .flags = UPF_BOOT_AUTOCONF,
409 },
410 {
411 .iobase = SYSCON2,
412 .irq = IRQ_UTXINT2, /* IRQ_URXINT2 */
413 .uartclk = 3686400,
414 .fifosize = 16,
415 .ops = &clps711x_pops,
416 .line = 1,
417 .flags = UPF_BOOT_AUTOCONF,
418 }
419}; 358};
420 359
421#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE 360#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
422static void clps711xuart_console_putchar(struct uart_port *port, int ch) 361static void uart_clps711x_console_putchar(struct uart_port *port, int ch)
423{ 362{
424 while (clps_readl(SYSFLG(port)) & SYSFLG_UTXFF) 363 while (clps_readl(SYSFLG(port)) & SYSFLG_UTXFF)
425 barrier(); 364 barrier();
426 clps_writel(ch, UARTDR(port)); 365
366 clps_writew(ch, UARTDR(port));
427} 367}
428 368
429/* 369static void uart_clps711x_console_write(struct console *co, const char *c,
430 * Print a string to the serial port trying not to disturb 370 unsigned n)
431 * any possible real use of the port...
432 *
433 * The console_lock must be held when we get here.
434 *
435 * Note that this is called with interrupts already disabled
436 */
437static void
438clps711xuart_console_write(struct console *co, const char *s,
439 unsigned int count)
440{ 371{
441 struct uart_port *port = clps711x_ports + co->index; 372 struct clps711x_port *s = (struct clps711x_port *)co->data;
442 unsigned int status, syscon; 373 struct uart_port *port = &s->port[co->index];
374 u32 syscon;
443 375
444 /* 376 /* Ensure that the port is enabled */
445 * Ensure that the port is enabled.
446 */
447 syscon = clps_readl(SYSCON(port)); 377 syscon = clps_readl(SYSCON(port));
448 clps_writel(syscon | SYSCON_UARTEN, SYSCON(port)); 378 clps_writel(syscon | SYSCON_UARTEN, SYSCON(port));
449 379
450 uart_console_write(port, s, count, clps711xuart_console_putchar); 380 uart_console_write(port, c, n, uart_clps711x_console_putchar);
451 381
452 /* 382 /* Wait for transmitter to become empty */
453 * Finally, wait for transmitter to become empty 383 while (clps_readl(SYSFLG(port)) & SYSFLG_UBUSY)
454 * and restore the uart state. 384 barrier();
455 */
456 do {
457 status = clps_readl(SYSFLG(port));
458 } while (status & SYSFLG_UBUSY);
459 385
386 /* Restore the uart state */
460 clps_writel(syscon, SYSCON(port)); 387 clps_writel(syscon, SYSCON(port));
461} 388}
462 389
463static void __init 390static void uart_clps711x_console_get_options(struct uart_port *port,
464clps711xuart_console_get_options(struct uart_port *port, int *baud, 391 int *baud, int *parity,
465 int *parity, int *bits) 392 int *bits)
466{ 393{
467 if (clps_readl(SYSCON(port)) & SYSCON_UARTEN) { 394 if (clps_readl(SYSCON(port)) & SYSCON_UARTEN) {
468 unsigned int ubrlcr, quot; 395 unsigned int ubrlcr, quot;
@@ -487,92 +414,124 @@ clps711xuart_console_get_options(struct uart_port *port, int *baud,
487 } 414 }
488} 415}
489 416
490static int __init clps711xuart_console_setup(struct console *co, char *options) 417static int uart_clps711x_console_setup(struct console *co, char *options)
491{ 418{
492 struct uart_port *port; 419 int baud = 38400, bits = 8, parity = 'n', flow = 'n';
493 int baud = 38400; 420 struct clps711x_port *s = (struct clps711x_port *)co->data;
494 int bits = 8; 421 struct uart_port *port = &s->port[(co->index > 0) ? co->index : 0];
495 int parity = 'n';
496 int flow = 'n';
497
498 /*
499 * Check whether an invalid uart number has been specified, and
500 * if so, search for the first available port that does have
501 * console support.
502 */
503 port = uart_get_console(clps711x_ports, UART_NR, co);
504 422
505 if (options) 423 if (options)
506 uart_parse_options(options, &baud, &parity, &bits, &flow); 424 uart_parse_options(options, &baud, &parity, &bits, &flow);
507 else 425 else
508 clps711xuart_console_get_options(port, &baud, &parity, &bits); 426 uart_clps711x_console_get_options(port, &baud, &parity, &bits);
509 427
510 return uart_set_options(port, co, baud, parity, bits, flow); 428 return uart_set_options(port, co, baud, parity, bits, flow);
511} 429}
430#endif
512 431
513static struct uart_driver clps711x_reg; 432static int uart_clps711x_probe(struct platform_device *pdev)
514static struct console clps711x_console = {
515 .name = "ttyCL",
516 .write = clps711xuart_console_write,
517 .device = uart_console_device,
518 .setup = clps711xuart_console_setup,
519 .flags = CON_PRINTBUFFER,
520 .index = -1,
521 .data = &clps711x_reg,
522};
523
524static int __init clps711xuart_console_init(void)
525{ 433{
526 register_console(&clps711x_console); 434 struct clps711x_port *s;
527 return 0; 435 int ret, i;
528} 436
529console_initcall(clps711xuart_console_init); 437 s = devm_kzalloc(&pdev->dev, sizeof(struct clps711x_port), GFP_KERNEL);
438 if (!s) {
439 dev_err(&pdev->dev, "Error allocating port structure\n");
440 return -ENOMEM;
441 }
442 platform_set_drvdata(pdev, s);
530 443
531#define CLPS711X_CONSOLE &clps711x_console 444 s->uart_clk = devm_clk_get(&pdev->dev, "uart");
532#else 445 if (IS_ERR(s->uart_clk)) {
533#define CLPS711X_CONSOLE NULL 446 dev_err(&pdev->dev, "Can't get UART clocks\n");
447 ret = PTR_ERR(s->uart_clk);
448 goto err_out;
449 }
450
451 s->uart.owner = THIS_MODULE;
452 s->uart.dev_name = "ttyCL";
453 s->uart.major = UART_CLPS711X_MAJOR;
454 s->uart.minor = UART_CLPS711X_MINOR;
455 s->uart.nr = UART_CLPS711X_NR;
456#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
457 s->uart.cons = &s->console;
458 s->uart.cons->device = uart_console_device;
459 s->uart.cons->write = uart_clps711x_console_write;
460 s->uart.cons->setup = uart_clps711x_console_setup;
461 s->uart.cons->flags = CON_PRINTBUFFER;
462 s->uart.cons->index = -1;
463 s->uart.cons->data = s;
464 strcpy(s->uart.cons->name, "ttyCL");
534#endif 465#endif
466 ret = uart_register_driver(&s->uart);
467 if (ret) {
468 dev_err(&pdev->dev, "Registering UART driver failed\n");
469 devm_clk_put(&pdev->dev, s->uart_clk);
470 goto err_out;
471 }
535 472
536static struct uart_driver clps711x_reg = { 473 for (i = 0; i < UART_CLPS711X_NR; i++) {
537 .driver_name = "ttyCL", 474 s->port[i].line = i;
538 .dev_name = "ttyCL", 475 s->port[i].dev = &pdev->dev;
539 .major = SERIAL_CLPS711X_MAJOR, 476 s->port[i].irq = TX_IRQ(&s->port[i]);
540 .minor = SERIAL_CLPS711X_MINOR, 477 s->port[i].iobase = SYSCON(&s->port[i]);
541 .nr = UART_NR, 478 s->port[i].type = PORT_CLPS711X;
479 s->port[i].fifosize = 16;
480 s->port[i].flags = UPF_SKIP_TEST | UPF_FIXED_TYPE;
481 s->port[i].uartclk = clk_get_rate(s->uart_clk);
482 s->port[i].ops = &uart_clps711x_ops;
483 WARN_ON(uart_add_one_port(&s->uart, &s->port[i]));
484 }
542 485
543 .cons = CLPS711X_CONSOLE, 486 return 0;
544};
545 487
546static int __init clps711xuart_init(void) 488err_out:
547{ 489 platform_set_drvdata(pdev, NULL);
548 int ret, i;
549 490
550 printk(KERN_INFO "Serial: CLPS711x driver\n"); 491 return ret;
492}
551 493
552 ret = uart_register_driver(&clps711x_reg); 494static int uart_clps711x_remove(struct platform_device *pdev)
553 if (ret) 495{
554 return ret; 496 struct clps711x_port *s = platform_get_drvdata(pdev);
497 int i;
555 498
556 for (i = 0; i < UART_NR; i++) 499 for (i = 0; i < UART_CLPS711X_NR; i++)
557 uart_add_one_port(&clps711x_reg, &clps711x_ports[i]); 500 uart_remove_one_port(&s->uart, &s->port[i]);
501
502 devm_clk_put(&pdev->dev, s->uart_clk);
503 uart_unregister_driver(&s->uart);
504 platform_set_drvdata(pdev, NULL);
558 505
559 return 0; 506 return 0;
560} 507}
561 508
562static void __exit clps711xuart_exit(void) 509static struct platform_driver clps711x_uart_driver = {
563{ 510 .driver = {
564 int i; 511 .name = UART_CLPS711X_NAME,
512 .owner = THIS_MODULE,
513 },
514 .probe = uart_clps711x_probe,
515 .remove = uart_clps711x_remove,
516};
517module_platform_driver(clps711x_uart_driver);
565 518
566 for (i = 0; i < UART_NR; i++) 519static struct platform_device clps711x_uart_device = {
567 uart_remove_one_port(&clps711x_reg, &clps711x_ports[i]); 520 .name = UART_CLPS711X_NAME,
521};
568 522
569 uart_unregister_driver(&clps711x_reg); 523static int __init uart_clps711x_init(void)
524{
525 return platform_device_register(&clps711x_uart_device);
570} 526}
527module_init(uart_clps711x_init);
571 528
572module_init(clps711xuart_init); 529static void __exit uart_clps711x_exit(void)
573module_exit(clps711xuart_exit); 530{
531 platform_device_unregister(&clps711x_uart_device);
532}
533module_exit(uart_clps711x_exit);
574 534
575MODULE_AUTHOR("Deep Blue Solutions Ltd"); 535MODULE_AUTHOR("Deep Blue Solutions Ltd");
576MODULE_DESCRIPTION("CLPS-711x generic serial driver"); 536MODULE_DESCRIPTION("CLPS711X serial driver");
577MODULE_LICENSE("GPL"); 537MODULE_LICENSE("GPL");
578MODULE_ALIAS_CHARDEV(SERIAL_CLPS711X_MAJOR, SERIAL_CLPS711X_MINOR);
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index d0dd9194cec..ad0caf17680 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1373,7 +1373,7 @@ static struct uart_driver cpm_reg = {
1373 1373
1374static int probe_index; 1374static int probe_index;
1375 1375
1376static int __devinit cpm_uart_probe(struct platform_device *ofdev) 1376static int cpm_uart_probe(struct platform_device *ofdev)
1377{ 1377{
1378 int index = probe_index++; 1378 int index = probe_index++;
1379 struct uart_cpm_port *pinfo = &cpm_uart_ports[index]; 1379 struct uart_cpm_port *pinfo = &cpm_uart_ports[index];
@@ -1396,7 +1396,7 @@ static int __devinit cpm_uart_probe(struct platform_device *ofdev)
1396 return uart_add_one_port(&cpm_reg, &pinfo->port); 1396 return uart_add_one_port(&cpm_reg, &pinfo->port);
1397} 1397}
1398 1398
1399static int __devexit cpm_uart_remove(struct platform_device *ofdev) 1399static int cpm_uart_remove(struct platform_device *ofdev)
1400{ 1400{
1401 struct uart_cpm_port *pinfo = dev_get_drvdata(&ofdev->dev); 1401 struct uart_cpm_port *pinfo = dev_get_drvdata(&ofdev->dev);
1402 return uart_remove_one_port(&cpm_reg, &pinfo->port); 1402 return uart_remove_one_port(&cpm_reg, &pinfo->port);
diff --git a/drivers/tty/serial/efm32-uart.c b/drivers/tty/serial/efm32-uart.c
index 615e4647049..a8cbb267052 100644
--- a/drivers/tty/serial/efm32-uart.c
+++ b/drivers/tty/serial/efm32-uart.c
@@ -690,7 +690,7 @@ static int efm32_uart_probe_dt(struct platform_device *pdev,
690 690
691} 691}
692 692
693static int __devinit efm32_uart_probe(struct platform_device *pdev) 693static int efm32_uart_probe(struct platform_device *pdev)
694{ 694{
695 struct efm32_uart_port *efm_port; 695 struct efm32_uart_port *efm_port;
696 struct resource *res; 696 struct resource *res;
@@ -764,7 +764,7 @@ err_get_base:
764 return ret; 764 return ret;
765} 765}
766 766
767static int __devexit efm32_uart_remove(struct platform_device *pdev) 767static int efm32_uart_remove(struct platform_device *pdev)
768{ 768{
769 struct efm32_uart_port *efm_port = platform_get_drvdata(pdev); 769 struct efm32_uart_port *efm_port = platform_get_drvdata(pdev);
770 770
@@ -791,7 +791,7 @@ MODULE_DEVICE_TABLE(of, efm32_uart_dt_ids);
791 791
792static struct platform_driver efm32_uart_driver = { 792static struct platform_driver efm32_uart_driver = {
793 .probe = efm32_uart_probe, 793 .probe = efm32_uart_probe,
794 .remove = __devexit_p(efm32_uart_remove), 794 .remove = efm32_uart_remove,
795 795
796 .driver = { 796 .driver = {
797 .name = DRIVER_NAME, 797 .name = DRIVER_NAME,
diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
index defc4e3393a..6197a69adb4 100644
--- a/drivers/tty/serial/icom.c
+++ b/drivers/tty/serial/icom.c
@@ -175,7 +175,7 @@ static void free_port_memory(struct icom_port *icom_port)
175 } 175 }
176} 176}
177 177
178static int __devinit get_port_memory(struct icom_port *icom_port) 178static int get_port_memory(struct icom_port *icom_port)
179{ 179{
180 int index; 180 int index;
181 unsigned long stgAddr; 181 unsigned long stgAddr;
@@ -1314,7 +1314,7 @@ static struct uart_driver icom_uart_driver = {
1314 .cons = ICOM_CONSOLE, 1314 .cons = ICOM_CONSOLE,
1315}; 1315};
1316 1316
1317static int __devinit icom_init_ports(struct icom_adapter *icom_adapter) 1317static int icom_init_ports(struct icom_adapter *icom_adapter)
1318{ 1318{
1319 u32 subsystem_id = icom_adapter->subsystem_id; 1319 u32 subsystem_id = icom_adapter->subsystem_id;
1320 int i; 1320 int i;
@@ -1381,7 +1381,7 @@ static void icom_port_active(struct icom_port *icom_port, struct icom_adapter *i
1381 0x8024 + 2 - 2 * (icom_port->port - 2); 1381 0x8024 + 2 - 2 * (icom_port->port - 2);
1382 } 1382 }
1383} 1383}
1384static int __devinit icom_load_ports(struct icom_adapter *icom_adapter) 1384static int icom_load_ports(struct icom_adapter *icom_adapter)
1385{ 1385{
1386 struct icom_port *icom_port; 1386 struct icom_port *icom_port;
1387 int port_num; 1387 int port_num;
@@ -1407,7 +1407,7 @@ static int __devinit icom_load_ports(struct icom_adapter *icom_adapter)
1407 return 0; 1407 return 0;
1408} 1408}
1409 1409
1410static int __devinit icom_alloc_adapter(struct icom_adapter 1410static int icom_alloc_adapter(struct icom_adapter
1411 **icom_adapter_ref) 1411 **icom_adapter_ref)
1412{ 1412{
1413 int adapter_count = 0; 1413 int adapter_count = 0;
@@ -1487,7 +1487,7 @@ static void icom_kref_release(struct kref *kref)
1487 icom_remove_adapter(icom_adapter); 1487 icom_remove_adapter(icom_adapter);
1488} 1488}
1489 1489
1490static int __devinit icom_probe(struct pci_dev *dev, 1490static int icom_probe(struct pci_dev *dev,
1491 const struct pci_device_id *ent) 1491 const struct pci_device_id *ent)
1492{ 1492{
1493 int index; 1493 int index;
@@ -1596,7 +1596,7 @@ probe_exit0:
1596 return retval; 1596 return retval;
1597} 1597}
1598 1598
1599static void __devexit icom_remove(struct pci_dev *dev) 1599static void icom_remove(struct pci_dev *dev)
1600{ 1600{
1601 struct icom_adapter *icom_adapter; 1601 struct icom_adapter *icom_adapter;
1602 struct list_head *tmp; 1602 struct list_head *tmp;
@@ -1617,7 +1617,7 @@ static struct pci_driver icom_pci_driver = {
1617 .name = ICOM_DRIVER_NAME, 1617 .name = ICOM_DRIVER_NAME,
1618 .id_table = icom_pci_table, 1618 .id_table = icom_pci_table,
1619 .probe = icom_probe, 1619 .probe = icom_probe,
1620 .remove = __devexit_p(icom_remove), 1620 .remove = icom_remove,
1621}; 1621};
1622 1622
1623static int __init icom_init(void) 1623static int __init icom_init(void)
diff --git a/drivers/tty/serial/ifx6x60.c b/drivers/tty/serial/ifx6x60.c
index 5b9bc19ed13..675d94ab0af 100644
--- a/drivers/tty/serial/ifx6x60.c
+++ b/drivers/tty/serial/ifx6x60.c
@@ -60,20 +60,27 @@
60#include <linux/pm_runtime.h> 60#include <linux/pm_runtime.h>
61#include <linux/spi/ifx_modem.h> 61#include <linux/spi/ifx_modem.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/reboot.h>
63 64
64#include "ifx6x60.h" 65#include "ifx6x60.h"
65 66
66#define IFX_SPI_MORE_MASK 0x10 67#define IFX_SPI_MORE_MASK 0x10
67#define IFX_SPI_MORE_BIT 12 /* bit position in u16 */ 68#define IFX_SPI_MORE_BIT 4 /* bit position in u8 */
68#define IFX_SPI_CTS_BIT 13 /* bit position in u16 */ 69#define IFX_SPI_CTS_BIT 6 /* bit position in u8 */
69#define IFX_SPI_MODE SPI_MODE_1 70#define IFX_SPI_MODE SPI_MODE_1
70#define IFX_SPI_TTY_ID 0 71#define IFX_SPI_TTY_ID 0
71#define IFX_SPI_TIMEOUT_SEC 2 72#define IFX_SPI_TIMEOUT_SEC 2
72#define IFX_SPI_HEADER_0 (-1) 73#define IFX_SPI_HEADER_0 (-1)
73#define IFX_SPI_HEADER_F (-2) 74#define IFX_SPI_HEADER_F (-2)
74 75
76#define PO_POST_DELAY 200
77#define IFX_MDM_RST_PMU 4
78
75/* forward reference */ 79/* forward reference */
76static void ifx_spi_handle_srdy(struct ifx_spi_device *ifx_dev); 80static void ifx_spi_handle_srdy(struct ifx_spi_device *ifx_dev);
81static int ifx_modem_reboot_callback(struct notifier_block *nfb,
82 unsigned long event, void *data);
83static int ifx_modem_power_off(struct ifx_spi_device *ifx_dev);
77 84
78/* local variables */ 85/* local variables */
79static int spi_bpw = 16; /* 8, 16 or 32 bit word length */ 86static int spi_bpw = 16; /* 8, 16 or 32 bit word length */
@@ -81,6 +88,29 @@ static struct tty_driver *tty_drv;
81static struct ifx_spi_device *saved_ifx_dev; 88static struct ifx_spi_device *saved_ifx_dev;
82static struct lock_class_key ifx_spi_key; 89static struct lock_class_key ifx_spi_key;
83 90
91static struct notifier_block ifx_modem_reboot_notifier_block = {
92 .notifier_call = ifx_modem_reboot_callback,
93};
94
95static int ifx_modem_power_off(struct ifx_spi_device *ifx_dev)
96{
97 gpio_set_value(IFX_MDM_RST_PMU, 1);
98 msleep(PO_POST_DELAY);
99
100 return 0;
101}
102
103static int ifx_modem_reboot_callback(struct notifier_block *nfb,
104 unsigned long event, void *data)
105{
106 if (saved_ifx_dev)
107 ifx_modem_power_off(saved_ifx_dev);
108 else
109 pr_warn("no ifx modem active;\n");
110
111 return NOTIFY_OK;
112}
113
84/* GPIO/GPE settings */ 114/* GPIO/GPE settings */
85 115
86/** 116/**
@@ -152,26 +182,67 @@ ifx_spi_power_state_clear(struct ifx_spi_device *ifx_dev, unsigned char val)
152} 182}
153 183
154/** 184/**
155 * swap_buf 185 * swap_buf_8
156 * @buf: our buffer 186 * @buf: our buffer
157 * @len : number of bytes (not words) in the buffer 187 * @len : number of bytes (not words) in the buffer
158 * @end: end of buffer 188 * @end: end of buffer
159 * 189 *
160 * Swap the contents of a buffer into big endian format 190 * Swap the contents of a buffer into big endian format
161 */ 191 */
162static inline void swap_buf(u16 *buf, int len, void *end) 192static inline void swap_buf_8(unsigned char *buf, int len, void *end)
193{
194 /* don't swap buffer if SPI word width is 8 bits */
195 return;
196}
197
198/**
199 * swap_buf_16
200 * @buf: our buffer
201 * @len : number of bytes (not words) in the buffer
202 * @end: end of buffer
203 *
204 * Swap the contents of a buffer into big endian format
205 */
206static inline void swap_buf_16(unsigned char *buf, int len, void *end)
163{ 207{
164 int n; 208 int n;
165 209
210 u16 *buf_16 = (u16 *)buf;
166 len = ((len + 1) >> 1); 211 len = ((len + 1) >> 1);
167 if ((void *)&buf[len] > end) { 212 if ((void *)&buf_16[len] > end) {
168 pr_err("swap_buf: swap exceeds boundary (%p > %p)!", 213 pr_err("swap_buf_16: swap exceeds boundary (%p > %p)!",
169 &buf[len], end); 214 &buf_16[len], end);
215 return;
216 }
217 for (n = 0; n < len; n++) {
218 *buf_16 = cpu_to_be16(*buf_16);
219 buf_16++;
220 }
221}
222
223/**
224 * swap_buf_32
225 * @buf: our buffer
226 * @len : number of bytes (not words) in the buffer
227 * @end: end of buffer
228 *
229 * Swap the contents of a buffer into big endian format
230 */
231static inline void swap_buf_32(unsigned char *buf, int len, void *end)
232{
233 int n;
234
235 u32 *buf_32 = (u32 *)buf;
236 len = (len + 3) >> 2;
237
238 if ((void *)&buf_32[len] > end) {
239 pr_err("swap_buf_32: swap exceeds boundary (%p > %p)!\n",
240 &buf_32[len], end);
170 return; 241 return;
171 } 242 }
172 for (n = 0; n < len; n++) { 243 for (n = 0; n < len; n++) {
173 *buf = cpu_to_be16(*buf); 244 *buf_32 = cpu_to_be32(*buf_32);
174 buf++; 245 buf_32++;
175 } 246 }
176} 247}
177 248
@@ -190,9 +261,7 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev)
190 if (!val) { 261 if (!val) {
191 if (!test_and_set_bit(IFX_SPI_STATE_TIMER_PENDING, 262 if (!test_and_set_bit(IFX_SPI_STATE_TIMER_PENDING,
192 &ifx_dev->flags)) { 263 &ifx_dev->flags)) {
193 ifx_dev->spi_timer.expires = 264 mod_timer(&ifx_dev->spi_timer,jiffies + IFX_SPI_TIMEOUT_SEC*HZ);
194 jiffies + IFX_SPI_TIMEOUT_SEC*HZ;
195 add_timer(&ifx_dev->spi_timer);
196 265
197 } 266 }
198 } 267 }
@@ -449,7 +518,7 @@ static int ifx_spi_prepare_tx_buffer(struct ifx_spi_device *ifx_dev)
449 tx_count-IFX_SPI_HEADER_OVERHEAD, 518 tx_count-IFX_SPI_HEADER_OVERHEAD,
450 ifx_dev->spi_more); 519 ifx_dev->spi_more);
451 /* swap actual data in the buffer */ 520 /* swap actual data in the buffer */
452 swap_buf((u16 *)(ifx_dev->tx_buffer), tx_count, 521 ifx_dev->swap_buf((ifx_dev->tx_buffer), tx_count,
453 &ifx_dev->tx_buffer[IFX_SPI_TRANSFER_SIZE]); 522 &ifx_dev->tx_buffer[IFX_SPI_TRANSFER_SIZE]);
454 return tx_count; 523 return tx_count;
455} 524}
@@ -469,9 +538,17 @@ static int ifx_spi_write(struct tty_struct *tty, const unsigned char *buf,
469{ 538{
470 struct ifx_spi_device *ifx_dev = tty->driver_data; 539 struct ifx_spi_device *ifx_dev = tty->driver_data;
471 unsigned char *tmp_buf = (unsigned char *)buf; 540 unsigned char *tmp_buf = (unsigned char *)buf;
472 int tx_count = kfifo_in_locked(&ifx_dev->tx_fifo, tmp_buf, count, 541 unsigned long flags;
473 &ifx_dev->fifo_lock); 542 bool is_fifo_empty;
474 mrdy_assert(ifx_dev); 543 int tx_count;
544
545 spin_lock_irqsave(&ifx_dev->fifo_lock, flags);
546 is_fifo_empty = kfifo_is_empty(&ifx_dev->tx_fifo);
547 tx_count = kfifo_in(&ifx_dev->tx_fifo, tmp_buf, count);
548 spin_unlock_irqrestore(&ifx_dev->fifo_lock, flags);
549 if (is_fifo_empty)
550 mrdy_assert(ifx_dev);
551
475 return tx_count; 552 return tx_count;
476} 553}
477 554
@@ -530,12 +607,19 @@ static int ifx_port_activate(struct tty_port *port, struct tty_struct *tty)
530 /* clear any old data; can't do this in 'close' */ 607 /* clear any old data; can't do this in 'close' */
531 kfifo_reset(&ifx_dev->tx_fifo); 608 kfifo_reset(&ifx_dev->tx_fifo);
532 609
610 /* clear any flag which may be set in port shutdown procedure */
611 clear_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &ifx_dev->flags);
612 clear_bit(IFX_SPI_STATE_IO_READY, &ifx_dev->flags);
613
533 /* put port data into this tty */ 614 /* put port data into this tty */
534 tty->driver_data = ifx_dev; 615 tty->driver_data = ifx_dev;
535 616
536 /* allows flip string push from int context */ 617 /* allows flip string push from int context */
537 tty->low_latency = 1; 618 tty->low_latency = 1;
538 619
620 /* set flag to allows data transfer */
621 set_bit(IFX_SPI_STATE_IO_AVAILABLE, &ifx_dev->flags);
622
539 return 0; 623 return 0;
540} 624}
541 625
@@ -551,6 +635,7 @@ static void ifx_port_shutdown(struct tty_port *port)
551 struct ifx_spi_device *ifx_dev = 635 struct ifx_spi_device *ifx_dev =
552 container_of(port, struct ifx_spi_device, tty_port); 636 container_of(port, struct ifx_spi_device, tty_port);
553 637
638 clear_bit(IFX_SPI_STATE_IO_AVAILABLE, &ifx_dev->flags);
554 mrdy_set_low(ifx_dev); 639 mrdy_set_low(ifx_dev);
555 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); 640 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
556 tasklet_kill(&ifx_dev->io_work_tasklet); 641 tasklet_kill(&ifx_dev->io_work_tasklet);
@@ -617,7 +702,7 @@ static void ifx_spi_complete(void *ctx)
617 702
618 if (!ifx_dev->spi_msg.status) { 703 if (!ifx_dev->spi_msg.status) {
619 /* check header validity, get comm flags */ 704 /* check header validity, get comm flags */
620 swap_buf((u16 *)ifx_dev->rx_buffer, IFX_SPI_HEADER_OVERHEAD, 705 ifx_dev->swap_buf(ifx_dev->rx_buffer, IFX_SPI_HEADER_OVERHEAD,
621 &ifx_dev->rx_buffer[IFX_SPI_HEADER_OVERHEAD]); 706 &ifx_dev->rx_buffer[IFX_SPI_HEADER_OVERHEAD]);
622 decode_result = ifx_spi_decode_spi_header(ifx_dev->rx_buffer, 707 decode_result = ifx_spi_decode_spi_header(ifx_dev->rx_buffer,
623 &length, &more, &cts); 708 &length, &more, &cts);
@@ -636,7 +721,8 @@ static void ifx_spi_complete(void *ctx)
636 721
637 actual_length = min((unsigned int)length, 722 actual_length = min((unsigned int)length,
638 ifx_dev->spi_msg.actual_length); 723 ifx_dev->spi_msg.actual_length);
639 swap_buf((u16 *)(ifx_dev->rx_buffer + IFX_SPI_HEADER_OVERHEAD), 724 ifx_dev->swap_buf(
725 (ifx_dev->rx_buffer + IFX_SPI_HEADER_OVERHEAD),
640 actual_length, 726 actual_length,
641 &ifx_dev->rx_buffer[IFX_SPI_TRANSFER_SIZE]); 727 &ifx_dev->rx_buffer[IFX_SPI_TRANSFER_SIZE]);
642 ifx_spi_insert_flip_string( 728 ifx_spi_insert_flip_string(
@@ -705,7 +791,8 @@ static void ifx_spi_io(unsigned long data)
705 int retval; 791 int retval;
706 struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *) data; 792 struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *) data;
707 793
708 if (!test_and_set_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &ifx_dev->flags)) { 794 if (!test_and_set_bit(IFX_SPI_STATE_IO_IN_PROGRESS, &ifx_dev->flags) &&
795 test_bit(IFX_SPI_STATE_IO_AVAILABLE, &ifx_dev->flags)) {
709 if (ifx_dev->gpio.unack_srdy_int_nb > 0) 796 if (ifx_dev->gpio.unack_srdy_int_nb > 0)
710 ifx_dev->gpio.unack_srdy_int_nb--; 797 ifx_dev->gpio.unack_srdy_int_nb--;
711 798
@@ -773,6 +860,7 @@ static void ifx_spi_free_port(struct ifx_spi_device *ifx_dev)
773{ 860{
774 if (ifx_dev->tty_dev) 861 if (ifx_dev->tty_dev)
775 tty_unregister_device(tty_drv, ifx_dev->minor); 862 tty_unregister_device(tty_drv, ifx_dev->minor);
863 tty_port_destroy(&ifx_dev->tty_port);
776 kfifo_free(&ifx_dev->tx_fifo); 864 kfifo_free(&ifx_dev->tx_fifo);
777} 865}
778 866
@@ -806,10 +894,12 @@ static int ifx_spi_create_port(struct ifx_spi_device *ifx_dev)
806 dev_dbg(&ifx_dev->spi_dev->dev, 894 dev_dbg(&ifx_dev->spi_dev->dev,
807 "%s: registering tty device failed", __func__); 895 "%s: registering tty device failed", __func__);
808 ret = PTR_ERR(ifx_dev->tty_dev); 896 ret = PTR_ERR(ifx_dev->tty_dev);
809 goto error_ret; 897 goto error_port;
810 } 898 }
811 return 0; 899 return 0;
812 900
901error_port:
902 tty_port_destroy(pport);
813error_ret: 903error_ret:
814 ifx_spi_free_port(ifx_dev); 904 ifx_spi_free_port(ifx_dev);
815 return ret; 905 return ret;
@@ -826,7 +916,7 @@ error_ret:
826static void ifx_spi_handle_srdy(struct ifx_spi_device *ifx_dev) 916static void ifx_spi_handle_srdy(struct ifx_spi_device *ifx_dev)
827{ 917{
828 if (test_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags)) { 918 if (test_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags)) {
829 del_timer_sync(&ifx_dev->spi_timer); 919 del_timer(&ifx_dev->spi_timer);
830 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags); 920 clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
831 } 921 }
832 922
@@ -1001,6 +1091,14 @@ static int ifx_spi_spi_probe(struct spi_device *spi)
1001 return -ENODEV; 1091 return -ENODEV;
1002 } 1092 }
1003 1093
1094 /* init swap_buf function according to word width configuration */
1095 if (spi->bits_per_word == 32)
1096 ifx_dev->swap_buf = swap_buf_32;
1097 else if (spi->bits_per_word == 16)
1098 ifx_dev->swap_buf = swap_buf_16;
1099 else
1100 ifx_dev->swap_buf = swap_buf_8;
1101
1004 /* ensure SPI protocol flags are initialized to enable transfer */ 1102 /* ensure SPI protocol flags are initialized to enable transfer */
1005 ifx_dev->spi_more = 0; 1103 ifx_dev->spi_more = 0;
1006 ifx_dev->spi_slave_cts = 0; 1104 ifx_dev->spi_slave_cts = 0;
@@ -1219,6 +1317,9 @@ static int ifx_spi_spi_remove(struct spi_device *spi)
1219 1317
1220static void ifx_spi_spi_shutdown(struct spi_device *spi) 1318static void ifx_spi_spi_shutdown(struct spi_device *spi)
1221{ 1319{
1320 struct ifx_spi_device *ifx_dev = spi_get_drvdata(spi);
1321
1322 ifx_modem_power_off(ifx_dev);
1222} 1323}
1223 1324
1224/* 1325/*
@@ -1338,7 +1439,7 @@ static struct spi_driver ifx_spi_driver = {
1338 .owner = THIS_MODULE}, 1439 .owner = THIS_MODULE},
1339 .probe = ifx_spi_spi_probe, 1440 .probe = ifx_spi_spi_probe,
1340 .shutdown = ifx_spi_spi_shutdown, 1441 .shutdown = ifx_spi_spi_shutdown,
1341 .remove = __devexit_p(ifx_spi_spi_remove), 1442 .remove = ifx_spi_spi_remove,
1342 .suspend = ifx_spi_spi_suspend, 1443 .suspend = ifx_spi_spi_suspend,
1343 .resume = ifx_spi_spi_resume, 1444 .resume = ifx_spi_spi_resume,
1344 .id_table = ifx_id_table 1445 .id_table = ifx_id_table
@@ -1354,7 +1455,9 @@ static void __exit ifx_spi_exit(void)
1354{ 1455{
1355 /* unregister */ 1456 /* unregister */
1356 tty_unregister_driver(tty_drv); 1457 tty_unregister_driver(tty_drv);
1458 put_tty_driver(tty_drv);
1357 spi_unregister_driver((void *)&ifx_spi_driver); 1459 spi_unregister_driver((void *)&ifx_spi_driver);
1460 unregister_reboot_notifier(&ifx_modem_reboot_notifier_block);
1358} 1461}
1359 1462
1360/** 1463/**
@@ -1389,16 +1492,31 @@ static int __init ifx_spi_init(void)
1389 if (result) { 1492 if (result) {
1390 pr_err("%s: tty_register_driver failed(%d)", 1493 pr_err("%s: tty_register_driver failed(%d)",
1391 DRVNAME, result); 1494 DRVNAME, result);
1392 put_tty_driver(tty_drv); 1495 goto err_free_tty;
1393 return result;
1394 } 1496 }
1395 1497
1396 result = spi_register_driver((void *)&ifx_spi_driver); 1498 result = spi_register_driver((void *)&ifx_spi_driver);
1397 if (result) { 1499 if (result) {
1398 pr_err("%s: spi_register_driver failed(%d)", 1500 pr_err("%s: spi_register_driver failed(%d)",
1399 DRVNAME, result); 1501 DRVNAME, result);
1400 tty_unregister_driver(tty_drv); 1502 goto err_unreg_tty;
1401 } 1503 }
1504
1505 result = register_reboot_notifier(&ifx_modem_reboot_notifier_block);
1506 if (result) {
1507 pr_err("%s: register ifx modem reboot notifier failed(%d)",
1508 DRVNAME, result);
1509 goto err_unreg_spi;
1510 }
1511
1512 return 0;
1513err_unreg_spi:
1514 spi_unregister_driver((void *)&ifx_spi_driver);
1515err_unreg_tty:
1516 tty_unregister_driver(tty_drv);
1517err_free_tty:
1518 put_tty_driver(tty_drv);
1519
1402 return result; 1520 return result;
1403} 1521}
1404 1522
diff --git a/drivers/tty/serial/ifx6x60.h b/drivers/tty/serial/ifx6x60.h
index e8464baf9e7..4fbddc29783 100644
--- a/drivers/tty/serial/ifx6x60.h
+++ b/drivers/tty/serial/ifx6x60.h
@@ -41,6 +41,7 @@
41#define IFX_SPI_STATE_IO_IN_PROGRESS 1 41#define IFX_SPI_STATE_IO_IN_PROGRESS 1
42#define IFX_SPI_STATE_IO_READY 2 42#define IFX_SPI_STATE_IO_READY 2
43#define IFX_SPI_STATE_TIMER_PENDING 3 43#define IFX_SPI_STATE_TIMER_PENDING 3
44#define IFX_SPI_STATE_IO_AVAILABLE 4
44 45
45/* flow control bitfields */ 46/* flow control bitfields */
46#define IFX_SPI_DCD 0 47#define IFX_SPI_DCD 0
@@ -124,6 +125,7 @@ struct ifx_spi_device {
124#define MR_INPROGRESS 1 125#define MR_INPROGRESS 1
125#define MR_COMPLETE 2 126#define MR_COMPLETE 2
126 wait_queue_head_t mdm_reset_wait; 127 wait_queue_head_t mdm_reset_wait;
128 void (*swap_buf)(unsigned char *buf, int len, void *end);
127}; 129};
128 130
129#endif /* _IFX6X60_H */ 131#endif /* _IFX6X60_H */
diff --git a/drivers/tty/serial/ioc3_serial.c b/drivers/tty/serial/ioc3_serial.c
index 5ac52898a0b..d8f1d1d5447 100644
--- a/drivers/tty/serial/ioc3_serial.c
+++ b/drivers/tty/serial/ioc3_serial.c
@@ -2010,7 +2010,7 @@ static int ioc3uart_remove(struct ioc3_submodule *is,
2010 * @idd: ioc3 driver data for this card 2010 * @idd: ioc3 driver data for this card
2011 */ 2011 */
2012 2012
2013static int __devinit 2013static int
2014ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd) 2014ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2015{ 2015{
2016 struct pci_dev *pdev = idd->pdev; 2016 struct pci_dev *pdev = idd->pdev;
diff --git a/drivers/tty/serial/jsm/jsm.h b/drivers/tty/serial/jsm/jsm.h
index 529bec6edaf..844d5e4eb1a 100644
--- a/drivers/tty/serial/jsm/jsm.h
+++ b/drivers/tty/serial/jsm/jsm.h
@@ -57,9 +57,11 @@ enum {
57 DBG_CARR = 0x10000, 57 DBG_CARR = 0x10000,
58}; 58};
59 59
60#define jsm_printk(nlevel, klevel, pdev, fmt, args...) \ 60#define jsm_dbg(nlevel, pdev, fmt, ...) \
61 if ((DBG_##nlevel & jsm_debug)) \ 61do { \
62 dev_printk(KERN_##klevel, pdev->dev, fmt, ## args) 62 if (DBG_##nlevel & jsm_debug) \
63 dev_dbg(pdev->dev, fmt, ##__VA_ARGS__); \
64} while (0)
63 65
64#define MAXLINES 256 66#define MAXLINES 256
65#define MAXPORTS 8 67#define MAXPORTS 8
diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c
index 5ab3c3b595e..a47d882d674 100644
--- a/drivers/tty/serial/jsm/jsm_driver.c
+++ b/drivers/tty/serial/jsm/jsm_driver.c
@@ -64,7 +64,7 @@ int jsm_debug;
64module_param(jsm_debug, int, 0); 64module_param(jsm_debug, int, 0);
65MODULE_PARM_DESC(jsm_debug, "Driver debugging level"); 65MODULE_PARM_DESC(jsm_debug, "Driver debugging level");
66 66
67static int __devinit jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent) 67static int jsm_probe_one(struct pci_dev *pdev, const struct pci_device_id *ent)
68{ 68{
69 int rc = 0; 69 int rc = 0;
70 struct jsm_board *brd; 70 struct jsm_board *brd;
@@ -107,8 +107,7 @@ static int __devinit jsm_probe_one(struct pci_dev *pdev, const struct pci_device
107 107
108 brd->irq = pdev->irq; 108 brd->irq = pdev->irq;
109 109
110 jsm_printk(INIT, INFO, &brd->pci_dev, 110 jsm_dbg(INIT, &brd->pci_dev, "jsm_found_board - NEO adapter\n");
111 "jsm_found_board - NEO adapter\n");
112 111
113 /* get the PCI Base Address Registers */ 112 /* get the PCI Base Address Registers */
114 brd->membase = pci_resource_start(pdev, 0); 113 brd->membase = pci_resource_start(pdev, 0);
@@ -179,7 +178,7 @@ static int __devinit jsm_probe_one(struct pci_dev *pdev, const struct pci_device
179 return rc; 178 return rc;
180} 179}
181 180
182static void __devexit jsm_remove_one(struct pci_dev *pdev) 181static void jsm_remove_one(struct pci_dev *pdev)
183{ 182{
184 struct jsm_board *brd = pci_get_drvdata(pdev); 183 struct jsm_board *brd = pci_get_drvdata(pdev);
185 int i = 0; 184 int i = 0;
@@ -218,7 +217,7 @@ static struct pci_driver jsm_driver = {
218 .name = "jsm", 217 .name = "jsm",
219 .id_table = jsm_pci_tbl, 218 .id_table = jsm_pci_tbl,
220 .probe = jsm_probe_one, 219 .probe = jsm_probe_one,
221 .remove = __devexit_p(jsm_remove_one), 220 .remove = jsm_remove_one,
222 .err_handler = &jsm_err_handler, 221 .err_handler = &jsm_err_handler,
223}; 222};
224 223
diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index 81dfafa11b0..dfaf4882641 100644
--- a/drivers/tty/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
@@ -52,7 +52,7 @@ static void neo_set_cts_flow_control(struct jsm_channel *ch)
52 ier = readb(&ch->ch_neo_uart->ier); 52 ier = readb(&ch->ch_neo_uart->ier);
53 efr = readb(&ch->ch_neo_uart->efr); 53 efr = readb(&ch->ch_neo_uart->efr);
54 54
55 jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting CTSFLOW\n"); 55 jsm_dbg(PARAM, &ch->ch_bd->pci_dev, "Setting CTSFLOW\n");
56 56
57 /* Turn on auto CTS flow control */ 57 /* Turn on auto CTS flow control */
58 ier |= (UART_17158_IER_CTSDSR); 58 ier |= (UART_17158_IER_CTSDSR);
@@ -83,7 +83,7 @@ static void neo_set_rts_flow_control(struct jsm_channel *ch)
83 ier = readb(&ch->ch_neo_uart->ier); 83 ier = readb(&ch->ch_neo_uart->ier);
84 efr = readb(&ch->ch_neo_uart->efr); 84 efr = readb(&ch->ch_neo_uart->efr);
85 85
86 jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting RTSFLOW\n"); 86 jsm_dbg(PARAM, &ch->ch_bd->pci_dev, "Setting RTSFLOW\n");
87 87
88 /* Turn on auto RTS flow control */ 88 /* Turn on auto RTS flow control */
89 ier |= (UART_17158_IER_RTSDTR); 89 ier |= (UART_17158_IER_RTSDTR);
@@ -123,7 +123,7 @@ static void neo_set_ixon_flow_control(struct jsm_channel *ch)
123 ier = readb(&ch->ch_neo_uart->ier); 123 ier = readb(&ch->ch_neo_uart->ier);
124 efr = readb(&ch->ch_neo_uart->efr); 124 efr = readb(&ch->ch_neo_uart->efr);
125 125
126 jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting IXON FLOW\n"); 126 jsm_dbg(PARAM, &ch->ch_bd->pci_dev, "Setting IXON FLOW\n");
127 127
128 /* Turn off auto CTS flow control */ 128 /* Turn off auto CTS flow control */
129 ier &= ~(UART_17158_IER_CTSDSR); 129 ier &= ~(UART_17158_IER_CTSDSR);
@@ -160,7 +160,7 @@ static void neo_set_ixoff_flow_control(struct jsm_channel *ch)
160 ier = readb(&ch->ch_neo_uart->ier); 160 ier = readb(&ch->ch_neo_uart->ier);
161 efr = readb(&ch->ch_neo_uart->efr); 161 efr = readb(&ch->ch_neo_uart->efr);
162 162
163 jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Setting IXOFF FLOW\n"); 163 jsm_dbg(PARAM, &ch->ch_bd->pci_dev, "Setting IXOFF FLOW\n");
164 164
165 /* Turn off auto RTS flow control */ 165 /* Turn off auto RTS flow control */
166 ier &= ~(UART_17158_IER_RTSDTR); 166 ier &= ~(UART_17158_IER_RTSDTR);
@@ -198,7 +198,7 @@ static void neo_set_no_input_flow_control(struct jsm_channel *ch)
198 ier = readb(&ch->ch_neo_uart->ier); 198 ier = readb(&ch->ch_neo_uart->ier);
199 efr = readb(&ch->ch_neo_uart->efr); 199 efr = readb(&ch->ch_neo_uart->efr);
200 200
201 jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Unsetting Input FLOW\n"); 201 jsm_dbg(PARAM, &ch->ch_bd->pci_dev, "Unsetting Input FLOW\n");
202 202
203 /* Turn off auto RTS flow control */ 203 /* Turn off auto RTS flow control */
204 ier &= ~(UART_17158_IER_RTSDTR); 204 ier &= ~(UART_17158_IER_RTSDTR);
@@ -237,7 +237,7 @@ static void neo_set_no_output_flow_control(struct jsm_channel *ch)
237 ier = readb(&ch->ch_neo_uart->ier); 237 ier = readb(&ch->ch_neo_uart->ier);
238 efr = readb(&ch->ch_neo_uart->efr); 238 efr = readb(&ch->ch_neo_uart->efr);
239 239
240 jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "Unsetting Output FLOW\n"); 240 jsm_dbg(PARAM, &ch->ch_bd->pci_dev, "Unsetting Output FLOW\n");
241 241
242 /* Turn off auto CTS flow control */ 242 /* Turn off auto CTS flow control */
243 ier &= ~(UART_17158_IER_CTSDSR); 243 ier &= ~(UART_17158_IER_CTSDSR);
@@ -276,7 +276,7 @@ static inline void neo_set_new_start_stop_chars(struct jsm_channel *ch)
276 if (ch->ch_c_cflag & CRTSCTS) 276 if (ch->ch_c_cflag & CRTSCTS)
277 return; 277 return;
278 278
279 jsm_printk(PARAM, INFO, &ch->ch_bd->pci_dev, "start\n"); 279 jsm_dbg(PARAM, &ch->ch_bd->pci_dev, "start\n");
280 280
281 /* Tell UART what start/stop chars it should be looking for */ 281 /* Tell UART what start/stop chars it should be looking for */
282 writeb(ch->ch_startc, &ch->ch_neo_uart->xonchar1); 282 writeb(ch->ch_startc, &ch->ch_neo_uart->xonchar1);
@@ -455,7 +455,7 @@ static void neo_copy_data_from_uart_to_queue(struct jsm_channel *ch)
455 * I hope thats okay with everyone? Yes? Good. 455 * I hope thats okay with everyone? Yes? Good.
456 */ 456 */
457 while (qleft < 1) { 457 while (qleft < 1) {
458 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 458 jsm_dbg(READ, &ch->ch_bd->pci_dev,
459 "Queue full, dropping DATA:%x LSR:%x\n", 459 "Queue full, dropping DATA:%x LSR:%x\n",
460 ch->ch_rqueue[tail], ch->ch_equeue[tail]); 460 ch->ch_rqueue[tail], ch->ch_equeue[tail]);
461 461
@@ -467,8 +467,8 @@ static void neo_copy_data_from_uart_to_queue(struct jsm_channel *ch)
467 memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1); 467 memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1);
468 ch->ch_equeue[head] = (u8) linestatus; 468 ch->ch_equeue[head] = (u8) linestatus;
469 469
470 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 470 jsm_dbg(READ, &ch->ch_bd->pci_dev, "DATA/LSR pair: %x %x\n",
471 "DATA/LSR pair: %x %x\n", ch->ch_rqueue[head], ch->ch_equeue[head]); 471 ch->ch_rqueue[head], ch->ch_equeue[head]);
472 472
473 /* Ditch any remaining linestatus value. */ 473 /* Ditch any remaining linestatus value. */
474 linestatus = 0; 474 linestatus = 0;
@@ -521,8 +521,8 @@ static void neo_copy_data_from_queue_to_uart(struct jsm_channel *ch)
521 ch->ch_cached_lsr &= ~(UART_LSR_THRE); 521 ch->ch_cached_lsr &= ~(UART_LSR_THRE);
522 522
523 writeb(circ->buf[circ->tail], &ch->ch_neo_uart->txrx); 523 writeb(circ->buf[circ->tail], &ch->ch_neo_uart->txrx);
524 jsm_printk(WRITE, INFO, &ch->ch_bd->pci_dev, 524 jsm_dbg(WRITE, &ch->ch_bd->pci_dev,
525 "Tx data: %x\n", circ->buf[circ->tail]); 525 "Tx data: %x\n", circ->buf[circ->tail]);
526 circ->tail = (circ->tail + 1) & (UART_XMIT_SIZE - 1); 526 circ->tail = (circ->tail + 1) & (UART_XMIT_SIZE - 1);
527 ch->ch_txcount++; 527 ch->ch_txcount++;
528 } 528 }
@@ -575,8 +575,9 @@ static void neo_parse_modem(struct jsm_channel *ch, u8 signals)
575{ 575{
576 u8 msignals = signals; 576 u8 msignals = signals;
577 577
578 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev, 578 jsm_dbg(MSIGS, &ch->ch_bd->pci_dev,
579 "neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals); 579 "neo_parse_modem: port: %d msignals: %x\n",
580 ch->ch_portnum, msignals);
580 581
581 /* Scrub off lower bits. They signify delta's, which I don't care about */ 582 /* Scrub off lower bits. They signify delta's, which I don't care about */
582 /* Keep DDCD and DDSR though */ 583 /* Keep DDCD and DDSR though */
@@ -606,8 +607,8 @@ static void neo_parse_modem(struct jsm_channel *ch, u8 signals)
606 else 607 else
607 ch->ch_mistat &= ~UART_MSR_CTS; 608 ch->ch_mistat &= ~UART_MSR_CTS;
608 609
609 jsm_printk(MSIGS, INFO, &ch->ch_bd->pci_dev, 610 jsm_dbg(MSIGS, &ch->ch_bd->pci_dev,
610 "Port: %d DTR: %d RTS: %d CTS: %d DSR: %d " "RI: %d CD: %d\n", 611 "Port: %d DTR: %d RTS: %d CTS: %d DSR: %d " "RI: %d CD: %d\n",
611 ch->ch_portnum, 612 ch->ch_portnum,
612 !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_DTR), 613 !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_DTR),
613 !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_RTS), 614 !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_RTS),
@@ -649,8 +650,8 @@ static void neo_flush_uart_write(struct jsm_channel *ch)
649 /* Check to see if the UART feels it completely flushed the FIFO. */ 650 /* Check to see if the UART feels it completely flushed the FIFO. */
650 tmp = readb(&ch->ch_neo_uart->isr_fcr); 651 tmp = readb(&ch->ch_neo_uart->isr_fcr);
651 if (tmp & 4) { 652 if (tmp & 4) {
652 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, 653 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev,
653 "Still flushing TX UART... i: %d\n", i); 654 "Still flushing TX UART... i: %d\n", i);
654 udelay(10); 655 udelay(10);
655 } 656 }
656 else 657 else
@@ -681,8 +682,8 @@ static void neo_flush_uart_read(struct jsm_channel *ch)
681 /* Check to see if the UART feels it completely flushed the FIFO. */ 682 /* Check to see if the UART feels it completely flushed the FIFO. */
682 tmp = readb(&ch->ch_neo_uart->isr_fcr); 683 tmp = readb(&ch->ch_neo_uart->isr_fcr);
683 if (tmp & 2) { 684 if (tmp & 2) {
684 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, 685 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev,
685 "Still flushing RX UART... i: %d\n", i); 686 "Still flushing RX UART... i: %d\n", i);
686 udelay(10); 687 udelay(10);
687 } 688 }
688 else 689 else
@@ -705,8 +706,9 @@ static void neo_clear_break(struct jsm_channel *ch, int force)
705 writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr); 706 writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr);
706 707
707 ch->ch_flags &= ~(CH_BREAK_SENDING); 708 ch->ch_flags &= ~(CH_BREAK_SENDING);
708 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, 709 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev,
709 "clear break Finishing UART_LCR_SBC! finished: %lx\n", jiffies); 710 "clear break Finishing UART_LCR_SBC! finished: %lx\n",
711 jiffies);
710 712
711 /* flush write operation */ 713 /* flush write operation */
712 neo_pci_posting_flush(ch->ch_bd); 714 neo_pci_posting_flush(ch->ch_bd);
@@ -748,8 +750,8 @@ static inline void neo_parse_isr(struct jsm_board *brd, u32 port)
748 */ 750 */
749 isr &= ~(UART_17158_IIR_FIFO_ENABLED); 751 isr &= ~(UART_17158_IIR_FIFO_ENABLED);
750 752
751 jsm_printk(INTR, INFO, &ch->ch_bd->pci_dev, 753 jsm_dbg(INTR, &ch->ch_bd->pci_dev, "%s:%d isr: %x\n",
752 "%s:%d isr: %x\n", __FILE__, __LINE__, isr); 754 __FILE__, __LINE__, isr);
753 755
754 if (isr & (UART_17158_IIR_RDI_TIMEOUT | UART_IIR_RDI)) { 756 if (isr & (UART_17158_IIR_RDI_TIMEOUT | UART_IIR_RDI)) {
755 /* Read data from uart -> queue */ 757 /* Read data from uart -> queue */
@@ -772,8 +774,9 @@ static inline void neo_parse_isr(struct jsm_board *brd, u32 port)
772 if (isr & UART_17158_IIR_XONXOFF) { 774 if (isr & UART_17158_IIR_XONXOFF) {
773 cause = readb(&ch->ch_neo_uart->xoffchar1); 775 cause = readb(&ch->ch_neo_uart->xoffchar1);
774 776
775 jsm_printk(INTR, INFO, &ch->ch_bd->pci_dev, 777 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
776 "Port %d. Got ISR_XONXOFF: cause:%x\n", port, cause); 778 "Port %d. Got ISR_XONXOFF: cause:%x\n",
779 port, cause);
777 780
778 /* 781 /*
779 * Since the UART detected either an XON or 782 * Since the UART detected either an XON or
@@ -786,17 +789,19 @@ static inline void neo_parse_isr(struct jsm_board *brd, u32 port)
786 if (brd->channels[port]->ch_flags & CH_STOP) { 789 if (brd->channels[port]->ch_flags & CH_STOP) {
787 ch->ch_flags &= ~(CH_STOP); 790 ch->ch_flags &= ~(CH_STOP);
788 } 791 }
789 jsm_printk(INTR, INFO, &ch->ch_bd->pci_dev, 792 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
790 "Port %d. XON detected in incoming data\n", port); 793 "Port %d. XON detected in incoming data\n",
794 port);
791 } 795 }
792 else if (cause == UART_17158_XOFF_DETECT) { 796 else if (cause == UART_17158_XOFF_DETECT) {
793 if (!(brd->channels[port]->ch_flags & CH_STOP)) { 797 if (!(brd->channels[port]->ch_flags & CH_STOP)) {
794 ch->ch_flags |= CH_STOP; 798 ch->ch_flags |= CH_STOP;
795 jsm_printk(INTR, INFO, &ch->ch_bd->pci_dev, 799 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
796 "Setting CH_STOP\n"); 800 "Setting CH_STOP\n");
797 } 801 }
798 jsm_printk(INTR, INFO, &ch->ch_bd->pci_dev, 802 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
799 "Port: %d. XOFF detected in incoming data\n", port); 803 "Port: %d. XOFF detected in incoming data\n",
804 port);
800 } 805 }
801 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 806 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
802 } 807 }
@@ -825,8 +830,8 @@ static inline void neo_parse_isr(struct jsm_board *brd, u32 port)
825 } 830 }
826 831
827 /* Parse any modem signal changes */ 832 /* Parse any modem signal changes */
828 jsm_printk(INTR, INFO, &ch->ch_bd->pci_dev, 833 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
829 "MOD_STAT: sending to parse_modem_sigs\n"); 834 "MOD_STAT: sending to parse_modem_sigs\n");
830 neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr)); 835 neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
831 } 836 }
832} 837}
@@ -849,8 +854,8 @@ static inline void neo_parse_lsr(struct jsm_board *brd, u32 port)
849 854
850 linestatus = readb(&ch->ch_neo_uart->lsr); 855 linestatus = readb(&ch->ch_neo_uart->lsr);
851 856
852 jsm_printk(INTR, INFO, &ch->ch_bd->pci_dev, 857 jsm_dbg(INTR, &ch->ch_bd->pci_dev, "%s:%d port: %d linestatus: %x\n",
853 "%s:%d port: %d linestatus: %x\n", __FILE__, __LINE__, port, linestatus); 858 __FILE__, __LINE__, port, linestatus);
854 859
855 ch->ch_cached_lsr |= linestatus; 860 ch->ch_cached_lsr |= linestatus;
856 861
@@ -869,7 +874,7 @@ static inline void neo_parse_lsr(struct jsm_board *brd, u32 port)
869 *to do the special RX+LSR read for this FIFO load. 874 *to do the special RX+LSR read for this FIFO load.
870 */ 875 */
871 if (linestatus & UART_17158_RX_FIFO_DATA_ERROR) 876 if (linestatus & UART_17158_RX_FIFO_DATA_ERROR)
872 jsm_printk(INTR, DEBUG, &ch->ch_bd->pci_dev, 877 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
873 "%s:%d Port: %d Got an RX error, need to parse LSR\n", 878 "%s:%d Port: %d Got an RX error, need to parse LSR\n",
874 __FILE__, __LINE__, port); 879 __FILE__, __LINE__, port);
875 880
@@ -880,20 +885,21 @@ static inline void neo_parse_lsr(struct jsm_board *brd, u32 port)
880 885
881 if (linestatus & UART_LSR_PE) { 886 if (linestatus & UART_LSR_PE) {
882 ch->ch_err_parity++; 887 ch->ch_err_parity++;
883 jsm_printk(INTR, DEBUG, &ch->ch_bd->pci_dev, 888 jsm_dbg(INTR, &ch->ch_bd->pci_dev, "%s:%d Port: %d. PAR ERR!\n",
884 "%s:%d Port: %d. PAR ERR!\n", __FILE__, __LINE__, port); 889 __FILE__, __LINE__, port);
885 } 890 }
886 891
887 if (linestatus & UART_LSR_FE) { 892 if (linestatus & UART_LSR_FE) {
888 ch->ch_err_frame++; 893 ch->ch_err_frame++;
889 jsm_printk(INTR, DEBUG, &ch->ch_bd->pci_dev, 894 jsm_dbg(INTR, &ch->ch_bd->pci_dev, "%s:%d Port: %d. FRM ERR!\n",
890 "%s:%d Port: %d. FRM ERR!\n", __FILE__, __LINE__, port); 895 __FILE__, __LINE__, port);
891 } 896 }
892 897
893 if (linestatus & UART_LSR_BI) { 898 if (linestatus & UART_LSR_BI) {
894 ch->ch_err_break++; 899 ch->ch_err_break++;
895 jsm_printk(INTR, DEBUG, &ch->ch_bd->pci_dev, 900 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
896 "%s:%d Port: %d. BRK INTR!\n", __FILE__, __LINE__, port); 901 "%s:%d Port: %d. BRK INTR!\n",
902 __FILE__, __LINE__, port);
897 } 903 }
898 904
899 if (linestatus & UART_LSR_OE) { 905 if (linestatus & UART_LSR_OE) {
@@ -904,8 +910,9 @@ static inline void neo_parse_lsr(struct jsm_board *brd, u32 port)
904 * Probably we should eventually have an orun stat in our driver... 910 * Probably we should eventually have an orun stat in our driver...
905 */ 911 */
906 ch->ch_err_overrun++; 912 ch->ch_err_overrun++;
907 jsm_printk(INTR, DEBUG, &ch->ch_bd->pci_dev, 913 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
908 "%s:%d Port: %d. Rx Overrun!\n", __FILE__, __LINE__, port); 914 "%s:%d Port: %d. Rx Overrun!\n",
915 __FILE__, __LINE__, port);
909 } 916 }
910 917
911 if (linestatus & UART_LSR_THRE) { 918 if (linestatus & UART_LSR_THRE) {
@@ -1128,11 +1135,11 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
1128 */ 1135 */
1129 uart_poll = readl(brd->re_map_membase + UART_17158_POLL_ADDR_OFFSET); 1136 uart_poll = readl(brd->re_map_membase + UART_17158_POLL_ADDR_OFFSET);
1130 1137
1131 jsm_printk(INTR, INFO, &brd->pci_dev, 1138 jsm_dbg(INTR, &brd->pci_dev, "%s:%d uart_poll: %x\n",
1132 "%s:%d uart_poll: %x\n", __FILE__, __LINE__, uart_poll); 1139 __FILE__, __LINE__, uart_poll);
1133 1140
1134 if (!uart_poll) { 1141 if (!uart_poll) {
1135 jsm_printk(INTR, INFO, &brd->pci_dev, 1142 jsm_dbg(INTR, &brd->pci_dev,
1136 "Kernel interrupted to me, but no pending interrupts...\n"); 1143 "Kernel interrupted to me, but no pending interrupts...\n");
1137 spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags); 1144 spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags);
1138 return IRQ_NONE; 1145 return IRQ_NONE;
@@ -1158,15 +1165,15 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
1158 continue; 1165 continue;
1159 } 1166 }
1160 1167
1161 jsm_printk(INTR, INFO, &brd->pci_dev, 1168 jsm_dbg(INTR, &brd->pci_dev, "%s:%d port: %x type: %x\n",
1162 "%s:%d port: %x type: %x\n", __FILE__, __LINE__, port, type); 1169 __FILE__, __LINE__, port, type);
1163 1170
1164 /* Remove this port + type from uart_poll */ 1171 /* Remove this port + type from uart_poll */
1165 uart_poll &= ~(jsm_offset_table[port]); 1172 uart_poll &= ~(jsm_offset_table[port]);
1166 1173
1167 if (!type) { 1174 if (!type) {
1168 /* If no type, just ignore it, and move onto next port */ 1175 /* If no type, just ignore it, and move onto next port */
1169 jsm_printk(INTR, ERR, &brd->pci_dev, 1176 jsm_dbg(INTR, &brd->pci_dev,
1170 "Interrupt with no type! port: %d\n", port); 1177 "Interrupt with no type! port: %d\n", port);
1171 continue; 1178 continue;
1172 } 1179 }
@@ -1231,15 +1238,16 @@ static irqreturn_t neo_intr(int irq, void *voidbrd)
1231 * these once and awhile. 1238 * these once and awhile.
1232 * Its harmless, just ignore it and move on. 1239 * Its harmless, just ignore it and move on.
1233 */ 1240 */
1234 jsm_printk(INTR, ERR, &brd->pci_dev, 1241 jsm_dbg(INTR, &brd->pci_dev,
1235 "%s:%d Unknown Interrupt type: %x\n", __FILE__, __LINE__, type); 1242 "%s:%d Unknown Interrupt type: %x\n",
1243 __FILE__, __LINE__, type);
1236 continue; 1244 continue;
1237 } 1245 }
1238 } 1246 }
1239 1247
1240 spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags); 1248 spin_unlock_irqrestore(&brd->bd_intr_lock, lock_flags);
1241 1249
1242 jsm_printk(INTR, INFO, &brd->pci_dev, "finish.\n"); 1250 jsm_dbg(INTR, &brd->pci_dev, "finish\n");
1243 return IRQ_HANDLED; 1251 return IRQ_HANDLED;
1244} 1252}
1245 1253
diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
index 71397961773..4c00c5550b1 100644
--- a/drivers/tty/serial/jsm/jsm_tty.c
+++ b/drivers/tty/serial/jsm/jsm_tty.c
@@ -43,7 +43,7 @@ static inline int jsm_get_mstat(struct jsm_channel *ch)
43 unsigned char mstat; 43 unsigned char mstat;
44 unsigned result; 44 unsigned result;
45 45
46 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "start\n"); 46 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "start\n");
47 47
48 mstat = (ch->ch_mostat | ch->ch_mistat); 48 mstat = (ch->ch_mostat | ch->ch_mistat);
49 49
@@ -62,7 +62,7 @@ static inline int jsm_get_mstat(struct jsm_channel *ch)
62 if (mstat & UART_MSR_DCD) 62 if (mstat & UART_MSR_DCD)
63 result |= TIOCM_CD; 63 result |= TIOCM_CD;
64 64
65 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n"); 65 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "finish\n");
66 return result; 66 return result;
67} 67}
68 68
@@ -79,14 +79,14 @@ static unsigned int jsm_tty_get_mctrl(struct uart_port *port)
79 int result; 79 int result;
80 struct jsm_channel *channel = (struct jsm_channel *)port; 80 struct jsm_channel *channel = (struct jsm_channel *)port;
81 81
82 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "start\n"); 82 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
83 83
84 result = jsm_get_mstat(channel); 84 result = jsm_get_mstat(channel);
85 85
86 if (result < 0) 86 if (result < 0)
87 return -ENXIO; 87 return -ENXIO;
88 88
89 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "finish\n"); 89 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "finish\n");
90 90
91 return result; 91 return result;
92} 92}
@@ -100,7 +100,7 @@ static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
100{ 100{
101 struct jsm_channel *channel = (struct jsm_channel *)port; 101 struct jsm_channel *channel = (struct jsm_channel *)port;
102 102
103 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "start\n"); 103 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
104 104
105 if (mctrl & TIOCM_RTS) 105 if (mctrl & TIOCM_RTS)
106 channel->ch_mostat |= UART_MCR_RTS; 106 channel->ch_mostat |= UART_MCR_RTS;
@@ -114,7 +114,7 @@ static void jsm_tty_set_mctrl(struct uart_port *port, unsigned int mctrl)
114 114
115 channel->ch_bd->bd_ops->assert_modem_signals(channel); 115 channel->ch_bd->bd_ops->assert_modem_signals(channel);
116 116
117 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "finish\n"); 117 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "finish\n");
118 udelay(10); 118 udelay(10);
119} 119}
120 120
@@ -135,23 +135,23 @@ static void jsm_tty_start_tx(struct uart_port *port)
135{ 135{
136 struct jsm_channel *channel = (struct jsm_channel *)port; 136 struct jsm_channel *channel = (struct jsm_channel *)port;
137 137
138 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "start\n"); 138 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
139 139
140 channel->ch_flags &= ~(CH_STOP); 140 channel->ch_flags &= ~(CH_STOP);
141 jsm_tty_write(port); 141 jsm_tty_write(port);
142 142
143 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "finish\n"); 143 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "finish\n");
144} 144}
145 145
146static void jsm_tty_stop_tx(struct uart_port *port) 146static void jsm_tty_stop_tx(struct uart_port *port)
147{ 147{
148 struct jsm_channel *channel = (struct jsm_channel *)port; 148 struct jsm_channel *channel = (struct jsm_channel *)port;
149 149
150 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "start\n"); 150 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "start\n");
151 151
152 channel->ch_flags |= (CH_STOP); 152 channel->ch_flags |= (CH_STOP);
153 153
154 jsm_printk(IOCTL, INFO, &channel->ch_bd->pci_dev, "finish\n"); 154 jsm_dbg(IOCTL, &channel->ch_bd->pci_dev, "finish\n");
155} 155}
156 156
157static void jsm_tty_send_xchar(struct uart_port *port, char ch) 157static void jsm_tty_send_xchar(struct uart_port *port, char ch)
@@ -216,16 +216,16 @@ static int jsm_tty_open(struct uart_port *port)
216 if (!channel->ch_rqueue) { 216 if (!channel->ch_rqueue) {
217 channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); 217 channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
218 if (!channel->ch_rqueue) { 218 if (!channel->ch_rqueue) {
219 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, 219 jsm_dbg(INIT, &channel->ch_bd->pci_dev,
220 "unable to allocate read queue buf"); 220 "unable to allocate read queue buf\n");
221 return -ENOMEM; 221 return -ENOMEM;
222 } 222 }
223 } 223 }
224 if (!channel->ch_equeue) { 224 if (!channel->ch_equeue) {
225 channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL); 225 channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
226 if (!channel->ch_equeue) { 226 if (!channel->ch_equeue) {
227 jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev, 227 jsm_dbg(INIT, &channel->ch_bd->pci_dev,
228 "unable to allocate error queue buf"); 228 "unable to allocate error queue buf\n");
229 return -ENOMEM; 229 return -ENOMEM;
230 } 230 }
231 } 231 }
@@ -234,7 +234,7 @@ static int jsm_tty_open(struct uart_port *port)
234 /* 234 /*
235 * Initialize if neither terminal is open. 235 * Initialize if neither terminal is open.
236 */ 236 */
237 jsm_printk(OPEN, INFO, &channel->ch_bd->pci_dev, 237 jsm_dbg(OPEN, &channel->ch_bd->pci_dev,
238 "jsm_open: initializing channel in open...\n"); 238 "jsm_open: initializing channel in open...\n");
239 239
240 /* 240 /*
@@ -270,7 +270,7 @@ static int jsm_tty_open(struct uart_port *port)
270 270
271 channel->ch_open_count++; 271 channel->ch_open_count++;
272 272
273 jsm_printk(OPEN, INFO, &channel->ch_bd->pci_dev, "finish\n"); 273 jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
274 return 0; 274 return 0;
275} 275}
276 276
@@ -280,7 +280,7 @@ static void jsm_tty_close(struct uart_port *port)
280 struct ktermios *ts; 280 struct ktermios *ts;
281 struct jsm_channel *channel = (struct jsm_channel *)port; 281 struct jsm_channel *channel = (struct jsm_channel *)port;
282 282
283 jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "start\n"); 283 jsm_dbg(CLOSE, &channel->ch_bd->pci_dev, "start\n");
284 284
285 bd = channel->ch_bd; 285 bd = channel->ch_bd;
286 ts = &port->state->port.tty->termios; 286 ts = &port->state->port.tty->termios;
@@ -293,7 +293,7 @@ static void jsm_tty_close(struct uart_port *port)
293 * If we have HUPCL set, lower DTR and RTS 293 * If we have HUPCL set, lower DTR and RTS
294 */ 294 */
295 if (channel->ch_c_cflag & HUPCL) { 295 if (channel->ch_c_cflag & HUPCL) {
296 jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, 296 jsm_dbg(CLOSE, &channel->ch_bd->pci_dev,
297 "Close. HUPCL set, dropping DTR/RTS\n"); 297 "Close. HUPCL set, dropping DTR/RTS\n");
298 298
299 /* Drop RTS/DTR */ 299 /* Drop RTS/DTR */
@@ -304,7 +304,7 @@ static void jsm_tty_close(struct uart_port *port)
304 /* Turn off UART interrupts for this port */ 304 /* Turn off UART interrupts for this port */
305 channel->ch_bd->bd_ops->uart_off(channel); 305 channel->ch_bd->bd_ops->uart_off(channel);
306 306
307 jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "finish\n"); 307 jsm_dbg(CLOSE, &channel->ch_bd->pci_dev, "finish\n");
308} 308}
309 309
310static void jsm_tty_set_termios(struct uart_port *port, 310static void jsm_tty_set_termios(struct uart_port *port,
@@ -371,7 +371,7 @@ static struct uart_ops jsm_ops = {
371 * Init the tty subsystem. Called once per board after board has been 371 * Init the tty subsystem. Called once per board after board has been
372 * downloaded and init'ed. 372 * downloaded and init'ed.
373 */ 373 */
374int __devinit jsm_tty_init(struct jsm_board *brd) 374int jsm_tty_init(struct jsm_board *brd)
375{ 375{
376 int i; 376 int i;
377 void __iomem *vaddr; 377 void __iomem *vaddr;
@@ -380,7 +380,7 @@ int __devinit jsm_tty_init(struct jsm_board *brd)
380 if (!brd) 380 if (!brd)
381 return -ENXIO; 381 return -ENXIO;
382 382
383 jsm_printk(INIT, INFO, &brd->pci_dev, "start\n"); 383 jsm_dbg(INIT, &brd->pci_dev, "start\n");
384 384
385 /* 385 /*
386 * Initialize board structure elements. 386 * Initialize board structure elements.
@@ -401,9 +401,9 @@ int __devinit jsm_tty_init(struct jsm_board *brd)
401 */ 401 */
402 brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL); 402 brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL);
403 if (!brd->channels[i]) { 403 if (!brd->channels[i]) {
404 jsm_printk(CORE, ERR, &brd->pci_dev, 404 jsm_dbg(CORE, &brd->pci_dev,
405 "%s:%d Unable to allocate memory for channel struct\n", 405 "%s:%d Unable to allocate memory for channel struct\n",
406 __FILE__, __LINE__); 406 __FILE__, __LINE__);
407 } 407 }
408 } 408 }
409 } 409 }
@@ -431,7 +431,7 @@ int __devinit jsm_tty_init(struct jsm_board *brd)
431 init_waitqueue_head(&ch->ch_flags_wait); 431 init_waitqueue_head(&ch->ch_flags_wait);
432 } 432 }
433 433
434 jsm_printk(INIT, INFO, &brd->pci_dev, "finish\n"); 434 jsm_dbg(INIT, &brd->pci_dev, "finish\n");
435 return 0; 435 return 0;
436} 436}
437 437
@@ -444,7 +444,7 @@ int jsm_uart_port_init(struct jsm_board *brd)
444 if (!brd) 444 if (!brd)
445 return -ENXIO; 445 return -ENXIO;
446 446
447 jsm_printk(INIT, INFO, &brd->pci_dev, "start\n"); 447 jsm_dbg(INIT, &brd->pci_dev, "start\n");
448 448
449 /* 449 /*
450 * Initialize board structure elements. 450 * Initialize board structure elements.
@@ -481,7 +481,7 @@ int jsm_uart_port_init(struct jsm_board *brd)
481 printk(KERN_INFO "jsm: Port %d added\n", i); 481 printk(KERN_INFO "jsm: Port %d added\n", i);
482 } 482 }
483 483
484 jsm_printk(INIT, INFO, &brd->pci_dev, "finish\n"); 484 jsm_dbg(INIT, &brd->pci_dev, "finish\n");
485 return 0; 485 return 0;
486} 486}
487 487
@@ -493,7 +493,7 @@ int jsm_remove_uart_port(struct jsm_board *brd)
493 if (!brd) 493 if (!brd)
494 return -ENXIO; 494 return -ENXIO;
495 495
496 jsm_printk(INIT, INFO, &brd->pci_dev, "start\n"); 496 jsm_dbg(INIT, &brd->pci_dev, "start\n");
497 497
498 /* 498 /*
499 * Initialize board structure elements. 499 * Initialize board structure elements.
@@ -513,7 +513,7 @@ int jsm_remove_uart_port(struct jsm_board *brd)
513 uart_remove_one_port(&jsm_uart_driver, &brd->channels[i]->uart_port); 513 uart_remove_one_port(&jsm_uart_driver, &brd->channels[i]->uart_port);
514 } 514 }
515 515
516 jsm_printk(INIT, INFO, &brd->pci_dev, "finish\n"); 516 jsm_dbg(INIT, &brd->pci_dev, "finish\n");
517 return 0; 517 return 0;
518} 518}
519 519
@@ -531,7 +531,7 @@ void jsm_input(struct jsm_channel *ch)
531 int s = 0; 531 int s = 0;
532 int i = 0; 532 int i = 0;
533 533
534 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "start\n"); 534 jsm_dbg(READ, &ch->ch_bd->pci_dev, "start\n");
535 535
536 if (!ch) 536 if (!ch)
537 return; 537 return;
@@ -560,7 +560,7 @@ void jsm_input(struct jsm_channel *ch)
560 return; 560 return;
561 } 561 }
562 562
563 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "start\n"); 563 jsm_dbg(READ, &ch->ch_bd->pci_dev, "start\n");
564 564
565 /* 565 /*
566 *If the device is not open, or CREAD is off, flush 566 *If the device is not open, or CREAD is off, flush
@@ -569,8 +569,9 @@ void jsm_input(struct jsm_channel *ch)
569 if (!tp || 569 if (!tp ||
570 !(tp->termios.c_cflag & CREAD) ) { 570 !(tp->termios.c_cflag & CREAD) ) {
571 571
572 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 572 jsm_dbg(READ, &ch->ch_bd->pci_dev,
573 "input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum); 573 "input. dropping %d bytes on port %d...\n",
574 data_len, ch->ch_portnum);
574 ch->ch_r_head = tail; 575 ch->ch_r_head = tail;
575 576
576 /* Force queue flow control to be released, if needed */ 577 /* Force queue flow control to be released, if needed */
@@ -585,17 +586,17 @@ void jsm_input(struct jsm_channel *ch)
585 */ 586 */
586 if (ch->ch_flags & CH_STOPI) { 587 if (ch->ch_flags & CH_STOPI) {
587 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 588 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
588 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 589 jsm_dbg(READ, &ch->ch_bd->pci_dev,
589 "Port %d throttled, not reading any data. head: %x tail: %x\n", 590 "Port %d throttled, not reading any data. head: %x tail: %x\n",
590 ch->ch_portnum, head, tail); 591 ch->ch_portnum, head, tail);
591 return; 592 return;
592 } 593 }
593 594
594 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "start 2\n"); 595 jsm_dbg(READ, &ch->ch_bd->pci_dev, "start 2\n");
595 596
596 if (data_len <= 0) { 597 if (data_len <= 0) {
597 spin_unlock_irqrestore(&ch->ch_lock, lock_flags); 598 spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
598 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "jsm_input 1\n"); 599 jsm_dbg(READ, &ch->ch_bd->pci_dev, "jsm_input 1\n");
599 return; 600 return;
600 } 601 }
601 602
@@ -653,7 +654,7 @@ void jsm_input(struct jsm_channel *ch)
653 /* Tell the tty layer its okay to "eat" the data now */ 654 /* Tell the tty layer its okay to "eat" the data now */
654 tty_flip_buffer_push(tp); 655 tty_flip_buffer_push(tp);
655 656
656 jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n"); 657 jsm_dbg(IOCTL, &ch->ch_bd->pci_dev, "finish\n");
657} 658}
658 659
659static void jsm_carrier(struct jsm_channel *ch) 660static void jsm_carrier(struct jsm_channel *ch)
@@ -663,7 +664,7 @@ static void jsm_carrier(struct jsm_channel *ch)
663 int virt_carrier = 0; 664 int virt_carrier = 0;
664 int phys_carrier = 0; 665 int phys_carrier = 0;
665 666
666 jsm_printk(CARR, INFO, &ch->ch_bd->pci_dev, "start\n"); 667 jsm_dbg(CARR, &ch->ch_bd->pci_dev, "start\n");
667 if (!ch) 668 if (!ch)
668 return; 669 return;
669 670
@@ -673,16 +674,16 @@ static void jsm_carrier(struct jsm_channel *ch)
673 return; 674 return;
674 675
675 if (ch->ch_mistat & UART_MSR_DCD) { 676 if (ch->ch_mistat & UART_MSR_DCD) {
676 jsm_printk(CARR, INFO, &ch->ch_bd->pci_dev, 677 jsm_dbg(CARR, &ch->ch_bd->pci_dev, "mistat: %x D_CD: %x\n",
677 "mistat: %x D_CD: %x\n", ch->ch_mistat, ch->ch_mistat & UART_MSR_DCD); 678 ch->ch_mistat, ch->ch_mistat & UART_MSR_DCD);
678 phys_carrier = 1; 679 phys_carrier = 1;
679 } 680 }
680 681
681 if (ch->ch_c_cflag & CLOCAL) 682 if (ch->ch_c_cflag & CLOCAL)
682 virt_carrier = 1; 683 virt_carrier = 1;
683 684
684 jsm_printk(CARR, INFO, &ch->ch_bd->pci_dev, 685 jsm_dbg(CARR, &ch->ch_bd->pci_dev, "DCD: physical: %d virt: %d\n",
685 "DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier); 686 phys_carrier, virt_carrier);
686 687
687 /* 688 /*
688 * Test for a VIRTUAL carrier transition to HIGH. 689 * Test for a VIRTUAL carrier transition to HIGH.
@@ -694,8 +695,7 @@ static void jsm_carrier(struct jsm_channel *ch)
694 * for carrier in the open routine. 695 * for carrier in the open routine.
695 */ 696 */
696 697
697 jsm_printk(CARR, INFO, &ch->ch_bd->pci_dev, 698 jsm_dbg(CARR, &ch->ch_bd->pci_dev, "carrier: virt DCD rose\n");
698 "carrier: virt DCD rose\n");
699 699
700 if (waitqueue_active(&(ch->ch_flags_wait))) 700 if (waitqueue_active(&(ch->ch_flags_wait)))
701 wake_up_interruptible(&ch->ch_flags_wait); 701 wake_up_interruptible(&ch->ch_flags_wait);
@@ -711,7 +711,7 @@ static void jsm_carrier(struct jsm_channel *ch)
711 * for carrier in the open routine. 711 * for carrier in the open routine.
712 */ 712 */
713 713
714 jsm_printk(CARR, INFO, &ch->ch_bd->pci_dev, 714 jsm_dbg(CARR, &ch->ch_bd->pci_dev,
715 "carrier: physical DCD rose\n"); 715 "carrier: physical DCD rose\n");
716 716
717 if (waitqueue_active(&(ch->ch_flags_wait))) 717 if (waitqueue_active(&(ch->ch_flags_wait)))
@@ -790,8 +790,8 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
790 if(!(ch->ch_flags & CH_RECEIVER_OFF)) { 790 if(!(ch->ch_flags & CH_RECEIVER_OFF)) {
791 bd_ops->disable_receiver(ch); 791 bd_ops->disable_receiver(ch);
792 ch->ch_flags |= (CH_RECEIVER_OFF); 792 ch->ch_flags |= (CH_RECEIVER_OFF);
793 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 793 jsm_dbg(READ, &ch->ch_bd->pci_dev,
794 "Internal queue hit hilevel mark (%d)! Turning off interrupts.\n", 794 "Internal queue hit hilevel mark (%d)! Turning off interrupts\n",
795 qleft); 795 qleft);
796 } 796 }
797 } 797 }
@@ -800,8 +800,9 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
800 if (ch->ch_stops_sent <= MAX_STOPS_SENT) { 800 if (ch->ch_stops_sent <= MAX_STOPS_SENT) {
801 bd_ops->send_stop_character(ch); 801 bd_ops->send_stop_character(ch);
802 ch->ch_stops_sent++; 802 ch->ch_stops_sent++;
803 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 803 jsm_dbg(READ, &ch->ch_bd->pci_dev,
804 "Sending stop char! Times sent: %x\n", ch->ch_stops_sent); 804 "Sending stop char! Times sent: %x\n",
805 ch->ch_stops_sent);
805 } 806 }
806 } 807 }
807 } 808 }
@@ -827,8 +828,8 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
827 if (ch->ch_flags & CH_RECEIVER_OFF) { 828 if (ch->ch_flags & CH_RECEIVER_OFF) {
828 bd_ops->enable_receiver(ch); 829 bd_ops->enable_receiver(ch);
829 ch->ch_flags &= ~(CH_RECEIVER_OFF); 830 ch->ch_flags &= ~(CH_RECEIVER_OFF);
830 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, 831 jsm_dbg(READ, &ch->ch_bd->pci_dev,
831 "Internal queue hit lowlevel mark (%d)! Turning on interrupts.\n", 832 "Internal queue hit lowlevel mark (%d)! Turning on interrupts\n",
832 qleft); 833 qleft);
833 } 834 }
834 } 835 }
@@ -836,7 +837,8 @@ void jsm_check_queue_flow_control(struct jsm_channel *ch)
836 else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) { 837 else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) {
837 ch->ch_stops_sent = 0; 838 ch->ch_stops_sent = 0;
838 bd_ops->send_start_character(ch); 839 bd_ops->send_start_character(ch);
839 jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "Sending start char!\n"); 840 jsm_dbg(READ, &ch->ch_bd->pci_dev,
841 "Sending start char!\n");
840 } 842 }
841 } 843 }
842} 844}
diff --git a/drivers/tty/serial/kgdb_nmi.c b/drivers/tty/serial/kgdb_nmi.c
index d185247ba1a..6ac2b797a76 100644
--- a/drivers/tty/serial/kgdb_nmi.c
+++ b/drivers/tty/serial/kgdb_nmi.c
@@ -266,6 +266,7 @@ static int kgdb_nmi_tty_install(struct tty_driver *drv, struct tty_struct *tty)
266 } 266 }
267 return 0; 267 return 0;
268err: 268err:
269 tty_port_destroy(&priv->port);
269 kfree(priv); 270 kfree(priv);
270 return ret; 271 return ret;
271} 272}
@@ -275,6 +276,7 @@ static void kgdb_nmi_tty_cleanup(struct tty_struct *tty)
275 struct kgdb_nmi_tty_priv *priv = tty->driver_data; 276 struct kgdb_nmi_tty_priv *priv = tty->driver_data;
276 277
277 tty->driver_data = NULL; 278 tty->driver_data = NULL;
279 tty_port_destroy(&priv->port);
278 kfree(priv); 280 kfree(priv);
279} 281}
280 282
diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c
index ba3af3bf6d4..0e86bff3fe2 100644
--- a/drivers/tty/serial/lpc32xx_hs.c
+++ b/drivers/tty/serial/lpc32xx_hs.c
@@ -686,7 +686,7 @@ static struct uart_ops serial_lpc32xx_pops = {
686/* 686/*
687 * Register a set of serial devices attached to a platform device 687 * Register a set of serial devices attached to a platform device
688 */ 688 */
689static int __devinit serial_hs_lpc32xx_probe(struct platform_device *pdev) 689static int serial_hs_lpc32xx_probe(struct platform_device *pdev)
690{ 690{
691 struct lpc32xx_hsuart_port *p = &lpc32xx_hs_ports[uarts_registered]; 691 struct lpc32xx_hsuart_port *p = &lpc32xx_hs_ports[uarts_registered];
692 int ret = 0; 692 int ret = 0;
@@ -740,7 +740,7 @@ static int __devinit serial_hs_lpc32xx_probe(struct platform_device *pdev)
740/* 740/*
741 * Remove serial ports registered against a platform device. 741 * Remove serial ports registered against a platform device.
742 */ 742 */
743static int __devexit serial_hs_lpc32xx_remove(struct platform_device *pdev) 743static int serial_hs_lpc32xx_remove(struct platform_device *pdev)
744{ 744{
745 struct lpc32xx_hsuart_port *p = platform_get_drvdata(pdev); 745 struct lpc32xx_hsuart_port *p = platform_get_drvdata(pdev);
746 746
@@ -783,7 +783,7 @@ MODULE_DEVICE_TABLE(of, serial_hs_lpc32xx_dt_ids);
783 783
784static struct platform_driver serial_hs_lpc32xx_driver = { 784static struct platform_driver serial_hs_lpc32xx_driver = {
785 .probe = serial_hs_lpc32xx_probe, 785 .probe = serial_hs_lpc32xx_probe,
786 .remove = __devexit_p(serial_hs_lpc32xx_remove), 786 .remove = serial_hs_lpc32xx_remove,
787 .suspend = serial_hs_lpc32xx_suspend, 787 .suspend = serial_hs_lpc32xx_suspend,
788 .resume = serial_hs_lpc32xx_resume, 788 .resume = serial_hs_lpc32xx_resume,
789 .driver = { 789 .driver = {
diff --git a/drivers/tty/serial/max3100.c b/drivers/tty/serial/max3100.c
index 0f24486be53..7ce3197087b 100644
--- a/drivers/tty/serial/max3100.c
+++ b/drivers/tty/serial/max3100.c
@@ -742,7 +742,7 @@ static struct uart_driver max3100_uart_driver = {
742}; 742};
743static int uart_driver_registered; 743static int uart_driver_registered;
744 744
745static int __devinit max3100_probe(struct spi_device *spi) 745static int max3100_probe(struct spi_device *spi)
746{ 746{
747 int i, retval; 747 int i, retval;
748 struct plat_max3100 *pdata; 748 struct plat_max3100 *pdata;
@@ -818,7 +818,7 @@ static int __devinit max3100_probe(struct spi_device *spi)
818 return 0; 818 return 0;
819} 819}
820 820
821static int __devexit max3100_remove(struct spi_device *spi) 821static int max3100_remove(struct spi_device *spi)
822{ 822{
823 struct max3100_port *s = dev_get_drvdata(&spi->dev); 823 struct max3100_port *s = dev_get_drvdata(&spi->dev);
824 int i; 824 int i;
@@ -907,7 +907,7 @@ static struct spi_driver max3100_driver = {
907 }, 907 },
908 908
909 .probe = max3100_probe, 909 .probe = max3100_probe,
910 .remove = __devexit_p(max3100_remove), 910 .remove = max3100_remove,
911 .suspend = max3100_suspend, 911 .suspend = max3100_suspend,
912 .resume = max3100_resume, 912 .resume = max3100_resume,
913}; 913};
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 1ab1d2c66de..a801f6872ca 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -378,7 +378,7 @@ static void max310x_wait_pll(struct max310x_port *s)
378 } 378 }
379} 379}
380 380
381static int __devinit max310x_update_best_err(unsigned long f, long *besterr) 381static int max310x_update_best_err(unsigned long f, long *besterr)
382{ 382{
383 /* Use baudrate 115200 for calculate error */ 383 /* Use baudrate 115200 for calculate error */
384 long err = f % (115200 * 16); 384 long err = f % (115200 * 16);
@@ -391,7 +391,7 @@ static int __devinit max310x_update_best_err(unsigned long f, long *besterr)
391 return 1; 391 return 1;
392} 392}
393 393
394static int __devinit max310x_set_ref_clk(struct max310x_port *s) 394static int max310x_set_ref_clk(struct max310x_port *s)
395{ 395{
396 unsigned int div, clksrc, pllcfg = 0; 396 unsigned int div, clksrc, pllcfg = 0;
397 long besterr = -1; 397 long besterr = -1;
@@ -995,7 +995,7 @@ static struct max310x_pdata generic_plat_data = {
995 .frequency = 26000000, 995 .frequency = 26000000,
996}; 996};
997 997
998static int __devinit max310x_probe(struct spi_device *spi) 998static int max310x_probe(struct spi_device *spi)
999{ 999{
1000 struct max310x_port *s; 1000 struct max310x_port *s;
1001 struct device *dev = &spi->dev; 1001 struct device *dev = &spi->dev;
@@ -1178,6 +1178,7 @@ static int __devinit max310x_probe(struct spi_device *spi)
1178 s->gpio.set = max310x_gpio_set; 1178 s->gpio.set = max310x_gpio_set;
1179 s->gpio.base = pdata->gpio_base; 1179 s->gpio.base = pdata->gpio_base;
1180 s->gpio.ngpio = s->nr_gpio; 1180 s->gpio.ngpio = s->nr_gpio;
1181 s->gpio.can_sleep = 1;
1181 if (gpiochip_add(&s->gpio)) { 1182 if (gpiochip_add(&s->gpio)) {
1182 /* Indicate that we should not call gpiochip_remove */ 1183 /* Indicate that we should not call gpiochip_remove */
1183 s->gpio.base = 0; 1184 s->gpio.base = 0;
@@ -1202,7 +1203,7 @@ err_out:
1202 return ret; 1203 return ret;
1203} 1204}
1204 1205
1205static int __devexit max310x_remove(struct spi_device *spi) 1206static int max310x_remove(struct spi_device *spi)
1206{ 1207{
1207 struct device *dev = &spi->dev; 1208 struct device *dev = &spi->dev;
1208 struct max310x_port *s = dev_get_drvdata(dev); 1209 struct max310x_port *s = dev_get_drvdata(dev);
@@ -1249,7 +1250,7 @@ static struct spi_driver max310x_driver = {
1249 .owner = THIS_MODULE, 1250 .owner = THIS_MODULE,
1250 }, 1251 },
1251 .probe = max310x_probe, 1252 .probe = max310x_probe,
1252 .remove = __devexit_p(max310x_remove), 1253 .remove = max310x_remove,
1253 .suspend = max310x_suspend, 1254 .suspend = max310x_suspend,
1254 .resume = max310x_resume, 1255 .resume = max310x_resume,
1255 .id_table = max310x_id_table, 1256 .id_table = max310x_id_table,
diff --git a/drivers/tty/serial/mcf.c b/drivers/tty/serial/mcf.c
index 9afca093d6e..fcd56ab6053 100644
--- a/drivers/tty/serial/mcf.c
+++ b/drivers/tty/serial/mcf.c
@@ -571,7 +571,7 @@ static struct uart_driver mcf_driver = {
571 571
572/****************************************************************************/ 572/****************************************************************************/
573 573
574static int __devinit mcf_probe(struct platform_device *pdev) 574static int mcf_probe(struct platform_device *pdev)
575{ 575{
576 struct mcf_platform_uart *platp = pdev->dev.platform_data; 576 struct mcf_platform_uart *platp = pdev->dev.platform_data;
577 struct uart_port *port; 577 struct uart_port *port;
@@ -599,7 +599,7 @@ static int __devinit mcf_probe(struct platform_device *pdev)
599 599
600/****************************************************************************/ 600/****************************************************************************/
601 601
602static int __devexit mcf_remove(struct platform_device *pdev) 602static int mcf_remove(struct platform_device *pdev)
603{ 603{
604 struct uart_port *port; 604 struct uart_port *port;
605 int i; 605 int i;
@@ -617,7 +617,7 @@ static int __devexit mcf_remove(struct platform_device *pdev)
617 617
618static struct platform_driver mcf_platform_driver = { 618static struct platform_driver mcf_platform_driver = {
619 .probe = mcf_probe, 619 .probe = mcf_probe,
620 .remove = __devexit_p(mcf_remove), 620 .remove = mcf_remove,
621 .driver = { 621 .driver = {
622 .name = "mcfuart", 622 .name = "mcfuart",
623 .owner = THIS_MODULE, 623 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c
index c4b50af46c4..2c01344dc33 100644
--- a/drivers/tty/serial/mfd.c
+++ b/drivers/tty/serial/mfd.c
@@ -36,6 +36,7 @@
36#include <linux/serial_mfd.h> 36#include <linux/serial_mfd.h>
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/nmi.h>
39#include <linux/io.h> 40#include <linux/io.h>
40#include <linux/debugfs.h> 41#include <linux/debugfs.h>
41#include <linux/pm_runtime.h> 42#include <linux/pm_runtime.h>
@@ -1113,6 +1114,8 @@ serial_hsu_console_write(struct console *co, const char *s, unsigned int count)
1113 unsigned int ier; 1114 unsigned int ier;
1114 int locked = 1; 1115 int locked = 1;
1115 1116
1117 touch_nmi_watchdog();
1118
1116 local_irq_save(flags); 1119 local_irq_save(flags);
1117 if (up->port.sysrq) 1120 if (up->port.sysrq)
1118 locked = 0; 1121 locked = 0;
@@ -1456,7 +1459,7 @@ static void serial_hsu_remove(struct pci_dev *pdev)
1456} 1459}
1457 1460
1458/* First 3 are UART ports, and the 4th is the DMA */ 1461/* First 3 are UART ports, and the 4th is the DMA */
1459static const struct pci_device_id pci_ids[] __devinitconst = { 1462static const struct pci_device_id pci_ids[] = {
1460 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x081B) }, 1463 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x081B) },
1461 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x081C) }, 1464 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x081C) },
1462 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x081D) }, 1465 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x081D) },
@@ -1468,7 +1471,7 @@ static struct pci_driver hsu_pci_driver = {
1468 .name = "HSU serial", 1471 .name = "HSU serial",
1469 .id_table = pci_ids, 1472 .id_table = pci_ids,
1470 .probe = serial_hsu_probe, 1473 .probe = serial_hsu_probe,
1471 .remove = __devexit_p(serial_hsu_remove), 1474 .remove = serial_hsu_remove,
1472 .suspend = serial_hsu_suspend, 1475 .suspend = serial_hsu_suspend,
1473 .resume = serial_hsu_resume, 1476 .resume = serial_hsu_resume,
1474 .driver = { 1477 .driver = {
diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c
index 8cf577008ad..7c23c4f4c58 100644
--- a/drivers/tty/serial/mpc52xx_uart.c
+++ b/drivers/tty/serial/mpc52xx_uart.c
@@ -1308,7 +1308,7 @@ static struct of_device_id mpc52xx_uart_of_match[] = {
1308 {}, 1308 {},
1309}; 1309};
1310 1310
1311static int __devinit mpc52xx_uart_of_probe(struct platform_device *op) 1311static int mpc52xx_uart_of_probe(struct platform_device *op)
1312{ 1312{
1313 int idx = -1; 1313 int idx = -1;
1314 unsigned int uartclk; 1314 unsigned int uartclk;
diff --git a/drivers/tty/serial/mrst_max3110.c b/drivers/tty/serial/mrst_max3110.c
index df2a2240a3a..58734d7e746 100644
--- a/drivers/tty/serial/mrst_max3110.c
+++ b/drivers/tty/serial/mrst_max3110.c
@@ -773,7 +773,7 @@ static int serial_m3110_resume(struct spi_device *spi)
773#define serial_m3110_resume NULL 773#define serial_m3110_resume NULL
774#endif 774#endif
775 775
776static int __devinit serial_m3110_probe(struct spi_device *spi) 776static int serial_m3110_probe(struct spi_device *spi)
777{ 777{
778 struct uart_max3110 *max; 778 struct uart_max3110 *max;
779 void *buffer; 779 void *buffer;
@@ -855,7 +855,7 @@ err_get_page:
855 return ret; 855 return ret;
856} 856}
857 857
858static int __devexit serial_m3110_remove(struct spi_device *dev) 858static int serial_m3110_remove(struct spi_device *dev)
859{ 859{
860 struct uart_max3110 *max = spi_get_drvdata(dev); 860 struct uart_max3110 *max = spi_get_drvdata(dev);
861 861
@@ -879,7 +879,7 @@ static struct spi_driver uart_max3110_driver = {
879 .owner = THIS_MODULE, 879 .owner = THIS_MODULE,
880 }, 880 },
881 .probe = serial_m3110_probe, 881 .probe = serial_m3110_probe,
882 .remove = __devexit_p(serial_m3110_remove), 882 .remove = serial_m3110_remove,
883 .suspend = serial_m3110_suspend, 883 .suspend = serial_m3110_suspend,
884 .resume = serial_m3110_resume, 884 .resume = serial_m3110_resume,
885}; 885};
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 033e0bc9eba..95fd39be293 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -917,7 +917,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
917 return uart_add_one_port(&msm_uart_driver, port); 917 return uart_add_one_port(&msm_uart_driver, port);
918} 918}
919 919
920static int __devexit msm_serial_remove(struct platform_device *pdev) 920static int msm_serial_remove(struct platform_device *pdev)
921{ 921{
922 struct msm_port *msm_port = platform_get_drvdata(pdev); 922 struct msm_port *msm_port = platform_get_drvdata(pdev);
923 923
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c
index fca13dc73e2..1fa92284ade 100644
--- a/drivers/tty/serial/msm_serial_hs.c
+++ b/drivers/tty/serial/msm_serial_hs.c
@@ -401,7 +401,7 @@ static int msm_hs_request_port(struct uart_port *port)
401 return 0; 401 return 0;
402} 402}
403 403
404static int __devexit msm_hs_remove(struct platform_device *pdev) 404static int msm_hs_remove(struct platform_device *pdev)
405{ 405{
406 406
407 struct msm_hs_port *msm_uport; 407 struct msm_hs_port *msm_uport;
@@ -1521,7 +1521,7 @@ err_msm_hs_init_clk:
1521} 1521}
1522 1522
1523/* Initialize tx and rx data structures */ 1523/* Initialize tx and rx data structures */
1524static int __devinit uartdm_init_port(struct uart_port *uport) 1524static int uartdm_init_port(struct uart_port *uport)
1525{ 1525{
1526 int ret = 0; 1526 int ret = 0;
1527 struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport); 1527 struct msm_hs_port *msm_uport = UARTDM_TO_MSM(uport);
@@ -1614,7 +1614,7 @@ err_tx_command_ptr_ptr:
1614 return ret; 1614 return ret;
1615} 1615}
1616 1616
1617static int __devinit msm_hs_probe(struct platform_device *pdev) 1617static int msm_hs_probe(struct platform_device *pdev)
1618{ 1618{
1619 int ret; 1619 int ret;
1620 struct uart_port *uport; 1620 struct uart_port *uport;
@@ -1838,7 +1838,7 @@ static const struct dev_pm_ops msm_hs_dev_pm_ops = {
1838 1838
1839static struct platform_driver msm_serial_hs_platform_driver = { 1839static struct platform_driver msm_serial_hs_platform_driver = {
1840 .probe = msm_hs_probe, 1840 .probe = msm_hs_probe,
1841 .remove = __devexit_p(msm_hs_remove), 1841 .remove = msm_hs_remove,
1842 .driver = { 1842 .driver = {
1843 .name = "msm_serial_hs", 1843 .name = "msm_serial_hs",
1844 .owner = THIS_MODULE, 1844 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c
index 7ea8a263fd9..e2775b6df5a 100644
--- a/drivers/tty/serial/mux.c
+++ b/drivers/tty/serial/mux.c
@@ -520,7 +520,7 @@ static int __init mux_probe(struct parisc_device *dev)
520 return 0; 520 return 0;
521} 521}
522 522
523static int __devexit mux_remove(struct parisc_device *dev) 523static int mux_remove(struct parisc_device *dev)
524{ 524{
525 int i, j; 525 int i, j;
526 int port_count = (long)dev_get_drvdata(&dev->dev); 526 int port_count = (long)dev_get_drvdata(&dev->dev);
@@ -571,14 +571,14 @@ static struct parisc_driver builtin_serial_mux_driver = {
571 .name = "builtin_serial_mux", 571 .name = "builtin_serial_mux",
572 .id_table = builtin_mux_tbl, 572 .id_table = builtin_mux_tbl,
573 .probe = mux_probe, 573 .probe = mux_probe,
574 .remove = __devexit_p(mux_remove), 574 .remove = mux_remove,
575}; 575};
576 576
577static struct parisc_driver serial_mux_driver = { 577static struct parisc_driver serial_mux_driver = {
578 .name = "serial_mux", 578 .name = "serial_mux",
579 .id_table = mux_tbl, 579 .id_table = mux_tbl,
580 .probe = mux_probe, 580 .probe = mux_probe,
581 .remove = __devexit_p(mux_remove), 581 .remove = mux_remove,
582}; 582};
583 583
584/** 584/**
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 6db3baa39a9..6db23b035ef 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -34,6 +34,8 @@
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/pinctrl/consumer.h> 35#include <linux/pinctrl/consumer.h>
36#include <linux/of_device.h> 36#include <linux/of_device.h>
37#include <linux/dma-mapping.h>
38#include <linux/fsl/mxs-dma.h>
37 39
38#include <asm/cacheflush.h> 40#include <asm/cacheflush.h>
39 41
@@ -71,6 +73,15 @@
71 73
72#define AUART_CTRL0_SFTRST (1 << 31) 74#define AUART_CTRL0_SFTRST (1 << 31)
73#define AUART_CTRL0_CLKGATE (1 << 30) 75#define AUART_CTRL0_CLKGATE (1 << 30)
76#define AUART_CTRL0_RXTO_ENABLE (1 << 27)
77#define AUART_CTRL0_RXTIMEOUT(v) (((v) & 0x7ff) << 16)
78#define AUART_CTRL0_XFER_COUNT(v) ((v) & 0xffff)
79
80#define AUART_CTRL1_XFER_COUNT(v) ((v) & 0xffff)
81
82#define AUART_CTRL2_DMAONERR (1 << 26)
83#define AUART_CTRL2_TXDMAE (1 << 25)
84#define AUART_CTRL2_RXDMAE (1 << 24)
74 85
75#define AUART_CTRL2_CTSEN (1 << 15) 86#define AUART_CTRL2_CTSEN (1 << 15)
76#define AUART_CTRL2_RTSEN (1 << 14) 87#define AUART_CTRL2_RTSEN (1 << 14)
@@ -111,29 +122,170 @@
111#define AUART_STAT_BERR (1 << 18) 122#define AUART_STAT_BERR (1 << 18)
112#define AUART_STAT_PERR (1 << 17) 123#define AUART_STAT_PERR (1 << 17)
113#define AUART_STAT_FERR (1 << 16) 124#define AUART_STAT_FERR (1 << 16)
125#define AUART_STAT_RXCOUNT_MASK 0xffff
114 126
115static struct uart_driver auart_driver; 127static struct uart_driver auart_driver;
116 128
129enum mxs_auart_type {
130 IMX23_AUART,
131 IMX28_AUART,
132};
133
117struct mxs_auart_port { 134struct mxs_auart_port {
118 struct uart_port port; 135 struct uart_port port;
119 136
120 unsigned int flags; 137#define MXS_AUART_DMA_CONFIG 0x1
138#define MXS_AUART_DMA_ENABLED 0x2
139#define MXS_AUART_DMA_TX_SYNC 2 /* bit 2 */
140#define MXS_AUART_DMA_RX_READY 3 /* bit 3 */
141 unsigned long flags;
121 unsigned int ctrl; 142 unsigned int ctrl;
143 enum mxs_auart_type devtype;
122 144
123 unsigned int irq; 145 unsigned int irq;
124 146
125 struct clk *clk; 147 struct clk *clk;
126 struct device *dev; 148 struct device *dev;
149
150 /* for DMA */
151 struct mxs_dma_data dma_data;
152 int dma_channel_rx, dma_channel_tx;
153 int dma_irq_rx, dma_irq_tx;
154 int dma_channel;
155
156 struct scatterlist tx_sgl;
157 struct dma_chan *tx_dma_chan;
158 void *tx_dma_buf;
159
160 struct scatterlist rx_sgl;
161 struct dma_chan *rx_dma_chan;
162 void *rx_dma_buf;
163};
164
165static struct platform_device_id mxs_auart_devtype[] = {
166 { .name = "mxs-auart-imx23", .driver_data = IMX23_AUART },
167 { .name = "mxs-auart-imx28", .driver_data = IMX28_AUART },
168 { /* sentinel */ }
169};
170MODULE_DEVICE_TABLE(platform, mxs_auart_devtype);
171
172static struct of_device_id mxs_auart_dt_ids[] = {
173 {
174 .compatible = "fsl,imx28-auart",
175 .data = &mxs_auart_devtype[IMX28_AUART]
176 }, {
177 .compatible = "fsl,imx23-auart",
178 .data = &mxs_auart_devtype[IMX23_AUART]
179 }, { /* sentinel */ }
127}; 180};
181MODULE_DEVICE_TABLE(of, mxs_auart_dt_ids);
182
183static inline int is_imx28_auart(struct mxs_auart_port *s)
184{
185 return s->devtype == IMX28_AUART;
186}
187
188static inline bool auart_dma_enabled(struct mxs_auart_port *s)
189{
190 return s->flags & MXS_AUART_DMA_ENABLED;
191}
128 192
129static void mxs_auart_stop_tx(struct uart_port *u); 193static void mxs_auart_stop_tx(struct uart_port *u);
130 194
131#define to_auart_port(u) container_of(u, struct mxs_auart_port, port) 195#define to_auart_port(u) container_of(u, struct mxs_auart_port, port)
132 196
133static inline void mxs_auart_tx_chars(struct mxs_auart_port *s) 197static void mxs_auart_tx_chars(struct mxs_auart_port *s);
198
199static void dma_tx_callback(void *param)
134{ 200{
201 struct mxs_auart_port *s = param;
135 struct circ_buf *xmit = &s->port.state->xmit; 202 struct circ_buf *xmit = &s->port.state->xmit;
136 203
204 dma_unmap_sg(s->dev, &s->tx_sgl, 1, DMA_TO_DEVICE);
205
206 /* clear the bit used to serialize the DMA tx. */
207 clear_bit(MXS_AUART_DMA_TX_SYNC, &s->flags);
208 smp_mb__after_clear_bit();
209
210 /* wake up the possible processes. */
211 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
212 uart_write_wakeup(&s->port);
213
214 mxs_auart_tx_chars(s);
215}
216
217static int mxs_auart_dma_tx(struct mxs_auart_port *s, int size)
218{
219 struct dma_async_tx_descriptor *desc;
220 struct scatterlist *sgl = &s->tx_sgl;
221 struct dma_chan *channel = s->tx_dma_chan;
222 u32 pio;
223
224 /* [1] : send PIO. Note, the first pio word is CTRL1. */
225 pio = AUART_CTRL1_XFER_COUNT(size);
226 desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)&pio,
227 1, DMA_TRANS_NONE, 0);
228 if (!desc) {
229 dev_err(s->dev, "step 1 error\n");
230 return -EINVAL;
231 }
232
233 /* [2] : set DMA buffer. */
234 sg_init_one(sgl, s->tx_dma_buf, size);
235 dma_map_sg(s->dev, sgl, 1, DMA_TO_DEVICE);
236 desc = dmaengine_prep_slave_sg(channel, sgl,
237 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
238 if (!desc) {
239 dev_err(s->dev, "step 2 error\n");
240 return -EINVAL;
241 }
242
243 /* [3] : submit the DMA */
244 desc->callback = dma_tx_callback;
245 desc->callback_param = s;
246 dmaengine_submit(desc);
247 dma_async_issue_pending(channel);
248 return 0;
249}
250
251static void mxs_auart_tx_chars(struct mxs_auart_port *s)
252{
253 struct circ_buf *xmit = &s->port.state->xmit;
254
255 if (auart_dma_enabled(s)) {
256 int i = 0;
257 int size;
258 void *buffer = s->tx_dma_buf;
259
260 if (test_and_set_bit(MXS_AUART_DMA_TX_SYNC, &s->flags))
261 return;
262
263 while (!uart_circ_empty(xmit) && !uart_tx_stopped(&s->port)) {
264 size = min_t(u32, UART_XMIT_SIZE - i,
265 CIRC_CNT_TO_END(xmit->head,
266 xmit->tail,
267 UART_XMIT_SIZE));
268 memcpy(buffer + i, xmit->buf + xmit->tail, size);
269 xmit->tail = (xmit->tail + size) & (UART_XMIT_SIZE - 1);
270
271 i += size;
272 if (i >= UART_XMIT_SIZE)
273 break;
274 }
275
276 if (uart_tx_stopped(&s->port))
277 mxs_auart_stop_tx(&s->port);
278
279 if (i) {
280 mxs_auart_dma_tx(s, i);
281 } else {
282 clear_bit(MXS_AUART_DMA_TX_SYNC, &s->flags);
283 smp_mb__after_clear_bit();
284 }
285 return;
286 }
287
288
137 while (!(readl(s->port.membase + AUART_STAT) & 289 while (!(readl(s->port.membase + AUART_STAT) &
138 AUART_STAT_TXFF)) { 290 AUART_STAT_TXFF)) {
139 if (s->port.x_char) { 291 if (s->port.x_char) {
@@ -287,10 +439,159 @@ static u32 mxs_auart_get_mctrl(struct uart_port *u)
287 return mctrl; 439 return mctrl;
288} 440}
289 441
442static bool mxs_auart_dma_filter(struct dma_chan *chan, void *param)
443{
444 struct mxs_auart_port *s = param;
445
446 if (!mxs_dma_is_apbx(chan))
447 return false;
448
449 if (s->dma_channel == chan->chan_id) {
450 chan->private = &s->dma_data;
451 return true;
452 }
453 return false;
454}
455
456static int mxs_auart_dma_prep_rx(struct mxs_auart_port *s);
457static void dma_rx_callback(void *arg)
458{
459 struct mxs_auart_port *s = (struct mxs_auart_port *) arg;
460 struct tty_struct *tty = s->port.state->port.tty;
461 int count;
462 u32 stat;
463
464 dma_unmap_sg(s->dev, &s->rx_sgl, 1, DMA_FROM_DEVICE);
465
466 stat = readl(s->port.membase + AUART_STAT);
467 stat &= ~(AUART_STAT_OERR | AUART_STAT_BERR |
468 AUART_STAT_PERR | AUART_STAT_FERR);
469
470 count = stat & AUART_STAT_RXCOUNT_MASK;
471 tty_insert_flip_string(tty, s->rx_dma_buf, count);
472
473 writel(stat, s->port.membase + AUART_STAT);
474 tty_flip_buffer_push(tty);
475
476 /* start the next DMA for RX. */
477 mxs_auart_dma_prep_rx(s);
478}
479
480static int mxs_auart_dma_prep_rx(struct mxs_auart_port *s)
481{
482 struct dma_async_tx_descriptor *desc;
483 struct scatterlist *sgl = &s->rx_sgl;
484 struct dma_chan *channel = s->rx_dma_chan;
485 u32 pio[1];
486
487 /* [1] : send PIO */
488 pio[0] = AUART_CTRL0_RXTO_ENABLE
489 | AUART_CTRL0_RXTIMEOUT(0x80)
490 | AUART_CTRL0_XFER_COUNT(UART_XMIT_SIZE);
491 desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)pio,
492 1, DMA_TRANS_NONE, 0);
493 if (!desc) {
494 dev_err(s->dev, "step 1 error\n");
495 return -EINVAL;
496 }
497
498 /* [2] : send DMA request */
499 sg_init_one(sgl, s->rx_dma_buf, UART_XMIT_SIZE);
500 dma_map_sg(s->dev, sgl, 1, DMA_FROM_DEVICE);
501 desc = dmaengine_prep_slave_sg(channel, sgl, 1, DMA_DEV_TO_MEM,
502 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
503 if (!desc) {
504 dev_err(s->dev, "step 2 error\n");
505 return -1;
506 }
507
508 /* [3] : submit the DMA, but do not issue it. */
509 desc->callback = dma_rx_callback;
510 desc->callback_param = s;
511 dmaengine_submit(desc);
512 dma_async_issue_pending(channel);
513 return 0;
514}
515
516static void mxs_auart_dma_exit_channel(struct mxs_auart_port *s)
517{
518 if (s->tx_dma_chan) {
519 dma_release_channel(s->tx_dma_chan);
520 s->tx_dma_chan = NULL;
521 }
522 if (s->rx_dma_chan) {
523 dma_release_channel(s->rx_dma_chan);
524 s->rx_dma_chan = NULL;
525 }
526
527 kfree(s->tx_dma_buf);
528 kfree(s->rx_dma_buf);
529 s->tx_dma_buf = NULL;
530 s->rx_dma_buf = NULL;
531}
532
533static void mxs_auart_dma_exit(struct mxs_auart_port *s)
534{
535
536 writel(AUART_CTRL2_TXDMAE | AUART_CTRL2_RXDMAE | AUART_CTRL2_DMAONERR,
537 s->port.membase + AUART_CTRL2_CLR);
538
539 mxs_auart_dma_exit_channel(s);
540 s->flags &= ~MXS_AUART_DMA_ENABLED;
541 clear_bit(MXS_AUART_DMA_TX_SYNC, &s->flags);
542 clear_bit(MXS_AUART_DMA_RX_READY, &s->flags);
543}
544
545static int mxs_auart_dma_init(struct mxs_auart_port *s)
546{
547 dma_cap_mask_t mask;
548
549 if (auart_dma_enabled(s))
550 return 0;
551
552 /* We do not get the right DMA channels. */
553 if (s->dma_channel_rx == -1 || s->dma_channel_rx == -1)
554 return -EINVAL;
555
556 /* init for RX */
557 dma_cap_zero(mask);
558 dma_cap_set(DMA_SLAVE, mask);
559 s->dma_channel = s->dma_channel_rx;
560 s->dma_data.chan_irq = s->dma_irq_rx;
561 s->rx_dma_chan = dma_request_channel(mask, mxs_auart_dma_filter, s);
562 if (!s->rx_dma_chan)
563 goto err_out;
564 s->rx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA);
565 if (!s->rx_dma_buf)
566 goto err_out;
567
568 /* init for TX */
569 s->dma_channel = s->dma_channel_tx;
570 s->dma_data.chan_irq = s->dma_irq_tx;
571 s->tx_dma_chan = dma_request_channel(mask, mxs_auart_dma_filter, s);
572 if (!s->tx_dma_chan)
573 goto err_out;
574 s->tx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA);
575 if (!s->tx_dma_buf)
576 goto err_out;
577
578 /* set the flags */
579 s->flags |= MXS_AUART_DMA_ENABLED;
580 dev_dbg(s->dev, "enabled the DMA support.");
581
582 return 0;
583
584err_out:
585 mxs_auart_dma_exit_channel(s);
586 return -EINVAL;
587
588}
589
290static void mxs_auart_settermios(struct uart_port *u, 590static void mxs_auart_settermios(struct uart_port *u,
291 struct ktermios *termios, 591 struct ktermios *termios,
292 struct ktermios *old) 592 struct ktermios *old)
293{ 593{
594 struct mxs_auart_port *s = to_auart_port(u);
294 u32 bm, ctrl, ctrl2, div; 595 u32 bm, ctrl, ctrl2, div;
295 unsigned int cflag, baud; 596 unsigned int cflag, baud;
296 597
@@ -362,10 +663,23 @@ static void mxs_auart_settermios(struct uart_port *u,
362 ctrl |= AUART_LINECTRL_STP2; 663 ctrl |= AUART_LINECTRL_STP2;
363 664
364 /* figure out the hardware flow control settings */ 665 /* figure out the hardware flow control settings */
365 if (cflag & CRTSCTS) 666 if (cflag & CRTSCTS) {
667 /*
668 * The DMA has a bug(see errata:2836) in mx23.
669 * So we can not implement the DMA for auart in mx23,
670 * we can only implement the DMA support for auart
671 * in mx28.
672 */
673 if (is_imx28_auart(s) && (s->flags & MXS_AUART_DMA_CONFIG)) {
674 if (!mxs_auart_dma_init(s))
675 /* enable DMA tranfer */
676 ctrl2 |= AUART_CTRL2_TXDMAE | AUART_CTRL2_RXDMAE
677 | AUART_CTRL2_DMAONERR;
678 }
366 ctrl2 |= AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN; 679 ctrl2 |= AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN;
367 else 680 } else {
368 ctrl2 &= ~(AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN); 681 ctrl2 &= ~(AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN);
682 }
369 683
370 /* set baud rate */ 684 /* set baud rate */
371 baud = uart_get_baud_rate(u, termios, old, 0, u->uartclk); 685 baud = uart_get_baud_rate(u, termios, old, 0, u->uartclk);
@@ -377,6 +691,19 @@ static void mxs_auart_settermios(struct uart_port *u,
377 writel(ctrl2, u->membase + AUART_CTRL2); 691 writel(ctrl2, u->membase + AUART_CTRL2);
378 692
379 uart_update_timeout(u, termios->c_cflag, baud); 693 uart_update_timeout(u, termios->c_cflag, baud);
694
695 /* prepare for the DMA RX. */
696 if (auart_dma_enabled(s) &&
697 !test_and_set_bit(MXS_AUART_DMA_RX_READY, &s->flags)) {
698 if (!mxs_auart_dma_prep_rx(s)) {
699 /* Disable the normal RX interrupt. */
700 writel(AUART_INTR_RXIEN | AUART_INTR_RTIEN,
701 u->membase + AUART_INTR_CLR);
702 } else {
703 mxs_auart_dma_exit(s);
704 dev_err(s->dev, "We can not start up the DMA.\n");
705 }
706 }
380} 707}
381 708
382static irqreturn_t mxs_auart_irq_handle(int irq, void *context) 709static irqreturn_t mxs_auart_irq_handle(int irq, void *context)
@@ -395,7 +722,8 @@ static irqreturn_t mxs_auart_irq_handle(int irq, void *context)
395 } 722 }
396 723
397 if (istat & (AUART_INTR_RTIS | AUART_INTR_RXIS)) { 724 if (istat & (AUART_INTR_RTIS | AUART_INTR_RXIS)) {
398 mxs_auart_rx_chars(s); 725 if (!auart_dma_enabled(s))
726 mxs_auart_rx_chars(s);
399 istat &= ~(AUART_INTR_RTIS | AUART_INTR_RXIS); 727 istat &= ~(AUART_INTR_RTIS | AUART_INTR_RXIS);
400 } 728 }
401 729
@@ -455,6 +783,9 @@ static void mxs_auart_shutdown(struct uart_port *u)
455{ 783{
456 struct mxs_auart_port *s = to_auart_port(u); 784 struct mxs_auart_port *s = to_auart_port(u);
457 785
786 if (auart_dma_enabled(s))
787 mxs_auart_dma_exit(s);
788
458 writel(AUART_CTRL2_UARTEN, u->membase + AUART_CTRL2_CLR); 789 writel(AUART_CTRL2_UARTEN, u->membase + AUART_CTRL2_CLR);
459 790
460 writel(AUART_INTR_RXIEN | AUART_INTR_RTIEN | AUART_INTR_CTSMIEN, 791 writel(AUART_INTR_RXIEN | AUART_INTR_RTIEN | AUART_INTR_CTSMIEN,
@@ -688,6 +1019,7 @@ static int serial_mxs_probe_dt(struct mxs_auart_port *s,
688 struct platform_device *pdev) 1019 struct platform_device *pdev)
689{ 1020{
690 struct device_node *np = pdev->dev.of_node; 1021 struct device_node *np = pdev->dev.of_node;
1022 u32 dma_channel[2];
691 int ret; 1023 int ret;
692 1024
693 if (!np) 1025 if (!np)
@@ -701,11 +1033,27 @@ static int serial_mxs_probe_dt(struct mxs_auart_port *s,
701 } 1033 }
702 s->port.line = ret; 1034 s->port.line = ret;
703 1035
1036 s->dma_irq_rx = platform_get_irq(pdev, 1);
1037 s->dma_irq_tx = platform_get_irq(pdev, 2);
1038
1039 ret = of_property_read_u32_array(np, "fsl,auart-dma-channel",
1040 dma_channel, 2);
1041 if (ret == 0) {
1042 s->dma_channel_rx = dma_channel[0];
1043 s->dma_channel_tx = dma_channel[1];
1044
1045 s->flags |= MXS_AUART_DMA_CONFIG;
1046 } else {
1047 s->dma_channel_rx = -1;
1048 s->dma_channel_tx = -1;
1049 }
704 return 0; 1050 return 0;
705} 1051}
706 1052
707static int __devinit mxs_auart_probe(struct platform_device *pdev) 1053static int mxs_auart_probe(struct platform_device *pdev)
708{ 1054{
1055 const struct of_device_id *of_id =
1056 of_match_device(mxs_auart_dt_ids, &pdev->dev);
709 struct mxs_auart_port *s; 1057 struct mxs_auart_port *s;
710 u32 version; 1058 u32 version;
711 int ret = 0; 1059 int ret = 0;
@@ -730,6 +1078,11 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
730 goto out_free; 1078 goto out_free;
731 } 1079 }
732 1080
1081 if (of_id) {
1082 pdev->id_entry = of_id->data;
1083 s->devtype = pdev->id_entry->driver_data;
1084 }
1085
733 s->clk = clk_get(&pdev->dev, NULL); 1086 s->clk = clk_get(&pdev->dev, NULL);
734 if (IS_ERR(s->clk)) { 1087 if (IS_ERR(s->clk)) {
735 ret = PTR_ERR(s->clk); 1088 ret = PTR_ERR(s->clk);
@@ -751,7 +1104,6 @@ static int __devinit mxs_auart_probe(struct platform_device *pdev)
751 s->port.type = PORT_IMX; 1104 s->port.type = PORT_IMX;
752 s->port.dev = s->dev = get_device(&pdev->dev); 1105 s->port.dev = s->dev = get_device(&pdev->dev);
753 1106
754 s->flags = 0;
755 s->ctrl = 0; 1107 s->ctrl = 0;
756 1108
757 s->irq = platform_get_irq(pdev, 0); 1109 s->irq = platform_get_irq(pdev, 0);
@@ -789,7 +1141,7 @@ out:
789 return ret; 1141 return ret;
790} 1142}
791 1143
792static int __devexit mxs_auart_remove(struct platform_device *pdev) 1144static int mxs_auart_remove(struct platform_device *pdev)
793{ 1145{
794 struct mxs_auart_port *s = platform_get_drvdata(pdev); 1146 struct mxs_auart_port *s = platform_get_drvdata(pdev);
795 1147
@@ -805,15 +1157,9 @@ static int __devexit mxs_auart_remove(struct platform_device *pdev)
805 return 0; 1157 return 0;
806} 1158}
807 1159
808static struct of_device_id mxs_auart_dt_ids[] = {
809 { .compatible = "fsl,imx23-auart", },
810 { /* sentinel */ }
811};
812MODULE_DEVICE_TABLE(of, mxs_auart_dt_ids);
813
814static struct platform_driver mxs_auart_driver = { 1160static struct platform_driver mxs_auart_driver = {
815 .probe = mxs_auart_probe, 1161 .probe = mxs_auart_probe,
816 .remove = __devexit_p(mxs_auart_remove), 1162 .remove = mxs_auart_remove,
817 .driver = { 1163 .driver = {
818 .name = "mxs-auart", 1164 .name = "mxs-auart",
819 .owner = THIS_MODULE, 1165 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index df443b908ca..e7cae1c2d7d 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -21,8 +21,10 @@
21#include <linux/of_serial.h> 21#include <linux/of_serial.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/nwpserial.h> 23#include <linux/nwpserial.h>
24#include <linux/clk.h>
24 25
25struct of_serial_info { 26struct of_serial_info {
27 struct clk *clk;
26 int type; 28 int type;
27 int line; 29 int line;
28}; 30};
@@ -50,8 +52,9 @@ EXPORT_SYMBOL_GPL(tegra_serial_handle_break);
50/* 52/*
51 * Fill a struct uart_port for a given device node 53 * Fill a struct uart_port for a given device node
52 */ 54 */
53static int __devinit of_platform_serial_setup(struct platform_device *ofdev, 55static int of_platform_serial_setup(struct platform_device *ofdev,
54 int type, struct uart_port *port) 56 int type, struct uart_port *port,
57 struct of_serial_info *info)
55{ 58{
56 struct resource resource; 59 struct resource resource;
57 struct device_node *np = ofdev->dev.of_node; 60 struct device_node *np = ofdev->dev.of_node;
@@ -60,8 +63,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
60 63
61 memset(port, 0, sizeof *port); 64 memset(port, 0, sizeof *port);
62 if (of_property_read_u32(np, "clock-frequency", &clk)) { 65 if (of_property_read_u32(np, "clock-frequency", &clk)) {
63 dev_warn(&ofdev->dev, "no clock-frequency property set\n"); 66
64 return -ENODEV; 67 /* Get clk rate through clk driver if present */
68 info->clk = clk_get(&ofdev->dev, NULL);
69 if (IS_ERR(info->clk)) {
70 dev_warn(&ofdev->dev,
71 "clk or clock-frequency not defined\n");
72 return PTR_ERR(info->clk);
73 }
74
75 clk_prepare_enable(info->clk);
76 clk = clk_get_rate(info->clk);
65 } 77 }
66 /* If current-speed was set, then try not to change it. */ 78 /* If current-speed was set, then try not to change it. */
67 if (of_property_read_u32(np, "current-speed", &spd) == 0) 79 if (of_property_read_u32(np, "current-speed", &spd) == 0)
@@ -70,7 +82,7 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
70 ret = of_address_to_resource(np, 0, &resource); 82 ret = of_address_to_resource(np, 0, &resource);
71 if (ret) { 83 if (ret) {
72 dev_warn(&ofdev->dev, "invalid address\n"); 84 dev_warn(&ofdev->dev, "invalid address\n");
73 return ret; 85 goto out;
74 } 86 }
75 87
76 spin_lock_init(&port->lock); 88 spin_lock_init(&port->lock);
@@ -97,7 +109,8 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
97 default: 109 default:
98 dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n", 110 dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
99 prop); 111 prop);
100 return -EINVAL; 112 ret = -EINVAL;
113 goto out;
101 } 114 }
102 } 115 }
103 116
@@ -115,13 +128,17 @@ static int __devinit of_platform_serial_setup(struct platform_device *ofdev,
115 port->handle_break = tegra_serial_handle_break; 128 port->handle_break = tegra_serial_handle_break;
116 129
117 return 0; 130 return 0;
131out:
132 if (info->clk)
133 clk_disable_unprepare(info->clk);
134 return ret;
118} 135}
119 136
120/* 137/*
121 * Try to register a serial port 138 * Try to register a serial port
122 */ 139 */
123static struct of_device_id of_platform_serial_table[]; 140static struct of_device_id of_platform_serial_table[];
124static int __devinit of_platform_serial_probe(struct platform_device *ofdev) 141static int of_platform_serial_probe(struct platform_device *ofdev)
125{ 142{
126 const struct of_device_id *match; 143 const struct of_device_id *match;
127 struct of_serial_info *info; 144 struct of_serial_info *info;
@@ -141,7 +158,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev)
141 return -ENOMEM; 158 return -ENOMEM;
142 159
143 port_type = (unsigned long)match->data; 160 port_type = (unsigned long)match->data;
144 ret = of_platform_serial_setup(ofdev, port_type, &port); 161 ret = of_platform_serial_setup(ofdev, port_type, &port, info);
145 if (ret) 162 if (ret)
146 goto out; 163 goto out;
147 164
@@ -204,6 +221,9 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
204 /* need to add code for these */ 221 /* need to add code for these */
205 break; 222 break;
206 } 223 }
224
225 if (info->clk)
226 clk_disable_unprepare(info->clk);
207 kfree(info); 227 kfree(info);
208 return 0; 228 return 0;
209} 229}
@@ -211,7 +231,7 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
211/* 231/*
212 * A few common types, add more as needed. 232 * A few common types, add more as needed.
213 */ 233 */
214static struct of_device_id __devinitdata of_platform_serial_table[] = { 234static struct of_device_id of_platform_serial_table[] = {
215 { .compatible = "ns8250", .data = (void *)PORT_8250, }, 235 { .compatible = "ns8250", .data = (void *)PORT_8250, },
216 { .compatible = "ns16450", .data = (void *)PORT_16450, }, 236 { .compatible = "ns16450", .data = (void *)PORT_16450, },
217 { .compatible = "ns16550a", .data = (void *)PORT_16550A, }, 237 { .compatible = "ns16550a", .data = (void *)PORT_16550A, },
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6d3d26a607b..b538e2e4ae5 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -96,7 +96,7 @@ struct uart_omap_port {
96 unsigned char msr_saved_flags; 96 unsigned char msr_saved_flags;
97 char name[20]; 97 char name[20];
98 unsigned long port_activity; 98 unsigned long port_activity;
99 u32 context_loss_cnt; 99 int context_loss_cnt;
100 u32 errata; 100 u32 errata;
101 u8 wakeups_enabled; 101 u8 wakeups_enabled;
102 unsigned int irq_pending:1; 102 unsigned int irq_pending:1;
@@ -702,11 +702,7 @@ serial_omap_configure_xonxoff
702 serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR); 702 serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR);
703 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 703 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
704 serial_out(up, UART_TI752_TCR, OMAP_UART_TCR_TRIG); 704 serial_out(up, UART_TI752_TCR, OMAP_UART_TCR_TRIG);
705 /* Enable special char function UARTi.EFR_REG[5] and 705
706 * load the new software flow control mode IXON or IXOFF
707 * and restore the UARTi.EFR_REG[4] ENHANCED_EN value.
708 */
709 serial_out(up, UART_EFR, up->efr | UART_EFR_SCD);
710 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); 706 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
711 707
712 serial_out(up, UART_MCR, up->mcr & ~UART_MCR_TCRTLR); 708 serial_out(up, UART_MCR, up->mcr & ~UART_MCR_TCRTLR);
@@ -1081,7 +1077,7 @@ out:
1081 1077
1082#ifdef CONFIG_SERIAL_OMAP_CONSOLE 1078#ifdef CONFIG_SERIAL_OMAP_CONSOLE
1083 1079
1084static struct uart_omap_port *serial_omap_console_ports[4]; 1080static struct uart_omap_port *serial_omap_console_ports[OMAP_MAX_HSUART_PORTS];
1085 1081
1086static struct uart_driver serial_omap_reg; 1082static struct uart_driver serial_omap_reg;
1087 1083
@@ -1242,7 +1238,7 @@ static int serial_omap_resume(struct device *dev)
1242} 1238}
1243#endif 1239#endif
1244 1240
1245static void __devinit omap_serial_fill_features_erratas(struct uart_omap_port *up) 1241static void omap_serial_fill_features_erratas(struct uart_omap_port *up)
1246{ 1242{
1247 u32 mvr, scheme; 1243 u32 mvr, scheme;
1248 u16 revision, major, minor; 1244 u16 revision, major, minor;
@@ -1295,7 +1291,7 @@ static void __devinit omap_serial_fill_features_erratas(struct uart_omap_port *u
1295 } 1291 }
1296} 1292}
1297 1293
1298static __devinit struct omap_uart_port_info *of_get_uart_port_info(struct device *dev) 1294static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev)
1299{ 1295{
1300 struct omap_uart_port_info *omap_up_info; 1296 struct omap_uart_port_info *omap_up_info;
1301 1297
@@ -1308,7 +1304,7 @@ static __devinit struct omap_uart_port_info *of_get_uart_port_info(struct device
1308 return omap_up_info; 1304 return omap_up_info;
1309} 1305}
1310 1306
1311static int __devinit serial_omap_probe(struct platform_device *pdev) 1307static int serial_omap_probe(struct platform_device *pdev)
1312{ 1308{
1313 struct uart_omap_port *up; 1309 struct uart_omap_port *up;
1314 struct resource *mem, *irq; 1310 struct resource *mem, *irq;
@@ -1445,7 +1441,7 @@ err_port_line:
1445 return ret; 1441 return ret;
1446} 1442}
1447 1443
1448static int __devexit serial_omap_remove(struct platform_device *dev) 1444static int serial_omap_remove(struct platform_device *dev)
1449{ 1445{
1450 struct uart_omap_port *up = platform_get_drvdata(dev); 1446 struct uart_omap_port *up = platform_get_drvdata(dev);
1451 1447
@@ -1556,11 +1552,15 @@ static int serial_omap_runtime_resume(struct device *dev)
1556{ 1552{
1557 struct uart_omap_port *up = dev_get_drvdata(dev); 1553 struct uart_omap_port *up = dev_get_drvdata(dev);
1558 1554
1559 u32 loss_cnt = serial_omap_get_context_loss_count(up); 1555 int loss_cnt = serial_omap_get_context_loss_count(up);
1560 1556
1561 if (up->context_loss_cnt != loss_cnt) 1557 if (loss_cnt < 0) {
1558 dev_err(dev, "serial_omap_get_context_loss_count failed : %d\n",
1559 loss_cnt);
1562 serial_omap_restore_context(up); 1560 serial_omap_restore_context(up);
1563 1561 } else if (up->context_loss_cnt != loss_cnt) {
1562 serial_omap_restore_context(up);
1563 }
1564 up->latency = up->calc_latency; 1564 up->latency = up->calc_latency;
1565 schedule_work(&up->qos_work); 1565 schedule_work(&up->qos_work);
1566 1566
@@ -1586,7 +1586,7 @@ MODULE_DEVICE_TABLE(of, omap_serial_of_match);
1586 1586
1587static struct platform_driver serial_omap_driver = { 1587static struct platform_driver serial_omap_driver = {
1588 .probe = serial_omap_probe, 1588 .probe = serial_omap_probe,
1589 .remove = __devexit_p(serial_omap_remove), 1589 .remove = serial_omap_remove,
1590 .driver = { 1590 .driver = {
1591 .name = DRIVER_NAME, 1591 .name = DRIVER_NAME,
1592 .pm = &serial_omap_dev_pm_ops, 1592 .pm = &serial_omap_dev_pm_ops,
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c
index 4cd6c238152..8318925fbf6 100644
--- a/drivers/tty/serial/pch_uart.c
+++ b/drivers/tty/serial/pch_uart.c
@@ -1839,7 +1839,7 @@ static DEFINE_PCI_DEVICE_TABLE(pch_uart_pci_id) = {
1839 {0,}, 1839 {0,},
1840}; 1840};
1841 1841
1842static int __devinit pch_uart_pci_probe(struct pci_dev *pdev, 1842static int pch_uart_pci_probe(struct pci_dev *pdev,
1843 const struct pci_device_id *id) 1843 const struct pci_device_id *id)
1844{ 1844{
1845 int ret; 1845 int ret;
@@ -1869,7 +1869,7 @@ static struct pci_driver pch_uart_pci_driver = {
1869 .name = "pch_uart", 1869 .name = "pch_uart",
1870 .id_table = pch_uart_pci_id, 1870 .id_table = pch_uart_pci_id,
1871 .probe = pch_uart_pci_probe, 1871 .probe = pch_uart_pci_probe,
1872 .remove = __devexit_p(pch_uart_pci_remove), 1872 .remove = pch_uart_pci_remove,
1873 .suspend = pch_uart_pci_suspend, 1873 .suspend = pch_uart_pci_suspend,
1874 .resume = pch_uart_pci_resume, 1874 .resume = pch_uart_pci_resume,
1875}; 1875};
diff --git a/drivers/tty/serial/pxa.c b/drivers/tty/serial/pxa.c
index 9033fc6e0e4..2764828251f 100644
--- a/drivers/tty/serial/pxa.c
+++ b/drivers/tty/serial/pxa.c
@@ -705,6 +705,57 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
705 clk_disable_unprepare(up->clk); 705 clk_disable_unprepare(up->clk);
706} 706}
707 707
708#ifdef CONFIG_CONSOLE_POLL
709/*
710 * Console polling routines for writing and reading from the uart while
711 * in an interrupt or debug context.
712 */
713
714static int serial_pxa_get_poll_char(struct uart_port *port)
715{
716 struct uart_pxa_port *up = (struct uart_pxa_port *)port;
717 unsigned char lsr = serial_in(up, UART_LSR);
718
719 while (!(lsr & UART_LSR_DR))
720 lsr = serial_in(up, UART_LSR);
721
722 return serial_in(up, UART_RX);
723}
724
725
726static void serial_pxa_put_poll_char(struct uart_port *port,
727 unsigned char c)
728{
729 unsigned int ier;
730 struct uart_pxa_port *up = (struct uart_pxa_port *)port;
731
732 /*
733 * First save the IER then disable the interrupts
734 */
735 ier = serial_in(up, UART_IER);
736 serial_out(up, UART_IER, UART_IER_UUE);
737
738 wait_for_xmitr(up);
739 /*
740 * Send the character out.
741 * If a LF, also do CR...
742 */
743 serial_out(up, UART_TX, c);
744 if (c == 10) {
745 wait_for_xmitr(up);
746 serial_out(up, UART_TX, 13);
747 }
748
749 /*
750 * Finally, wait for transmitter to become empty
751 * and restore the IER
752 */
753 wait_for_xmitr(up);
754 serial_out(up, UART_IER, ier);
755}
756
757#endif /* CONFIG_CONSOLE_POLL */
758
708static int __init 759static int __init
709serial_pxa_console_setup(struct console *co, char *options) 760serial_pxa_console_setup(struct console *co, char *options)
710{ 761{
@@ -759,6 +810,10 @@ struct uart_ops serial_pxa_pops = {
759 .request_port = serial_pxa_request_port, 810 .request_port = serial_pxa_request_port,
760 .config_port = serial_pxa_config_port, 811 .config_port = serial_pxa_config_port,
761 .verify_port = serial_pxa_verify_port, 812 .verify_port = serial_pxa_verify_port,
813#ifdef CONFIG_CONSOLE_POLL
814 .poll_get_char = serial_pxa_get_poll_char,
815 .poll_put_char = serial_pxa_put_poll_char,
816#endif
762}; 817};
763 818
764static struct uart_driver serial_pxa_reg = { 819static struct uart_driver serial_pxa_reg = {
diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
index 2ca5959ec3f..da56c8a0fdc 100644
--- a/drivers/tty/serial/sa1100.c
+++ b/drivers/tty/serial/sa1100.c
@@ -637,7 +637,7 @@ static void __init sa1100_init_ports(void)
637 PPSR |= PPC_TXD1 | PPC_TXD3; 637 PPSR |= PPC_TXD1 | PPC_TXD3;
638} 638}
639 639
640void __devinit sa1100_register_uart_fns(struct sa1100_port_fns *fns) 640void sa1100_register_uart_fns(struct sa1100_port_fns *fns)
641{ 641{
642 if (fns->get_mctrl) 642 if (fns->get_mctrl)
643 sa1100_pops.get_mctrl = fns->get_mctrl; 643 sa1100_pops.get_mctrl = fns->get_mctrl;
diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 7f04717176a..fb0e0f0bed0 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -223,8 +223,11 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id)
223 struct uart_port *port = &ourport->port; 223 struct uart_port *port = &ourport->port;
224 struct tty_struct *tty = port->state->port.tty; 224 struct tty_struct *tty = port->state->port.tty;
225 unsigned int ufcon, ch, flag, ufstat, uerstat; 225 unsigned int ufcon, ch, flag, ufstat, uerstat;
226 unsigned long flags;
226 int max_count = 64; 227 int max_count = 64;
227 228
229 spin_lock_irqsave(&port->lock, flags);
230
228 while (max_count-- > 0) { 231 while (max_count-- > 0) {
229 ufcon = rd_regl(port, S3C2410_UFCON); 232 ufcon = rd_regl(port, S3C2410_UFCON);
230 ufstat = rd_regl(port, S3C2410_UFSTAT); 233 ufstat = rd_regl(port, S3C2410_UFSTAT);
@@ -299,6 +302,7 @@ s3c24xx_serial_rx_chars(int irq, void *dev_id)
299 tty_flip_buffer_push(tty); 302 tty_flip_buffer_push(tty);
300 303
301 out: 304 out:
305 spin_unlock_irqrestore(&port->lock, flags);
302 return IRQ_HANDLED; 306 return IRQ_HANDLED;
303} 307}
304 308
@@ -307,8 +311,11 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id)
307 struct s3c24xx_uart_port *ourport = id; 311 struct s3c24xx_uart_port *ourport = id;
308 struct uart_port *port = &ourport->port; 312 struct uart_port *port = &ourport->port;
309 struct circ_buf *xmit = &port->state->xmit; 313 struct circ_buf *xmit = &port->state->xmit;
314 unsigned long flags;
310 int count = 256; 315 int count = 256;
311 316
317 spin_lock_irqsave(&port->lock, flags);
318
312 if (port->x_char) { 319 if (port->x_char) {
313 wr_regb(port, S3C2410_UTXH, port->x_char); 320 wr_regb(port, S3C2410_UTXH, port->x_char);
314 port->icount.tx++; 321 port->icount.tx++;
@@ -336,13 +343,17 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id)
336 port->icount.tx++; 343 port->icount.tx++;
337 } 344 }
338 345
339 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 346 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) {
347 spin_unlock(&port->lock);
340 uart_write_wakeup(port); 348 uart_write_wakeup(port);
349 spin_lock(&port->lock);
350 }
341 351
342 if (uart_circ_empty(xmit)) 352 if (uart_circ_empty(xmit))
343 s3c24xx_serial_stop_tx(port); 353 s3c24xx_serial_stop_tx(port);
344 354
345 out: 355 out:
356 spin_unlock_irqrestore(&port->lock, flags);
346 return IRQ_HANDLED; 357 return IRQ_HANDLED;
347} 358}
348 359
@@ -352,10 +363,8 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
352 struct s3c24xx_uart_port *ourport = id; 363 struct s3c24xx_uart_port *ourport = id;
353 struct uart_port *port = &ourport->port; 364 struct uart_port *port = &ourport->port;
354 unsigned int pend = rd_regl(port, S3C64XX_UINTP); 365 unsigned int pend = rd_regl(port, S3C64XX_UINTP);
355 unsigned long flags;
356 irqreturn_t ret = IRQ_HANDLED; 366 irqreturn_t ret = IRQ_HANDLED;
357 367
358 spin_lock_irqsave(&port->lock, flags);
359 if (pend & S3C64XX_UINTM_RXD_MSK) { 368 if (pend & S3C64XX_UINTM_RXD_MSK) {
360 ret = s3c24xx_serial_rx_chars(irq, id); 369 ret = s3c24xx_serial_rx_chars(irq, id);
361 wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_RXD_MSK); 370 wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_RXD_MSK);
@@ -364,7 +373,6 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
364 ret = s3c24xx_serial_tx_chars(irq, id); 373 ret = s3c24xx_serial_tx_chars(irq, id);
365 wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_TXD_MSK); 374 wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_TXD_MSK);
366 } 375 }
367 spin_unlock_irqrestore(&port->lock, flags);
368 return ret; 376 return ret;
369} 377}
370 378
@@ -530,16 +538,16 @@ static void s3c24xx_serial_pm(struct uart_port *port, unsigned int level,
530 switch (level) { 538 switch (level) {
531 case 3: 539 case 3:
532 if (!IS_ERR(ourport->baudclk)) 540 if (!IS_ERR(ourport->baudclk))
533 clk_disable(ourport->baudclk); 541 clk_disable_unprepare(ourport->baudclk);
534 542
535 clk_disable(ourport->clk); 543 clk_disable_unprepare(ourport->clk);
536 break; 544 break;
537 545
538 case 0: 546 case 0:
539 clk_enable(ourport->clk); 547 clk_prepare_enable(ourport->clk);
540 548
541 if (!IS_ERR(ourport->baudclk)) 549 if (!IS_ERR(ourport->baudclk))
542 clk_enable(ourport->baudclk); 550 clk_prepare_enable(ourport->baudclk);
543 551
544 break; 552 break;
545 default: 553 default:
@@ -713,11 +721,11 @@ static void s3c24xx_serial_set_termios(struct uart_port *port,
713 s3c24xx_serial_setsource(port, clk_sel); 721 s3c24xx_serial_setsource(port, clk_sel);
714 722
715 if (!IS_ERR(ourport->baudclk)) { 723 if (!IS_ERR(ourport->baudclk)) {
716 clk_disable(ourport->baudclk); 724 clk_disable_unprepare(ourport->baudclk);
717 ourport->baudclk = ERR_PTR(-EINVAL); 725 ourport->baudclk = ERR_PTR(-EINVAL);
718 } 726 }
719 727
720 clk_enable(clk); 728 clk_prepare_enable(clk);
721 729
722 ourport->baudclk = clk; 730 ourport->baudclk = clk;
723 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; 731 ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0;
@@ -1256,7 +1264,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
1256 return ret; 1264 return ret;
1257} 1265}
1258 1266
1259static int __devexit s3c24xx_serial_remove(struct platform_device *dev) 1267static int s3c24xx_serial_remove(struct platform_device *dev)
1260{ 1268{
1261 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev); 1269 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev);
1262 1270
@@ -1287,9 +1295,9 @@ static int s3c24xx_serial_resume(struct device *dev)
1287 struct s3c24xx_uart_port *ourport = to_ourport(port); 1295 struct s3c24xx_uart_port *ourport = to_ourport(port);
1288 1296
1289 if (port) { 1297 if (port) {
1290 clk_enable(ourport->clk); 1298 clk_prepare_enable(ourport->clk);
1291 s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port)); 1299 s3c24xx_serial_resetport(port, s3c24xx_port_to_cfg(port));
1292 clk_disable(ourport->clk); 1300 clk_disable_unprepare(ourport->clk);
1293 1301
1294 uart_resume_port(&s3c24xx_uart_drv, port); 1302 uart_resume_port(&s3c24xx_uart_drv, port);
1295 } 1303 }
@@ -1701,6 +1709,16 @@ MODULE_DEVICE_TABLE(platform, s3c24xx_serial_driver_ids);
1701 1709
1702#ifdef CONFIG_OF 1710#ifdef CONFIG_OF
1703static const struct of_device_id s3c24xx_uart_dt_match[] = { 1711static const struct of_device_id s3c24xx_uart_dt_match[] = {
1712 { .compatible = "samsung,s3c2410-uart",
1713 .data = (void *)S3C2410_SERIAL_DRV_DATA },
1714 { .compatible = "samsung,s3c2412-uart",
1715 .data = (void *)S3C2412_SERIAL_DRV_DATA },
1716 { .compatible = "samsung,s3c2440-uart",
1717 .data = (void *)S3C2440_SERIAL_DRV_DATA },
1718 { .compatible = "samsung,s3c6400-uart",
1719 .data = (void *)S3C6400_SERIAL_DRV_DATA },
1720 { .compatible = "samsung,s5pv210-uart",
1721 .data = (void *)S5PV210_SERIAL_DRV_DATA },
1704 { .compatible = "samsung,exynos4210-uart", 1722 { .compatible = "samsung,exynos4210-uart",
1705 .data = (void *)EXYNOS4210_SERIAL_DRV_DATA }, 1723 .data = (void *)EXYNOS4210_SERIAL_DRV_DATA },
1706 {}, 1724 {},
@@ -1712,7 +1730,7 @@ MODULE_DEVICE_TABLE(of, s3c24xx_uart_dt_match);
1712 1730
1713static struct platform_driver samsung_serial_driver = { 1731static struct platform_driver samsung_serial_driver = {
1714 .probe = s3c24xx_serial_probe, 1732 .probe = s3c24xx_serial_probe,
1715 .remove = __devexit_p(s3c24xx_serial_remove), 1733 .remove = s3c24xx_serial_remove,
1716 .id_table = s3c24xx_serial_driver_ids, 1734 .id_table = s3c24xx_serial_driver_ids,
1717 .driver = { 1735 .driver = {
1718 .name = "samsung-uart", 1736 .name = "samsung-uart",
diff --git a/drivers/tty/serial/sc26xx.c b/drivers/tty/serial/sc26xx.c
index 9d664242b31..aced1dd923d 100644
--- a/drivers/tty/serial/sc26xx.c
+++ b/drivers/tty/serial/sc26xx.c
@@ -621,7 +621,7 @@ static u8 sc26xx_flags2mask(unsigned int flags, unsigned int bitpos)
621 return bit ? (1 << (bit - 1)) : 0; 621 return bit ? (1 << (bit - 1)) : 0;
622} 622}
623 623
624static void __devinit sc26xx_init_masks(struct uart_sc26xx_port *up, 624static void sc26xx_init_masks(struct uart_sc26xx_port *up,
625 int line, unsigned int data) 625 int line, unsigned int data)
626{ 626{
627 up->dtr_mask[line] = sc26xx_flags2mask(data, 0); 627 up->dtr_mask[line] = sc26xx_flags2mask(data, 0);
@@ -632,7 +632,7 @@ static void __devinit sc26xx_init_masks(struct uart_sc26xx_port *up,
632 up->ri_mask[line] = sc26xx_flags2mask(data, 20); 632 up->ri_mask[line] = sc26xx_flags2mask(data, 20);
633} 633}
634 634
635static int __devinit sc26xx_probe(struct platform_device *dev) 635static int sc26xx_probe(struct platform_device *dev)
636{ 636{
637 struct resource *res; 637 struct resource *res;
638 struct uart_sc26xx_port *up; 638 struct uart_sc26xx_port *up;
@@ -733,7 +733,7 @@ static int __exit sc26xx_driver_remove(struct platform_device *dev)
733 733
734static struct platform_driver sc26xx_driver = { 734static struct platform_driver sc26xx_driver = {
735 .probe = sc26xx_probe, 735 .probe = sc26xx_probe,
736 .remove = __devexit_p(sc26xx_driver_remove), 736 .remove = sc26xx_driver_remove,
737 .driver = { 737 .driver = {
738 .name = "SC26xx", 738 .name = "SC26xx",
739 .owner = THIS_MODULE, 739 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index e821068cd95..418b495e323 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -740,7 +740,7 @@ static int sccnxp_console_setup(struct console *co, char *options)
740} 740}
741#endif 741#endif
742 742
743static int __devinit sccnxp_probe(struct platform_device *pdev) 743static int sccnxp_probe(struct platform_device *pdev)
744{ 744{
745 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 745 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
746 int chiptype = pdev->id_entry->driver_data; 746 int chiptype = pdev->id_entry->driver_data;
@@ -943,7 +943,7 @@ err_out:
943 return ret; 943 return ret;
944} 944}
945 945
946static int __devexit sccnxp_remove(struct platform_device *pdev) 946static int sccnxp_remove(struct platform_device *pdev)
947{ 947{
948 int i; 948 int i;
949 struct sccnxp_port *s = platform_get_drvdata(pdev); 949 struct sccnxp_port *s = platform_get_drvdata(pdev);
@@ -981,7 +981,7 @@ static struct platform_driver sccnxp_uart_driver = {
981 .owner = THIS_MODULE, 981 .owner = THIS_MODULE,
982 }, 982 },
983 .probe = sccnxp_probe, 983 .probe = sccnxp_probe,
984 .remove = __devexit_p(sccnxp_remove), 984 .remove = sccnxp_remove,
985 .id_table = sccnxp_id_table, 985 .id_table = sccnxp_id_table,
986}; 986};
987module_platform_driver(sccnxp_uart_driver); 987module_platform_driver(sccnxp_uart_driver);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 0fcfd98a956..fb5aa42fde7 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -634,10 +634,10 @@ static void uart_unthrottle(struct tty_struct *tty)
634 uart_set_mctrl(port, TIOCM_RTS); 634 uart_set_mctrl(port, TIOCM_RTS);
635} 635}
636 636
637static void uart_get_info(struct tty_port *port, 637static void do_uart_get_info(struct tty_port *port,
638 struct uart_state *state,
639 struct serial_struct *retinfo) 638 struct serial_struct *retinfo)
640{ 639{
640 struct uart_state *state = container_of(port, struct uart_state, port);
641 struct uart_port *uport = state->uart_port; 641 struct uart_port *uport = state->uart_port;
642 642
643 memset(retinfo, 0, sizeof(*retinfo)); 643 memset(retinfo, 0, sizeof(*retinfo));
@@ -662,17 +662,21 @@ static void uart_get_info(struct tty_port *port,
662 retinfo->iomem_base = (void *)(unsigned long)uport->mapbase; 662 retinfo->iomem_base = (void *)(unsigned long)uport->mapbase;
663} 663}
664 664
665static int uart_get_info_user(struct uart_state *state, 665static void uart_get_info(struct tty_port *port,
666 struct serial_struct __user *retinfo) 666 struct serial_struct *retinfo)
667{ 667{
668 struct tty_port *port = &state->port;
669 struct serial_struct tmp;
670
671 /* Ensure the state we copy is consistent and no hardware changes 668 /* Ensure the state we copy is consistent and no hardware changes
672 occur as we go */ 669 occur as we go */
673 mutex_lock(&port->mutex); 670 mutex_lock(&port->mutex);
674 uart_get_info(port, state, &tmp); 671 do_uart_get_info(port, retinfo);
675 mutex_unlock(&port->mutex); 672 mutex_unlock(&port->mutex);
673}
674
675static int uart_get_info_user(struct tty_port *port,
676 struct serial_struct __user *retinfo)
677{
678 struct serial_struct tmp;
679 uart_get_info(port, &tmp);
676 680
677 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 681 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
678 return -EFAULT; 682 return -EFAULT;
@@ -1131,7 +1135,7 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd,
1131 */ 1135 */
1132 switch (cmd) { 1136 switch (cmd) {
1133 case TIOCGSERIAL: 1137 case TIOCGSERIAL:
1134 ret = uart_get_info_user(state, uarg); 1138 ret = uart_get_info_user(port, uarg);
1135 break; 1139 break;
1136 1140
1137 case TIOCSSERIAL: 1141 case TIOCSSERIAL:
@@ -2293,6 +2297,8 @@ int uart_register_driver(struct uart_driver *drv)
2293 if (retval >= 0) 2297 if (retval >= 0)
2294 return retval; 2298 return retval;
2295 2299
2300 for (i = 0; i < drv->nr; i++)
2301 tty_port_destroy(&drv->state[i].port);
2296 put_tty_driver(normal); 2302 put_tty_driver(normal);
2297out_kfree: 2303out_kfree:
2298 kfree(drv->state); 2304 kfree(drv->state);
@@ -2312,8 +2318,12 @@ out:
2312void uart_unregister_driver(struct uart_driver *drv) 2318void uart_unregister_driver(struct uart_driver *drv)
2313{ 2319{
2314 struct tty_driver *p = drv->tty_driver; 2320 struct tty_driver *p = drv->tty_driver;
2321 unsigned int i;
2322
2315 tty_unregister_driver(p); 2323 tty_unregister_driver(p);
2316 put_tty_driver(p); 2324 put_tty_driver(p);
2325 for (i = 0; i < drv->nr; i++)
2326 tty_port_destroy(&drv->state[i].port);
2317 kfree(drv->state); 2327 kfree(drv->state);
2318 drv->state = NULL; 2328 drv->state = NULL;
2319 drv->tty_driver = NULL; 2329 drv->tty_driver = NULL;
@@ -2329,21 +2339,166 @@ struct tty_driver *uart_console_device(struct console *co, int *index)
2329static ssize_t uart_get_attr_uartclk(struct device *dev, 2339static ssize_t uart_get_attr_uartclk(struct device *dev,
2330 struct device_attribute *attr, char *buf) 2340 struct device_attribute *attr, char *buf)
2331{ 2341{
2332 int ret; 2342 struct serial_struct tmp;
2333 struct tty_port *port = dev_get_drvdata(dev); 2343 struct tty_port *port = dev_get_drvdata(dev);
2334 struct uart_state *state = container_of(port, struct uart_state, port);
2335 2344
2336 mutex_lock(&state->port.mutex); 2345 uart_get_info(port, &tmp);
2337 ret = snprintf(buf, PAGE_SIZE, "%d\n", state->uart_port->uartclk); 2346 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.baud_base * 16);
2338 mutex_unlock(&state->port.mutex); 2347}
2339 2348
2340 return ret; 2349static ssize_t uart_get_attr_type(struct device *dev,
2350 struct device_attribute *attr, char *buf)
2351{
2352 struct serial_struct tmp;
2353 struct tty_port *port = dev_get_drvdata(dev);
2354
2355 uart_get_info(port, &tmp);
2356 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.type);
2357}
2358static ssize_t uart_get_attr_line(struct device *dev,
2359 struct device_attribute *attr, char *buf)
2360{
2361 struct serial_struct tmp;
2362 struct tty_port *port = dev_get_drvdata(dev);
2363
2364 uart_get_info(port, &tmp);
2365 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.line);
2366}
2367
2368static ssize_t uart_get_attr_port(struct device *dev,
2369 struct device_attribute *attr, char *buf)
2370{
2371 struct serial_struct tmp;
2372 struct tty_port *port = dev_get_drvdata(dev);
2373 unsigned long ioaddr;
2374
2375 uart_get_info(port, &tmp);
2376 ioaddr = tmp.port;
2377 if (HIGH_BITS_OFFSET)
2378 ioaddr |= (unsigned long)tmp.port_high << HIGH_BITS_OFFSET;
2379 return snprintf(buf, PAGE_SIZE, "0x%lX\n", ioaddr);
2341} 2380}
2342 2381
2382static ssize_t uart_get_attr_irq(struct device *dev,
2383 struct device_attribute *attr, char *buf)
2384{
2385 struct serial_struct tmp;
2386 struct tty_port *port = dev_get_drvdata(dev);
2387
2388 uart_get_info(port, &tmp);
2389 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.irq);
2390}
2391
2392static ssize_t uart_get_attr_flags(struct device *dev,
2393 struct device_attribute *attr, char *buf)
2394{
2395 struct serial_struct tmp;
2396 struct tty_port *port = dev_get_drvdata(dev);
2397
2398 uart_get_info(port, &tmp);
2399 return snprintf(buf, PAGE_SIZE, "0x%X\n", tmp.flags);
2400}
2401
2402static ssize_t uart_get_attr_xmit_fifo_size(struct device *dev,
2403 struct device_attribute *attr, char *buf)
2404{
2405 struct serial_struct tmp;
2406 struct tty_port *port = dev_get_drvdata(dev);
2407
2408 uart_get_info(port, &tmp);
2409 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.xmit_fifo_size);
2410}
2411
2412
2413static ssize_t uart_get_attr_close_delay(struct device *dev,
2414 struct device_attribute *attr, char *buf)
2415{
2416 struct serial_struct tmp;
2417 struct tty_port *port = dev_get_drvdata(dev);
2418
2419 uart_get_info(port, &tmp);
2420 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.close_delay);
2421}
2422
2423
2424static ssize_t uart_get_attr_closing_wait(struct device *dev,
2425 struct device_attribute *attr, char *buf)
2426{
2427 struct serial_struct tmp;
2428 struct tty_port *port = dev_get_drvdata(dev);
2429
2430 uart_get_info(port, &tmp);
2431 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.closing_wait);
2432}
2433
2434static ssize_t uart_get_attr_custom_divisor(struct device *dev,
2435 struct device_attribute *attr, char *buf)
2436{
2437 struct serial_struct tmp;
2438 struct tty_port *port = dev_get_drvdata(dev);
2439
2440 uart_get_info(port, &tmp);
2441 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.custom_divisor);
2442}
2443
2444static ssize_t uart_get_attr_io_type(struct device *dev,
2445 struct device_attribute *attr, char *buf)
2446{
2447 struct serial_struct tmp;
2448 struct tty_port *port = dev_get_drvdata(dev);
2449
2450 uart_get_info(port, &tmp);
2451 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.io_type);
2452}
2453
2454static ssize_t uart_get_attr_iomem_base(struct device *dev,
2455 struct device_attribute *attr, char *buf)
2456{
2457 struct serial_struct tmp;
2458 struct tty_port *port = dev_get_drvdata(dev);
2459
2460 uart_get_info(port, &tmp);
2461 return snprintf(buf, PAGE_SIZE, "0x%lX\n", (unsigned long)tmp.iomem_base);
2462}
2463
2464static ssize_t uart_get_attr_iomem_reg_shift(struct device *dev,
2465 struct device_attribute *attr, char *buf)
2466{
2467 struct serial_struct tmp;
2468 struct tty_port *port = dev_get_drvdata(dev);
2469
2470 uart_get_info(port, &tmp);
2471 return snprintf(buf, PAGE_SIZE, "%d\n", tmp.iomem_reg_shift);
2472}
2473
2474static DEVICE_ATTR(type, S_IRUSR | S_IRGRP, uart_get_attr_type, NULL);
2475static DEVICE_ATTR(line, S_IRUSR | S_IRGRP, uart_get_attr_line, NULL);
2476static DEVICE_ATTR(port, S_IRUSR | S_IRGRP, uart_get_attr_port, NULL);
2477static DEVICE_ATTR(irq, S_IRUSR | S_IRGRP, uart_get_attr_irq, NULL);
2478static DEVICE_ATTR(flags, S_IRUSR | S_IRGRP, uart_get_attr_flags, NULL);
2479static DEVICE_ATTR(xmit_fifo_size, S_IRUSR | S_IRGRP, uart_get_attr_xmit_fifo_size, NULL);
2343static DEVICE_ATTR(uartclk, S_IRUSR | S_IRGRP, uart_get_attr_uartclk, NULL); 2480static DEVICE_ATTR(uartclk, S_IRUSR | S_IRGRP, uart_get_attr_uartclk, NULL);
2481static DEVICE_ATTR(close_delay, S_IRUSR | S_IRGRP, uart_get_attr_close_delay, NULL);
2482static DEVICE_ATTR(closing_wait, S_IRUSR | S_IRGRP, uart_get_attr_closing_wait, NULL);
2483static DEVICE_ATTR(custom_divisor, S_IRUSR | S_IRGRP, uart_get_attr_custom_divisor, NULL);
2484static DEVICE_ATTR(io_type, S_IRUSR | S_IRGRP, uart_get_attr_io_type, NULL);
2485static DEVICE_ATTR(iomem_base, S_IRUSR | S_IRGRP, uart_get_attr_iomem_base, NULL);
2486static DEVICE_ATTR(iomem_reg_shift, S_IRUSR | S_IRGRP, uart_get_attr_iomem_reg_shift, NULL);
2344 2487
2345static struct attribute *tty_dev_attrs[] = { 2488static struct attribute *tty_dev_attrs[] = {
2489 &dev_attr_type.attr,
2490 &dev_attr_line.attr,
2491 &dev_attr_port.attr,
2492 &dev_attr_irq.attr,
2493 &dev_attr_flags.attr,
2494 &dev_attr_xmit_fifo_size.attr,
2346 &dev_attr_uartclk.attr, 2495 &dev_attr_uartclk.attr,
2496 &dev_attr_close_delay.attr,
2497 &dev_attr_closing_wait.attr,
2498 &dev_attr_custom_divisor.attr,
2499 &dev_attr_io_type.attr,
2500 &dev_attr_iomem_base.attr,
2501 &dev_attr_iomem_reg_shift.attr,
2347 NULL, 2502 NULL,
2348 }; 2503 };
2349 2504
@@ -2356,6 +2511,7 @@ static const struct attribute_group *tty_dev_attr_groups[] = {
2356 NULL 2511 NULL
2357 }; 2512 };
2358 2513
2514
2359/** 2515/**
2360 * uart_add_one_port - attach a driver-defined port structure 2516 * uart_add_one_port - attach a driver-defined port structure
2361 * @drv: pointer to the uart low level driver structure for this port 2517 * @drv: pointer to the uart low level driver structure for this port
diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
index 6ae2a58d62f..b52b21aeb25 100644
--- a/drivers/tty/serial/serial_txx9.c
+++ b/drivers/tty/serial/serial_txx9.c
@@ -1030,7 +1030,7 @@ static DEFINE_MUTEX(serial_txx9_mutex);
1030 * 1030 *
1031 * On success the port is ready to use and the line number is returned. 1031 * On success the port is ready to use and the line number is returned.
1032 */ 1032 */
1033static int __devinit serial_txx9_register_port(struct uart_port *port) 1033static int serial_txx9_register_port(struct uart_port *port)
1034{ 1034{
1035 int i; 1035 int i;
1036 struct uart_txx9_port *uart; 1036 struct uart_txx9_port *uart;
@@ -1078,7 +1078,7 @@ static int __devinit serial_txx9_register_port(struct uart_port *port)
1078 * Remove one serial port. This may not be called from interrupt 1078 * Remove one serial port. This may not be called from interrupt
1079 * context. We hand the port back to the our control. 1079 * context. We hand the port back to the our control.
1080 */ 1080 */
1081static void __devexit serial_txx9_unregister_port(int line) 1081static void serial_txx9_unregister_port(int line)
1082{ 1082{
1083 struct uart_txx9_port *uart = &serial_txx9_ports[line]; 1083 struct uart_txx9_port *uart = &serial_txx9_ports[line];
1084 1084
@@ -1096,7 +1096,7 @@ static void __devexit serial_txx9_unregister_port(int line)
1096/* 1096/*
1097 * Register a set of serial devices attached to a platform device. 1097 * Register a set of serial devices attached to a platform device.
1098 */ 1098 */
1099static int __devinit serial_txx9_probe(struct platform_device *dev) 1099static int serial_txx9_probe(struct platform_device *dev)
1100{ 1100{
1101 struct uart_port *p = dev->dev.platform_data; 1101 struct uart_port *p = dev->dev.platform_data;
1102 struct uart_port port; 1102 struct uart_port port;
@@ -1126,7 +1126,7 @@ static int __devinit serial_txx9_probe(struct platform_device *dev)
1126/* 1126/*
1127 * Remove serial ports registered against a platform device. 1127 * Remove serial ports registered against a platform device.
1128 */ 1128 */
1129static int __devexit serial_txx9_remove(struct platform_device *dev) 1129static int serial_txx9_remove(struct platform_device *dev)
1130{ 1130{
1131 int i; 1131 int i;
1132 1132
@@ -1171,7 +1171,7 @@ static int serial_txx9_resume(struct platform_device *dev)
1171 1171
1172static struct platform_driver serial_txx9_plat_driver = { 1172static struct platform_driver serial_txx9_plat_driver = {
1173 .probe = serial_txx9_probe, 1173 .probe = serial_txx9_probe,
1174 .remove = __devexit_p(serial_txx9_remove), 1174 .remove = serial_txx9_remove,
1175#ifdef CONFIG_PM 1175#ifdef CONFIG_PM
1176 .suspend = serial_txx9_suspend, 1176 .suspend = serial_txx9_suspend,
1177 .resume = serial_txx9_resume, 1177 .resume = serial_txx9_resume,
@@ -1187,7 +1187,7 @@ static struct platform_driver serial_txx9_plat_driver = {
1187 * Probe one serial board. Unfortunately, there is no rhyme nor reason 1187 * Probe one serial board. Unfortunately, there is no rhyme nor reason
1188 * to the arrangement of serial ports on a PCI card. 1188 * to the arrangement of serial ports on a PCI card.
1189 */ 1189 */
1190static int __devinit 1190static int
1191pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent) 1191pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
1192{ 1192{
1193 struct uart_port port; 1193 struct uart_port port;
@@ -1217,7 +1217,7 @@ pciserial_txx9_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
1217 return 0; 1217 return 0;
1218} 1218}
1219 1219
1220static void __devexit pciserial_txx9_remove_one(struct pci_dev *dev) 1220static void pciserial_txx9_remove_one(struct pci_dev *dev)
1221{ 1221{
1222 struct uart_txx9_port *up = pci_get_drvdata(dev); 1222 struct uart_txx9_port *up = pci_get_drvdata(dev);
1223 1223
@@ -1261,7 +1261,7 @@ static const struct pci_device_id serial_txx9_pci_tbl[] = {
1261static struct pci_driver serial_txx9_pci_driver = { 1261static struct pci_driver serial_txx9_pci_driver = {
1262 .name = "serial_txx9", 1262 .name = "serial_txx9",
1263 .probe = pciserial_txx9_init_one, 1263 .probe = pciserial_txx9_init_one,
1264 .remove = __devexit_p(pciserial_txx9_remove_one), 1264 .remove = pciserial_txx9_remove_one,
1265#ifdef CONFIG_PM 1265#ifdef CONFIG_PM
1266 .suspend = pciserial_txx9_suspend_one, 1266 .suspend = pciserial_txx9_suspend_one,
1267 .resume = pciserial_txx9_resume_one, 1267 .resume = pciserial_txx9_resume_one,
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 6ee59001d61..61477567423 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -99,12 +99,6 @@ struct sci_port {
99#endif 99#endif
100 100
101 struct notifier_block freq_transition; 101 struct notifier_block freq_transition;
102
103#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
104 unsigned short saved_smr;
105 unsigned short saved_fcr;
106 unsigned char saved_brr;
107#endif
108}; 102};
109 103
110/* Function prototypes */ 104/* Function prototypes */
@@ -202,9 +196,9 @@ static struct plat_sci_reg sci_regmap[SCIx_NR_REGTYPES][SCIx_NR_REGS] = {
202 [SCxSR] = { 0x14, 16 }, 196 [SCxSR] = { 0x14, 16 },
203 [SCxRDR] = { 0x60, 8 }, 197 [SCxRDR] = { 0x60, 8 },
204 [SCFCR] = { 0x18, 16 }, 198 [SCFCR] = { 0x18, 16 },
205 [SCFDR] = { 0x1c, 16 }, 199 [SCFDR] = sci_reg_invalid,
206 [SCTFDR] = sci_reg_invalid, 200 [SCTFDR] = { 0x38, 16 },
207 [SCRFDR] = sci_reg_invalid, 201 [SCRFDR] = { 0x3c, 16 },
208 [SCSPTR] = sci_reg_invalid, 202 [SCSPTR] = sci_reg_invalid,
209 [SCLSR] = sci_reg_invalid, 203 [SCLSR] = sci_reg_invalid,
210 }, 204 },
@@ -491,7 +485,7 @@ static int sci_txfill(struct uart_port *port)
491 485
492 reg = sci_getreg(port, SCTFDR); 486 reg = sci_getreg(port, SCTFDR);
493 if (reg->size) 487 if (reg->size)
494 return serial_port_in(port, SCTFDR) & 0xff; 488 return serial_port_in(port, SCTFDR) & ((port->fifosize << 1) - 1);
495 489
496 reg = sci_getreg(port, SCFDR); 490 reg = sci_getreg(port, SCFDR);
497 if (reg->size) 491 if (reg->size)
@@ -511,7 +505,7 @@ static int sci_rxfill(struct uart_port *port)
511 505
512 reg = sci_getreg(port, SCRFDR); 506 reg = sci_getreg(port, SCRFDR);
513 if (reg->size) 507 if (reg->size)
514 return serial_port_in(port, SCRFDR) & 0xff; 508 return serial_port_in(port, SCRFDR) & ((port->fifosize << 1) - 1);
515 509
516 reg = sci_getreg(port, SCFDR); 510 reg = sci_getreg(port, SCFDR);
517 if (reg->size) 511 if (reg->size)
@@ -1132,7 +1126,7 @@ static const char *sci_gpio_str(unsigned int index)
1132 return sci_gpio_names[index]; 1126 return sci_gpio_names[index];
1133} 1127}
1134 1128
1135static void __devinit sci_init_gpios(struct sci_port *port) 1129static void sci_init_gpios(struct sci_port *port)
1136{ 1130{
1137 struct uart_port *up = &port->port; 1131 struct uart_port *up = &port->port;
1138 int i; 1132 int i;
@@ -1749,22 +1743,21 @@ static inline void sci_free_dma(struct uart_port *port)
1749static int sci_startup(struct uart_port *port) 1743static int sci_startup(struct uart_port *port)
1750{ 1744{
1751 struct sci_port *s = to_sci_port(port); 1745 struct sci_port *s = to_sci_port(port);
1746 unsigned long flags;
1752 int ret; 1747 int ret;
1753 1748
1754 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); 1749 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
1755 1750
1756 pm_runtime_put_noidle(port->dev);
1757
1758 sci_port_enable(s);
1759
1760 ret = sci_request_irq(s); 1751 ret = sci_request_irq(s);
1761 if (unlikely(ret < 0)) 1752 if (unlikely(ret < 0))
1762 return ret; 1753 return ret;
1763 1754
1764 sci_request_dma(port); 1755 sci_request_dma(port);
1765 1756
1757 spin_lock_irqsave(&port->lock, flags);
1766 sci_start_tx(port); 1758 sci_start_tx(port);
1767 sci_start_rx(port); 1759 sci_start_rx(port);
1760 spin_unlock_irqrestore(&port->lock, flags);
1768 1761
1769 return 0; 1762 return 0;
1770} 1763}
@@ -1772,18 +1765,17 @@ static int sci_startup(struct uart_port *port)
1772static void sci_shutdown(struct uart_port *port) 1765static void sci_shutdown(struct uart_port *port)
1773{ 1766{
1774 struct sci_port *s = to_sci_port(port); 1767 struct sci_port *s = to_sci_port(port);
1768 unsigned long flags;
1775 1769
1776 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); 1770 dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
1777 1771
1772 spin_lock_irqsave(&port->lock, flags);
1778 sci_stop_rx(port); 1773 sci_stop_rx(port);
1779 sci_stop_tx(port); 1774 sci_stop_tx(port);
1775 spin_unlock_irqrestore(&port->lock, flags);
1780 1776
1781 sci_free_dma(port); 1777 sci_free_dma(port);
1782 sci_free_irq(s); 1778 sci_free_irq(s);
1783
1784 sci_port_disable(s);
1785
1786 pm_runtime_get_noresume(port->dev);
1787} 1779}
1788 1780
1789static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, 1781static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps,
@@ -1829,7 +1821,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1829{ 1821{
1830 struct sci_port *s = to_sci_port(port); 1822 struct sci_port *s = to_sci_port(port);
1831 struct plat_sci_reg *reg; 1823 struct plat_sci_reg *reg;
1832 unsigned int baud, smr_val, max_baud; 1824 unsigned int baud, smr_val, max_baud, cks;
1833 int t = -1; 1825 int t = -1;
1834 1826
1835 /* 1827 /*
@@ -1863,21 +1855,18 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1863 1855
1864 uart_update_timeout(port, termios->c_cflag, baud); 1856 uart_update_timeout(port, termios->c_cflag, baud);
1865 1857
1866 serial_port_out(port, SCSMR, smr_val); 1858 for (cks = 0; t >= 256 && cks <= 3; cks++)
1867 1859 t >>= 2;
1868 dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t,
1869 s->cfg->scscr);
1870 1860
1871 if (t > 0) { 1861 dev_dbg(port->dev, "%s: SMR %x, cks %x, t %x, SCSCR %x\n",
1872 if (t >= 256) { 1862 __func__, smr_val, cks, t, s->cfg->scscr);
1873 serial_port_out(port, SCSMR, (serial_port_in(port, SCSMR) & ~3) | 1);
1874 t >>= 2;
1875 } else
1876 serial_port_out(port, SCSMR, serial_port_in(port, SCSMR) & ~3);
1877 1863
1864 if (t >= 0) {
1865 serial_port_out(port, SCSMR, (smr_val & ~3) | cks);
1878 serial_port_out(port, SCBRR, t); 1866 serial_port_out(port, SCBRR, t);
1879 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */ 1867 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
1880 } 1868 } else
1869 serial_port_out(port, SCSMR, smr_val);
1881 1870
1882 sci_init_pins(port, termios->c_cflag); 1871 sci_init_pins(port, termios->c_cflag);
1883 1872
@@ -1932,6 +1921,21 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1932 sci_port_disable(s); 1921 sci_port_disable(s);
1933} 1922}
1934 1923
1924static void sci_pm(struct uart_port *port, unsigned int state,
1925 unsigned int oldstate)
1926{
1927 struct sci_port *sci_port = to_sci_port(port);
1928
1929 switch (state) {
1930 case 3:
1931 sci_port_disable(sci_port);
1932 break;
1933 default:
1934 sci_port_enable(sci_port);
1935 break;
1936 }
1937}
1938
1935static const char *sci_type(struct uart_port *port) 1939static const char *sci_type(struct uart_port *port)
1936{ 1940{
1937 switch (port->type) { 1941 switch (port->type) {
@@ -2053,6 +2057,7 @@ static struct uart_ops sci_uart_ops = {
2053 .startup = sci_startup, 2057 .startup = sci_startup,
2054 .shutdown = sci_shutdown, 2058 .shutdown = sci_shutdown,
2055 .set_termios = sci_set_termios, 2059 .set_termios = sci_set_termios,
2060 .pm = sci_pm,
2056 .type = sci_type, 2061 .type = sci_type,
2057 .release_port = sci_release_port, 2062 .release_port = sci_release_port,
2058 .request_port = sci_request_port, 2063 .request_port = sci_request_port,
@@ -2064,7 +2069,7 @@ static struct uart_ops sci_uart_ops = {
2064#endif 2069#endif
2065}; 2070};
2066 2071
2067static int __devinit sci_init_single(struct platform_device *dev, 2072static int sci_init_single(struct platform_device *dev,
2068 struct sci_port *sci_port, 2073 struct sci_port *sci_port,
2069 unsigned int index, 2074 unsigned int index,
2070 struct plat_sci_port *p) 2075 struct plat_sci_port *p)
@@ -2121,8 +2126,6 @@ static int __devinit sci_init_single(struct platform_device *dev,
2121 2126
2122 sci_init_gpios(sci_port); 2127 sci_init_gpios(sci_port);
2123 2128
2124 pm_runtime_irq_safe(&dev->dev);
2125 pm_runtime_get_noresume(&dev->dev);
2126 pm_runtime_enable(&dev->dev); 2129 pm_runtime_enable(&dev->dev);
2127 } 2130 }
2128 2131
@@ -2206,9 +2209,21 @@ static void serial_console_write(struct console *co, const char *s,
2206{ 2209{
2207 struct sci_port *sci_port = &sci_ports[co->index]; 2210 struct sci_port *sci_port = &sci_ports[co->index];
2208 struct uart_port *port = &sci_port->port; 2211 struct uart_port *port = &sci_port->port;
2209 unsigned short bits; 2212 unsigned short bits, ctrl;
2213 unsigned long flags;
2214 int locked = 1;
2215
2216 local_irq_save(flags);
2217 if (port->sysrq)
2218 locked = 0;
2219 else if (oops_in_progress)
2220 locked = spin_trylock(&port->lock);
2221 else
2222 spin_lock(&port->lock);
2210 2223
2211 sci_port_enable(sci_port); 2224 /* first save the SCSCR then disable the interrupts */
2225 ctrl = serial_port_in(port, SCSCR);
2226 serial_port_out(port, SCSCR, sci_port->cfg->scscr);
2212 2227
2213 uart_console_write(port, s, count, serial_console_putchar); 2228 uart_console_write(port, s, count, serial_console_putchar);
2214 2229
@@ -2217,10 +2232,15 @@ static void serial_console_write(struct console *co, const char *s,
2217 while ((serial_port_in(port, SCxSR) & bits) != bits) 2232 while ((serial_port_in(port, SCxSR) & bits) != bits)
2218 cpu_relax(); 2233 cpu_relax();
2219 2234
2220 sci_port_disable(sci_port); 2235 /* restore the SCSCR */
2236 serial_port_out(port, SCSCR, ctrl);
2237
2238 if (locked)
2239 spin_unlock(&port->lock);
2240 local_irq_restore(flags);
2221} 2241}
2222 2242
2223static int __devinit serial_console_setup(struct console *co, char *options) 2243static int serial_console_setup(struct console *co, char *options)
2224{ 2244{
2225 struct sci_port *sci_port; 2245 struct sci_port *sci_port;
2226 struct uart_port *port; 2246 struct uart_port *port;
@@ -2249,13 +2269,9 @@ static int __devinit serial_console_setup(struct console *co, char *options)
2249 if (unlikely(ret != 0)) 2269 if (unlikely(ret != 0))
2250 return ret; 2270 return ret;
2251 2271
2252 sci_port_enable(sci_port);
2253
2254 if (options) 2272 if (options)
2255 uart_parse_options(options, &baud, &parity, &bits, &flow); 2273 uart_parse_options(options, &baud, &parity, &bits, &flow);
2256 2274
2257 sci_port_disable(sci_port);
2258
2259 return uart_set_options(port, co, baud, parity, bits, flow); 2275 return uart_set_options(port, co, baud, parity, bits, flow);
2260} 2276}
2261 2277
@@ -2278,7 +2294,7 @@ static struct console early_serial_console = {
2278 2294
2279static char early_serial_buf[32]; 2295static char early_serial_buf[32];
2280 2296
2281static int __devinit sci_probe_earlyprintk(struct platform_device *pdev) 2297static int sci_probe_earlyprintk(struct platform_device *pdev)
2282{ 2298{
2283 struct plat_sci_port *cfg = pdev->dev.platform_data; 2299 struct plat_sci_port *cfg = pdev->dev.platform_data;
2284 2300
@@ -2298,57 +2314,15 @@ static int __devinit sci_probe_earlyprintk(struct platform_device *pdev)
2298 return 0; 2314 return 0;
2299} 2315}
2300 2316
2301#define uart_console(port) ((port)->cons->index == (port)->line)
2302
2303static int sci_runtime_suspend(struct device *dev)
2304{
2305 struct sci_port *sci_port = dev_get_drvdata(dev);
2306 struct uart_port *port = &sci_port->port;
2307
2308 if (uart_console(port)) {
2309 struct plat_sci_reg *reg;
2310
2311 sci_port->saved_smr = serial_port_in(port, SCSMR);
2312 sci_port->saved_brr = serial_port_in(port, SCBRR);
2313
2314 reg = sci_getreg(port, SCFCR);
2315 if (reg->size)
2316 sci_port->saved_fcr = serial_port_in(port, SCFCR);
2317 else
2318 sci_port->saved_fcr = 0;
2319 }
2320 return 0;
2321}
2322
2323static int sci_runtime_resume(struct device *dev)
2324{
2325 struct sci_port *sci_port = dev_get_drvdata(dev);
2326 struct uart_port *port = &sci_port->port;
2327
2328 if (uart_console(port)) {
2329 sci_reset(port);
2330 serial_port_out(port, SCSMR, sci_port->saved_smr);
2331 serial_port_out(port, SCBRR, sci_port->saved_brr);
2332
2333 if (sci_port->saved_fcr)
2334 serial_port_out(port, SCFCR, sci_port->saved_fcr);
2335
2336 serial_port_out(port, SCSCR, sci_port->cfg->scscr);
2337 }
2338 return 0;
2339}
2340
2341#define SCI_CONSOLE (&serial_console) 2317#define SCI_CONSOLE (&serial_console)
2342 2318
2343#else 2319#else
2344static inline int __devinit sci_probe_earlyprintk(struct platform_device *pdev) 2320static inline int sci_probe_earlyprintk(struct platform_device *pdev)
2345{ 2321{
2346 return -EINVAL; 2322 return -EINVAL;
2347} 2323}
2348 2324
2349#define SCI_CONSOLE NULL 2325#define SCI_CONSOLE NULL
2350#define sci_runtime_suspend NULL
2351#define sci_runtime_resume NULL
2352 2326
2353#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ 2327#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
2354 2328
@@ -2379,7 +2353,7 @@ static int sci_remove(struct platform_device *dev)
2379 return 0; 2353 return 0;
2380} 2354}
2381 2355
2382static int __devinit sci_probe_single(struct platform_device *dev, 2356static int sci_probe_single(struct platform_device *dev,
2383 unsigned int index, 2357 unsigned int index,
2384 struct plat_sci_port *p, 2358 struct plat_sci_port *p,
2385 struct sci_port *sciport) 2359 struct sci_port *sciport)
@@ -2409,7 +2383,7 @@ static int __devinit sci_probe_single(struct platform_device *dev,
2409 return 0; 2383 return 0;
2410} 2384}
2411 2385
2412static int __devinit sci_probe(struct platform_device *dev) 2386static int sci_probe(struct platform_device *dev)
2413{ 2387{
2414 struct plat_sci_port *p = dev->dev.platform_data; 2388 struct plat_sci_port *p = dev->dev.platform_data;
2415 struct sci_port *sp = &sci_ports[dev->id]; 2389 struct sci_port *sp = &sci_ports[dev->id];
@@ -2466,8 +2440,6 @@ static int sci_resume(struct device *dev)
2466} 2440}
2467 2441
2468static const struct dev_pm_ops sci_dev_pm_ops = { 2442static const struct dev_pm_ops sci_dev_pm_ops = {
2469 .runtime_suspend = sci_runtime_suspend,
2470 .runtime_resume = sci_runtime_resume,
2471 .suspend = sci_suspend, 2443 .suspend = sci_suspend,
2472 .resume = sci_resume, 2444 .resume = sci_resume,
2473}; 2445};
diff --git a/drivers/tty/serial/sirfsoc_uart.c b/drivers/tty/serial/sirfsoc_uart.c
index a9e2bd1ab53..5da5cb96276 100644
--- a/drivers/tty/serial/sirfsoc_uart.c
+++ b/drivers/tty/serial/sirfsoc_uart.c
@@ -727,7 +727,7 @@ static int sirfsoc_uart_resume(struct platform_device *pdev)
727 return 0; 727 return 0;
728} 728}
729 729
730static struct of_device_id sirfsoc_uart_ids[] __devinitdata = { 730static struct of_device_id sirfsoc_uart_ids[] = {
731 { .compatible = "sirf,prima2-uart", }, 731 { .compatible = "sirf,prima2-uart", },
732 {} 732 {}
733}; 733};
@@ -735,7 +735,7 @@ MODULE_DEVICE_TABLE(of, sirfsoc_serial_of_match);
735 735
736static struct platform_driver sirfsoc_uart_driver = { 736static struct platform_driver sirfsoc_uart_driver = {
737 .probe = sirfsoc_uart_probe, 737 .probe = sirfsoc_uart_probe,
738 .remove = __devexit_p(sirfsoc_uart_remove), 738 .remove = sirfsoc_uart_remove,
739 .suspend = sirfsoc_uart_suspend, 739 .suspend = sirfsoc_uart_suspend,
740 .resume = sirfsoc_uart_resume, 740 .resume = sirfsoc_uart_resume,
741 .driver = { 741 .driver = {
diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c
index 505961cfd93..b9bf9c53f7f 100644
--- a/drivers/tty/serial/sunhv.c
+++ b/drivers/tty/serial/sunhv.c
@@ -519,7 +519,7 @@ static struct console sunhv_console = {
519 .data = &sunhv_reg, 519 .data = &sunhv_reg,
520}; 520};
521 521
522static int __devinit hv_probe(struct platform_device *op) 522static int hv_probe(struct platform_device *op)
523{ 523{
524 struct uart_port *port; 524 struct uart_port *port;
525 unsigned long minor; 525 unsigned long minor;
@@ -598,7 +598,7 @@ out_free_port:
598 return err; 598 return err;
599} 599}
600 600
601static int __devexit hv_remove(struct platform_device *dev) 601static int hv_remove(struct platform_device *dev)
602{ 602{
603 struct uart_port *port = dev_get_drvdata(&dev->dev); 603 struct uart_port *port = dev_get_drvdata(&dev->dev);
604 604
@@ -636,7 +636,7 @@ static struct platform_driver hv_driver = {
636 .of_match_table = hv_match, 636 .of_match_table = hv_match,
637 }, 637 },
638 .probe = hv_probe, 638 .probe = hv_probe,
639 .remove = __devexit_p(hv_remove), 639 .remove = hv_remove,
640}; 640};
641 641
642static int __init sunhv_init(void) 642static int __init sunhv_init(void)
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c
index f0d93eb7e6e..bd8b3b63410 100644
--- a/drivers/tty/serial/sunsab.c
+++ b/drivers/tty/serial/sunsab.c
@@ -954,7 +954,7 @@ static inline struct console *SUNSAB_CONSOLE(void)
954#define sunsab_console_init() do { } while (0) 954#define sunsab_console_init() do { } while (0)
955#endif 955#endif
956 956
957static int __devinit sunsab_init_one(struct uart_sunsab_port *up, 957static int sunsab_init_one(struct uart_sunsab_port *up,
958 struct platform_device *op, 958 struct platform_device *op,
959 unsigned long offset, 959 unsigned long offset,
960 int line) 960 int line)
@@ -1007,7 +1007,7 @@ static int __devinit sunsab_init_one(struct uart_sunsab_port *up,
1007 return 0; 1007 return 0;
1008} 1008}
1009 1009
1010static int __devinit sab_probe(struct platform_device *op) 1010static int sab_probe(struct platform_device *op)
1011{ 1011{
1012 static int inst; 1012 static int inst;
1013 struct uart_sunsab_port *up; 1013 struct uart_sunsab_port *up;
@@ -1063,7 +1063,7 @@ out:
1063 return err; 1063 return err;
1064} 1064}
1065 1065
1066static int __devexit sab_remove(struct platform_device *op) 1066static int sab_remove(struct platform_device *op)
1067{ 1067{
1068 struct uart_sunsab_port *up = dev_get_drvdata(&op->dev); 1068 struct uart_sunsab_port *up = dev_get_drvdata(&op->dev);
1069 1069
@@ -1100,7 +1100,7 @@ static struct platform_driver sab_driver = {
1100 .of_match_table = sab_match, 1100 .of_match_table = sab_match,
1101 }, 1101 },
1102 .probe = sab_probe, 1102 .probe = sab_probe,
1103 .remove = __devexit_p(sab_remove), 1103 .remove = sab_remove,
1104}; 1104};
1105 1105
1106static int __init sunsab_init(void) 1106static int __init sunsab_init(void)
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index b97913dcdbf..220da3f9724 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -1185,7 +1185,7 @@ static struct uart_driver sunsu_reg = {
1185 .major = TTY_MAJOR, 1185 .major = TTY_MAJOR,
1186}; 1186};
1187 1187
1188static int __devinit sunsu_kbd_ms_init(struct uart_sunsu_port *up) 1188static int sunsu_kbd_ms_init(struct uart_sunsu_port *up)
1189{ 1189{
1190 int quot, baud; 1190 int quot, baud;
1191#ifdef CONFIG_SERIO 1191#ifdef CONFIG_SERIO
@@ -1391,7 +1391,7 @@ static inline struct console *SUNSU_CONSOLE(void)
1391#define sunsu_serial_console_init() do { } while (0) 1391#define sunsu_serial_console_init() do { } while (0)
1392#endif 1392#endif
1393 1393
1394static enum su_type __devinit su_get_type(struct device_node *dp) 1394static enum su_type su_get_type(struct device_node *dp)
1395{ 1395{
1396 struct device_node *ap = of_find_node_by_path("/aliases"); 1396 struct device_node *ap = of_find_node_by_path("/aliases");
1397 1397
@@ -1412,7 +1412,7 @@ static enum su_type __devinit su_get_type(struct device_node *dp)
1412 return SU_PORT_PORT; 1412 return SU_PORT_PORT;
1413} 1413}
1414 1414
1415static int __devinit su_probe(struct platform_device *op) 1415static int su_probe(struct platform_device *op)
1416{ 1416{
1417 static int inst; 1417 static int inst;
1418 struct device_node *dp = op->dev.of_node; 1418 struct device_node *dp = op->dev.of_node;
@@ -1503,7 +1503,7 @@ out_unmap:
1503 return err; 1503 return err;
1504} 1504}
1505 1505
1506static int __devexit su_remove(struct platform_device *op) 1506static int su_remove(struct platform_device *op)
1507{ 1507{
1508 struct uart_sunsu_port *up = dev_get_drvdata(&op->dev); 1508 struct uart_sunsu_port *up = dev_get_drvdata(&op->dev);
1509 bool kbdms = false; 1509 bool kbdms = false;
@@ -1556,7 +1556,7 @@ static struct platform_driver su_driver = {
1556 .of_match_table = su_match, 1556 .of_match_table = su_match,
1557 }, 1557 },
1558 .probe = su_probe, 1558 .probe = su_probe,
1559 .remove = __devexit_p(su_remove), 1559 .remove = su_remove,
1560}; 1560};
1561 1561
1562static int __init sunsu_init(void) 1562static int __init sunsu_init(void)
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c
index babd9470982..aef4fab957c 100644
--- a/drivers/tty/serial/sunzilog.c
+++ b/drivers/tty/serial/sunzilog.c
@@ -1282,7 +1282,7 @@ static inline struct console *SUNZILOG_CONSOLE(void)
1282#define SUNZILOG_CONSOLE() (NULL) 1282#define SUNZILOG_CONSOLE() (NULL)
1283#endif 1283#endif
1284 1284
1285static void __devinit sunzilog_init_kbdms(struct uart_sunzilog_port *up) 1285static void sunzilog_init_kbdms(struct uart_sunzilog_port *up)
1286{ 1286{
1287 int baud, brg; 1287 int baud, brg;
1288 1288
@@ -1302,7 +1302,7 @@ static void __devinit sunzilog_init_kbdms(struct uart_sunzilog_port *up)
1302} 1302}
1303 1303
1304#ifdef CONFIG_SERIO 1304#ifdef CONFIG_SERIO
1305static void __devinit sunzilog_register_serio(struct uart_sunzilog_port *up) 1305static void sunzilog_register_serio(struct uart_sunzilog_port *up)
1306{ 1306{
1307 struct serio *serio = &up->serio; 1307 struct serio *serio = &up->serio;
1308 1308
@@ -1331,7 +1331,7 @@ static void __devinit sunzilog_register_serio(struct uart_sunzilog_port *up)
1331} 1331}
1332#endif 1332#endif
1333 1333
1334static void __devinit sunzilog_init_hw(struct uart_sunzilog_port *up) 1334static void sunzilog_init_hw(struct uart_sunzilog_port *up)
1335{ 1335{
1336 struct zilog_channel __iomem *channel; 1336 struct zilog_channel __iomem *channel;
1337 unsigned long flags; 1337 unsigned long flags;
@@ -1400,7 +1400,7 @@ static void __devinit sunzilog_init_hw(struct uart_sunzilog_port *up)
1400 1400
1401static int zilog_irq; 1401static int zilog_irq;
1402 1402
1403static int __devinit zs_probe(struct platform_device *op) 1403static int zs_probe(struct platform_device *op)
1404{ 1404{
1405 static int kbm_inst, uart_inst; 1405 static int kbm_inst, uart_inst;
1406 int inst; 1406 int inst;
@@ -1507,7 +1507,7 @@ static int __devinit zs_probe(struct platform_device *op)
1507 return 0; 1507 return 0;
1508} 1508}
1509 1509
1510static void __devexit zs_remove_one(struct uart_sunzilog_port *up) 1510static void zs_remove_one(struct uart_sunzilog_port *up)
1511{ 1511{
1512 if (ZS_IS_KEYB(up) || ZS_IS_MOUSE(up)) { 1512 if (ZS_IS_KEYB(up) || ZS_IS_MOUSE(up)) {
1513#ifdef CONFIG_SERIO 1513#ifdef CONFIG_SERIO
@@ -1517,7 +1517,7 @@ static void __devexit zs_remove_one(struct uart_sunzilog_port *up)
1517 uart_remove_one_port(&sunzilog_reg, &up->port); 1517 uart_remove_one_port(&sunzilog_reg, &up->port);
1518} 1518}
1519 1519
1520static int __devexit zs_remove(struct platform_device *op) 1520static int zs_remove(struct platform_device *op)
1521{ 1521{
1522 struct uart_sunzilog_port *up = dev_get_drvdata(&op->dev); 1522 struct uart_sunzilog_port *up = dev_get_drvdata(&op->dev);
1523 struct zilog_layout __iomem *regs; 1523 struct zilog_layout __iomem *regs;
@@ -1548,7 +1548,7 @@ static struct platform_driver zs_driver = {
1548 .of_match_table = zs_match, 1548 .of_match_table = zs_match,
1549 }, 1549 },
1550 .probe = zs_probe, 1550 .probe = zs_probe,
1551 .remove = __devexit_p(zs_remove), 1551 .remove = zs_remove,
1552}; 1552};
1553 1553
1554static int __init sunzilog_init(void) 1554static int __init sunzilog_init(void)
diff --git a/drivers/tty/serial/timbuart.c b/drivers/tty/serial/timbuart.c
index 70f97491d8f..5be0d68fece 100644
--- a/drivers/tty/serial/timbuart.c
+++ b/drivers/tty/serial/timbuart.c
@@ -426,7 +426,7 @@ static struct uart_driver timbuart_driver = {
426 .nr = 1 426 .nr = 1
427}; 427};
428 428
429static int __devinit timbuart_probe(struct platform_device *dev) 429static int timbuart_probe(struct platform_device *dev)
430{ 430{
431 int err, irq; 431 int err, irq;
432 struct timbuart_port *uart; 432 struct timbuart_port *uart;
@@ -492,7 +492,7 @@ err_mem:
492 return err; 492 return err;
493} 493}
494 494
495static int __devexit timbuart_remove(struct platform_device *dev) 495static int timbuart_remove(struct platform_device *dev)
496{ 496{
497 struct timbuart_port *uart = platform_get_drvdata(dev); 497 struct timbuart_port *uart = platform_get_drvdata(dev);
498 498
@@ -510,7 +510,7 @@ static struct platform_driver timbuart_platform_driver = {
510 .owner = THIS_MODULE, 510 .owner = THIS_MODULE,
511 }, 511 },
512 .probe = timbuart_probe, 512 .probe = timbuart_probe,
513 .remove = __devexit_p(timbuart_remove), 513 .remove = timbuart_remove,
514}; 514};
515 515
516module_platform_driver(timbuart_platform_driver); 516module_platform_driver(timbuart_platform_driver);
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 6579ffdd8e9..89eee43c4e2 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -408,7 +408,7 @@ static void ulite_console_write(struct console *co, const char *s,
408 spin_unlock_irqrestore(&port->lock, flags); 408 spin_unlock_irqrestore(&port->lock, flags);
409} 409}
410 410
411static int __devinit ulite_console_setup(struct console *co, char *options) 411static int ulite_console_setup(struct console *co, char *options)
412{ 412{
413 struct uart_port *port; 413 struct uart_port *port;
414 int baud = 9600; 414 int baud = 9600;
@@ -486,7 +486,7 @@ static struct uart_driver ulite_uart_driver = {
486 * 486 *
487 * Returns: 0 on success, <0 otherwise 487 * Returns: 0 on success, <0 otherwise
488 */ 488 */
489static int __devinit ulite_assign(struct device *dev, int id, u32 base, int irq) 489static int ulite_assign(struct device *dev, int id, u32 base, int irq)
490{ 490{
491 struct uart_port *port; 491 struct uart_port *port;
492 int rc; 492 int rc;
@@ -542,7 +542,7 @@ static int __devinit ulite_assign(struct device *dev, int id, u32 base, int irq)
542 * 542 *
543 * @dev: pointer to device structure 543 * @dev: pointer to device structure
544 */ 544 */
545static int __devexit ulite_release(struct device *dev) 545static int ulite_release(struct device *dev)
546{ 546{
547 struct uart_port *port = dev_get_drvdata(dev); 547 struct uart_port *port = dev_get_drvdata(dev);
548 int rc = 0; 548 int rc = 0;
@@ -562,7 +562,7 @@ static int __devexit ulite_release(struct device *dev)
562 562
563#if defined(CONFIG_OF) 563#if defined(CONFIG_OF)
564/* Match table for of_platform binding */ 564/* Match table for of_platform binding */
565static struct of_device_id ulite_of_match[] __devinitdata = { 565static struct of_device_id ulite_of_match[] = {
566 { .compatible = "xlnx,opb-uartlite-1.00.b", }, 566 { .compatible = "xlnx,opb-uartlite-1.00.b", },
567 { .compatible = "xlnx,xps-uartlite-1.00.a", }, 567 { .compatible = "xlnx,xps-uartlite-1.00.a", },
568 {} 568 {}
@@ -570,7 +570,7 @@ static struct of_device_id ulite_of_match[] __devinitdata = {
570MODULE_DEVICE_TABLE(of, ulite_of_match); 570MODULE_DEVICE_TABLE(of, ulite_of_match);
571#endif /* CONFIG_OF */ 571#endif /* CONFIG_OF */
572 572
573static int __devinit ulite_probe(struct platform_device *pdev) 573static int ulite_probe(struct platform_device *pdev)
574{ 574{
575 struct resource *res, *res2; 575 struct resource *res, *res2;
576 int id = pdev->id; 576 int id = pdev->id;
@@ -593,7 +593,7 @@ static int __devinit ulite_probe(struct platform_device *pdev)
593 return ulite_assign(&pdev->dev, id, res->start, res2->start); 593 return ulite_assign(&pdev->dev, id, res->start, res2->start);
594} 594}
595 595
596static int __devexit ulite_remove(struct platform_device *pdev) 596static int ulite_remove(struct platform_device *pdev)
597{ 597{
598 return ulite_release(&pdev->dev); 598 return ulite_release(&pdev->dev);
599} 599}
@@ -603,7 +603,7 @@ MODULE_ALIAS("platform:uartlite");
603 603
604static struct platform_driver ulite_platform_driver = { 604static struct platform_driver ulite_platform_driver = {
605 .probe = ulite_probe, 605 .probe = ulite_probe,
606 .remove = __devexit_p(ulite_remove), 606 .remove = ulite_remove,
607 .driver = { 607 .driver = {
608 .owner = THIS_MODULE, 608 .owner = THIS_MODULE,
609 .name = "uartlite", 609 .name = "uartlite",
diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_siu.c
index cf0d9485ec0..62ee0166bc6 100644
--- a/drivers/tty/serial/vr41xx_siu.c
+++ b/drivers/tty/serial/vr41xx_siu.c
@@ -823,7 +823,7 @@ static struct console siu_console = {
823 .data = &siu_uart_driver, 823 .data = &siu_uart_driver,
824}; 824};
825 825
826static int __devinit siu_console_init(void) 826static int siu_console_init(void)
827{ 827{
828 struct uart_port *port; 828 struct uart_port *port;
829 int i; 829 int i;
@@ -867,7 +867,7 @@ static struct uart_driver siu_uart_driver = {
867 .cons = SERIAL_VR41XX_CONSOLE, 867 .cons = SERIAL_VR41XX_CONSOLE,
868}; 868};
869 869
870static int __devinit siu_probe(struct platform_device *dev) 870static int siu_probe(struct platform_device *dev)
871{ 871{
872 struct uart_port *port; 872 struct uart_port *port;
873 int num, i, retval; 873 int num, i, retval;
@@ -901,7 +901,7 @@ static int __devinit siu_probe(struct platform_device *dev)
901 return 0; 901 return 0;
902} 902}
903 903
904static int __devexit siu_remove(struct platform_device *dev) 904static int siu_remove(struct platform_device *dev)
905{ 905{
906 struct uart_port *port; 906 struct uart_port *port;
907 int i; 907 int i;
@@ -952,7 +952,7 @@ static int siu_resume(struct platform_device *dev)
952 952
953static struct platform_driver siu_device_driver = { 953static struct platform_driver siu_device_driver = {
954 .probe = siu_probe, 954 .probe = siu_probe,
955 .remove = __devexit_p(siu_remove), 955 .remove = siu_remove,
956 .suspend = siu_suspend, 956 .suspend = siu_suspend,
957 .resume = siu_resume, 957 .resume = siu_resume,
958 .driver = { 958 .driver = {
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 205d4cf4a06..8fd181436a6 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -554,7 +554,7 @@ static struct uart_driver vt8500_uart_driver = {
554 .cons = VT8500_CONSOLE, 554 .cons = VT8500_CONSOLE,
555}; 555};
556 556
557static int __devinit vt8500_serial_probe(struct platform_device *pdev) 557static int vt8500_serial_probe(struct platform_device *pdev)
558{ 558{
559 struct vt8500_port *vt8500_port; 559 struct vt8500_port *vt8500_port;
560 struct resource *mmres, *irqres; 560 struct resource *mmres, *irqres;
@@ -567,10 +567,6 @@ static int __devinit vt8500_serial_probe(struct platform_device *pdev)
567 if (!mmres || !irqres) 567 if (!mmres || !irqres)
568 return -ENODEV; 568 return -ENODEV;
569 569
570 vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL);
571 if (!vt8500_port)
572 return -ENOMEM;
573
574 if (np) 570 if (np)
575 port = of_alias_get_id(np, "serial"); 571 port = of_alias_get_id(np, "serial");
576 if (port > VT8500_MAX_PORTS) 572 if (port > VT8500_MAX_PORTS)
@@ -593,6 +589,10 @@ static int __devinit vt8500_serial_probe(struct platform_device *pdev)
593 return -EBUSY; 589 return -EBUSY;
594 } 590 }
595 591
592 vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL);
593 if (!vt8500_port)
594 return -ENOMEM;
595
596 vt8500_port->uart.type = PORT_VT8500; 596 vt8500_port->uart.type = PORT_VT8500;
597 vt8500_port->uart.iotype = UPIO_MEM; 597 vt8500_port->uart.iotype = UPIO_MEM;
598 vt8500_port->uart.mapbase = mmres->start; 598 vt8500_port->uart.mapbase = mmres->start;
@@ -634,7 +634,7 @@ err:
634 return ret; 634 return ret;
635} 635}
636 636
637static int __devexit vt8500_serial_remove(struct platform_device *pdev) 637static int vt8500_serial_remove(struct platform_device *pdev)
638{ 638{
639 struct vt8500_port *vt8500_port = platform_get_drvdata(pdev); 639 struct vt8500_port *vt8500_port = platform_get_drvdata(pdev);
640 640
@@ -652,7 +652,7 @@ static const struct of_device_id wmt_dt_ids[] = {
652 652
653static struct platform_driver vt8500_platform_driver = { 653static struct platform_driver vt8500_platform_driver = {
654 .probe = vt8500_serial_probe, 654 .probe = vt8500_serial_probe,
655 .remove = __devexit_p(vt8500_serial_remove), 655 .remove = vt8500_serial_remove,
656 .driver = { 656 .driver = {
657 .name = "vt8500_serial", 657 .name = "vt8500_serial",
658 .owner = THIS_MODULE, 658 .owner = THIS_MODULE,
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c
index b627363352e..9ab910370c5 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -939,22 +939,18 @@ static struct uart_driver xuartps_uart_driver = {
939 * 939 *
940 * Returns 0 on success, negative error otherwise 940 * Returns 0 on success, negative error otherwise
941 **/ 941 **/
942static int __devinit xuartps_probe(struct platform_device *pdev) 942static int xuartps_probe(struct platform_device *pdev)
943{ 943{
944 int rc; 944 int rc;
945 struct uart_port *port; 945 struct uart_port *port;
946 struct resource *res, *res2; 946 struct resource *res, *res2;
947 int clk = 0; 947 int clk = 0;
948 948
949#ifdef CONFIG_OF
950 const unsigned int *prop; 949 const unsigned int *prop;
951 950
952 prop = of_get_property(pdev->dev.of_node, "clock", NULL); 951 prop = of_get_property(pdev->dev.of_node, "clock", NULL);
953 if (prop) 952 if (prop)
954 clk = be32_to_cpup(prop); 953 clk = be32_to_cpup(prop);
955#else
956 clk = *((unsigned int *)(pdev->dev.platform_data));
957#endif
958 if (!clk) { 954 if (!clk) {
959 dev_err(&pdev->dev, "no clock specified\n"); 955 dev_err(&pdev->dev, "no clock specified\n");
960 return -ENODEV; 956 return -ENODEV;
@@ -1001,7 +997,7 @@ static int __devinit xuartps_probe(struct platform_device *pdev)
1001 * 997 *
1002 * Returns 0 on success, negative error otherwise 998 * Returns 0 on success, negative error otherwise
1003 **/ 999 **/
1004static int __devexit xuartps_remove(struct platform_device *pdev) 1000static int xuartps_remove(struct platform_device *pdev)
1005{ 1001{
1006 struct uart_port *port = dev_get_drvdata(&pdev->dev); 1002 struct uart_port *port = dev_get_drvdata(&pdev->dev);
1007 int rc = 0; 1003 int rc = 0;
@@ -1044,16 +1040,11 @@ static int xuartps_resume(struct platform_device *pdev)
1044} 1040}
1045 1041
1046/* Match table for of_platform binding */ 1042/* Match table for of_platform binding */
1047 1043static struct of_device_id xuartps_of_match[] = {
1048#ifdef CONFIG_OF
1049static struct of_device_id xuartps_of_match[] __devinitdata = {
1050 { .compatible = "xlnx,xuartps", }, 1044 { .compatible = "xlnx,xuartps", },
1051 {} 1045 {}
1052}; 1046};
1053MODULE_DEVICE_TABLE(of, xuartps_of_match); 1047MODULE_DEVICE_TABLE(of, xuartps_of_match);
1054#else
1055#define xuartps_of_match NULL
1056#endif
1057 1048
1058static struct platform_driver xuartps_platform_driver = { 1049static struct platform_driver xuartps_platform_driver = {
1059 .probe = xuartps_probe, /* Probe method */ 1050 .probe = xuartps_probe, /* Probe method */