serial: 8250_dw: Add optional reset control support
authorChen-Yu Tsai <wens@csie.org>
Wed, 23 Jul 2014 15:33:06 +0000 (23:33 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 27 Jul 2014 18:07:07 +0000 (11:07 -0700)
The Allwinner A31 and A23 SoCs have a reset controller
maintaining the UART in reset by default.

This patch adds optional reset support to the driver.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt
drivers/tty/serial/8250/8250_dw.c

index 095ac7172ffe62bf08409897ec228075f4478b95..7f76214f728aa6028f133a94d04f183ccb3b1c38 100644 (file)
@@ -15,6 +15,7 @@ The supplying peripheral clock can also be handled, needing a second property
        Required elements: "baudclk", "apb_pclk"
 
 Optional properties:
+- resets : phandle to the parent reset controller.
 - reg-shift : quantity to shift the register offsets by.  If this property is
   not present then the register offsets are not shifted.
 - reg-io-width : the size (in bytes) of the IO accesses that should be
index affdcb192aed8c24f6851278e5a1e3ceb7092b0b..501db2f58fd24dc8dead3c8467123300252e8a03 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/acpi.h>
 #include <linux/clk.h>
+#include <linux/reset.h>
 #include <linux/pm_runtime.h>
 
 #include <asm/byteorder.h>
@@ -60,6 +61,7 @@ struct dw8250_data {
        int                     line;
        struct clk              *clk;
        struct clk              *pclk;
+       struct reset_control    *rst;
        struct uart_8250_dma    dma;
 };
 
@@ -383,6 +385,10 @@ static int dw8250_probe(struct platform_device *pdev)
                }
        }
 
+       data->rst = devm_reset_control_get_optional(&pdev->dev, NULL);
+       if (!IS_ERR(data->rst))
+               reset_control_deassert(data->rst);
+
        data->dma.rx_chan_id = -1;
        data->dma.tx_chan_id = -1;
        data->dma.rx_param = data;
@@ -426,6 +432,9 @@ static int dw8250_remove(struct platform_device *pdev)
 
        serial8250_unregister_port(data->line);
 
+       if (!IS_ERR(data->rst))
+               reset_control_assert(data->rst);
+
        if (!IS_ERR(data->pclk))
                clk_disable_unprepare(data->pclk);