Skip to content

Commit

Permalink
serial: 8250_of: Add reset support
Browse files Browse the repository at this point in the history
This adds the hooks for an optional reset controller in the 8250 device
tree node.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Joel Stanley authored and Greg Kroah-Hartman committed Jun 3, 2017
1 parent 71e0779 commit e2860e1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/serial/8250.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Optional properties:
property.
- tx-threshold: Specify the TX FIFO low water indication for parts with
programmable TX FIFO thresholds.
- resets : phandle + reset specifier pairs

Note:
* fsl,ns16550:
Expand Down
10 changes: 10 additions & 0 deletions drivers/tty/serial/8250/8250_of.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/clk.h>
#include <linux/reset.h>

#include "8250.h"

struct of_serial_info {
struct clk *clk;
struct reset_control *rst;
int type;
int line;
};
Expand Down Expand Up @@ -132,6 +134,13 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
}
}

info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL);
if (IS_ERR(info->rst))
goto out;
ret = reset_control_deassert(info->rst);
if (ret)
goto out;

port->type = type;
port->uartclk = clk;
port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
Expand Down Expand Up @@ -229,6 +238,7 @@ static int of_platform_serial_remove(struct platform_device *ofdev)

serial8250_unregister_port(info->line);

reset_control_assert(info->rst);
if (info->clk)
clk_disable_unprepare(info->clk);
kfree(info);
Expand Down

0 comments on commit e2860e1

Please sign in to comment.