diff options
author | Michal Simek <michal.simek@xilinx.com> | 2020-10-13 16:00:24 +0300 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2020-10-27 10:13:32 +0300 |
commit | 6c9662df49abeefffe9987cb51f47c41b8457d10 (patch) | |
tree | e61053378fd9694bd58a12d021f870957831e268 /drivers/serial/serial_pl01x.c | |
parent | a03b594738f8b5980fecda9946b1be31cc087e56 (diff) | |
download | u-boot-6c9662df49abeefffe9987cb51f47c41b8457d10.tar.xz |
serial: pl01x: Add error value checking
There also a need to check return values to make sure that clocks were
enabled and setup properly.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/serial/serial_pl01x.c')
-rw-r--r-- | drivers/serial/serial_pl01x.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 2772c25f1d..d9e35c6a2b 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -19,6 +19,7 @@ #include <watchdog.h> #include <asm/io.h> #include <serial.h> +#include <dm/device_compat.h> #include <dm/platform_data/serial_pl01x.h> #include <linux/compiler.h> #include "serial_pl01x_internal.h" @@ -362,8 +363,18 @@ int pl01x_serial_ofdata_to_platdata(struct udevice *dev) plat->clock = dev_read_u32_default(dev, "clock", CONFIG_PL011_CLOCK); ret = clk_get_by_index(dev, 0, &clk); if (!ret) { - clk_enable(&clk); + ret = clk_enable(&clk); + if (ret && ret != -ENOSYS) { + dev_err(dev, "failed to enable clock\n"); + return ret; + } + plat->clock = clk_get_rate(&clk); + if (IS_ERR_VALUE(plat->clock)) { + dev_err(dev, "failed to get rate\n"); + return plat->clock; + } + debug("%s: CLK %d\n", __func__, plat->clock); } plat->type = dev_get_driver_data(dev); plat->skip_init = dev_read_bool(dev, "skip-init"); |