aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/sh-sci.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2011-01-19 03:19:35 -0500
committerPaul Mundt <lethal@linux-sh.org>2011-01-19 03:19:35 -0500
commitd535a2305facf9b49a65bd412c6deaaf4d4316f2 (patch)
treed0e7ac5c78f372191e03e40e1ed2e580dbc0f1c1 /drivers/serial/sh-sci.c
parent27bd107525607e6a64c612ca3c43ca0dac4768b1 (diff)
serial: sh-sci: Require a device per port mapping.
In the olden days it was possible to register a map of ports per device, but this has long since been abandoned due to the desire to match up with clkdev and other functionality. As a result, all of the in-tree users have for some time already been migrated off of such behaviour, while we've left support code in place to deal with either case. Dropping the code permits for quite a bit of simplification, so we do that now before any users of the old interface are able to be added back in. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers/serial/sh-sci.c')
-rw-r--r--drivers/serial/sh-sci.c118
1 files changed, 38 insertions, 80 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 5b3e9769ca21..3fd1577a162f 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/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>
@@ -83,8 +82,6 @@ struct sci_port {
83 /* Function clock */ 82 /* Function clock */
84 struct clk *fclk; 83 struct clk *fclk;
85 84
86 struct list_head node;
87
88 struct dma_chan *chan_tx; 85 struct dma_chan *chan_tx;
89 struct dma_chan *chan_rx; 86 struct dma_chan *chan_rx;
90 87
@@ -105,16 +102,14 @@ struct sci_port {
105 struct timer_list rx_timer; 102 struct timer_list rx_timer;
106 unsigned int rx_timeout; 103 unsigned int rx_timeout;
107#endif 104#endif
108};
109 105
110struct sh_sci_priv { 106 struct notifier_block freq_transition;
111 spinlock_t lock;
112 struct list_head ports;
113 struct notifier_block clk_nb;
114}; 107};
115 108
116/* Function prototypes */ 109/* Function prototypes */
110static void sci_start_tx(struct uart_port *port);
117static void sci_stop_tx(struct uart_port *port); 111static void sci_stop_tx(struct uart_port *port);
112static void sci_start_rx(struct uart_port *port);
118 113
119#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS 114#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS
120 115
@@ -827,17 +822,17 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr)
827static int sci_notifier(struct notifier_block *self, 822static int sci_notifier(struct notifier_block *self,
828 unsigned long phase, void *p) 823 unsigned long phase, void *p)
829{ 824{
830 struct sh_sci_priv *priv = container_of(self,
831 struct sh_sci_priv, clk_nb);
832 struct sci_port *sci_port; 825 struct sci_port *sci_port;
833 unsigned long flags; 826 unsigned long flags;
834 827
828 sci_port = container_of(self, struct sci_port, freq_transition);
829
835 if ((phase == CPUFREQ_POSTCHANGE) || 830 if ((phase == CPUFREQ_POSTCHANGE) ||
836 (phase == CPUFREQ_RESUMECHANGE)) { 831 (phase == CPUFREQ_RESUMECHANGE)) {
837 spin_lock_irqsave(&priv->lock, flags); 832 struct uart_port *port = &sci_port->port;
838 list_for_each_entry(sci_port, &priv->ports, node) 833 spin_lock_irqsave(&port->lock, flags);
839 sci_port->port.uartclk = clk_get_rate(sci_port->iclk); 834 port->uartclk = clk_get_rate(sci_port->iclk);
840 spin_unlock_irqrestore(&priv->lock, flags); 835 spin_unlock_irqrestore(&port->lock, flags);
841 } 836 }
842 837
843 return NOTIFY_OK; 838 return NOTIFY_OK;
@@ -1025,9 +1020,6 @@ static void sci_dma_rx_complete(void *arg)
1025 schedule_work(&s->work_rx); 1020 schedule_work(&s->work_rx);
1026} 1021}
1027 1022
1028static void sci_start_rx(struct uart_port *port);
1029static void sci_start_tx(struct uart_port *port);
1030
1031static void sci_rx_dma_release(struct sci_port *s, bool enable_pio) 1023static void sci_rx_dma_release(struct sci_port *s, bool enable_pio)
1032{ 1024{
1033 struct dma_chan *chan = s->chan_rx; 1025 struct dma_chan *chan = s->chan_rx;
@@ -1874,24 +1866,18 @@ static struct uart_driver sci_uart_driver = {
1874 .cons = SCI_CONSOLE, 1866 .cons = SCI_CONSOLE,
1875}; 1867};
1876 1868
1877
1878static int sci_remove(struct platform_device *dev) 1869static int sci_remove(struct platform_device *dev)
1879{ 1870{
1880 struct sh_sci_priv *priv = platform_get_drvdata(dev); 1871 struct sci_port *port = platform_get_drvdata(dev);
1881 struct sci_port *p;
1882 unsigned long flags;
1883 1872
1884 cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); 1873 cpufreq_unregister_notifier(&port->freq_transition,
1874 CPUFREQ_TRANSITION_NOTIFIER);
1885 1875
1886 spin_lock_irqsave(&priv->lock, flags); 1876 uart_remove_one_port(&sci_uart_driver, &port->port);
1887 list_for_each_entry(p, &priv->ports, node) { 1877
1888 uart_remove_one_port(&sci_uart_driver, &p->port); 1878 clk_put(port->iclk);
1889 clk_put(p->iclk); 1879 clk_put(port->fclk);
1890 clk_put(p->fclk);
1891 }
1892 spin_unlock_irqrestore(&priv->lock, flags);
1893 1880
1894 kfree(priv);
1895 return 0; 1881 return 0;
1896} 1882}
1897 1883
@@ -1900,8 +1886,6 @@ static int __devinit sci_probe_single(struct platform_device *dev,
1900 struct plat_sci_port *p, 1886 struct plat_sci_port *p,
1901 struct sci_port *sciport) 1887 struct sci_port *sciport)
1902{ 1888{
1903 struct sh_sci_priv *priv = platform_get_drvdata(dev);
1904 unsigned long flags;
1905 int ret; 1889 int ret;
1906 1890
1907 /* Sanity check */ 1891 /* Sanity check */
@@ -1918,17 +1902,7 @@ static int __devinit sci_probe_single(struct platform_device *dev,
1918 if (ret) 1902 if (ret)
1919 return ret; 1903 return ret;
1920 1904
1921 ret = uart_add_one_port(&sci_uart_driver, &sciport->port); 1905 return uart_add_one_port(&sci_uart_driver, &sciport->port);
1922 if (ret)
1923 return ret;
1924
1925 INIT_LIST_HEAD(&sciport->node);
1926
1927 spin_lock_irqsave(&priv->lock, flags);
1928 list_add(&sciport->node, &priv->ports);
1929 spin_unlock_irqrestore(&priv->lock, flags);
1930
1931 return 0;
1932} 1906}
1933 1907
1934/* 1908/*
@@ -1940,46 +1914,38 @@ static int __devinit sci_probe_single(struct platform_device *dev,
1940static int __devinit sci_probe(struct platform_device *dev) 1914static int __devinit sci_probe(struct platform_device *dev)
1941{ 1915{
1942 struct plat_sci_port *p = dev->dev.platform_data; 1916 struct plat_sci_port *p = dev->dev.platform_data;
1943 struct sh_sci_priv *priv; 1917 struct sci_port *sp = &sci_ports[dev->id];
1944 int i, ret = -EINVAL; 1918 int ret = -EINVAL;
1945 1919
1946#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE 1920#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
1947 if (is_early_platform_device(dev)) { 1921 if (is_early_platform_device(dev)) {
1948 if (dev->id == -1)
1949 return -ENOTSUPP;
1950 early_serial_console.index = dev->id; 1922 early_serial_console.index = dev->id;
1951 early_serial_console.data = &early_serial_port.port; 1923 early_serial_console.data = &early_serial_port.port;
1924
1952 sci_init_single(NULL, &early_serial_port, dev->id, p); 1925 sci_init_single(NULL, &early_serial_port, dev->id, p);
1926
1953 serial_console_setup(&early_serial_console, early_serial_buf); 1927 serial_console_setup(&early_serial_console, early_serial_buf);
1928
1954 if (!strstr(early_serial_buf, "keep")) 1929 if (!strstr(early_serial_buf, "keep"))
1955 early_serial_console.flags |= CON_BOOT; 1930 early_serial_console.flags |= CON_BOOT;
1931
1956 register_console(&early_serial_console); 1932 register_console(&early_serial_console);
1957 return 0; 1933 return 0;
1958 } 1934 }
1959#endif 1935#endif
1960 1936
1961 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1937 platform_set_drvdata(dev, sp);
1962 if (!priv)
1963 return -ENOMEM;
1964 1938
1965 INIT_LIST_HEAD(&priv->ports); 1939 ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]);
1966 spin_lock_init(&priv->lock); 1940 if (ret)
1967 platform_set_drvdata(dev, priv); 1941 goto err_unreg;
1968 1942
1969 priv->clk_nb.notifier_call = sci_notifier; 1943 sp->freq_transition.notifier_call = sci_notifier;
1970 cpufreq_register_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER);
1971 1944
1972 if (dev->id != -1) { 1945 ret = cpufreq_register_notifier(&sp->freq_transition,
1973 ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]); 1946 CPUFREQ_TRANSITION_NOTIFIER);
1974 if (ret) 1947 if (unlikely(ret < 0))
1975 goto err_unreg; 1948 goto err_unreg;
1976 } else {
1977 for (i = 0; p && p->flags != 0; p++, i++) {
1978 ret = sci_probe_single(dev, i, p, &sci_ports[i]);
1979 if (ret)
1980 goto err_unreg;
1981 }
1982 }
1983 1949
1984#ifdef CONFIG_SH_STANDARD_BIOS 1950#ifdef CONFIG_SH_STANDARD_BIOS
1985 sh_bios_gdb_detach(); 1951 sh_bios_gdb_detach();
@@ -1994,28 +1960,20 @@ err_unreg:
1994 1960
1995static int sci_suspend(struct device *dev) 1961static int sci_suspend(struct device *dev)
1996{ 1962{
1997 struct sh_sci_priv *priv = dev_get_drvdata(dev); 1963 struct sci_port *sport = dev_get_drvdata(dev);
1998 struct sci_port *p;
1999 unsigned long flags;
2000 1964
2001 spin_lock_irqsave(&priv->lock, flags); 1965 if (sport)
2002 list_for_each_entry(p, &priv->ports, node) 1966 uart_suspend_port(&sci_uart_driver, &sport->port);
2003 uart_suspend_port(&sci_uart_driver, &p->port);
2004 spin_unlock_irqrestore(&priv->lock, flags);
2005 1967
2006 return 0; 1968 return 0;
2007} 1969}
2008 1970
2009static int sci_resume(struct device *dev) 1971static int sci_resume(struct device *dev)
2010{ 1972{
2011 struct sh_sci_priv *priv = dev_get_drvdata(dev); 1973 struct sci_port *sport = dev_get_drvdata(dev);
2012 struct sci_port *p;
2013 unsigned long flags;
2014 1974
2015 spin_lock_irqsave(&priv->lock, flags); 1975 if (sport)
2016 list_for_each_entry(p, &priv->ports, node) 1976 uart_resume_port(&sci_uart_driver, &sport->port);
2017 uart_resume_port(&sci_uart_driver, &p->port);
2018 spin_unlock_irqrestore(&priv->lock, flags);
2019 1977
2020 return 0; 1978 return 0;
2021} 1979}