diff options
Diffstat (limited to 'drivers/tty/serial/sh-sci.c')
-rw-r--r-- | drivers/tty/serial/sh-sci.c | 431 |
1 files changed, 212 insertions, 219 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 92c91c83edde..eb7958c675a8 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c | |||
@@ -47,7 +47,6 @@ | |||
47 | #include <linux/clk.h> | 47 | #include <linux/clk.h> |
48 | #include <linux/ctype.h> | 48 | #include <linux/ctype.h> |
49 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/list.h> | ||
51 | #include <linux/dmaengine.h> | 50 | #include <linux/dmaengine.h> |
52 | #include <linux/scatterlist.h> | 51 | #include <linux/scatterlist.h> |
53 | #include <linux/slab.h> | 52 | #include <linux/slab.h> |
@@ -65,11 +64,8 @@ | |||
65 | struct sci_port { | 64 | struct sci_port { |
66 | struct uart_port port; | 65 | struct uart_port port; |
67 | 66 | ||
68 | /* Port type */ | 67 | /* Platform configuration */ |
69 | unsigned int type; | 68 | struct plat_sci_port *cfg; |
70 | |||
71 | /* Port IRQs: ERI, RXI, TXI, BRI (optional) */ | ||
72 | unsigned int irqs[SCIx_NR_IRQS]; | ||
73 | 69 | ||
74 | /* Port enable callback */ | 70 | /* Port enable callback */ |
75 | void (*enable)(struct uart_port *port); | 71 | void (*enable)(struct uart_port *port); |
@@ -81,26 +77,15 @@ struct sci_port { | |||
81 | struct timer_list break_timer; | 77 | struct timer_list break_timer; |
82 | int break_flag; | 78 | int break_flag; |
83 | 79 | ||
84 | /* SCSCR initialization */ | ||
85 | unsigned int scscr; | ||
86 | |||
87 | /* SCBRR calculation algo */ | ||
88 | unsigned int scbrr_algo_id; | ||
89 | |||
90 | /* Interface clock */ | 80 | /* Interface clock */ |
91 | struct clk *iclk; | 81 | struct clk *iclk; |
92 | /* Function clock */ | 82 | /* Function clock */ |
93 | struct clk *fclk; | 83 | struct clk *fclk; |
94 | 84 | ||
95 | struct list_head node; | ||
96 | |||
97 | struct dma_chan *chan_tx; | 85 | struct dma_chan *chan_tx; |
98 | struct dma_chan *chan_rx; | 86 | struct dma_chan *chan_rx; |
99 | 87 | ||
100 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 88 | #ifdef CONFIG_SERIAL_SH_SCI_DMA |
101 | struct device *dma_dev; | ||
102 | unsigned int slave_tx; | ||
103 | unsigned int slave_rx; | ||
104 | struct dma_async_tx_descriptor *desc_tx; | 89 | struct dma_async_tx_descriptor *desc_tx; |
105 | struct dma_async_tx_descriptor *desc_rx[2]; | 90 | struct dma_async_tx_descriptor *desc_rx[2]; |
106 | dma_cookie_t cookie_tx; | 91 | dma_cookie_t cookie_tx; |
@@ -117,16 +102,14 @@ struct sci_port { | |||
117 | struct timer_list rx_timer; | 102 | struct timer_list rx_timer; |
118 | unsigned int rx_timeout; | 103 | unsigned int rx_timeout; |
119 | #endif | 104 | #endif |
120 | }; | ||
121 | 105 | ||
122 | struct sh_sci_priv { | 106 | struct notifier_block freq_transition; |
123 | spinlock_t lock; | ||
124 | struct list_head ports; | ||
125 | struct notifier_block clk_nb; | ||
126 | }; | 107 | }; |
127 | 108 | ||
128 | /* Function prototypes */ | 109 | /* Function prototypes */ |
110 | static void sci_start_tx(struct uart_port *port); | ||
129 | static void sci_stop_tx(struct uart_port *port); | 111 | static void sci_stop_tx(struct uart_port *port); |
112 | static void sci_start_rx(struct uart_port *port); | ||
130 | 113 | ||
131 | #define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS | 114 | #define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS |
132 | 115 | ||
@@ -142,12 +125,6 @@ to_sci_port(struct uart_port *uart) | |||
142 | #if defined(CONFIG_CONSOLE_POLL) || defined(CONFIG_SERIAL_SH_SCI_CONSOLE) | 125 | #if defined(CONFIG_CONSOLE_POLL) || defined(CONFIG_SERIAL_SH_SCI_CONSOLE) |
143 | 126 | ||
144 | #ifdef CONFIG_CONSOLE_POLL | 127 | #ifdef CONFIG_CONSOLE_POLL |
145 | static inline void handle_error(struct uart_port *port) | ||
146 | { | ||
147 | /* Clear error flags */ | ||
148 | sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); | ||
149 | } | ||
150 | |||
151 | static int sci_poll_get_char(struct uart_port *port) | 128 | static int sci_poll_get_char(struct uart_port *port) |
152 | { | 129 | { |
153 | unsigned short status; | 130 | unsigned short status; |
@@ -156,7 +133,7 @@ static int sci_poll_get_char(struct uart_port *port) | |||
156 | do { | 133 | do { |
157 | status = sci_in(port, SCxSR); | 134 | status = sci_in(port, SCxSR); |
158 | if (status & SCxSR_ERRORS(port)) { | 135 | if (status & SCxSR_ERRORS(port)) { |
159 | handle_error(port); | 136 | sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); |
160 | continue; | 137 | continue; |
161 | } | 138 | } |
162 | break; | 139 | break; |
@@ -475,7 +452,7 @@ static void sci_transmit_chars(struct uart_port *port) | |||
475 | /* On SH3, SCIF may read end-of-break as a space->mark char */ | 452 | /* On SH3, SCIF may read end-of-break as a space->mark char */ |
476 | #define STEPFN(c) ({int __c = (c); (((__c-1)|(__c)) == -1); }) | 453 | #define STEPFN(c) ({int __c = (c); (((__c-1)|(__c)) == -1); }) |
477 | 454 | ||
478 | static inline void sci_receive_chars(struct uart_port *port) | 455 | static void sci_receive_chars(struct uart_port *port) |
479 | { | 456 | { |
480 | struct sci_port *sci_port = to_sci_port(port); | 457 | struct sci_port *sci_port = to_sci_port(port); |
481 | struct tty_struct *tty = port->state->port.tty; | 458 | struct tty_struct *tty = port->state->port.tty; |
@@ -566,18 +543,20 @@ static inline void sci_receive_chars(struct uart_port *port) | |||
566 | } | 543 | } |
567 | 544 | ||
568 | #define SCI_BREAK_JIFFIES (HZ/20) | 545 | #define SCI_BREAK_JIFFIES (HZ/20) |
569 | /* The sci generates interrupts during the break, | 546 | |
547 | /* | ||
548 | * The sci generates interrupts during the break, | ||
570 | * 1 per millisecond or so during the break period, for 9600 baud. | 549 | * 1 per millisecond or so during the break period, for 9600 baud. |
571 | * So dont bother disabling interrupts. | 550 | * So dont bother disabling interrupts. |
572 | * But dont want more than 1 break event. | 551 | * But dont want more than 1 break event. |
573 | * Use a kernel timer to periodically poll the rx line until | 552 | * Use a kernel timer to periodically poll the rx line until |
574 | * the break is finished. | 553 | * the break is finished. |
575 | */ | 554 | */ |
576 | static void sci_schedule_break_timer(struct sci_port *port) | 555 | static inline void sci_schedule_break_timer(struct sci_port *port) |
577 | { | 556 | { |
578 | port->break_timer.expires = jiffies + SCI_BREAK_JIFFIES; | 557 | mod_timer(&port->break_timer, jiffies + SCI_BREAK_JIFFIES); |
579 | add_timer(&port->break_timer); | ||
580 | } | 558 | } |
559 | |||
581 | /* Ensure that two consecutive samples find the break over. */ | 560 | /* Ensure that two consecutive samples find the break over. */ |
582 | static void sci_break_timer(unsigned long data) | 561 | static void sci_break_timer(unsigned long data) |
583 | { | 562 | { |
@@ -594,7 +573,7 @@ static void sci_break_timer(unsigned long data) | |||
594 | port->break_flag = 0; | 573 | port->break_flag = 0; |
595 | } | 574 | } |
596 | 575 | ||
597 | static inline int sci_handle_errors(struct uart_port *port) | 576 | static int sci_handle_errors(struct uart_port *port) |
598 | { | 577 | { |
599 | int copied = 0; | 578 | int copied = 0; |
600 | unsigned short status = sci_in(port, SCxSR); | 579 | unsigned short status = sci_in(port, SCxSR); |
@@ -650,7 +629,7 @@ static inline int sci_handle_errors(struct uart_port *port) | |||
650 | return copied; | 629 | return copied; |
651 | } | 630 | } |
652 | 631 | ||
653 | static inline int sci_handle_fifo_overrun(struct uart_port *port) | 632 | static int sci_handle_fifo_overrun(struct uart_port *port) |
654 | { | 633 | { |
655 | struct tty_struct *tty = port->state->port.tty; | 634 | struct tty_struct *tty = port->state->port.tty; |
656 | int copied = 0; | 635 | int copied = 0; |
@@ -671,7 +650,7 @@ static inline int sci_handle_fifo_overrun(struct uart_port *port) | |||
671 | return copied; | 650 | return copied; |
672 | } | 651 | } |
673 | 652 | ||
674 | static inline int sci_handle_breaks(struct uart_port *port) | 653 | static int sci_handle_breaks(struct uart_port *port) |
675 | { | 654 | { |
676 | int copied = 0; | 655 | int copied = 0; |
677 | unsigned short status = sci_in(port, SCxSR); | 656 | unsigned short status = sci_in(port, SCxSR); |
@@ -794,7 +773,7 @@ static inline unsigned long port_rx_irq_mask(struct uart_port *port) | |||
794 | * it's unset, it's logically inferred that there's no point in | 773 | * it's unset, it's logically inferred that there's no point in |
795 | * testing for it. | 774 | * testing for it. |
796 | */ | 775 | */ |
797 | return SCSCR_RIE | (to_sci_port(port)->scscr & SCSCR_REIE); | 776 | return SCSCR_RIE | (to_sci_port(port)->cfg->scscr & SCSCR_REIE); |
798 | } | 777 | } |
799 | 778 | ||
800 | static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) | 779 | static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) |
@@ -839,17 +818,18 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) | |||
839 | static int sci_notifier(struct notifier_block *self, | 818 | static int sci_notifier(struct notifier_block *self, |
840 | unsigned long phase, void *p) | 819 | unsigned long phase, void *p) |
841 | { | 820 | { |
842 | struct sh_sci_priv *priv = container_of(self, | ||
843 | struct sh_sci_priv, clk_nb); | ||
844 | struct sci_port *sci_port; | 821 | struct sci_port *sci_port; |
845 | unsigned long flags; | 822 | unsigned long flags; |
846 | 823 | ||
824 | sci_port = container_of(self, struct sci_port, freq_transition); | ||
825 | |||
847 | if ((phase == CPUFREQ_POSTCHANGE) || | 826 | if ((phase == CPUFREQ_POSTCHANGE) || |
848 | (phase == CPUFREQ_RESUMECHANGE)) { | 827 | (phase == CPUFREQ_RESUMECHANGE)) { |
849 | spin_lock_irqsave(&priv->lock, flags); | 828 | struct uart_port *port = &sci_port->port; |
850 | list_for_each_entry(sci_port, &priv->ports, node) | 829 | |
851 | sci_port->port.uartclk = clk_get_rate(sci_port->iclk); | 830 | spin_lock_irqsave(&port->lock, flags); |
852 | spin_unlock_irqrestore(&priv->lock, flags); | 831 | port->uartclk = clk_get_rate(sci_port->iclk); |
832 | spin_unlock_irqrestore(&port->lock, flags); | ||
853 | } | 833 | } |
854 | 834 | ||
855 | return NOTIFY_OK; | 835 | return NOTIFY_OK; |
@@ -882,21 +862,21 @@ static int sci_request_irq(struct sci_port *port) | |||
882 | const char *desc[] = { "SCI Receive Error", "SCI Receive Data Full", | 862 | const char *desc[] = { "SCI Receive Error", "SCI Receive Data Full", |
883 | "SCI Transmit Data Empty", "SCI Break" }; | 863 | "SCI Transmit Data Empty", "SCI Break" }; |
884 | 864 | ||
885 | if (port->irqs[0] == port->irqs[1]) { | 865 | if (port->cfg->irqs[0] == port->cfg->irqs[1]) { |
886 | if (unlikely(!port->irqs[0])) | 866 | if (unlikely(!port->cfg->irqs[0])) |
887 | return -ENODEV; | 867 | return -ENODEV; |
888 | 868 | ||
889 | if (request_irq(port->irqs[0], sci_mpxed_interrupt, | 869 | if (request_irq(port->cfg->irqs[0], sci_mpxed_interrupt, |
890 | IRQF_DISABLED, "sci", port)) { | 870 | IRQF_DISABLED, "sci", port)) { |
891 | dev_err(port->port.dev, "Can't allocate IRQ\n"); | 871 | dev_err(port->port.dev, "Can't allocate IRQ\n"); |
892 | return -ENODEV; | 872 | return -ENODEV; |
893 | } | 873 | } |
894 | } else { | 874 | } else { |
895 | for (i = 0; i < ARRAY_SIZE(handlers); i++) { | 875 | for (i = 0; i < ARRAY_SIZE(handlers); i++) { |
896 | if (unlikely(!port->irqs[i])) | 876 | if (unlikely(!port->cfg->irqs[i])) |
897 | continue; | 877 | continue; |
898 | 878 | ||
899 | if (request_irq(port->irqs[i], handlers[i], | 879 | if (request_irq(port->cfg->irqs[i], handlers[i], |
900 | IRQF_DISABLED, desc[i], port)) { | 880 | IRQF_DISABLED, desc[i], port)) { |
901 | dev_err(port->port.dev, "Can't allocate IRQ\n"); | 881 | dev_err(port->port.dev, "Can't allocate IRQ\n"); |
902 | return -ENODEV; | 882 | return -ENODEV; |
@@ -911,14 +891,14 @@ static void sci_free_irq(struct sci_port *port) | |||
911 | { | 891 | { |
912 | int i; | 892 | int i; |
913 | 893 | ||
914 | if (port->irqs[0] == port->irqs[1]) | 894 | if (port->cfg->irqs[0] == port->cfg->irqs[1]) |
915 | free_irq(port->irqs[0], port); | 895 | free_irq(port->cfg->irqs[0], port); |
916 | else { | 896 | else { |
917 | for (i = 0; i < ARRAY_SIZE(port->irqs); i++) { | 897 | for (i = 0; i < ARRAY_SIZE(port->cfg->irqs); i++) { |
918 | if (!port->irqs[i]) | 898 | if (!port->cfg->irqs[i]) |
919 | continue; | 899 | continue; |
920 | 900 | ||
921 | free_irq(port->irqs[i], port); | 901 | free_irq(port->cfg->irqs[i], port); |
922 | } | 902 | } |
923 | } | 903 | } |
924 | } | 904 | } |
@@ -1037,9 +1017,6 @@ static void sci_dma_rx_complete(void *arg) | |||
1037 | schedule_work(&s->work_rx); | 1017 | schedule_work(&s->work_rx); |
1038 | } | 1018 | } |
1039 | 1019 | ||
1040 | static void sci_start_rx(struct uart_port *port); | ||
1041 | static void sci_start_tx(struct uart_port *port); | ||
1042 | |||
1043 | static void sci_rx_dma_release(struct sci_port *s, bool enable_pio) | 1020 | static void sci_rx_dma_release(struct sci_port *s, bool enable_pio) |
1044 | { | 1021 | { |
1045 | struct dma_chan *chan = s->chan_rx; | 1022 | struct dma_chan *chan = s->chan_rx; |
@@ -1325,7 +1302,7 @@ static void rx_timer_fn(unsigned long arg) | |||
1325 | 1302 | ||
1326 | if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { | 1303 | if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { |
1327 | scr &= ~0x4000; | 1304 | scr &= ~0x4000; |
1328 | enable_irq(s->irqs[1]); | 1305 | enable_irq(s->cfg->irqs[1]); |
1329 | } | 1306 | } |
1330 | sci_out(port, SCSCR, scr | SCSCR_RIE); | 1307 | sci_out(port, SCSCR, scr | SCSCR_RIE); |
1331 | dev_dbg(port->dev, "DMA Rx timed out\n"); | 1308 | dev_dbg(port->dev, "DMA Rx timed out\n"); |
@@ -1341,9 +1318,9 @@ static void sci_request_dma(struct uart_port *port) | |||
1341 | int nent; | 1318 | int nent; |
1342 | 1319 | ||
1343 | dev_dbg(port->dev, "%s: port %d DMA %p\n", __func__, | 1320 | dev_dbg(port->dev, "%s: port %d DMA %p\n", __func__, |
1344 | port->line, s->dma_dev); | 1321 | port->line, s->cfg->dma_dev); |
1345 | 1322 | ||
1346 | if (!s->dma_dev) | 1323 | if (!s->cfg->dma_dev) |
1347 | return; | 1324 | return; |
1348 | 1325 | ||
1349 | dma_cap_zero(mask); | 1326 | dma_cap_zero(mask); |
@@ -1352,8 +1329,8 @@ static void sci_request_dma(struct uart_port *port) | |||
1352 | param = &s->param_tx; | 1329 | param = &s->param_tx; |
1353 | 1330 | ||
1354 | /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_TX */ | 1331 | /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_TX */ |
1355 | param->slave_id = s->slave_tx; | 1332 | param->slave_id = s->cfg->dma_slave_tx; |
1356 | param->dma_dev = s->dma_dev; | 1333 | param->dma_dev = s->cfg->dma_dev; |
1357 | 1334 | ||
1358 | s->cookie_tx = -EINVAL; | 1335 | s->cookie_tx = -EINVAL; |
1359 | chan = dma_request_channel(mask, filter, param); | 1336 | chan = dma_request_channel(mask, filter, param); |
@@ -1381,8 +1358,8 @@ static void sci_request_dma(struct uart_port *port) | |||
1381 | param = &s->param_rx; | 1358 | param = &s->param_rx; |
1382 | 1359 | ||
1383 | /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_RX */ | 1360 | /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_RX */ |
1384 | param->slave_id = s->slave_rx; | 1361 | param->slave_id = s->cfg->dma_slave_rx; |
1385 | param->dma_dev = s->dma_dev; | 1362 | param->dma_dev = s->cfg->dma_dev; |
1386 | 1363 | ||
1387 | chan = dma_request_channel(mask, filter, param); | 1364 | chan = dma_request_channel(mask, filter, param); |
1388 | dev_dbg(port->dev, "%s: RX: got channel %p\n", __func__, chan); | 1365 | dev_dbg(port->dev, "%s: RX: got channel %p\n", __func__, chan); |
@@ -1427,7 +1404,7 @@ static void sci_free_dma(struct uart_port *port) | |||
1427 | { | 1404 | { |
1428 | struct sci_port *s = to_sci_port(port); | 1405 | struct sci_port *s = to_sci_port(port); |
1429 | 1406 | ||
1430 | if (!s->dma_dev) | 1407 | if (!s->cfg->dma_dev) |
1431 | return; | 1408 | return; |
1432 | 1409 | ||
1433 | if (s->chan_tx) | 1410 | if (s->chan_tx) |
@@ -1435,21 +1412,32 @@ static void sci_free_dma(struct uart_port *port) | |||
1435 | if (s->chan_rx) | 1412 | if (s->chan_rx) |
1436 | sci_rx_dma_release(s, false); | 1413 | sci_rx_dma_release(s, false); |
1437 | } | 1414 | } |
1415 | #else | ||
1416 | static inline void sci_request_dma(struct uart_port *port) | ||
1417 | { | ||
1418 | } | ||
1419 | |||
1420 | static inline void sci_free_dma(struct uart_port *port) | ||
1421 | { | ||
1422 | } | ||
1438 | #endif | 1423 | #endif |
1439 | 1424 | ||
1440 | static int sci_startup(struct uart_port *port) | 1425 | static int sci_startup(struct uart_port *port) |
1441 | { | 1426 | { |
1442 | struct sci_port *s = to_sci_port(port); | 1427 | struct sci_port *s = to_sci_port(port); |
1428 | int ret; | ||
1443 | 1429 | ||
1444 | dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); | 1430 | dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); |
1445 | 1431 | ||
1446 | if (s->enable) | 1432 | if (s->enable) |
1447 | s->enable(port); | 1433 | s->enable(port); |
1448 | 1434 | ||
1449 | sci_request_irq(s); | 1435 | ret = sci_request_irq(s); |
1450 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 1436 | if (unlikely(ret < 0)) |
1437 | return ret; | ||
1438 | |||
1451 | sci_request_dma(port); | 1439 | sci_request_dma(port); |
1452 | #endif | 1440 | |
1453 | sci_start_tx(port); | 1441 | sci_start_tx(port); |
1454 | sci_start_rx(port); | 1442 | sci_start_rx(port); |
1455 | 1443 | ||
@@ -1464,9 +1452,8 @@ static void sci_shutdown(struct uart_port *port) | |||
1464 | 1452 | ||
1465 | sci_stop_rx(port); | 1453 | sci_stop_rx(port); |
1466 | sci_stop_tx(port); | 1454 | sci_stop_tx(port); |
1467 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 1455 | |
1468 | sci_free_dma(port); | 1456 | sci_free_dma(port); |
1469 | #endif | ||
1470 | sci_free_irq(s); | 1457 | sci_free_irq(s); |
1471 | 1458 | ||
1472 | if (s->disable) | 1459 | if (s->disable) |
@@ -1491,6 +1478,7 @@ static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, | |||
1491 | 1478 | ||
1492 | /* Warn, but use a safe default */ | 1479 | /* Warn, but use a safe default */ |
1493 | WARN_ON(1); | 1480 | WARN_ON(1); |
1481 | |||
1494 | return ((freq + 16 * bps) / (32 * bps) - 1); | 1482 | return ((freq + 16 * bps) / (32 * bps) - 1); |
1495 | } | 1483 | } |
1496 | 1484 | ||
@@ -1514,7 +1502,10 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1514 | 1502 | ||
1515 | baud = uart_get_baud_rate(port, termios, old, 0, max_baud); | 1503 | baud = uart_get_baud_rate(port, termios, old, 0, max_baud); |
1516 | if (likely(baud && port->uartclk)) | 1504 | if (likely(baud && port->uartclk)) |
1517 | t = sci_scbrr_calc(s->scbrr_algo_id, baud, port->uartclk); | 1505 | t = sci_scbrr_calc(s->cfg->scbrr_algo_id, baud, port->uartclk); |
1506 | |||
1507 | if (s->enable) | ||
1508 | s->enable(port); | ||
1518 | 1509 | ||
1519 | do { | 1510 | do { |
1520 | status = sci_in(port, SCxSR); | 1511 | status = sci_in(port, SCxSR); |
@@ -1526,6 +1517,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1526 | sci_out(port, SCFCR, scfcr | SCFCR_RFRST | SCFCR_TFRST); | 1517 | sci_out(port, SCFCR, scfcr | SCFCR_RFRST | SCFCR_TFRST); |
1527 | 1518 | ||
1528 | smr_val = sci_in(port, SCSMR) & 3; | 1519 | smr_val = sci_in(port, SCSMR) & 3; |
1520 | |||
1529 | if ((termios->c_cflag & CSIZE) == CS7) | 1521 | if ((termios->c_cflag & CSIZE) == CS7) |
1530 | smr_val |= 0x40; | 1522 | smr_val |= 0x40; |
1531 | if (termios->c_cflag & PARENB) | 1523 | if (termios->c_cflag & PARENB) |
@@ -1540,7 +1532,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1540 | sci_out(port, SCSMR, smr_val); | 1532 | sci_out(port, SCSMR, smr_val); |
1541 | 1533 | ||
1542 | dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t, | 1534 | dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t, |
1543 | s->scscr); | 1535 | s->cfg->scscr); |
1544 | 1536 | ||
1545 | if (t > 0) { | 1537 | if (t > 0) { |
1546 | if (t >= 256) { | 1538 | if (t >= 256) { |
@@ -1556,7 +1548,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1556 | sci_init_pins(port, termios->c_cflag); | 1548 | sci_init_pins(port, termios->c_cflag); |
1557 | sci_out(port, SCFCR, scfcr | ((termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0)); | 1549 | sci_out(port, SCFCR, scfcr | ((termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0)); |
1558 | 1550 | ||
1559 | sci_out(port, SCSCR, s->scscr); | 1551 | sci_out(port, SCSCR, s->cfg->scscr); |
1560 | 1552 | ||
1561 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 1553 | #ifdef CONFIG_SERIAL_SH_SCI_DMA |
1562 | /* | 1554 | /* |
@@ -1582,6 +1574,9 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1582 | 1574 | ||
1583 | if ((termios->c_cflag & CREAD) != 0) | 1575 | if ((termios->c_cflag & CREAD) != 0) |
1584 | sci_start_rx(port); | 1576 | sci_start_rx(port); |
1577 | |||
1578 | if (s->disable) | ||
1579 | s->disable(port); | ||
1585 | } | 1580 | } |
1586 | 1581 | ||
1587 | static const char *sci_type(struct uart_port *port) | 1582 | static const char *sci_type(struct uart_port *port) |
@@ -1602,31 +1597,33 @@ static const char *sci_type(struct uart_port *port) | |||
1602 | return NULL; | 1597 | return NULL; |
1603 | } | 1598 | } |
1604 | 1599 | ||
1605 | static void sci_release_port(struct uart_port *port) | 1600 | static inline unsigned long sci_port_size(struct uart_port *port) |
1606 | { | 1601 | { |
1607 | /* Nothing here yet .. */ | 1602 | /* |
1608 | } | 1603 | * Pick an arbitrary size that encapsulates all of the base |
1609 | 1604 | * registers by default. This can be optimized later, or derived | |
1610 | static int sci_request_port(struct uart_port *port) | 1605 | * from platform resource data at such a time that ports begin to |
1611 | { | 1606 | * behave more erratically. |
1612 | /* Nothing here yet .. */ | 1607 | */ |
1613 | return 0; | 1608 | return 64; |
1614 | } | 1609 | } |
1615 | 1610 | ||
1616 | static void sci_config_port(struct uart_port *port, int flags) | 1611 | static int sci_remap_port(struct uart_port *port) |
1617 | { | 1612 | { |
1618 | struct sci_port *s = to_sci_port(port); | 1613 | unsigned long size = sci_port_size(port); |
1619 | |||
1620 | port->type = s->type; | ||
1621 | 1614 | ||
1615 | /* | ||
1616 | * Nothing to do if there's already an established membase. | ||
1617 | */ | ||
1622 | if (port->membase) | 1618 | if (port->membase) |
1623 | return; | 1619 | return 0; |
1624 | 1620 | ||
1625 | if (port->flags & UPF_IOREMAP) { | 1621 | if (port->flags & UPF_IOREMAP) { |
1626 | port->membase = ioremap_nocache(port->mapbase, 0x40); | 1622 | port->membase = ioremap_nocache(port->mapbase, size); |
1627 | 1623 | if (unlikely(!port->membase)) { | |
1628 | if (IS_ERR(port->membase)) | ||
1629 | dev_err(port->dev, "can't remap port#%d\n", port->line); | 1624 | dev_err(port->dev, "can't remap port#%d\n", port->line); |
1625 | return -ENXIO; | ||
1626 | } | ||
1630 | } else { | 1627 | } else { |
1631 | /* | 1628 | /* |
1632 | * For the simple (and majority of) cases where we don't | 1629 | * For the simple (and majority of) cases where we don't |
@@ -1635,13 +1632,54 @@ static void sci_config_port(struct uart_port *port, int flags) | |||
1635 | */ | 1632 | */ |
1636 | port->membase = (void __iomem *)port->mapbase; | 1633 | port->membase = (void __iomem *)port->mapbase; |
1637 | } | 1634 | } |
1635 | |||
1636 | return 0; | ||
1637 | } | ||
1638 | |||
1639 | static void sci_release_port(struct uart_port *port) | ||
1640 | { | ||
1641 | if (port->flags & UPF_IOREMAP) { | ||
1642 | iounmap(port->membase); | ||
1643 | port->membase = NULL; | ||
1644 | } | ||
1645 | |||
1646 | release_mem_region(port->mapbase, sci_port_size(port)); | ||
1647 | } | ||
1648 | |||
1649 | static int sci_request_port(struct uart_port *port) | ||
1650 | { | ||
1651 | unsigned long size = sci_port_size(port); | ||
1652 | struct resource *res; | ||
1653 | int ret; | ||
1654 | |||
1655 | res = request_mem_region(port->mapbase, size, dev_name(port->dev)); | ||
1656 | if (unlikely(res == NULL)) | ||
1657 | return -EBUSY; | ||
1658 | |||
1659 | ret = sci_remap_port(port); | ||
1660 | if (unlikely(ret != 0)) { | ||
1661 | release_resource(res); | ||
1662 | return ret; | ||
1663 | } | ||
1664 | |||
1665 | return 0; | ||
1666 | } | ||
1667 | |||
1668 | static void sci_config_port(struct uart_port *port, int flags) | ||
1669 | { | ||
1670 | if (flags & UART_CONFIG_TYPE) { | ||
1671 | struct sci_port *sport = to_sci_port(port); | ||
1672 | |||
1673 | port->type = sport->cfg->type; | ||
1674 | sci_request_port(port); | ||
1675 | } | ||
1638 | } | 1676 | } |
1639 | 1677 | ||
1640 | static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) | 1678 | static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) |
1641 | { | 1679 | { |
1642 | struct sci_port *s = to_sci_port(port); | 1680 | struct sci_port *s = to_sci_port(port); |
1643 | 1681 | ||
1644 | if (ser->irq != s->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs) | 1682 | if (ser->irq != s->cfg->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs) |
1645 | return -EINVAL; | 1683 | return -EINVAL; |
1646 | if (ser->baud_base < 2400) | 1684 | if (ser->baud_base < 2400) |
1647 | /* No paper tape reader for Mitch.. */ | 1685 | /* No paper tape reader for Mitch.. */ |
@@ -1726,36 +1764,29 @@ static int __devinit sci_init_single(struct platform_device *dev, | |||
1726 | sci_port->break_timer.function = sci_break_timer; | 1764 | sci_port->break_timer.function = sci_break_timer; |
1727 | init_timer(&sci_port->break_timer); | 1765 | init_timer(&sci_port->break_timer); |
1728 | 1766 | ||
1729 | port->mapbase = p->mapbase; | 1767 | sci_port->cfg = p; |
1730 | port->membase = p->membase; | ||
1731 | 1768 | ||
1732 | port->irq = p->irqs[SCIx_TXI_IRQ]; | 1769 | port->mapbase = p->mapbase; |
1770 | port->type = p->type; | ||
1733 | port->flags = p->flags; | 1771 | port->flags = p->flags; |
1734 | sci_port->type = port->type = p->type; | ||
1735 | sci_port->scscr = p->scscr; | ||
1736 | sci_port->scbrr_algo_id = p->scbrr_algo_id; | ||
1737 | 1772 | ||
1738 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 1773 | /* |
1739 | sci_port->dma_dev = p->dma_dev; | 1774 | * The UART port needs an IRQ value, so we peg this to the TX IRQ |
1740 | sci_port->slave_tx = p->dma_slave_tx; | 1775 | * for the multi-IRQ ports, which is where we are primarily |
1741 | sci_port->slave_rx = p->dma_slave_rx; | 1776 | * concerned with the shutdown path synchronization. |
1777 | * | ||
1778 | * For the muxed case there's nothing more to do. | ||
1779 | */ | ||
1780 | port->irq = p->irqs[SCIx_TXI_IRQ]; | ||
1742 | 1781 | ||
1743 | dev_dbg(port->dev, "%s: DMA device %p, tx %d, rx %d\n", __func__, | 1782 | if (p->dma_dev) |
1744 | p->dma_dev, p->dma_slave_tx, p->dma_slave_rx); | 1783 | dev_dbg(port->dev, "DMA device %p, tx %d, rx %d\n", |
1745 | #endif | 1784 | p->dma_dev, p->dma_slave_tx, p->dma_slave_rx); |
1746 | 1785 | ||
1747 | memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); | ||
1748 | return 0; | 1786 | return 0; |
1749 | } | 1787 | } |
1750 | 1788 | ||
1751 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE | 1789 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE |
1752 | static struct tty_driver *serial_console_device(struct console *co, int *index) | ||
1753 | { | ||
1754 | struct uart_driver *p = &sci_uart_driver; | ||
1755 | *index = co->index; | ||
1756 | return p->tty_driver; | ||
1757 | } | ||
1758 | |||
1759 | static void serial_console_putchar(struct uart_port *port, int ch) | 1790 | static void serial_console_putchar(struct uart_port *port, int ch) |
1760 | { | 1791 | { |
1761 | sci_poll_put_char(port, ch); | 1792 | sci_poll_put_char(port, ch); |
@@ -1768,8 +1799,8 @@ static void serial_console_putchar(struct uart_port *port, int ch) | |||
1768 | static void serial_console_write(struct console *co, const char *s, | 1799 | static void serial_console_write(struct console *co, const char *s, |
1769 | unsigned count) | 1800 | unsigned count) |
1770 | { | 1801 | { |
1771 | struct uart_port *port = co->data; | 1802 | struct sci_port *sci_port = &sci_ports[co->index]; |
1772 | struct sci_port *sci_port = to_sci_port(port); | 1803 | struct uart_port *port = &sci_port->port; |
1773 | unsigned short bits; | 1804 | unsigned short bits; |
1774 | 1805 | ||
1775 | if (sci_port->enable) | 1806 | if (sci_port->enable) |
@@ -1797,32 +1828,17 @@ static int __devinit serial_console_setup(struct console *co, char *options) | |||
1797 | int ret; | 1828 | int ret; |
1798 | 1829 | ||
1799 | /* | 1830 | /* |
1800 | * Check whether an invalid uart number has been specified, and | 1831 | * Refuse to handle any bogus ports. |
1801 | * if so, search for the first available port that does have | ||
1802 | * console support. | ||
1803 | */ | ||
1804 | if (co->index >= SCI_NPORTS) | ||
1805 | co->index = 0; | ||
1806 | |||
1807 | if (co->data) { | ||
1808 | port = co->data; | ||
1809 | sci_port = to_sci_port(port); | ||
1810 | } else { | ||
1811 | sci_port = &sci_ports[co->index]; | ||
1812 | port = &sci_port->port; | ||
1813 | co->data = port; | ||
1814 | } | ||
1815 | |||
1816 | /* | ||
1817 | * Also need to check port->type, we don't actually have any | ||
1818 | * UPIO_PORT ports, but uart_report_port() handily misreports | ||
1819 | * it anyways if we don't have a port available by the time this is | ||
1820 | * called. | ||
1821 | */ | 1832 | */ |
1822 | if (!port->type) | 1833 | if (co->index < 0 || co->index >= SCI_NPORTS) |
1823 | return -ENODEV; | 1834 | return -ENODEV; |
1824 | 1835 | ||
1825 | sci_config_port(port, 0); | 1836 | sci_port = &sci_ports[co->index]; |
1837 | port = &sci_port->port; | ||
1838 | |||
1839 | ret = sci_remap_port(port); | ||
1840 | if (unlikely(ret != 0)) | ||
1841 | return ret; | ||
1826 | 1842 | ||
1827 | if (sci_port->enable) | 1843 | if (sci_port->enable) |
1828 | sci_port->enable(port); | 1844 | sci_port->enable(port); |
@@ -1842,11 +1858,12 @@ static int __devinit serial_console_setup(struct console *co, char *options) | |||
1842 | 1858 | ||
1843 | static struct console serial_console = { | 1859 | static struct console serial_console = { |
1844 | .name = "ttySC", | 1860 | .name = "ttySC", |
1845 | .device = serial_console_device, | 1861 | .device = uart_console_device, |
1846 | .write = serial_console_write, | 1862 | .write = serial_console_write, |
1847 | .setup = serial_console_setup, | 1863 | .setup = serial_console_setup, |
1848 | .flags = CON_PRINTBUFFER, | 1864 | .flags = CON_PRINTBUFFER, |
1849 | .index = -1, | 1865 | .index = -1, |
1866 | .data = &sci_uart_driver, | ||
1850 | }; | 1867 | }; |
1851 | 1868 | ||
1852 | static int __init sci_console_init(void) | 1869 | static int __init sci_console_init(void) |
@@ -1856,14 +1873,39 @@ static int __init sci_console_init(void) | |||
1856 | } | 1873 | } |
1857 | console_initcall(sci_console_init); | 1874 | console_initcall(sci_console_init); |
1858 | 1875 | ||
1859 | static struct sci_port early_serial_port; | ||
1860 | static struct console early_serial_console = { | 1876 | static struct console early_serial_console = { |
1861 | .name = "early_ttySC", | 1877 | .name = "early_ttySC", |
1862 | .write = serial_console_write, | 1878 | .write = serial_console_write, |
1863 | .flags = CON_PRINTBUFFER, | 1879 | .flags = CON_PRINTBUFFER, |
1880 | .index = -1, | ||
1864 | }; | 1881 | }; |
1882 | |||
1865 | static char early_serial_buf[32]; | 1883 | static char early_serial_buf[32]; |
1866 | 1884 | ||
1885 | static int __devinit sci_probe_earlyprintk(struct platform_device *pdev) | ||
1886 | { | ||
1887 | struct plat_sci_port *cfg = pdev->dev.platform_data; | ||
1888 | |||
1889 | if (early_serial_console.data) | ||
1890 | return -EEXIST; | ||
1891 | |||
1892 | early_serial_console.index = pdev->id; | ||
1893 | |||
1894 | sci_init_single(NULL, &sci_ports[pdev->id], pdev->id, cfg); | ||
1895 | |||
1896 | serial_console_setup(&early_serial_console, early_serial_buf); | ||
1897 | |||
1898 | if (!strstr(early_serial_buf, "keep")) | ||
1899 | early_serial_console.flags |= CON_BOOT; | ||
1900 | |||
1901 | register_console(&early_serial_console); | ||
1902 | return 0; | ||
1903 | } | ||
1904 | #else | ||
1905 | static inline int __devinit sci_probe_earlyprintk(struct platform_device *pdev) | ||
1906 | { | ||
1907 | return -EINVAL; | ||
1908 | } | ||
1867 | #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ | 1909 | #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ |
1868 | 1910 | ||
1869 | #if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) | 1911 | #if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) |
@@ -1885,24 +1927,18 @@ static struct uart_driver sci_uart_driver = { | |||
1885 | .cons = SCI_CONSOLE, | 1927 | .cons = SCI_CONSOLE, |
1886 | }; | 1928 | }; |
1887 | 1929 | ||
1888 | |||
1889 | static int sci_remove(struct platform_device *dev) | 1930 | static int sci_remove(struct platform_device *dev) |
1890 | { | 1931 | { |
1891 | struct sh_sci_priv *priv = platform_get_drvdata(dev); | 1932 | struct sci_port *port = platform_get_drvdata(dev); |
1892 | struct sci_port *p; | ||
1893 | unsigned long flags; | ||
1894 | 1933 | ||
1895 | cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); | 1934 | cpufreq_unregister_notifier(&port->freq_transition, |
1935 | CPUFREQ_TRANSITION_NOTIFIER); | ||
1896 | 1936 | ||
1897 | spin_lock_irqsave(&priv->lock, flags); | 1937 | uart_remove_one_port(&sci_uart_driver, &port->port); |
1898 | list_for_each_entry(p, &priv->ports, node) { | 1938 | |
1899 | uart_remove_one_port(&sci_uart_driver, &p->port); | 1939 | clk_put(port->iclk); |
1900 | clk_put(p->iclk); | 1940 | clk_put(port->fclk); |
1901 | clk_put(p->fclk); | ||
1902 | } | ||
1903 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1904 | 1941 | ||
1905 | kfree(priv); | ||
1906 | return 0; | 1942 | return 0; |
1907 | } | 1943 | } |
1908 | 1944 | ||
@@ -1911,8 +1947,6 @@ static int __devinit sci_probe_single(struct platform_device *dev, | |||
1911 | struct plat_sci_port *p, | 1947 | struct plat_sci_port *p, |
1912 | struct sci_port *sciport) | 1948 | struct sci_port *sciport) |
1913 | { | 1949 | { |
1914 | struct sh_sci_priv *priv = platform_get_drvdata(dev); | ||
1915 | unsigned long flags; | ||
1916 | int ret; | 1950 | int ret; |
1917 | 1951 | ||
1918 | /* Sanity check */ | 1952 | /* Sanity check */ |
@@ -1929,68 +1963,35 @@ static int __devinit sci_probe_single(struct platform_device *dev, | |||
1929 | if (ret) | 1963 | if (ret) |
1930 | return ret; | 1964 | return ret; |
1931 | 1965 | ||
1932 | ret = uart_add_one_port(&sci_uart_driver, &sciport->port); | 1966 | return uart_add_one_port(&sci_uart_driver, &sciport->port); |
1933 | if (ret) | ||
1934 | return ret; | ||
1935 | |||
1936 | INIT_LIST_HEAD(&sciport->node); | ||
1937 | |||
1938 | spin_lock_irqsave(&priv->lock, flags); | ||
1939 | list_add(&sciport->node, &priv->ports); | ||
1940 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1941 | |||
1942 | return 0; | ||
1943 | } | 1967 | } |
1944 | 1968 | ||
1945 | /* | ||
1946 | * Register a set of serial devices attached to a platform device. The | ||
1947 | * list is terminated with a zero flags entry, which means we expect | ||
1948 | * all entries to have at least UPF_BOOT_AUTOCONF set. Platforms that need | ||
1949 | * remapping (such as sh64) should also set UPF_IOREMAP. | ||
1950 | */ | ||
1951 | static int __devinit sci_probe(struct platform_device *dev) | 1969 | static int __devinit sci_probe(struct platform_device *dev) |
1952 | { | 1970 | { |
1953 | struct plat_sci_port *p = dev->dev.platform_data; | 1971 | struct plat_sci_port *p = dev->dev.platform_data; |
1954 | struct sh_sci_priv *priv; | 1972 | struct sci_port *sp = &sci_ports[dev->id]; |
1955 | int i, ret = -EINVAL; | 1973 | int ret; |
1956 | 1974 | ||
1957 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE | 1975 | /* |
1958 | if (is_early_platform_device(dev)) { | 1976 | * If we've come here via earlyprintk initialization, head off to |
1959 | if (dev->id == -1) | 1977 | * the special early probe. We don't have sufficient device state |
1960 | return -ENOTSUPP; | 1978 | * to make it beyond this yet. |
1961 | early_serial_console.index = dev->id; | 1979 | */ |
1962 | early_serial_console.data = &early_serial_port.port; | 1980 | if (is_early_platform_device(dev)) |
1963 | sci_init_single(NULL, &early_serial_port, dev->id, p); | 1981 | return sci_probe_earlyprintk(dev); |
1964 | serial_console_setup(&early_serial_console, early_serial_buf); | ||
1965 | if (!strstr(early_serial_buf, "keep")) | ||
1966 | early_serial_console.flags |= CON_BOOT; | ||
1967 | register_console(&early_serial_console); | ||
1968 | return 0; | ||
1969 | } | ||
1970 | #endif | ||
1971 | 1982 | ||
1972 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | 1983 | platform_set_drvdata(dev, sp); |
1973 | if (!priv) | ||
1974 | return -ENOMEM; | ||
1975 | 1984 | ||
1976 | INIT_LIST_HEAD(&priv->ports); | 1985 | ret = sci_probe_single(dev, dev->id, p, sp); |
1977 | spin_lock_init(&priv->lock); | 1986 | if (ret) |
1978 | platform_set_drvdata(dev, priv); | 1987 | goto err_unreg; |
1979 | 1988 | ||
1980 | priv->clk_nb.notifier_call = sci_notifier; | 1989 | sp->freq_transition.notifier_call = sci_notifier; |
1981 | cpufreq_register_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); | ||
1982 | 1990 | ||
1983 | if (dev->id != -1) { | 1991 | ret = cpufreq_register_notifier(&sp->freq_transition, |
1984 | ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]); | 1992 | CPUFREQ_TRANSITION_NOTIFIER); |
1985 | if (ret) | 1993 | if (unlikely(ret < 0)) |
1986 | goto err_unreg; | 1994 | goto err_unreg; |
1987 | } else { | ||
1988 | for (i = 0; p && p->flags != 0; p++, i++) { | ||
1989 | ret = sci_probe_single(dev, i, p, &sci_ports[i]); | ||
1990 | if (ret) | ||
1991 | goto err_unreg; | ||
1992 | } | ||
1993 | } | ||
1994 | 1995 | ||
1995 | #ifdef CONFIG_SH_STANDARD_BIOS | 1996 | #ifdef CONFIG_SH_STANDARD_BIOS |
1996 | sh_bios_gdb_detach(); | 1997 | sh_bios_gdb_detach(); |
@@ -2005,28 +2006,20 @@ err_unreg: | |||
2005 | 2006 | ||
2006 | static int sci_suspend(struct device *dev) | 2007 | static int sci_suspend(struct device *dev) |
2007 | { | 2008 | { |
2008 | struct sh_sci_priv *priv = dev_get_drvdata(dev); | 2009 | struct sci_port *sport = dev_get_drvdata(dev); |
2009 | struct sci_port *p; | ||
2010 | unsigned long flags; | ||
2011 | 2010 | ||
2012 | spin_lock_irqsave(&priv->lock, flags); | 2011 | if (sport) |
2013 | list_for_each_entry(p, &priv->ports, node) | 2012 | uart_suspend_port(&sci_uart_driver, &sport->port); |
2014 | uart_suspend_port(&sci_uart_driver, &p->port); | ||
2015 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2016 | 2013 | ||
2017 | return 0; | 2014 | return 0; |
2018 | } | 2015 | } |
2019 | 2016 | ||
2020 | static int sci_resume(struct device *dev) | 2017 | static int sci_resume(struct device *dev) |
2021 | { | 2018 | { |
2022 | struct sh_sci_priv *priv = dev_get_drvdata(dev); | 2019 | struct sci_port *sport = dev_get_drvdata(dev); |
2023 | struct sci_port *p; | ||
2024 | unsigned long flags; | ||
2025 | 2020 | ||
2026 | spin_lock_irqsave(&priv->lock, flags); | 2021 | if (sport) |
2027 | list_for_each_entry(p, &priv->ports, node) | 2022 | uart_resume_port(&sci_uart_driver, &sport->port); |
2028 | uart_resume_port(&sci_uart_driver, &p->port); | ||
2029 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2030 | 2023 | ||
2031 | return 0; | 2024 | return 0; |
2032 | } | 2025 | } |