aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/serial/sh-sci.c91
1 files changed, 41 insertions, 50 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 1d1e700c7a43..dccc9822ab9b 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -65,11 +65,8 @@
65struct sci_port { 65struct sci_port {
66 struct uart_port port; 66 struct uart_port port;
67 67
68 /* Port type */ 68 /* Platform configuration */
69 unsigned int type; 69 struct plat_sci_port *cfg;
70
71 /* Port IRQs: ERI, RXI, TXI, BRI (optional) */
72 unsigned int irqs[SCIx_NR_IRQS];
73 70
74 /* Port enable callback */ 71 /* Port enable callback */
75 void (*enable)(struct uart_port *port); 72 void (*enable)(struct uart_port *port);
@@ -81,12 +78,6 @@ struct sci_port {
81 struct timer_list break_timer; 78 struct timer_list break_timer;
82 int break_flag; 79 int break_flag;
83 80
84 /* SCSCR initialization */
85 unsigned int scscr;
86
87 /* SCBRR calculation algo */
88 unsigned int scbrr_algo_id;
89
90 /* Interface clock */ 81 /* Interface clock */
91 struct clk *iclk; 82 struct clk *iclk;
92 /* Function clock */ 83 /* Function clock */
@@ -98,9 +89,6 @@ struct sci_port {
98 struct dma_chan *chan_rx; 89 struct dma_chan *chan_rx;
99 90
100#ifdef CONFIG_SERIAL_SH_SCI_DMA 91#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; 92 struct dma_async_tx_descriptor *desc_tx;
105 struct dma_async_tx_descriptor *desc_rx[2]; 93 struct dma_async_tx_descriptor *desc_rx[2];
106 dma_cookie_t cookie_tx; 94 dma_cookie_t cookie_tx;
@@ -794,7 +782,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 782 * it's unset, it's logically inferred that there's no point in
795 * testing for it. 783 * testing for it.
796 */ 784 */
797 return SCSCR_RIE | (to_sci_port(port)->scscr & SCSCR_REIE); 785 return SCSCR_RIE | (to_sci_port(port)->cfg->scscr & SCSCR_REIE);
798} 786}
799 787
800static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) 788static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
@@ -882,21 +870,21 @@ static int sci_request_irq(struct sci_port *port)
882 const char *desc[] = { "SCI Receive Error", "SCI Receive Data Full", 870 const char *desc[] = { "SCI Receive Error", "SCI Receive Data Full",
883 "SCI Transmit Data Empty", "SCI Break" }; 871 "SCI Transmit Data Empty", "SCI Break" };
884 872
885 if (port->irqs[0] == port->irqs[1]) { 873 if (port->cfg->irqs[0] == port->cfg->irqs[1]) {
886 if (unlikely(!port->irqs[0])) 874 if (unlikely(!port->cfg->irqs[0]))
887 return -ENODEV; 875 return -ENODEV;
888 876
889 if (request_irq(port->irqs[0], sci_mpxed_interrupt, 877 if (request_irq(port->cfg->irqs[0], sci_mpxed_interrupt,
890 IRQF_DISABLED, "sci", port)) { 878 IRQF_DISABLED, "sci", port)) {
891 dev_err(port->port.dev, "Can't allocate IRQ\n"); 879 dev_err(port->port.dev, "Can't allocate IRQ\n");
892 return -ENODEV; 880 return -ENODEV;
893 } 881 }
894 } else { 882 } else {
895 for (i = 0; i < ARRAY_SIZE(handlers); i++) { 883 for (i = 0; i < ARRAY_SIZE(handlers); i++) {
896 if (unlikely(!port->irqs[i])) 884 if (unlikely(!port->cfg->irqs[i]))
897 continue; 885 continue;
898 886
899 if (request_irq(port->irqs[i], handlers[i], 887 if (request_irq(port->cfg->irqs[i], handlers[i],
900 IRQF_DISABLED, desc[i], port)) { 888 IRQF_DISABLED, desc[i], port)) {
901 dev_err(port->port.dev, "Can't allocate IRQ\n"); 889 dev_err(port->port.dev, "Can't allocate IRQ\n");
902 return -ENODEV; 890 return -ENODEV;
@@ -911,14 +899,14 @@ static void sci_free_irq(struct sci_port *port)
911{ 899{
912 int i; 900 int i;
913 901
914 if (port->irqs[0] == port->irqs[1]) 902 if (port->cfg->irqs[0] == port->cfg->irqs[1])
915 free_irq(port->irqs[0], port); 903 free_irq(port->cfg->irqs[0], port);
916 else { 904 else {
917 for (i = 0; i < ARRAY_SIZE(port->irqs); i++) { 905 for (i = 0; i < ARRAY_SIZE(port->cfg->irqs); i++) {
918 if (!port->irqs[i]) 906 if (!port->cfg->irqs[i])
919 continue; 907 continue;
920 908
921 free_irq(port->irqs[i], port); 909 free_irq(port->cfg->irqs[i], port);
922 } 910 }
923 } 911 }
924} 912}
@@ -1325,7 +1313,7 @@ static void rx_timer_fn(unsigned long arg)
1325 1313
1326 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 1314 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1327 scr &= ~0x4000; 1315 scr &= ~0x4000;
1328 enable_irq(s->irqs[1]); 1316 enable_irq(s->cfg->irqs[1]);
1329 } 1317 }
1330 sci_out(port, SCSCR, scr | SCSCR_RIE); 1318 sci_out(port, SCSCR, scr | SCSCR_RIE);
1331 dev_dbg(port->dev, "DMA Rx timed out\n"); 1319 dev_dbg(port->dev, "DMA Rx timed out\n");
@@ -1341,9 +1329,9 @@ static void sci_request_dma(struct uart_port *port)
1341 int nent; 1329 int nent;
1342 1330
1343 dev_dbg(port->dev, "%s: port %d DMA %p\n", __func__, 1331 dev_dbg(port->dev, "%s: port %d DMA %p\n", __func__,
1344 port->line, s->dma_dev); 1332 port->line, s->cfg->dma_dev);
1345 1333
1346 if (!s->dma_dev) 1334 if (!s->cfg->dma_dev)
1347 return; 1335 return;
1348 1336
1349 dma_cap_zero(mask); 1337 dma_cap_zero(mask);
@@ -1352,8 +1340,8 @@ static void sci_request_dma(struct uart_port *port)
1352 param = &s->param_tx; 1340 param = &s->param_tx;
1353 1341
1354 /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_TX */ 1342 /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_TX */
1355 param->slave_id = s->slave_tx; 1343 param->slave_id = s->cfg->dma_slave_tx;
1356 param->dma_dev = s->dma_dev; 1344 param->dma_dev = s->cfg->dma_dev;
1357 1345
1358 s->cookie_tx = -EINVAL; 1346 s->cookie_tx = -EINVAL;
1359 chan = dma_request_channel(mask, filter, param); 1347 chan = dma_request_channel(mask, filter, param);
@@ -1381,8 +1369,8 @@ static void sci_request_dma(struct uart_port *port)
1381 param = &s->param_rx; 1369 param = &s->param_rx;
1382 1370
1383 /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_RX */ 1371 /* Slave ID, e.g., SHDMA_SLAVE_SCIF0_RX */
1384 param->slave_id = s->slave_rx; 1372 param->slave_id = s->cfg->dma_slave_rx;
1385 param->dma_dev = s->dma_dev; 1373 param->dma_dev = s->cfg->dma_dev;
1386 1374
1387 chan = dma_request_channel(mask, filter, param); 1375 chan = dma_request_channel(mask, filter, param);
1388 dev_dbg(port->dev, "%s: RX: got channel %p\n", __func__, chan); 1376 dev_dbg(port->dev, "%s: RX: got channel %p\n", __func__, chan);
@@ -1427,7 +1415,7 @@ static void sci_free_dma(struct uart_port *port)
1427{ 1415{
1428 struct sci_port *s = to_sci_port(port); 1416 struct sci_port *s = to_sci_port(port);
1429 1417
1430 if (!s->dma_dev) 1418 if (!s->cfg->dma_dev)
1431 return; 1419 return;
1432 1420
1433 if (s->chan_tx) 1421 if (s->chan_tx)
@@ -1514,7 +1502,7 @@ 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);
1518 1506
1519 do { 1507 do {
1520 status = sci_in(port, SCxSR); 1508 status = sci_in(port, SCxSR);
@@ -1540,7 +1528,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1540 sci_out(port, SCSMR, smr_val); 1528 sci_out(port, SCSMR, smr_val);
1541 1529
1542 dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t, 1530 dev_dbg(port->dev, "%s: SMR %x, t %x, SCSCR %x\n", __func__, smr_val, t,
1543 s->scscr); 1531 s->cfg->scscr);
1544 1532
1545 if (t > 0) { 1533 if (t > 0) {
1546 if (t >= 256) { 1534 if (t >= 256) {
@@ -1556,7 +1544,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1556 sci_init_pins(port, termios->c_cflag); 1544 sci_init_pins(port, termios->c_cflag);
1557 sci_out(port, SCFCR, scfcr | ((termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0)); 1545 sci_out(port, SCFCR, scfcr | ((termios->c_cflag & CRTSCTS) ? SCFCR_MCE : 0));
1558 1546
1559 sci_out(port, SCSCR, s->scscr); 1547 sci_out(port, SCSCR, s->cfg->scscr);
1560 1548
1561#ifdef CONFIG_SERIAL_SH_SCI_DMA 1549#ifdef CONFIG_SERIAL_SH_SCI_DMA
1562 /* 1550 /*
@@ -1617,7 +1605,7 @@ static void sci_config_port(struct uart_port *port, int flags)
1617{ 1605{
1618 struct sci_port *s = to_sci_port(port); 1606 struct sci_port *s = to_sci_port(port);
1619 1607
1620 port->type = s->type; 1608 port->type = s->cfg->type;
1621 1609
1622 if (port->flags & UPF_IOREMAP) { 1610 if (port->flags & UPF_IOREMAP) {
1623 port->membase = ioremap_nocache(port->mapbase, 0x40); 1611 port->membase = ioremap_nocache(port->mapbase, 0x40);
@@ -1638,7 +1626,7 @@ static int sci_verify_port(struct uart_port *port, struct serial_struct *ser)
1638{ 1626{
1639 struct sci_port *s = to_sci_port(port); 1627 struct sci_port *s = to_sci_port(port);
1640 1628
1641 if (ser->irq != s->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs) 1629 if (ser->irq != s->cfg->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs)
1642 return -EINVAL; 1630 return -EINVAL;
1643 if (ser->baud_base < 2400) 1631 if (ser->baud_base < 2400)
1644 /* No paper tape reader for Mitch.. */ 1632 /* No paper tape reader for Mitch.. */
@@ -1723,24 +1711,27 @@ static int __devinit sci_init_single(struct platform_device *dev,
1723 sci_port->break_timer.function = sci_break_timer; 1711 sci_port->break_timer.function = sci_break_timer;
1724 init_timer(&sci_port->break_timer); 1712 init_timer(&sci_port->break_timer);
1725 1713
1726 port->mapbase = p->mapbase; 1714 sci_port->cfg = p;
1727 1715
1728 port->irq = p->irqs[SCIx_TXI_IRQ]; 1716 port->mapbase = p->mapbase;
1717 port->type = p->type;
1729 port->flags = p->flags; 1718 port->flags = p->flags;
1730 sci_port->type = port->type = p->type;
1731 sci_port->scscr = p->scscr;
1732 sci_port->scbrr_algo_id = p->scbrr_algo_id;
1733 1719
1734#ifdef CONFIG_SERIAL_SH_SCI_DMA 1720 /*
1735 sci_port->dma_dev = p->dma_dev; 1721 * The UART port needs an IRQ value, so we peg this to the TX IRQ
1736 sci_port->slave_tx = p->dma_slave_tx; 1722 * for the multi-IRQ ports, which is where we are primarily
1737 sci_port->slave_rx = p->dma_slave_rx; 1723 * concerned with the shutdown path synchronization.
1724 *
1725 * For the muxed case there's nothing more to do.
1726 */
1727 port->irq = p->irqs[SCIx_TXI_IRQ];
1738 1728
1739 dev_dbg(port->dev, "%s: DMA device %p, tx %d, rx %d\n", __func__, 1729#ifdef CONFIG_SERIAL_SH_SCI_DMA
1740 p->dma_dev, p->dma_slave_tx, p->dma_slave_rx); 1730 if (p->dma_dev)
1731 dev_dbg(port->dev, "DMA device %p, tx %d, rx %d\n",
1732 p->dma_dev, p->dma_slave_tx, p->dma_slave_rx);
1741#endif 1733#endif
1742 1734
1743 memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs));
1744 return 0; 1735 return 0;
1745} 1736}
1746 1737