diff options
author | Chunyan Zhang <chunyan.zhang@unisoc.com> | 2019-08-26 15:29:29 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-04 12:43:55 +0200 |
commit | 418319026ca3e7b7b8964fed8dbe7ba464c1d95a (patch) | |
tree | 956ac578e8fa2f1972af287aed5c3f3a227e4910 | |
parent | e85c9d6786e5afc93c3a29582cf42ee4b00b1e08 (diff) | |
download | linux-418319026ca3e7b7b8964fed8dbe7ba464c1d95a.tar.bz2 |
serial: sprd: keep console alive even if missing the 'enable' clock
The sprd serial console can work with only 26M fixed clock,
but the probe() is returning fail if the clock "enable" is not
configured in device tree.
This patch will fix the problem to let the uart device which is
used for console can be initialized even missing "enable" clock
configured in devicetree. We should make sure the debug function
as available as we can.
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Chunyan Zhang <zhang.lyra@gmail.com>
Reviewed-by: Baolin Wang <baolin.wang@linaro.org>
Tested-by: Baolin Wang <baolin.wang@linaro.org>
Link: https://lore.kernel.org/r/20190826072929.7696-4-zhang.lyra@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/serial/sprd_serial.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c index 6b9000f7adca..f8db5c8e4e39 100644 --- a/drivers/tty/serial/sprd_serial.c +++ b/drivers/tty/serial/sprd_serial.c @@ -1111,6 +1111,16 @@ static int sprd_remove(struct platform_device *dev) return 0; } +static bool sprd_uart_is_console(struct uart_port *uport) +{ + struct console *cons = sprd_uart_driver.cons; + + if (cons && cons->index >= 0 && cons->index == uport->line) + return true; + + return false; +} + static int sprd_clk_init(struct uart_port *uport) { struct clk *clk_uart, *clk_parent; @@ -1137,10 +1147,17 @@ static int sprd_clk_init(struct uart_port *uport) u->clk = devm_clk_get(uport->dev, "enable"); if (IS_ERR(u->clk)) { - if (PTR_ERR(u->clk) != -EPROBE_DEFER) - dev_err(uport->dev, "uart%d can't get enable clock\n", - uport->line); - return PTR_ERR(u->clk); + if (PTR_ERR(u->clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + dev_warn(uport->dev, "uart%d can't get enable clock\n", + uport->line); + + /* To keep console alive even if the error occurred */ + if (!sprd_uart_is_console(uport)) + return PTR_ERR(u->clk); + + u->clk = NULL; } return 0; |