aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c14
-rw-r--r--drivers/serial/mcf.c2
-rw-r--r--drivers/serial/mpc52xx_uart.c40
-rw-r--r--drivers/serial/serial_core.c76
4 files changed, 60 insertions, 72 deletions
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index bde4b4b0b80f..5c6ef51da274 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -406,6 +406,18 @@ static int cpm_uart_startup(struct uart_port *port)
406 406
407 pr_debug("CPM uart[%d]:startup\n", port->line); 407 pr_debug("CPM uart[%d]:startup\n", port->line);
408 408
409 /* If the port is not the console, make sure rx is disabled. */
410 if (!(pinfo->flags & FLAG_CONSOLE)) {
411 /* Disable UART rx */
412 if (IS_SMC(pinfo)) {
413 clrbits16(&pinfo->smcp->smc_smcmr, SMCMR_REN);
414 clrbits8(&pinfo->smcp->smc_smcm, SMCM_RX);
415 } else {
416 clrbits32(&pinfo->sccp->scc_gsmrl, SCC_GSMRL_ENR);
417 clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_RX);
418 }
419 cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
420 }
409 /* Install interrupt handler. */ 421 /* Install interrupt handler. */
410 retval = request_irq(port->irq, cpm_uart_int, 0, "cpm_uart", port); 422 retval = request_irq(port->irq, cpm_uart_int, 0, "cpm_uart", port);
411 if (retval) 423 if (retval)
@@ -420,8 +432,6 @@ static int cpm_uart_startup(struct uart_port *port)
420 setbits32(&pinfo->sccp->scc_gsmrl, (SCC_GSMRL_ENR | SCC_GSMRL_ENT)); 432 setbits32(&pinfo->sccp->scc_gsmrl, (SCC_GSMRL_ENR | SCC_GSMRL_ENT));
421 } 433 }
422 434
423 if (!(pinfo->flags & FLAG_CONSOLE))
424 cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX);
425 return 0; 435 return 0;
426} 436}
427 437
diff --git a/drivers/serial/mcf.c b/drivers/serial/mcf.c
index 56841fe5f483..0eefb07bebaf 100644
--- a/drivers/serial/mcf.c
+++ b/drivers/serial/mcf.c
@@ -513,7 +513,7 @@ static int __init mcf_console_setup(struct console *co, char *options)
513 int parity = 'n'; 513 int parity = 'n';
514 int flow = 'n'; 514 int flow = 'n';
515 515
516 if ((co->index >= 0) && (co->index <= MCF_MAXPORTS)) 516 if ((co->index < 0) || (co->index >= MCF_MAXPORTS))
517 co->index = 0; 517 co->index = 0;
518 port = &mcf_ports[co->index].port; 518 port = &mcf_ports[co->index].port;
519 if (port->membase == 0) 519 if (port->membase == 0)
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 0c3a2ab1612c..7f72f8ceaa6f 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -50,8 +50,8 @@
50/* OF Platform device Usage : 50/* OF Platform device Usage :
51 * 51 *
52 * This driver is only used for PSCs configured in uart mode. The device 52 * This driver is only used for PSCs configured in uart mode. The device
53 * tree will have a node for each PSC in uart mode w/ device_type = "serial" 53 * tree will have a node for each PSC with "mpc52xx-psc-uart" in the compatible
54 * and "mpc52xx-psc-uart" in the compatible string 54 * list.
55 * 55 *
56 * By default, PSC devices are enumerated in the order they are found. However 56 * By default, PSC devices are enumerated in the order they are found. However
57 * a particular PSC number can be forces by adding 'device_no = <port#>' 57 * a particular PSC number can be forces by adding 'device_no = <port#>'
@@ -522,7 +522,7 @@ mpc52xx_uart_startup(struct uart_port *port)
522 522
523 /* Request IRQ */ 523 /* Request IRQ */
524 ret = request_irq(port->irq, mpc52xx_uart_int, 524 ret = request_irq(port->irq, mpc52xx_uart_int,
525 IRQF_DISABLED | IRQF_SAMPLE_RANDOM | IRQF_SHARED, 525 IRQF_DISABLED | IRQF_SAMPLE_RANDOM,
526 "mpc52xx_psc_uart", port); 526 "mpc52xx_psc_uart", port);
527 if (ret) 527 if (ret)
528 return ret; 528 return ret;
@@ -1212,30 +1212,18 @@ mpc52xx_uart_of_resume(struct of_device *op)
1212#endif 1212#endif
1213 1213
1214static void 1214static void
1215mpc52xx_uart_of_assign(struct device_node *np, int idx) 1215mpc52xx_uart_of_assign(struct device_node *np)
1216{ 1216{
1217 int free_idx = -1;
1218 int i; 1217 int i;
1219 1218
1220 /* Find the first free node */ 1219 /* Find the first free PSC number */
1221 for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { 1220 for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
1222 if (mpc52xx_uart_nodes[i] == NULL) { 1221 if (mpc52xx_uart_nodes[i] == NULL) {
1223 free_idx = i; 1222 of_node_get(np);
1224 break; 1223 mpc52xx_uart_nodes[i] = np;
1224 return;
1225 } 1225 }
1226 } 1226 }
1227
1228 if ((idx < 0) || (idx >= MPC52xx_PSC_MAXNUM))
1229 idx = free_idx;
1230
1231 if (idx < 0)
1232 return; /* No free slot; abort */
1233
1234 of_node_get(np);
1235 /* If the slot is already occupied, then swap slots */
1236 if (mpc52xx_uart_nodes[idx] && (free_idx != -1))
1237 mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx];
1238 mpc52xx_uart_nodes[idx] = np;
1239} 1227}
1240 1228
1241static void 1229static void
@@ -1243,23 +1231,17 @@ mpc52xx_uart_of_enumerate(void)
1243{ 1231{
1244 static int enum_done; 1232 static int enum_done;
1245 struct device_node *np; 1233 struct device_node *np;
1246 const unsigned int *devno;
1247 const struct of_device_id *match; 1234 const struct of_device_id *match;
1248 int i; 1235 int i;
1249 1236
1250 if (enum_done) 1237 if (enum_done)
1251 return; 1238 return;
1252 1239
1253 for_each_node_by_type(np, "serial") { 1240 /* Assign index to each PSC in device tree */
1241 for_each_matching_node(np, mpc52xx_uart_of_match) {
1254 match = of_match_node(mpc52xx_uart_of_match, np); 1242 match = of_match_node(mpc52xx_uart_of_match, np);
1255 if (!match)
1256 continue;
1257
1258 psc_ops = match->data; 1243 psc_ops = match->data;
1259 1244 mpc52xx_uart_of_assign(np);
1260 /* Is a particular device number requested? */
1261 devno = of_get_property(np, "port-number", NULL);
1262 mpc52xx_uart_of_assign(np, devno ? *devno : -1);
1263 } 1245 }
1264 1246
1265 enum_done = 1; 1247 enum_done = 1;
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 42f4e66fccaf..b0bb29d804ae 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -27,6 +27,8 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/console.h> 29#include <linux/console.h>
30#include <linux/proc_fs.h>
31#include <linux/seq_file.h>
30#include <linux/serial_core.h> 32#include <linux/serial_core.h>
31#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
32#include <linux/device.h> 34#include <linux/device.h>
@@ -1682,20 +1684,20 @@ static const char *uart_type(struct uart_port *port)
1682 1684
1683#ifdef CONFIG_PROC_FS 1685#ifdef CONFIG_PROC_FS
1684 1686
1685static int uart_line_info(char *buf, struct uart_driver *drv, int i) 1687static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
1686{ 1688{
1687 struct uart_state *state = drv->state + i; 1689 struct uart_state *state = drv->state + i;
1688 int pm_state; 1690 int pm_state;
1689 struct uart_port *port = state->port; 1691 struct uart_port *port = state->port;
1690 char stat_buf[32]; 1692 char stat_buf[32];
1691 unsigned int status; 1693 unsigned int status;
1692 int mmio, ret; 1694 int mmio;
1693 1695
1694 if (!port) 1696 if (!port)
1695 return 0; 1697 return;
1696 1698
1697 mmio = port->iotype >= UPIO_MEM; 1699 mmio = port->iotype >= UPIO_MEM;
1698 ret = sprintf(buf, "%d: uart:%s %s%08llX irq:%d", 1700 seq_printf(m, "%d: uart:%s %s%08llX irq:%d",
1699 port->line, uart_type(port), 1701 port->line, uart_type(port),
1700 mmio ? "mmio:0x" : "port:", 1702 mmio ? "mmio:0x" : "port:",
1701 mmio ? (unsigned long long)port->mapbase 1703 mmio ? (unsigned long long)port->mapbase
@@ -1703,8 +1705,8 @@ static int uart_line_info(char *buf, struct uart_driver *drv, int i)
1703 port->irq); 1705 port->irq);
1704 1706
1705 if (port->type == PORT_UNKNOWN) { 1707 if (port->type == PORT_UNKNOWN) {
1706 strcat(buf, "\n"); 1708 seq_putc(m, '\n');
1707 return ret + 1; 1709 return;
1708 } 1710 }
1709 1711
1710 if (capable(CAP_SYS_ADMIN)) { 1712 if (capable(CAP_SYS_ADMIN)) {
@@ -1719,19 +1721,19 @@ static int uart_line_info(char *buf, struct uart_driver *drv, int i)
1719 uart_change_pm(state, pm_state); 1721 uart_change_pm(state, pm_state);
1720 mutex_unlock(&state->mutex); 1722 mutex_unlock(&state->mutex);
1721 1723
1722 ret += sprintf(buf + ret, " tx:%d rx:%d", 1724 seq_printf(m, " tx:%d rx:%d",
1723 port->icount.tx, port->icount.rx); 1725 port->icount.tx, port->icount.rx);
1724 if (port->icount.frame) 1726 if (port->icount.frame)
1725 ret += sprintf(buf + ret, " fe:%d", 1727 seq_printf(m, " fe:%d",
1726 port->icount.frame); 1728 port->icount.frame);
1727 if (port->icount.parity) 1729 if (port->icount.parity)
1728 ret += sprintf(buf + ret, " pe:%d", 1730 seq_printf(m, " pe:%d",
1729 port->icount.parity); 1731 port->icount.parity);
1730 if (port->icount.brk) 1732 if (port->icount.brk)
1731 ret += sprintf(buf + ret, " brk:%d", 1733 seq_printf(m, " brk:%d",
1732 port->icount.brk); 1734 port->icount.brk);
1733 if (port->icount.overrun) 1735 if (port->icount.overrun)
1734 ret += sprintf(buf + ret, " oe:%d", 1736 seq_printf(m, " oe:%d",
1735 port->icount.overrun); 1737 port->icount.overrun);
1736 1738
1737#define INFOBIT(bit, str) \ 1739#define INFOBIT(bit, str) \
@@ -1753,45 +1755,39 @@ static int uart_line_info(char *buf, struct uart_driver *drv, int i)
1753 STATBIT(TIOCM_RNG, "|RI"); 1755 STATBIT(TIOCM_RNG, "|RI");
1754 if (stat_buf[0]) 1756 if (stat_buf[0])
1755 stat_buf[0] = ' '; 1757 stat_buf[0] = ' ';
1756 strcat(stat_buf, "\n");
1757 1758
1758 ret += sprintf(buf + ret, stat_buf); 1759 seq_puts(m, stat_buf);
1759 } else {
1760 strcat(buf, "\n");
1761 ret++;
1762 } 1760 }
1761 seq_putc(m, '\n');
1763#undef STATBIT 1762#undef STATBIT
1764#undef INFOBIT 1763#undef INFOBIT
1765 return ret;
1766} 1764}
1767 1765
1768static int uart_read_proc(char *page, char **start, off_t off, 1766static int uart_proc_show(struct seq_file *m, void *v)
1769 int count, int *eof, void *data)
1770{ 1767{
1771 struct tty_driver *ttydrv = data; 1768 struct tty_driver *ttydrv = m->private;
1772 struct uart_driver *drv = ttydrv->driver_state; 1769 struct uart_driver *drv = ttydrv->driver_state;
1773 int i, len = 0, l; 1770 int i;
1774 off_t begin = 0;
1775 1771
1776 len += sprintf(page, "serinfo:1.0 driver%s%s revision:%s\n", 1772 seq_printf(m, "serinfo:1.0 driver%s%s revision:%s\n",
1777 "", "", ""); 1773 "", "", "");
1778 for (i = 0; i < drv->nr && len < PAGE_SIZE - 96; i++) { 1774 for (i = 0; i < drv->nr; i++)
1779 l = uart_line_info(page + len, drv, i); 1775 uart_line_info(m, drv, i);
1780 len += l; 1776 return 0;
1781 if (len + begin > off + count)
1782 goto done;
1783 if (len + begin < off) {
1784 begin += len;
1785 len = 0;
1786 }
1787 }
1788 *eof = 1;
1789 done:
1790 if (off >= len + begin)
1791 return 0;
1792 *start = page + (off - begin);
1793 return (count < begin + len - off) ? count : (begin + len - off);
1794} 1777}
1778
1779static int uart_proc_open(struct inode *inode, struct file *file)
1780{
1781 return single_open(file, uart_proc_show, PDE(inode)->data);
1782}
1783
1784static const struct file_operations uart_proc_fops = {
1785 .owner = THIS_MODULE,
1786 .open = uart_proc_open,
1787 .read = seq_read,
1788 .llseek = seq_lseek,
1789 .release = single_release,
1790};
1795#endif 1791#endif
1796 1792
1797#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL) 1793#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL)
@@ -2299,7 +2295,7 @@ static const struct tty_operations uart_ops = {
2299 .break_ctl = uart_break_ctl, 2295 .break_ctl = uart_break_ctl,
2300 .wait_until_sent= uart_wait_until_sent, 2296 .wait_until_sent= uart_wait_until_sent,
2301#ifdef CONFIG_PROC_FS 2297#ifdef CONFIG_PROC_FS
2302 .read_proc = uart_read_proc, 2298 .proc_fops = &uart_proc_fops,
2303#endif 2299#endif
2304 .tiocmget = uart_tiocmget, 2300 .tiocmget = uart_tiocmget,
2305 .tiocmset = uart_tiocmset, 2301 .tiocmset = uart_tiocmset,