2017-11-06 17:11:51 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2007-02-13 20:35:38 +00:00
|
|
|
/*
|
|
|
|
* Serial Port driver for Open Firmware platform devices
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp.
|
|
|
|
*/
|
2014-11-11 07:09:05 +00:00
|
|
|
#include <linux/console.h>
|
2007-02-13 20:35:38 +00:00
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2007-02-13 20:35:38 +00:00
|
|
|
#include <linux/serial_core.h>
|
2012-04-10 21:10:53 +00:00
|
|
|
#include <linux/serial_reg.h>
|
2010-08-17 05:44:49 +00:00
|
|
|
#include <linux/of_address.h>
|
2010-11-17 23:50:23 +00:00
|
|
|
#include <linux/of_irq.h>
|
2008-05-23 06:32:54 +00:00
|
|
|
#include <linux/of_platform.h>
|
2017-08-16 20:55:36 +00:00
|
|
|
#include <linux/pm_runtime.h>
|
2012-10-22 15:58:01 +00:00
|
|
|
#include <linux/clk.h>
|
2017-05-29 09:57:52 +00:00
|
|
|
#include <linux/reset.h>
|
2007-02-13 20:35:38 +00:00
|
|
|
|
2015-12-18 13:00:49 +00:00
|
|
|
#include "8250.h"
|
2013-03-25 13:51:15 +00:00
|
|
|
|
2007-05-31 09:33:04 +00:00
|
|
|
struct of_serial_info {
|
2012-10-22 15:58:01 +00:00
|
|
|
struct clk *clk;
|
2017-05-29 09:57:52 +00:00
|
|
|
struct reset_control *rst;
|
2007-05-31 09:33:04 +00:00
|
|
|
int type;
|
|
|
|
int line;
|
|
|
|
};
|
|
|
|
|
2007-02-13 20:35:38 +00:00
|
|
|
/*
|
|
|
|
* Fill a struct uart_port for a given device node
|
|
|
|
*/
|
2012-11-19 18:21:50 +00:00
|
|
|
static int of_platform_serial_setup(struct platform_device *ofdev,
|
2020-02-28 13:31:06 +00:00
|
|
|
int type, struct uart_8250_port *up,
|
2012-10-22 15:58:01 +00:00
|
|
|
struct of_serial_info *info)
|
2007-02-13 20:35:38 +00:00
|
|
|
{
|
|
|
|
struct resource resource;
|
2010-04-13 23:12:29 +00:00
|
|
|
struct device_node *np = ofdev->dev.of_node;
|
2020-02-28 13:31:06 +00:00
|
|
|
struct uart_port *port = &up->port;
|
2011-06-30 18:39:12 +00:00
|
|
|
u32 clk, spd, prop;
|
2018-08-30 09:08:50 +00:00
|
|
|
int ret, irq;
|
2007-02-13 20:35:38 +00:00
|
|
|
|
|
|
|
memset(port, 0, sizeof *port);
|
2017-08-16 20:55:36 +00:00
|
|
|
|
|
|
|
pm_runtime_enable(&ofdev->dev);
|
|
|
|
pm_runtime_get_sync(&ofdev->dev);
|
|
|
|
|
2011-06-30 18:39:12 +00:00
|
|
|
if (of_property_read_u32(np, "clock-frequency", &clk)) {
|
2012-10-22 15:58:01 +00:00
|
|
|
|
|
|
|
/* Get clk rate through clk driver if present */
|
2015-05-25 05:57:43 +00:00
|
|
|
info->clk = devm_clk_get(&ofdev->dev, NULL);
|
2012-11-01 05:27:34 +00:00
|
|
|
if (IS_ERR(info->clk)) {
|
2017-08-16 20:55:36 +00:00
|
|
|
ret = PTR_ERR(info->clk);
|
2019-06-05 08:51:42 +00:00
|
|
|
if (ret != -EPROBE_DEFER)
|
|
|
|
dev_warn(&ofdev->dev,
|
|
|
|
"failed to get clock: %d\n", ret);
|
2017-08-16 20:55:36 +00:00
|
|
|
goto err_pmruntime;
|
2012-10-22 15:58:01 +00:00
|
|
|
}
|
|
|
|
|
2015-05-25 06:03:32 +00:00
|
|
|
ret = clk_prepare_enable(info->clk);
|
|
|
|
if (ret < 0)
|
2017-08-16 20:55:36 +00:00
|
|
|
goto err_pmruntime;
|
2015-05-25 06:03:32 +00:00
|
|
|
|
2012-10-22 15:58:01 +00:00
|
|
|
clk = clk_get_rate(info->clk);
|
2007-02-13 20:35:38 +00:00
|
|
|
}
|
2011-06-30 18:39:12 +00:00
|
|
|
/* If current-speed was set, then try not to change it. */
|
|
|
|
if (of_property_read_u32(np, "current-speed", &spd) == 0)
|
|
|
|
port->custom_divisor = clk / (16 * spd);
|
2007-02-13 20:35:38 +00:00
|
|
|
|
|
|
|
ret = of_address_to_resource(np, 0, &resource);
|
|
|
|
if (ret) {
|
|
|
|
dev_warn(&ofdev->dev, "invalid address\n");
|
2017-07-19 08:32:37 +00:00
|
|
|
goto err_unprepare;
|
2007-02-13 20:35:38 +00:00
|
|
|
}
|
|
|
|
|
2018-04-27 10:36:06 +00:00
|
|
|
port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_FIXED_PORT |
|
|
|
|
UPF_FIXED_TYPE;
|
2007-02-13 20:35:38 +00:00
|
|
|
spin_lock_init(&port->lock);
|
2008-04-02 23:22:19 +00:00
|
|
|
|
2018-04-27 10:36:06 +00:00
|
|
|
if (resource_type(&resource) == IORESOURCE_IO) {
|
|
|
|
port->iotype = UPIO_PORT;
|
|
|
|
port->iobase = resource.start;
|
|
|
|
} else {
|
|
|
|
port->mapbase = resource.start;
|
|
|
|
port->mapsize = resource_size(&resource);
|
|
|
|
|
|
|
|
/* Check for shifted address mapping */
|
|
|
|
if (of_property_read_u32(np, "reg-offset", &prop) == 0)
|
|
|
|
port->mapbase += prop;
|
|
|
|
|
|
|
|
port->iotype = UPIO_MEM;
|
|
|
|
if (of_property_read_u32(np, "reg-io-width", &prop) == 0) {
|
|
|
|
switch (prop) {
|
|
|
|
case 1:
|
|
|
|
port->iotype = UPIO_MEM;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
port->iotype = UPIO_MEM16;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
port->iotype = of_device_is_big_endian(np) ?
|
|
|
|
UPIO_MEM32BE : UPIO_MEM32;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n",
|
|
|
|
prop);
|
|
|
|
ret = -EINVAL;
|
2018-07-13 14:58:54 +00:00
|
|
|
goto err_unprepare;
|
2018-04-27 10:36:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
port->flags |= UPF_IOREMAP;
|
|
|
|
}
|
2008-04-02 23:22:19 +00:00
|
|
|
|
2019-02-24 12:00:53 +00:00
|
|
|
/* Compatibility with the deprecated pxa driver and 8250_pxa drivers. */
|
|
|
|
if (of_device_is_compatible(np, "mrvl,mmp-uart"))
|
|
|
|
port->regshift = 2;
|
|
|
|
|
2008-04-02 23:22:19 +00:00
|
|
|
/* Check for registers offset within the devices address range */
|
2011-06-30 18:39:12 +00:00
|
|
|
if (of_property_read_u32(np, "reg-shift", &prop) == 0)
|
|
|
|
port->regshift = prop;
|
2008-04-02 23:22:19 +00:00
|
|
|
|
2013-03-25 11:34:45 +00:00
|
|
|
/* Check for fifo size */
|
|
|
|
if (of_property_read_u32(np, "fifo-size", &prop) == 0)
|
|
|
|
port->fifosize = prop;
|
|
|
|
|
2014-12-05 19:21:57 +00:00
|
|
|
/* Check for a fixed line number */
|
|
|
|
ret = of_alias_get_id(np, "serial");
|
|
|
|
if (ret >= 0)
|
|
|
|
port->line = ret;
|
|
|
|
|
2018-08-30 09:08:50 +00:00
|
|
|
irq = of_irq_get(np, 0);
|
|
|
|
if (irq < 0) {
|
|
|
|
if (irq == -EPROBE_DEFER) {
|
|
|
|
ret = -EPROBE_DEFER;
|
|
|
|
goto err_unprepare;
|
|
|
|
}
|
|
|
|
/* IRQ support not mandatory */
|
|
|
|
irq = 0;
|
2018-07-13 15:01:19 +00:00
|
|
|
}
|
2011-06-27 12:32:34 +00:00
|
|
|
|
2018-08-30 09:08:50 +00:00
|
|
|
port->irq = irq;
|
|
|
|
|
2017-05-29 09:57:52 +00:00
|
|
|
info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
|
2017-12-27 05:21:05 +00:00
|
|
|
if (IS_ERR(info->rst)) {
|
|
|
|
ret = PTR_ERR(info->rst);
|
2018-08-30 09:08:50 +00:00
|
|
|
goto err_unprepare;
|
2017-12-27 05:21:05 +00:00
|
|
|
}
|
|
|
|
|
2017-05-29 09:57:52 +00:00
|
|
|
ret = reset_control_deassert(info->rst);
|
|
|
|
if (ret)
|
2018-08-30 09:08:50 +00:00
|
|
|
goto err_unprepare;
|
2017-05-29 09:57:52 +00:00
|
|
|
|
2007-02-13 20:35:38 +00:00
|
|
|
port->type = type;
|
2011-06-30 18:39:12 +00:00
|
|
|
port->uartclk = clk;
|
2012-07-17 16:08:31 +00:00
|
|
|
|
2017-08-20 16:51:55 +00:00
|
|
|
if (of_property_read_bool(np, "no-loopback-test"))
|
2012-07-17 16:08:31 +00:00
|
|
|
port->flags |= UPF_SKIP_TEST;
|
|
|
|
|
2007-02-13 20:35:38 +00:00
|
|
|
port->dev = &ofdev->dev;
|
2020-02-28 13:31:03 +00:00
|
|
|
port->rs485_config = serial8250_em485_config;
|
2020-02-28 13:31:06 +00:00
|
|
|
up->rs485_start_tx = serial8250_em485_start_tx;
|
|
|
|
up->rs485_stop_tx = serial8250_em485_stop_tx;
|
2007-02-13 20:35:38 +00:00
|
|
|
|
2014-10-16 19:48:21 +00:00
|
|
|
switch (type) {
|
|
|
|
case PORT_RT2880:
|
|
|
|
port->iotype = UPIO_AU;
|
|
|
|
break;
|
|
|
|
}
|
2012-04-10 21:10:53 +00:00
|
|
|
|
2015-10-07 22:31:21 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SERIAL_8250_FSL) &&
|
|
|
|
(of_device_is_compatible(np, "fsl,ns16550") ||
|
2019-12-13 00:06:04 +00:00
|
|
|
of_device_is_compatible(np, "fsl,16550-FIFO64"))) {
|
2015-10-07 22:31:21 +00:00
|
|
|
port->handle_irq = fsl8250_handle_irq;
|
2019-12-13 00:06:04 +00:00
|
|
|
port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
|
|
|
|
}
|
2015-10-07 22:31:21 +00:00
|
|
|
|
2007-02-13 20:35:38 +00:00
|
|
|
return 0;
|
2017-07-19 08:32:37 +00:00
|
|
|
err_unprepare:
|
2017-08-16 20:55:36 +00:00
|
|
|
clk_disable_unprepare(info->clk);
|
|
|
|
err_pmruntime:
|
|
|
|
pm_runtime_put_sync(&ofdev->dev);
|
|
|
|
pm_runtime_disable(&ofdev->dev);
|
2012-10-22 15:58:01 +00:00
|
|
|
return ret;
|
2007-02-13 20:35:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to register a serial port
|
|
|
|
*/
|
2012-11-19 18:21:50 +00:00
|
|
|
static int of_platform_serial_probe(struct platform_device *ofdev)
|
2007-02-13 20:35:38 +00:00
|
|
|
{
|
2007-05-31 09:33:04 +00:00
|
|
|
struct of_serial_info *info;
|
2017-01-25 22:19:01 +00:00
|
|
|
struct uart_8250_port port8250;
|
2019-04-30 18:45:59 +00:00
|
|
|
unsigned int port_type;
|
2017-01-25 22:19:01 +00:00
|
|
|
u32 tx_threshold;
|
2007-02-13 20:35:38 +00:00
|
|
|
int ret;
|
|
|
|
|
serial: 8250: of: Check for CONFIG_SERIAL_8250_BCM7271
Our SoC's have always had a NS16650A UART core and older SoC's would
have a compatible string of: 'compatible = ""ns16550a"' and use the
8250_of driver. Our newer SoC's have added enhancements to the base
core to add support for DMA and accurate high speed baud rates and use
this newer 8250_bcm7271 driver. The Device Tree node for our enhanced
UARTs has a compatible string of: 'compatible = "brcm,bcm7271-uart",
"ns16550a"''. With both drivers running and the link order setup so
that the 8250_bcm7217 driver is initialized before the 8250_of driver,
we should bind the 8250_bcm7271 driver to the enhanced UART, or for
upstream kernels that don't have the 8250_bcm7271 driver, we bind to
the 8250_of driver.
The problem is that when both the 8250_of and 8250_bcm7271 drivers
were running, occasionally the 8250_of driver would be bound to the
enhanced UART instead of the 8250_bcm7271 driver. This was happening
because we use SCMI based clocks which come up late in initialization
and cause probe DEFER's when the two drivers get their clocks.
Occasionally the SCMI clock would become ready between the 8250_bcm7271
probe and the 8250_of probe and the 8250_of driver would be bound. To
fix this we decided to config only our 8250_bcm7271 driver and added
"ns16665a0" to the compatible string so the driver would work on our
older system.
This commit has of_platform_serial_probe() check specifically for the
"brcm,bcm7271-uart" and whether its companion driver is enabled. If it
is the case, and the clock provider is not ready, we want to make sure
that when the 8250_bcm7271.c driver returns EPROBE_DEFER, we are not
getting the UART registered via 8250_of.c.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
Signed-off-by: Al Cooper <alcooperx@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20210423183206.3917725-1-f.fainelli@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-04-23 18:32:04 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SERIAL_8250_BCM7271) &&
|
|
|
|
of_device_is_compatible(ofdev->dev.of_node, "brcm,bcm7271-uart"))
|
|
|
|
return -ENODEV;
|
|
|
|
|
2019-04-30 18:45:59 +00:00
|
|
|
port_type = (unsigned long)of_device_get_match_data(&ofdev->dev);
|
|
|
|
if (port_type == PORT_UNKNOWN)
|
2011-02-23 04:10:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2017-08-20 16:51:55 +00:00
|
|
|
if (of_property_read_bool(ofdev->dev.of_node, "used-by-rtas"))
|
2007-02-13 20:35:38 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
2014-10-21 08:50:21 +00:00
|
|
|
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
2007-05-31 09:33:04 +00:00
|
|
|
if (info == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2017-01-25 22:19:01 +00:00
|
|
|
memset(&port8250, 0, sizeof(port8250));
|
2020-02-28 13:31:06 +00:00
|
|
|
ret = of_platform_serial_setup(ofdev, port_type, &port8250, info);
|
2007-02-13 20:35:38 +00:00
|
|
|
if (ret)
|
2017-07-19 08:32:37 +00:00
|
|
|
goto err_free;
|
2007-02-13 20:35:38 +00:00
|
|
|
|
2017-01-25 22:19:01 +00:00
|
|
|
if (port8250.port.fifosize)
|
|
|
|
port8250.capabilities = UART_CAP_FIFO;
|
2013-03-25 13:51:15 +00:00
|
|
|
|
2017-01-25 22:19:01 +00:00
|
|
|
/* 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;
|
2013-03-25 13:51:15 +00:00
|
|
|
|
2017-01-25 22:19:01 +00:00
|
|
|
if (of_property_read_bool(ofdev->dev.of_node, "auto-flow-control"))
|
|
|
|
port8250.capabilities |= UART_CAP_AFE;
|
2016-09-22 19:56:15 +00:00
|
|
|
|
2018-12-09 22:29:09 +00:00
|
|
|
if (of_property_read_u32(ofdev->dev.of_node,
|
|
|
|
"overrun-throttle-ms",
|
|
|
|
&port8250.overrun_backoff_time_ms) != 0)
|
|
|
|
port8250.overrun_backoff_time_ms = 0;
|
|
|
|
|
2017-01-25 22:19:01 +00:00
|
|
|
ret = serial8250_register_8250_port(&port8250);
|
2007-02-13 20:35:38 +00:00
|
|
|
if (ret < 0)
|
2017-07-19 08:32:37 +00:00
|
|
|
goto err_dispose;
|
2007-02-13 20:35:38 +00:00
|
|
|
|
2007-05-31 09:33:04 +00:00
|
|
|
info->type = port_type;
|
|
|
|
info->line = ret;
|
2013-05-23 10:39:36 +00:00
|
|
|
platform_set_drvdata(ofdev, info);
|
2007-02-13 20:35:38 +00:00
|
|
|
return 0;
|
2017-07-19 08:32:37 +00:00
|
|
|
err_dispose:
|
2017-01-25 22:19:01 +00:00
|
|
|
irq_dispose_mapping(port8250.port.irq);
|
2017-08-16 20:55:36 +00:00
|
|
|
pm_runtime_put_sync(&ofdev->dev);
|
|
|
|
pm_runtime_disable(&ofdev->dev);
|
|
|
|
clk_disable_unprepare(info->clk);
|
2017-07-19 08:32:37 +00:00
|
|
|
err_free:
|
|
|
|
kfree(info);
|
2007-02-13 20:35:38 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release a line
|
|
|
|
*/
|
2010-08-06 15:25:50 +00:00
|
|
|
static int of_platform_serial_remove(struct platform_device *ofdev)
|
2007-02-13 20:35:38 +00:00
|
|
|
{
|
2013-05-23 10:39:36 +00:00
|
|
|
struct of_serial_info *info = platform_get_drvdata(ofdev);
|
2017-01-25 22:19:01 +00:00
|
|
|
|
|
|
|
serial8250_unregister_port(info->line);
|
2012-10-22 15:58:01 +00:00
|
|
|
|
2017-05-29 09:57:52 +00:00
|
|
|
reset_control_assert(info->rst);
|
2017-08-16 20:55:36 +00:00
|
|
|
pm_runtime_put_sync(&ofdev->dev);
|
|
|
|
pm_runtime_disable(&ofdev->dev);
|
|
|
|
clk_disable_unprepare(info->clk);
|
2007-05-31 09:33:04 +00:00
|
|
|
kfree(info);
|
2007-02-13 20:35:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-11 07:09:05 +00:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2017-01-25 22:19:01 +00:00
|
|
|
static int of_serial_suspend(struct device *dev)
|
2014-11-11 07:09:05 +00:00
|
|
|
{
|
2017-01-25 22:19:01 +00:00
|
|
|
struct of_serial_info *info = dev_get_drvdata(dev);
|
2014-11-11 07:09:05 +00:00
|
|
|
struct uart_8250_port *port8250 = serial8250_get_port(info->line);
|
|
|
|
struct uart_port *port = &port8250->port;
|
|
|
|
|
|
|
|
serial8250_suspend_port(info->line);
|
2017-01-25 22:19:01 +00:00
|
|
|
|
2017-08-16 20:55:36 +00:00
|
|
|
if (!uart_console(port) || console_suspend_enabled) {
|
|
|
|
pm_runtime_put_sync(dev);
|
2014-11-11 07:09:05 +00:00
|
|
|
clk_disable_unprepare(info->clk);
|
2017-08-16 20:55:36 +00:00
|
|
|
}
|
2017-01-25 22:19:01 +00:00
|
|
|
return 0;
|
2014-11-11 07:09:05 +00:00
|
|
|
}
|
|
|
|
|
2017-01-25 22:19:01 +00:00
|
|
|
static int of_serial_resume(struct device *dev)
|
2014-11-11 07:09:05 +00:00
|
|
|
{
|
2017-01-25 22:19:01 +00:00
|
|
|
struct of_serial_info *info = dev_get_drvdata(dev);
|
2014-11-11 07:09:05 +00:00
|
|
|
struct uart_8250_port *port8250 = serial8250_get_port(info->line);
|
|
|
|
struct uart_port *port = &port8250->port;
|
|
|
|
|
2017-08-16 20:55:36 +00:00
|
|
|
if (!uart_console(port) || console_suspend_enabled) {
|
|
|
|
pm_runtime_get_sync(dev);
|
2014-11-11 07:09:05 +00:00
|
|
|
clk_prepare_enable(info->clk);
|
2017-08-16 20:55:36 +00:00
|
|
|
}
|
2014-11-11 07:09:05 +00:00
|
|
|
|
|
|
|
serial8250_resume_port(info->line);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
static SIMPLE_DEV_PM_OPS(of_serial_pm_ops, of_serial_suspend, of_serial_resume);
|
|
|
|
|
2007-02-13 20:35:38 +00:00
|
|
|
/*
|
|
|
|
* A few common types, add more as needed.
|
|
|
|
*/
|
2015-03-16 19:17:11 +00:00
|
|
|
static const struct of_device_id of_platform_serial_table[] = {
|
2011-02-23 02:12:21 +00:00
|
|
|
{ .compatible = "ns8250", .data = (void *)PORT_8250, },
|
|
|
|
{ .compatible = "ns16450", .data = (void *)PORT_16450, },
|
|
|
|
{ .compatible = "ns16550a", .data = (void *)PORT_16550A, },
|
|
|
|
{ .compatible = "ns16550", .data = (void *)PORT_16550, },
|
|
|
|
{ .compatible = "ns16750", .data = (void *)PORT_16750, },
|
|
|
|
{ .compatible = "ns16850", .data = (void *)PORT_16850, },
|
2012-06-11 19:57:14 +00:00
|
|
|
{ .compatible = "nxp,lpc3220-uart", .data = (void *)PORT_LPC3220, },
|
2014-10-16 19:48:21 +00:00
|
|
|
{ .compatible = "ralink,rt2880-uart", .data = (void *)PORT_RT2880, },
|
2019-01-27 01:04:04 +00:00
|
|
|
{ .compatible = "intel,xscale-uart", .data = (void *)PORT_XSCALE, },
|
2013-03-07 02:28:37 +00:00
|
|
|
{ .compatible = "altr,16550-FIFO32",
|
|
|
|
.data = (void *)PORT_ALTR_16550_F32, },
|
|
|
|
{ .compatible = "altr,16550-FIFO64",
|
|
|
|
.data = (void *)PORT_ALTR_16550_F64, },
|
|
|
|
{ .compatible = "altr,16550-FIFO128",
|
|
|
|
.data = (void *)PORT_ALTR_16550_F128, },
|
2017-08-20 17:17:56 +00:00
|
|
|
{ .compatible = "mediatek,mtk-btif",
|
|
|
|
.data = (void *)PORT_MTK_BTIF, },
|
2015-01-27 04:50:08 +00:00
|
|
|
{ .compatible = "mrvl,mmp-uart",
|
|
|
|
.data = (void *)PORT_XSCALE, },
|
2017-01-05 18:54:18 +00:00
|
|
|
{ .compatible = "ti,da830-uart", .data = (void *)PORT_DA830, },
|
2021-03-20 18:16:05 +00:00
|
|
|
{ .compatible = "nuvoton,wpcm450-uart", .data = (void *)PORT_NPCM, },
|
2018-03-05 11:47:38 +00:00
|
|
|
{ .compatible = "nuvoton,npcm750-uart", .data = (void *)PORT_NPCM, },
|
2007-02-13 20:35:38 +00:00
|
|
|
{ /* end of list */ },
|
|
|
|
};
|
2015-09-18 18:03:43 +00:00
|
|
|
MODULE_DEVICE_TABLE(of, of_platform_serial_table);
|
2007-02-13 20:35:38 +00:00
|
|
|
|
2011-02-23 04:10:26 +00:00
|
|
|
static struct platform_driver of_platform_serial_driver = {
|
2010-04-13 23:13:02 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "of_serial",
|
|
|
|
.of_match_table = of_platform_serial_table,
|
2016-01-21 07:59:53 +00:00
|
|
|
.pm = &of_serial_pm_ops,
|
2010-04-13 23:13:02 +00:00
|
|
|
},
|
2007-02-13 20:35:38 +00:00
|
|
|
.probe = of_platform_serial_probe,
|
|
|
|
.remove = of_platform_serial_remove,
|
|
|
|
};
|
|
|
|
|
2011-10-05 17:29:49 +00:00
|
|
|
module_platform_driver(of_platform_serial_driver);
|
2007-02-13 20:35:38 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("Serial Port driver for Open Firmware platform devices");
|