diff options
Diffstat (limited to 'drivers/serial/sh-sci.c')
-rw-r--r-- | drivers/serial/sh-sci.c | 194 |
1 files changed, 126 insertions, 68 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 980f39449ee5..291bc08e2e84 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -50,7 +50,6 @@ | |||
50 | #include <linux/list.h> | 50 | #include <linux/list.h> |
51 | #include <linux/dmaengine.h> | 51 | #include <linux/dmaengine.h> |
52 | #include <linux/scatterlist.h> | 52 | #include <linux/scatterlist.h> |
53 | #include <linux/timer.h> | ||
54 | 53 | ||
55 | #ifdef CONFIG_SUPERH | 54 | #ifdef CONFIG_SUPERH |
56 | #include <asm/sh_bios.h> | 55 | #include <asm/sh_bios.h> |
@@ -83,16 +82,16 @@ struct sci_port { | |||
83 | 82 | ||
84 | /* Interface clock */ | 83 | /* Interface clock */ |
85 | struct clk *iclk; | 84 | struct clk *iclk; |
86 | /* Data clock */ | 85 | /* Function clock */ |
87 | struct clk *dclk; | 86 | struct clk *fclk; |
88 | 87 | ||
89 | struct list_head node; | 88 | struct list_head node; |
90 | struct dma_chan *chan_tx; | 89 | struct dma_chan *chan_tx; |
91 | struct dma_chan *chan_rx; | 90 | struct dma_chan *chan_rx; |
92 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 91 | #ifdef CONFIG_SERIAL_SH_SCI_DMA |
93 | struct device *dma_dev; | 92 | struct device *dma_dev; |
94 | enum sh_dmae_slave_chan_id slave_tx; | 93 | unsigned int slave_tx; |
95 | enum sh_dmae_slave_chan_id slave_rx; | 94 | unsigned int slave_rx; |
96 | struct dma_async_tx_descriptor *desc_tx; | 95 | struct dma_async_tx_descriptor *desc_tx; |
97 | struct dma_async_tx_descriptor *desc_rx[2]; | 96 | struct dma_async_tx_descriptor *desc_rx[2]; |
98 | dma_cookie_t cookie_tx; | 97 | dma_cookie_t cookie_tx; |
@@ -107,6 +106,7 @@ struct sci_port { | |||
107 | struct work_struct work_tx; | 106 | struct work_struct work_tx; |
108 | struct work_struct work_rx; | 107 | struct work_struct work_rx; |
109 | struct timer_list rx_timer; | 108 | struct timer_list rx_timer; |
109 | unsigned int rx_timeout; | ||
110 | #endif | 110 | #endif |
111 | }; | 111 | }; |
112 | 112 | ||
@@ -674,22 +674,22 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr) | |||
674 | struct sci_port *s = to_sci_port(port); | 674 | struct sci_port *s = to_sci_port(port); |
675 | 675 | ||
676 | if (s->chan_rx) { | 676 | if (s->chan_rx) { |
677 | unsigned long tout; | ||
678 | u16 scr = sci_in(port, SCSCR); | 677 | u16 scr = sci_in(port, SCSCR); |
679 | u16 ssr = sci_in(port, SCxSR); | 678 | u16 ssr = sci_in(port, SCxSR); |
680 | 679 | ||
681 | /* Disable future Rx interrupts */ | 680 | /* Disable future Rx interrupts */ |
682 | sci_out(port, SCSCR, scr & ~SCI_CTRL_FLAGS_RIE); | 681 | if (port->type == PORT_SCIFA) { |
682 | disable_irq_nosync(irq); | ||
683 | scr |= 0x4000; | ||
684 | } else { | ||
685 | scr &= ~SCI_CTRL_FLAGS_RIE; | ||
686 | } | ||
687 | sci_out(port, SCSCR, scr); | ||
683 | /* Clear current interrupt */ | 688 | /* Clear current interrupt */ |
684 | sci_out(port, SCxSR, ssr & ~(1 | SCxSR_RDxF(port))); | 689 | sci_out(port, SCxSR, ssr & ~(1 | SCxSR_RDxF(port))); |
685 | /* Calculate delay for 1.5 DMA buffers */ | 690 | dev_dbg(port->dev, "Rx IRQ %lu: setup t-out in %u jiffies\n", |
686 | tout = (port->timeout - HZ / 50) * s->buf_len_rx * 3 / | 691 | jiffies, s->rx_timeout); |
687 | port->fifosize / 2; | 692 | mod_timer(&s->rx_timer, jiffies + s->rx_timeout); |
688 | dev_dbg(port->dev, "Rx IRQ: setup timeout in %lu ms\n", | ||
689 | tout * 1000 / HZ); | ||
690 | if (tout < 2) | ||
691 | tout = 2; | ||
692 | mod_timer(&s->rx_timer, jiffies + tout); | ||
693 | 693 | ||
694 | return IRQ_HANDLED; | 694 | return IRQ_HANDLED; |
695 | } | 695 | } |
@@ -780,10 +780,6 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) | |||
780 | if ((ssr_status & SCxSR_BRK(port)) && err_enabled) | 780 | if ((ssr_status & SCxSR_BRK(port)) && err_enabled) |
781 | ret = sci_br_interrupt(irq, ptr); | 781 | ret = sci_br_interrupt(irq, ptr); |
782 | 782 | ||
783 | WARN_ONCE(ret == IRQ_NONE, | ||
784 | "%s: %d IRQ %d, status %x, control %x\n", __func__, | ||
785 | irq, port->line, ssr_status, scr_status); | ||
786 | |||
787 | return ret; | 783 | return ret; |
788 | } | 784 | } |
789 | 785 | ||
@@ -803,7 +799,7 @@ static int sci_notifier(struct notifier_block *self, | |||
803 | (phase == CPUFREQ_RESUMECHANGE)) { | 799 | (phase == CPUFREQ_RESUMECHANGE)) { |
804 | spin_lock_irqsave(&priv->lock, flags); | 800 | spin_lock_irqsave(&priv->lock, flags); |
805 | list_for_each_entry(sci_port, &priv->ports, node) | 801 | list_for_each_entry(sci_port, &priv->ports, node) |
806 | sci_port->port.uartclk = clk_get_rate(sci_port->dclk); | 802 | sci_port->port.uartclk = clk_get_rate(sci_port->iclk); |
807 | spin_unlock_irqrestore(&priv->lock, flags); | 803 | spin_unlock_irqrestore(&priv->lock, flags); |
808 | } | 804 | } |
809 | 805 | ||
@@ -814,21 +810,17 @@ static void sci_clk_enable(struct uart_port *port) | |||
814 | { | 810 | { |
815 | struct sci_port *sci_port = to_sci_port(port); | 811 | struct sci_port *sci_port = to_sci_port(port); |
816 | 812 | ||
817 | clk_enable(sci_port->dclk); | 813 | clk_enable(sci_port->iclk); |
818 | sci_port->port.uartclk = clk_get_rate(sci_port->dclk); | 814 | sci_port->port.uartclk = clk_get_rate(sci_port->iclk); |
819 | 815 | clk_enable(sci_port->fclk); | |
820 | if (sci_port->iclk) | ||
821 | clk_enable(sci_port->iclk); | ||
822 | } | 816 | } |
823 | 817 | ||
824 | static void sci_clk_disable(struct uart_port *port) | 818 | static void sci_clk_disable(struct uart_port *port) |
825 | { | 819 | { |
826 | struct sci_port *sci_port = to_sci_port(port); | 820 | struct sci_port *sci_port = to_sci_port(port); |
827 | 821 | ||
828 | if (sci_port->iclk) | 822 | clk_disable(sci_port->fclk); |
829 | clk_disable(sci_port->iclk); | 823 | clk_disable(sci_port->iclk); |
830 | |||
831 | clk_disable(sci_port->dclk); | ||
832 | } | 824 | } |
833 | 825 | ||
834 | static int sci_request_irq(struct sci_port *port) | 826 | static int sci_request_irq(struct sci_port *port) |
@@ -917,22 +909,26 @@ static void sci_dma_tx_complete(void *arg) | |||
917 | 909 | ||
918 | spin_lock_irqsave(&port->lock, flags); | 910 | spin_lock_irqsave(&port->lock, flags); |
919 | 911 | ||
920 | xmit->tail += s->sg_tx.length; | 912 | xmit->tail += sg_dma_len(&s->sg_tx); |
921 | xmit->tail &= UART_XMIT_SIZE - 1; | 913 | xmit->tail &= UART_XMIT_SIZE - 1; |
922 | 914 | ||
923 | port->icount.tx += s->sg_tx.length; | 915 | port->icount.tx += sg_dma_len(&s->sg_tx); |
924 | 916 | ||
925 | async_tx_ack(s->desc_tx); | 917 | async_tx_ack(s->desc_tx); |
926 | s->cookie_tx = -EINVAL; | 918 | s->cookie_tx = -EINVAL; |
927 | s->desc_tx = NULL; | 919 | s->desc_tx = NULL; |
928 | 920 | ||
929 | spin_unlock_irqrestore(&port->lock, flags); | ||
930 | |||
931 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 921 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
932 | uart_write_wakeup(port); | 922 | uart_write_wakeup(port); |
933 | 923 | ||
934 | if (uart_circ_chars_pending(xmit)) | 924 | if (!uart_circ_empty(xmit)) { |
935 | schedule_work(&s->work_tx); | 925 | schedule_work(&s->work_tx); |
926 | } else if (port->type == PORT_SCIFA) { | ||
927 | u16 ctrl = sci_in(port, SCSCR); | ||
928 | sci_out(port, SCSCR, ctrl & ~SCI_CTRL_FLAGS_TIE); | ||
929 | } | ||
930 | |||
931 | spin_unlock_irqrestore(&port->lock, flags); | ||
936 | } | 932 | } |
937 | 933 | ||
938 | /* Locking: called with port lock held */ | 934 | /* Locking: called with port lock held */ |
@@ -976,13 +972,13 @@ static void sci_dma_rx_complete(void *arg) | |||
976 | unsigned long flags; | 972 | unsigned long flags; |
977 | int count; | 973 | int count; |
978 | 974 | ||
979 | dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); | 975 | dev_dbg(port->dev, "%s(%d) active #%d\n", __func__, port->line, s->active_rx); |
980 | 976 | ||
981 | spin_lock_irqsave(&port->lock, flags); | 977 | spin_lock_irqsave(&port->lock, flags); |
982 | 978 | ||
983 | count = sci_dma_rx_push(s, tty, s->buf_len_rx); | 979 | count = sci_dma_rx_push(s, tty, s->buf_len_rx); |
984 | 980 | ||
985 | mod_timer(&s->rx_timer, jiffies + msecs_to_jiffies(5)); | 981 | mod_timer(&s->rx_timer, jiffies + s->rx_timeout); |
986 | 982 | ||
987 | spin_unlock_irqrestore(&port->lock, flags); | 983 | spin_unlock_irqrestore(&port->lock, flags); |
988 | 984 | ||
@@ -1054,6 +1050,8 @@ static void sci_submit_rx(struct sci_port *s) | |||
1054 | sci_rx_dma_release(s, true); | 1050 | sci_rx_dma_release(s, true); |
1055 | return; | 1051 | return; |
1056 | } | 1052 | } |
1053 | dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", __func__, | ||
1054 | s->cookie_rx[i], i); | ||
1057 | } | 1055 | } |
1058 | 1056 | ||
1059 | s->active_rx = s->cookie_rx[0]; | 1057 | s->active_rx = s->cookie_rx[0]; |
@@ -1111,10 +1109,10 @@ static void work_fn_rx(struct work_struct *work) | |||
1111 | return; | 1109 | return; |
1112 | } | 1110 | } |
1113 | 1111 | ||
1114 | dev_dbg(port->dev, "%s: cookie %d #%d\n", __func__, | ||
1115 | s->cookie_rx[new], new); | ||
1116 | |||
1117 | s->active_rx = s->cookie_rx[!new]; | 1112 | s->active_rx = s->cookie_rx[!new]; |
1113 | |||
1114 | dev_dbg(port->dev, "%s: cookie %d #%d, new active #%d\n", __func__, | ||
1115 | s->cookie_rx[new], new, s->active_rx); | ||
1118 | } | 1116 | } |
1119 | 1117 | ||
1120 | static void work_fn_tx(struct work_struct *work) | 1118 | static void work_fn_tx(struct work_struct *work) |
@@ -1135,14 +1133,13 @@ static void work_fn_tx(struct work_struct *work) | |||
1135 | */ | 1133 | */ |
1136 | spin_lock_irq(&port->lock); | 1134 | spin_lock_irq(&port->lock); |
1137 | sg->offset = xmit->tail & (UART_XMIT_SIZE - 1); | 1135 | sg->offset = xmit->tail & (UART_XMIT_SIZE - 1); |
1138 | sg->dma_address = (sg_dma_address(sg) & ~(UART_XMIT_SIZE - 1)) + | 1136 | sg_dma_address(sg) = (sg_dma_address(sg) & ~(UART_XMIT_SIZE - 1)) + |
1139 | sg->offset; | 1137 | sg->offset; |
1140 | sg->length = min((int)CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE), | 1138 | sg_dma_len(sg) = min((int)CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE), |
1141 | CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE)); | 1139 | CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE)); |
1142 | sg->dma_length = sg->length; | ||
1143 | spin_unlock_irq(&port->lock); | 1140 | spin_unlock_irq(&port->lock); |
1144 | 1141 | ||
1145 | BUG_ON(!sg->length); | 1142 | BUG_ON(!sg_dma_len(sg)); |
1146 | 1143 | ||
1147 | desc = chan->device->device_prep_slave_sg(chan, | 1144 | desc = chan->device->device_prep_slave_sg(chan, |
1148 | sg, s->sg_len_tx, DMA_TO_DEVICE, | 1145 | sg, s->sg_len_tx, DMA_TO_DEVICE, |
@@ -1177,23 +1174,28 @@ static void work_fn_tx(struct work_struct *work) | |||
1177 | 1174 | ||
1178 | static void sci_start_tx(struct uart_port *port) | 1175 | static void sci_start_tx(struct uart_port *port) |
1179 | { | 1176 | { |
1177 | struct sci_port *s = to_sci_port(port); | ||
1180 | unsigned short ctrl; | 1178 | unsigned short ctrl; |
1181 | 1179 | ||
1182 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | 1180 | #ifdef CONFIG_SERIAL_SH_SCI_DMA |
1183 | struct sci_port *s = to_sci_port(port); | 1181 | if (port->type == PORT_SCIFA) { |
1184 | 1182 | u16 new, scr = sci_in(port, SCSCR); | |
1185 | if (s->chan_tx) { | 1183 | if (s->chan_tx) |
1186 | if (!uart_circ_empty(&s->port.state->xmit) && s->cookie_tx < 0) | 1184 | new = scr | 0x8000; |
1187 | schedule_work(&s->work_tx); | 1185 | else |
1188 | 1186 | new = scr & ~0x8000; | |
1189 | return; | 1187 | if (new != scr) |
1188 | sci_out(port, SCSCR, new); | ||
1190 | } | 1189 | } |
1190 | if (s->chan_tx && !uart_circ_empty(&s->port.state->xmit) && | ||
1191 | s->cookie_tx < 0) | ||
1192 | schedule_work(&s->work_tx); | ||
1191 | #endif | 1193 | #endif |
1192 | 1194 | if (!s->chan_tx || port->type == PORT_SCIFA) { | |
1193 | /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */ | 1195 | /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */ |
1194 | ctrl = sci_in(port, SCSCR); | 1196 | ctrl = sci_in(port, SCSCR); |
1195 | ctrl |= SCI_CTRL_FLAGS_TIE; | 1197 | sci_out(port, SCSCR, ctrl | SCI_CTRL_FLAGS_TIE); |
1196 | sci_out(port, SCSCR, ctrl); | 1198 | } |
1197 | } | 1199 | } |
1198 | 1200 | ||
1199 | static void sci_stop_tx(struct uart_port *port) | 1201 | static void sci_stop_tx(struct uart_port *port) |
@@ -1202,6 +1204,8 @@ static void sci_stop_tx(struct uart_port *port) | |||
1202 | 1204 | ||
1203 | /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */ | 1205 | /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */ |
1204 | ctrl = sci_in(port, SCSCR); | 1206 | ctrl = sci_in(port, SCSCR); |
1207 | if (port->type == PORT_SCIFA) | ||
1208 | ctrl &= ~0x8000; | ||
1205 | ctrl &= ~SCI_CTRL_FLAGS_TIE; | 1209 | ctrl &= ~SCI_CTRL_FLAGS_TIE; |
1206 | sci_out(port, SCSCR, ctrl); | 1210 | sci_out(port, SCSCR, ctrl); |
1207 | } | 1211 | } |
@@ -1212,6 +1216,8 @@ static void sci_start_rx(struct uart_port *port) | |||
1212 | 1216 | ||
1213 | /* Set RIE (Receive Interrupt Enable) bit in SCSCR */ | 1217 | /* Set RIE (Receive Interrupt Enable) bit in SCSCR */ |
1214 | ctrl |= sci_in(port, SCSCR); | 1218 | ctrl |= sci_in(port, SCSCR); |
1219 | if (port->type == PORT_SCIFA) | ||
1220 | ctrl &= ~0x4000; | ||
1215 | sci_out(port, SCSCR, ctrl); | 1221 | sci_out(port, SCSCR, ctrl); |
1216 | } | 1222 | } |
1217 | 1223 | ||
@@ -1221,6 +1227,8 @@ static void sci_stop_rx(struct uart_port *port) | |||
1221 | 1227 | ||
1222 | /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */ | 1228 | /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */ |
1223 | ctrl = sci_in(port, SCSCR); | 1229 | ctrl = sci_in(port, SCSCR); |
1230 | if (port->type == PORT_SCIFA) | ||
1231 | ctrl &= ~0x4000; | ||
1224 | ctrl &= ~(SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE); | 1232 | ctrl &= ~(SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE); |
1225 | sci_out(port, SCSCR, ctrl); | 1233 | sci_out(port, SCSCR, ctrl); |
1226 | } | 1234 | } |
@@ -1255,8 +1263,12 @@ static void rx_timer_fn(unsigned long arg) | |||
1255 | { | 1263 | { |
1256 | struct sci_port *s = (struct sci_port *)arg; | 1264 | struct sci_port *s = (struct sci_port *)arg; |
1257 | struct uart_port *port = &s->port; | 1265 | struct uart_port *port = &s->port; |
1258 | |||
1259 | u16 scr = sci_in(port, SCSCR); | 1266 | u16 scr = sci_in(port, SCSCR); |
1267 | |||
1268 | if (port->type == PORT_SCIFA) { | ||
1269 | scr &= ~0x4000; | ||
1270 | enable_irq(s->irqs[1]); | ||
1271 | } | ||
1260 | sci_out(port, SCSCR, scr | SCI_CTRL_FLAGS_RIE); | 1272 | sci_out(port, SCSCR, scr | SCI_CTRL_FLAGS_RIE); |
1261 | dev_dbg(port->dev, "DMA Rx timed out\n"); | 1273 | dev_dbg(port->dev, "DMA Rx timed out\n"); |
1262 | schedule_work(&s->work_rx); | 1274 | schedule_work(&s->work_rx); |
@@ -1343,8 +1355,7 @@ static void sci_request_dma(struct uart_port *port) | |||
1343 | sg_init_table(sg, 1); | 1355 | sg_init_table(sg, 1); |
1344 | sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx, | 1356 | sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx, |
1345 | (int)buf[i] & ~PAGE_MASK); | 1357 | (int)buf[i] & ~PAGE_MASK); |
1346 | sg->dma_address = dma[i]; | 1358 | sg_dma_address(sg) = dma[i]; |
1347 | sg->dma_length = sg->length; | ||
1348 | } | 1359 | } |
1349 | 1360 | ||
1350 | INIT_WORK(&s->work_rx, work_fn_rx); | 1361 | INIT_WORK(&s->work_rx, work_fn_rx); |
@@ -1407,8 +1418,12 @@ static void sci_shutdown(struct uart_port *port) | |||
1407 | static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | 1418 | static void sci_set_termios(struct uart_port *port, struct ktermios *termios, |
1408 | struct ktermios *old) | 1419 | struct ktermios *old) |
1409 | { | 1420 | { |
1421 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | ||
1422 | struct sci_port *s = to_sci_port(port); | ||
1423 | #endif | ||
1410 | unsigned int status, baud, smr_val, max_baud; | 1424 | unsigned int status, baud, smr_val, max_baud; |
1411 | int t = -1; | 1425 | int t = -1; |
1426 | u16 scfcr = 0; | ||
1412 | 1427 | ||
1413 | /* | 1428 | /* |
1414 | * earlyprintk comes here early on with port->uartclk set to zero. | 1429 | * earlyprintk comes here early on with port->uartclk set to zero. |
@@ -1431,7 +1446,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1431 | sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ | 1446 | sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ |
1432 | 1447 | ||
1433 | if (port->type != PORT_SCI) | 1448 | if (port->type != PORT_SCI) |
1434 | sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); | 1449 | sci_out(port, SCFCR, scfcr | SCFCR_RFRST | SCFCR_TFRST); |
1435 | 1450 | ||
1436 | smr_val = sci_in(port, SCSMR) & 3; | 1451 | smr_val = sci_in(port, SCSMR) & 3; |
1437 | if ((termios->c_cflag & CSIZE) == CS7) | 1452 | if ((termios->c_cflag & CSIZE) == CS7) |
@@ -1462,10 +1477,32 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, | |||
1462 | } | 1477 | } |
1463 | 1478 | ||
1464 | sci_init_pins(port, termios->c_cflag); | 1479 | sci_init_pins(port, termios->c_cflag); |
1465 | sci_out(port, SCFCR, (termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0); | 1480 | sci_out(port, SCFCR, scfcr | ((termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0)); |
1466 | 1481 | ||
1467 | sci_out(port, SCSCR, SCSCR_INIT(port)); | 1482 | sci_out(port, SCSCR, SCSCR_INIT(port)); |
1468 | 1483 | ||
1484 | #ifdef CONFIG_SERIAL_SH_SCI_DMA | ||
1485 | /* | ||
1486 | * Calculate delay for 1.5 DMA buffers: see | ||
1487 | * drivers/serial/serial_core.c::uart_update_timeout(). With 10 bits | ||
1488 | * (CS8), 250Hz, 115200 baud and 64 bytes FIFO, the above function | ||
1489 | * calculates 1 jiffie for the data plus 5 jiffies for the "slop(e)." | ||
1490 | * Then below we calculate 3 jiffies (12ms) for 1.5 DMA buffers (3 FIFO | ||
1491 | * sizes), but it has been found out experimentally, that this is not | ||
1492 | * enough: the driver too often needlessly runs on a DMA timeout. 20ms | ||
1493 | * as a minimum seem to work perfectly. | ||
1494 | */ | ||
1495 | if (s->chan_rx) { | ||
1496 | s->rx_timeout = (port->timeout - HZ / 50) * s->buf_len_rx * 3 / | ||
1497 | port->fifosize / 2; | ||
1498 | dev_dbg(port->dev, | ||
1499 | "DMA Rx t-out %ums, tty t-out %u jiffies\n", | ||
1500 | s->rx_timeout * 1000 / HZ, port->timeout); | ||
1501 | if (s->rx_timeout < msecs_to_jiffies(20)) | ||
1502 | s->rx_timeout = msecs_to_jiffies(20); | ||
1503 | } | ||
1504 | #endif | ||
1505 | |||
1469 | if ((termios->c_cflag & CREAD) != 0) | 1506 | if ((termios->c_cflag & CREAD) != 0) |
1470 | sci_start_rx(port); | 1507 | sci_start_rx(port); |
1471 | } | 1508 | } |
@@ -1557,10 +1594,10 @@ static struct uart_ops sci_uart_ops = { | |||
1557 | #endif | 1594 | #endif |
1558 | }; | 1595 | }; |
1559 | 1596 | ||
1560 | static void __devinit sci_init_single(struct platform_device *dev, | 1597 | static int __devinit sci_init_single(struct platform_device *dev, |
1561 | struct sci_port *sci_port, | 1598 | struct sci_port *sci_port, |
1562 | unsigned int index, | 1599 | unsigned int index, |
1563 | struct plat_sci_port *p) | 1600 | struct plat_sci_port *p) |
1564 | { | 1601 | { |
1565 | struct uart_port *port = &sci_port->port; | 1602 | struct uart_port *port = &sci_port->port; |
1566 | 1603 | ||
@@ -1581,8 +1618,23 @@ static void __devinit sci_init_single(struct platform_device *dev, | |||
1581 | } | 1618 | } |
1582 | 1619 | ||
1583 | if (dev) { | 1620 | if (dev) { |
1584 | sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; | 1621 | sci_port->iclk = clk_get(&dev->dev, "sci_ick"); |
1585 | sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); | 1622 | if (IS_ERR(sci_port->iclk)) { |
1623 | sci_port->iclk = clk_get(&dev->dev, "peripheral_clk"); | ||
1624 | if (IS_ERR(sci_port->iclk)) { | ||
1625 | dev_err(&dev->dev, "can't get iclk\n"); | ||
1626 | return PTR_ERR(sci_port->iclk); | ||
1627 | } | ||
1628 | } | ||
1629 | |||
1630 | /* | ||
1631 | * The function clock is optional, ignore it if we can't | ||
1632 | * find it. | ||
1633 | */ | ||
1634 | sci_port->fclk = clk_get(&dev->dev, "sci_fck"); | ||
1635 | if (IS_ERR(sci_port->fclk)) | ||
1636 | sci_port->fclk = NULL; | ||
1637 | |||
1586 | sci_port->enable = sci_clk_enable; | 1638 | sci_port->enable = sci_clk_enable; |
1587 | sci_port->disable = sci_clk_disable; | 1639 | sci_port->disable = sci_clk_disable; |
1588 | port->dev = &dev->dev; | 1640 | port->dev = &dev->dev; |
@@ -1609,6 +1661,7 @@ static void __devinit sci_init_single(struct platform_device *dev, | |||
1609 | #endif | 1661 | #endif |
1610 | 1662 | ||
1611 | memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); | 1663 | memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); |
1664 | return 0; | ||
1612 | } | 1665 | } |
1613 | 1666 | ||
1614 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE | 1667 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE |
@@ -1758,8 +1811,11 @@ static int sci_remove(struct platform_device *dev) | |||
1758 | cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); | 1811 | cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); |
1759 | 1812 | ||
1760 | spin_lock_irqsave(&priv->lock, flags); | 1813 | spin_lock_irqsave(&priv->lock, flags); |
1761 | list_for_each_entry(p, &priv->ports, node) | 1814 | list_for_each_entry(p, &priv->ports, node) { |
1762 | uart_remove_one_port(&sci_uart_driver, &p->port); | 1815 | uart_remove_one_port(&sci_uart_driver, &p->port); |
1816 | clk_put(p->iclk); | ||
1817 | clk_put(p->fclk); | ||
1818 | } | ||
1763 | spin_unlock_irqrestore(&priv->lock, flags); | 1819 | spin_unlock_irqrestore(&priv->lock, flags); |
1764 | 1820 | ||
1765 | kfree(priv); | 1821 | kfree(priv); |
@@ -1785,7 +1841,9 @@ static int __devinit sci_probe_single(struct platform_device *dev, | |||
1785 | return 0; | 1841 | return 0; |
1786 | } | 1842 | } |
1787 | 1843 | ||
1788 | sci_init_single(dev, sciport, index, p); | 1844 | ret = sci_init_single(dev, sciport, index, p); |
1845 | if (ret) | ||
1846 | return ret; | ||
1789 | 1847 | ||
1790 | ret = uart_add_one_port(&sci_uart_driver, &sciport->port); | 1848 | ret = uart_add_one_port(&sci_uart_driver, &sciport->port); |
1791 | if (ret) | 1849 | if (ret) |