aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/8250/8250_of.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial/8250/8250_of.c')
-rw-r--r--drivers/tty/serial/8250/8250_of.c94
1 files changed, 25 insertions, 69 deletions
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index d25ab1cd4295..1cbadafc6889 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -172,7 +172,8 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
{
const struct of_device_id *match;
struct of_serial_info *info;
- struct uart_port port;
+ struct uart_8250_port port8250;
+ u32 tx_threshold;
int port_type;
int ret;
@@ -188,41 +189,24 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
return -ENOMEM;
port_type = (unsigned long)match->data;
- ret = of_platform_serial_setup(ofdev, port_type, &port, info);
+ memset(&port8250, 0, sizeof(port8250));
+ ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info);
if (ret)
goto out;
- switch (port_type) {
- case PORT_8250 ... PORT_MAX_8250:
- {
- u32 tx_threshold;
- struct uart_8250_port port8250;
- memset(&port8250, 0, sizeof(port8250));
- port8250.port = port;
+ if (port8250.port.fifosize)
+ port8250.capabilities = UART_CAP_FIFO;
- if (port.fifosize)
- port8250.capabilities = UART_CAP_FIFO;
+ /* Check for TX FIFO threshold & set tx_loadsz */
+ if ((of_property_read_u32(ofdev->dev.of_node, "tx-threshold",
+ &tx_threshold) == 0) &&
+ (tx_threshold < port8250.port.fifosize))
+ port8250.tx_loadsz = port8250.port.fifosize - tx_threshold;
- /* Check for TX FIFO threshold & set tx_loadsz */
- if ((of_property_read_u32(ofdev->dev.of_node, "tx-threshold",
- &tx_threshold) == 0) &&
- (tx_threshold < port.fifosize))
- port8250.tx_loadsz = port.fifosize - tx_threshold;
+ if (of_property_read_bool(ofdev->dev.of_node, "auto-flow-control"))
+ port8250.capabilities |= UART_CAP_AFE;
- if (of_property_read_bool(ofdev->dev.of_node,
- "auto-flow-control"))
- port8250.capabilities |= UART_CAP_AFE;
-
- ret = serial8250_register_8250_port(&port8250);
- break;
- }
- default:
- /* need to add code for these */
- case PORT_UNKNOWN:
- dev_info(&ofdev->dev, "Unknown serial port found, ignored\n");
- ret = -ENODEV;
- break;
- }
+ ret = serial8250_register_8250_port(&port8250);
if (ret < 0)
goto out;
@@ -232,7 +216,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
return 0;
out:
kfree(info);
- irq_dispose_mapping(port.irq);
+ irq_dispose_mapping(port8250.port.irq);
return ret;
}
@@ -242,14 +226,8 @@ out:
static int of_platform_serial_remove(struct platform_device *ofdev)
{
struct of_serial_info *info = platform_get_drvdata(ofdev);
- switch (info->type) {
- case PORT_8250 ... PORT_MAX_8250:
- serial8250_unregister_port(info->line);
- break;
- default:
- /* need to add code for these */
- break;
- }
+
+ serial8250_unregister_port(info->line);
if (info->clk)
clk_disable_unprepare(info->clk);
@@ -258,18 +236,23 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
}
#ifdef CONFIG_PM_SLEEP
-static void of_serial_suspend_8250(struct of_serial_info *info)
+static int of_serial_suspend(struct device *dev)
{
+ struct of_serial_info *info = dev_get_drvdata(dev);
struct uart_8250_port *port8250 = serial8250_get_port(info->line);
struct uart_port *port = &port8250->port;
serial8250_suspend_port(info->line);
+
if (info->clk && (!uart_console(port) || console_suspend_enabled))
clk_disable_unprepare(info->clk);
+
+ return 0;
}
-static void of_serial_resume_8250(struct of_serial_info *info)
+static int of_serial_resume(struct device *dev)
{
+ struct of_serial_info *info = dev_get_drvdata(dev);
struct uart_8250_port *port8250 = serial8250_get_port(info->line);
struct uart_port *port = &port8250->port;
@@ -277,34 +260,6 @@ static void of_serial_resume_8250(struct of_serial_info *info)
clk_prepare_enable(info->clk);
serial8250_resume_port(info->line);
-}
-
-static int of_serial_suspend(struct device *dev)
-{
- struct of_serial_info *info = dev_get_drvdata(dev);
-
- switch (info->type) {
- case PORT_8250 ... PORT_MAX_8250:
- of_serial_suspend_8250(info);
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-static int of_serial_resume(struct device *dev)
-{
- struct of_serial_info *info = dev_get_drvdata(dev);
-
- switch (info->type) {
- case PORT_8250 ... PORT_MAX_8250:
- of_serial_resume_8250(info);
- break;
- default:
- break;
- }
return 0;
}
@@ -332,6 +287,7 @@ static const struct of_device_id of_platform_serial_table[] = {
.data = (void *)PORT_ALTR_16550_F128, },
{ .compatible = "mrvl,mmp-uart",
.data = (void *)PORT_XSCALE, },
+ { .compatible = "ti,da830-uart", .data = (void *)PORT_DA830, },
{ /* end of list */ },
};
MODULE_DEVICE_TABLE(of, of_platform_serial_table);