]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
serial_lpuart: add clock enable if CONFIG_CLK is defined
authorGiulio Benetti <giulio.benetti@benettiengineering.com>
Fri, 10 Jan 2020 14:47:05 +0000 (15:47 +0100)
committerStefano Babic <sbabic@denx.de>
Tue, 14 Jan 2020 21:54:00 +0000 (22:54 +0100)
This driver assumes that lpuart clock is already enabled before probing
but using DM only lpuart won't be automatically enabled so add
clk_enable() when probing if CONFIG_CLK is defined. If clock is not
found, because DM is not used, let's emit a warning and proceed, because
serial clock could also be already enabled by non DM code. If clock is
found but cna't be enabled then return with error.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
drivers/serial/serial_lpuart.c

index 4b0a964d1b0e79d23260301d47f26081243e84ed..b2ec56172e13d9c0633534f9aaf3bb61ec2a39ca 100644 (file)
@@ -483,6 +483,22 @@ static int lpuart_serial_pending(struct udevice *dev, bool input)
 
 static int lpuart_serial_probe(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(CLK)
+       struct clk per_clk;
+       int ret;
+
+       ret = clk_get_by_name(dev, "per", &per_clk);
+       if (!ret) {
+               ret = clk_enable(&per_clk);
+               if (ret) {
+                       dev_err(dev, "Failed to get per clk: %d\n", ret);
+                       return ret;
+               }
+       } else {
+               dev_warn(dev, "Failed to get per clk: %d\n",  ret);
+       }
+#endif
+
        if (is_lpuart32(dev))
                return _lpuart32_serial_init(dev);
        else